-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
messageboxex.cpp
336 lines (266 loc) · 8.85 KB
/
messageboxex.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
/////////////////////////////////////////////////////////////////////////////
// Name: messageboxex.cpp
// Purpose:
// Author: Julian Smart
// Modified by:
// Created: 12/10/05 18:55:50
// RCS-ID:
// Copyright: (c) Julian Smart, Anthemion Software Ltd
// Licence:
/////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(__APPLE__)
#pragma implementation "messageboxex.h"
#endif
// For compilers that support precompilation, includes "wx/wx.h".
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
////@begin includes
////@end includes
#include "messageboxex.h"
#if 0
#if defined(__WXMSW__)
#include "bitmaps/exclamation_msw.xpm"
#include "bitmaps/question_msw.xpm"
#include "bitmaps/info_msw.xpm"
#elif defined(__WXGTK__)
#include "bitmaps/exclamation_gtk.xpm"
#include "bitmaps/question_gtk.xpm"
#include "bitmaps/info_gtk.xpm"
#elif defined(__WXMAC__)
#include "bitmaps/exclamation_generic.xpm"
#include "bitmaps/question_generic.xpm"
#include "bitmaps/info_generic.xpm"
#endif
#endif
/*!
* wxMessageDialogEx type definition
*/
IMPLEMENT_DYNAMIC_CLASS( wxMessageDialogEx, wxDialog )
/*!
* wxMessageDialogEx event table definition
*/
BEGIN_EVENT_TABLE( wxMessageDialogEx, wxDialog )
////@begin wxMessageDialogEx event table entries
EVT_BUTTON( wxID_YES, wxMessageDialogEx::OnYesClick )
EVT_BUTTON( wxID_YESTOALL, wxMessageDialogEx::OnYestoallClick )
EVT_BUTTON( wxID_NO, wxMessageDialogEx::OnNoClick )
EVT_BUTTON( wxID_NOTOALL, wxMessageDialogEx::OnNotoallClick )
EVT_BUTTON( wxID_OK, wxMessageDialogEx::OnOkClick )
EVT_BUTTON( wxID_CANCEL, wxMessageDialogEx::OnCancelClick )
////@end wxMessageDialogEx event table entries
END_EVENT_TABLE()
/*!
* wxMessageDialogEx constructors
*/
wxMessageDialogEx::wxMessageDialogEx( )
{
m_messageDialogStyle = wxOK;
m_displayNextTime = true;
//m_staticBitmap = NULL;
}
wxMessageDialogEx::wxMessageDialogEx( wxWindow* parent, const wxString& message, const wxString& caption, int style, const wxPoint& pos )
{
m_messageDialogStyle = wxOK;
m_displayNextTime = true;
//m_staticBitmap = NULL;
Create(parent, message, caption, style, pos);
}
/*!
* wxMessageBoxEx creator
*/
bool wxMessageDialogEx::Create( wxWindow* parent, const wxString& message, const wxString& caption, int style, const wxPoint& pos )
{
m_messageDialogStyle = style;
m_message = message;
SetExtraStyle(GetExtraStyle()|wxWS_EX_BLOCK_EVENTS);
wxDialog::Create( parent, wxID_ANY, caption, pos, wxDefaultSize, wxDEFAULT_DIALOG_STYLE );
CreateControls();
GetSizer()->Fit(this);
GetSizer()->SetSizeHints(this);
Centre();
return true;
}
/*!
* Control creation for wxMessageBoxEx
*/
void wxMessageDialogEx::CreateControls()
{
//// @begin wxMessageDialogEx content construction
wxMessageDialogEx* itemDialog1 = this;
wxBoxSizer* itemBoxSizer2 = new wxBoxSizer(wxVERTICAL);
itemDialog1->SetSizer(itemBoxSizer2);
wxBoxSizer* itemBoxSizer3 = new wxBoxSizer(wxVERTICAL);
itemBoxSizer2->Add(itemBoxSizer3, 0, wxALIGN_CENTER_HORIZONTAL|wxALL, 5);
wxBoxSizer* itemBoxSizer4 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer3->Add(itemBoxSizer4, 0, wxGROW, 5);
#if 0
wxBitmap m_staticBitmapBitmap;
if (m_messageDialogStyle & wxICON_QUESTION)
m_staticBitmapBitmap = itemDialog1->GetBitmapResource(wxT("question.xpm"));
else if (m_messageDialogStyle & (wxICON_EXCLAMATION|wxICON_ERROR))
m_staticBitmapBitmap = itemDialog1->GetBitmapResource(wxT("exclamation.xpm"));
else
m_staticBitmapBitmap = itemDialog1->GetBitmapResource(wxT("info.xpm"));
m_staticBitmap = new wxStaticBitmap( itemDialog1, wxID_STATIC, m_staticBitmapBitmap, wxDefaultPosition, wxSize(32, 32), 0 );
itemBoxSizer4->Add(m_staticBitmap, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer4->AddSpacer(10);
#endif
wxStaticText* itemStaticText6 = new wxStaticText( itemDialog1, wxID_STATIC, m_message, wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer4->Add(itemStaticText6, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer3->AddSpacer(10);
wxBoxSizer* itemBoxSizer7 = new wxBoxSizer(wxHORIZONTAL);
itemBoxSizer3->Add(itemBoxSizer7, 0, wxALIGN_CENTER_HORIZONTAL, 5);
if (m_messageDialogStyle & wxDISPLAY_NEXT_TIME)
{
wxCheckBox* displayNextTime = new wxCheckBox( itemDialog1, wxID_ANY, _("&Display next time"), wxDefaultPosition, wxDefaultSize, 0 );
displayNextTime->SetValidator(wxGenericValidator(& m_displayNextTime));
itemBoxSizer7->Add(displayNextTime, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
itemBoxSizer7->AddStretchSpacer();
}
if (m_messageDialogStyle & wxYES)
{
wxButton* itemButton8 = new wxButton( itemDialog1, wxID_YES, _("&Yes"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton8, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
}
if (m_messageDialogStyle & wxYES_TO_ALL)
{
wxButton* itemButton9 = new wxButton( itemDialog1, wxID_YESTOALL, _("Yes to &All"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton9, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
}
if (m_messageDialogStyle & wxNO)
{
wxButton* itemButton10 = new wxButton( itemDialog1, wxID_NO, _("&No"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton10, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
}
if (m_messageDialogStyle & wxNO_TO_ALL)
{
wxButton* itemButton11 = new wxButton( itemDialog1, wxID_NOTOALL, _("No &to All"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton11, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
}
if (m_messageDialogStyle & wxOK)
{
wxButton* itemButton12 = new wxButton( itemDialog1, wxID_OK, _("&OK"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton12, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
}
if (m_messageDialogStyle & wxCANCEL)
{
wxButton* itemButton13 = new wxButton( itemDialog1, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, 0 );
itemBoxSizer7->Add(itemButton13, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5);
}
//// @end wxMessageDialogEx content construction
}
/*!
* Should we show tooltips?
*/
bool wxMessageDialogEx::ShowToolTips()
{
return true;
}
#if 0
/*!
* Get bitmap resources
*/
wxBitmap wxMessageDialogEx::GetBitmapResource( const wxString& name )
{
// Bitmap retrieval
wxUnusedVar(name);
if (name == _T("info.xpm"))
{
wxBitmap bitmap(info_xpm);
return bitmap;
}
else if (name == _T("question.xpm"))
{
wxBitmap bitmap(question_xpm);
return bitmap;
}
else if (name == _T("exclamation.xpm"))
{
wxBitmap bitmap(exclamation_xpm);
return bitmap;
}
return wxNullBitmap;
}
#endif
/*!
* Get icon resources
*/
wxIcon wxMessageDialogEx::GetIconResource( const wxString& name )
{
// Icon retrieval
////@begin wxMessageDialogEx icon retrieval
wxUnusedVar(name);
return wxNullIcon;
////@end wxMessageDialogEx icon retrieval
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_YES
*/
void wxMessageDialogEx::OnYesClick( wxCommandEvent& WXUNUSED(event) )
{
TransferDataFromWindow();
EndModal(wxID_YES);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_YESTOALL
*/
void wxMessageDialogEx::OnYestoallClick( wxCommandEvent& WXUNUSED(event) )
{
TransferDataFromWindow();
EndModal(wxID_YESTOALL);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_NO
*/
void wxMessageDialogEx::OnNoClick( wxCommandEvent& WXUNUSED(event) )
{
TransferDataFromWindow();
EndModal(wxID_NO);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_NOTOALL
*/
void wxMessageDialogEx::OnNotoallClick( wxCommandEvent& WXUNUSED(event) )
{
TransferDataFromWindow();
EndModal(wxID_NOTOALL);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_OK
*/
void wxMessageDialogEx::OnOkClick( wxCommandEvent& WXUNUSED(event) )
{
TransferDataFromWindow();
EndModal(wxID_OK);
}
/*!
* wxEVT_COMMAND_BUTTON_CLICKED event handler for wxID_CANCEL
*/
void wxMessageDialogEx::OnCancelClick( wxCommandEvent& WXUNUSED(event) )
{
EndModal(wxID_CANCEL);
}
// Convenience dialog
int wxMessageBoxEx(const wxString& msg, const wxString& caption, int style, wxWindow* parent)
{
wxMessageDialogEx dialog(parent, msg, caption, style);
int id = dialog.ShowModal();
if (id == wxID_YES)
return wxYES;
else if (id == wxID_NO)
return wxNO;
else if (id == wxID_YESTOALL)
return wxYES_TO_ALL;
else if (id == wxID_NOTOALL)
return wxNO_TO_ALL;
else if (id == wxID_OK)
return wxOK;
else if (id == wxID_CANCEL)
return wxCANCEL;
return wxCANCEL;
}