Remove all lines containing cvs/svn "$Id$" keyword.
[wxWidgets.git] / include / wx / univ / button.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/button.h
3 // Purpose: wxButton for wxUniversal
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 15.08.00
7 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_UNIV_BUTTON_H_
12 #define _WX_UNIV_BUTTON_H_
13
14 class WXDLLIMPEXP_FWD_CORE wxInputHandler;
15
16 #include "wx/bitmap.h"
17
18 // ----------------------------------------------------------------------------
19 // the actions supported by this control
20 // ----------------------------------------------------------------------------
21
22 #define wxACTION_BUTTON_TOGGLE wxT("toggle") // press/release the button
23 #define wxACTION_BUTTON_PRESS wxT("press") // press the button
24 #define wxACTION_BUTTON_RELEASE wxT("release") // release the button
25 #define wxACTION_BUTTON_CLICK wxT("click") // generate button click event
26
27 // ----------------------------------------------------------------------------
28 // wxButton: a push button
29 // ----------------------------------------------------------------------------
30
31 class WXDLLIMPEXP_CORE wxButton : public wxButtonBase
32 {
33 public:
34 wxButton() { Init(); }
35 wxButton(wxWindow *parent,
36 wxWindowID id,
37 const wxBitmap& bitmap,
38 const wxString& label = wxEmptyString,
39 const wxPoint& pos = wxDefaultPosition,
40 const wxSize& size = wxDefaultSize,
41 long style = 0,
42 const wxValidator& validator = wxDefaultValidator,
43 const wxString& name = wxButtonNameStr)
44 {
45 Init();
46
47 Create(parent, id, bitmap, label, pos, size, style, validator, name);
48 }
49
50 wxButton(wxWindow *parent,
51 wxWindowID id,
52 const wxString& label = wxEmptyString,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxButtonNameStr)
58 {
59 Init();
60
61 Create(parent, id, label, pos, size, style, validator, name);
62 }
63
64 bool Create(wxWindow *parent,
65 wxWindowID id,
66 const wxString& label = wxEmptyString,
67 const wxPoint& pos = wxDefaultPosition,
68 const wxSize& size = wxDefaultSize,
69 long style = 0,
70 const wxValidator& validator = wxDefaultValidator,
71 const wxString& name = wxButtonNameStr)
72 {
73 return Create(parent, id, wxNullBitmap, label,
74 pos, size, style, validator, name);
75 }
76
77 bool Create(wxWindow *parent,
78 wxWindowID id,
79 const wxBitmap& bitmap,
80 const wxString& label = wxEmptyString,
81 const wxPoint& pos = wxDefaultPosition,
82 const wxSize& size = wxDefaultSize,
83 long style = 0,
84 const wxValidator& validator = wxDefaultValidator,
85 const wxString& name = wxButtonNameStr);
86
87 virtual ~wxButton();
88
89 virtual wxWindow *SetDefault();
90
91 virtual bool IsPressed() const { return m_isPressed; }
92 virtual bool IsDefault() const { return m_isDefault; }
93
94 // wxButton actions
95 virtual void Toggle();
96 virtual void Press();
97 virtual void Release();
98 virtual void Click();
99
100 virtual bool PerformAction(const wxControlAction& action,
101 long numArg = -1,
102 const wxString& strArg = wxEmptyString);
103
104 virtual bool CanBeHighlighted() const { return true; }
105
106 static wxInputHandler *GetStdInputHandler(wxInputHandler *handlerDef);
107 virtual wxInputHandler *DoGetStdInputHandler(wxInputHandler *handlerDef)
108 {
109 return GetStdInputHandler(handlerDef);
110 }
111
112
113 protected:
114 virtual wxSize DoGetBestClientSize() const;
115
116 virtual bool DoDrawBackground(wxDC& dc);
117 virtual void DoDraw(wxControlRenderer *renderer);
118
119 virtual void DoSetBitmap(const wxBitmap& bitmap, State which);
120 virtual void DoSetBitmapMargins(wxCoord x, wxCoord y);
121
122 // common part of all ctors
123 void Init();
124
125 // current state
126 bool m_isPressed,
127 m_isDefault;
128
129 // the (optional) image to show and the margins around it
130 wxBitmap m_bitmap;
131 wxCoord m_marginBmpX,
132 m_marginBmpY;
133
134 private:
135 DECLARE_DYNAMIC_CLASS(wxButton)
136 };
137
138 #endif // _WX_UNIV_BUTTON_H_
139