]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/textctrl.cpp
fix for potential crash when conversion fails
[wxWidgets.git] / samples / widgets / textctrl.cpp
index c3b4392181b59579093c3ffb4757934896b807ff..0d2e8e293c966b098b2a8e8e08193f0d74d9e64d 100644 (file)
@@ -53,7 +53,7 @@
 // control ids
 enum
 {
-    TextPage_Reset = 100,
+    TextPage_Reset = wxID_HIGHEST,
 
     TextPage_Set,
     TextPage_Add,
@@ -132,10 +132,14 @@ class TextWidgetsPage : public WidgetsPage
 {
 public:
     // ctor(s) and dtor
-    TextWidgetsPage(wxBookCtrlBase *book, wxImageList *imaglist);
+    TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist);
     virtual ~TextWidgetsPage(){};
 
     virtual wxControl *GetWidget() const { return m_text; }
+    virtual void RecreateWidget() { CreateText(); }
+
+    // lazy creation of the content
+    virtual void CreateContent();
 
 protected:
     // create an info text contorl
@@ -328,17 +332,25 @@ END_EVENT_TABLE()
 // implementation
 // ============================================================================
 
-IMPLEMENT_WIDGETS_PAGE(TextWidgetsPage, _T("Text"));
+#if defined(__WXX11__)
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#elif defined(__WXUNIVERSAL__)
+    #define FAMILY_CTRLS UNIVERSAL_CTRLS
+#else
+    #define FAMILY_CTRLS NATIVE_CTRLS
+#endif
+
+IMPLEMENT_WIDGETS_PAGE(TextWidgetsPage, _T("Text"),
+                       FAMILY_CTRLS | EDITABLE_CTRLS
+                       );
 
 // ----------------------------------------------------------------------------
 // TextWidgetsPage creation
 // ----------------------------------------------------------------------------
 
-TextWidgetsPage::TextWidgetsPage(wxBookCtrlBase *book, wxImageList *imaglist)
-               : WidgetsPage(book)
+TextWidgetsPage::TextWidgetsPage(WidgetsBookCtrl *book, wxImageList *imaglist)
+               : WidgetsPage(book, imaglist, text_xpm)
 {
-    imaglist->Add(wxBitmap(text_xpm));
-
     // init everything
 #ifdef __WXMSW__
     m_radioKind =
@@ -365,7 +377,10 @@ TextWidgetsPage::TextWidgetsPage(wxBookCtrlBase *book, wxImageList *imaglist)
     m_posLast =
     m_selFrom =
     m_selTo = -2; // not -1 which means "no selection"
+}
 
+void TextWidgetsPage::CreateContent()
+{
     // left pane
     static const wxString modes[] =
     {
@@ -599,7 +614,7 @@ void TextWidgetsPage::Reset()
 
 void TextWidgetsPage::CreateText()
 {
-    int flags = 0;
+    int flags = ms_defaultFlags;
     switch ( m_radioTextLines->GetSelection() )
     {
         default:
@@ -633,7 +648,7 @@ void TextWidgetsPage::CreateText()
             break;
 
         case WrapStyle_Char:
-            flags |= wxTE_LINEWRAP;
+            flags |= wxTE_CHARWRAP;
             break;
 
         case WrapStyle_Best: