2000-07-15 19:51:35 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2011-03-20 00:14:35 +00:00
|
|
|
// Name: wx/msw/spinctrl.h
|
1999-10-10 23:28:07 +00:00
|
|
|
// Purpose: wxSpinCtrl class declaration for Win32
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 22.07.99
|
|
|
|
// Copyright: (c) Vadim Zeitlin
|
2004-05-23 20:53:33 +00:00
|
|
|
// Licence: wxWindows licence
|
1999-10-10 23:28:07 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_MSW_SPINCTRL_H_
|
|
|
|
#define _WX_MSW_SPINCTRL_H_
|
|
|
|
|
|
|
|
#include "wx/spinbutt.h" // the base class
|
|
|
|
|
2004-11-23 20:08:56 +00:00
|
|
|
#if wxUSE_SPINCTRL
|
|
|
|
|
2000-12-21 02:12:22 +00:00
|
|
|
#include "wx/dynarray.h"
|
2002-02-07 12:24:57 +00:00
|
|
|
|
2007-07-09 10:09:52 +00:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
|
2003-10-08 22:13:14 +00:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins);
|
2000-12-21 02:12:22 +00:00
|
|
|
|
1999-10-10 23:28:07 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Under Win32, wxSpinCtrl is a wxSpinButton with a buddy (as MSDN docs call
|
|
|
|
// it) text window whose contents is automatically updated when the spin
|
|
|
|
// control is clicked.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-03-26 15:06:00 +00:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton
|
1999-10-10 23:28:07 +00:00
|
|
|
{
|
|
|
|
public:
|
2012-03-04 00:29:48 +00:00
|
|
|
wxSpinCtrl() { Init(); }
|
1999-10-10 23:28:07 +00:00
|
|
|
|
|
|
|
wxSpinCtrl(wxWindow *parent,
|
2004-09-04 01:53:42 +00:00
|
|
|
wxWindowID id = wxID_ANY,
|
1999-10-28 01:17:35 +00:00
|
|
|
const wxString& value = wxEmptyString,
|
1999-10-10 23:28:07 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 10:55:55 +00:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
1999-10-10 23:28:07 +00:00
|
|
|
int min = 0, int max = 100, int initial = 0,
|
2009-07-23 20:30:22 +00:00
|
|
|
const wxString& name = wxT("wxSpinCtrl"))
|
1999-10-10 23:28:07 +00:00
|
|
|
{
|
2012-03-04 00:29:48 +00:00
|
|
|
Init();
|
|
|
|
|
1999-10-28 01:17:35 +00:00
|
|
|
Create(parent, id, value, pos, size, style, min, max, initial, name);
|
1999-10-10 23:28:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
2004-09-04 01:53:42 +00:00
|
|
|
wxWindowID id = wxID_ANY,
|
1999-10-28 01:17:35 +00:00
|
|
|
const wxString& value = wxEmptyString,
|
1999-10-10 23:28:07 +00:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 10:55:55 +00:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
1999-10-10 23:28:07 +00:00
|
|
|
int min = 0, int max = 100, int initial = 0,
|
2009-07-23 20:30:22 +00:00
|
|
|
const wxString& name = wxT("wxSpinCtrl"));
|
1999-10-10 23:28:07 +00:00
|
|
|
|
1999-10-28 01:17:35 +00:00
|
|
|
// a wxTextCtrl-like method (but we can't have GetValue returning wxString
|
|
|
|
// because the base class already has one returning int!)
|
|
|
|
void SetValue(const wxString& text);
|
|
|
|
|
2002-08-30 01:00:04 +00:00
|
|
|
// another wxTextCtrl-like method
|
|
|
|
void SetSelection(long from, long to);
|
|
|
|
|
2012-08-30 20:24:38 +00:00
|
|
|
// wxSpinCtrlBase methods
|
|
|
|
virtual int GetBase() const;
|
|
|
|
virtual bool SetBase(int base);
|
|
|
|
|
|
|
|
|
1999-12-29 23:34:18 +00:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
virtual ~wxSpinCtrl();
|
|
|
|
|
2006-06-26 12:20:50 +00:00
|
|
|
virtual void SetValue(int val);
|
2000-01-08 16:10:31 +00:00
|
|
|
virtual int GetValue() const;
|
2009-08-23 22:48:35 +00:00
|
|
|
virtual void SetRange(int minVal, int maxVal);
|
1999-10-28 00:38:59 +00:00
|
|
|
virtual bool SetFont(const wxFont &font);
|
2000-01-08 16:10:31 +00:00
|
|
|
virtual void SetFocus();
|
1999-10-28 00:38:59 +00:00
|
|
|
|
2004-09-04 01:53:42 +00:00
|
|
|
virtual bool Enable(bool enable = true);
|
|
|
|
virtual bool Show(bool show = true);
|
1999-12-29 23:34:18 +00:00
|
|
|
|
2008-03-15 04:10:43 +00:00
|
|
|
virtual bool Reparent(wxWindowBase *newParent);
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// wxSpinButton doesn't accept focus, but we do
|
|
|
|
virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
|
|
|
|
|
2009-09-08 12:23:06 +00:00
|
|
|
// we're like wxTextCtrl and not (default) wxButton
|
|
|
|
virtual wxVisualAttributes GetDefaultAttributes() const
|
|
|
|
{
|
|
|
|
return GetClassDefaultAttributes(GetWindowVariant());
|
|
|
|
}
|
|
|
|
|
|
|
|
static wxVisualAttributes
|
|
|
|
GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL)
|
|
|
|
{
|
|
|
|
return GetCompositeControlsDefaultAttributes(variant);
|
|
|
|
}
|
|
|
|
|
2000-12-21 02:12:22 +00:00
|
|
|
// for internal use only
|
|
|
|
|
|
|
|
// get the subclassed window proc of the buddy text
|
|
|
|
WXFARPROC GetBuddyWndProc() const { return m_wndProcBuddy; }
|
|
|
|
|
|
|
|
// return the spinctrl object whose buddy is the given window or NULL
|
|
|
|
static wxSpinCtrl *GetSpinForTextCtrl(WXHWND hwndBuddy);
|
|
|
|
|
|
|
|
// process a WM_COMMAND generated by the buddy text control
|
|
|
|
bool ProcessTextCommand(WXWORD cmd, WXWORD id);
|
2000-01-23 23:23:46 +00:00
|
|
|
|
2009-09-06 14:31:25 +00:00
|
|
|
// recognize buddy window as part of this control at wx level
|
|
|
|
virtual bool ContainsHWND(WXHWND hWnd) const { return hWnd == m_hwndBuddy; }
|
|
|
|
|
1999-10-10 23:28:07 +00:00
|
|
|
protected:
|
2000-07-15 19:51:35 +00:00
|
|
|
virtual void DoGetPosition(int *x, int *y) const;
|
1999-10-28 00:38:59 +00:00
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
1999-11-19 21:01:20 +00:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
2012-11-20 12:49:53 +00:00
|
|
|
virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
|
2000-07-15 19:51:35 +00:00
|
|
|
virtual void DoGetSize(int *width, int *height) const;
|
2007-12-06 19:52:57 +00:00
|
|
|
virtual void DoGetClientSize(int *x, int *y) const;
|
2005-02-28 01:23:03 +00:00
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
virtual void DoSetToolTip( wxToolTip *tip );
|
|
|
|
#endif // wxUSE_TOOLTIPS
|
1999-10-10 23:28:07 +00:00
|
|
|
|
2008-06-20 08:17:33 +00:00
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
|
|
|
virtual bool MSWOnScroll(int orientation, WXWORD wParam,
|
|
|
|
WXWORD pos, WXHWND control);
|
1999-12-22 23:00:10 +00:00
|
|
|
|
2007-01-11 01:59:42 +00:00
|
|
|
// handle processing of special keys
|
2001-01-09 15:50:01 +00:00
|
|
|
void OnChar(wxKeyEvent& event);
|
2003-03-24 18:55:42 +00:00
|
|
|
void OnSetFocus(wxFocusEvent& event);
|
2006-01-17 16:59:02 +00:00
|
|
|
void OnKillFocus(wxFocusEvent& event);
|
2001-01-09 15:50:01 +00:00
|
|
|
|
2007-01-11 01:59:42 +00:00
|
|
|
// generate spin control update event with the given value
|
|
|
|
void SendSpinUpdate(int value);
|
|
|
|
|
|
|
|
// called to ensure that the value is in the correct range
|
2006-09-20 14:15:14 +00:00
|
|
|
virtual void NormalizeValue();
|
2007-01-11 01:59:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// the value of the control before the latest change (which might not have
|
|
|
|
// changed anything in fact -- this is why we need this field)
|
|
|
|
int m_oldValue;
|
|
|
|
|
2000-07-15 19:51:35 +00:00
|
|
|
// the data for the "buddy" text ctrl
|
|
|
|
WXHWND m_hwndBuddy;
|
2000-12-21 02:12:22 +00:00
|
|
|
WXFARPROC m_wndProcBuddy;
|
|
|
|
|
2009-08-21 10:41:26 +00:00
|
|
|
// Block text update event after SetValue()
|
2008-05-24 20:24:58 +00:00
|
|
|
bool m_blockEvent;
|
|
|
|
|
1999-12-22 23:00:10 +00:00
|
|
|
private:
|
2012-03-04 00:29:48 +00:00
|
|
|
// Common part of all ctors.
|
|
|
|
void Init();
|
|
|
|
|
2012-08-30 20:24:38 +00:00
|
|
|
// Adjust the text control style depending on whether we need to enter only
|
|
|
|
// digits or may need to enter something else (e.g. "-" sign, "x"
|
|
|
|
// hexadecimal prefix, ...) in it.
|
|
|
|
void UpdateBuddyStyle();
|
|
|
|
|
|
|
|
|
1999-10-10 23:28:07 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
|
1999-12-22 23:00:10 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 11:45:59 +00:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxSpinCtrl);
|
1999-10-10 23:28:07 +00:00
|
|
|
};
|
|
|
|
|
2004-11-23 20:08:56 +00:00
|
|
|
#endif // wxUSE_SPINCTRL
|
|
|
|
|
1999-10-10 23:28:07 +00:00
|
|
|
#endif // _WX_MSW_SPINCTRL_H_
|
|
|
|
|
|
|
|
|