X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/fd07e185b46d550b70864a1ad0e40544630d49f1..530cda2fdc600cd39b4eb2a19cde767b1a06ba00:/samples/widgets/spinbtn.cpp diff --git a/samples/widgets/spinbtn.cpp b/samples/widgets/spinbtn.cpp index bf396d7cb7..ec4b310301 100644 --- a/samples/widgets/spinbtn.cpp +++ b/samples/widgets/spinbtn.cpp @@ -67,6 +67,14 @@ enum SpinBtnPage_SpinCtrlDouble }; +// alignment radiobox values +enum +{ + Align_Left, + Align_Centre, + Align_Right +}; + // ---------------------------------------------------------------------------- // SpinBtnWidgetsPage // ---------------------------------------------------------------------------- @@ -130,6 +138,7 @@ protected: *m_chkArrowKeys, *m_chkWrap, *m_chkProcessEnter; + wxRadioBox *m_radioAlign; // the spinbtn and the spinctrl and the sizer containing them wxSpinButton *m_spinbtn; @@ -199,6 +208,7 @@ SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book, m_chkArrowKeys = NULL; m_chkWrap = NULL; m_chkProcessEnter = NULL; + m_radioAlign = NULL; m_spinbtn = NULL; m_spinctrl = NULL; m_spinctrldbl = NULL; @@ -228,6 +238,21 @@ void SpinBtnWidgetsPage::CreateContent() sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer + static const wxString halign[] = + { + _T("left"), + _T("centre"), + _T("right"), + }; + + m_radioAlign = new wxRadioBox(this, wxID_ANY, _T("&Text alignment"), + wxDefaultPosition, wxDefaultSize, + WXSIZEOF(halign), halign, 1); + + sizerLeft->Add(m_radioAlign, 0, wxGROW | wxALL, 5); + + sizerLeft->Add(5, 5, 0, wxGROW | wxALL, 5); // spacer + wxButton *btn = new wxButton(this, SpinBtnPage_Reset, _T("&Reset")); sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15); @@ -291,6 +316,7 @@ void SpinBtnWidgetsPage::Reset() m_chkArrowKeys->SetValue(true); m_chkWrap->SetValue(false); m_chkProcessEnter->SetValue(false); + m_radioAlign->SetSelection(Align_Right); } void SpinBtnWidgetsPage::CreateSpin() @@ -312,6 +338,26 @@ void SpinBtnWidgetsPage::CreateSpin() if ( m_chkProcessEnter->GetValue() ) flags |= wxTE_PROCESS_ENTER; + int textFlags = 0; + switch ( m_radioAlign->GetSelection() ) + { + default: + wxFAIL_MSG(_T("unexpected radiobox selection")); + // fall through + + case Align_Left: + textFlags |= wxALIGN_LEFT; // no-op + break; + + case Align_Centre: + textFlags |= wxALIGN_CENTRE_HORIZONTAL; + break; + + case Align_Right: + textFlags |= wxALIGN_RIGHT; + break; + } + int val = m_min; if ( m_spinbtn ) { @@ -334,13 +380,13 @@ void SpinBtnWidgetsPage::CreateSpin() m_spinctrl = new wxSpinCtrl(this, SpinBtnPage_SpinCtrl, wxString::Format(_T("%d"), val), wxDefaultPosition, wxDefaultSize, - flags, + flags | textFlags, m_min, m_max, val); m_spinctrldbl = new wxSpinCtrlDouble(this, SpinBtnPage_SpinCtrlDouble, wxString::Format(_T("%d"), val), wxDefaultPosition, wxDefaultSize, - flags, + flags | textFlags, m_min, m_max, val, 0.1); // Add spacers, labels and spin controls to the sizer.