]>
git.saurik.com Git - wxWidgets.git/blob - samples/taskbar/tbtest.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxTaskBarIcon demo
4 // Author: Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
23 // the application icon (under Windows and OS/2 it is in resources)
24 #if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXMAC__) || defined(__WXMGL__) || defined(__WXX11__)
25 #include "mondrian.xpm"
28 #include "wx/taskbar.h"
32 MyDialog
*dialog
= NULL
;
36 bool MyApp::OnInit(void)
38 if (!m_taskBarIcon
.SetIcon(wxICON(mondrian
), wxT("wxTaskBarIcon Sample")))
39 wxMessageBox(wxT("Could not set icon."));
41 // Create the main frame window
42 dialog
= new MyDialog(NULL
, -1, wxT("wxTaskBarIcon Test Dialog"), wxPoint(-1, -1), wxSize(365, 290), wxDIALOG_MODELESS
|wxDEFAULT_DIALOG_STYLE
);
50 BEGIN_EVENT_TABLE(MyDialog
, wxDialog
)
51 EVT_BUTTON(wxID_OK
, MyDialog::OnOK
)
52 EVT_BUTTON(wxID_EXIT
, MyDialog::OnExit
)
53 EVT_CLOSE(MyDialog::OnCloseWindow
)
58 MyDialog::MyDialog(wxWindow
* parent
, const wxWindowID id
, const wxString
& title
,
59 const wxPoint
& pos
, const wxSize
& size
, const long windowStyle
):
60 wxDialog(parent
, id
, title
, pos
, size
, windowStyle
)
65 void MyDialog::OnOK(wxCommandEvent
& event
)
70 void MyDialog::OnExit(wxCommandEvent
& event
)
75 void MyDialog::OnCloseWindow(wxCloseEvent
& event
)
80 void MyDialog::Init(void)
82 (void)new wxStaticText(this, -1, _T("Press OK to hide me, Exit to quit."),
85 (void)new wxStaticText(this, -1, _T("Double-click on the taskbar icon to show me again."),
88 (void)new wxButton(this, wxID_EXIT
, _T("Exit"), wxPoint(185, 230), wxSize(80, 25));
89 (new wxButton(this, wxID_OK
, _T("OK"), wxPoint(100, 230), wxSize(80, 25)))->SetDefault();
101 BEGIN_EVENT_TABLE(MyTaskBarIcon
, wxTaskBarIcon
)
102 EVT_MENU(PU_RESTORE
, MyTaskBarIcon::OnMenuRestore
)
103 EVT_MENU(PU_EXIT
, MyTaskBarIcon::OnMenuExit
)
104 EVT_MENU(PU_NEW_ICON
,MyTaskBarIcon::OnMenuSetNewIcon
)
105 EVT_TASKBAR_RIGHT_UP (MyTaskBarIcon::OnRButtonUp
)
106 EVT_TASKBAR_LEFT_DCLICK (MyTaskBarIcon::OnLButtonDClick
)
109 void MyTaskBarIcon::OnMenuRestore(wxCommandEvent
& )
114 void MyTaskBarIcon::OnMenuExit(wxCommandEvent
& )
118 // Nudge wxWindows into destroying the dialog, since
119 // with a hidden window no messages will get sent to put
120 // it into idle processing.
121 wxGetApp().ProcessIdle();
124 void MyTaskBarIcon::OnMenuSetNewIcon(wxCommandEvent
&)
127 wxIcon
icon(wxT("wxDEFAULT_FRAME"));
129 if (!SetIcon(icon
, wxT("wxTaskBarIcon Sample")))
130 wxMessageBox(wxT("Could not set new icon."));
135 void MyTaskBarIcon::OnRButtonUp(wxEvent
&)
139 menu
.Append(PU_RESTORE
, _T("&Restore TBTest"));
141 menu
.Append(PU_NEW_ICON
,_T("&Set New Icon"));
143 menu
.Append(PU_EXIT
, _T("E&xit"));
148 void MyTaskBarIcon::OnLButtonDClick(wxEvent
&)