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
);
89 wxDEFINE_EVENT( wxEVT_WIZARD_PAGE_SHOWN
, wxWizardEvent
);
91 BEGIN_EVENT_TABLE(wxWizard
, wxDialog
)
92 EVT_BUTTON(wxID_CANCEL
, wxWizard::OnCancel
)
93 EVT_BUTTON(wxID_BACKWARD
, wxWizard::OnBackOrNext
)
94 EVT_BUTTON(wxID_FORWARD
, wxWizard::OnBackOrNext
)
95 EVT_BUTTON(wxID_HELP
, wxWizard::OnHelp
)
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
)
104 IMPLEMENT_DYNAMIC_CLASS(wxWizard
, wxDialog
)
113 IMPLEMENT_ABSTRACT_CLASS(wxWizardPage
, wxPanel
)
114 IMPLEMENT_DYNAMIC_CLASS(wxWizardPageSimple
, wxWizardPage
)
115 IMPLEMENT_DYNAMIC_CLASS(wxWizardEvent
, wxNotifyEvent
)
117 // ============================================================================
119 // ============================================================================
121 // ----------------------------------------------------------------------------
123 // ----------------------------------------------------------------------------
125 void wxWizardPage::Init()
127 m_bitmap
= wxNullBitmap
;
130 wxWizardPage::wxWizardPage(wxWizard
*parent
,
131 const wxBitmap
& bitmap
)
133 Create(parent
, bitmap
);
136 bool wxWizardPage::Create(wxWizard
*parent
,
137 const wxBitmap
& bitmap
)
139 if ( !wxPanel::Create(parent
, wxID_ANY
) )
144 // initially the page is hidden, it's shown only when it becomes current
150 // ----------------------------------------------------------------------------
151 // wxWizardPageSimple
152 // ----------------------------------------------------------------------------
154 wxWizardPage
*wxWizardPageSimple::GetPrev() const
159 wxWizardPage
*wxWizardPageSimple::GetNext() const
164 // ----------------------------------------------------------------------------
166 // ----------------------------------------------------------------------------
168 wxWizardSizer::wxWizardSizer(wxWizard
*owner
)
170 m_childSize(wxDefaultSize
)
174 wxSizerItem
*wxWizardSizer::Insert(size_t index
, wxSizerItem
*item
)
176 m_owner
->m_usingSizer
= true;
178 if ( item
->IsWindow() )
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();
186 return wxSizer::Insert(index
, item
);
189 void wxWizardSizer::HidePages()
191 for ( wxSizerItemList::compatibility_iterator node
= GetChildren().GetFirst();
193 node
= node
->GetNext() )
195 wxSizerItem
* const item
= node
->GetData();
196 if ( item
->IsWindow() )
197 item
->GetWindow()->wxWindowBase::Show(false);
201 void wxWizardSizer::RecalcSizes()
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
)
207 m_owner
->m_page
->SetSize(wxRect(m_position
, m_size
));
211 wxSize
wxWizardSizer::CalcMin()
213 return m_owner
->GetPageSize();
216 wxSize
wxWizardSizer::GetMaxChildSize()
220 for ( wxSizerItemList::compatibility_iterator childNode
= m_children
.GetFirst();
222 childNode
= childNode
->GetNext() )
224 wxSizerItem
*child
= childNode
->GetData();
225 maxOfMin
.IncTo(child
->CalcMin());
226 maxOfMin
.IncTo(SiblingSize(child
));
229 if ( m_owner
->m_started
)
231 m_childSize
= maxOfMin
;
237 int wxWizardSizer::GetBorder() const
239 return m_owner
->m_border
;
242 wxSize
wxWizardSizer::SiblingSize(wxSizerItem
*child
)
246 if ( child
->IsWindow() )
248 wxWizardPage
*page
= wxDynamicCast(child
->GetWindow(), wxWizardPage
);
251 for ( wxWizardPage
*sibling
= page
->GetNext();
253 sibling
= sibling
->GetNext() )
255 if ( sibling
->GetSizer() )
257 maxSibling
.IncTo(sibling
->GetSizer()->CalcMin());
266 // ----------------------------------------------------------------------------
267 // generic wxWizard implementation
268 // ----------------------------------------------------------------------------
270 void wxWizard::Init()
272 m_posWizard
= wxDefaultPosition
;
274 m_btnPrev
= m_btnNext
= NULL
;
276 m_sizerBmpAndPage
= NULL
;
281 m_usingSizer
= false;
282 m_bitmapBackgroundColour
= *wxWHITE
;
283 m_bitmapPlacement
= 0;
284 m_bitmapMinimumWidth
= 115;
287 bool wxWizard::Create(wxWindow
*parent
,
289 const wxString
& title
,
290 const wxBitmap
& bitmap
,
294 bool result
= wxDialog::Create(parent
,id
,title
,pos
,wxDefaultSize
,style
);
304 wxWizard::~wxWizard()
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
)
313 void wxWizard::AddBitmapRow(wxBoxSizer
*mainColumn
)
315 m_sizerBmpAndPage
= new wxBoxSizer(wxHORIZONTAL
);
318 1, // Vertically stretchable
319 wxEXPAND
// Horizonal stretching, no border
322 0, // No vertical stretching
323 wxEXPAND
// No border, (mostly useless) horizontal stretching
329 wxSize
bitmapSize(wxDefaultSize
);
330 if (GetBitmapPlacement())
331 bitmapSize
.x
= GetMinimumBitmapWidth();
333 m_statbmp
= new wxStaticBitmap(this, wxID_ANY
, m_bitmap
, wxDefaultPosition
, bitmapSize
);
334 m_sizerBmpAndPage
->Add(
336 0, // No horizontal stretching
337 wxALL
, // Border all around, top alignment
340 m_sizerBmpAndPage
->Add(
342 0, // No horizontal stretching
343 wxEXPAND
// No border, (mostly useless) vertical stretching
348 // Added to m_sizerBmpAndPage later
349 m_sizerPage
= new wxWizardSizer(this);
352 void wxWizard::AddStaticLine(wxBoxSizer
*mainColumn
)
356 new wxStaticLine(this, wxID_ANY
),
357 0, // Vertically unstretchable
358 wxEXPAND
| wxALL
, // Border all around, horizontally stretchable
362 0, // No vertical stretching
363 wxEXPAND
// No border, (mostly useless) horizontal stretching
367 #endif // wxUSE_STATLINE
370 void wxWizard::AddBackNextPair(wxBoxSizer
*buttonRow
)
372 wxASSERT_MSG( m_btnNext
&& m_btnPrev
,
373 wxT("You must create the buttons before calling ")
374 wxT("wxWizard::AddBackNextPair") );
376 // margin between Back and Next buttons
378 static const int BACKNEXT_MARGIN
= 10;
380 static const int BACKNEXT_MARGIN
= 0;
383 wxBoxSizer
*backNextPair
= new wxBoxSizer(wxHORIZONTAL
);
386 0, // No horizontal stretching
387 wxALL
, // Border all around
391 backNextPair
->Add(m_btnPrev
);
392 backNextPair
->Add(BACKNEXT_MARGIN
,0,
393 0, // No horizontal stretching
394 wxEXPAND
// No border, (mostly useless) vertical stretching
396 backNextPair
->Add(m_btnNext
);
399 void wxWizard::AddButtonRow(wxBoxSizer
*mainColumn
)
401 // the order in which the buttons are created determines the TAB order - at least under MSWindows...
402 // although the 'back' button appears before the 'next' button, a more userfriendly tab order is
403 // to activate the 'next' button first (create the next button before the back button).
404 // The reason is: The user will repeatedly enter information in the wizard pages and then wants to
405 // press 'next'. If a user uses mostly the keyboard, he would have to skip the 'back' button
406 // everytime. This is annoying. There is a second reason: RETURN acts as TAB. If the 'next'
407 // button comes first in the TAB order, the user can enter information very fast using the RETURN
408 // key to TAB to the next entry field and page. This would not be possible, if the 'back' button
409 // was created before the 'next' button.
411 bool isPda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
412 int buttonStyle
= isPda
? wxBU_EXACTFIT
: 0;
414 wxBoxSizer
*buttonRow
= new wxBoxSizer(wxHORIZONTAL
);
416 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
419 0, // Vertically unstretchable
420 wxGROW
|wxALIGN_CENTRE
426 0, // Vertically unstretchable
427 wxALIGN_RIGHT
// Right aligned, no border
430 // Desired TAB order is 'next', 'cancel', 'help', 'back'. This makes the 'back' button the last control on the page.
431 // Create the buttons in the right order...
434 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
435 btnHelp
=new wxButton(this, wxID_HELP
, wxEmptyString
, wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
438 m_btnNext
= new wxButton(this, wxID_FORWARD
, _("&Next >"));
439 wxButton
*btnCancel
=new wxButton(this, wxID_CANCEL
, _("&Cancel"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
441 if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON
)
442 btnHelp
=new wxButton(this, wxID_HELP
, _("&Help"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
444 m_btnPrev
= new wxButton(this, wxID_BACKWARD
, _("< &Back"), wxDefaultPosition
, wxDefaultSize
, buttonStyle
);
450 0, // Horizontally unstretchable
451 wxALL
, // Border all around, top aligned
455 // Put stretchable space between help button and others
456 buttonRow
->Add(0, 0, 1, wxALIGN_CENTRE
, 0);
460 AddBackNextPair(buttonRow
);
464 0, // Horizontally unstretchable
465 wxALL
, // Border all around, top aligned
470 void wxWizard::DoCreateControls()
472 // do nothing if the controls were already created
476 bool isPda
= (wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
);
478 // Horizontal stretching, and if not PDA, border all around
479 int mainColumnSizerFlags
= isPda
? wxEXPAND
: wxALL
|wxEXPAND
;
481 // wxWindow::SetSizer will be called at end
482 wxBoxSizer
*windowSizer
= new wxBoxSizer(wxVERTICAL
);
484 wxBoxSizer
*mainColumn
= new wxBoxSizer(wxVERTICAL
);
487 1, // Vertical stretching
488 mainColumnSizerFlags
,
492 AddBitmapRow(mainColumn
);
495 AddStaticLine(mainColumn
);
497 AddButtonRow(mainColumn
);
499 SetSizer(windowSizer
);
502 void wxWizard::SetPageSize(const wxSize
& size
)
504 wxCHECK_RET(!m_started
, wxT("wxWizard::SetPageSize after RunWizard"));
508 void wxWizard::FitToPage(const wxWizardPage
*page
)
510 wxCHECK_RET(!m_started
, wxT("wxWizard::FitToPage after RunWizard"));
514 wxSize size
= page
->GetBestSize();
516 m_sizePage
.IncTo(size
);
518 page
= page
->GetNext();
522 bool wxWizard::ShowPage(wxWizardPage
*page
, bool goingForward
)
524 wxASSERT_MSG( page
!= m_page
, wxT("this is useless") );
526 wxSizerFlags
flags(1);
527 flags
.Border(wxALL
, m_border
).Expand();
533 m_sizerBmpAndPage
->Add(m_sizerPage
, flags
);
535 // now that our layout is computed correctly, hide the pages
536 // artificially shown in wxWizardSizer::Insert() back again
537 m_sizerPage
->HidePages();
542 // remember the old bitmap (if any) to compare with the new one later
545 // check for previous page
548 // send the event to the old page
549 wxWizardEvent
event(wxEVT_WIZARD_PAGE_CHANGING
, GetId(),
550 goingForward
, m_page
);
551 if ( m_page
->GetEventHandler()->ProcessEvent(event
) &&
554 // vetoed by the page
560 bmpPrev
= m_page
->GetBitmap();
563 m_sizerBmpAndPage
->Detach(m_page
);
569 // terminate successfully
576 SetReturnCode(wxID_OK
);
580 // and notify the user code (this is especially useful for modeless
582 wxWizardEvent
event(wxEVT_WIZARD_FINISHED
, GetId(), false, m_page
);
583 (void)GetEventHandler()->ProcessEvent(event
);
590 // notice that we change m_page only here so that wxEVT_WIZARD_FINISHED
591 // event above could still use the correct (i.e. old) value of m_page
594 // position and show the new page
595 (void)m_page
->TransferDataToWindow();
599 // wxWizardSizer::RecalcSizes wants to be called when m_page changes
600 m_sizerPage
->RecalcSizes();
602 else // pages are not managed by the sizer
604 m_sizerBmpAndPage
->Add(m_page
, flags
);
605 m_sizerBmpAndPage
->SetItemMinSize(m_page
, GetPageSize());
609 // update the bitmap if:it changed
613 bmp
= m_page
->GetBitmap();
620 if (!GetBitmapPlacement())
622 if ( !bmp
.IsSameAs(bmpPrev
) )
623 m_statbmp
->SetBitmap(bmp
);
626 #endif // wxUSE_STATBMP
629 // and update the buttons state
630 m_btnPrev
->Enable(HasPrevPage(m_page
));
632 const bool hasNext
= HasNextPage(m_page
);
633 const wxString label
= hasNext
? _("&Next >") : _("&Finish");
634 if ( label
!= m_btnNext
->GetLabel() )
635 m_btnNext
->SetLabel(label
);
637 m_btnNext
->SetDefault();
640 // send the change event to the new page now
641 wxWizardEvent
event(wxEVT_WIZARD_PAGE_CHANGED
, GetId(), goingForward
, m_page
);
642 (void)m_page
->GetEventHandler()->ProcessEvent(event
);
644 // and finally show it
649 m_sizerBmpAndPage
->Layout();
658 if (GetBitmapPlacement() && m_statbmp
)
662 if ( !bmp
.IsSameAs(bmpPrev
) )
663 m_statbmp
->SetBitmap(bmp
);
666 m_sizerPage
->RecalcSizes();
669 wxWizardEvent
pageShownEvent(wxEVT_WIZARD_PAGE_SHOWN
, GetId(),
670 goingForward
, m_page
);
671 m_page
->GetEventHandler()->ProcessEvent(pageShownEvent
);
676 /// Do fit, and adjust to screen size if necessary
677 void wxWizard::DoWizardLayout()
679 if ( wxSystemSettings::GetScreenType() > wxSYS_SCREEN_PDA
)
681 if (CanDoLayoutAdaptation())
682 DoLayoutAdaptation();
684 GetSizer()->SetSizeHints(this);
686 if ( m_posWizard
== wxDefaultPosition
)
690 SetLayoutAdaptationDone(true);
693 bool wxWizard::RunWizard(wxWizardPage
*firstPage
)
695 wxCHECK_MSG( firstPage
, false, wxT("can't run empty wizard") );
697 // can't return false here because there is no old page
698 (void)ShowPage(firstPage
, true /* forward */);
702 return ShowModal() == wxID_OK
;
705 wxWizardPage
*wxWizard::GetCurrentPage() const
710 wxSize
wxWizard::GetPageSize() const
712 // default width and height of the page
713 int DEFAULT_PAGE_WIDTH
,
715 if ( wxSystemSettings::GetScreenType() <= wxSYS_SCREEN_PDA
)
717 // Make the default page size small enough to fit on screen
718 DEFAULT_PAGE_WIDTH
= wxSystemSettings::GetMetric(wxSYS_SCREEN_X
) / 2;
719 DEFAULT_PAGE_HEIGHT
= wxSystemSettings::GetMetric(wxSYS_SCREEN_Y
) / 2;
724 DEFAULT_PAGE_HEIGHT
= 270;
727 // start with default minimal size
728 wxSize
pageSize(DEFAULT_PAGE_WIDTH
, DEFAULT_PAGE_HEIGHT
);
730 // make the page at least as big as specified by user
731 pageSize
.IncTo(m_sizePage
);
735 // make the page at least as tall as the bitmap
736 pageSize
.IncTo(wxSize(0, m_bitmap
.GetHeight()));
741 // make it big enough to contain all pages added to the sizer
742 pageSize
.IncTo(m_sizerPage
->GetMaxChildSize());
748 wxSizer
*wxWizard::GetPageAreaSizer() const
753 void wxWizard::SetBorder(int border
)
755 wxCHECK_RET(!m_started
, wxT("wxWizard::SetBorder after RunWizard"));
760 void wxWizard::OnCancel(wxCommandEvent
& WXUNUSED(eventUnused
))
762 // this function probably can never be called when we don't have an active
763 // page, but a small extra check won't hurt
764 wxWindow
*win
= m_page
? (wxWindow
*)m_page
: (wxWindow
*)this;
766 wxWizardEvent
event(wxEVT_WIZARD_CANCEL
, GetId(), false, m_page
);
767 if ( !win
->GetEventHandler()->ProcessEvent(event
) || event
.IsAllowed() )
769 // no objections - close the dialog
772 EndModal(wxID_CANCEL
);
776 SetReturnCode(wxID_CANCEL
);
780 //else: request to Cancel ignored
783 void wxWizard::OnBackOrNext(wxCommandEvent
& event
)
785 wxASSERT_MSG( (event
.GetEventObject() == m_btnNext
) ||
786 (event
.GetEventObject() == m_btnPrev
),
787 wxT("unknown button") );
789 wxCHECK_RET( m_page
, wxT("should have a valid current page") );
791 // ask the current page first: notice that we do it before calling
792 // GetNext/Prev() because the data transfered from the controls of the page
793 // may change the value returned by these methods
794 if ( !m_page
->Validate() || !m_page
->TransferDataFromWindow() )
796 // the page data is incorrect, don't do anything
800 bool forward
= event
.GetEventObject() == m_btnNext
;
805 page
= m_page
->GetNext();
809 page
= m_page
->GetPrev();
811 wxASSERT_MSG( page
, wxT("\"<Back\" button should have been disabled") );
814 // just pass to the new page (or maybe not - but we don't care here)
815 (void)ShowPage(page
, forward
);
818 void wxWizard::OnHelp(wxCommandEvent
& WXUNUSED(event
))
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
824 // Create and send the help event to the specific page handler
825 // event data contains the active page so that context-sensitive
827 wxWizardEvent
eventHelp(wxEVT_WIZARD_HELP
, GetId(), true, m_page
);
828 (void)m_page
->GetEventHandler()->ProcessEvent(eventHelp
);
832 void wxWizard::OnWizEvent(wxWizardEvent
& event
)
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
) )
838 // the event will be propagated anyhow
843 wxWindow
*parent
= GetParent();
845 if ( !parent
|| !parent
->GetEventHandler()->ProcessEvent(event
) )
851 if ( ( !m_wasModal
) &&
853 ( event
.GetEventType() == wxEVT_WIZARD_FINISHED
||
854 event
.GetEventType() == wxEVT_WIZARD_CANCEL
862 void wxWizard::SetBitmap(const wxBitmap
& bitmap
)
866 m_statbmp
->SetBitmap(m_bitmap
);
869 // ----------------------------------------------------------------------------
871 // ----------------------------------------------------------------------------
873 wxWizardEvent::wxWizardEvent(wxEventType type
, int id
, bool direction
, wxWizardPage
* page
)
874 : wxNotifyEvent(type
, id
)
876 // Modified 10-20-2001 Robert Cavanaugh
877 // add the active page to the event data
878 m_direction
= direction
;
882 /// Do the adaptation
883 bool wxWizard::DoLayoutAdaptation()
885 wxWindowList windows
;
888 // Make all the pages (that use sizers) scrollable
889 for ( wxSizerItemList::compatibility_iterator node
= m_sizerPage
->GetChildren().GetFirst(); node
; node
= node
->GetNext() )
891 wxSizerItem
* const item
= node
->GetData();
892 if ( item
->IsWindow() )
894 wxWizardPage
* page
= wxDynamicCast(item
->GetWindow(), wxWizardPage
);
899 if (!pages
.Find(page
) && page
->GetSizer())
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();
905 wxSizer
* newSizer
= new wxBoxSizer(wxVERTICAL
);
906 newSizer
->Add(scrolledWindow
,1, wxEXPAND
, 0);
908 page
->SetSizer(newSizer
, false /* don't delete the old sizer */);
910 scrolledWindow
->SetSizer(oldSizer
);
912 wxStandardDialogLayoutAdapter::DoReparentControls(page
, scrolledWindow
);
915 windows
.Append(scrolledWindow
);
917 page
= page
->GetNext();
923 wxStandardDialogLayoutAdapter::DoFitWithScrolling(this, windows
);
925 // Size event doesn't get sent soon enough on wxGTK
928 SetLayoutAdaptationDone(true);
933 bool wxWizard::ResizeBitmap(wxBitmap
& bmp
)
935 if (!GetBitmapPlacement())
940 wxSize pageSize
= m_sizerPage
->GetSize();
941 if (pageSize
== wxSize(0,0))
942 pageSize
= GetPageSize();
943 int bitmapWidth
= wxMax(bmp
.GetWidth(), GetMinimumBitmapWidth());
944 int bitmapHeight
= pageSize
.y
;
946 if (!m_statbmp
->GetBitmap().Ok() || m_statbmp
->GetBitmap().GetHeight() != bitmapHeight
)
948 wxBitmap
bitmap(bitmapWidth
, bitmapHeight
);
951 dc
.SelectObject(bitmap
);
952 dc
.SetBackground(wxBrush(m_bitmapBackgroundColour
));
955 if (GetBitmapPlacement() & wxWIZARD_TILE
)
957 TileBitmap(wxRect(0, 0, bitmapWidth
, bitmapHeight
), dc
, bmp
);
963 if (GetBitmapPlacement() & wxWIZARD_HALIGN_LEFT
)
965 else if (GetBitmapPlacement() & wxWIZARD_HALIGN_RIGHT
)
966 x
= bitmapWidth
- bmp
.GetWidth();
968 x
= (bitmapWidth
- bmp
.GetWidth())/2;
970 if (GetBitmapPlacement() & wxWIZARD_VALIGN_TOP
)
972 else if (GetBitmapPlacement() & wxWIZARD_VALIGN_BOTTOM
)
973 y
= bitmapHeight
- bmp
.GetHeight();
975 y
= (bitmapHeight
- bmp
.GetHeight())/2;
977 dc
.DrawBitmap(bmp
, x
, y
, true);
978 dc
.SelectObject(wxNullBitmap
);
989 bool wxWizard::TileBitmap(const wxRect
& rect
, wxDC
& dc
, const wxBitmap
& bitmap
)
991 int w
= bitmap
.GetWidth();
992 int h
= bitmap
.GetHeight();
996 dcMem
.SelectObjectAsSource(bitmap
);
999 for (i
= rect
.x
; i
< rect
.x
+ rect
.width
; i
+= w
)
1001 for (j
= rect
.y
; j
< rect
.y
+ rect
.height
; j
+= h
)
1002 dc
.Blit(i
, j
, bitmap
.GetWidth(), bitmap
.GetHeight(), & dcMem
, 0, 0);
1004 dcMem
.SelectObject(wxNullBitmap
);
1009 #endif // wxUSE_WIZARDDLG