Code cleaning.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27341 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Włodzimierz Skiba
2004-05-18 17:17:32 +00:00
parent adb0baf7d4
commit 3fb7939695

View File

@@ -57,12 +57,12 @@ class wxSpinCtrlText : public wxTextCtrl
{ {
public: public:
wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value) wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value)
: wxTextCtrl(spin->GetParent(), -1, value) : wxTextCtrl(spin->GetParent(), wxID_ANY, value)
{ {
m_spin = spin; m_spin = spin;
// remove the default minsize, the spinctrl will have one instead // remove the default minsize, the spinctrl will have one instead
SetSizeHints(-1,-1); SetSizeHints(wxDefaultSize.x,wxDefaultSize.y);
} }
protected: protected:
@@ -81,7 +81,7 @@ protected:
{ {
// Hand button down events to wxSpinCtrl. Doesn't work. // Hand button down events to wxSpinCtrl. Doesn't work.
if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event )) if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event ))
return TRUE; return true;
return wxTextCtrl::ProcessEvent( event ); return wxTextCtrl::ProcessEvent( event );
} }
@@ -93,7 +93,7 @@ private:
}; };
BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl) BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl)
EVT_TEXT(-1, wxSpinCtrlText::OnTextChange) EVT_TEXT(wxID_ANY, wxSpinCtrlText::OnTextChange)
END_EVENT_TABLE() END_EVENT_TABLE()
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -111,7 +111,7 @@ public:
SetWindowStyle(style | wxSP_VERTICAL); SetWindowStyle(style | wxSP_VERTICAL);
// remove the default minsize, the spinctrl will have one instead // remove the default minsize, the spinctrl will have one instead
SetSizeHints(-1,-1); SetSizeHints(wxDefaultSize.x,wxDefaultSize.y);
} }
protected: protected:
@@ -135,7 +135,7 @@ private:
}; };
BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton) BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton)
EVT_SPIN(-1, wxSpinCtrlButton::OnSpinButton) EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton)
END_EVENT_TABLE() END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
@@ -157,7 +157,7 @@ void wxSpinCtrl::Init()
bool wxSpinCtrl::Create(wxWindow *parent, bool wxSpinCtrl::Create(wxWindow *parent,
wxWindowID id, wxWindowID id,
const wxString& value, const wxString& value,
const wxPoint& pos, const wxPoint& WXUNUSED(pos),
const wxSize& size, const wxSize& size,
long style, long style,
int min, int min,
@@ -168,7 +168,7 @@ bool wxSpinCtrl::Create(wxWindow *parent,
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style, if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style,
wxDefaultValidator, name) ) wxDefaultValidator, name) )
{ {
return FALSE; return false;
} }
// the string value overrides the numeric one (for backwards compatibility // the string value overrides the numeric one (for backwards compatibility
@@ -191,15 +191,15 @@ bool wxSpinCtrl::Create(wxWindow *parent,
// have to disable this window to avoid interfering it with message // have to disable this window to avoid interfering it with message
// processing to the text and the button... but pretend it is enabled to // processing to the text and the button... but pretend it is enabled to
// make IsEnabled() return TRUE // make IsEnabled() return true
wxControl::Enable(FALSE); // don't use non virtual Disable() here! wxControl::Enable(false); // don't use non virtual Disable() here!
m_isEnabled = TRUE; m_isEnabled = true;
// we don't even need to show this window itself - and not doing it avoids // we don't even need to show this window itself - and not doing it avoids
// that it overwrites the text control // that it overwrites the text control
wxControl::Show(FALSE); wxControl::Show(false);
m_isShown = TRUE; m_isShown = true;
return TRUE; return true;
} }
wxSpinCtrl::~wxSpinCtrl() wxSpinCtrl::~wxSpinCtrl()
@@ -234,7 +234,7 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
wxCoord wText = width - sizeBtn.x; wxCoord wText = width - sizeBtn.x;
m_text->SetSize(x, y, wText, height); m_text->SetSize(x, y, wText, height);
m_btn->SetSize(x + wText + MARGIN, y, -1, height); m_btn->SetSize(x + wText + MARGIN, y, wxDefaultSize.x, height);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -244,18 +244,18 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
bool wxSpinCtrl::Enable(bool enable) bool wxSpinCtrl::Enable(bool enable)
{ {
if ( !wxControl::Enable(enable) ) if ( !wxControl::Enable(enable) )
return FALSE; return false;
m_btn->Enable(enable); m_btn->Enable(enable);
m_text->Enable(enable); m_text->Enable(enable);
return TRUE; return true;
} }
bool wxSpinCtrl::Show(bool show) bool wxSpinCtrl::Show(bool show)
{ {
if ( !wxControl::Show(show) ) if ( !wxControl::Show(show) )
return FALSE; return false;
// under GTK Show() is called the first time before we are fully // under GTK Show() is called the first time before we are fully
// constructed // constructed
@@ -265,7 +265,7 @@ bool wxSpinCtrl::Show(bool show)
m_text->Show(show); m_text->Show(show);
} }
return TRUE; return true;
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
@@ -278,18 +278,18 @@ bool wxSpinCtrl::GetTextValue(int *val) const
if ( !m_text->GetValue().ToLong(&l) ) if ( !m_text->GetValue().ToLong(&l) )
{ {
// not a number at all // not a number at all
return FALSE; return false;
} }
if ( l < GetMin() || l > GetMax() ) if ( l < GetMin() || l > GetMax() )
{ {
// out of range // out of range
return FALSE; return false;
} }
*val = l; *val = l;
return TRUE; return true;
} }
int wxSpinCtrl::GetValue() const int wxSpinCtrl::GetValue() const