Added possibility of 2-step initialisation, and wxWIZARD_EX_HELPBUTTON style.
Also added & to Cancel button. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,11 +20,22 @@ class WXDLLEXPORT wxWizard : public wxWizardBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// ctor
|
// ctor
|
||||||
wxWizard(wxWindow *parent = NULL,
|
wxWizard() { Init(); }
|
||||||
|
wxWizard(wxWindow *parent,
|
||||||
|
int id = -1,
|
||||||
|
const wxString& title = wxEmptyString,
|
||||||
|
const wxBitmap& bitmap = wxNullBitmap,
|
||||||
|
const wxPoint& pos = wxDefaultPosition)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
Create(parent, id, title, bitmap, pos);
|
||||||
|
}
|
||||||
|
bool Create(wxWindow *parent,
|
||||||
int id = -1,
|
int id = -1,
|
||||||
const wxString& title = wxEmptyString,
|
const wxString& title = wxEmptyString,
|
||||||
const wxBitmap& bitmap = wxNullBitmap,
|
const wxBitmap& bitmap = wxNullBitmap,
|
||||||
const wxPoint& pos = wxDefaultPosition);
|
const wxPoint& pos = wxDefaultPosition);
|
||||||
|
void Init();
|
||||||
|
|
||||||
// implement base class pure virtuals
|
// implement base class pure virtuals
|
||||||
virtual bool RunWizard(wxWizardPage *firstPage);
|
virtual bool RunWizard(wxWizardPage *firstPage);
|
||||||
@@ -43,13 +54,14 @@ public:
|
|||||||
// TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
|
// TransferDataFromWindow() returns FALSE - otherwise, returns TRUE
|
||||||
bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
|
bool ShowPage(wxWizardPage *page, bool goingForward = TRUE);
|
||||||
|
|
||||||
|
// do fill the dialog with controls
|
||||||
|
// this is app-overridable to, for example, set help and tooltip text
|
||||||
|
void DoCreateControls();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
// was the dialog really created?
|
// was the dialog really created?
|
||||||
bool WasCreated() const { return m_btnPrev != NULL; }
|
bool WasCreated() const { return m_btnPrev != NULL; }
|
||||||
|
|
||||||
// do fill the dialog with controls
|
|
||||||
void DoCreateControls();
|
|
||||||
|
|
||||||
// event handlers
|
// event handlers
|
||||||
void OnCancel(wxCommandEvent& event);
|
void OnCancel(wxCommandEvent& event);
|
||||||
void OnBackOrNext(wxCommandEvent& event);
|
void OnBackOrNext(wxCommandEvent& event);
|
||||||
|
@@ -26,6 +26,9 @@
|
|||||||
#include "wx/event.h" // wxEVT_XXX constants
|
#include "wx/event.h" // wxEVT_XXX constants
|
||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
|
// Extended style to specify a help button
|
||||||
|
#define wxWIZARD_EX_HELPBUTTON 0x00000010
|
||||||
|
|
||||||
// forward declarations
|
// forward declarations
|
||||||
class WXDLLEXPORT wxWizard;
|
class WXDLLEXPORT wxWizard;
|
||||||
|
|
||||||
|
@@ -97,20 +97,29 @@ wxWizardPage *wxWizardPageSimple::GetNext() const
|
|||||||
// generic wxWizard implementation
|
// generic wxWizard implementation
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxWizard::wxWizard(wxWindow *parent,
|
void wxWizard::Init()
|
||||||
|
{
|
||||||
|
m_posWizard = wxDefaultPosition;
|
||||||
|
m_page = (wxWizardPage *)NULL;
|
||||||
|
m_btnPrev = m_btnNext = NULL;
|
||||||
|
m_statbmp = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxWizard::Create(wxWindow *parent,
|
||||||
int id,
|
int id,
|
||||||
const wxString& title,
|
const wxString& title,
|
||||||
const wxBitmap& bitmap,
|
const wxBitmap& bitmap,
|
||||||
const wxPoint& pos)
|
const wxPoint& pos)
|
||||||
: m_posWizard(pos), m_bitmap(bitmap)
|
|
||||||
{
|
{
|
||||||
|
m_posWizard = pos;
|
||||||
|
m_bitmap = bitmap ;
|
||||||
// just create the dialog itself here, the controls will be created in
|
// just create the dialog itself here, the controls will be created in
|
||||||
// DoCreateControls() called later when we know our final size
|
// DoCreateControls() called later when we know our final size
|
||||||
m_page = (wxWizardPage *)NULL;
|
m_page = (wxWizardPage *)NULL;
|
||||||
m_btnPrev = m_btnNext = NULL;
|
m_btnPrev = m_btnNext = NULL;
|
||||||
m_statbmp = NULL;
|
m_statbmp = NULL;
|
||||||
|
|
||||||
(void)wxDialog::Create(parent, id, title, pos);
|
return wxDialog::Create(parent, id, title, pos);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWizard::DoCreateControls()
|
void wxWizard::DoCreateControls()
|
||||||
@@ -189,13 +198,24 @@ void wxWizard::DoCreateControls()
|
|||||||
|
|
||||||
x = m_x + m_width - 3*sizeBtn.x - BUTTON_MARGIN;
|
x = m_x + m_width - 3*sizeBtn.x - BUTTON_MARGIN;
|
||||||
y += SEPARATOR_LINE_MARGIN;
|
y += SEPARATOR_LINE_MARGIN;
|
||||||
|
|
||||||
|
if (GetExtraStyle() & wxWIZARD_EX_HELPBUTTON)
|
||||||
|
{
|
||||||
|
x -= sizeBtn.x;
|
||||||
|
x -= BUTTON_MARGIN ;
|
||||||
|
|
||||||
|
(void*) new wxButton(this, wxID_HELP, _("&Help"), wxPoint(x, y), sizeBtn);
|
||||||
|
x += sizeBtn.x;
|
||||||
|
x += BUTTON_MARGIN ;
|
||||||
|
}
|
||||||
|
|
||||||
m_btnPrev = new wxButton(this, wxID_BACKWARD, _("< &Back"), wxPoint(x, y), sizeBtn);
|
m_btnPrev = new wxButton(this, wxID_BACKWARD, _("< &Back"), wxPoint(x, y), sizeBtn);
|
||||||
|
|
||||||
x += sizeBtn.x;
|
x += sizeBtn.x;
|
||||||
m_btnNext = new wxButton(this, wxID_FORWARD, _("&Next >"), wxPoint(x, y), sizeBtn);
|
m_btnNext = new wxButton(this, wxID_FORWARD, _("&Next >"), wxPoint(x, y), sizeBtn);
|
||||||
|
|
||||||
x += sizeBtn.x + BUTTON_MARGIN;
|
x += sizeBtn.x + BUTTON_MARGIN;
|
||||||
(void)new wxButton(this, wxID_CANCEL, _("Cancel"), wxPoint(x, y), sizeBtn);
|
(void)new wxButton(this, wxID_CANCEL, _("&Cancel"), wxPoint(x, y), sizeBtn);
|
||||||
|
|
||||||
// position and size the dialog
|
// position and size the dialog
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
|
Reference in New Issue
Block a user