]>
Commit | Line | Data |
---|---|---|
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 | // RCS-ID: $Id$ | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _WX_TASKBAR_H_BASE_ | |
13 | #define _WX_TASKBAR_H_BASE_ | |
14 | ||
15 | #include "wx/defs.h" | |
16 | ||
17 | #if wxUSE_TASKBARICON | |
18 | ||
19 | #include "wx/event.h" | |
20 | ||
21 | class WXDLLIMPEXP_FWD_ADV wxTaskBarIconEvent; | |
22 | ||
23 | // ---------------------------------------------------------------------------- | |
24 | // wxTaskBarIconBase: define wxTaskBarIcon interface | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | class WXDLLIMPEXP_ADV wxTaskBarIconBase : public wxEvtHandler | |
28 | { | |
29 | public: | |
30 | wxTaskBarIconBase() { } | |
31 | ||
32 | // Operations: | |
33 | virtual bool SetIcon(const wxIcon& icon, | |
34 | const wxString& tooltip = wxEmptyString) = 0; | |
35 | virtual bool RemoveIcon() = 0; | |
36 | virtual bool PopupMenu(wxMenu *menu) = 0; | |
37 | ||
38 | // delayed destruction (similarly to wxWindow::Destroy()) | |
39 | void Destroy(); | |
40 | ||
41 | protected: | |
42 | // creates menu to be displayed when user clicks on the icon | |
43 | virtual wxMenu *CreatePopupMenu() { return NULL; } | |
44 | ||
45 | private: | |
46 | // default events handling, calls CreatePopupMenu: | |
47 | void OnRightButtonDown(wxTaskBarIconEvent& event); | |
48 | ||
49 | DECLARE_EVENT_TABLE() | |
50 | DECLARE_NO_COPY_CLASS(wxTaskBarIconBase) | |
51 | }; | |
52 | ||
53 | ||
54 | // ---------------------------------------------------------------------------- | |
55 | // now include the actual class declaration | |
56 | // ---------------------------------------------------------------------------- | |
57 | ||
58 | #if defined(__WXPALMOS__) | |
59 | #include "wx/palmos/taskbar.h" | |
60 | #elif defined(__WXMSW__) | |
61 | #include "wx/msw/taskbar.h" | |
62 | #elif defined(__WXGTK__) || defined(__WXX11__) || defined(__WXMOTIF__) | |
63 | #include "wx/unix/taskbarx11.h" | |
64 | #elif defined (__WXMAC__) | |
65 | #include "wx/osx/taskbarosx.h" | |
66 | #elif defined (__WXCOCOA__) | |
67 | #include "wx/cocoa/taskbar.h" | |
68 | #endif | |
69 | ||
70 | // ---------------------------------------------------------------------------- | |
71 | // wxTaskBarIcon events | |
72 | // ---------------------------------------------------------------------------- | |
73 | ||
74 | class WXDLLIMPEXP_ADV wxTaskBarIconEvent : public wxEvent | |
75 | { | |
76 | public: | |
77 | wxTaskBarIconEvent(wxEventType evtType, wxTaskBarIcon *tbIcon) | |
78 | : wxEvent(wxID_ANY, evtType) | |
79 | { | |
80 | SetEventObject(tbIcon); | |
81 | } | |
82 | ||
83 | virtual wxEvent *Clone() const { return new wxTaskBarIconEvent(*this); } | |
84 | ||
85 | private: | |
86 | DECLARE_NO_ASSIGN_CLASS(wxTaskBarIconEvent) | |
87 | }; | |
88 | ||
89 | typedef void (wxEvtHandler::*wxTaskBarIconEventFunction)(wxTaskBarIconEvent&); | |
90 | ||
91 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_MOVE; | |
92 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_LEFT_DOWN; | |
93 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_LEFT_UP; | |
94 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_RIGHT_DOWN; | |
95 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_RIGHT_UP; | |
96 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_LEFT_DCLICK; | |
97 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_RIGHT_DCLICK; | |
98 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_BALLOON_TIMEOUT; | |
99 | extern WXDLLIMPEXP_ADV const wxEventType wxEVT_TASKBAR_BALLOON_CLICK; | |
100 | ||
101 | #define wxTaskBarIconEventHandler(func) \ | |
102 | (wxObjectEventFunction)(wxEventFunction)wxStaticCastEvent(wxTaskBarIconEventFunction, &func) | |
103 | ||
104 | #define wx__DECLARE_TASKBAREVT(evt, fn) \ | |
105 | wx__DECLARE_EVT0(wxEVT_TASKBAR_ ## evt, wxTaskBarIconEventHandler(fn)) | |
106 | ||
107 | #define EVT_TASKBAR_MOVE(fn) wx__DECLARE_TASKBAREVT(MOVE, fn) | |
108 | #define EVT_TASKBAR_LEFT_DOWN(fn) wx__DECLARE_TASKBAREVT(LEFT_DOWN, fn) | |
109 | #define EVT_TASKBAR_LEFT_UP(fn) wx__DECLARE_TASKBAREVT(LEFT_UP, fn) | |
110 | #define EVT_TASKBAR_RIGHT_DOWN(fn) wx__DECLARE_TASKBAREVT(RIGHT_DOWN, fn) | |
111 | #define EVT_TASKBAR_RIGHT_UP(fn) wx__DECLARE_TASKBAREVT(RIGHT_UP, fn) | |
112 | #define EVT_TASKBAR_LEFT_DCLICK(fn) wx__DECLARE_TASKBAREVT(LEFT_DCLICK, fn) | |
113 | #define EVT_TASKBAR_RIGHT_DCLICK(fn) wx__DECLARE_TASKBAREVT(RIGHT_DCLICK, fn) | |
114 | ||
115 | // taskbar menu is shown on right button press under all platforms except MSW | |
116 | // where it's shown on right button release, using this event type and macro | |
117 | // allows to write code which works correctly on all platforms | |
118 | #ifdef __WXMSW__ | |
119 | #define wxEVT_TASKBAR_CLICK wxEVT_TASKBAR_RIGHT_UP | |
120 | #else | |
121 | #define wxEVT_TASKBAR_CLICK wxEVT_TASKBAR_RIGHT_DOWN | |
122 | #endif | |
123 | #define EVT_TASKBAR_CLICK(fn) wx__DECLARE_TASKBAREVT(CLICK, fn) | |
124 | ||
125 | // these events are currently generated only under wxMSW and only after (MSW- | |
126 | // specific) ShowBalloon() had been called, don't use them in portable code | |
127 | #define EVT_TASKBAR_BALLOON_TIMEOUT(fn) \ | |
128 | wx__DECLARE_TASKBAREVT(BALLOON_TIMEOUT, fn) | |
129 | #define EVT_TASKBAR_BALLOON_CLICK(fn) \ | |
130 | wx__DECLARE_TASKBAREVT(BALLOON_CLICK, fn) | |
131 | ||
132 | #endif // wxUSE_TASKBARICON | |
133 | ||
134 | #endif // _WX_TASKBAR_H_BASE_ |