Tweaks to the generic scpinctrl to handle layouts on wxMac better and
fixed alignment of the spinbutton. Also, since the generic spinctrl is used then the generic header should be included. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27301 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -64,7 +64,7 @@ protected:
|
|||||||
#elif defined(__WXMOTIF__)
|
#elif defined(__WXMOTIF__)
|
||||||
#include "wx/generic/spinctlg.h"
|
#include "wx/generic/spinctlg.h"
|
||||||
#elif defined(__WXMAC__)
|
#elif defined(__WXMAC__)
|
||||||
#include "wx/mac/spinctrl.h"
|
#include "wx/generic/spinctlg.h"
|
||||||
#elif defined(__WXCOCOA__)
|
#elif defined(__WXCOCOA__)
|
||||||
#include "wx/generic/spinctlg.h"
|
#include "wx/generic/spinctlg.h"
|
||||||
#endif // platform
|
#endif // platform
|
||||||
|
@@ -45,7 +45,11 @@
|
|||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
// the margin between the text control and the spin
|
// the margin between the text control and the spin
|
||||||
|
#ifdef __WXMAC__
|
||||||
|
static const wxCoord MARGIN = 4;
|
||||||
|
#else
|
||||||
static const wxCoord MARGIN = 2;
|
static const wxCoord MARGIN = 2;
|
||||||
|
#endif
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxSpinCtrlText: text control used by spin control
|
// wxSpinCtrlText: text control used by spin control
|
||||||
@@ -58,6 +62,9 @@ public:
|
|||||||
: wxTextCtrl(spin->GetParent(), -1, value)
|
: wxTextCtrl(spin->GetParent(), -1, value)
|
||||||
{
|
{
|
||||||
m_spin = spin;
|
m_spin = spin;
|
||||||
|
|
||||||
|
// remove the default minsize, the spinctrl will have one instead
|
||||||
|
SetSizeHints(-1,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -104,6 +111,9 @@ public:
|
|||||||
m_spin = spin;
|
m_spin = spin;
|
||||||
|
|
||||||
SetWindowStyle(style | wxSP_VERTICAL);
|
SetWindowStyle(style | wxSP_VERTICAL);
|
||||||
|
|
||||||
|
// remove the default minsize, the spinctrl will have one instead
|
||||||
|
SetSizeHints(-1,-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -174,7 +184,6 @@ bool wxSpinCtrl::Create(wxWindow *parent,
|
|||||||
initial = l;
|
initial = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetBackgroundColour(*wxRED);
|
|
||||||
m_text = new wxSpinCtrlText(this, value);
|
m_text = new wxSpinCtrlText(this, value);
|
||||||
m_btn = new wxSpinCtrlButton(this, style);
|
m_btn = new wxSpinCtrlButton(this, style);
|
||||||
|
|
||||||
@@ -183,15 +192,13 @@ bool wxSpinCtrl::Create(wxWindow *parent,
|
|||||||
#ifdef __WXMAC__
|
#ifdef __WXMAC__
|
||||||
wxSize csize = size ;
|
wxSize csize = size ;
|
||||||
if ( size.y == -1 ) {
|
if ( size.y == -1 ) {
|
||||||
csize.y = m_text->GetSize().y ;
|
csize.y = m_text->GetSize().y;
|
||||||
}
|
}
|
||||||
DoSetSize(pos.x, pos.y, csize.x, csize.y);
|
SetBestSize(csize);
|
||||||
#else
|
#else
|
||||||
wxSize best = GetBestSize();
|
SetBestSize(size);
|
||||||
if ( size.x != -1 ) best.x = size.x;
|
|
||||||
if ( size.y != -1 ) best.y = size.y;
|
|
||||||
DoSetSize(pos.x, pos.y, best.x, best.y);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// have to disable this window to avoid interfering it with message
|
// have to disable this window to avoid interfering it with message
|
||||||
// processing to the text and the button... but pretend it is enabled to
|
// processing to the text and the button... but pretend it is enabled to
|
||||||
// make IsEnabled() return TRUE
|
// make IsEnabled() return TRUE
|
||||||
@@ -209,11 +216,13 @@ bool wxSpinCtrl::Create(wxWindow *parent,
|
|||||||
|
|
||||||
wxSpinCtrl::~wxSpinCtrl()
|
wxSpinCtrl::~wxSpinCtrl()
|
||||||
{
|
{
|
||||||
// delete the controls now, don't leave them alive even though they woudl
|
// 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
|
// still be eventually deleted by our parent - but it will be too late, the
|
||||||
// user code expects them to be gone now
|
// user code expects them to be gone now
|
||||||
delete m_text;
|
delete m_text;
|
||||||
|
m_text = NULL ;
|
||||||
delete m_btn;
|
delete m_btn;
|
||||||
|
m_btn = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -237,11 +246,7 @@ void wxSpinCtrl::DoMoveWindow(int x, int y, int width, int height)
|
|||||||
|
|
||||||
wxCoord wText = width - sizeBtn.x;
|
wxCoord wText = width - sizeBtn.x;
|
||||||
m_text->SetSize(x, y, wText, height);
|
m_text->SetSize(x, y, wText, height);
|
||||||
#ifdef __WXMAC__
|
|
||||||
m_btn->SetSize(x + wText + MARGIN, y, -1, -1);
|
|
||||||
#else
|
|
||||||
m_btn->SetSize(x + wText + MARGIN, y, -1, height);
|
m_btn->SetSize(x + wText + MARGIN, y, -1, height);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user