2000-07-15 15:51:35 -04:00
|
|
|
////////////////////////////////////////////////////////////////////////////
|
2011-03-19 20:14:35 -04:00
|
|
|
// Name: wx/msw/spinctrl.h
|
1999-10-10 19:28:07 -04:00
|
|
|
// Purpose: wxSpinCtrl class declaration for Win32
|
|
|
|
// Author: Vadim Zeitlin
|
|
|
|
// Modified by:
|
|
|
|
// Created: 22.07.99
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Copyright: (c) Vadim Zeitlin
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-10-10 19:28:07 -04:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#ifndef _WX_MSW_SPINCTRL_H_
|
|
|
|
#define _WX_MSW_SPINCTRL_H_
|
|
|
|
|
|
|
|
#include "wx/spinbutt.h" // the base class
|
|
|
|
|
2004-11-23 15:08:56 -05:00
|
|
|
#if wxUSE_SPINCTRL
|
|
|
|
|
2000-12-20 21:12:22 -05:00
|
|
|
#include "wx/dynarray.h"
|
2002-02-07 07:24:57 -05:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxSpinCtrl;
|
2003-10-08 18:13:14 -04:00
|
|
|
WX_DEFINE_EXPORTED_ARRAY_PTR(wxSpinCtrl *, wxArraySpins);
|
2000-12-20 21:12:22 -05:00
|
|
|
|
1999-10-10 19:28:07 -04: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 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxSpinCtrl : public wxSpinButton
|
1999-10-10 19:28:07 -04:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
wxSpinCtrl() { }
|
|
|
|
|
|
|
|
wxSpinCtrl(wxWindow *parent,
|
2004-09-03 21:53:42 -04:00
|
|
|
wxWindowID id = wxID_ANY,
|
1999-10-27 21:17:35 -04:00
|
|
|
const wxString& value = wxEmptyString,
|
1999-10-10 19:28:07 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 06:55:55 -04:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
1999-10-10 19:28:07 -04:00
|
|
|
int min = 0, int max = 100, int initial = 0,
|
2009-07-23 16:30:22 -04:00
|
|
|
const wxString& name = wxT("wxSpinCtrl"))
|
1999-10-10 19:28:07 -04:00
|
|
|
{
|
1999-10-27 21:17:35 -04:00
|
|
|
Create(parent, id, value, pos, size, style, min, max, initial, name);
|
1999-10-10 19:28:07 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
bool Create(wxWindow *parent,
|
2004-09-03 21:53:42 -04:00
|
|
|
wxWindowID id = wxID_ANY,
|
1999-10-27 21:17:35 -04:00
|
|
|
const wxString& value = wxEmptyString,
|
1999-10-10 19:28:07 -04:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-03-22 06:55:55 -04:00
|
|
|
long style = wxSP_ARROW_KEYS | wxALIGN_RIGHT,
|
1999-10-10 19:28:07 -04:00
|
|
|
int min = 0, int max = 100, int initial = 0,
|
2009-07-23 16:30:22 -04:00
|
|
|
const wxString& name = wxT("wxSpinCtrl"));
|
1999-10-10 19:28:07 -04:00
|
|
|
|
1999-10-27 21:17:35 -04: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-29 21:00:04 -04:00
|
|
|
// another wxTextCtrl-like method
|
|
|
|
void SetSelection(long from, long to);
|
|
|
|
|
1999-12-29 18:34:18 -05:00
|
|
|
// implementation only from now on
|
|
|
|
// -------------------------------
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
virtual ~wxSpinCtrl();
|
|
|
|
|
2006-06-26 08:20:50 -04:00
|
|
|
virtual void SetValue(int val);
|
2000-01-08 11:10:31 -05:00
|
|
|
virtual int GetValue() const;
|
2009-08-23 18:48:35 -04:00
|
|
|
virtual void SetRange(int minVal, int maxVal);
|
1999-10-27 20:38:59 -04:00
|
|
|
virtual bool SetFont(const wxFont &font);
|
2000-01-08 11:10:31 -05:00
|
|
|
virtual void SetFocus();
|
1999-10-27 20:38:59 -04:00
|
|
|
|
2004-09-03 21:53:42 -04:00
|
|
|
virtual bool Enable(bool enable = true);
|
|
|
|
virtual bool Show(bool show = true);
|
1999-12-29 18:34:18 -05:00
|
|
|
|
2008-03-15 00:10:43 -04:00
|
|
|
virtual bool Reparent(wxWindowBase *newParent);
|
|
|
|
|
2000-07-15 15:51:35 -04:00
|
|
|
// wxSpinButton doesn't accept focus, but we do
|
|
|
|
virtual bool AcceptsFocus() const { return wxWindow::AcceptsFocus(); }
|
|
|
|
|
2009-09-08 08:23:06 -04: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-20 21:12:22 -05: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 18:23:46 -05:00
|
|
|
|
2009-09-06 10:31:25 -04: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 19:28:07 -04:00
|
|
|
protected:
|
2000-07-15 15:51:35 -04:00
|
|
|
virtual void DoGetPosition(int *x, int *y) const;
|
1999-10-27 20:38:59 -04:00
|
|
|
virtual void DoMoveWindow(int x, int y, int width, int height);
|
1999-11-19 16:01:20 -05:00
|
|
|
virtual wxSize DoGetBestSize() const;
|
2000-07-15 15:51:35 -04:00
|
|
|
virtual void DoGetSize(int *width, int *height) const;
|
2007-12-06 14:52:57 -05:00
|
|
|
virtual void DoGetClientSize(int *x, int *y) const;
|
2005-02-27 20:23:03 -05:00
|
|
|
#if wxUSE_TOOLTIPS
|
|
|
|
virtual void DoSetToolTip( wxToolTip *tip );
|
|
|
|
#endif // wxUSE_TOOLTIPS
|
1999-10-10 19:28:07 -04:00
|
|
|
|
2008-06-20 04:17:33 -04:00
|
|
|
virtual bool MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result);
|
|
|
|
virtual bool MSWOnScroll(int orientation, WXWORD wParam,
|
|
|
|
WXWORD pos, WXHWND control);
|
1999-12-22 18:00:10 -05:00
|
|
|
|
2007-01-10 20:59:42 -05:00
|
|
|
// handle processing of special keys
|
2001-01-09 10:50:01 -05:00
|
|
|
void OnChar(wxKeyEvent& event);
|
2003-03-24 13:55:42 -05:00
|
|
|
void OnSetFocus(wxFocusEvent& event);
|
2006-01-17 11:59:02 -05:00
|
|
|
void OnKillFocus(wxFocusEvent& event);
|
2001-01-09 10:50:01 -05:00
|
|
|
|
2007-01-10 20:59:42 -05: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 10:15:14 -04:00
|
|
|
virtual void NormalizeValue();
|
2007-01-10 20:59:42 -05: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 15:51:35 -04:00
|
|
|
// the data for the "buddy" text ctrl
|
|
|
|
WXHWND m_hwndBuddy;
|
2000-12-20 21:12:22 -05:00
|
|
|
WXFARPROC m_wndProcBuddy;
|
|
|
|
|
2009-08-21 06:41:26 -04:00
|
|
|
// Block text update event after SetValue()
|
2008-05-24 16:24:58 -04:00
|
|
|
bool m_blockEvent;
|
|
|
|
|
1999-12-22 18:00:10 -05:00
|
|
|
private:
|
1999-10-10 19:28:07 -04:00
|
|
|
DECLARE_DYNAMIC_CLASS(wxSpinCtrl)
|
1999-12-22 18:00:10 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2009-02-08 06:45:59 -05:00
|
|
|
wxDECLARE_NO_COPY_CLASS(wxSpinCtrl);
|
1999-10-10 19:28:07 -04:00
|
|
|
};
|
|
|
|
|
2004-11-23 15:08:56 -05:00
|
|
|
#endif // wxUSE_SPINCTRL
|
|
|
|
|
1999-10-10 19:28:07 -04:00
|
|
|
#endif // _WX_MSW_SPINCTRL_H_
|
|
|
|
|
|
|
|
|