From 571d14b2621325840e465e1e55be9f5a362a5dbd Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Mon, 17 May 2004 19:14:38 +0000 Subject: [PATCH] wxMac should use /src/mac/carbon/spinctrl.cpp, applied some sizing layout fixes to that file, removed wxMac specific parts from the generic wxSpinCtrl. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27319 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- Makefile.in | 16 ++++++++++++++++ build/bakefiles/files.bkl | 1 + include/wx/spinctrl.h | 2 +- src/generic/spinctlg.cpp | 20 ++++---------------- src/mac/carbon/spinctrl.cpp | 33 +++++++++++++++++---------------- 5 files changed, 39 insertions(+), 33 deletions(-) diff --git a/Makefile.in b/Makefile.in index 7f49b7150c..e975220235 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2738,6 +2738,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS = \ monodll_settings.o \ monodll_slider.o \ monodll_spinbutt.o \ + monodll_spinctrl.o \ monodll_statbmp.o \ monodll_statbox.o \ monodll_statbrma.o \ @@ -3593,6 +3594,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_1 = \ monolib_settings.o \ monolib_slider.o \ monolib_spinbutt.o \ + monolib_spinctrl.o \ monolib_statbmp.o \ monolib_statbox.o \ monolib_statbrma.o \ @@ -4620,6 +4622,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_2 = \ coredll_settings.o \ coredll_slider.o \ coredll_spinbutt.o \ + coredll_spinctrl.o \ coredll_statbmp.o \ coredll_statbox.o \ coredll_statbrma.o \ @@ -5344,6 +5347,7 @@ COND_TOOLKIT_MAC___GUI_SRC_OBJECTS_3 = \ corelib_settings.o \ corelib_slider.o \ corelib_spinbutt.o \ + corelib_spinctrl.o \ corelib_statbmp.o \ corelib_statbox.o \ corelib_statbrma.o \ @@ -10058,6 +10062,9 @@ monodll_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monodll_spinctrl.o: $(srcdir)/src/msw/spinctrl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monodll_spinctrl.o: $(srcdir)/src/mac/carbon/spinctrl.cpp $(MONODLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< + @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monodll_spinctrl.o: $(srcdir)/src/os2/spinctrl.cpp $(MONODLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $< @@ -12983,6 +12990,9 @@ monolib_sound_sdl.o: $(srcdir)/src/unix/sound_sdl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@monolib_spinctrl.o: $(srcdir)/src/msw/spinctrl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@monolib_spinctrl.o: $(srcdir)/src/mac/carbon/spinctrl.cpp $(MONOLIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< + @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@monolib_spinctrl.o: $(srcdir)/src/os2/spinctrl.cpp $(MONOLIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $< @@ -16178,6 +16188,9 @@ coredll_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@coredll_spinctrl.o: $(srcdir)/src/msw/spinctrl.cpp $(COREDLL_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@coredll_spinctrl.o: $(srcdir)/src/mac/carbon/spinctrl.cpp $(COREDLL_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< + @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@coredll_spinctrl.o: $(srcdir)/src/os2/spinctrl.cpp $(COREDLL_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(COREDLL_CXXFLAGS) $< @@ -18596,6 +18609,9 @@ corelib_win32.o: $(srcdir)/src/univ/themes/win32.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@corelib_spinctrl.o: $(srcdir)/src/msw/spinctrl.cpp $(CORELIB_ODEP) @COND_TOOLKIT_WINCE_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@corelib_spinctrl.o: $(srcdir)/src/mac/carbon/spinctrl.cpp $(CORELIB_ODEP) +@COND_TOOLKIT_MAC_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< + @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@corelib_spinctrl.o: $(srcdir)/src/os2/spinctrl.cpp $(CORELIB_ODEP) @COND_TOOLKIT_PM_USE_GUI_1_WXUNIV_0@ $(CXXC) -c -o $@ $(CORELIB_CXXFLAGS) $< diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index f984c448b4..c793b3f1d5 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -1624,6 +1624,7 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! src/mac/carbon/settings.cpp src/mac/carbon/slider.cpp src/mac/carbon/spinbutt.cpp + src/mac/carbon/spinctrl.cpp src/mac/carbon/statbmp.cpp src/mac/carbon/statbox.cpp src/mac/carbon/statbrma.cpp diff --git a/include/wx/spinctrl.h b/include/wx/spinctrl.h index 38ff4a0c59..ce1b7f3553 100644 --- a/include/wx/spinctrl.h +++ b/include/wx/spinctrl.h @@ -64,7 +64,7 @@ protected: #elif defined(__WXMOTIF__) #include "wx/generic/spinctlg.h" #elif defined(__WXMAC__) - #include "wx/generic/spinctlg.h" + #include "wx/mac/spinctrl.h" #elif defined(__WXCOCOA__) #include "wx/generic/spinctlg.h" #endif // platform diff --git a/src/generic/spinctlg.cpp b/src/generic/spinctlg.cpp index ff33ce7494..d090d17ad3 100644 --- a/src/generic/spinctlg.cpp +++ b/src/generic/spinctlg.cpp @@ -28,8 +28,10 @@ #pragma hdrstop #endif -#if !(defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXPM__)) || \ - defined(__WXMAC__) || defined(__WXUNIVERSAL__) +// There are port-specific versions for MSW, GTK, OS/2 and Mac, so exclude the +// contents of this file in those cases +#if !(defined(__WXMSW__) || defined(__WXGTK__) || defined(__WXPM__) || \ + defined(__WXMAC__)) || defined(__WXUNIVERSAL__) #ifndef WX_PRECOMP #include "wx/textctrl.h" @@ -45,11 +47,7 @@ // ---------------------------------------------------------------------------- // the margin between the text control and the spin -#ifdef __WXMAC__ -static const wxCoord MARGIN = 4; -#else static const wxCoord MARGIN = 2; -#endif // ---------------------------------------------------------------------------- // wxSpinCtrlText: text control used by spin control @@ -189,15 +187,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, m_btn->SetRange(min, max); m_btn->SetValue(initial); -#ifdef __WXMAC__ - wxSize csize = size ; - if ( size.y == -1 ) { - csize.y = m_text->GetSize().y; - } - SetBestSize(csize); -#else SetBestSize(size); -#endif // have to disable this window to avoid interfering it with message // processing to the text and the button... but pretend it is enabled to @@ -208,9 +198,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, // we don't even need to show this window itself - and not doing it avoids // that it overwrites the text control wxControl::Show(FALSE); -#ifndef __WXMAC__ m_isShown = TRUE; -#endif return TRUE; } diff --git a/src/mac/carbon/spinctrl.cpp b/src/mac/carbon/spinctrl.cpp index 22553d47f1..b0bb8c8441 100644 --- a/src/mac/carbon/spinctrl.cpp +++ b/src/mac/carbon/spinctrl.cpp @@ -8,24 +8,19 @@ // Licence: wxWindows licence ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ -#pragma implementation "spinctlg.h" +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) +#pragma implementation "spinctrl.h" #endif #include "wx/defs.h" -#ifndef WX_PRECOMP - #include "wx/textctrl.h" -#endif //WX_PRECOMP - #if wxUSE_SPINCTRL #include "wx/spinbutt.h" #include "wx/spinctrl.h" +#include "wx/textctrl.h" -#include "wx/spinctrl.h" - // ---------------------------------------------------------------------------- // constants // ---------------------------------------------------------------------------- @@ -44,6 +39,9 @@ public: : wxTextCtrl(spin , -1, value) { m_spin = spin; + + // remove the default minsize, the spinctrl will have one instead + SetSizeHints(-1,-1); } protected: @@ -88,14 +86,21 @@ public: : wxSpinButton(spin ) { m_spin = spin; - SetWindowStyle(style | wxSP_VERTICAL); + + // TODO: The spin button gets truncated a little bit due to size + // differences so change it's default size a bit. SMALL still gets a + // bit truncated, but MINI seems to be too small... Readdress this + // when the textctrl issues are all sorted out. + SetWindowVariant(wxWINDOW_VARIANT_SMALL); + + // remove the default minsize, the spinctrl will have one instead + SetSizeHints(-1,-1); } protected: void OnSpinButton(wxSpinEvent& eventSpin) { -#if defined(__WXMAC__) || defined(__WXMOTIF__) m_spin->SetTextValue(eventSpin.GetPosition()); wxCommandEvent event(wxEVT_COMMAND_SPINCTRL_UPDATED, m_spin->GetId()); @@ -103,10 +108,6 @@ protected: event.SetInt(eventSpin.GetPosition()); m_spin->GetEventHandler()->ProcessEvent(event); -#else - m_spin->SetTextValue(eventSpin.GetPosition()); - eventSpin.Skip(); -#endif } private: @@ -173,7 +174,7 @@ bool wxSpinCtrl::Create(wxWindow *parent, if ( size.y == -1 ) { csize.y = m_text->GetSize().y ; } - DoSetSize(pos.x , pos.y , csize.x, csize.y); + SetBestSize(csize); return TRUE; } @@ -210,7 +211,7 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height) wxCoord wText = width - sizeBtn.x; m_text->SetSize(0, 0, wText, height); - m_btn->SetSize(0 + wText + MARGIN, 0, -1, -1); + m_btn->SetSize(0 + wText + MARGIN, 0, -1, height); } // ---------------------------------------------------------------------------- -- 2.45.2