From: Vadim Zeitlin Date: Sat, 1 Dec 2007 15:55:28 +0000 (+0000) Subject: removed the menu item which could be used to remove the icon and leave the user witho... X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/3ecee463f53424f00bf462e184ebc282ee3b995e removed the menu item which could be used to remove the icon and leave the user without any way to interact with the application (nor quit it) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50401 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/samples/taskbar/tbtest.cpp b/samples/taskbar/tbtest.cpp index fcda0b64e3..ac5c80bda2 100644 --- a/samples/taskbar/tbtest.cpp +++ b/samples/taskbar/tbtest.cpp @@ -97,20 +97,28 @@ void MyDialog::Init(void) (void)new wxButton(this, wxID_EXIT, _T("Exit"), wxPoint(185, 230), wxSize(80, 25)); (new wxButton(this, wxID_OK, _T("Hide me"), wxPoint(100, 230), wxSize(80, 25)))->SetDefault(); Centre(wxBOTH); - + m_taskBarIcon = new MyTaskBarIcon(); #if defined(__WXCOCOA__) m_dockIcon = new MyTaskBarIcon(wxTaskBarIcon::DOCK); #endif - if (!m_taskBarIcon->SetIcon(wxICON(sample), wxT("wxTaskBarIcon Sample"))) + // we should be able to show up to 128 characters on recent Windows versions + // (and 64 on Win9x) + if (!m_taskBarIcon->SetIcon(wxICON(sample), + "wxTaskBarIcon Sample\n" + "With a very, very, very, very\n" + "long tooltip whose length is\n" + "greater than 64 characters.")) + { wxMessageBox(wxT("Could not set icon.")); + } } -enum { +enum +{ PU_RESTORE = 10001, PU_NEW_ICON, - PU_OLD_ICON, PU_EXIT, PU_CHECKMARK, PU_SUB1, @@ -123,7 +131,6 @@ BEGIN_EVENT_TABLE(MyTaskBarIcon, wxTaskBarIcon) EVT_MENU(PU_RESTORE, MyTaskBarIcon::OnMenuRestore) EVT_MENU(PU_EXIT, MyTaskBarIcon::OnMenuExit) EVT_MENU(PU_NEW_ICON,MyTaskBarIcon::OnMenuSetNewIcon) - EVT_MENU(PU_OLD_ICON,MyTaskBarIcon::OnMenuSetOldIcon) EVT_MENU(PU_CHECKMARK,MyTaskBarIcon::OnMenuCheckmark) EVT_UPDATE_UI(PU_CHECKMARK,MyTaskBarIcon::OnMenuUICheckmark) EVT_TASKBAR_LEFT_DCLICK (MyTaskBarIcon::OnLeftButtonDClick) @@ -145,12 +152,12 @@ static bool check = true; void MyTaskBarIcon::OnMenuCheckmark(wxCommandEvent& ) { - check =!check; + check = !check; } void MyTaskBarIcon::OnMenuUICheckmark(wxUpdateUIEvent &event) { - event.Check( check ); + event.Check(check); } void MyTaskBarIcon::OnMenuSetNewIcon(wxCommandEvent&) @@ -161,18 +168,6 @@ void MyTaskBarIcon::OnMenuSetNewIcon(wxCommandEvent&) wxMessageBox(wxT("Could not set new icon.")); } -void MyTaskBarIcon::OnMenuSetOldIcon(wxCommandEvent&) -{ - if (IsIconInstalled()) - { - RemoveIcon(); - } - else - { - wxMessageBox(wxT("wxTaskBarIcon Sample - icon already is the old version")); - } -} - void MyTaskBarIcon::OnMenuSub(wxCommandEvent&) { wxMessageBox(wxT("You clicked on a submenu!")); @@ -181,15 +176,12 @@ void MyTaskBarIcon::OnMenuSub(wxCommandEvent&) // Overridables wxMenu *MyTaskBarIcon::CreatePopupMenu() { - // Try creating menus different ways - // TODO: Probably try calling SetBitmap with some XPMs here wxMenu *menu = new wxMenu; - menu->Append(PU_RESTORE, _T("&Restore TBTest")); + menu->Append(PU_RESTORE, _T("&Restore main window")); menu->AppendSeparator(); - menu->Append(PU_OLD_ICON, _T("&Restore Old Icon")); menu->Append(PU_NEW_ICON, _T("&Set New Icon")); menu->AppendSeparator(); - menu->Append(PU_CHECKMARK, _T("Checkmark"),wxT(""), wxITEM_CHECK); + menu->AppendCheckItem(PU_CHECKMARK, _T("Test &check mark")); menu->AppendSeparator(); wxMenu *submenu = new wxMenu; submenu->Append(PU_SUB1, _T("One submenu")); diff --git a/samples/taskbar/tbtest.h b/samples/taskbar/tbtest.h index 0167ac662d..a2dc242b5a 100644 --- a/samples/taskbar/tbtest.h +++ b/samples/taskbar/tbtest.h @@ -24,13 +24,12 @@ public: void OnMenuRestore(wxCommandEvent&); void OnMenuExit(wxCommandEvent&); void OnMenuSetNewIcon(wxCommandEvent&); - void OnMenuSetOldIcon(wxCommandEvent&); - void OnMenuCheckmark(wxCommandEvent&); - void OnMenuUICheckmark(wxUpdateUIEvent&); + void OnMenuCheckmark(wxCommandEvent&); + void OnMenuUICheckmark(wxUpdateUIEvent&); void OnMenuSub(wxCommandEvent&); virtual wxMenu *CreatePopupMenu(); -DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() }; @@ -38,7 +37,7 @@ DECLARE_EVENT_TABLE() class MyApp: public wxApp { public: - bool OnInit(void); + virtual bool OnInit(); }; class MyDialog: public wxDialog @@ -46,18 +45,19 @@ class MyDialog: public wxDialog public: MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, const long windowStyle = wxDEFAULT_DIALOG_STYLE); - ~MyDialog(); + virtual ~MyDialog(); + +protected: + void Init(); void OnOK(wxCommandEvent& event); void OnExit(wxCommandEvent& event); void OnCloseWindow(wxCloseEvent& event); - void Init(void); -protected: MyTaskBarIcon *m_taskBarIcon; #if defined(__WXCOCOA__) MyTaskBarIcon *m_dockIcon; #endif -DECLARE_EVENT_TABLE() + DECLARE_EVENT_TABLE() };