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.
5 #ifndef ATOM_BROWSER_UI_WIN_NOTIFY_ICON_H_
6 #define ATOM_BROWSER_UI_WIN_NOTIFY_ICON_H_
13 #include "atom/browser/ui/tray_icon.h"
14 #include "base/compiler_specific.h"
15 #include "base/macros.h"
16 #include "base/win/scoped_gdi_object.h"
26 class NotifyIcon : public TrayIcon {
28 // Constructor which provides this icon's unique ID and messaging window.
29 NotifyIcon(NotifyIconHost* host, UINT id, HWND window, UINT message);
30 virtual ~NotifyIcon();
32 // Handles a click event from the user - if |left_button_click| is true and
33 // there is a registered observer, passes the click event to the observer,
34 // otherwise displays the context menu if there is one.
35 void HandleClickEvent(int modifiers,
36 bool left_button_click,
37 bool double_button_click);
39 // Re-creates the status tray icon now after the taskbar has been created.
42 UINT icon_id() const { return icon_id_; }
43 HWND window() const { return window_; }
44 UINT message_id() const { return message_id_; }
46 // Overridden from TrayIcon:
47 void SetImage(HICON image) override;
48 void SetPressedImage(HICON image) override;
49 void SetToolTip(const std::string& tool_tip) override;
50 void DisplayBalloon(HICON icon,
51 const base::string16& title,
52 const base::string16& contents) override;
53 void PopUpContextMenu(const gfx::Point& pos,
54 AtomMenuModel* menu_model) override;
55 void SetContextMenu(AtomMenuModel* menu_model) override;
56 gfx::Rect GetBounds() override;
59 void InitIconData(NOTIFYICONDATA* icon_data);
61 // The tray that owns us. Weak.
62 NotifyIconHost* host_;
64 // The unique ID corresponding to this icon.
67 // Window used for processing messages from this icon.
70 // The message identifier used for status icon messages.
73 // The currently-displayed icon for the window.
74 base::win::ScopedHICON icon_;
77 AtomMenuModel* menu_model_;
79 DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
84 #endif // ATOM_BROWSER_UI_WIN_NOTIFY_ICON_H_