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 DEFINE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGED
)
85 DEFINE_EVENT_TYPE(wxEVT_WIZARD_PAGE_CHANGING
)
86 DEFINE_EVENT_TYPE(wxEVT_WIZARD_CANCEL
)
87 DEFINE_EVENT_TYPE(wxEVT_WIZARD_FINISHED
)
88 DEFINE_EVENT_TYPE(wxEVT_WIZARD_HELP
)
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()
217 #if !defined(__WXDEBUG__)
218 if ( m_childSize
.IsFullySpecified() )
224 for ( wxSizerItemList::compatibility_iterator childNode
= m_children
.GetFirst();
226 childNode
= childNode
->GetNext() )
228 wxSizerItem
*child
= childNode
->GetData();
229 maxOfMin
.IncTo(child
->CalcMin());
230 maxOfMin
.IncTo(SiblingSize(child
));
233 // No longer applicable since we may change sizes when size adaptation is done
236 if ( m_childSize
.IsFullySpecified() && m_childSize
!= maxOfMin
)
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?")) ;
245 #endif // __WXDEBUG__
248 if ( m_owner
->m_started
)
250 m_childSize
= maxOfMin
;
256 int wxWizardSizer::GetBorder() const
258 return m_owner
->m_border
;
261 wxSize
wxWizardSizer::SiblingSize(wxSizerItem
*child
)
265 if ( child
->IsWindow() )
267 wxWizardPage
*page
= wxDynamicCast(child
->GetWindow(), wxWizardPage
);
270 for ( wxWizardPage
*sibling
= page
->GetNext();
272 sibling
= sibling
->GetNext() )
274 if ( sibling
->GetSizer() )
276 maxSibling
.IncTo(sibling
->GetSizer()->CalcMin());
285 // ----------------------------------------------------------------------------
286 // generic wxWizard implementation
287 // ----------------------------------------------------------------------------
289 void wxWizard::Init()
291 m_posWizard
= wxDefaultPosition
;
292 m_page
= (wxWizardPage
*)NULL
;
293 m_btnPrev
= m_btnNext
= NULL
;
295 m_sizerBmpAndPage
= NULL
;
300 m_usingSizer
= false;
301 m_bitmapBackgroundColour
= *wxWHITE
;
302 m_bitmapPlacement
= 0;
303 m_bitmapMinimumWidth
= 115;
306 bool wxWizard::Create(wxWindow
*parent
,
308 const wxString
& title
,
309 const wxBitmap
& bitmap
,
313 bool result
= wxDialog::Create(parent
,id
,title
,pos
,wxDefaultSize
,style
);
323 wxWizard::~wxWizard()
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
)
332 void wxWizard::AddBitmapRow(wxBoxSizer
*mainColumn
)
334 m_sizerBmpAndPage
= new wxBoxSizer(wxHORIZONTAL
);
337 1, // Vertically stretchable
338 wxEXPAND
// Horizonal stretching, no border
341 0, // No vertical stretching
342 wxEXPAND
// No border, (mostly useless) horizontal stretching
348 wxSize
bitmapSize(wxDefaultSize
);
349 if (GetBitmapPlacement())
350 bitmapSize
.x
= GetMinimumBitmapWidth();
352 m_statbmp
= new wxStaticBitmap(this, wxID_ANY
, m_bitmap
, wxDefaultPosition
, bitmapSize
);
353 m_sizerBmpAndPage
->Add(
355 0, // No horizontal stretching
356 wxALL
, // Border all around, top alignment
359 m_sizerBmpAndPage
->Add(
361 0, // No horizontal stretching
362 wxEXPAND
// No border, (mostly useless) vertical stretching
367 // Added to m_sizerBmpAndPage later
368 m_sizerPage
= new wxWizardSizer(this);
371 void wxWizard::AddStaticLine(wxBoxSizer
*mainColumn
)
375 new wxStaticLine(this, wxID_ANY
),
376 0, // Vertically unstretchable
377 wxEXPAND
| wxALL
, // Border all around, horizontally stretchable
381 0, // No vertical stretching
382 wxEXPAND
// No border, (mostly useless) horizontal stretching
386 #endif // wxUSE_STATLINE
389 void wxWizard::AddBackNextPair(wxBoxSizer
*buttonRow
)
391 wxASSERT_MSG( m_btnNext
&& m_btnPrev
,
392 _T("You must create the buttons before calling ")
393 _T("wxWizard::AddBackNextPair") );
395 // margin between Back and Next buttons
397 static const int BACKNEXT_MARGIN
= 10;
399 static const int BACKNEXT_MARGIN
= 0;
402 wxBoxSizer
*backNextPair
= new wxBoxSizer(wxHORIZONTAL
);
405 0, // No horizontal stretching
406 wxALL
, // Border all around
410 backNextPair
->Add(m_btnPrev
);
411 backNextPair
->Add(BACKNEXT_MARGIN
,0,
412 0, // No horizontal stretching
413 wxEXPAND
// No border, (mostly useless) vertical stretching
415 backNextPair
->Add(m_btnNext
);
418 void wxWizard::AddButtonRow(wxBoxSizer
*mainColumn
)
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.
430 bool isPda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
431 int buttonStyle
= isPda
? wxBU_EXACTFIT
: 0;
433 wxBoxSizer
*buttonRow
= new wxBoxSizer(wxHORIZONTAL
);
435 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
438 0, // Vertically unstretchable
439 wxGROW
|wxALIGN_CENTRE
445 0, // Vertically unstretchable
446 wxALIGN_RIGHT
// Right aligned, no border
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...
453 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
454 btnHelp
=new wxButton(this, wxID_HELP
, _("&Help"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
457 m_btnNext
= new wxButton(this, wxID_FORWARD
, _("&Next >"));
458 wxButton
*btnCancel
=new wxButton(this, wxID_CANCEL
, _("&Cancel"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
460 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
461 btnHelp
=new wxButton(this, wxID_HELP
, _("&Help"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
463 m_btnPrev
= new wxButton(this, wxID_BACKWARD
, _("< &Back"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
469 0, // Horizontally unstretchable
470 wxALL
, // Border all around, top aligned
474 // Put stretchable space between help button and others
475 buttonRow
->Add(0, 0, 1, wxALIGN_CENTRE
, 0);
479 AddBackNextPair(buttonRow
);
483 0, // Horizontally unstretchable
484 wxALL
, // Border all around, top aligned
489 void wxWizard::DoCreateControls()
491 // do nothing if the controls were already created
495 bool isPda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
497 // Horizontal stretching, and if not PDA, border all around
498 int mainColumnSizerFlags
= isPda
? wxEXPAND
: wxALL
|wxEXPAND
;
500 // wxWindow::SetSizer will be called at end
501 wxBoxSizer
*windowSizer
= new wxBoxSizer(wxVERTICAL
);
503 wxBoxSizer
*mainColumn
= new wxBoxSizer(wxVERTICAL
);
506 1, // Vertical stretching
507 mainColumnSizerFlags
,
511 AddBitmapRow(mainColumn
);
514 AddStaticLine(mainColumn
);
516 AddButtonRow(mainColumn
);
518 SetSizer(windowSizer
);
521 void wxWizard::SetPageSize(const wxSize
& size
)
523 wxCHECK_RET(!m_started
, wxT("wxWizard::SetPageSize after RunWizard"));
527 void wxWizard::FitToPage(const wxWizardPage
*page
)
529 wxCHECK_RET(!m_started
, wxT("wxWizard::FitToPage after RunWizard"));
533 wxSize size
= page
->GetBestSize();
535 m_sizePage
.IncTo(size
);
537 page
= page
->GetNext();
541 bool wxWizard::ShowPage(wxWizardPage
*page
, bool goingForward
)
543 wxASSERT_MSG( page
!= m_page
, wxT("this is useless") );
545 wxSizerFlags
flags(1);
546 flags
.Border(wxALL
, m_border
).Expand();
552 m_sizerBmpAndPage
->Add(m_sizerPage
, flags
);
554 // now that our layout is computed correctly, hide the pages
555 // artificially shown in wxWizardSizer::Insert() back again
556 m_sizerPage
->HidePages();
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")
563 bool btnLabelWasNext
= true;
565 // remember the old bitmap (if any) to compare with the new one later
568 // check for previous page
571 // send the event to the old page
572 wxWizardEvent
event(wxEVT_WIZARD_PAGE_CHANGING
, GetId(),
573 goingForward
, m_page
);
574 if ( m_page
->GetEventHandler()->ProcessEvent(event
) &&
577 // vetoed by the page
583 btnLabelWasNext
= HasNextPage(m_page
);
585 bmpPrev
= m_page
->GetBitmap();
588 m_sizerBmpAndPage
->Detach(m_page
);
597 // terminate successfully
604 SetReturnCode(wxID_OK
);
608 // and notify the user code (this is especially useful for modeless
610 wxWizardEvent
event(wxEVT_WIZARD_FINISHED
, GetId(), false, 0);
611 (void)GetEventHandler()->ProcessEvent(event
);
616 // position and show the new page
617 (void)m_page
->TransferDataToWindow();
621 // wxWizardSizer::RecalcSizes wants to be called when m_page changes
622 m_sizerPage
->RecalcSizes();
624 else // pages are not managed by the sizer
626 m_sizerBmpAndPage
->Add(m_page
, flags
);
627 m_sizerBmpAndPage
->SetItemMinSize(m_page
, GetPageSize());
631 // update the bitmap if:it changed
635 bmp
= m_page
->GetBitmap();
642 if (!GetBitmapPlacement())
644 if ( !bmp
.IsSameAs(bmpPrev
) )
645 m_statbmp
->SetBitmap(bmp
);
648 #endif // wxUSE_STATBMP
651 // and update the buttons state
652 m_btnPrev
->Enable(HasPrevPage(m_page
));
654 bool hasNext
= HasNextPage(m_page
);
655 if ( btnLabelWasNext
!= hasNext
)
658 m_btnNext
->SetLabel(_("&Next >"));
660 m_btnNext
->SetLabel(_("&Finish"));
662 // nothing to do: the label was already correct
664 m_btnNext
->SetDefault();
667 // send the change event to the new page now
668 wxWizardEvent
event(wxEVT_WIZARD_PAGE_CHANGED
, GetId(), goingForward
, m_page
);
669 (void)m_page
->GetEventHandler()->ProcessEvent(event
);
671 // and finally show it
676 m_sizerBmpAndPage
->Layout();
685 if (GetBitmapPlacement() && m_statbmp
)
689 if ( !bmp
.IsSameAs(bmpPrev
) )
690 m_statbmp
->SetBitmap(bmp
);
693 m_sizerPage
->RecalcSizes();
699 /// Do fit, and adjust to screen size if necessary
700 void wxWizard::DoWizardLayout()
702 if ( wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
704 if (CanDoLayoutAdaptation())
705 DoLayoutAdaptation();
707 GetSizer()->SetSizeHints(this);
709 if ( m_posWizard
== wxDefaultPosition
)
713 SetLayoutAdaptationDone(true);
716 bool wxWizard::RunWizard(wxWizardPage
*firstPage
)
718 wxCHECK_MSG( firstPage
, false, wxT("can't run empty wizard") );
720 // can't return false here because there is no old page
721 (void)ShowPage(firstPage
, true /* forward */);
725 return ShowModal() == wxID_OK
;
728 wxWizardPage
*wxWizard::GetCurrentPage() const
733 wxSize
wxWizard::GetPageSize() const
735 // default width and height of the page
736 int DEFAULT_PAGE_WIDTH
,
738 if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
)
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;
747 DEFAULT_PAGE_HEIGHT
= 270;
750 // start with default minimal size
751 wxSize
pageSize(DEFAULT_PAGE_WIDTH
, DEFAULT_PAGE_HEIGHT
);
753 // make the page at least as big as specified by user
754 pageSize
.IncTo(m_sizePage
);
758 // make the page at least as tall as the bitmap
759 pageSize
.IncTo(wxSize(0, m_bitmap
.GetHeight()));
764 // make it big enough to contain all pages added to the sizer
765 pageSize
.IncTo(m_sizerPage
->GetMaxChildSize());
771 wxSizer
*wxWizard::GetPageAreaSizer() const
776 void wxWizard::SetBorder(int border
)
778 wxCHECK_RET(!m_started
, wxT("wxWizard::SetBorder after RunWizard"));
783 void wxWizard::OnCancel(wxCommandEvent
& WXUNUSED(eventUnused
))
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;
789 wxWizardEvent
event(wxEVT_WIZARD_CANCEL
, GetId(), false, m_page
);
790 if ( !win
->GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed() )
792 // no objections - close the dialog
795 EndModal(wxID_CANCEL
);
799 SetReturnCode(wxID_CANCEL
);
803 //else: request to Cancel ignored
806 void wxWizard::OnBackOrNext(wxCommandEvent
& event
)
808 wxASSERT_MSG( (event
.GetEventObject() == m_btnNext
) ||
809 (event
.GetEventObject() == m_btnPrev
),
810 wxT("unknown button") );
812 wxCHECK_RET( m_page
, _T("should have a valid current page") );
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
817 if ( !m_page
->Validate() || !m_page
->TransferDataFromWindow() )
819 // the page data is incorrect, don't do anything
823 bool forward
= event
.GetEventObject() == m_btnNext
;
828 page
= m_page
->GetNext();
832 page
= m_page
->GetPrev();
834 wxASSERT_MSG( page
, wxT("\"<Back\" button should have been disabled") );
837 // just pass to the new page (or maybe not - but we don't care here)
838 (void)ShowPage(page
, forward
);
841 void wxWizard::OnHelp(wxCommandEvent
& WXUNUSED(event
))
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
847 // Create and send the help event to the specific page handler
848 // event data contains the active page so that context-sensitive
850 wxWizardEvent
eventHelp(wxEVT_WIZARD_HELP
, GetId(), true, m_page
);
851 (void)m_page
->GetEventHandler()->ProcessEvent(eventHelp
);
855 void wxWizard::OnWizEvent(wxWizardEvent
& event
)
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
) )
861 // the event will be propagated anyhow
866 wxWindow
*parent
= GetParent();
868 if ( !parent
|| !parent
->GetEventHandler()->ProcessEvent(event
) )
874 if ( ( !m_wasModal
) &&
876 ( event
.GetEventType() == wxEVT_WIZARD_FINISHED
||
877 event
.GetEventType() == wxEVT_WIZARD_CANCEL
885 void wxWizard::SetBitmap(const wxBitmap
& bitmap
)
889 m_statbmp
->SetBitmap(m_bitmap
);
892 // ----------------------------------------------------------------------------
894 // ----------------------------------------------------------------------------
896 wxWizardEvent::wxWizardEvent(wxEventType type
, int id
, bool direction
, wxWizardPage
* page
)
897 : wxNotifyEvent(type
, id
)
899 // Modified 10-20-2001 Robert Cavanaugh
900 // add the active page to the event data
901 m_direction
= direction
;
905 /// Do the adaptation
906 bool wxWizard::DoLayoutAdaptation()
908 wxWindowList windows
;
911 // Make all the pages (that use sizers) scrollable
912 for ( wxSizerItemList::compatibility_iterator node
= m_sizerPage
->GetChildren().GetFirst(); node
; node
= node
->GetNext() )
914 wxSizerItem
* const item
= node
->GetData();
915 if ( item
->IsWindow() )
917 wxWizardPage
* page
= wxDynamicCast(item
->GetWindow(), wxWizardPage
);
922 if (!pages
.Find(page
) && page
->GetSizer())
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();
928 wxSizer
* newSizer
= new wxBoxSizer(wxVERTICAL
);
929 newSizer
->Add(scrolledWindow
,1, wxEXPAND
, 0);
931 page
->SetSizer(newSizer
, false /* don't delete the old sizer */);
933 scrolledWindow
->SetSizer(oldSizer
);
935 wxStandardDialogLayoutAdapter::DoReparentControls(page
, scrolledWindow
);
938 windows
.Append(scrolledWindow
);
940 page
= page
->GetNext();
946 wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows
);
948 SetLayoutAdaptationDone(true);
953 bool wxWizard::ResizeBitmap(wxBitmap
& bmp
)
955 if (!GetBitmapPlacement())
960 wxSize pageSize
= m_sizerPage
->GetSize();
961 int bitmapWidth
= wxMax(bmp
.GetWidth(), GetMinimumBitmapWidth());
962 int bitmapHeight
= pageSize
.y
;
964 if (!m_statbmp
->GetBitmap().Ok() || m_statbmp
->GetBitmap().GetHeight() != bitmapHeight
)
966 wxBitmap
bitmap(bitmapWidth
, bitmapHeight
);
969 dc
.SelectObject(bitmap
);
970 dc
.SetBackground(wxBrush(m_bitmapBackgroundColour
));
973 if (GetBitmapPlacement() & wxWIZARD_TILE
)
975 TileBitmap(wxRect(0, 0, bitmapWidth
, bitmapHeight
), dc
, bmp
);
981 if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT
)
983 else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT
)
984 x
= bitmapWidth
- bmp
.GetWidth();
986 x
= (bitmapWidth
- bmp
.GetWidth())/2;
988 if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP
)
990 else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM
)
991 y
= bitmapHeight
- bmp
.GetHeight();
993 y
= (bitmapHeight
- bmp
.GetHeight())/2;
995 dc
.DrawBitmap(bmp
, x
, y
, true);
996 dc
.SelectObject(wxNullBitmap
);
1007 bool wxWizard::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
1009 int w
= bitmap
.GetWidth();
1010 int h
= bitmap
.GetHeight();
1014 dcMem
.SelectObjectAsSource(bitmap
);
1017 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
1019 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
1020 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
1022 dcMem
.SelectObject(wxNullBitmap
);
1027 #endif // wxUSE_WIZARDDLG