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