X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cdcfde5d20f9dfdef75984802862924a68cdc2e1..b640fa17f3359e2766232e5dae3922de28236bde:/samples/taskbar/tbtest.cpp diff --git a/samples/taskbar/tbtest.cpp b/samples/taskbar/tbtest.cpp index 54f2e79215..c31128f06b 100644 --- a/samples/taskbar/tbtest.cpp +++ b/samples/taskbar/tbtest.cpp @@ -29,7 +29,7 @@ #endif // the application icon (under Windows and OS/2 it is in resources) -#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__) +#ifndef wxHAS_IMAGES_IN_RESOURCES #include "../sample.xpm" #endif @@ -60,6 +60,16 @@ bool MyApp::OnInit() if ( !wxApp::OnInit() ) return false; + if ( !wxTaskBarIcon::IsAvailable() ) + { + wxMessageBox + ( + "There appears to be no system tray support in your current environment. This sample may not behave as expected.", + "Warning", + wxOK | wxICON_EXCLAMATION + ); + } + // Create the main window gs_dialog = new MyDialog(wxT("wxTaskBarIcon Test Dialog")); @@ -93,31 +103,28 @@ MyDialog::MyDialog(const wxString& title) ( this, wxID_ANY, - _T("Press 'Hide me' to hide this window, Exit to quit.") + wxT("Press 'Hide me' to hide this window, Exit to quit.") ), flags); sizerTop->Add(new wxStaticText ( this, wxID_ANY, - _T("Double-click on the taskbar icon to show me again.") + wxT("Double-click on the taskbar icon to show me again.") ), flags); sizerTop->AddStretchSpacer()->SetMinSize(200, 50); wxSizer * const sizerBtns = new wxBoxSizer(wxHORIZONTAL); - sizerBtns->Add(new wxButton(this, wxID_ABOUT, _T("&About")), flags); - sizerBtns->Add(new wxButton(this, wxID_OK, _T("&Hide")), flags); - sizerBtns->Add(new wxButton(this, wxID_EXIT, _T("E&xit")), flags); + sizerBtns->Add(new wxButton(this, wxID_ABOUT, wxT("&About")), flags); + sizerBtns->Add(new wxButton(this, wxID_OK, wxT("&Hide")), flags); + sizerBtns->Add(new wxButton(this, wxID_EXIT, wxT("E&xit")), flags); sizerTop->Add(sizerBtns, flags.Align(wxALIGN_CENTER_HORIZONTAL)); SetSizerAndFit(sizerTop); Centre(); m_taskBarIcon = new MyTaskBarIcon(); -#if defined(__WXCOCOA__) - m_dockIcon = new MyTaskBarIcon(wxTaskBarIcon::DOCK); -#endif // we should be able to show up to 128 characters on recent Windows versions // (and 64 on Win9x) @@ -129,6 +136,14 @@ MyDialog::MyDialog(const wxString& title) { wxLogError(wxT("Could not set icon.")); } + +#if defined(__WXOSX__) && wxOSX_USE_COCOA + m_dockIcon = new MyTaskBarIcon(wxTBI_DOCK); + if ( !m_dockIcon->SetIcon(wxICON(sample)) ) + { + wxLogError(wxT("Could not set icon.")); + } +#endif } MyDialog::~MyDialog() @@ -148,10 +163,10 @@ void MyDialog::OnAbout(wxCommandEvent& WXUNUSED(event)) "(C) 1997 Julian Smart\n" "(C) 2007 Vadim Zeitlin"; -#ifdef __WXMSW__ +#if defined(__WXMSW__) && wxUSE_TASKBARICON_BALLOONS m_taskBarIcon->ShowBalloon(title, message, 15000, wxICON_INFORMATION); #else // !__WXMSW__ - wxMessageBox(message, title, wxICON_INFORMATION, this); + wxMessageBox(message, title, wxICON_INFORMATION|wxOK, this); #endif // __WXMSW__/!__WXMSW__ } @@ -237,21 +252,25 @@ void MyTaskBarIcon::OnMenuSub(wxCommandEvent&) wxMenu *MyTaskBarIcon::CreatePopupMenu() { wxMenu *menu = new wxMenu; - menu->Append(PU_RESTORE, _T("&Restore main window")); + menu->Append(PU_RESTORE, wxT("&Restore main window")); menu->AppendSeparator(); - menu->Append(PU_NEW_ICON, _T("&Set New Icon")); + menu->Append(PU_NEW_ICON, wxT("&Set New Icon")); menu->AppendSeparator(); - menu->AppendCheckItem(PU_CHECKMARK, _T("Test &check mark")); + menu->AppendCheckItem(PU_CHECKMARK, wxT("Test &check mark")); menu->AppendSeparator(); wxMenu *submenu = new wxMenu; - submenu->Append(PU_SUB1, _T("One submenu")); + submenu->Append(PU_SUB1, wxT("One submenu")); submenu->AppendSeparator(); - submenu->Append(PU_SUB2, _T("Another submenu")); - menu->Append(PU_SUBMAIN, _T("Submenu"), submenu); -#ifndef __WXMAC_OSX__ /*Mac has built-in quit menu*/ - menu->AppendSeparator(); - menu->Append(PU_EXIT, _T("E&xit")); + submenu->Append(PU_SUB2, wxT("Another submenu")); + menu->Append(PU_SUBMAIN, wxT("Submenu"), submenu); + /* OSX has built-in quit menu for the dock menu, but not for the status item */ +#ifdef __WXOSX__ + if ( OSXIsStatusItem() ) #endif + { + menu->AppendSeparator(); + menu->Append(PU_EXIT, wxT("E&xit")); + } return menu; }