]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: taskbar.h | |
e54c96f1 | 3 | // Purpose: interface of wxTaskBarIcon |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
6 | // Licence: wxWindows license | |
7 | ///////////////////////////////////////////////////////////////////////////// | |
8 | ||
9 | /** | |
10 | @class wxTaskBarIcon | |
7c913512 | 11 | |
c6cf894a FM |
12 | This class represents a taskbar icon. |
13 | A taskbar icon is an icon that appears in the 'system tray' and responds to | |
14 | mouse clicks, optionally with a tooltip above it to help provide information. | |
15 | ||
16 | @section taskbaricon_xnote X Window System Note | |
17 | Under X Window System, the window manager must support either the | |
4876436a | 18 | "System Tray Protocol" (see http://freedesktop.org/wiki/Specifications/systemtray-spec) |
c6cf894a FM |
19 | by freedesktop.org (WMs used by modern desktop environments such as GNOME >= 2, |
20 | KDE >= 3 and XFCE >= 4 all do) or the older methods used in GNOME 1.2 and KDE 1 and 2. | |
21 | ||
22 | If it doesn't, the icon will appear as a toplevel window on user's desktop. | |
23 | Because not all window managers have system tray, there's no guarantee that | |
24 | wxTaskBarIcon will work correctly under X Window System and so the applications | |
25 | should use it only as an optional component of their user interface. | |
26 | The user should be required to explicitly enable the taskbar icon on Unix, | |
27 | it shouldn't be on by default. | |
28 | ||
29 | @beginEventTable{wxTaskBarIconEvent} | |
30 | Note that not all ports are required to send these events and so it's better | |
31 | to override wxTaskBarIcon::CreatePopupMenu() if all that the application does | |
32 | is that it shows a popup menu in reaction to mouse click. | |
33 | @event{EVT_TASKBAR_MOVE(func)} | |
34 | Process a wxEVT_TASKBAR_MOVE event. | |
35 | @event{EVT_TASKBAR_LEFT_DOWN(func)} | |
36 | Process a wxEVT_TASKBAR_LEFT_DOWN event. | |
37 | @event{EVT_TASKBAR_LEFT_UP(func)} | |
38 | Process a wxEVT_TASKBAR_LEFT_UP event. | |
39 | @event{EVT_TASKBAR_RIGHT_DOWN(func)} | |
40 | Process a wxEVT_TASKBAR_RIGHT_DOWN event. | |
41 | @event{EVT_TASKBAR_RIGHT_UP(func)} | |
42 | Process a wxEVT_TASKBAR_RIGHT_UP event. | |
43 | @event{EVT_TASKBAR_LEFT_DCLICK(func)} | |
44 | Process a wxEVT_TASKBAR_LEFT_DCLICK event. | |
45 | @event{EVT_TASKBAR_RIGHT_DCLICK(func)} | |
46 | Process a wxEVT_TASKBAR_RIGHT_DCLICK event. | |
47 | @event{EVT_TASKBAR_CLICK(func)} | |
48 | This is a synonym for either EVT_TASKBAR_RIGHT_DOWN or UP depending on | |
49 | the platform, use this event macro to catch the event which should result | |
50 | in the menu being displayed on the current platform. | |
51 | @endEventTable | |
7c913512 | 52 | |
23324ae1 | 53 | @library{wxadv} |
c6cf894a | 54 | @category{misc} |
23324ae1 FM |
55 | */ |
56 | class wxTaskBarIcon : public wxEvtHandler | |
57 | { | |
58 | public: | |
59 | /** | |
60 | Default constructor. | |
61 | */ | |
62 | wxTaskBarIcon(); | |
63 | ||
64 | /** | |
65 | Destroys the wxTaskBarIcon object, removing the icon if not already removed. | |
66 | */ | |
adaaa686 | 67 | virtual ~wxTaskBarIcon(); |
23324ae1 | 68 | |
23324ae1 | 69 | /** |
c6cf894a FM |
70 | This method is similar to wxWindow::Destroy and can be used to schedule |
71 | the task bar icon object for the delayed destruction: it will be deleted | |
72 | during the next event loop iteration, which allows the task bar | |
23324ae1 FM |
73 | icon to process any pending events for it before being destroyed. |
74 | */ | |
75 | void Destroy(); | |
76 | ||
77 | /** | |
78 | Returns @true if SetIcon() was called with no subsequent RemoveIcon(). | |
79 | */ | |
adaaa686 | 80 | bool IsIconInstalled() const; |
23324ae1 FM |
81 | |
82 | /** | |
83 | Returns @true if the object initialized successfully. | |
84 | */ | |
adaaa686 | 85 | bool IsOk() const; |
23324ae1 FM |
86 | |
87 | /** | |
c6cf894a FM |
88 | Pops up a menu at the current mouse position. |
89 | The events can be handled by a class derived from wxTaskBarIcon. | |
90 | ||
91 | @note | |
92 | It is recommended to override CreatePopupMenu() callback instead of | |
93 | calling this method from event handler, because some ports (e.g. wxCocoa) | |
94 | may not implement PopupMenu() and mouse click events at all. | |
23324ae1 | 95 | */ |
adaaa686 | 96 | virtual bool PopupMenu(wxMenu* menu); |
23324ae1 FM |
97 | |
98 | /** | |
99 | Removes the icon previously set with SetIcon(). | |
100 | */ | |
adaaa686 | 101 | virtual bool RemoveIcon(); |
23324ae1 FM |
102 | |
103 | /** | |
104 | Sets the icon, and optional tooltip text. | |
105 | */ | |
43c48e1e FM |
106 | virtual bool SetIcon(const wxIcon& icon, |
107 | const wxString& tooltip = wxEmptyString); | |
cf78bdcb VS |
108 | |
109 | /** | |
110 | Returns true if system tray is available in the desktop environment the | |
111 | app runs under. | |
112 | ||
113 | On Windows and Mac OS X, the tray is always available and this function | |
114 | simply returns true. | |
115 | ||
116 | On Unix, X11 environment may or may not provide the tray, depending on | |
117 | user's desktop environment. Most modern desktops support the tray via | |
118 | the System Tray Protocol by freedesktop.org | |
119 | (http://freedesktop.org/wiki/Specifications/systemtray-spec). | |
120 | ||
121 | @note Tray availability may change during application's lifetime | |
122 | under X11 and so applications shouldn't cache the result. | |
123 | ||
124 | @note wxTaskBarIcon supports older GNOME 1.2 and KDE 1/2 methods of | |
125 | adding icons to tray, but they are unreliable and this method | |
126 | doesn't detect them. | |
127 | ||
128 | @since 2.9.0 | |
129 | */ | |
130 | static bool IsAvailable(); | |
5e6e278d FM |
131 | |
132 | protected: | |
133 | ||
134 | /** | |
135 | This method is called by the library when the user requests popup menu | |
136 | (on Windows and Unix platforms, this is when the user right-clicks the icon). | |
137 | ||
138 | Override this function in order to provide popup menu associated with the icon. | |
139 | If CreatePopupMenu() returns @NULL (this happens by default), no menu is shown, | |
140 | otherwise the menu is displayed and then deleted by the library as soon as the | |
141 | user dismisses it. | |
142 | ||
143 | The events can be handled by a class derived from wxTaskBarIcon. | |
144 | */ | |
145 | virtual wxMenu* CreatePopupMenu(); | |
23324ae1 | 146 | }; |
e54c96f1 | 147 |