+ MyAboutDialog dlg(this);
+ dlg.ShowModal();
+}
+
+void MyFrame::OnUpdateSetPaneStyle(wxUpdateUIEvent& event)
+{
+ switch (event.GetId())
+ {
+ case StatusBar_SetPaneStyleNormal:
+ event.Check(m_statbarPaneStyle == wxSB_NORMAL);
+ break;
+ case StatusBar_SetPaneStyleFlat:
+ event.Check(m_statbarPaneStyle == wxSB_FLAT);
+ break;
+ case StatusBar_SetPaneStyleRaised:
+ event.Check(m_statbarPaneStyle == wxSB_RAISED);
+ break;
+ }
+}
+
+void MyFrame::OnSetPaneStyle(wxCommandEvent& event)
+{
+ switch (event.GetId())
+ {
+ case StatusBar_SetPaneStyleNormal:
+ m_statbarPaneStyle = wxSB_NORMAL;
+ break;
+ case StatusBar_SetPaneStyleFlat:
+ m_statbarPaneStyle = wxSB_FLAT;
+ break;
+ case StatusBar_SetPaneStyleRaised:
+ m_statbarPaneStyle = wxSB_RAISED;
+ break;
+ }
+
+ ApplyPaneStyle();
+}
+
+void MyFrame::ApplyPaneStyle()
+{
+ wxStatusBar *sb = GetStatusBar();
+ if (!sb)
+ return;
+
+ int fields = sb->GetFieldsCount();
+ int *styles = new int[fields];
+
+ for (int i = 1; i < fields; i++)
+ styles[i] = wxSB_NORMAL;
+
+ styles[0] = m_statbarPaneStyle;
+
+ sb->SetStatusStyles(fields, styles);
+
+ delete [] styles;
+}
+
+void MyFrame::OnUpdateSetStyle(wxUpdateUIEvent& event)
+{
+ long currentStyle = wxSTB_DEFAULT_STYLE;
+ if (GetStatusBar())
+ currentStyle = GetStatusBar()->GetWindowStyle();
+
+ switch (event.GetId())
+ {
+ case StatusBar_SetStyleSizeGrip:
+ event.Check((currentStyle & wxSTB_SIZEGRIP) != 0);
+ break;
+ case StatusBar_SetStyleShowTips:
+ event.Check((currentStyle & wxSTB_SHOW_TIPS) != 0);
+ break;
+
+ case StatusBar_SetStyleEllipsizeStart:
+ event.Check((currentStyle & wxSTB_ELLIPSIZE_START) != 0);
+ break;
+ case StatusBar_SetStyleEllipsizeMiddle:
+ event.Check((currentStyle & wxSTB_ELLIPSIZE_MIDDLE) != 0);
+ break;
+ case StatusBar_SetStyleEllipsizeEnd:
+ event.Check((currentStyle & wxSTB_ELLIPSIZE_END) != 0);
+ break;
+ }
+}
+
+void MyFrame::OnSetStyle(wxCommandEvent& event)
+{
+ long oldStyle = wxSTB_DEFAULT_STYLE;
+ if (GetStatusBar())
+ oldStyle = GetStatusBar()->GetWindowStyle();
+
+ #define STB_ELLIPSIZE_MASK \
+ (wxSTB_ELLIPSIZE_START|wxSTB_ELLIPSIZE_MIDDLE|wxSTB_ELLIPSIZE_END)
+
+ long newStyle = oldStyle;
+ long newStyleBit = 0;
+ switch (event.GetId())
+ {
+ case StatusBar_SetStyleSizeGrip:
+ newStyleBit = wxSTB_SIZEGRIP;
+ break;
+ case StatusBar_SetStyleShowTips:
+ newStyleBit = wxSTB_SHOW_TIPS;
+ break;
+
+ case StatusBar_SetStyleEllipsizeStart:
+ newStyleBit = wxSTB_ELLIPSIZE_START;
+ newStyle &= ~STB_ELLIPSIZE_MASK;
+ break;
+ case StatusBar_SetStyleEllipsizeMiddle:
+ newStyleBit = wxSTB_ELLIPSIZE_MIDDLE;
+ newStyle &= ~STB_ELLIPSIZE_MASK;
+ break;
+ case StatusBar_SetStyleEllipsizeEnd:
+ newStyleBit = wxSTB_ELLIPSIZE_END;
+ newStyle &= ~STB_ELLIPSIZE_MASK;
+ break;
+ }
+
+ newStyle = event.IsChecked() ? (newStyle | newStyleBit) :
+ (newStyle & ~newStyleBit);
+ if (newStyle != oldStyle)
+ {
+ DoCreateStatusBar(m_statbarKind, newStyle);
+ SetStatusText("Status bar recreated with a new style");
+ }
+}
+
+// ----------------------------------------------------------------------------
+// MyAboutDialog
+// ----------------------------------------------------------------------------
+
+MyAboutDialog::MyAboutDialog(wxWindow *parent)
+ : wxDialog(parent, wxID_ANY, wxString(wxT("About statbar")),
+ wxDefaultPosition, wxDefaultSize,
+ wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+{
+ wxStaticText *text = new wxStaticText(this, wxID_ANY,
+ wxT("wxStatusBar sample\n")
+ wxT("(c) 2000 Vadim Zeitlin"));
+
+ wxButton *btn = new wxButton(this, wxID_OK, wxT("&Close"));
+
+ // create the top status bar without the size grip (default style),
+ // otherwise it looks weird
+ wxStatusBar *statbarTop = new wxStatusBar(this, wxID_ANY, 0);
+ statbarTop->SetFieldsCount(3);
+ statbarTop->SetStatusText(wxT("This is a top status bar"), 0);
+ statbarTop->SetStatusText(wxT("in a dialog"), 1);
+ statbarTop->SetStatusText(wxT("Great, isn't it?"), 2);
+
+ wxStatusBar *statbarBottom = new wxStatusBar(this, wxID_ANY);
+ statbarBottom->SetFieldsCount(2);
+ statbarBottom->SetStatusText(wxT("This is a bottom status bar"), 0);
+ statbarBottom->SetStatusText(wxT("in a dialog"), 1);
+
+ wxBoxSizer *sizerTop = new wxBoxSizer(wxVERTICAL);
+ sizerTop->Add(statbarTop, 0, wxGROW);
+ sizerTop->Add(-1, 10, 1, wxGROW);
+ sizerTop->Add(text, 0, wxCENTRE | wxRIGHT | wxLEFT, 20);
+ sizerTop->Add(-1, 10, 1, wxGROW);
+ sizerTop->Add(btn, 0, wxCENTRE | wxRIGHT | wxLEFT, 20);
+ sizerTop->Add(-1, 10, 1, wxGROW);
+ sizerTop->Add(statbarBottom, 0, wxGROW);
+
+ SetSizerAndFit(sizerTop);