Added wxTaskBarIcon::PopupMenu()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@1169 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
5de5db0eb1
commit
69ecd30f31
@ -35,6 +35,7 @@ public:
|
||||
// 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&);
|
||||
@ -61,6 +62,16 @@ protected:
|
||||
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()
|
||||
};
|
||||
|
||||
@ -83,6 +94,7 @@ const wxEventType wxEVT_TASKBAR_RIGHT_DCLICK = wxEVT_FIRST + 1556;
|
||||
#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_
|
||||
|
||||
|
@ -43,11 +43,14 @@ bool MyApp::OnInit(void)
|
||||
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)
|
||||
@ -77,7 +80,7 @@ void MyDialog::Init(void)
|
||||
|
||||
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));
|
||||
|
||||
@ -87,34 +90,65 @@ void MyDialog::Init(void)
|
||||
this->Centre(wxBOTH);
|
||||
}
|
||||
|
||||
// Overridables
|
||||
void MyTaskBarIcon::OnMouseMove(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnLButtonDown(void)
|
||||
{
|
||||
}
|
||||
enum {
|
||||
PU_RESTORE = 10001,
|
||||
PU_EXIT,
|
||||
};
|
||||
|
||||
void MyTaskBarIcon::OnLButtonUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnRButtonDown(void)
|
||||
{
|
||||
}
|
||||
BEGIN_EVENT_TABLE(MyTaskBarIcon, wxTaskBarIcon)
|
||||
EVT_MENU(PU_RESTORE, MyTaskBarIcon::OnMenuRestore)
|
||||
EVT_MENU(PU_EXIT, MyTaskBarIcon::OnMenuExit)
|
||||
END_EVENT_TABLE()
|
||||
|
||||
void MyTaskBarIcon::OnRButtonUp(void)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnLButtonDClick(void)
|
||||
void MyTaskBarIcon::OnMenuRestore(wxEvent& )
|
||||
{
|
||||
dialog->Show(TRUE);
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnRButtonDClick(void)
|
||||
void MyTaskBarIcon::OnMenuExit(wxEvent& )
|
||||
{
|
||||
dialog->Close(TRUE);
|
||||
}
|
||||
|
||||
|
||||
// Overridables
|
||||
void MyTaskBarIcon::OnMouseMove(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnLButtonDown(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnLButtonUp(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnRButtonDown(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnRButtonUp(wxEvent&)
|
||||
{
|
||||
wxMenu menu;
|
||||
|
||||
menu.Append(PU_RESTORE, "&Restore TBTest");
|
||||
menu.Append(PU_EXIT, "E&xit");
|
||||
|
||||
PopupMenu(&menu);
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnLButtonDClick(wxEvent&)
|
||||
{
|
||||
dialog->Show(TRUE);
|
||||
}
|
||||
|
||||
void MyTaskBarIcon::OnRButtonDClick(wxEvent&)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -14,13 +14,18 @@ class MyTaskBarIcon: public wxTaskBarIcon
|
||||
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()
|
||||
};
|
||||
|
||||
|
||||
|
@ -48,13 +48,13 @@ UINT wxTaskBarIcon::sm_taskbarMsg = 0;
|
||||
|
||||
#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()
|
||||
|
||||
|
||||
@ -144,6 +144,25 @@ bool wxTaskBarIcon::RemoveIcon(void)
|
||||
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&)
|
||||
{
|
||||
@ -173,6 +192,15 @@ void wxTaskBarIcon::OnRButtonDClick(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();
|
||||
|
Loading…
Reference in New Issue
Block a user