]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/gauge.cpp
fix for potential crash when conversion fails
[wxWidgets.git] / samples / widgets / gauge.cpp
index 5c779721cbcbc7b1cd0c39e69e118fb09ad8f88e..7093f874c40e6a06e1e9190f8229479540cfa585 100644 (file)
@@ -52,7 +52,7 @@
 // control ids
 enum
 {
-    GaugePage_Reset = 100,
+    GaugePage_Reset = wxID_HIGHEST,
     GaugePage_Progress,
     GaugePage_Clear,
     GaugePage_SetValue,
@@ -77,6 +77,9 @@ public:
     virtual wxControl *GetWidget() const { return m_gauge; }
     virtual void RecreateWidget() { CreateGauge(); }
 
+    // lazy creation of the content
+    virtual void CreateContent();
+
 protected:
     // event handlers
     void OnButtonReset(wxCommandEvent& event);
@@ -157,16 +160,18 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_WIDGETS_PAGE(GaugeWidgetsPage, _T("Gauge"),
-                       (int)wxPlatform(GENERIC_CTRLS).If(wxMSW,NATIVE_CTRLS)
-                       );
+#if defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(GaugeWidgetsPage, _T("Gauge"), FAMILY_CTRLS );
 
 GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
                                    wxImageList *imaglist)
-                 :WidgetsPage(book)
+                 :WidgetsPage(book, imaglist, gauge_xpm)
 {
-    imaglist->Add(wxBitmap(gauge_xpm));
-
     // init everything
     m_range = 100;
 
@@ -177,7 +182,10 @@ GaugeWidgetsPage::GaugeWidgetsPage(WidgetsBookCtrl *book,
 
     m_gauge = (wxGauge *)NULL;
     m_sizerGauge = (wxSizer *)NULL;
+}
 
+void GaugeWidgetsPage::CreateContent()
+{
     wxSizer *sizerTop = new wxBoxSizer(wxHORIZONTAL);
 
     // left pane