Sort includes alphabetically
[platform/framework/web/crosswalk-tizen.git] / atom / browser / ui / win / notify_icon.h
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
5 #ifndef ATOM_BROWSER_UI_WIN_NOTIFY_ICON_H_
6 #define ATOM_BROWSER_UI_WIN_NOTIFY_ICON_H_
7
8 #include <shellapi.h>
9 #include <windows.h>
10
11 #include <string>
12
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"
17
18 namespace gfx {
19 class Point;
20 }
21
22 namespace atom {
23
24 class NotifyIconHost;
25
26 class NotifyIcon : public TrayIcon {
27  public:
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();
31
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);
38
39   // Re-creates the status tray icon now after the taskbar has been created.
40   void ResetIcon();
41
42   UINT icon_id() const { return icon_id_; }
43   HWND window() const { return window_; }
44   UINT message_id() const { return message_id_; }
45
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;
57
58  private:
59   void InitIconData(NOTIFYICONDATA* icon_data);
60
61   // The tray that owns us.  Weak.
62   NotifyIconHost* host_;
63
64   // The unique ID corresponding to this icon.
65   UINT icon_id_;
66
67   // Window used for processing messages from this icon.
68   HWND window_;
69
70   // The message identifier used for status icon messages.
71   UINT message_id_;
72
73   // The currently-displayed icon for the window.
74   base::win::ScopedHICON icon_;
75
76   // The context menu.
77   AtomMenuModel* menu_model_;
78
79   DISALLOW_COPY_AND_ASSIGN(NotifyIcon);
80 };
81
82 }  // namespace atom
83
84 #endif  // ATOM_BROWSER_UI_WIN_NOTIFY_ICON_H_