X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5b884f4c74dc5257afcac0c14d2b6ca712ed807a..344ff08345eba81fcdcc55dd711ce6bc4bb747a3:/src/mac/carbon/spinctrl.cpp diff --git a/src/mac/carbon/spinctrl.cpp b/src/mac/carbon/spinctrl.cpp index 5db84619e4..908ad7a0b5 100644 --- a/src/mac/carbon/spinctrl.cpp +++ b/src/mac/carbon/spinctrl.cpp @@ -8,18 +8,14 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) -#pragma implementation "spinctrl.h" -#endif - -#include "wx/defs.h" +#include "wx/wxprec.h" #if wxUSE_SPINCTRL #include "wx/spinbutt.h" #include "wx/spinctrl.h" #include "wx/textctrl.h" - +#include "wx/containr.h" // ---------------------------------------------------------------------------- // constants @@ -27,7 +23,7 @@ // the focus rect around a text may have 4 pixels in each direction // we handle these problems right now in an extended vis region of a window -static const wxCoord TEXTBORDER = 0 ; +static const wxCoord TEXTBORDER = 4 ; // the margin between the text control and the spin static const wxCoord MARGIN = 8 - TEXTBORDER; @@ -47,6 +43,15 @@ public: SetSizeHints(-1,-1); } + bool ProcessEvent(wxEvent &event) + { + // Hand button down events to wxSpinCtrl. Doesn't work. + if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event )) + return TRUE; + + return wxTextCtrl::ProcessEvent( event ); + } + protected: void OnTextChange(wxCommandEvent& event) { @@ -55,9 +60,19 @@ protected: { m_spin->GetSpinButton()->SetValue(val); + // If we're already processing a text update from m_spin, + // don't send it again, since we could end up recursing + // infinitely. + if (event.GetId() == m_spin->GetId()) + { + event.Skip(); + return; + } + // Send event that the text was manually changed wxCommandEvent event(wxEVT_COMMAND_TEXT_UPDATED, m_spin->GetId()); event.SetEventObject(m_spin); + event.SetString(m_spin->GetText()->GetValue()); event.SetInt(val); m_spin->GetEventHandler()->ProcessEvent(event); @@ -66,15 +81,6 @@ protected: event.Skip(); } - bool ProcessEvent(wxEvent &event) - { - // Hand button down events to wxSpinCtrl. Doesn't work. - if (event.GetEventType() == wxEVT_LEFT_DOWN && m_spin->ProcessEvent( event )) - return TRUE; - - return wxTextCtrl::ProcessEvent( event ); - } - private: wxSpinCtrl *m_spin; @@ -132,6 +138,13 @@ 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) + + // ============================================================================ // implementation // ============================================================================ @@ -144,6 +157,7 @@ void wxSpinCtrl::Init() { m_text = NULL; m_btn = NULL; + m_container.SetContainerWindow(this); } bool wxSpinCtrl::Create(wxWindow *parent, @@ -194,7 +208,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, //SetSize(csize); - MacPostControlCreate(pos, csize); + //MacPostControlCreate(pos, csize); SetInitialBestSize(csize); return TRUE;