wxGTK::wxSpinCtrl API synchronised with wxMSW
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@4243 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -16,7 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxSpinButton
|
// wxSpinCtrl
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxSpinCtrl : public wxControl
|
class wxSpinCtrl : public wxControl
|
||||||
@@ -25,29 +25,34 @@ public:
|
|||||||
wxSpinCtrl() {}
|
wxSpinCtrl() {}
|
||||||
wxSpinCtrl(wxWindow *parent,
|
wxSpinCtrl(wxWindow *parent,
|
||||||
wxWindowID id = -1,
|
wxWindowID id = -1,
|
||||||
|
const wxString& value = wxEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxSP_ARROW_KEYS,
|
long style = wxSP_ARROW_KEYS,
|
||||||
int min = 0, int max = 100, int initial = 0,
|
int min = 0, int max = 100, int initial = 0,
|
||||||
const wxString& name = _T("wxSpinCtrl"))
|
const wxString& name = _T("wxSpinCtrl"))
|
||||||
{
|
{
|
||||||
Create(parent, id, pos, size, style, min, max, initial, name);
|
Create(parent, id, value, pos, size, style, min, max, initial, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id = -1,
|
wxWindowID id = -1,
|
||||||
|
const wxString& value = wxEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxSP_ARROW_KEYS,
|
long style = wxSP_ARROW_KEYS,
|
||||||
int min = 0, int max = 100, int initial = 0,
|
int min = 0, int max = 100, int initial = 0,
|
||||||
const wxString& name = _T("wxSpinCtrl"));
|
const wxString& name = _T("wxSpinCtrl"));
|
||||||
|
|
||||||
|
void SetValue(const wxString& text);
|
||||||
|
|
||||||
virtual int GetValue() const;
|
virtual int GetValue() const;
|
||||||
virtual void SetValue( int value );
|
virtual void SetValue( int value );
|
||||||
virtual void SetRange( int minVal, int maxVal );
|
virtual void SetRange( int minVal, int maxVal );
|
||||||
virtual int GetMin() const;
|
virtual int GetMin() const;
|
||||||
virtual int GetMax() const;
|
virtual int GetMax() const;
|
||||||
|
|
||||||
|
// implementation
|
||||||
bool IsOwnGtkWindow( GdkWindow *window );
|
bool IsOwnGtkWindow( GdkWindow *window );
|
||||||
void ApplyWidgetStyle();
|
void ApplyWidgetStyle();
|
||||||
|
|
||||||
|
@@ -16,7 +16,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// wxSpinButton
|
// wxSpinCtrl
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxSpinCtrl : public wxControl
|
class wxSpinCtrl : public wxControl
|
||||||
@@ -25,29 +25,34 @@ public:
|
|||||||
wxSpinCtrl() {}
|
wxSpinCtrl() {}
|
||||||
wxSpinCtrl(wxWindow *parent,
|
wxSpinCtrl(wxWindow *parent,
|
||||||
wxWindowID id = -1,
|
wxWindowID id = -1,
|
||||||
|
const wxString& value = wxEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxSP_ARROW_KEYS,
|
long style = wxSP_ARROW_KEYS,
|
||||||
int min = 0, int max = 100, int initial = 0,
|
int min = 0, int max = 100, int initial = 0,
|
||||||
const wxString& name = _T("wxSpinCtrl"))
|
const wxString& name = _T("wxSpinCtrl"))
|
||||||
{
|
{
|
||||||
Create(parent, id, pos, size, style, min, max, initial, name);
|
Create(parent, id, value, pos, size, style, min, max, initial, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(wxWindow *parent,
|
bool Create(wxWindow *parent,
|
||||||
wxWindowID id = -1,
|
wxWindowID id = -1,
|
||||||
|
const wxString& value = wxEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize,
|
const wxSize& size = wxDefaultSize,
|
||||||
long style = wxSP_ARROW_KEYS,
|
long style = wxSP_ARROW_KEYS,
|
||||||
int min = 0, int max = 100, int initial = 0,
|
int min = 0, int max = 100, int initial = 0,
|
||||||
const wxString& name = _T("wxSpinCtrl"));
|
const wxString& name = _T("wxSpinCtrl"));
|
||||||
|
|
||||||
|
void SetValue(const wxString& text);
|
||||||
|
|
||||||
virtual int GetValue() const;
|
virtual int GetValue() const;
|
||||||
virtual void SetValue( int value );
|
virtual void SetValue( int value );
|
||||||
virtual void SetRange( int minVal, int maxVal );
|
virtual void SetRange( int minVal, int maxVal );
|
||||||
virtual int GetMin() const;
|
virtual int GetMin() const;
|
||||||
virtual int GetMax() const;
|
virtual int GetMax() const;
|
||||||
|
|
||||||
|
// implementation
|
||||||
bool IsOwnGtkWindow( GdkWindow *window );
|
bool IsOwnGtkWindow( GdkWindow *window );
|
||||||
void ApplyWidgetStyle();
|
void ApplyWidgetStyle();
|
||||||
|
|
||||||
|
@@ -86,10 +86,11 @@ static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl,wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl,wxControl)
|
||||||
|
|
||||||
bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxPoint& pos, const wxSize& size,
|
const wxString& value,
|
||||||
long style,
|
const wxPoint& pos, const wxSize& size,
|
||||||
int min, int max, int initial,
|
long style,
|
||||||
const wxString& name)
|
int min, int max, int initial,
|
||||||
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_needParent = TRUE;
|
m_needParent = TRUE;
|
||||||
|
|
||||||
@@ -123,6 +124,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||||
|
|
||||||
|
SetValue( value );
|
||||||
|
|
||||||
Show( TRUE );
|
Show( TRUE );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -149,6 +152,23 @@ int wxSpinCtrl::GetValue() const
|
|||||||
return (int)ceil(m_adjust->value);
|
return (int)ceil(m_adjust->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSpinCtrl::SetValue( const wxString& value )
|
||||||
|
{
|
||||||
|
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||||
|
|
||||||
|
int n;
|
||||||
|
if ( (wxSscanf(value, wxT("%d"), &n) == 1) )
|
||||||
|
{
|
||||||
|
// a number - set it
|
||||||
|
SetValue(n);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// invalid number - set text as is (wxMSW compatible)
|
||||||
|
gtk_entry_set_text( GTK_ENTRY(m_widget), value.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxSpinCtrl::SetValue( int value )
|
void wxSpinCtrl::SetValue( int value )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||||
|
@@ -86,10 +86,11 @@ static void gtk_spinctrl_callback( GtkWidget *WXUNUSED(widget), wxSpinCtrl *win
|
|||||||
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl,wxControl)
|
IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl,wxControl)
|
||||||
|
|
||||||
bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
||||||
const wxPoint& pos, const wxSize& size,
|
const wxString& value,
|
||||||
long style,
|
const wxPoint& pos, const wxSize& size,
|
||||||
int min, int max, int initial,
|
long style,
|
||||||
const wxString& name)
|
int min, int max, int initial,
|
||||||
|
const wxString& name)
|
||||||
{
|
{
|
||||||
m_needParent = TRUE;
|
m_needParent = TRUE;
|
||||||
|
|
||||||
@@ -123,6 +124,8 @@ bool wxSpinCtrl::Create(wxWindow *parent, wxWindowID id,
|
|||||||
|
|
||||||
SetBackgroundColour( parent->GetBackgroundColour() );
|
SetBackgroundColour( parent->GetBackgroundColour() );
|
||||||
|
|
||||||
|
SetValue( value );
|
||||||
|
|
||||||
Show( TRUE );
|
Show( TRUE );
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@@ -149,6 +152,23 @@ int wxSpinCtrl::GetValue() const
|
|||||||
return (int)ceil(m_adjust->value);
|
return (int)ceil(m_adjust->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxSpinCtrl::SetValue( const wxString& value )
|
||||||
|
{
|
||||||
|
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||||
|
|
||||||
|
int n;
|
||||||
|
if ( (wxSscanf(value, wxT("%d"), &n) == 1) )
|
||||||
|
{
|
||||||
|
// a number - set it
|
||||||
|
SetValue(n);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// invalid number - set text as is (wxMSW compatible)
|
||||||
|
gtk_entry_set_text( GTK_ENTRY(m_widget), value.c_str() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxSpinCtrl::SetValue( int value )
|
void wxSpinCtrl::SetValue( int value )
|
||||||
{
|
{
|
||||||
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
wxCHECK_RET( (m_widget != NULL), wxT("invalid spin button") );
|
||||||
|
Reference in New Issue
Block a user