1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/wizard.cpp
3 // Purpose: generic implementation of wxWizard class
4 // Author: Vadim Zeitlin
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
9 // Robert Vazan (sizers)
12 // Copyright: (c) 1999 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
13 // Licence: wxWindows licence
14 ///////////////////////////////////////////////////////////////////////////////
16 // ============================================================================
18 // ============================================================================
20 // ----------------------------------------------------------------------------
22 // ----------------------------------------------------------------------------
24 // For compilers that support precompilation, includes "wx.h".
25 #include "wx/wxprec.h"
34 #include "wx/dynarray.h"
36 #include "wx/statbmp.h"
37 #include "wx/button.h"
38 #include "wx/settings.h"
42 #include "wx/statline.h"
44 #include "wx/scrolwin.h"
45 #include "wx/wizard.h"
46 #include "wx/dcmemory.h"
48 // ----------------------------------------------------------------------------
50 // ----------------------------------------------------------------------------
52 class wxWizardSizer
: public wxSizer
55 wxWizardSizer(wxWizard
*owner
);
57 virtual wxSizerItem
*Insert(size_t index
, wxSizerItem
*item
);
59 virtual void RecalcSizes();
60 virtual wxSize
CalcMin();
62 // get the max size of all wizard pages
63 wxSize
GetMaxChildSize();
65 // return the border which can be either set using wxWizard::SetBorder() or
67 int GetBorder() const;
69 // hide the pages which we temporarily "show" when they're added to this
70 // sizer (see Insert())
74 wxSize
SiblingSize(wxSizerItem
*child
);
80 // ----------------------------------------------------------------------------
81 // event tables and such
82 // ----------------------------------------------------------------------------
84 wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_CHANGED
, wxWizardEvent
);
85 wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_CHANGING
, wxWizardEvent
);
86 wxDEFINE_EVENT( wxEVT_WIZARD_CANCEL
, wxWizardEvent
);
87 wxDEFINE_EVENT( wxEVT_WIZARD_FINISHED
, wxWizardEvent
);
88 wxDEFINE_EVENT( wxEVT_WIZARD_HELP
, wxWizardEvent
);
90 BEGIN_EVENT_TABLE(wxWizard
, wxDialog
)
91 EVT_BUTTON(wxID_CANCEL
, wxWizard::OnCancel
)
92 EVT_BUTTON(wxID_BACKWARD
, wxWizard::OnBackOrNext
)
93 EVT_BUTTON(wxID_FORWARD
, wxWizard::OnBackOrNext
)
94 EVT_BUTTON(wxID_HELP
, wxWizard::OnHelp
)
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
)
103 IMPLEMENT_DYNAMIC_CLASS(wxWizard
, wxDialog
)
112 IMPLEMENT_ABSTRACT_CLASS(wxWizardPage
, wxPanel
)
113 IMPLEMENT_DYNAMIC_CLASS(wxWizardPageSimple
, wxWizardPage
)
114 IMPLEMENT_DYNAMIC_CLASS(wxWizardEvent
, wxNotifyEvent
)
116 // ============================================================================
118 // ============================================================================
120 // ----------------------------------------------------------------------------
122 // ----------------------------------------------------------------------------
124 void wxWizardPage::Init()
126 m_bitmap
= wxNullBitmap
;
129 wxWizardPage::wxWizardPage(wxWizard
*parent
,
130 const wxBitmap
& bitmap
)
132 Create(parent
, bitmap
);
135 bool wxWizardPage::Create(wxWizard
*parent
,
136 const wxBitmap
& bitmap
)
138 if ( !wxPanel::Create(parent
, wxID_ANY
) )
143 // initially the page is hidden, it's shown only when it becomes current
149 // ----------------------------------------------------------------------------
150 // wxWizardPageSimple
151 // ----------------------------------------------------------------------------
153 wxWizardPage
*wxWizardPageSimple::GetPrev() const
158 wxWizardPage
*wxWizardPageSimple::GetNext() const
163 // ----------------------------------------------------------------------------
165 // ----------------------------------------------------------------------------
167 wxWizardSizer::wxWizardSizer(wxWizard
*owner
)
169 m_childSize(wxDefaultSize
)
173 wxSizerItem
*wxWizardSizer::Insert(size_t index
, wxSizerItem
*item
)
175 m_owner
->m_usingSizer
= true;
177 if ( item
->IsWindow() )
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();
185 return wxSizer::Insert(index
, item
);
188 void wxWizardSizer::HidePages()
190 for ( wxSizerItemList::compatibility_iterator node
= GetChildren().GetFirst();
192 node
= node
->GetNext() )
194 wxSizerItem
* const item
= node
->GetData();
195 if ( item
->IsWindow() )
196 item
->GetWindow()->wxWindowBase::Show(false);
200 void wxWizardSizer::RecalcSizes()
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
)
206 m_owner
->m_page
->SetSize(wxRect(m_position
, m_size
));
210 wxSize
wxWizardSizer::CalcMin()
212 return m_owner
->GetPageSize();
215 wxSize
wxWizardSizer::GetMaxChildSize()
219 for ( wxSizerItemList::compatibility_iterator childNode
= m_children
.GetFirst();
221 childNode
= childNode
->GetNext() )
223 wxSizerItem
*child
= childNode
->GetData();
224 maxOfMin
.IncTo(child
->CalcMin());
225 maxOfMin
.IncTo(SiblingSize(child
));
228 if ( m_owner
->m_started
)
230 m_childSize
= maxOfMin
;
236 int wxWizardSizer::GetBorder() const
238 return m_owner
->m_border
;
241 wxSize
wxWizardSizer::SiblingSize(wxSizerItem
*child
)
245 if ( child
->IsWindow() )
247 wxWizardPage
*page
= wxDynamicCast(child
->GetWindow(), wxWizardPage
);
250 for ( wxWizardPage
*sibling
= page
->GetNext();
252 sibling
= sibling
->GetNext() )
254 if ( sibling
->GetSizer() )
256 maxSibling
.IncTo(sibling
->GetSizer()->CalcMin());
265 // ----------------------------------------------------------------------------
266 // generic wxWizard implementation
267 // ----------------------------------------------------------------------------
269 void wxWizard::Init()
271 m_posWizard
= wxDefaultPosition
;
273 m_btnPrev
= m_btnNext
= NULL
;
275 m_sizerBmpAndPage
= NULL
;
280 m_usingSizer
= false;
281 m_bitmapBackgroundColour
= *wxWHITE
;
282 m_bitmapPlacement
= 0;
283 m_bitmapMinimumWidth
= 115;
286 bool wxWizard::Create(wxWindow
*parent
,
288 const wxString
& title
,
289 const wxBitmap
& bitmap
,
293 bool result
= wxDialog::Create(parent
,id
,title
,pos
,wxDefaultSize
,style
);
303 wxWizard::~wxWizard()
305 // normally we don't have to delete this sizer as it's deleted by the
306 // associated window but if we never used it or didn't set it as the window
307 // sizer yet, do delete it manually
308 if ( !m_usingSizer
|| !m_started
)
312 void wxWizard::AddBitmapRow(wxBoxSizer
*mainColumn
)
314 m_sizerBmpAndPage
= new wxBoxSizer(wxHORIZONTAL
);
317 1, // Vertically stretchable
318 wxEXPAND
// Horizonal stretching, no border
321 0, // No vertical stretching
322 wxEXPAND
// No border, (mostly useless) horizontal stretching
328 wxSize
bitmapSize(wxDefaultSize
);
329 if (GetBitmapPlacement())
330 bitmapSize
.x
= GetMinimumBitmapWidth();
332 m_statbmp
= new wxStaticBitmap(this, wxID_ANY
, m_bitmap
, wxDefaultPosition
, bitmapSize
);
333 m_sizerBmpAndPage
->Add(
335 0, // No horizontal stretching
336 wxALL
, // Border all around, top alignment
339 m_sizerBmpAndPage
->Add(
341 0, // No horizontal stretching
342 wxEXPAND
// No border, (mostly useless) vertical stretching
347 // Added to m_sizerBmpAndPage later
348 m_sizerPage
= new wxWizardSizer(this);
351 void wxWizard::AddStaticLine(wxBoxSizer
*mainColumn
)
355 new wxStaticLine(this, wxID_ANY
),
356 0, // Vertically unstretchable
357 wxEXPAND
| wxALL
, // Border all around, horizontally stretchable
361 0, // No vertical stretching
362 wxEXPAND
// No border, (mostly useless) horizontal stretching
366 #endif // wxUSE_STATLINE
369 void wxWizard::AddBackNextPair(wxBoxSizer
*buttonRow
)
371 wxASSERT_MSG( m_btnNext
&& m_btnPrev
,
372 _T("You must create the buttons before calling ")
373 _T("wxWizard::AddBackNextPair") );
375 // margin between Back and Next buttons
377 static const int BACKNEXT_MARGIN
= 10;
379 static const int BACKNEXT_MARGIN
= 0;
382 wxBoxSizer
*backNextPair
= new wxBoxSizer(wxHORIZONTAL
);
385 0, // No horizontal stretching
386 wxALL
, // Border all around
390 backNextPair
->Add(m_btnPrev
);
391 backNextPair
->Add(BACKNEXT_MARGIN
,0,
392 0, // No horizontal stretching
393 wxEXPAND
// No border, (mostly useless) vertical stretching
395 backNextPair
->Add(m_btnNext
);
398 void wxWizard::AddButtonRow(wxBoxSizer
*mainColumn
)
400 // the order in which the buttons are created determines the TAB order - at least under MSWindows...
401 // although the 'back' button appears before the 'next' button, a more userfriendly tab order is
402 // to activate the 'next' button first (create the next button before the back button).
403 // The reason is: The user will repeatedly enter information in the wizard pages and then wants to
404 // press 'next'. If a user uses mostly the keyboard, he would have to skip the 'back' button
405 // everytime. This is annoying. There is a second reason: RETURN acts as TAB. If the 'next'
406 // button comes first in the TAB order, the user can enter information very fast using the RETURN
407 // key to TAB to the next entry field and page. This would not be possible, if the 'back' button
408 // was created before the 'next' button.
410 bool isPda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
411 int buttonStyle
= isPda
? wxBU_EXACTFIT
: 0;
413 wxBoxSizer
*buttonRow
= new wxBoxSizer(wxHORIZONTAL
);
415 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
418 0, // Vertically unstretchable
419 wxGROW
|wxALIGN_CENTRE
425 0, // Vertically unstretchable
426 wxALIGN_RIGHT
// Right aligned, no border
429 // Desired TAB order is 'next', 'cancel', 'help', 'back'. This makes the 'back' button the last control on the page.
430 // Create the buttons in the right order...
433 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
434 btnHelp
=new wxButton(this, wxID_HELP
, _("&Help"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
437 m_btnNext
= new wxButton(this, wxID_FORWARD
, _("&Next >"));
438 wxButton
*btnCancel
=new wxButton(this, wxID_CANCEL
, _("&Cancel"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
440 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
441 btnHelp
=new wxButton(this, wxID_HELP
, _("&Help"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
443 m_btnPrev
= new wxButton(this, wxID_BACKWARD
, _("< &Back"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
449 0, // Horizontally unstretchable
450 wxALL
, // Border all around, top aligned
454 // Put stretchable space between help button and others
455 buttonRow
->Add(0, 0, 1, wxALIGN_CENTRE
, 0);
459 AddBackNextPair(buttonRow
);
463 0, // Horizontally unstretchable
464 wxALL
, // Border all around, top aligned
469 void wxWizard::DoCreateControls()
471 // do nothing if the controls were already created
475 bool isPda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
477 // Horizontal stretching, and if not PDA, border all around
478 int mainColumnSizerFlags
= isPda
? wxEXPAND
: wxALL
|wxEXPAND
;
480 // wxWindow::SetSizer will be called at end
481 wxBoxSizer
*windowSizer
= new wxBoxSizer(wxVERTICAL
);
483 wxBoxSizer
*mainColumn
= new wxBoxSizer(wxVERTICAL
);
486 1, // Vertical stretching
487 mainColumnSizerFlags
,
491 AddBitmapRow(mainColumn
);
494 AddStaticLine(mainColumn
);
496 AddButtonRow(mainColumn
);
498 SetSizer(windowSizer
);
501 void wxWizard::SetPageSize(const wxSize
& size
)
503 wxCHECK_RET(!m_started
, wxT("wxWizard::SetPageSize after RunWizard"));
507 void wxWizard::FitToPage(const wxWizardPage
*page
)
509 wxCHECK_RET(!m_started
, wxT("wxWizard::FitToPage after RunWizard"));
513 wxSize size
= page
->GetBestSize();
515 m_sizePage
.IncTo(size
);
517 page
= page
->GetNext();
521 bool wxWizard::ShowPage(wxWizardPage
*page
, bool goingForward
)
523 wxASSERT_MSG( page
!= m_page
, wxT("this is useless") );
525 wxSizerFlags
flags(1);
526 flags
.Border(wxALL
, m_border
).Expand();
532 m_sizerBmpAndPage
->Add(m_sizerPage
, flags
);
534 // now that our layout is computed correctly, hide the pages
535 // artificially shown in wxWizardSizer::Insert() back again
536 m_sizerPage
->HidePages();
541 // remember the old bitmap (if any) to compare with the new one later
544 // check for previous page
547 // send the event to the old page
548 wxWizardEvent
event(wxEVT_WIZARD_PAGE_CHANGING
, GetId(),
549 goingForward
, m_page
);
550 if ( m_page
->GetEventHandler()->ProcessEvent(event
) &&
553 // vetoed by the page
559 bmpPrev
= m_page
->GetBitmap();
562 m_sizerBmpAndPage
->Detach(m_page
);
571 // terminate successfully
578 SetReturnCode(wxID_OK
);
582 // and notify the user code (this is especially useful for modeless
584 wxWizardEvent
event(wxEVT_WIZARD_FINISHED
, GetId(), false, 0);
585 (void)GetEventHandler()->ProcessEvent(event
);
590 // position and show the new page
591 (void)m_page
->TransferDataToWindow();
595 // wxWizardSizer::RecalcSizes wants to be called when m_page changes
596 m_sizerPage
->RecalcSizes();
598 else // pages are not managed by the sizer
600 m_sizerBmpAndPage
->Add(m_page
, flags
);
601 m_sizerBmpAndPage
->SetItemMinSize(m_page
, GetPageSize());
605 // update the bitmap if:it changed
609 bmp
= m_page
->GetBitmap();
616 if (!GetBitmapPlacement())
618 if ( !bmp
.IsSameAs(bmpPrev
) )
619 m_statbmp
->SetBitmap(bmp
);
622 #endif // wxUSE_STATBMP
625 // and update the buttons state
626 m_btnPrev
->Enable(HasPrevPage(m_page
));
628 const bool hasNext
= HasNextPage(m_page
);
629 const wxString label
= hasNext
? _("&Next >") : _("&Finish");
630 if ( label
!= m_btnNext
->GetLabel() )
631 m_btnNext
->SetLabel(label
);
633 m_btnNext
->SetDefault();
636 // send the change event to the new page now
637 wxWizardEvent
event(wxEVT_WIZARD_PAGE_CHANGED
, GetId(), goingForward
, m_page
);
638 (void)m_page
->GetEventHandler()->ProcessEvent(event
);
640 // and finally show it
645 m_sizerBmpAndPage
->Layout();
654 if (GetBitmapPlacement() && m_statbmp
)
658 if ( !bmp
.IsSameAs(bmpPrev
) )
659 m_statbmp
->SetBitmap(bmp
);
662 m_sizerPage
->RecalcSizes();
668 /// Do fit, and adjust to screen size if necessary
669 void wxWizard::DoWizardLayout()
671 if ( wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
673 if (CanDoLayoutAdaptation())
674 DoLayoutAdaptation();
676 GetSizer()->SetSizeHints(this);
678 if ( m_posWizard
== wxDefaultPosition
)
682 SetLayoutAdaptationDone(true);
685 bool wxWizard::RunWizard(wxWizardPage
*firstPage
)
687 wxCHECK_MSG( firstPage
, false, wxT("can't run empty wizard") );
689 // can't return false here because there is no old page
690 (void)ShowPage(firstPage
, true /* forward */);
694 return ShowModal() == wxID_OK
;
697 wxWizardPage
*wxWizard::GetCurrentPage() const
702 wxSize
wxWizard::GetPageSize() const
704 // default width and height of the page
705 int DEFAULT_PAGE_WIDTH
,
707 if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
)
709 // Make the default page size small enough to fit on screen
710 DEFAULT_PAGE_WIDTH
= wxSystemSettings::GetMetric(wxSYS_SCREEN_X
) / 2;
711 DEFAULT_PAGE_HEIGHT
= wxSystemSettings::GetMetric(wxSYS_SCREEN_Y
) / 2;
716 DEFAULT_PAGE_HEIGHT
= 270;
719 // start with default minimal size
720 wxSize
pageSize(DEFAULT_PAGE_WIDTH
, DEFAULT_PAGE_HEIGHT
);
722 // make the page at least as big as specified by user
723 pageSize
.IncTo(m_sizePage
);
727 // make the page at least as tall as the bitmap
728 pageSize
.IncTo(wxSize(0, m_bitmap
.GetHeight()));
733 // make it big enough to contain all pages added to the sizer
734 pageSize
.IncTo(m_sizerPage
->GetMaxChildSize());
740 wxSizer
*wxWizard::GetPageAreaSizer() const
745 void wxWizard::SetBorder(int border
)
747 wxCHECK_RET(!m_started
, wxT("wxWizard::SetBorder after RunWizard"));
752 void wxWizard::OnCancel(wxCommandEvent
& WXUNUSED(eventUnused
))
754 // this function probably can never be called when we don't have an active
755 // page, but a small extra check won't hurt
756 wxWindow
*win
= m_page
? (wxWindow
*)m_page
: (wxWindow
*)this;
758 wxWizardEvent
event(wxEVT_WIZARD_CANCEL
, GetId(), false, m_page
);
759 if ( !win
->GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed() )
761 // no objections - close the dialog
764 EndModal(wxID_CANCEL
);
768 SetReturnCode(wxID_CANCEL
);
772 //else: request to Cancel ignored
775 void wxWizard::OnBackOrNext(wxCommandEvent
& event
)
777 wxASSERT_MSG( (event
.GetEventObject() == m_btnNext
) ||
778 (event
.GetEventObject() == m_btnPrev
),
779 wxT("unknown button") );
781 wxCHECK_RET( m_page
, _T("should have a valid current page") );
783 // ask the current page first: notice that we do it before calling
784 // GetNext/Prev() because the data transfered from the controls of the page
785 // may change the value returned by these methods
786 if ( !m_page
->Validate() || !m_page
->TransferDataFromWindow() )
788 // the page data is incorrect, don't do anything
792 bool forward
= event
.GetEventObject() == m_btnNext
;
797 page
= m_page
->GetNext();
801 page
= m_page
->GetPrev();
803 wxASSERT_MSG( page
, wxT("\"<Back\" button should have been disabled") );
806 // just pass to the new page (or maybe not - but we don't care here)
807 (void)ShowPage(page
, forward
);
810 void wxWizard::OnHelp(wxCommandEvent
& WXUNUSED(event
))
812 // this function probably can never be called when we don't have an active
813 // page, but a small extra check won't hurt
816 // Create and send the help event to the specific page handler
817 // event data contains the active page so that context-sensitive
819 wxWizardEvent
eventHelp(wxEVT_WIZARD_HELP
, GetId(), true, m_page
);
820 (void)m_page
->GetEventHandler()->ProcessEvent(eventHelp
);
824 void wxWizard::OnWizEvent(wxWizardEvent
& event
)
826 // the dialogs have wxWS_EX_BLOCK_EVENTS style on by default but we want to
827 // propagate wxEVT_WIZARD_XXX to the parent (if any), so do it manually
828 if ( !(GetExtraStyle() & wxWS_EX_BLOCK_EVENTS
) )
830 // the event will be propagated anyhow
835 wxWindow
*parent
= GetParent();
837 if ( !parent
|| !parent
->GetEventHandler()->ProcessEvent(event
) )
843 if ( ( !m_wasModal
) &&
845 ( event
.GetEventType() == wxEVT_WIZARD_FINISHED
||
846 event
.GetEventType() == wxEVT_WIZARD_CANCEL
854 void wxWizard::SetBitmap(const wxBitmap
& bitmap
)
858 m_statbmp
->SetBitmap(m_bitmap
);
861 // ----------------------------------------------------------------------------
863 // ----------------------------------------------------------------------------
865 wxWizardEvent::wxWizardEvent(wxEventType type
, int id
, bool direction
, wxWizardPage
* page
)
866 : wxNotifyEvent(type
, id
)
868 // Modified 10-20-2001 Robert Cavanaugh
869 // add the active page to the event data
870 m_direction
= direction
;
874 /// Do the adaptation
875 bool wxWizard::DoLayoutAdaptation()
877 wxWindowList windows
;
880 // Make all the pages (that use sizers) scrollable
881 for ( wxSizerItemList::compatibility_iterator node
= m_sizerPage
->GetChildren().GetFirst(); node
; node
= node
->GetNext() )
883 wxSizerItem
* const item
= node
->GetData();
884 if ( item
->IsWindow() )
886 wxWizardPage
* page
= wxDynamicCast(item
->GetWindow(), wxWizardPage
);
891 if (!pages
.Find(page
) && page
->GetSizer())
893 // Create a scrolled window and reparent
894 wxScrolledWindow
* scrolledWindow
= new wxScrolledWindow(page
, wxID_ANY
, wxDefaultPosition
, wxDefaultSize
, wxTAB_TRAVERSAL
|wxVSCROLL
|wxHSCROLL
|wxBORDER_NONE
);
895 wxSizer
* oldSizer
= page
->GetSizer();
897 wxSizer
* newSizer
= new wxBoxSizer(wxVERTICAL
);
898 newSizer
->Add(scrolledWindow
,1, wxEXPAND
, 0);
900 page
->SetSizer(newSizer
, false /* don't delete the old sizer */);
902 scrolledWindow
->SetSizer(oldSizer
);
904 wxStandardDialogLayoutAdapter::DoReparentControls(page
, scrolledWindow
);
907 windows
.Append(scrolledWindow
);
909 page
= page
->GetNext();
915 wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows
);
917 // Size event doesn't get sent soon enough on wxGTK
920 SetLayoutAdaptationDone(true);
925 bool wxWizard::ResizeBitmap(wxBitmap
& bmp
)
927 if (!GetBitmapPlacement())
932 wxSize pageSize
= m_sizerPage
->GetSize();
933 if (pageSize
== wxSize(0,0))
934 pageSize
= GetPageSize();
935 int bitmapWidth
= wxMax(bmp
.GetWidth(), GetMinimumBitmapWidth());
936 int bitmapHeight
= pageSize
.y
;
938 if (!m_statbmp
->GetBitmap().Ok() || m_statbmp
->GetBitmap().GetHeight() != bitmapHeight
)
940 wxBitmap
bitmap(bitmapWidth
, bitmapHeight
);
943 dc
.SelectObject(bitmap
);
944 dc
.SetBackground(wxBrush(m_bitmapBackgroundColour
));
947 if (GetBitmapPlacement() & wxWIZARD_TILE
)
949 TileBitmap(wxRect(0, 0, bitmapWidth
, bitmapHeight
), dc
, bmp
);
955 if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT
)
957 else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT
)
958 x
= bitmapWidth
- bmp
.GetWidth();
960 x
= (bitmapWidth
- bmp
.GetWidth())/2;
962 if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP
)
964 else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM
)
965 y
= bitmapHeight
- bmp
.GetHeight();
967 y
= (bitmapHeight
- bmp
.GetHeight())/2;
969 dc
.DrawBitmap(bmp
, x
, y
, true);
970 dc
.SelectObject(wxNullBitmap
);
981 bool wxWizard::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
983 int w
= bitmap
.GetWidth();
984 int h
= bitmap
.GetHeight();
988 dcMem
.SelectObjectAsSource(bitmap
);
991 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
993 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
994 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
996 dcMem
.SelectObject(wxNullBitmap
);
1001 #endif // wxUSE_WIZARDDLG