Fix for building with limited ports/platforms.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@29738 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-10-08 19:51:30 +00:00
parent 0148745bb7
commit a6ebd5596e

View File

@@ -96,7 +96,9 @@ public:
void UpdateClock(); void UpdateClock();
// event handlers // event handlers
#if wxUSE_TIMER
void OnTimer(wxTimerEvent& WXUNUSED(event)) { UpdateClock(); } void OnTimer(wxTimerEvent& WXUNUSED(event)) { UpdateClock(); }
#endif
void OnSize(wxSizeEvent& event); void OnSize(wxSizeEvent& event);
void OnToggleClock(wxCommandEvent& event); void OnToggleClock(wxCommandEvent& event);
void OnButton(wxCommandEvent& event); void OnButton(wxCommandEvent& event);
@@ -116,9 +118,13 @@ private:
Field_Max Field_Max
}; };
#if wxUSE_TIMER
wxTimer m_timer; wxTimer m_timer;
#endif
#if wxUSE_CHECKBOX
wxCheckBox *m_checkbox; wxCheckBox *m_checkbox;
#endif
#ifdef USE_STATIC_BITMAP #ifdef USE_STATIC_BITMAP
wxStaticBitmap *m_statbmp; wxStaticBitmap *m_statbmp;
#else #else
@@ -234,9 +240,13 @@ END_EVENT_TABLE()
BEGIN_EVENT_TABLE(MyStatusBar, wxStatusBar) BEGIN_EVENT_TABLE(MyStatusBar, wxStatusBar)
EVT_SIZE(MyStatusBar::OnSize) EVT_SIZE(MyStatusBar::OnSize)
#if wxUSE_CHECKBOX
EVT_CHECKBOX(StatusBar_Checkbox, MyStatusBar::OnToggleClock) EVT_CHECKBOX(StatusBar_Checkbox, MyStatusBar::OnToggleClock)
#endif
EVT_BUTTON(wxID_ANY, MyStatusBar::OnButton) EVT_BUTTON(wxID_ANY, MyStatusBar::OnButton)
#if wxUSE_TIMER
EVT_TIMER(wxID_ANY, MyStatusBar::OnTimer) EVT_TIMER(wxID_ANY, MyStatusBar::OnTimer)
#endif
END_EVENT_TABLE() END_EVENT_TABLE()
// Create a new application object: this macro will allow wxWidgets to create // Create a new application object: this macro will allow wxWidgets to create
@@ -584,15 +594,23 @@ MyAboutDialog::MyAboutDialog(wxWindow *parent)
#endif #endif
MyStatusBar::MyStatusBar(wxWindow *parent) 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 }; static const int widths[Field_Max] = { -1, 150, BITMAP_SIZE_X, 100 };
SetFieldsCount(Field_Max); SetFieldsCount(Field_Max);
SetStatusWidths(Field_Max, widths); SetStatusWidths(Field_Max, widths);
#if wxUSE_CHECKBOX
m_checkbox = new wxCheckBox(this, StatusBar_Checkbox, _T("&Toggle clock")); m_checkbox = new wxCheckBox(this, StatusBar_Checkbox, _T("&Toggle clock"));
m_checkbox->SetValue(true); m_checkbox->SetValue(true);
#endif
#ifdef USE_STATIC_BITMAP #ifdef USE_STATIC_BITMAP
m_statbmp = new wxStaticBitmap(this, wxID_ANY, wxIcon(green_xpm)); m_statbmp = new wxStaticBitmap(this, wxID_ANY, wxIcon(green_xpm));
@@ -602,7 +620,9 @@ MyStatusBar::MyStatusBar(wxWindow *parent)
wxBU_EXACTFIT); wxBU_EXACTFIT);
#endif #endif
#if wxUSE_TIMER
m_timer.Start(1000); m_timer.Start(1000);
#endif
SetMinHeight(BITMAP_SIZE_Y); SetMinHeight(BITMAP_SIZE_Y);
@@ -615,10 +635,12 @@ MyStatusBar::MyStatusBar(wxWindow *parent)
MyStatusBar::~MyStatusBar() MyStatusBar::~MyStatusBar()
{ {
#if wxUSE_TIMER
if ( m_timer.IsRunning() ) if ( m_timer.IsRunning() )
{ {
m_timer.Stop(); m_timer.Stop();
} }
#endif
} }
wxBitmap MyStatusBar::CreateBitmapForButton(bool on) wxBitmap MyStatusBar::CreateBitmapForButton(bool on)
@@ -640,13 +662,17 @@ wxBitmap MyStatusBar::CreateBitmapForButton(bool on)
void MyStatusBar::OnSize(wxSizeEvent& event) void MyStatusBar::OnSize(wxSizeEvent& event)
{ {
#if wxUSE_CHECKBOX
if ( !m_checkbox ) if ( !m_checkbox )
return; return;
#endif
wxRect rect; wxRect rect;
GetFieldRect(Field_Checkbox, rect); GetFieldRect(Field_Checkbox, rect);
#if wxUSE_CHECKBOX
m_checkbox->SetSize(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4); m_checkbox->SetSize(rect.x + 2, rect.y + 2, rect.width - 4, rect.height - 4);
#endif
GetFieldRect(Field_Bitmap, rect); GetFieldRect(Field_Bitmap, rect);
wxSize size = m_statbmp->GetSize(); wxSize size = m_statbmp->GetSize();
@@ -659,7 +685,9 @@ void MyStatusBar::OnSize(wxSizeEvent& event)
void MyStatusBar::OnButton(wxCommandEvent& WXUNUSED(event)) void MyStatusBar::OnButton(wxCommandEvent& WXUNUSED(event))
{ {
#if wxUSE_CHECKBOX
m_checkbox->SetValue(!m_checkbox->GetValue()); m_checkbox->SetValue(!m_checkbox->GetValue());
#endif
DoToggle(); DoToggle();
} }
@@ -671,9 +699,12 @@ void MyStatusBar::OnToggleClock(wxCommandEvent& WXUNUSED(event))
void MyStatusBar::DoToggle() void MyStatusBar::DoToggle()
{ {
#if wxUSE_CHECKBOX
if ( m_checkbox->GetValue() ) if ( m_checkbox->GetValue() )
{ {
#if wxUSE_TIMER
m_timer.Start(1000); m_timer.Start(1000);
#endif
#ifdef USE_STATIC_BITMAP #ifdef USE_STATIC_BITMAP
m_statbmp->SetIcon(wxIcon(green_xpm)); m_statbmp->SetIcon(wxIcon(green_xpm));
@@ -686,7 +717,9 @@ void MyStatusBar::DoToggle()
} }
else // don't show clock else // don't show clock
{ {
#if wxUSE_TIMER
m_timer.Stop(); m_timer.Stop();
#endif
#ifdef USE_STATIC_BITMAP #ifdef USE_STATIC_BITMAP
m_statbmp->SetIcon(wxIcon(red_xpm)); m_statbmp->SetIcon(wxIcon(red_xpm));
@@ -697,6 +730,7 @@ void MyStatusBar::DoToggle()
SetStatusText(wxEmptyString, Field_Clock); SetStatusText(wxEmptyString, Field_Clock);
} }
#endif
} }
void MyStatusBar::UpdateClock() void MyStatusBar::UpdateClock()