X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c016394bc2c558f2e59bbb2b99ecc4df87730bd9..8a31648287be0ef976f133de2786b137f1e98340:/src/osx/spinctrl_osx.cpp diff --git a/src/osx/spinctrl_osx.cpp b/src/osx/spinctrl_osx.cpp index 841b946616..cace5fd4e6 100644 --- a/src/osx/spinctrl_osx.cpp +++ b/src/osx/spinctrl_osx.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/osx/carbon/spinbutt.cpp +// Name: src/osx/spinctrl_osx.cpp // Purpose: wxSpinCtrl // Author: Robert // Modified by: Mark Newsam (Based on GTK file) @@ -41,8 +41,8 @@ static const wxCoord MARGIN = 3; class wxSpinCtrlText : public wxTextCtrl { public: - wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value) - : wxTextCtrl(spin , wxID_ANY, value, wxDefaultPosition, wxSize(40, wxDefaultCoord)) + wxSpinCtrlText(wxSpinCtrl *spin, const wxString& value, int style) + : wxTextCtrl(spin , wxID_ANY, value, wxDefaultPosition, wxSize(40, wxDefaultCoord), style ) { m_spin = spin; @@ -60,6 +60,13 @@ public: } protected: + void OnSetFocus(wxFocusEvent& event) + { + // delegate to parent control + event.SetEventObject( GetParent() ); + GetParent()->HandleWindowEvent(event); + } + void OnKillFocus(wxFocusEvent& event) { long l; @@ -95,7 +102,8 @@ protected: m_spin->m_oldValue = l; } - + + // delegate to parent control event.SetEventObject( GetParent() ); GetParent()->HandleWindowEvent(event); } @@ -136,7 +144,8 @@ private: BEGIN_EVENT_TABLE(wxSpinCtrlText, wxTextCtrl) EVT_TEXT(wxID_ANY, wxSpinCtrlText::OnTextChange) - EVT_KILL_FOCUS( wxSpinCtrlText::OnKillFocus) + EVT_SET_FOCUS(wxSpinCtrlText::OnSetFocus) + EVT_KILL_FOCUS(wxSpinCtrlText::OnKillFocus) END_EVENT_TABLE() // ---------------------------------------------------------------------------- @@ -187,15 +196,6 @@ BEGIN_EVENT_TABLE(wxSpinCtrlButton, wxSpinButton) EVT_SPIN(wxID_ANY, wxSpinCtrlButton::OnSpinButton) END_EVENT_TABLE() -IMPLEMENT_DYNAMIC_CLASS(wxSpinCtrl, wxControl) - -BEGIN_EVENT_TABLE(wxSpinCtrl, wxControl) - WX_EVENT_TABLE_CONTROL_CONTAINER(wxSpinCtrl) -END_EVENT_TABLE() - -WX_DELEGATE_TO_CONTROL_CONTAINER(wxSpinCtrl, wxControl) - - // ============================================================================ // implementation // ============================================================================ @@ -208,7 +208,6 @@ void wxSpinCtrl::Init() { m_text = NULL; m_btn = NULL; - WX_INIT_CONTROL_CONTAINER(); } bool wxSpinCtrl::Create(wxWindow *parent, @@ -222,7 +221,6 @@ bool wxSpinCtrl::Create(wxWindow *parent, int initial, const wxString& name) { - m_macIsUserPane = true; if ( !wxControl::Create(parent, id, pos, size, style, wxDefaultValidator, name) ) { @@ -241,7 +239,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, } wxSize csize = size ; - m_text = new wxSpinCtrlText(this, value); + m_text = new wxSpinCtrlText(this, value, style & ( wxTE_PROCESS_ENTER | wxALIGN_MASK ) ); m_btn = new wxSpinCtrlButton(this, style); m_btn->SetRange(min, max); @@ -272,10 +270,8 @@ wxSpinCtrl::~wxSpinCtrl() // delete the controls now, don't leave them alive even though they would // still be eventually deleted by our parent - but it will be too late, the // user code expects them to be gone now - delete m_text; - m_text = NULL ; - delete m_btn; - m_btn = NULL ; + wxDELETE(m_text); + wxDELETE(m_btn); } // ---------------------------------------------------------------------------- @@ -379,20 +375,22 @@ int wxSpinCtrl::GetMax() const void wxSpinCtrl::SetTextValue(int val) { - wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetTextValue") ); + wxCHECK_RET( m_text, wxT("invalid call to wxSpinCtrl::SetTextValue") ); - m_text->SetValue(wxString::Format(_T("%d"), val)); + m_text->SetValue(wxString::Format(wxT("%d"), val)); // select all text m_text->SetSelection(0, -1); + m_text->SetInsertionPointEnd(); + // and give focus to the control! // m_text->SetFocus(); Why???? TODO. } void wxSpinCtrl::SetValue(int val) { - wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetValue") ); + wxCHECK_RET( m_btn, wxT("invalid call to wxSpinCtrl::SetValue") ); SetTextValue(val); @@ -402,7 +400,7 @@ void wxSpinCtrl::SetValue(int val) void wxSpinCtrl::SetValue(const wxString& text) { - wxCHECK_RET( m_text, _T("invalid call to wxSpinCtrl::SetValue") ); + wxCHECK_RET( m_text, wxT("invalid call to wxSpinCtrl::SetValue") ); long val; if ( text.ToLong(&val) && ((val > INT_MIN) && (val < INT_MAX)) ) @@ -418,7 +416,7 @@ void wxSpinCtrl::SetValue(const wxString& text) void wxSpinCtrl::SetRange(int min, int max) { - wxCHECK_RET( m_btn, _T("invalid call to wxSpinCtrl::SetRange") ); + wxCHECK_RET( m_btn, wxT("invalid call to wxSpinCtrl::SetRange") ); m_btn->SetRange(min, max); }