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