X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/bdb1f15c2ba3b58506bfc6a2b058714629fa7be3..f5766910b6731eb03e82371416e9778203396ce7:/samples/statbar/statbar.cpp?ds=inline diff --git a/samples/statbar/statbar.cpp b/samples/statbar/statbar.cpp index e70243ea80..06ad57c3b3 100644 --- a/samples/statbar/statbar.cpp +++ b/samples/statbar/statbar.cpp @@ -96,7 +96,9 @@ public: void UpdateClock(); // event handlers +#if wxUSE_TIMER void OnTimer(wxTimerEvent& WXUNUSED(event)) { UpdateClock(); } +#endif void OnSize(wxSizeEvent& event); void OnToggleClock(wxCommandEvent& event); void OnButton(wxCommandEvent& event); @@ -116,9 +118,13 @@ private: Field_Max }; +#if wxUSE_TIMER wxTimer m_timer; +#endif +#if wxUSE_CHECKBOX wxCheckBox *m_checkbox; +#endif #ifdef USE_STATIC_BITMAP wxStaticBitmap *m_statbmp; #else @@ -234,9 +240,13 @@ END_EVENT_TABLE() BEGIN_EVENT_TABLE(MyStatusBar, wxStatusBar) EVT_SIZE(MyStatusBar::OnSize) +#if wxUSE_CHECKBOX EVT_CHECKBOX(StatusBar_Checkbox, MyStatusBar::OnToggleClock) +#endif EVT_BUTTON(wxID_ANY, MyStatusBar::OnButton) +#if wxUSE_TIMER EVT_TIMER(wxID_ANY, MyStatusBar::OnTimer) +#endif END_EVENT_TABLE() // Create a new application object: this macro will allow wxWidgets to create @@ -442,7 +452,7 @@ void MyFrame::OnSetStatusFields(wxCommandEvent& WXUNUSED(event)) void MyFrame::OnUpdateStatusBarToggle(wxUpdateUIEvent& event) { - event.Check(GetStatusBar() != 0); + event.Check(GetStatusBar() != NULL); } void MyFrame::OnStatusBarToggle(wxCommandEvent& WXUNUSED(event)) @@ -451,17 +461,12 @@ void MyFrame::OnStatusBarToggle(wxCommandEvent& WXUNUSED(event)) if ( statbarOld ) { statbarOld->Hide(); - SetStatusBar(0); + SetStatusBar(NULL); } else { DoCreateStatusBar(m_statbarKind); } -#ifdef __WXMSW__ - // The following is a kludge suggested by Vadim Zeitlin (one of the wxWidgets - // authors) while we look for a proper fix.. -// SendSizeEvent(); -#endif } void MyFrame::OnRecreateStatusBar(wxCommandEvent& WXUNUSED(event)) @@ -584,15 +589,23 @@ MyAboutDialog::MyAboutDialog(wxWindow *parent) #endif MyStatusBar::MyStatusBar(wxWindow *parent) - : wxStatusBar(parent, wxID_ANY), m_timer(this), m_checkbox(NULL) + : wxStatusBar(parent, wxID_ANY) +#if wxUSE_TIMER + , m_timer(this) +#endif +#if wxUSE_CHECKBOX + , m_checkbox(NULL) +#endif { static const int widths[Field_Max] = { -1, 150, BITMAP_SIZE_X, 100 }; SetFieldsCount(Field_Max); SetStatusWidths(Field_Max, widths); +#if wxUSE_CHECKBOX m_checkbox = new wxCheckBox(this, StatusBar_Checkbox, _T("&Toggle clock")); m_checkbox->SetValue(true); +#endif #ifdef USE_STATIC_BITMAP m_statbmp = new wxStaticBitmap(this, wxID_ANY, wxIcon(green_xpm)); @@ -602,7 +615,9 @@ MyStatusBar::MyStatusBar(wxWindow *parent) wxBU_EXACTFIT); #endif +#if wxUSE_TIMER m_timer.Start(1000); +#endif SetMinHeight(BITMAP_SIZE_Y); @@ -615,10 +630,12 @@ MyStatusBar::MyStatusBar(wxWindow *parent) MyStatusBar::~MyStatusBar() { +#if wxUSE_TIMER if ( m_timer.IsRunning() ) { m_timer.Stop(); } +#endif } wxBitmap MyStatusBar::CreateBitmapForButton(bool on) @@ -640,13 +657,17 @@ wxBitmap MyStatusBar::CreateBitmapForButton(bool on) void MyStatusBar::OnSize(wxSizeEvent& event) { +#if wxUSE_CHECKBOX if ( !m_checkbox ) return; +#endif wxRect rect; GetFieldRect(Field_Checkbox, rect); +#if wxUSE_CHECKBOX m_checkbox->SetSize(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4); +#endif GetFieldRect(Field_Bitmap, rect); wxSize size = m_statbmp->GetSize(); @@ -659,7 +680,9 @@ void MyStatusBar::OnSize(wxSizeEvent& event) void MyStatusBar::OnButton(wxCommandEvent& WXUNUSED(event)) { +#if wxUSE_CHECKBOX m_checkbox->SetValue(!m_checkbox->GetValue()); +#endif DoToggle(); } @@ -671,9 +694,12 @@ void MyStatusBar::OnToggleClock(wxCommandEvent& WXUNUSED(event)) void MyStatusBar::DoToggle() { +#if wxUSE_CHECKBOX if ( m_checkbox->GetValue() ) { +#if wxUSE_TIMER m_timer.Start(1000); +#endif #ifdef USE_STATIC_BITMAP m_statbmp->SetIcon(wxIcon(green_xpm)); @@ -686,7 +712,9 @@ void MyStatusBar::DoToggle() } else // don't show clock { +#if wxUSE_TIMER m_timer.Stop(); +#endif #ifdef USE_STATIC_BITMAP m_statbmp->SetIcon(wxIcon(red_xpm)); @@ -697,6 +725,7 @@ void MyStatusBar::DoToggle() SetStatusText(wxEmptyString, Field_Clock); } +#endif } void MyStatusBar::UpdateClock()