]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/spinbutt.h
Define wx[U]IntPtr as long, not [s]size_t, in 32 bit builds.
[wxWidgets.git] / include / wx / univ / spinbutt.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/spinbutt.h
3// Purpose: universal version of wxSpinButton
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 21.01.01
7// RCS-ID: $Id$
442b35b5 8// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 9// Licence: wxWindows licence
1e6feb95
VZ
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_SPINBUTT_H_
13#define _WX_UNIV_SPINBUTT_H_
14
1e6feb95
VZ
15#include "wx/univ/scrarrow.h"
16
17// ----------------------------------------------------------------------------
18// wxSpinButton
19// ----------------------------------------------------------------------------
20
21// actions supported by this control
9a83f860
VZ
22#define wxACTION_SPIN_INC wxT("inc")
23#define wxACTION_SPIN_DEC wxT("dec")
1e6feb95 24
53a2db12 25class WXDLLIMPEXP_CORE wxSpinButton : public wxSpinButtonBase,
1e6feb95
VZ
26 public wxControlWithArrows
27{
28public:
29 wxSpinButton();
30 wxSpinButton(wxWindow *parent,
a290fa5a 31 wxWindowID id = wxID_ANY,
1e6feb95
VZ
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize,
34 long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
35 const wxString& name = wxSPIN_BUTTON_NAME);
36
37 bool Create(wxWindow *parent,
a290fa5a 38 wxWindowID id = wxID_ANY,
1e6feb95
VZ
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
42 const wxString& name = wxSPIN_BUTTON_NAME);
43
44 // implement wxSpinButtonBase methods
45 virtual int GetValue() const;
46 virtual void SetValue(int val);
47 virtual void SetRange(int minVal, int maxVal);
48
49 // implement wxControlWithArrows methods
50 virtual wxRenderer *GetRenderer() const { return m_renderer; }
51 virtual wxWindow *GetWindow() { return this; }
52 virtual bool IsVertical() const { return wxSpinButtonBase::IsVertical(); }
53 virtual int GetArrowState(wxScrollArrows::Arrow arrow) const;
54 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow, int flag, bool set);
55 virtual bool OnArrow(wxScrollArrows::Arrow arrow);
6236b8b4 56 virtual wxScrollArrows::Arrow HitTestArrow(const wxPoint& pt) const;
1e6feb95
VZ
57
58 // for wxStdSpinButtonInputHandler
59 const wxScrollArrows& GetArrows() { return m_arrows; }
60
6f02a879
VZ
61 virtual bool PerformAction(const wxControlAction& action,
62 long numArg = 0,
63 const wxString& strArg = wxEmptyString);
64
9467bdb7
VZ
65 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
66 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
67 {
68 return GetStdInputHandler(handlerDef);
69 }
70
1e6feb95
VZ
71protected:
72 virtual wxSize DoGetBestClientSize() const;
73 virtual void DoDraw(wxControlRenderer *renderer);
74 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
75
1e6feb95
VZ
76 // the common part of all ctors
77 void Init();
78
79 // normalize the value to fit into min..max range
80 int NormalizeValue(int value) const;
81
a290fa5a 82 // change the value by +1/-1 and send the event, return true if value was
1e6feb95
VZ
83 // changed
84 bool ChangeValue(int inc);
85
86 // get the rectangles for our 2 arrows
87 void CalcArrowRects(wxRect *rect1, wxRect *rect2) const;
88
89 // the current controls value
90 int m_value;
91
92private:
93 // the object which manages our arrows
94 wxScrollArrows m_arrows;
95
96 // the state (combination of wxCONTROL_XXX flags) of the arrows
97 int m_arrowsState[wxScrollArrows::Arrow_Max];
98
99 DECLARE_DYNAMIC_CLASS(wxSpinButton)
100};
101
102// ----------------------------------------------------------------------------
103// wxStdSpinButtonInputHandler: manages clicks on them (use arrows like
104// wxStdScrollBarInputHandler) and processes keyboard events too
105// ----------------------------------------------------------------------------
106
53a2db12 107class WXDLLIMPEXP_CORE wxStdSpinButtonInputHandler : public wxStdInputHandler
1e6feb95
VZ
108{
109public:
110 wxStdSpinButtonInputHandler(wxInputHandler *inphand);
111
23645bfa 112 virtual bool HandleKey(wxInputConsumer *consumer,
1e6feb95
VZ
113 const wxKeyEvent& event,
114 bool pressed);
23645bfa 115 virtual bool HandleMouse(wxInputConsumer *consumer,
1e6feb95 116 const wxMouseEvent& event);
23645bfa 117 virtual bool HandleMouseMove(wxInputConsumer *consumer,
1e6feb95
VZ
118 const wxMouseEvent& event);
119};
120
121#endif // _WX_UNIV_SPINBUTT_H_
122