]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/spinbtn.cpp
Fix wrong configure test for abi::__forced_unwind in previous commit.
[wxWidgets.git] / samples / widgets / spinbtn.cpp
index 347b1039c13998ef84e5fe9d420e4e0930c21558..b037345b02720acabffd0762f02eb19ce633680a 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     16.04.01
 // Id:          $Id$
 // Copyright:   (c) 2001 Vadim Zeitlin
 // Created:     16.04.01
 // Id:          $Id$
 // Copyright:   (c) 2001 Vadim Zeitlin
-// License:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -58,10 +58,12 @@ enum
     SpinBtnPage_Clear,
     SpinBtnPage_SetValue,
     SpinBtnPage_SetMinAndMax,
     SpinBtnPage_Clear,
     SpinBtnPage_SetValue,
     SpinBtnPage_SetMinAndMax,
+    SpinBtnPage_SetBase,
     SpinBtnPage_CurValueText,
     SpinBtnPage_ValueText,
     SpinBtnPage_MinText,
     SpinBtnPage_MaxText,
     SpinBtnPage_CurValueText,
     SpinBtnPage_ValueText,
     SpinBtnPage_MinText,
     SpinBtnPage_MaxText,
+    SpinBtnPage_BaseText,
     SpinBtnPage_SpinBtn,
     SpinBtnPage_SpinCtrl,
     SpinBtnPage_SpinCtrlDouble
     SpinBtnPage_SpinBtn,
     SpinBtnPage_SpinCtrl,
     SpinBtnPage_SpinCtrlDouble
@@ -86,8 +88,14 @@ public:
     virtual ~SpinBtnWidgetsPage(){};
 
     virtual wxControl *GetWidget() const { return m_spinbtn; }
     virtual ~SpinBtnWidgetsPage(){};
 
     virtual wxControl *GetWidget() const { return m_spinbtn; }
-    virtual wxControl *GetWidget2() const { return m_spinctrl; }
-    virtual wxControl *GetWidget3() const { return m_spinctrldbl; }
+    virtual Widgets GetWidgets() const
+    {
+        Widgets widgets(WidgetsPage::GetWidgets());
+        widgets.push_back(m_spinctrl);
+        widgets.push_back(m_spinctrldbl);
+        return widgets;
+    }
+
     virtual void RecreateWidget() { CreateSpin(); }
 
     // lazy creation of the content
     virtual void RecreateWidget() { CreateSpin(); }
 
     // lazy creation of the content
@@ -99,6 +107,7 @@ protected:
     void OnButtonClear(wxCommandEvent& event);
     void OnButtonSetValue(wxCommandEvent& event);
     void OnButtonSetMinAndMax(wxCommandEvent& event);
     void OnButtonClear(wxCommandEvent& event);
     void OnButtonSetValue(wxCommandEvent& event);
     void OnButtonSetMinAndMax(wxCommandEvent& event);
+    void OnButtonSetBase(wxCommandEvent& event);
 
     void OnCheckOrRadioBox(wxCommandEvent& event);
 
 
     void OnCheckOrRadioBox(wxCommandEvent& event);
 
@@ -112,6 +121,7 @@ protected:
 
     void OnUpdateUIValueButton(wxUpdateUIEvent& event);
     void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
 
     void OnUpdateUIValueButton(wxUpdateUIEvent& event);
     void OnUpdateUIMinMaxButton(wxUpdateUIEvent& event);
+    void OnUpdateUIBaseButton(wxUpdateUIEvent& event);
 
     void OnUpdateUIResetButton(wxUpdateUIEvent& event);
 
 
     void OnUpdateUIResetButton(wxUpdateUIEvent& event);
 
@@ -130,6 +140,9 @@ protected:
     // the spinbtn range
     int m_min, m_max;
 
     // the spinbtn range
     int m_min, m_max;
 
+    // and numeric base
+    int m_base;
+
     // the controls
     // ------------
 
     // the controls
     // ------------
 
@@ -138,7 +151,7 @@ protected:
                *m_chkArrowKeys,
                *m_chkWrap,
                *m_chkProcessEnter;
                *m_chkArrowKeys,
                *m_chkWrap,
                *m_chkProcessEnter;
-   wxRadioBox *m_radioAlign;
+    wxRadioBox *m_radioAlign;
 
     // the spinbtn and the spinctrl and the sizer containing them
     wxSpinButton *m_spinbtn;
 
     // the spinbtn and the spinctrl and the sizer containing them
     wxSpinButton *m_spinbtn;
@@ -150,7 +163,8 @@ protected:
     // the text entries for set value/range
     wxTextCtrl *m_textValue,
                *m_textMin,
     // the text entries for set value/range
     wxTextCtrl *m_textValue,
                *m_textMin,
-               *m_textMax;
+               *m_textMax,
+               *m_textBase;
 
 private:
     DECLARE_EVENT_TABLE()
 
 private:
     DECLARE_EVENT_TABLE()
@@ -165,9 +179,11 @@ BEGIN_EVENT_TABLE(SpinBtnWidgetsPage, WidgetsPage)
     EVT_BUTTON(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnButtonReset)
     EVT_BUTTON(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnButtonSetValue)
     EVT_BUTTON(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnButtonSetMinAndMax)
     EVT_BUTTON(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnButtonReset)
     EVT_BUTTON(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnButtonSetValue)
     EVT_BUTTON(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnButtonSetMinAndMax)
