]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/static.cpp
fix for dmc compilation of projects with more than one obj
[wxWidgets.git] / samples / widgets / static.cpp
index 991f823d1916d758bdd2ac898fc52449ed42dd8c..98b8d5803dd6045de2b0ccfeb6702ec864511350 100644 (file)
@@ -28,6 +28,7 @@
 #ifndef WX_PRECOMP
     #include "wx/log.h"
 
+    #include "wx/bitmap.h"
     #include "wx/button.h"
     #include "wx/checkbox.h"
     #include "wx/radiobox.h"
@@ -41,7 +42,6 @@
 #include "wx/statline.h"
 
 #include "widgets.h"
-#if 1
 #include "icons/statbox.xpm"
 
 // ----------------------------------------------------------------------------
@@ -73,6 +73,65 @@ enum
     StaticVAlign_Max
 };
 
+// ----------------------------------------------------------------------------
+// MyStaticText and MyStaticBox
+// ----------------------------------------------------------------------------
+
+// these 2 classes simply show that the static controls can get the mouse
+// clicks too -- this used to be broken under MSW but works now
+
+class MyStaticText : public wxStaticText
+{
+public:
+    MyStaticText(wxWindow* parent,
+                      wxWindowID id,
+                      const wxString& label,
+                      const wxPoint& pos = wxDefaultPosition,
+                      const wxSize& size = wxDefaultSize,
+                      long style = 0)
+        : wxStaticText(parent, id, label, pos, size, style)
+    {
+    }
+
+protected:
+    void OnMouseEvent(wxMouseEvent& event)
+    {
+        wxLogMessage(wxT("Clicked on static text"));
+    }
+
+    DECLARE_EVENT_TABLE()
+};
+
+class MyStaticBox : public wxStaticBox
+{
+public:
+    MyStaticBox(wxWindow* parent,
+                wxWindowID id,
+                const wxString& label,
+                const wxPoint& pos = wxDefaultPosition,
+                const wxSize& size = wxDefaultSize,
+                long style = 0)
+        : wxStaticBox(parent, id, label, pos, size, style)
+    {
+    }
+
+protected:
+    void OnMouseEvent(wxMouseEvent& event)
+    {
+        wxLogMessage(wxT("Clicked on static box"));
+    }
+
+    DECLARE_EVENT_TABLE()
+};
+
+BEGIN_EVENT_TABLE(MyStaticText, wxStaticText)
+    EVT_LEFT_UP(MyStaticText::OnMouseEvent)
+END_EVENT_TABLE()
+
+BEGIN_EVENT_TABLE(MyStaticBox, wxStaticBox)
+    EVT_LEFT_UP(MyStaticBox::OnMouseEvent)
+END_EVENT_TABLE()
+
 // ----------------------------------------------------------------------------
 // StaticWidgetsPage
 // ----------------------------------------------------------------------------
@@ -108,6 +167,7 @@ protected:
                *m_radioVAlign;
 
     // the controls and the sizer containing them
+    wxStaticBox *m_staticBox;
     wxStaticBoxSizer *m_sizerStatBox;
     wxStaticText *m_statText;
     wxStaticLine *m_statLine;
@@ -157,6 +217,7 @@ StaticWidgetsPage::StaticWidgetsPage(wxNotebook *notebook,
     m_statLine = (wxStaticLine *)NULL;
     m_statText = (wxStaticText *)NULL;
 
+    m_staticBox = (wxStaticBox *)NULL;
     m_sizerStatBox = (wxStaticBoxSizer *)NULL;
     m_sizerStatic = (wxSizer *)NULL;
 
@@ -261,9 +322,9 @@ void StaticWidgetsPage::CreateStatic()
 
     if ( m_sizerStatBox )
     {
-        m_sizerStatic->Remove(m_sizerStatBox);
-
+        delete m_staticBox;
         // delete m_sizerStatBox; -- deleted by Remove()
+        m_sizerStatic->Remove(m_sizerStatBox);
         delete m_statText;
         delete m_statLine;
     }
@@ -318,13 +379,13 @@ void StaticWidgetsPage::CreateStatic()
     flagsText |= align;
     flagsBox |= align;
 
-    wxStaticBox *box = new wxStaticBox(this, -1, m_textBox->GetValue(),
-                                       wxDefaultPosition, wxDefaultSize,
-                                       flagsBox);
-    m_sizerStatBox = new wxStaticBoxSizer(box, isVert ? wxHORIZONTAL
-                                                      : wxVERTICAL);
+    m_staticBox = new MyStaticBox(this, -1, m_textBox->GetValue(),
+                                  wxDefaultPosition, wxDefaultSize,
+                                  flagsBox);
+    m_sizerStatBox = new wxStaticBoxSizer(m_staticBox, isVert ? wxHORIZONTAL
+                                                              : wxVERTICAL);
 
-    m_statText = new wxStaticText(this, -1, m_textLabel->GetValue(),
+    m_statText = new MyStaticText(this, -1, m_textLabel->GetValue(),
                                   wxDefaultPosition, wxDefaultSize,
                                   flagsText);
 
@@ -367,4 +428,3 @@ void StaticWidgetsPage::OnButtonLabelText(wxCommandEvent& event)
     m_statText->SetLabel(m_textLabel->GetValue());
 }
 
-#endif
\ No newline at end of file