]> git.saurik.com Git - wxWidgets.git/blame - samples/taskbar/tbtest.cpp
mac fixes
[wxWidgets.git] / samples / taskbar / tbtest.cpp
CommitLineData
bbf1f0e5
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: tbtest.cpp
3// Purpose: wxTaskBarIcon demo
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c)
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
15#ifdef __BORLANDC__
16#pragma hdrstop
17#endif
18
19#ifndef WX_PRECOMP
c25a510b 20#include <wx/wx.h>
bbf1f0e5
KB
21#endif
22
c25a510b 23#include <wx/msw/taskbar.h>
bbf1f0e5
KB
24#include "tbtest.h"
25
26// Declare two frames
27MyDialog *dialog = NULL;
28
29IMPLEMENT_APP(MyApp)
30
31bool MyApp::OnInit(void)
32{
33 wxIcon icon("mondrian_icon");
34
35 if (!m_taskBarIcon.SetIcon(icon, "wxTaskBarIcon Sample"))
36 wxMessageBox("Could not set icon.");
37
38 // Create the main frame window
39 dialog = new MyDialog(NULL, -1, "wxTaskBarIcon Test Dialog", wxPoint(-1, -1), wxSize(365, 290), wxDIALOG_MODELESS|wxDEFAULT_DIALOG_STYLE);
40
41 dialog->Show(TRUE);
42
43 return TRUE;
44}
45
69ecd30f 46
bbf1f0e5
KB
47BEGIN_EVENT_TABLE(MyDialog, wxDialog)
48 EVT_BUTTON(wxID_OK, MyDialog::OnOK)
49 EVT_BUTTON(wxID_EXIT, MyDialog::OnExit)
d66d9d5b 50 EVT_CLOSE(MyDialog::OnCloseWindow)
bbf1f0e5
KB
51END_EVENT_TABLE()
52
69ecd30f
RD
53
54
bbf1f0e5
KB
55MyDialog::MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title,
56 const wxPoint& pos, const wxSize& size, const long windowStyle):
57 wxDialog(parent, id, title, pos, size, windowStyle)
58{
59 Init();
60}
61
62void MyDialog::OnOK(wxCommandEvent& event)
63{
64 Show(FALSE);
65}
66
67void MyDialog::OnExit(wxCommandEvent& event)
68{
69 Close(TRUE);
70}
71
72void MyDialog::OnCloseWindow(wxCloseEvent& event)
73{
74 Destroy();
75}
76
77void MyDialog::Init(void)
78{
79 int dialogWidth = 365;
80 int dialogHeight = 290;
81
82 wxStaticText* stat = new wxStaticText(this, -1, "Press OK to hide me, Exit to quit.",
83 wxPoint(10, 20));
69ecd30f 84
bbf1f0e5
KB
85 wxStaticText* stat2 = new wxStaticText(this, -1, "Double-click on the taskbar icon to show me again.",
86 wxPoint(10, 40));
87
88 wxButton *okButton = new wxButton(this, wxID_OK, "OK", wxPoint(100, 230), wxSize(80, 25));
89 wxButton *exitButton = new wxButton(this, wxID_EXIT, "Exit", wxPoint(185, 230), wxSize(80, 25));
90 okButton->SetDefault();
91 this->Centre(wxBOTH);
92}
93
69ecd30f
RD
94
95enum {
96 PU_RESTORE = 10001,
97 PU_EXIT,
98};
99
100
101BEGIN_EVENT_TABLE(MyTaskBarIcon, wxTaskBarIcon)
102 EVT_MENU(PU_RESTORE, MyTaskBarIcon::OnMenuRestore)
103 EVT_MENU(PU_EXIT, MyTaskBarIcon::OnMenuExit)
104END_EVENT_TABLE()
105
a42b93aa 106void MyTaskBarIcon::OnMenuRestore(wxCommandEvent& )
69ecd30f
RD
107{
108 dialog->Show(TRUE);
109}
110
a42b93aa 111void MyTaskBarIcon::OnMenuExit(wxCommandEvent& )
69ecd30f
RD
112{
113 dialog->Close(TRUE);
f6bcfd97
BP
114
115 // Nudge wxWindows into destroying the dialog, since
116 // with a hidden window no messages will get sent to put
117 // it into idle processing.
118 wxGetApp().ProcessIdle();
69ecd30f
RD
119}
120
121
bbf1f0e5 122// Overridables
69ecd30f 123void MyTaskBarIcon::OnMouseMove(wxEvent&)
bbf1f0e5
KB
124{
125}
126
69ecd30f 127void MyTaskBarIcon::OnLButtonDown(wxEvent&)
bbf1f0e5
KB
128{
129}
130
69ecd30f 131void MyTaskBarIcon::OnLButtonUp(wxEvent&)
bbf1f0e5
KB
132{
133}
134
69ecd30f 135void MyTaskBarIcon::OnRButtonDown(wxEvent&)
bbf1f0e5
KB
136{
137}
138
69ecd30f 139void MyTaskBarIcon::OnRButtonUp(wxEvent&)
bbf1f0e5 140{
69ecd30f
RD
141 wxMenu menu;
142
143 menu.Append(PU_RESTORE, "&Restore TBTest");
144 menu.Append(PU_EXIT, "E&xit");
145
146 PopupMenu(&menu);
bbf1f0e5
KB
147}
148
69ecd30f 149void MyTaskBarIcon::OnLButtonDClick(wxEvent&)
bbf1f0e5
KB
150{
151 dialog->Show(TRUE);
152}
153
69ecd30f 154void MyTaskBarIcon::OnRButtonDClick(wxEvent&)
bbf1f0e5
KB
155{
156}
157
158
69ecd30f
RD
159
160