]>
Commit | Line | Data |
---|---|---|
66cd017c | 1 | /////////////////////////////////////////////////////////////////////////////// |
94c09a19 | 2 | // Name: src/generic/wizard.cpp |
66cd017c VZ |
3 | // Purpose: generic implementation of wxWizard class |
4 | // Author: Vadim Zeitlin | |
a0a48a3f VZ |
5 | // Modified by: Robert Cavanaugh |
6 | // 1) Added capability for wxWizardPage to accept resources | |
7 | // 2) Added "Help" button handler stub | |
8 | // 3) Fixed ShowPage() bug on displaying bitmaps | |
07f20d9a | 9 | // Robert Vazan (sizers) |
66cd017c | 10 | // Created: 15.08.99 |
66cd017c | 11 | // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> |
65571936 | 12 | // Licence: wxWindows licence |
66cd017c VZ |
13 | /////////////////////////////////////////////////////////////////////////////// |
14 | ||
15 | // ============================================================================ | |
16 | // declarations | |
17 | // ============================================================================ | |
18 | ||
19 | // ---------------------------------------------------------------------------- | |
20 | // headers | |
21 | // ---------------------------------------------------------------------------- | |
22 | ||
66cd017c VZ |
23 | // For compilers that support precompilation, includes "wx.h". |
24 | #include "wx/wxprec.h" | |
25 | ||
26 | #ifdef __BORLANDC__ | |
27 | #pragma hdrstop | |
28 | #endif | |
29 | ||
1e6feb95 VZ |
30 | #if wxUSE_WIZARDDLG |
31 | ||
66cd017c VZ |
32 | #ifndef WX_PRECOMP |
33 | #include "wx/dynarray.h" | |
34 | #include "wx/intl.h" | |
b87654f3 | 35 | #include "wx/statbmp.h" |
f6bcfd97 | 36 | #include "wx/button.h" |
9eddec69 | 37 | #include "wx/settings.h" |
ed2fbeb8 | 38 | #include "wx/sizer.h" |
66cd017c VZ |
39 | #endif //WX_PRECOMP |
40 | ||
41 | #include "wx/statline.h" | |
42 | ||
d9af3670 | 43 | #include "wx/scrolwin.h" |
66cd017c | 44 | #include "wx/wizard.h" |
d9af3670 | 45 | #include "wx/dcmemory.h" |
66cd017c | 46 | |
aedd6d6a VZ |
47 | // ---------------------------------------------------------------------------- |
48 | // wxWizardSizer | |
49 | // ---------------------------------------------------------------------------- | |
50 | ||
51 | class wxWizardSizer : public wxSizer | |
52 | { | |
53 | public: | |
54 | wxWizardSizer(wxWizard *owner); | |
55 | ||
0a9ed8f1 VZ |
56 | virtual wxSizerItem *Insert(size_t index, wxSizerItem *item); |
57 | ||
88517d90 VZ |
58 | virtual void RecalcSizes(); |
59 | virtual wxSize CalcMin(); | |
aedd6d6a | 60 | |
88517d90 | 61 | // get the max size of all wizard pages |
aedd6d6a | 62 | wxSize GetMaxChildSize(); |
88517d90 VZ |
63 | |
64 | // return the border which can be either set using wxWizard::SetBorder() or | |
65 | // have default value | |
66 | int GetBorder() const; | |
ca65c044 | 67 | |
0a9ed8f1 VZ |
68 | // hide the pages which we temporarily "show" when they're added to this |
69 | // sizer (see Insert()) | |
70 | void HidePages(); | |
71 | ||
aedd6d6a VZ |
72 | private: |
73 | wxSize SiblingSize(wxSizerItem *child); | |
ca65c044 | 74 | |
aedd6d6a | 75 | wxWizard *m_owner; |
aedd6d6a VZ |
76 | wxSize m_childSize; |
77 | }; | |
78 | ||
66cd017c VZ |
79 | // ---------------------------------------------------------------------------- |
80 | // event tables and such | |
81 | // ---------------------------------------------------------------------------- | |
82 | ||
9b11752c VZ |
83 | wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_CHANGED, wxWizardEvent ); |
84 | wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_CHANGING, wxWizardEvent ); | |
c9f18835 | 85 | wxDEFINE_EVENT( wxEVT_WIZARD_BEFORE_PAGE_CHANGED, wxWizardEvent ); |
9b11752c VZ |
86 | wxDEFINE_EVENT( wxEVT_WIZARD_CANCEL, wxWizardEvent ); |
87 | wxDEFINE_EVENT( wxEVT_WIZARD_FINISHED, wxWizardEvent ); | |
88 | wxDEFINE_EVENT( wxEVT_WIZARD_HELP, wxWizardEvent ); | |
deeb0a89 | 89 | wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_SHOWN, wxWizardEvent ); |
2e4df4bf | 90 | |
74b31181 VZ |
91 | BEGIN_EVENT_TABLE(wxWizard, wxDialog) |
92 | EVT_BUTTON(wxID_CANCEL, wxWizard::OnCancel) | |
f80bf901 VZ |
93 | EVT_BUTTON(wxID_BACKWARD, wxWizard::OnBackOrNext) |
94 | EVT_BUTTON(wxID_FORWARD, wxWizard::OnBackOrNext) | |
95 | EVT_BUTTON(wxID_HELP, wxWizard::OnHelp) | |
91c68292 | 96 | |
ca65c044 WS |
97 | EVT_WIZARD_PAGE_CHANGED(wxID_ANY, wxWizard::OnWizEvent) |
98 | EVT_WIZARD_PAGE_CHANGING(wxID_ANY, wxWizard::OnWizEvent) | |
99 | EVT_WIZARD_CANCEL(wxID_ANY, wxWizard::OnWizEvent) | |
100 | EVT_WIZARD_FINISHED(wxID_ANY, wxWizard::OnWizEvent) | |
101 | EVT_WIZARD_HELP(wxID_ANY, wxWizard::OnWizEvent) | |
66cd017c VZ |
102 | END_EVENT_TABLE() |
103 | ||
74b31181 | 104 | IMPLEMENT_DYNAMIC_CLASS(wxWizard, wxDialog) |
066f1b7a SC |
105 | |
106 | /* | |
ca65c044 WS |
107 | TODO PROPERTIES : |
108 | wxWizard | |
109 | extstyle | |
110 | title | |
066f1b7a SC |
111 | */ |
112 | ||
74b31181 VZ |
113 | IMPLEMENT_ABSTRACT_CLASS(wxWizardPage, wxPanel) |
114 | IMPLEMENT_DYNAMIC_CLASS(wxWizardPageSimple, wxWizardPage) | |
66cd017c VZ |
115 | IMPLEMENT_DYNAMIC_CLASS(wxWizardEvent, wxNotifyEvent) |
116 | ||
117 | // ============================================================================ | |
118 | // implementation | |
119 | // ============================================================================ | |
120 | ||
74b31181 VZ |
121 | // ---------------------------------------------------------------------------- |
122 | // wxWizardPage | |
123 | // ---------------------------------------------------------------------------- | |
124 | ||
c7de4135 VS |
125 | void wxWizardPage::Init() |
126 | { | |
127 | m_bitmap = wxNullBitmap; | |
128 | } | |
129 | ||
a0a48a3f | 130 | wxWizardPage::wxWizardPage(wxWizard *parent, |
cf63f3d3 | 131 | const wxBitmap& bitmap) |
74b31181 | 132 | { |
cf63f3d3 | 133 | Create(parent, bitmap); |
c7de4135 | 134 | } |
91c68292 | 135 | |
c7de4135 | 136 | bool wxWizardPage::Create(wxWizard *parent, |
cf63f3d3 | 137 | const wxBitmap& bitmap) |
c7de4135 | 138 | { |
ca65c044 WS |
139 | if ( !wxPanel::Create(parent, wxID_ANY) ) |
140 | return false; | |
c7de4135 | 141 | |
636d266b | 142 | m_bitmap = bitmap; |
a0a48a3f | 143 | |
74b31181 VZ |
144 | // initially the page is hidden, it's shown only when it becomes current |
145 | Hide(); | |
91c68292 | 146 | |
ca65c044 | 147 | return true; |
74b31181 VZ |
148 | } |
149 | ||
150 | // ---------------------------------------------------------------------------- | |
151 | // wxWizardPageSimple | |
152 | // ---------------------------------------------------------------------------- | |
153 | ||
154 | wxWizardPage *wxWizardPageSimple::GetPrev() const | |
155 | { | |
156 | return m_prev; | |
157 | } | |
158 | ||
159 | wxWizardPage *wxWizardPageSimple::GetNext() const | |
160 | { | |
161 | return m_next; | |
162 | } | |
07f20d9a VZ |
163 | |
164 | // ---------------------------------------------------------------------------- | |
165 | // wxWizardSizer | |
166 | // ---------------------------------------------------------------------------- | |
167 | ||
07f20d9a | 168 | wxWizardSizer::wxWizardSizer(wxWizard *owner) |
0a089246 VZ |
169 | : m_owner(owner), |
170 | m_childSize(wxDefaultSize) | |
07f20d9a | 171 | { |
07f20d9a VZ |
172 | } |
173 | ||
0a9ed8f1 VZ |
174 | wxSizerItem *wxWizardSizer::Insert(size_t index, wxSizerItem *item) |
175 | { | |
0a089246 VZ |
176 | m_owner->m_usingSizer = true; |
177 | ||
0a9ed8f1 VZ |
178 | if ( item->IsWindow() ) |
179 | { | |
180 | // we must pretend that the window is shown as otherwise it wouldn't be | |
181 | // taken into account for the layout -- but avoid really showing it, so | |
182 | // just set the internal flag instead of calling wxWindow::Show() | |
183 | item->GetWindow()->wxWindowBase::Show(); | |
184 | } | |
185 | ||
186 | return wxSizer::Insert(index, item); | |
187 | } | |
188 | ||
189 | void wxWizardSizer::HidePages() | |
190 | { | |
191 | for ( wxSizerItemList::compatibility_iterator node = GetChildren().GetFirst(); | |
192 | node; | |
193 | node = node->GetNext() ) | |
194 | { | |
195 | wxSizerItem * const item = node->GetData(); | |
196 | if ( item->IsWindow() ) | |
197 | item->GetWindow()->wxWindowBase::Show(false); | |
198 | } | |
199 | } | |
200 | ||
07f20d9a VZ |
201 | void wxWizardSizer::RecalcSizes() |
202 | { | |
203 | // Effect of this function depends on m_owner->m_page and | |
204 | // it should be called whenever it changes (wxWizard::ShowPage) | |
205 | if ( m_owner->m_page ) | |
206 | { | |
0a089246 | 207 | m_owner->m_page->SetSize(wxRect(m_position, m_size)); |
07f20d9a VZ |
208 | } |
209 | } | |
210 | ||
211 | wxSize wxWizardSizer::CalcMin() | |
212 | { | |
213 | return m_owner->GetPageSize(); | |
214 | } | |
215 | ||
216 | wxSize wxWizardSizer::GetMaxChildSize() | |
217 | { | |
07f20d9a | 218 | wxSize maxOfMin; |
07f20d9a | 219 | |
0a089246 VZ |
220 | for ( wxSizerItemList::compatibility_iterator childNode = m_children.GetFirst(); |
221 | childNode; | |
222 | childNode = childNode->GetNext() ) | |
07f20d9a VZ |
223 | { |
224 | wxSizerItem *child = childNode->GetData(); | |
225 | maxOfMin.IncTo(child->CalcMin()); | |
226 | maxOfMin.IncTo(SiblingSize(child)); | |
227 | } | |
228 | ||
07f20d9a VZ |
229 | if ( m_owner->m_started ) |
230 | { | |
07f20d9a VZ |
231 | m_childSize = maxOfMin; |
232 | } | |
ca65c044 | 233 | |
07f20d9a VZ |
234 | return maxOfMin; |
235 | } | |
236 | ||
88517d90 | 237 | int wxWizardSizer::GetBorder() const |
07f20d9a | 238 | { |
0a089246 | 239 | return m_owner->m_border; |
07f20d9a VZ |
240 | } |
241 | ||
242 | wxSize wxWizardSizer::SiblingSize(wxSizerItem *child) | |
243 | { | |
244 | wxSize maxSibling; | |
ca65c044 | 245 | |
07f20d9a VZ |
246 | if ( child->IsWindow() ) |
247 | { | |
248 | wxWizardPage *page = wxDynamicCast(child->GetWindow(), wxWizardPage); | |
249 | if ( page ) | |
250 | { | |
251 | for ( wxWizardPage *sibling = page->GetNext(); | |
252 | sibling; | |
253 | sibling = sibling->GetNext() ) | |
254 | { | |
255 | if ( sibling->GetSizer() ) | |
256 | { | |
257 | maxSibling.IncTo(sibling->GetSizer()->CalcMin()); | |
258 | } | |
259 | } | |
260 | } | |
261 | } | |
ca65c044 | 262 | |
07f20d9a VZ |
263 | return maxSibling; |
264 | } | |
265 | ||
66cd017c VZ |
266 | // ---------------------------------------------------------------------------- |
267 | // generic wxWizard implementation | |
268 | // ---------------------------------------------------------------------------- | |
269 | ||
77436c4c JS |
270 | void wxWizard::Init() |
271 | { | |
272 | m_posWizard = wxDefaultPosition; | |
d3b9f782 | 273 | m_page = NULL; |
77436c4c JS |
274 | m_btnPrev = m_btnNext = NULL; |
275 | m_statbmp = NULL; | |
aedd6d6a | 276 | m_sizerBmpAndPage = NULL; |
07f20d9a | 277 | m_sizerPage = NULL; |
0a089246 | 278 | m_border = 5; |
07f20d9a | 279 | m_started = false; |
94c09a19 | 280 | m_wasModal = false; |
0a089246 | 281 | m_usingSizer = false; |
3aa8e4ea JS |
282 | m_bitmapBackgroundColour = *wxWHITE; |
283 | m_bitmapPlacement = 0; | |
284 | m_bitmapMinimumWidth = 115; | |
77436c4c JS |
285 | } |
286 | ||
287 | bool wxWizard::Create(wxWindow *parent, | |
aedd6d6a VZ |
288 | int id, |
289 | const wxString& title, | |
290 | const wxBitmap& bitmap, | |
291 | const wxPoint& pos, | |
292 | long style) | |
66cd017c | 293 | { |
07f20d9a | 294 | bool result = wxDialog::Create(parent,id,title,pos,wxDefaultSize,style); |
ca65c044 | 295 | |
77436c4c JS |
296 | m_posWizard = pos; |
297 | m_bitmap = bitmap ; | |
636d266b | 298 | |
07f20d9a | 299 | DoCreateControls(); |
ca65c044 | 300 | |
07f20d9a | 301 | return result; |
f6bcfd97 BP |
302 | } |
303 | ||
781130bf VZ |
304 | wxWizard::~wxWizard() |
305 | { | |
306 | // normally we don't have to delete this sizer as it's deleted by the | |
307 | // associated window but if we never used it or didn't set it as the window | |
308 | // sizer yet, do delete it manually | |
309 | if ( !m_usingSizer || !m_started ) | |
310 | delete m_sizerPage; | |
311 | } | |
312 | ||
07f20d9a | 313 | void wxWizard::AddBitmapRow(wxBoxSizer *mainColumn) |
f6bcfd97 | 314 | { |
07f20d9a VZ |
315 | m_sizerBmpAndPage = new wxBoxSizer(wxHORIZONTAL); |
316 | mainColumn->Add( | |
317 | m_sizerBmpAndPage, | |
318 | 1, // Vertically stretchable | |
4c51a665 | 319 | wxEXPAND // Horizontal stretching, no border |
07f20d9a VZ |
320 | ); |
321 | mainColumn->Add(0,5, | |
322 | 0, // No vertical stretching | |
323 | wxEXPAND // No border, (mostly useless) horizontal stretching | |
324 | ); | |
66cd017c | 325 | |
461dae94 | 326 | #if wxUSE_STATBMP |
a1b806b9 | 327 | if ( m_bitmap.IsOk() ) |
66cd017c | 328 | { |
3aa8e4ea JS |
329 | wxSize bitmapSize(wxDefaultSize); |
330 | if (GetBitmapPlacement()) | |
331 | bitmapSize.x = GetMinimumBitmapWidth(); | |
332 | ||
333 | m_statbmp = new wxStaticBitmap(this, wxID_ANY, m_bitmap, wxDefaultPosition, bitmapSize); | |
07f20d9a VZ |
334 | m_sizerBmpAndPage->Add( |
335 | m_statbmp, | |
336 | 0, // No horizontal stretching | |
337 | wxALL, // Border all around, top alignment | |
338 | 5 // Border width | |
339 | ); | |
340 | m_sizerBmpAndPage->Add( | |
341 | 5,0, | |
342 | 0, // No horizontal stretching | |
343 | wxEXPAND // No border, (mostly useless) vertical stretching | |
344 | ); | |
66cd017c | 345 | } |
461dae94 | 346 | #endif |
f1df0927 | 347 | |
0a089246 | 348 | // Added to m_sizerBmpAndPage later |
07f20d9a VZ |
349 | m_sizerPage = new wxWizardSizer(this); |
350 | } | |
74b31181 | 351 | |
07f20d9a VZ |
352 | void wxWizard::AddStaticLine(wxBoxSizer *mainColumn) |
353 | { | |
74b31181 | 354 | #if wxUSE_STATLINE |
07f20d9a | 355 | mainColumn->Add( |
ca65c044 | 356 | new wxStaticLine(this, wxID_ANY), |
07f20d9a VZ |
357 | 0, // Vertically unstretchable |
358 | wxEXPAND | wxALL, // Border all around, horizontally stretchable | |
359 | 5 // Border width | |
360 | ); | |
361 | mainColumn->Add(0,5, | |
362 | 0, // No vertical stretching | |
363 | wxEXPAND // No border, (mostly useless) horizontal stretching | |
364 | ); | |
365 | #else | |
366 | (void)mainColumn; | |
f6bcfd97 | 367 | #endif // wxUSE_STATLINE |
07f20d9a | 368 | } |
74b31181 | 369 | |
07f20d9a VZ |
370 | void wxWizard::AddBackNextPair(wxBoxSizer *buttonRow) |
371 | { | |
54cf600d | 372 | wxASSERT_MSG( m_btnNext && m_btnPrev, |
9a83f860 VZ |
373 | wxT("You must create the buttons before calling ") |
374 | wxT("wxWizard::AddBackNextPair") ); | |
54cf600d | 375 | |
07f20d9a VZ |
376 | wxBoxSizer *backNextPair = new wxBoxSizer(wxHORIZONTAL); |
377 | buttonRow->Add( | |
378 | backNextPair, | |
379 | 0, // No horizontal stretching | |
380 | wxALL, // Border all around | |
381 | 5 // Border width | |
382 | ); | |
ca65c044 | 383 | |
07f20d9a | 384 | backNextPair->Add(m_btnPrev); |
96989020 | 385 | backNextPair->Add(10, 0, |
07f20d9a VZ |
386 | 0, // No horizontal stretching |
387 | wxEXPAND // No border, (mostly useless) vertical stretching | |
388 | ); | |
07f20d9a VZ |
389 | backNextPair->Add(m_btnNext); |
390 | } | |
66cd017c | 391 | |
07f20d9a VZ |
392 | void wxWizard::AddButtonRow(wxBoxSizer *mainColumn) |
393 | { | |
9473e9a4 VZ |
394 | // the order in which the buttons are created determines the TAB order - at least under MSWindows... |
395 | // although the 'back' button appears before the 'next' button, a more userfriendly tab order is | |
396 | // to activate the 'next' button first (create the next button before the back button). | |
397 | // The reason is: The user will repeatedly enter information in the wizard pages and then wants to | |
398 | // press 'next'. If a user uses mostly the keyboard, he would have to skip the 'back' button | |
e75e8815 | 399 | // every time. This is annoying. There is a second reason: RETURN acts as TAB. If the 'next' |
9473e9a4 VZ |
400 | // button comes first in the TAB order, the user can enter information very fast using the RETURN |
401 | // key to TAB to the next entry field and page. This would not be possible, if the 'back' button | |
402 | // was created before the 'next' button. | |
403 | ||
a6328131 | 404 | bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); |
94c09a19 | 405 | int buttonStyle = isPda ? wxBU_EXACTFIT : 0; |
a6328131 | 406 | |
07f20d9a | 407 | wxBoxSizer *buttonRow = new wxBoxSizer(wxHORIZONTAL); |
977a3818 JS |
408 | #ifdef __WXMAC__ |
409 | if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON) | |
410 | mainColumn->Add( | |
411 | buttonRow, | |
412 | 0, // Vertically unstretchable | |
413 | wxGROW|wxALIGN_CENTRE | |
414 | ); | |
415 | else | |
416 | #endif | |
07f20d9a VZ |
417 | mainColumn->Add( |
418 | buttonRow, | |
419 | 0, // Vertically unstretchable | |
420 | wxALIGN_RIGHT // Right aligned, no border | |
421 | ); | |
66cd017c | 422 | |
9473e9a4 VZ |
423 | // Desired TAB order is 'next', 'cancel', 'help', 'back'. This makes the 'back' button the last control on the page. |
424 | // Create the buttons in the right order... | |
977a3818 JS |
425 | wxButton *btnHelp=0; |
426 | #ifdef __WXMAC__ | |
427 | if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON) | |
d90443b8 | 428 | btnHelp=new wxButton(this, wxID_HELP, wxEmptyString, wxDefaultPosition, wxDefaultSize, buttonStyle); |
977a3818 JS |
429 | #endif |
430 | ||
9473e9a4 | 431 | m_btnNext = new wxButton(this, wxID_FORWARD, _("&Next >")); |
a6328131 | 432 | wxButton *btnCancel=new wxButton(this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition, wxDefaultSize, buttonStyle); |
977a3818 | 433 | #ifndef __WXMAC__ |
07f20d9a | 434 | if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON) |
a6328131 | 435 | btnHelp=new wxButton(this, wxID_HELP, _("&Help"), wxDefaultPosition, wxDefaultSize, buttonStyle); |
977a3818 | 436 | #endif |
a6328131 | 437 | m_btnPrev = new wxButton(this, wxID_BACKWARD, _("< &Back"), wxDefaultPosition, wxDefaultSize, buttonStyle); |
9473e9a4 VZ |
438 | |
439 | if (btnHelp) | |
977a3818 | 440 | { |
07f20d9a | 441 | buttonRow->Add( |
9473e9a4 | 442 | btnHelp, |
07f20d9a VZ |
443 | 0, // Horizontally unstretchable |
444 | wxALL, // Border all around, top aligned | |
445 | 5 // Border width | |
977a3818 JS |
446 | ); |
447 | #ifdef __WXMAC__ | |
448 | // Put stretchable space between help button and others | |
449 | buttonRow->Add(0, 0, 1, wxALIGN_CENTRE, 0); | |
450 | #endif | |
451 | } | |
07f20d9a VZ |
452 | |
453 | AddBackNextPair(buttonRow); | |
ca65c044 | 454 | |
07f20d9a | 455 | buttonRow->Add( |
9473e9a4 | 456 | btnCancel, |
07f20d9a VZ |
457 | 0, // Horizontally unstretchable |
458 | wxALL, // Border all around, top aligned | |
459 | 5 // Border width | |
460 | ); | |
461 | } | |
66cd017c | 462 | |
07f20d9a VZ |
463 | void wxWizard::DoCreateControls() |
464 | { | |
465 | // do nothing if the controls were already created | |
466 | if ( WasCreated() ) | |
467 | return; | |
ca65c044 | 468 | |
a6328131 | 469 | bool isPda = (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA); |
94c09a19 | 470 | |
a6328131 JS |
471 | // Horizontal stretching, and if not PDA, border all around |
472 | int mainColumnSizerFlags = isPda ? wxEXPAND : wxALL|wxEXPAND ; | |
94c09a19 | 473 | |
07f20d9a VZ |
474 | // wxWindow::SetSizer will be called at end |
475 | wxBoxSizer *windowSizer = new wxBoxSizer(wxVERTICAL); | |
ca65c044 | 476 | |
07f20d9a VZ |
477 | wxBoxSizer *mainColumn = new wxBoxSizer(wxVERTICAL); |
478 | windowSizer->Add( | |
479 | mainColumn, | |
480 | 1, // Vertical stretching | |
a6328131 | 481 | mainColumnSizerFlags, |
07f20d9a VZ |
482 | 5 // Border width |
483 | ); | |
ca65c044 | 484 | |
07f20d9a | 485 | AddBitmapRow(mainColumn); |
94c09a19 | 486 | |
a6328131 JS |
487 | if (!isPda) |
488 | AddStaticLine(mainColumn); | |
94c09a19 | 489 | |
07f20d9a | 490 | AddButtonRow(mainColumn); |
ca65c044 | 491 | |
07f20d9a | 492 | SetSizer(windowSizer); |
66cd017c VZ |
493 | } |
494 | ||
f6bcfd97 BP |
495 | void wxWizard::SetPageSize(const wxSize& size) |
496 | { | |
0a089246 | 497 | wxCHECK_RET(!m_started, wxT("wxWizard::SetPageSize after RunWizard")); |
f6bcfd97 BP |
498 | m_sizePage = size; |
499 | } | |
500 | ||
07f20d9a VZ |
501 | void wxWizard::FitToPage(const wxWizardPage *page) |
502 | { | |
0a089246 | 503 | wxCHECK_RET(!m_started, wxT("wxWizard::FitToPage after RunWizard")); |
ca65c044 | 504 | |
c73b439f VZ |
505 | while ( page ) |
506 | { | |
507 | wxSize size = page->GetBestSize(); | |
508 | ||
07f20d9a | 509 | m_sizePage.IncTo(size); |
c73b439f VZ |
510 | |
511 | page = page->GetNext(); | |
512 | } | |
c73b439f VZ |
513 | } |
514 | ||
74b31181 | 515 | bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward) |
66cd017c | 516 | { |
223d09f6 | 517 | wxASSERT_MSG( page != m_page, wxT("this is useless") ); |
66cd017c | 518 | |
0a089246 VZ |
519 | wxSizerFlags flags(1); |
520 | flags.Border(wxALL, m_border).Expand(); | |
521 | ||
522 | if ( !m_started ) | |
523 | { | |
524 | if ( m_usingSizer ) | |
525 | { | |
526 | m_sizerBmpAndPage->Add(m_sizerPage, flags); | |
527 | ||
528 | // now that our layout is computed correctly, hide the pages | |
529 | // artificially shown in wxWizardSizer::Insert() back again | |
530 | m_sizerPage->HidePages(); | |
531 | } | |
532 | } | |
533 | ||
534 | ||
0a089246 VZ |
535 | // remember the old bitmap (if any) to compare with the new one later |
536 | wxBitmap bmpPrev; | |
7cc5041d VZ |
537 | |
538 | // check for previous page | |
74b31181 | 539 | if ( m_page ) |
66cd017c | 540 | { |
74b31181 | 541 | // send the event to the old page |
0a089246 VZ |
542 | wxWizardEvent event(wxEVT_WIZARD_PAGE_CHANGING, GetId(), |
543 | goingForward, m_page); | |
74b31181 VZ |
544 | if ( m_page->GetEventHandler()->ProcessEvent(event) && |
545 | !event.IsAllowed() ) | |
546 | { | |
547 | // vetoed by the page | |
ca65c044 | 548 | return false; |
74b31181 | 549 | } |
66cd017c | 550 | |
74b31181 VZ |
551 | m_page->Hide(); |
552 | ||
0a089246 VZ |
553 | bmpPrev = m_page->GetBitmap(); |
554 | ||
555 | if ( !m_usingSizer ) | |
556 | m_sizerBmpAndPage->Detach(m_page); | |
dee5b92f | 557 | } |
66cd017c | 558 | |
74b31181 | 559 | // is this the end? |
71d6cd60 | 560 | if ( !page ) |
66cd017c | 561 | { |
74b31181 | 562 | // terminate successfully |
0a089246 | 563 | if ( IsModal() ) |
b3eb133b WS |
564 | { |
565 | EndModal(wxID_OK); | |
566 | } | |
567 | else | |
568 | { | |
569 | SetReturnCode(wxID_OK); | |
570 | Hide(); | |
571 | } | |
64c2fa13 VZ |
572 | |
573 | // and notify the user code (this is especially useful for modeless | |
574 | // wizards) | |
71d6cd60 | 575 | wxWizardEvent event(wxEVT_WIZARD_FINISHED, GetId(), false, m_page); |
64c2fa13 VZ |
576 | (void)GetEventHandler()->ProcessEvent(event); |
577 | ||
71d6cd60 VZ |
578 | m_page = NULL; |
579 | ||
ca65c044 | 580 | return true; |
74b31181 | 581 | } |
66cd017c | 582 | |
71d6cd60 VZ |
583 | // notice that we change m_page only here so that wxEVT_WIZARD_FINISHED |
584 | // event above could still use the correct (i.e. old) value of m_page | |
585 | m_page = page; | |
586 | ||
74b31181 VZ |
587 | // position and show the new page |
588 | (void)m_page->TransferDataToWindow(); | |
ca65c044 | 589 | |
0a089246 | 590 | if ( m_usingSizer ) |
7cc5041d | 591 | { |
0a089246 VZ |
592 | // wxWizardSizer::RecalcSizes wants to be called when m_page changes |
593 | m_sizerPage->RecalcSizes(); | |
594 | } | |
595 | else // pages are not managed by the sizer | |
596 | { | |
597 | m_sizerBmpAndPage->Add(m_page, flags); | |
598 | m_sizerBmpAndPage->SetItemMinSize(m_page, GetPageSize()); | |
7cc5041d VZ |
599 | } |
600 | ||
461dae94 | 601 | #if wxUSE_STATBMP |
0a089246 | 602 | // update the bitmap if:it changed |
3aa8e4ea | 603 | wxBitmap bmp; |
0a089246 | 604 | if ( m_statbmp ) |
f1df0927 | 605 | { |
3aa8e4ea | 606 | bmp = m_page->GetBitmap(); |
a1b806b9 | 607 | if ( !bmp.IsOk() ) |
cfd88569 | 608 | bmp = m_bitmap; |
0a089246 | 609 | |
a1b806b9 | 610 | if ( !bmpPrev.IsOk() ) |
0a089246 VZ |
611 | bmpPrev = m_bitmap; |
612 | ||
3aa8e4ea JS |
613 | if (!GetBitmapPlacement()) |
614 | { | |
615 | if ( !bmp.IsSameAs(bmpPrev) ) | |
616 | m_statbmp->SetBitmap(bmp); | |
617 | } | |
f1df0927 | 618 | } |
0a089246 VZ |
619 | #endif // wxUSE_STATBMP |
620 | ||
f1df0927 | 621 | |
74b31181 | 622 | // and update the buttons state |
2b5f62a0 | 623 | m_btnPrev->Enable(HasPrevPage(m_page)); |
66cd017c | 624 | |
7f3bf33a VZ |
625 | const bool hasNext = HasNextPage(m_page); |
626 | const wxString label = hasNext ? _("&Next >") : _("&Finish"); | |
627 | if ( label != m_btnNext->GetLabel() ) | |
628 | m_btnNext->SetLabel(label); | |
66cd017c | 629 | |
0a089246 VZ |
630 | m_btnNext->SetDefault(); |
631 | ||
632 | ||
5bc28e84 | 633 | // send the change event to the new page now |
2365e5cb | 634 | wxWizardEvent event(wxEVT_WIZARD_PAGE_CHANGED, GetId(), goingForward, m_page); |
5bc28e84 VZ |
635 | (void)m_page->GetEventHandler()->ProcessEvent(event); |
636 | ||
637 | // and finally show it | |
638 | m_page->Show(); | |
639 | m_page->SetFocus(); | |
640 | ||
0a089246 VZ |
641 | if ( !m_usingSizer ) |
642 | m_sizerBmpAndPage->Layout(); | |
643 | ||
644 | if ( !m_started ) | |
645 | { | |
646 | m_started = true; | |
647 | ||
3aa8e4ea JS |
648 | DoWizardLayout(); |
649 | } | |
650 | ||
634bb98a | 651 | if (GetBitmapPlacement() && m_statbmp) |
3aa8e4ea JS |
652 | { |
653 | ResizeBitmap(bmp); | |
634bb98a | 654 | |
3aa8e4ea JS |
655 | if ( !bmp.IsSameAs(bmpPrev) ) |
656 | m_statbmp->SetBitmap(bmp); | |
634bb98a | 657 | |
3aa8e4ea JS |
658 | if (m_usingSizer) |
659 | m_sizerPage->RecalcSizes(); | |
0a089246 VZ |
660 | } |
661 | ||
deeb0a89 JS |
662 | wxWizardEvent pageShownEvent(wxEVT_WIZARD_PAGE_SHOWN, GetId(), |
663 | goingForward, m_page); | |
664 | m_page->GetEventHandler()->ProcessEvent(pageShownEvent); | |
665 | ||
ca65c044 | 666 | return true; |
66cd017c VZ |
667 | } |
668 | ||
3aa8e4ea JS |
669 | /// Do fit, and adjust to screen size if necessary |
670 | void wxWizard::DoWizardLayout() | |
671 | { | |
672 | if ( wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA ) | |
673 | { | |
674 | if (CanDoLayoutAdaptation()) | |
675 | DoLayoutAdaptation(); | |
676 | else | |
677 | GetSizer()->SetSizeHints(this); | |
678 | ||
679 | if ( m_posWizard == wxDefaultPosition ) | |
680 | CentreOnScreen(); | |
681 | } | |
682 | ||
683 | SetLayoutAdaptationDone(true); | |
684 | } | |
685 | ||
74b31181 | 686 | bool wxWizard::RunWizard(wxWizardPage *firstPage) |
66cd017c | 687 | { |
ca65c044 WS |
688 | wxCHECK_MSG( firstPage, false, wxT("can't run empty wizard") ); |
689 | ||
ca65c044 WS |
690 | // can't return false here because there is no old page |
691 | (void)ShowPage(firstPage, true /* forward */); | |
66cd017c | 692 | |
94c09a19 | 693 | m_wasModal = true; |
37f6a080 | 694 | |
66cd017c VZ |
695 | return ShowModal() == wxID_OK; |
696 | } | |
697 | ||
74b31181 | 698 | wxWizardPage *wxWizard::GetCurrentPage() const |
66cd017c | 699 | { |
74b31181 | 700 | return m_page; |
66cd017c VZ |
701 | } |
702 | ||
4fe5383d | 703 | wxSize wxWizard::GetPageSize() const |
07f20d9a VZ |
704 | { |
705 | // default width and height of the page | |
0a089246 VZ |
706 | int DEFAULT_PAGE_WIDTH, |
707 | DEFAULT_PAGE_HEIGHT; | |
708 | if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA ) | |
a6328131 JS |
709 | { |
710 | // Make the default page size small enough to fit on screen | |
711 | DEFAULT_PAGE_WIDTH = wxSystemSettings::GetMetric(wxSYS_SCREEN_X) / 2; | |
712 | DEFAULT_PAGE_HEIGHT = wxSystemSettings::GetMetric(wxSYS_SCREEN_Y) / 2; | |
713 | } | |
0a089246 VZ |
714 | else // !PDA |
715 | { | |
716 | DEFAULT_PAGE_WIDTH = | |
717 | DEFAULT_PAGE_HEIGHT = 270; | |
718 | } | |
94c09a19 | 719 | |
0a089246 VZ |
720 | // start with default minimal size |
721 | wxSize pageSize(DEFAULT_PAGE_WIDTH, DEFAULT_PAGE_HEIGHT); | |
ca65c044 | 722 | |
0a089246 VZ |
723 | // make the page at least as big as specified by user |
724 | pageSize.IncTo(m_sizePage); | |
ca65c044 | 725 | |
aedd6d6a VZ |
726 | if ( m_statbmp ) |
727 | { | |
0a089246 VZ |
728 | // make the page at least as tall as the bitmap |
729 | pageSize.IncTo(wxSize(0, m_bitmap.GetHeight())); | |
aedd6d6a | 730 | } |
ca65c044 | 731 | |
0a089246 VZ |
732 | if ( m_usingSizer ) |
733 | { | |
734 | // make it big enough to contain all pages added to the sizer | |
735 | pageSize.IncTo(m_sizerPage->GetMaxChildSize()); | |
736 | } | |
737 | ||
738 | return pageSize; | |
739 | } | |
740 | ||
741 | wxSizer *wxWizard::GetPageAreaSizer() const | |
742 | { | |
743 | return m_sizerPage; | |
744 | } | |
745 | ||
746 | void wxWizard::SetBorder(int border) | |
747 | { | |
748 | wxCHECK_RET(!m_started, wxT("wxWizard::SetBorder after RunWizard")); | |
749 | ||
750 | m_border = border; | |
4fe5383d VZ |
751 | } |
752 | ||
20f18ea1 | 753 | void wxWizard::OnCancel(wxCommandEvent& WXUNUSED(eventUnused)) |
66cd017c | 754 | { |
74b31181 VZ |
755 | // this function probably can never be called when we don't have an active |
756 | // page, but a small extra check won't hurt | |
757 | wxWindow *win = m_page ? (wxWindow *)m_page : (wxWindow *)this; | |
758 | ||
ca65c044 | 759 | wxWizardEvent event(wxEVT_WIZARD_CANCEL, GetId(), false, m_page); |
74b31181 | 760 | if ( !win->GetEventHandler()->ProcessEvent(event) || event.IsAllowed() ) |
66cd017c VZ |
761 | { |
762 | // no objections - close the dialog | |
b3eb133b WS |
763 | if(IsModal()) |
764 | { | |
765 | EndModal(wxID_CANCEL); | |
766 | } | |
767 | else | |
768 | { | |
769 | SetReturnCode(wxID_CANCEL); | |
770 | Hide(); | |
771 | } | |
66cd017c VZ |
772 | } |
773 | //else: request to Cancel ignored | |
774 | } | |
775 | ||
74b31181 | 776 | void wxWizard::OnBackOrNext(wxCommandEvent& event) |
66cd017c VZ |
777 | { |
778 | wxASSERT_MSG( (event.GetEventObject() == m_btnNext) || | |
779 | (event.GetEventObject() == m_btnPrev), | |
223d09f6 | 780 | wxT("unknown button") ); |
66cd017c | 781 | |
9a83f860 | 782 | wxCHECK_RET( m_page, wxT("should have a valid current page") ); |
47e64664 | 783 | |
f6bcfd97 | 784 | // ask the current page first: notice that we do it before calling |
e75e8815 | 785 | // GetNext/Prev() because the data transferred from the controls of the page |
f6bcfd97 | 786 | // may change the value returned by these methods |
47e64664 | 787 | if ( !m_page->Validate() || !m_page->TransferDataFromWindow() ) |
f6bcfd97 BP |
788 | { |
789 | // the page data is incorrect, don't do anything | |
790 | return; | |
791 | } | |
792 | ||
74b31181 | 793 | bool forward = event.GetEventObject() == m_btnNext; |
66cd017c | 794 | |
c9f18835 JS |
795 | // Give the application a chance to set state which may influence GetNext()/GetPrev() |
796 | wxWizardEvent eventPreChanged(wxEVT_WIZARD_BEFORE_PAGE_CHANGED, GetId(), forward, m_page); | |
797 | (void)m_page->GetEventHandler()->ProcessEvent(eventPreChanged); | |
798 | ||
799 | if (!eventPreChanged.IsAllowed()) | |
800 | return; | |
801 | ||
74b31181 VZ |
802 | wxWizardPage *page; |
803 | if ( forward ) | |
66cd017c | 804 | { |
74b31181 | 805 | page = m_page->GetNext(); |
66cd017c | 806 | } |
74b31181 | 807 | else // back |
66cd017c | 808 | { |
74b31181 VZ |
809 | page = m_page->GetPrev(); |
810 | ||
223d09f6 | 811 | wxASSERT_MSG( page, wxT("\"<Back\" button should have been disabled") ); |
66cd017c | 812 | } |
74b31181 | 813 | |
0a089246 | 814 | // just pass to the new page (or maybe not - but we don't care here) |
74b31181 | 815 | (void)ShowPage(page, forward); |
66cd017c VZ |
816 | } |
817 | ||
f80bf901 VZ |
818 | void wxWizard::OnHelp(wxCommandEvent& WXUNUSED(event)) |
819 | { | |
820 | // this function probably can never be called when we don't have an active | |
821 | // page, but a small extra check won't hurt | |
822 | if(m_page != NULL) | |
823 | { | |
824 | // Create and send the help event to the specific page handler | |
825 | // event data contains the active page so that context-sensitive | |
826 | // help is possible | |
ca65c044 | 827 | wxWizardEvent eventHelp(wxEVT_WIZARD_HELP, GetId(), true, m_page); |
f80bf901 VZ |
828 | (void)m_page->GetEventHandler()->ProcessEvent(eventHelp); |
829 | } | |
830 | } | |
831 | ||
91c68292 VZ |
832 | void wxWizard::OnWizEvent(wxWizardEvent& event) |
833 | { | |
834 | // the dialogs have wxWS_EX_BLOCK_EVENTS style on by default but we want to | |
835 | // propagate wxEVT_WIZARD_XXX to the parent (if any), so do it manually | |
836 | if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS) ) | |
837 | { | |
838 | // the event will be propagated anyhow | |
0a640208 | 839 | event.Skip(); |
91c68292 | 840 | } |
b3eb133b WS |
841 | else |
842 | { | |
843 | wxWindow *parent = GetParent(); | |
91c68292 | 844 | |
b3eb133b WS |
845 | if ( !parent || !parent->GetEventHandler()->ProcessEvent(event) ) |
846 | { | |
847 | event.Skip(); | |
848 | } | |
849 | } | |
37f6a080 | 850 | |
94c09a19 | 851 | if ( ( !m_wasModal ) && |
37f6a080 JS |
852 | event.IsAllowed() && |
853 | ( event.GetEventType() == wxEVT_WIZARD_FINISHED || | |
854 | event.GetEventType() == wxEVT_WIZARD_CANCEL | |
855 | ) | |
856 | ) | |
857 | { | |
37f6a080 JS |
858 | Destroy(); |
859 | } | |
91c68292 | 860 | } |
f80bf901 | 861 | |
f49fd6d0 JS |
862 | void wxWizard::SetBitmap(const wxBitmap& bitmap) |
863 | { | |
864 | m_bitmap = bitmap; | |
865 | if (m_statbmp) | |
866 | m_statbmp->SetBitmap(m_bitmap); | |
867 | } | |
868 | ||
66cd017c VZ |
869 | // ---------------------------------------------------------------------------- |
870 | // wxWizardEvent | |
871 | // ---------------------------------------------------------------------------- | |
872 | ||
f80bf901 | 873 | wxWizardEvent::wxWizardEvent(wxEventType type, int id, bool direction, wxWizardPage* page) |
66cd017c VZ |
874 | : wxNotifyEvent(type, id) |
875 | { | |
f80bf901 VZ |
876 | // Modified 10-20-2001 Robert Cavanaugh |
877 | // add the active page to the event data | |
74b31181 | 878 | m_direction = direction; |
f80bf901 | 879 | m_page = page; |
66cd017c | 880 | } |
74b31181 | 881 | |
3aa8e4ea JS |
882 | /// Do the adaptation |
883 | bool wxWizard::DoLayoutAdaptation() | |
884 | { | |
885 | wxWindowList windows; | |
886 | wxWindowList pages; | |
887 | ||
888 | // Make all the pages (that use sizers) scrollable | |
889 | for ( wxSizerItemList::compatibility_iterator node = m_sizerPage->GetChildren().GetFirst(); node; node = node->GetNext() ) | |
890 | { | |
891 | wxSizerItem * const item = node->GetData(); | |
892 | if ( item->IsWindow() ) | |
893 | { | |
894 | wxWizardPage* page = wxDynamicCast(item->GetWindow(), wxWizardPage); | |
895 | if (page) | |
896 | { | |
897 | while (page) | |
898 | { | |
899 | if (!pages.Find(page) && page->GetSizer()) | |
900 | { | |
901 | // Create a scrolled window and reparent | |
902 | wxScrolledWindow* scrolledWindow = new wxScrolledWindow(page, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL|wxVSCROLL|wxHSCROLL|wxBORDER_NONE); | |
903 | wxSizer* oldSizer = page->GetSizer(); | |
634bb98a | 904 | |
3aa8e4ea JS |
905 | wxSizer* newSizer = new wxBoxSizer(wxVERTICAL); |
906 | newSizer->Add(scrolledWindow,1, wxEXPAND, 0); | |
634bb98a | 907 | |
3aa8e4ea | 908 | page->SetSizer(newSizer, false /* don't delete the old sizer */); |
634bb98a | 909 | |
3aa8e4ea | 910 | scrolledWindow->SetSizer(oldSizer); |
634bb98a | 911 | |
3aa8e4ea | 912 | wxStandardDialogLayoutAdapter::DoReparentControls(page, scrolledWindow); |
634bb98a | 913 | |
3aa8e4ea JS |
914 | pages.Append(page); |
915 | windows.Append(scrolledWindow); | |
916 | } | |
917 | page = page->GetNext(); | |
918 | } | |
919 | } | |
920 | } | |
921 | } | |
922 | ||
923 | wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows); | |
924 | ||
a8eeee19 JS |
925 | // Size event doesn't get sent soon enough on wxGTK |
926 | DoLayout(); | |
03647350 | 927 | |
3aa8e4ea JS |
928 | SetLayoutAdaptationDone(true); |
929 | ||
930 | return true; | |
931 | } | |
932 | ||
933 | bool wxWizard::ResizeBitmap(wxBitmap& bmp) | |
934 | { | |
935 | if (!GetBitmapPlacement()) | |
936 | return false; | |
937 | ||
a1b806b9 | 938 | if (bmp.IsOk()) |
3aa8e4ea JS |
939 | { |
940 | wxSize pageSize = m_sizerPage->GetSize(); | |
49b75749 JS |
941 | if (pageSize == wxSize(0,0)) |
942 | pageSize = GetPageSize(); | |
3aa8e4ea JS |
943 | int bitmapWidth = wxMax(bmp.GetWidth(), GetMinimumBitmapWidth()); |
944 | int bitmapHeight = pageSize.y; | |
945 | ||
a1b806b9 | 946 | if (!m_statbmp->GetBitmap().IsOk() || m_statbmp->GetBitmap().GetHeight() != bitmapHeight) |
3aa8e4ea JS |
947 | { |
948 | wxBitmap bitmap(bitmapWidth, bitmapHeight); | |
949 | { | |
950 | wxMemoryDC dc; | |
951 | dc.SelectObject(bitmap); | |
952 | dc.SetBackground(wxBrush(m_bitmapBackgroundColour)); | |
953 | dc.Clear(); | |
954 | ||
955 | if (GetBitmapPlacement() & wxWIZARD_TILE) | |
956 | { | |
957 | TileBitmap(wxRect(0, 0, bitmapWidth, bitmapHeight), dc, bmp); | |
958 | } | |
959 | else | |
960 | { | |
961 | int x, y; | |
962 | ||
963 | if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT) | |
964 | x = 0; | |
965 | else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT) | |
634bb98a | 966 | x = bitmapWidth - bmp.GetWidth(); |
3aa8e4ea | 967 | else |
634bb98a | 968 | x = (bitmapWidth - bmp.GetWidth())/2; |
3aa8e4ea JS |
969 | |
970 | if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP) | |
971 | y = 0; | |
972 | else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM) | |
634bb98a | 973 | y = bitmapHeight - bmp.GetHeight(); |
3aa8e4ea | 974 | else |
634bb98a | 975 | y = (bitmapHeight - bmp.GetHeight())/2; |
3aa8e4ea JS |
976 | |
977 | dc.DrawBitmap(bmp, x, y, true); | |
978 | dc.SelectObject(wxNullBitmap); | |
979 | } | |
980 | } | |
981 | ||
982 | bmp = bitmap; | |
983 | } | |
984 | } | |
985 | ||
986 | return true; | |
987 | } | |
988 | ||
989 | bool wxWizard::TileBitmap(const wxRect& rect, wxDC& dc, const wxBitmap& bitmap) | |
990 | { | |
991 | int w = bitmap.GetWidth(); | |
992 | int h = bitmap.GetHeight(); | |
993 | ||
994 | wxMemoryDC dcMem; | |
995 | ||
996 | dcMem.SelectObjectAsSource(bitmap); | |
997 | ||
998 | int i, j; | |
999 | for (i = rect.x; i < rect.x + rect.width; i += w) | |
1000 | { | |
1001 | for (j = rect.y; j < rect.y + rect.height; j+= h) | |
1002 | dc.Blit(i, j, bitmap.GetWidth(), bitmap.GetHeight(), & dcMem, 0, 0); | |
1003 | } | |
1004 | dcMem.SelectObject(wxNullBitmap); | |
1005 | ||
1006 | return true; | |
1007 | } | |
1008 | ||
1e6feb95 | 1009 | #endif // wxUSE_WIZARDDLG |