// wxWizardPage
// ----------------------------------------------------------------------------
-wxWizardPage::wxWizardPage(wxWizard *parent) : wxPanel(parent)
+wxWizardPage::wxWizardPage(wxWizard *parent, const wxBitmap& bitmap)
+ : wxPanel(parent), m_bitmap(bitmap)
{
// initially the page is hidden, it's shown only when it becomes current
Hide();
const wxBitmap& bitmap,
const wxPoint& pos,
const wxSize& size)
+ : m_bitmap(bitmap)
{
// constants defining the dialog layout
// ------------------------------------
m_y = Y_MARGIN;
if ( bitmap.Ok() )
{
- (void)new wxStaticBitmap(this, -1, bitmap, wxPoint(m_x, m_y));
+ m_statbmp = new wxStaticBitmap(this, -1, bitmap, wxPoint(m_x, m_y));
m_x += bitmap.GetWidth() + BITMAP_X_MARGIN;
m_height = bitmap.GetHeight();
}
else
{
+ m_statbmp = (wxStaticBitmap *)NULL;
+
m_height = DEFAULT_PAGE_HEIGHT;
}
if ( pos == wxDefaultPosition )
{
- Centre();
+ CentreOnScreen();
}
}
bool wxWizard::ShowPage(wxWizardPage *page, bool goingForward)
{
- wxASSERT_MSG( page != m_page, T("this is useless") );
+ wxASSERT_MSG( page != m_page, wxT("this is useless") );
// we'll use this to decide whether we have to change the label of this
// button or not (initially the label is "Next")
bool btnLabelWasNext = TRUE;
+ // and this tells us whether we already had the default bitmap before
+ bool bmpWasDefault = TRUE;
+
if ( m_page )
{
// ask the current page first
m_page->Hide();
btnLabelWasNext = m_page->GetNext() != (wxWizardPage *)NULL;
+ bmpWasDefault = !m_page->GetBitmap().Ok();
}
// set the new one
m_page->SetSize(m_x, m_y, m_width, m_height);
m_page->Show();
+ // change the bitmap if necessary (and if we have it at all)
+ bool bmpIsDefault = !m_page->GetBitmap().Ok();
+ if ( m_statbmp && (bmpIsDefault != bmpWasDefault) )
+ {
+ wxBitmap bmp;
+ if ( bmpIsDefault )
+ bmp = m_bitmap;
+ else
+ bmp = m_page->GetBitmap();
+ m_statbmp->SetBitmap(bmp);
+ }
+
// and update the buttons state
m_btnPrev->Enable(m_page->GetPrev() != (wxWizardPage *)NULL);
- if ( btnLabelWasNext != (m_page->GetNext() != (wxWizardPage *)NULL) )
+ bool hasNext = m_page->GetNext() != (wxWizardPage *)NULL;
+ if ( btnLabelWasNext != hasNext )
{
// need to update
- m_btnNext->SetLabel(btnLabelWasNext ? _("&Finish") : _("&Next >"));
+ if (btnLabelWasNext)
+ m_btnNext->SetLabel(_("&Finish"));
+ else
+ m_btnNext->SetLabel(_("&Next >"));
}
// nothing to do: the label was already correct
bool wxWizard::RunWizard(wxWizardPage *firstPage)
{
- wxCHECK_MSG( firstPage, FALSE, T("can't run empty wizard") );
+ wxCHECK_MSG( firstPage, FALSE, wxT("can't run empty wizard") );
// can't return FALSE here because there is no old page
(void)ShowPage(firstPage, TRUE /* forward */);
return m_page;
}
+wxSize wxWizard::GetPageSize() const
+{
+ return wxSize(m_width, m_height);
+}
+
void wxWizard::OnCancel(wxCommandEvent& WXUNUSED(event))
{
// this function probably can never be called when we don't have an active
{
wxASSERT_MSG( (event.GetEventObject() == m_btnNext) ||
(event.GetEventObject() == m_btnPrev),
- T("unknown button") );
+ wxT("unknown button") );
bool forward = event.GetEventObject() == m_btnNext;
{
page = m_page->GetPrev();
- wxASSERT_MSG( page, T("\"<Back\" button should have been disabled") );
+ wxASSERT_MSG( page, wxT("\"<Back\" button should have been disabled") );
}
// just pass to the new page (or may be not - but we don't care here)