// headers
// ----------------------------------------------------------------------------
-#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
- #pragma implementation "spinctlg.h"
-#endif
-
// For compilers that support precompilation, includes "wx.h".
#include "wx/wxprec.h"
{
public:
wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value)
- : wxTextCtrl(spin->GetParent(), -1, value)
+ : wxTextCtrl(spin->GetParent(), wxID_ANY, value)
{
m_spin = spin;
-
+
// remove the default minsize, the spinctrl will have one instead
- SetSizeHints(-1,-1);
+ SetSizeHints(wxDefaultCoord,wxDefaultCoord);
}
protected:
{
// Hand button down events to wxSpinCtrl. Doesn't work.
if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event ))
- return TRUE;
+ return true;
return wxTextCtrl::ProcessEvent( event );
}
};
BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl)
- EVT_TEXT(-1, wxSpinCtrlText::OnTextChange)
+ EVT_TEXT(wxID_ANY, wxSpinCtrlText::OnTextChange)
END_EVENT_TABLE()
// ----------------------------------------------------------------------------
SetWindowStyle(style | wxSP_VERTICAL);
// remove the default minsize, the spinctrl will have one instead
- SetSizeHints(-1,-1);
+ SetSizeHints(wxDefaultCoord,wxDefaultCoord);
}
protected:
};
BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton)
- EVT_SPIN(-1, wxSpinCtrlButton::OnSpinButton)
+ EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton)
END_EVENT_TABLE()
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl)
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style,
wxDefaultValidator, name) )
{
- return FALSE;
+ return false;
}
// the string value overrides the numeric one (for backwards compatibility
m_text = new wxSpinCtrlText(this, value);
m_btn = new wxSpinCtrlButton(this, style);
-
+
m_btn->SetRange(min, max);
m_btn->SetValue(initial);
- SetBestSize(size);
-
+ SetInitialSize(size);
+ Move(pos);
+
// have to disable this window to avoid interfering it with message
// processing to the text and the button... but pretend it is enabled to
- // make IsEnabled() return TRUE
- wxControl::Enable(FALSE); // don't use non virtual Disable() here!
- m_isEnabled = TRUE;
+ // make IsEnabled() return true
+ wxControl::Enable(false); // don't use non virtual Disable() here!
+ m_isEnabled = true;
// we don't even need to show this window itself - and not doing it avoids
// that it overwrites the text control
- wxControl::Show(FALSE);
- m_isShown = TRUE;
- return TRUE;
+ wxControl::Show(false);
+ m_isShown = true;
+ return true;
}
wxSpinCtrl::~wxSpinCtrl()
wxCoord wText = width - sizeBtn.x;
m_text->SetSize(x, y, wText, height);
- m_btn->SetSize(x + wText + MARGIN, y, -1, height);
+ m_btn->SetSize(x + wText + MARGIN, y, wxDefaultCoord, height);
}
// ----------------------------------------------------------------------------
bool wxSpinCtrl::Enable(bool enable)
{
if ( !wxControl::Enable(enable) )
- return FALSE;
+ return false;
m_btn->Enable(enable);
m_text->Enable(enable);
- return TRUE;
+ return true;
}
bool wxSpinCtrl::Show(bool show)
{
if ( !wxControl::Show(show) )
- return FALSE;
+ return false;
// under GTK Show() is called the first time before we are fully
// constructed
m_text->Show(show);
}
- return TRUE;
+ return true;
+}
+
+bool wxSpinCtrl::Reparent(wxWindow *newParent)
+{
+ if ( m_btn )
+ {
+ m_btn->Reparent(newParent);
+ m_text->Reparent(newParent);
+ }
+
+ return true;
}
// ----------------------------------------------------------------------------
if ( !m_text->GetValue().ToLong(&l) )
{
// not a number at all
- return FALSE;
+ return false;
}
if ( l < GetMin() || l > GetMax() )
{
// out of range
- return FALSE;
+ return false;
}
*val = l;
- return TRUE;
+ return true;
}
int wxSpinCtrl::GetValue() const