// Operations
bool SetIcon(const wxIcon& icon, const wxString& tooltip = "");
bool RemoveIcon(void);
+ bool PopupMenu(wxMenu *menu); //, int x, int y);
// Overridables
virtual void OnMouseMove(wxEvent&);
static bool sm_registeredClass;
static unsigned int sm_taskbarMsg;
+ // non-virtual default event handlers to forward events to the virtuals
+ void _OnMouseMove(wxEvent&);
+ void _OnLButtonDown(wxEvent&);
+ void _OnLButtonUp(wxEvent&);
+ void _OnRButtonDown(wxEvent&);
+ void _OnRButtonUp(wxEvent&);
+ void _OnLButtonDClick(wxEvent&);
+ void _OnRButtonDClick(wxEvent&);
+
+
DECLARE_EVENT_TABLE()
};
#define EVT_TASKBAR_LEFT_DCLICK(fn) { wxEVT_TASKBAR_LEFT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
#define EVT_TASKBAR_RIGHT_DCLICK(fn) { wxEVT_TASKBAR_RIGHT_DCLICK, -1, -1, (wxObjectEventFunction) (wxEventFunction) &fn, NULL },
+
#endif
// _TASKBAR_H_
return TRUE;
}
+
BEGIN_EVENT_TABLE(MyDialog, wxDialog)
EVT_BUTTON(wxID_OK, MyDialog::OnOK)
EVT_BUTTON(wxID_EXIT, MyDialog::OnExit)
END_EVENT_TABLE()
+
+
MyDialog::MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size, const long windowStyle):
wxDialog(parent, id, title, pos, size, windowStyle)
wxStaticText* stat = new wxStaticText(this, -1, "Press OK to hide me, Exit to quit.",
wxPoint(10, 20));
-
+
wxStaticText* stat2 = new wxStaticText(this, -1, "Double-click on the taskbar icon to show me again.",
wxPoint(10, 40));
this->Centre(wxBOTH);
}
+
+enum {
+ PU_RESTORE = 10001,
+ PU_EXIT,
+};
+
+
+BEGIN_EVENT_TABLE(MyTaskBarIcon, wxTaskBarIcon)
+ EVT_MENU(PU_RESTORE, MyTaskBarIcon::OnMenuRestore)
+ EVT_MENU(PU_EXIT, MyTaskBarIcon::OnMenuExit)
+END_EVENT_TABLE()
+
+void MyTaskBarIcon::OnMenuRestore(wxEvent& )
+{
+ dialog->Show(TRUE);
+}
+
+void MyTaskBarIcon::OnMenuExit(wxEvent& )
+{
+ dialog->Close(TRUE);
+}
+
+
// Overridables
-void MyTaskBarIcon::OnMouseMove(void)
+void MyTaskBarIcon::OnMouseMove(wxEvent&)
{
}
-void MyTaskBarIcon::OnLButtonDown(void)
+void MyTaskBarIcon::OnLButtonDown(wxEvent&)
{
}
-void MyTaskBarIcon::OnLButtonUp(void)
+void MyTaskBarIcon::OnLButtonUp(wxEvent&)
{
}
-void MyTaskBarIcon::OnRButtonDown(void)
+void MyTaskBarIcon::OnRButtonDown(wxEvent&)
{
}
-void MyTaskBarIcon::OnRButtonUp(void)
+void MyTaskBarIcon::OnRButtonUp(wxEvent&)
{
+ wxMenu menu;
+
+ menu.Append(PU_RESTORE, "&Restore TBTest");
+ menu.Append(PU_EXIT, "E&xit");
+
+ PopupMenu(&menu);
}
-void MyTaskBarIcon::OnLButtonDClick(void)
+void MyTaskBarIcon::OnLButtonDClick(wxEvent&)
{
dialog->Show(TRUE);
}
-void MyTaskBarIcon::OnRButtonDClick(void)
+void MyTaskBarIcon::OnRButtonDClick(wxEvent&)
{
}
+
+
public:
MyTaskBarIcon() {};
- virtual void OnMouseMove(void);
- virtual void OnLButtonDown(void);
- virtual void OnLButtonUp(void);
- virtual void OnRButtonDown(void);
- virtual void OnRButtonUp(void);
- virtual void OnLButtonDClick(void);
- virtual void OnRButtonDClick(void);
+ virtual void OnMouseMove(wxEvent&);
+ virtual void OnLButtonDown(wxEvent&);
+ virtual void OnLButtonUp(wxEvent&);
+ virtual void OnRButtonDown(wxEvent&);
+ virtual void OnRButtonUp(wxEvent&);
+ virtual void OnLButtonDClick(wxEvent&);
+ virtual void OnRButtonDClick(wxEvent&);
+
+ void OnMenuRestore(wxEvent&);
+ void OnMenuExit(wxEvent&);
+
+DECLARE_EVENT_TABLE()
};
#if !USE_SHARED_LIBRARY
BEGIN_EVENT_TABLE(wxTaskBarIcon, wxEvtHandler)
- EVT_TASKBAR_MOVE (wxTaskBarIcon::OnMouseMove)
- EVT_TASKBAR_LEFT_DOWN (wxTaskBarIcon::OnLButtonDown)
- EVT_TASKBAR_LEFT_UP (wxTaskBarIcon::OnLButtonUp)
- EVT_TASKBAR_RIGHT_DOWN (wxTaskBarIcon::OnRButtonDown)
- EVT_TASKBAR_RIGHT_UP (wxTaskBarIcon::OnRButtonUp)
- EVT_TASKBAR_LEFT_DCLICK (wxTaskBarIcon::OnLButtonDClick)
- EVT_TASKBAR_RIGHT_DCLICK (wxTaskBarIcon::OnRButtonDClick)
+ EVT_TASKBAR_MOVE (wxTaskBarIcon::_OnMouseMove)
+ EVT_TASKBAR_LEFT_DOWN (wxTaskBarIcon::_OnLButtonDown)
+ EVT_TASKBAR_LEFT_UP (wxTaskBarIcon::_OnLButtonUp)
+ EVT_TASKBAR_RIGHT_DOWN (wxTaskBarIcon::_OnRButtonDown)
+ EVT_TASKBAR_RIGHT_UP (wxTaskBarIcon::_OnRButtonUp)
+ EVT_TASKBAR_LEFT_DCLICK (wxTaskBarIcon::_OnLButtonDClick)
+ EVT_TASKBAR_RIGHT_DCLICK (wxTaskBarIcon::_OnRButtonDClick)
END_EVENT_TABLE()
return (Shell_NotifyIcon(NIM_DELETE, & notifyData) != 0);
}
+bool wxTaskBarIcon::PopupMenu(wxMenu *menu) //, int x, int y);
+{
+ bool rval = FALSE;
+ wxWindow* win;
+ int x, y;
+ wxGetMousePosition(&x, &y);
+
+ // is wxFrame the best window type to use???
+ win = new wxFrame(NULL, -1, "", wxPoint(x,y), wxSize(-1,-1), 0);
+ win->PushEventHandler(this);
+
+ rval = win->PopupMenu(menu, 0, 0);
+
+ win->PopEventHandler(FALSE);
+ delete win;
+ return rval;
+}
+
+
// Overridables
void wxTaskBarIcon::OnMouseMove(wxEvent&)
{
{
}
+void wxTaskBarIcon::_OnMouseMove(wxEvent& e) { OnMouseMove(e); }
+void wxTaskBarIcon::_OnLButtonDown(wxEvent& e) { OnLButtonDown(e); }
+void wxTaskBarIcon::_OnLButtonUp(wxEvent& e) { OnLButtonUp(e); }
+void wxTaskBarIcon::_OnRButtonDown(wxEvent& e) { OnRButtonDown(e); }
+void wxTaskBarIcon::_OnRButtonUp(wxEvent& e) { OnRButtonUp(e); }
+void wxTaskBarIcon::_OnLButtonDClick(wxEvent& e) { OnLButtonDClick(e); }
+void wxTaskBarIcon::_OnRButtonDClick(wxEvent& e) { OnRButtonDClick(e); }
+
+
wxTaskBarIcon* wxTaskBarIcon::FindObjectForHWND(WXHWND hWnd)
{
wxNode*node = sm_taskBarIcons.First();