+    EVT_BUTTON(SpinBtnPage_SetBase, SpinBtnWidgetsPage::OnButtonSetBase)
 
     EVT_UPDATE_UI(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnUpdateUIValueButton)
     EVT_UPDATE_UI(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnUpdateUIMinMaxButton)
 
     EVT_UPDATE_UI(SpinBtnPage_SetValue, SpinBtnWidgetsPage::OnUpdateUIValueButton)
     EVT_UPDATE_UI(SpinBtnPage_SetMinAndMax, SpinBtnWidgetsPage::OnUpdateUIMinMaxButton)
+    EVT_UPDATE_UI(SpinBtnPage_SetBase, SpinBtnWidgetsPage::OnUpdateUIBaseButton)
 
     EVT_UPDATE_UI(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnUpdateUIResetButton)
 
 
     EVT_UPDATE_UI(SpinBtnPage_Reset, SpinBtnWidgetsPage::OnUpdateUIResetButton)
 
@@ -181,6 +197,7 @@ BEGIN_EVENT_TABLE(SpinBtnWidgetsPage, WidgetsPage)
     EVT_TEXT(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinText)
     EVT_TEXT_ENTER(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinTextEnter)
     EVT_TEXT(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinText)
     EVT_TEXT(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinText)
     EVT_TEXT_ENTER(SpinBtnPage_SpinCtrl, SpinBtnWidgetsPage::OnSpinTextEnter)
     EVT_TEXT(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinText)
+    EVT_TEXT_ENTER(SpinBtnPage_SpinCtrlDouble, SpinBtnWidgetsPage::OnSpinTextEnter)
 
     EVT_CHECKBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox)
     EVT_RADIOBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox)
 
     EVT_CHECKBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox)
     EVT_RADIOBOX(wxID_ANY, SpinBtnWidgetsPage::OnCheckOrRadioBox)
@@ -212,13 +229,16 @@ SpinBtnWidgetsPage::SpinBtnWidgetsPage(WidgetsBookCtrl *book,
     m_spinbtn = NULL;
     m_spinctrl = NULL;
     m_spinctrldbl = NULL;
     m_spinbtn = NULL;
     m_spinctrl = NULL;
     m_spinctrldbl = NULL;
-    m_textValue = NULL;
-    m_textMin = NULL;
-    m_textMax = NULL;
+    m_textValue =
+    m_textMin =
+    m_textMax =
+    m_textBase = NULL;
 
     m_min = 0;
     m_max = 10;
 
 
     m_min = 0;
     m_max = 10;
 
+    m_base = 10;
+
     m_sizerSpin = NULL;
 }
 
     m_sizerSpin = NULL;
 }
 
@@ -289,6 +309,13 @@ void SpinBtnWidgetsPage::CreateContent()
 
     sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
 
 
     sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
 
+    sizerRow = CreateSizerWithTextAndButton(SpinBtnPage_SetBase,
+                                            "Set &base",
+                                            SpinBtnPage_BaseText,
+                                            &m_textBase);
+    m_textBase->SetValue("10");
+    sizerMiddle->Add(sizerRow, 0, wxALL | wxGROW, 5);
+
     // right pane
     wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL);
     sizerRight->SetMinSize(150, 0);
     // right pane
     wxSizer *sizerRight = new wxBoxSizer(wxVERTICAL);
     sizerRight->SetMinSize(150, 0);
@@ -439,6 +466,22 @@ void SpinBtnWidgetsPage::OnButtonSetMinAndMax(wxCommandEvent& WXUNUSED(event))
     m_spinctrldbl->SetRange(minNew, maxNew);
 }
 
     m_spinctrldbl->SetRange(minNew, maxNew);
 }
 
+void SpinBtnWidgetsPage::OnButtonSetBase(wxCommandEvent& WXUNUSED(event))
+{
+    unsigned long base;
+    if ( !m_textBase->GetValue().ToULong(&base) || !base )
+    {
+        wxLogWarning("Invalid base value.");
+        return;
+    }
+
+    m_base = base;
+    if ( !m_spinctrl->SetBase(m_base) )
+    {
+        wxLogWarning("Setting base %d failed.", m_base);
+    }
+}
+
 void SpinBtnWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
 {
     long val;
 void SpinBtnWidgetsPage::OnButtonSetValue(wxCommandEvent& WXUNUSED(event))
 {
     long val;
@@ -468,6 +511,12 @@ void SpinBtnWidgetsPage::OnUpdateUIMinMaxButton(wxUpdateUIEvent& event)
                   mn <= mx);
 }
 
                   mn <= mx);
 }
 
+void SpinBtnWidgetsPage::OnUpdateUIBaseButton(wxUpdateUIEvent& event)
+{
+    unsigned long base;
+    event.Enable( m_textBase->GetValue().ToULong(&base) && base );
+}
+
 void SpinBtnWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
     event.Enable( !m_chkVert->GetValue() ||
 void SpinBtnWidgetsPage::OnUpdateUIResetButton(wxUpdateUIEvent& event)
 {
     event.Enable( !m_chkVert->GetValue() ||