tray_icon_cocoa.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright (c) 2014 GitHub, Inc.
  2. // Use of this source code is governed by the MIT license that can be
  3. // found in the LICENSE file.
  4. #ifndef ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_
  5. #define ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_
  6. #import <Cocoa/Cocoa.h>
  7. #include <string>
  8. #include "atom/browser/ui/tray_icon.h"
  9. #include "base/mac/scoped_nsobject.h"
  10. @class AtomMenuController;
  11. @class StatusItemView;
  12. namespace atom {
  13. class TrayIconCocoa : public TrayIcon, public AtomMenuModel::Observer {
  14. public:
  15. TrayIconCocoa();
  16. ~TrayIconCocoa() override;
  17. void SetImage(const gfx::Image& image) override;
  18. void SetPressedImage(const gfx::Image& image) override;
  19. void SetToolTip(const std::string& tool_tip) override;
  20. void SetTitle(const std::string& title) override;
  21. void SetHighlightMode(TrayIcon::HighlightMode mode) override;
  22. void SetIgnoreDoubleClickEvents(bool ignore) override;
  23. bool GetIgnoreDoubleClickEvents() override;
  24. void PopUpContextMenu(const gfx::Point& pos,
  25. AtomMenuModel* menu_model) override;
  26. void SetContextMenu(AtomMenuModel* menu_model) override;
  27. gfx::Rect GetBounds() override;
  28. protected:
  29. // AtomMenuModel::Observer:
  30. void OnMenuWillClose() override;
  31. private:
  32. // Atom custom view for NSStatusItem.
  33. base::scoped_nsobject<StatusItemView> status_item_view_;
  34. // Status menu shown when right-clicking the system icon.
  35. base::scoped_nsobject<AtomMenuController> menu_;
  36. // Used for unregistering observer.
  37. AtomMenuModel* menu_model_ = nullptr; // weak ref.
  38. DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);
  39. };
  40. } // namespace atom
  41. #endif // ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_