]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/tglbtn.h
[ 1493780 ] wxOwnerDrawnComboBox warnings fixes.
[wxWidgets.git] / include / wx / univ / tglbtn.h
CommitLineData
43be3c33
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/button.h
3// Purpose: wxToggleButton for wxUniversal
4// Author: Vadim Zeitlin
5// Modified by: David Bjorkevik
6// Created: 16.05.06
7// RCS-ID: $Id$
8// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9// Licence: wxWindows licence
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_TGLBTN_H_
13#define _WX_UNIV_TGLBTN_H_
14
43be3c33 15#include "wx/bitmap.h"
13199c3d
PC
16
17extern WXDLLEXPORT_DATA(const wxChar) wxCheckBoxNameStr[];
43be3c33
JS
18
19// ----------------------------------------------------------------------------
20// the actions supported by this control
21// ----------------------------------------------------------------------------
22
23#define wxACTION_BUTTON_TOGGLE _T("toggle") // press/release the button
24#define wxACTION_BUTTON_PRESS _T("press") // press the button
25#define wxACTION_BUTTON_RELEASE _T("release") // release the button
26#define wxACTION_BUTTON_CLICK _T("click") // generate button click event
27
28// ----------------------------------------------------------------------------
29// wxToggleButton: a push button
30// ----------------------------------------------------------------------------
31
32class WXDLLIMPEXP_CORE wxToggleButton: public wxControl
33{
34public:
35 wxToggleButton() { Init(); }
36 wxToggleButton(wxWindow *parent,
37 wxWindowID id,
38 const wxBitmap& bitmap,
39 const wxString& label = wxEmptyString,
40 const wxPoint& pos = wxDefaultPosition,
41 const wxSize& size = wxDefaultSize,
42 long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxCheckBoxNameStr)
45 {
46 Init();
47
48 Create(parent, id, bitmap, label, pos, size, style, validator, name);
49 }
50
51 wxToggleButton(wxWindow *parent,
52 wxWindowID id,
53 const wxString& label = wxEmptyString,
54 const wxPoint& pos = wxDefaultPosition,
55 const wxSize& size = wxDefaultSize,
56 long style = 0,
57 const wxValidator& validator = wxDefaultValidator,
58 const wxString& name = wxCheckBoxNameStr)
59 {
60 Init();
61
62 Create(parent, id, label, pos, size, style, validator, name);
63 }
64
65 bool Create(wxWindow *parent,
66 wxWindowID id,
67 const wxString& label = wxEmptyString,
68 const wxPoint& pos = wxDefaultPosition,
69 const wxSize& size = wxDefaultSize,
70 long style = 0,
71 const wxValidator& validator = wxDefaultValidator,
72 const wxString& name = wxCheckBoxNameStr)
73 {
74 return Create(parent, id, wxNullBitmap, label,
75 pos, size, style, validator, name);
76 }
77
78 bool Create(wxWindow *parent,
79 wxWindowID id,
80 const wxBitmap& bitmap,
81 const wxString& label = wxEmptyString,
82 const wxPoint& pos = wxDefaultPosition,
83 const wxSize& size = wxDefaultSize,
84 long style = 0,
85 const wxValidator& validator = wxDefaultValidator,
86 const wxString& name = wxCheckBoxNameStr);
87
88 virtual ~wxToggleButton();
89
90 virtual void SetImageLabel(const wxBitmap& bitmap);
91 virtual void SetImageMargins(wxCoord x, wxCoord y);
92
93 virtual bool IsPressed() const { return m_isPressed || m_value; }
94
95 // wxToggleButton actions
96 void Toggle();
97 virtual void Press();
98 virtual void Release();
99 virtual void Click();
100
101 // Get/set the value
102 void SetValue(bool state);
103 bool GetValue() const { return m_value; }
104
105 // returns the default button size for this platform
106 static wxSize GetDefaultSize();
107
43be3c33
JS
108 virtual bool PerformAction(const wxControlAction& action,
109 long numArg = -1,
110 const wxString& strArg = wxEmptyString);
13199c3d
PC
111
112 virtual bool CanBeHighlighted() const { return true; }
113
114protected:
43be3c33
JS
115 virtual wxSize DoGetBestClientSize() const;
116
117 virtual bool DoDrawBackground(wxDC& dc);
118 virtual void DoDraw(wxControlRenderer *renderer);
119
43be3c33
JS
120 // common part of all ctors
121 void Init();
122
123 // current state - is the user currently pressing the button
124 bool m_isPressed;
125
126 // the current value
127 bool m_value;
128
129 // the (optional) image to show and the margins around it
130 wxBitmap m_bitmap;
131 wxCoord m_marginBmpX,
132 m_marginBmpY;
133
134private:
135 DECLARE_DYNAMIC_CLASS(wxToggleButton)
136};
137// wxStdToggleButtonInputHandler: translates SPACE and ENTER keys and the left mouse
138// click into button press/release actions
139// ----------------------------------------------------------------------------
140
141class WXDLLEXPORT wxStdToggleButtonInputHandler : public wxStdInputHandler
142{
143public:
144 wxStdToggleButtonInputHandler(wxInputHandler *inphand);
145
146 virtual bool HandleKey(wxInputConsumer *consumer,
147 const wxKeyEvent& event,
148 bool pressed);
149 virtual bool HandleMouse(wxInputConsumer *consumer,
150 const wxMouseEvent& event);
151 virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
152 virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
153 virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
154
155private:
156 // the window (button) which has capture or NULL and the flag telling if
157 // the mouse is inside the button which captured it or not
158 wxWindow *m_winCapture;
159 bool m_winHasMouse;
160};
161
162#endif // _WX_UNIV_TGLBTN_H_
163