tray_icon_cocoa.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 PopUpOnUI(AtomMenuModel* menu_model);
  25. void PopUpContextMenu(const gfx::Point& pos,
  26. AtomMenuModel* menu_model) override;
  27. void SetContextMenu(AtomMenuModel* menu_model) override;
  28. gfx::Rect GetBounds() override;
  29. protected:
  30. // AtomMenuModel::Observer:
  31. void OnMenuWillClose() override;
  32. private:
  33. // Atom custom view for NSStatusItem.
  34. base::scoped_nsobject<StatusItemView> status_item_view_;
  35. // Status menu shown when right-clicking the system icon.
  36. base::scoped_nsobject<AtomMenuController> menu_;
  37. // Used for unregistering observer.
  38. AtomMenuModel* menu_model_ = nullptr; // weak ref.
  39. base::WeakPtrFactory<TrayIconCocoa> weak_factory_;
  40. DISALLOW_COPY_AND_ASSIGN(TrayIconCocoa);
  41. };
  42. } // namespace atom
  43. #endif // ATOM_BROWSER_UI_TRAY_ICON_COCOA_H_