]>
Commit | Line | Data |
---|---|---|
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 | |
20 | #include "wx.h" | |
21 | #endif | |
22 | ||
23 | #include "wx/msw/taskbar.h" | |
24 | #include "tbtest.h" | |
25 | ||
26 | // Declare two frames | |
27 | MyDialog *dialog = NULL; | |
28 | ||
29 | IMPLEMENT_APP(MyApp) | |
30 | ||
31 | bool 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 |
47 | BEGIN_EVENT_TABLE(MyDialog, wxDialog) |
48 | EVT_BUTTON(wxID_OK, MyDialog::OnOK) | |
49 | EVT_BUTTON(wxID_EXIT, MyDialog::OnExit) | |
50 | END_EVENT_TABLE() | |
51 | ||
69ecd30f RD |
52 | |
53 | ||
bbf1f0e5 KB |
54 | MyDialog::MyDialog(wxWindow* parent, const wxWindowID id, const wxString& title, |
55 | const wxPoint& pos, const wxSize& size, const long windowStyle): | |
56 | wxDialog(parent, id, title, pos, size, windowStyle) | |
57 | { | |
58 | Init(); | |
59 | } | |
60 | ||
61 | void MyDialog::OnOK(wxCommandEvent& event) | |
62 | { | |
63 | Show(FALSE); | |
64 | } | |
65 | ||
66 | void MyDialog::OnExit(wxCommandEvent& event) | |
67 | { | |
68 | Close(TRUE); | |
69 | } | |
70 | ||
71 | void MyDialog::OnCloseWindow(wxCloseEvent& event) | |
72 | { | |
73 | Destroy(); | |
74 | } | |
75 | ||
76 | void MyDialog::Init(void) | |
77 | { | |
78 | int dialogWidth = 365; | |
79 | int dialogHeight = 290; | |
80 | ||
81 | wxStaticText* stat = new wxStaticText(this, -1, "Press OK to hide me, Exit to quit.", | |
82 | wxPoint(10, 20)); | |
69ecd30f | 83 | |
bbf1f0e5 KB |
84 | wxStaticText* stat2 = new wxStaticText(this, -1, "Double-click on the taskbar icon to show me again.", |
85 | wxPoint(10, 40)); | |
86 | ||
87 | wxButton *okButton = new wxButton(this, wxID_OK, "OK", wxPoint(100, 230), wxSize(80, 25)); | |
88 | wxButton *exitButton = new wxButton(this, wxID_EXIT, "Exit", wxPoint(185, 230), wxSize(80, 25)); | |
89 | okButton->SetDefault(); | |
90 | this->Centre(wxBOTH); | |
91 | } | |
92 | ||
69ecd30f RD |
93 | |
94 | enum { | |
95 | PU_RESTORE = 10001, | |
96 | PU_EXIT, | |
97 | }; | |
98 | ||
99 | ||
100 | BEGIN_EVENT_TABLE(MyTaskBarIcon, wxTaskBarIcon) | |
101 | EVT_MENU(PU_RESTORE, MyTaskBarIcon::OnMenuRestore) | |
102 | EVT_MENU(PU_EXIT, MyTaskBarIcon::OnMenuExit) | |
103 | END_EVENT_TABLE() | |
104 | ||
105 | void MyTaskBarIcon::OnMenuRestore(wxEvent& ) | |
106 | { | |
107 | dialog->Show(TRUE); | |
108 | } | |
109 | ||
110 | void MyTaskBarIcon::OnMenuExit(wxEvent& ) | |
111 | { | |
112 | dialog->Close(TRUE); | |
113 | } | |
114 | ||
115 | ||
bbf1f0e5 | 116 | // Overridables |
69ecd30f | 117 | void MyTaskBarIcon::OnMouseMove(wxEvent&) |
bbf1f0e5 KB |
118 | { |
119 | } | |
120 | ||
69ecd30f | 121 | void MyTaskBarIcon::OnLButtonDown(wxEvent&) |
bbf1f0e5 KB |
122 | { |
123 | } | |
124 | ||
69ecd30f | 125 | void MyTaskBarIcon::OnLButtonUp(wxEvent&) |
bbf1f0e5 KB |
126 | { |
127 | } | |
128 | ||
69ecd30f | 129 | void MyTaskBarIcon::OnRButtonDown(wxEvent&) |
bbf1f0e5 KB |
130 | { |
131 | } | |
132 | ||
69ecd30f | 133 | void MyTaskBarIcon::OnRButtonUp(wxEvent&) |
bbf1f0e5 | 134 | { |
69ecd30f RD |
135 | wxMenu menu; |
136 | ||
137 | menu.Append(PU_RESTORE, "&Restore TBTest"); | |
138 | menu.Append(PU_EXIT, "E&xit"); | |
139 | ||
140 | PopupMenu(&menu); | |
bbf1f0e5 KB |
141 | } |
142 | ||
69ecd30f | 143 | void MyTaskBarIcon::OnLButtonDClick(wxEvent&) |
bbf1f0e5 KB |
144 | { |
145 | dialog->Show(TRUE); | |
146 | } | |
147 | ||
69ecd30f | 148 | void MyTaskBarIcon::OnRButtonDClick(wxEvent&) |
bbf1f0e5 KB |
149 | { |
150 | } | |
151 | ||
152 | ||
69ecd30f RD |
153 | |
154 |