break;
case WM_GETDLGCODE:
- // we want to get WXK_RETURN in order to generate the event for it
- return DLGC_WANTALLKEYS;
+ if ( spin->HasFlag(wxTE_PROCESS_ENTER) )
+ {
+ long dlgCode = ::CallWindowProc
+ (
+ CASTWNDPROC spin->GetBuddyWndProc(),
+ hwnd,
+ message,
+ wParam,
+ lParam
+ );
+ dlgCode |= DLGC_WANTMESSAGE;
+ return dlgCode;
+ }
+ break;
}
return ::CallWindowProc(CASTWNDPROC spin->GetBuddyWndProc(),
// sanity check
wxASSERT_MSG( spin->m_hwndBuddy == hwndBuddy,
- _T("wxSpinCtrl has incorrect buddy HWND!") );
+ wxT("wxSpinCtrl has incorrect buddy HWND!") );
return spin;
}
WXDWORD exStyle = 0;
WXDWORD msStyle = MSWGetStyle(GetWindowStyle(), & exStyle) ;
- // 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_RIGHT | ES_NUMBER;
+ // propagate text alignment style to text ctrl
+ if ( style & wxALIGN_RIGHT )
+ msStyle |= ES_RIGHT;
+ else if ( style & wxALIGN_CENTER )
+ msStyle |= ES_CENTER;
// 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)
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
void wxSpinCtrl::SetValue(int val)
{
m_blockEvent = true;
-
+
wxSpinButton::SetValue(val);
// normally setting the value of the spin button is enough as it updates
// 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();
-
+
m_blockEvent = false;
}
::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
// ----------------------------------------------------------------------------
// destroy the old spin button
UnsubclassWin();
if ( !::DestroyWindow(GetHwnd()) )
+ {
wxLogLastError(wxT("DestroyWindow"));
+ }
// create and initialize the new one
if ( !wxSpinButton::Create(GetParent(), GetId(),
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