]> git.saurik.com Git - wxWidgets.git/blob - include/wx/taskbar.h
using Run of base class
[wxWidgets.git] / include / wx / taskbar.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/taskbar.h
3 // Purpose: wxTaskBarIcon base header and class
4 // Author: Julian Smart
5 // Modified by:
6 // Created:
7 // Copyright: (c) Julian Smart
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_TASKBAR_H_BASE_
12 #define _WX_TASKBAR_H_BASE_
13
14 #include "wx/defs.h"
15
16 #if wxUSE_TASKBARICON
17
18 #include "wx/event.h"
19
20 class WXDLLIMPEXP_FWD_ADV wxTaskBarIconEvent;
21
22 // ----------------------------------------------------------------------------
23
24 // type of taskbar item to create. Only applicable in wxOSX_COCOA
25 enum wxTaskBarIconType
26 {
27 wxTBI_DOCK,
28 wxTBI_CUSTOM_STATUSITEM,
29 #if defined(wxOSX_USE_COCOA) && wxOSX_USE_COCOA
30 wxTBI_DEFAULT_TYPE = wxTBI_CUSTOM_STATUSITEM
31 #else
32 wxTBI_DEFAULT_TYPE = wxTBI_DOCK
33 #endif
34 };
35
36
37 // ----------------------------------------------------------------------------
38 // wxTaskBarIconBase: define wxTaskBarIcon interface
39 // ----------------------------------------------------------------------------
40
41 class WXDLLIMPEXP_ADV wxTaskBarIconBase : public wxEvtHandler
42 {
43 public:
44 wxTaskBarIconBase() { }
45
46 #if defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__)
47 static bool IsAvailable();
48 #else
49 static bool IsAvailable() { return true; }
50 #endif
51
52 // Operations:
53 virtual bool SetIcon(const wxIcon& icon,
54 const wxString& tooltip = wxEmptyString) = 0;
55 virtual bool RemoveIcon() = 0;
56 virtual bool PopupMenu(wxMenu *menu) = 0;
57
58 // delayed destruction (similarly to wxWindow::Destroy())
59 void Destroy();
60
61 protected:
62 // creates menu to be displayed when user clicks on the icon
63 virtual wxMenu *CreatePopupMenu() { return NULL; }
64
65 private:
66 // default events handling, calls CreatePopupMenu:
67 void OnRightButtonDown(wxTaskBarIconEvent& event);
68
69 DECLARE_EVENT_TABLE()
70 wxDECLARE_NO_COPY_CLASS(wxTaskBarIconBase);
71 };
72
73
74 // ----------------------------------------------------------------------------
75 // now include the actual class declaration
76 // ----------------------------------------------------------------------------
77
78 #if defined(__WXMSW__)
79 #include "wx/msw/taskbar.h"
80 #elif defined(__WXGTK20__)
81 #include "wx/gtk/taskbar.h"
82 #elif defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__)
83 #include "wx/unix/taskbarx11.h"
84 #elif defined (__WXMAC__)
85 #include "wx/osx/taskbarosx.h"
86 #elif defined (__WXCOCOA__)
87 #include "wx/cocoa/taskbar.h"
88 #endif
89
90 // ----------------------------------------------------------------------------
91 // wxTaskBarIcon events
92 // ----------------------------------------------------------------------------
93
94 class WXDLLIMPEXP_ADV wxTaskBarIconEvent : public wxEvent
95 {
96 public:
97 wxTaskBarIconEvent(wxEventType evtType, wxTaskBarIcon *tbIcon)
98 : wxEvent(wxID_ANY, evtType)
99 {
100 SetEventObject(tbIcon);
101 }
102
103 virtual wxEvent *Clone() const { return new wxTaskBarIconEvent(*this); }
104
105 private:
106 wxDECLARE_NO_ASSIGN_CLASS(wxTaskBarIconEvent);
107 };
108
109 typedef void (wxEvtHandler::*wxTaskBarIconEventFunction)(wxTaskBarIconEvent&);
110
111 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_MOVE, wxTaskBarIconEvent );
112 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_LEFT_DOWN, wxTaskBarIconEvent );
113 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_LEFT_UP, wxTaskBarIconEvent );
114 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_RIGHT_DOWN, wxTaskBarIconEvent );
115 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_RIGHT_UP, wxTaskBarIconEvent );
116 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_LEFT_DCLICK, wxTaskBarIconEvent );
117 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_RIGHT_DCLICK, wxTaskBarIconEvent );
118 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_BALLOON_TIMEOUT, wxTaskBarIconEvent );
119 wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_ADV, wxEVT_TASKBAR_BALLOON_CLICK, wxTaskBarIconEvent );
120
121 #define wxTaskBarIconEventHandler(func) \
122 wxEVENT_HANDLER_CAST(wxTaskBarIconEventFunction, func)
123
124 #define wx__DECLARE_TASKBAREVT(evt, fn) \
125 wx__DECLARE_EVT0(wxEVT_TASKBAR_ ## evt, wxTaskBarIconEventHandler(fn))
126
127 #define EVT_TASKBAR_MOVE(fn) wx__DECLARE_TASKBAREVT(MOVE, fn)
128 #define EVT_TASKBAR_LEFT_DOWN(fn) wx__DECLARE_TASKBAREVT(LEFT_DOWN, fn)
129 #define EVT_TASKBAR_LEFT_UP(fn) wx__DECLARE_TASKBAREVT(LEFT_UP, fn)
130 #define EVT_TASKBAR_RIGHT_DOWN(fn) wx__DECLARE_TASKBAREVT(RIGHT_DOWN, fn)
131 #define EVT_TASKBAR_RIGHT_UP(fn) wx__DECLARE_TASKBAREVT(RIGHT_UP, fn)
132 #define EVT_TASKBAR_LEFT_DCLICK(fn) wx__DECLARE_TASKBAREVT(LEFT_DCLICK, fn)
133 #define EVT_TASKBAR_RIGHT_DCLICK(fn) wx__DECLARE_TASKBAREVT(RIGHT_DCLICK, fn)
134
135 // taskbar menu is shown on right button press under all platforms except MSW
136 // where it's shown on right button release, using this event type and macro
137 // allows to write code which works correctly on all platforms
138 #ifdef __WXMSW__
139 #define wxEVT_TASKBAR_CLICK wxEVT_TASKBAR_RIGHT_UP
140 #else
141 #define wxEVT_TASKBAR_CLICK wxEVT_TASKBAR_RIGHT_DOWN
142 #endif
143 #define EVT_TASKBAR_CLICK(fn) wx__DECLARE_TASKBAREVT(CLICK, fn)
144
145 // these events are currently generated only under wxMSW and only after (MSW-
146 // specific) ShowBalloon() had been called, don't use them in portable code
147 #define EVT_TASKBAR_BALLOON_TIMEOUT(fn) \
148 wx__DECLARE_TASKBAREVT(BALLOON_TIMEOUT, fn)
149 #define EVT_TASKBAR_BALLOON_CLICK(fn) \
150 wx__DECLARE_TASKBAREVT(BALLOON_CLICK, fn)
151
152 #endif // wxUSE_TASKBARICON
153
154 #endif // _WX_TASKBAR_H_BASE_