]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/widgets/static.cpp
removed debugging code from the sample
[wxWidgets.git] / samples / widgets / static.cpp
index 61109a84d0853ba96a6b6c08621dd9e7cf2125d4..ba1b4d0ca9826172e8310a3a3203541c84198466 100644 (file)
@@ -41,7 +41,6 @@
 #include "wx/statline.h"
 
 #include "widgets.h"
-
 #include "icons/statbox.xpm"
 
 // ----------------------------------------------------------------------------
@@ -73,6 +72,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
 // ----------------------------------------------------------------------------
@@ -118,8 +176,8 @@ protected:
                *m_textLabel;
 
 private:
-    DECLARE_EVENT_TABLE();
-    DECLARE_WIDGETS_PAGE(StaticWidgetsPage);
+    DECLARE_EVENT_TABLE()
+    DECLARE_WIDGETS_PAGE(StaticWidgetsPage)
 };
 
 // ----------------------------------------------------------------------------
@@ -219,14 +277,14 @@ StaticWidgetsPage::StaticWidgetsPage(wxNotebook *notebook,
 
     // right pane
     wxSizer *sizerRight = new wxBoxSizer(wxHORIZONTAL);
-    sizerRight->SetMinSize(250, 0);
+    sizerRight->SetMinSize(150, 0);
     m_sizerStatic = sizerRight;
 
     CreateStatic();
 
     // the 3 panes panes compose the window
     sizerTop->Add(sizerLeft, 0, wxGROW | (wxALL & ~wxLEFT), 10);
-    sizerTop->Add(sizerMiddle, 1, wxGROW | wxALL, 10);
+    sizerTop->Add(sizerMiddle, 0, wxGROW | wxALL, 10);
     sizerTop->Add(sizerRight, 1, wxGROW | (wxALL & ~wxRIGHT), 10);
 
     // final initializations
@@ -318,13 +376,13 @@ void StaticWidgetsPage::CreateStatic()
     flagsText |= align;
     flagsBox |= align;
 
-    wxStaticBox *box = new wxStaticBox(this, -1, m_textBox->GetValue(),
+    wxStaticBox *box = new MyStaticBox(this, -1, m_textBox->GetValue(),
                                        wxDefaultPosition, wxDefaultSize,
                                        flagsBox);
     m_sizerStatBox = new wxStaticBoxSizer(box, isVert ? wxHORIZONTAL
                                                       : wxVERTICAL);
 
-    m_statText = new wxStaticText(this, -1, m_textLabel->GetValue(),
+    m_statText = new MyStaticText(this, -1, m_textLabel->GetValue(),
                                   wxDefaultPosition, wxDefaultSize,
                                   flagsText);