]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/spinbutt.h
pragma fix for gcc
[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)
1e6feb95
VZ
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_SPINBUTT_H_
13#define _WX_UNIV_SPINBUTT_H_
14
15#ifdef __GNUG__
a3870b2f 16 #pragma interface "univspinbutt.h"
1e6feb95
VZ
17#endif
18
19#include "wx/univ/scrarrow.h"
20
21// ----------------------------------------------------------------------------
22// wxSpinButton
23// ----------------------------------------------------------------------------
24
25// actions supported by this control
26#define wxACTION_SPIN_INC _T("inc")
27#define wxACTION_SPIN_DEC _T("dec")
28
29class WXDLLEXPORT wxSpinButton : public wxSpinButtonBase,
30 public wxControlWithArrows
31{
32public:
33 wxSpinButton();
34 wxSpinButton(wxWindow *parent,
35 wxWindowID id = -1,
36 const wxPoint& pos = wxDefaultPosition,
37 const wxSize& size = wxDefaultSize,
38 long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
39 const wxString& name = wxSPIN_BUTTON_NAME);
40
41 bool Create(wxWindow *parent,
42 wxWindowID id = -1,
43 const wxPoint& pos = wxDefaultPosition,
44 const wxSize& size = wxDefaultSize,
45 long style = wxSP_VERTICAL | wxSP_ARROW_KEYS,
46 const wxString& name = wxSPIN_BUTTON_NAME);
47
48 // implement wxSpinButtonBase methods
49 virtual int GetValue() const;
50 virtual void SetValue(int val);
51 virtual void SetRange(int minVal, int maxVal);
52
53 // implement wxControlWithArrows methods
54 virtual wxRenderer *GetRenderer() const { return m_renderer; }
55 virtual wxWindow *GetWindow() { return this; }
56 virtual bool IsVertical() const { return wxSpinButtonBase::IsVertical(); }
57 virtual int GetArrowState(wxScrollArrows::Arrow arrow) const;
58 virtual void SetArrowFlag(wxScrollArrows::Arrow arrow, int flag, bool set);
59 virtual bool OnArrow(wxScrollArrows::Arrow arrow);
60 virtual wxScrollArrows::Arrow HitTest(const wxPoint& pt) const;
61
62 // for wxStdSpinButtonInputHandler
63 const wxScrollArrows& GetArrows() { return m_arrows; }
64
65protected:
66 virtual wxSize DoGetBestClientSize() const;
67 virtual void DoDraw(wxControlRenderer *renderer);
68 virtual wxBorder GetDefaultBorder() const { return wxBORDER_NONE; }
69
70 virtual bool PerformAction(const wxControlAction& action,
71 long numArg = 0,
72 const wxString& strArg = wxEmptyString);
73
74 // the common part of all ctors
75 void Init();
76
77 // normalize the value to fit into min..max range
78 int NormalizeValue(int value) const;
79
80 // change the value by +1/-1 and send the event, return TRUE if value was
81 // changed
82 bool ChangeValue(int inc);
83
84 // get the rectangles for our 2 arrows
85 void CalcArrowRects(wxRect *rect1, wxRect *rect2) const;
86
87 // the current controls value
88 int m_value;
89
90private:
91 // the object which manages our arrows
92 wxScrollArrows m_arrows;
93
94 // the state (combination of wxCONTROL_XXX flags) of the arrows
95 int m_arrowsState[wxScrollArrows::Arrow_Max];
96
97 DECLARE_DYNAMIC_CLASS(wxSpinButton)
98};
99
100// ----------------------------------------------------------------------------
101// wxStdSpinButtonInputHandler: manages clicks on them (use arrows like
102// wxStdScrollBarInputHandler) and processes keyboard events too
103// ----------------------------------------------------------------------------
104
105class WXDLLEXPORT wxStdSpinButtonInputHandler : public wxStdInputHandler
106{
107public:
108 wxStdSpinButtonInputHandler(wxInputHandler *inphand);
109
110 virtual bool HandleKey(wxControl *control,
111 const wxKeyEvent& event,
112 bool pressed);
113 virtual bool HandleMouse(wxControl *control,
114 const wxMouseEvent& event);
115 virtual bool HandleMouseMove(wxControl *control,
116 const wxMouseEvent& event);
117};
118
119#endif // _WX_UNIV_SPINBUTT_H_
120