]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/checkbox.cpp
Rebake the rest of the files after TOOLKIT change in MSW bakefile.
[wxWidgets.git] / samples / widgets / checkbox.cpp
index efa37bf753ffea1ef8086ebc15924a067b5ed579..ae6261a898a8b53274b060cea5d3a58d6ad68d0e 100644 (file)
@@ -6,7 +6,7 @@
 // Created:     27 Sep 2003
 // Id:          $Id$
 // Copyright:   (c) 2003 wxWindows team
 // Created:     27 Sep 2003
 // Id:          $Id$
 // Copyright:   (c) 2003 wxWindows team
-// License:     wxWindows license
+// Licence:     wxWindows licence
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
 /////////////////////////////////////////////////////////////////////////////
 
 // ============================================================================
@@ -32,6 +32,9 @@
     #include "wx/bitmap.h"
     #include "wx/button.h"
     #include "wx/checkbox.h"
     #include "wx/bitmap.h"
     #include "wx/button.h"
     #include "wx/checkbox.h"
+    #include "wx/radiobox.h"
+    #include "wx/statbox.h"
+    #include "wx/textctrl.h"
 
     #include "wx/sizer.h"
 #endif
 
     #include "wx/sizer.h"
 #endif
@@ -47,7 +50,7 @@
 // control ids
 enum
 {
 // control ids
 enum
 {
-    CheckboxPage_Reset = 100,
+    CheckboxPage_Reset = wxID_HIGHEST,
     CheckboxPage_ChangeLabel,
     CheckboxPage_Check,
     CheckboxPage_Uncheck,
     CheckboxPage_ChangeLabel,
     CheckboxPage_Check,
     CheckboxPage_Uncheck,
@@ -70,8 +73,14 @@ enum
 class CheckBoxWidgetsPage : public WidgetsPage
 {
 public:
 class CheckBoxWidgetsPage : public WidgetsPage
 {
 public:
-    CheckBoxWidgetsPage(wxNotebook *notebook, wxImageList *imaglist);
-    virtual ~CheckBoxWidgetsPage();
+    CheckBoxWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
+    virtual ~CheckBoxWidgetsPage(){};
+
+    virtual wxControl *GetWidget() const { return m_checkbox; }
+    virtual void RecreateWidget() { CreateCheckbox(); }
+
+    // lazy creation of the content
+    virtual void CreateContent();
 
 protected:
     // event handlers
 
 protected:
     // event handlers
@@ -103,7 +112,7 @@ protected:
     // the controls
     // ------------
 
     // the controls
     // ------------
 
-    // the contols to choose the checkbox style
+    // the controls to choose the checkbox style
     wxCheckBox *m_chkRight;
     wxRadioBox *m_radioKind;
 
     wxCheckBox *m_chkRight;
     wxRadioBox *m_radioKind;
 
@@ -142,25 +151,33 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
 // implementation
 // ============================================================================
 
-IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, wxT("CheckBox"));
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
 
 
-CheckBoxWidgetsPage::CheckBoxWidgetsPage(wxNotebook *notebook,
-                                       wxImageList *imaglist)
-                  : WidgetsPage(notebook)
+IMPLEMENT_WIDGETS_PAGE(CheckBoxWidgetsPage, wxT("CheckBox"), FAMILY_CTRLS );
+
+CheckBoxWidgetsPage::CheckBoxWidgetsPage(WidgetsBookCtrl *book,
+                                         wxImageList *imaglist)
+                  : WidgetsPage(book, imaglist, checkbox_xpm)
 {
 {
-    imaglist->Add(wxBitmap(checkbox_xpm));
+}
 
 
+void CheckBoxWidgetsPage::CreateContent()
+{
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
     // left pane
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
     // left pane
-    wxStaticBox *box = new wxStaticBox(this, wxID_ANY, _T("&Set style"));
+    wxStaticBox *box = new wxStaticBox(this, wxID_ANY, wxT("&Set style"));
 
     wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
 
     m_chkRight = CreateCheckBoxAndAddToSizer
                  (
                     sizerLeft,
 
     wxSizer *sizerLeft = new wxStaticBoxSizer(box, wxVERTICAL);
 
     m_chkRight = CreateCheckBoxAndAddToSizer
                  (
                     sizerLeft,
-                    _T("&Right aligned"),
+                    wxT("&Right aligned"),
                     CheckboxPage_ChkRight
                  );
 
                     CheckboxPage_ChkRight
                  );
 
@@ -168,39 +185,39 @@ CheckBoxWidgetsPage::CheckBoxWidgetsPage(wxNotebook *notebook,
 
     static const wxString kinds[] =
     {
 
     static const wxString kinds[] =
     {
-        _T("usual &2-state checkbox"),
-        _T("&3rd state settable by program"),
-        _T("&user-settable 3rd state"),
+        wxT("usual &2-state checkbox"),
+        wxT("&3rd state settable by program"),
+        wxT("&user-settable 3rd state"),
     };
 
     };
 
-    m_radioKind = new wxRadioBox(this, wxID_ANY, _T("&Kind"),
+    m_radioKind = new wxRadioBox(this, wxID_ANY, wxT("&Kind"),
                                  wxDefaultPosition, wxDefaultSize,
                                  WXSIZEOF(kinds), kinds,
                                  1);
     sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
                                  wxDefaultPosition, wxDefaultSize,
                                  WXSIZEOF(kinds), kinds,
                                  1);
     sizerLeft->Add(m_radioKind, 0, wxGROW | wxALL, 5);
-    wxButton *btn = new wxButton(this, CheckboxPage_Reset, _T("&Reset"));
+    wxButton *btn = new wxButton(this, CheckboxPage_Reset, wxT("&Reset"));
     sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
 
     // middle pane
     sizerLeft->Add(btn, 0, wxALIGN_CENTRE_HORIZONTAL | wxALL, 15);
 
     // middle pane
-    wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, _T("&Operations"));
+    wxStaticBox *box2 = new wxStaticBox(this, wxID_ANY, wxT("&Operations"));
     wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
 
     sizerMiddle->Add(CreateSizerWithTextAndButton(CheckboxPage_ChangeLabel,
     wxSizer *sizerMiddle = new wxStaticBoxSizer(box2, wxVERTICAL);
 
     sizerMiddle->Add(CreateSizerWithTextAndButton(CheckboxPage_ChangeLabel,
-                                                     _T("Change label"),
+                                                     wxT("Change label"),
                                                      wxID_ANY,
                                                      &m_textLabel),
                      0, wxALL | wxGROW, 5);
                                                      wxID_ANY,
                                                      &m_textLabel),
                      0, wxALL | wxGROW, 5);
-    sizerMiddle->Add(new wxButton(this, CheckboxPage_Check, _T("&Check it")),
+    sizerMiddle->Add(new wxButton(this, CheckboxPage_Check, wxT("&Check it")),
                      0, wxALL | wxGROW, 5);
                      0, wxALL | wxGROW, 5);
-    sizerMiddle->Add(new wxButton(this, CheckboxPage_Uncheck, _T("&Uncheck it")),
+    sizerMiddle->Add(new wxButton(this, CheckboxPage_Uncheck, wxT("&Uncheck it")),
                      0, wxALL | wxGROW, 5);
     sizerMiddle->Add(new wxButton(this, CheckboxPage_PartCheck,
                      0, wxALL | wxGROW, 5);
     sizerMiddle->Add(new wxButton(this, CheckboxPage_PartCheck,
-                                  _T("Put in &3rd state")),
+                                  wxT("Put in &3rd state")),
                      0, wxALL | wxGROW, 5);
 
     // right pane
     wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
                      0, wxALL | wxGROW, 5);
 
     // right pane
     wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
-    m_checkbox = new wxCheckBox(this, CheckboxPage_Checkbox, _T("&Check me!"));
+    m_checkbox = new wxCheckBox(this, CheckboxPage_Checkbox, wxT("&Check me!"));
     sizerRight->Add(0, 0, 1, wxCENTRE);
     sizerRight->Add(m_checkbox, 1, wxCENTRE);
     sizerRight->Add(0, 0, 1, wxCENTRE);
     sizerRight->Add(0, 0, 1, wxCENTRE);
     sizerRight->Add(m_checkbox, 1, wxCENTRE);
     sizerRight->Add(0, 0, 1, wxCENTRE);
@@ -216,12 +233,6 @@ CheckBoxWidgetsPage::CheckBoxWidgetsPage(wxNotebook *notebook,
     Reset();
 
     SetSizer(sizerTop);
     Reset();
 
     SetSizer(sizerTop);
-
-    sizerTop->Fit(this);
-}
-
-CheckBoxWidgetsPage::~CheckBoxWidgetsPage()
-{
 }
 
 void CheckBoxWidgetsPage::Reset()
 }
 
 void CheckBoxWidgetsPage::Reset()
@@ -242,14 +253,14 @@ void CheckBoxWidgetsPage::CreateCheckbox()
 
     delete m_checkbox;
 
 
     delete m_checkbox;
 
-    int flags = 0;
+    int flags = ms_defaultFlags;
     if ( m_chkRight->IsChecked() )
         flags |= wxALIGN_RIGHT;
 
     switch ( m_radioKind->GetSelection() )
     {
         default:
     if ( m_chkRight->IsChecked() )
         flags |= wxALIGN_RIGHT;
 
     switch ( m_radioKind->GetSelection() )
     {
         default:
-            wxFAIL_MSG(_T("unexpected radiobox selection"));
+            wxFAIL_MSG(wxT("unexpected radiobox selection"));
             // fall through
 
         case CheckboxKind_2State:
             // fall through
 
         case CheckboxKind_2State:
@@ -298,8 +309,8 @@ void CheckBoxWidgetsPage::OnButtonChangeLabel(wxCommandEvent& WXUNUSED(event))
 
 void CheckBoxWidgetsPage::OnCheckBox(wxCommandEvent& event)
 {
 
 void CheckBoxWidgetsPage::OnCheckBox(wxCommandEvent& event)
 {
-    wxLogMessage(_T("Test checkbox %schecked (value = %d)."),
-                 event.IsChecked() ? _T("") : _T("un"),
+    wxLogMessage(wxT("Test checkbox %schecked (value = %d)."),
+                 event.IsChecked() ? wxT("") : wxT("un"),
                  (int)m_checkbox->Get3StateValue());
 }
 
                  (int)m_checkbox->Get3StateValue());
 }