// sanity check
wxASSERT_MSG( spin->m_hwndBuddy == hwndBuddy,
- _T("wxSpinCtrl has incorrect buddy HWND!") );
+ wxT("wxSpinCtrl has incorrect buddy HWND!") );
return spin;
}
else if ( style & wxALIGN_CENTER )
msStyle |= ES_CENTER;
- // this control is used for numeric entry so normally using these flags by
- // default shouldn't be a problem, if it is we can always add a style such
- // as wxSP_NON_NUMERIC later
- msStyle |= ES_NUMBER;
-
// calculate the sizes: the size given is the total size for both controls
// and we need to fit them both in the given width (height is the same)
wxSize sizeText(size), sizeBtn(size);
sizeText.x -= sizeBtn.x + MARGIN_BETWEEN;
if ( sizeText.x <= 0 )
{
- wxLogDebug(_T("not enough space for wxSpinCtrl!"));
+ wxLogDebug(wxT("not enough space for wxSpinCtrl!"));
}
wxPoint posBtn(pos);
m_hwndBuddy = (WXHWND)::CreateWindowEx
(
exStyle, // sunken border
- _T("EDIT"), // window class
+ wxT("EDIT"), // window class
NULL, // no window title
msStyle, // style (will be shown later)
pos.x, pos.y, // position
// to leave it like this, while we really want to always show the
// current value in the control, so do it manually
::SetWindowText(GetBuddyHwnd(),
- wxString::Format(_T("%d"), val).wx_str());
+ wxString::Format(wxT("%d"), val).wx_str());
}
m_oldValue = GetValue();
::SendMessage(GetBuddyHwnd(), EM_SETSEL, (WPARAM)from, (LPARAM)to);
}
+// ----------------------------------------------------------------------------
+// wxSpinButton methods
+// ----------------------------------------------------------------------------
+
+void wxSpinCtrl::SetRange(int minVal, int maxVal)
+{
+ wxSpinButton::SetRange(minVal, maxVal);
+
+ // this control is used for numeric entry so restrict the input to numeric
+ // keys only -- but only if we don't need to be able to enter "-" in it as
+ // otherwise this would become impossible
+ const DWORD styleOld = ::GetWindowLong(GetBuddyHwnd(), GWL_STYLE);
+ DWORD styleNew;
+ if ( minVal < 0 )
+ styleNew = styleOld & ~ES_NUMBER;
+ else
+ styleNew = styleOld | ES_NUMBER;
+
+ if ( styleNew != styleOld )
+ ::SetWindowLong(GetBuddyHwnd(), GWL_STYLE, styleNew);
+}
+
// ----------------------------------------------------------------------------
// forward some methods to subcontrols
// ----------------------------------------------------------------------------
int widthText = width - widthBtn - MARGIN_BETWEEN;
if ( widthText <= 0 )
{
- wxLogDebug(_T("not enough space for wxSpinCtrl!"));
+ wxLogDebug(wxT("not enough space for wxSpinCtrl!"));
}
// 1) The buddy window