1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/button.h
3 // Purpose: wxButton for wxUniversal
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_BUTTON_H_
13 #define _WX_UNIV_BUTTON_H_
16 #pragma interface "univbutton.h"
19 class WXDLLEXPORT wxInputHandler
;
21 #include "wx/bitmap.h"
23 // ----------------------------------------------------------------------------
24 // the actions supported by this control
25 // ----------------------------------------------------------------------------
27 #define wxACTION_BUTTON_TOGGLE _T("toggle") // press/release the button
28 #define wxACTION_BUTTON_PRESS _T("press") // press the button
29 #define wxACTION_BUTTON_RELEASE _T("release") // release the button
30 #define wxACTION_BUTTON_CLICK _T("click") // generate button click event
32 // ----------------------------------------------------------------------------
33 // wxButton: a push button
34 // ----------------------------------------------------------------------------
36 class WXDLLEXPORT wxButton
: public wxButtonBase
39 wxButton() { Init(); }
40 wxButton(wxWindow
*parent
,
42 const wxBitmap
& bitmap
,
43 const wxString
& label
,
44 const wxPoint
& pos
= wxDefaultPosition
,
45 const wxSize
& size
= wxDefaultSize
,
47 const wxValidator
& validator
= wxDefaultValidator
,
48 const wxString
& name
= wxButtonNameStr
)
52 Create(parent
, id
, bitmap
, label
, pos
, size
, style
, validator
, name
);
55 wxButton(wxWindow
*parent
,
57 const wxString
& label
,
58 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxSize
& size
= wxDefaultSize
,
61 const wxValidator
& validator
= wxDefaultValidator
,
62 const wxString
& name
= wxButtonNameStr
)
66 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
69 bool Create(wxWindow
*parent
,
71 const wxString
& label
,
72 const wxPoint
& pos
= wxDefaultPosition
,
73 const wxSize
& size
= wxDefaultSize
,
75 const wxValidator
& validator
= wxDefaultValidator
,
76 const wxString
& name
= wxButtonNameStr
)
78 return Create(parent
, id
, wxNullBitmap
, label
,
79 pos
, size
, style
, validator
, name
);
82 bool Create(wxWindow
*parent
,
84 const wxBitmap
& bitmap
,
85 const wxString
& label
,
86 const wxPoint
& pos
= wxDefaultPosition
,
87 const wxSize
& size
= wxDefaultSize
,
89 const wxValidator
& validator
= wxDefaultValidator
,
90 const wxString
& name
= wxButtonNameStr
);
94 virtual void SetImageLabel(const wxBitmap
& bitmap
);
95 virtual void SetImageMargins(wxCoord x
, wxCoord y
);
96 virtual void SetDefault();
98 virtual bool IsPressed() const { return m_isPressed
; }
99 virtual bool IsDefault() const { return m_isDefault
; }
103 virtual void Press();
104 virtual void Release();
105 virtual void Click();
108 virtual bool PerformAction(const wxControlAction
& action
,
110 const wxString
& strArg
= wxEmptyString
);
111 virtual wxSize
DoGetBestClientSize() const;
112 virtual void DoDraw(wxControlRenderer
*renderer
);
114 virtual bool CanBeHighlighted() const { return TRUE
; }
116 // common part of all ctors
123 // the (optional) image to show and the margins around it
125 wxCoord m_marginBmpX
,
129 DECLARE_DYNAMIC_CLASS(wxButton
)
132 // ----------------------------------------------------------------------------
133 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
134 // click into button press/release actions
135 // ----------------------------------------------------------------------------
137 class WXDLLEXPORT wxStdButtonInputHandler
: public wxStdInputHandler
140 wxStdButtonInputHandler(wxInputHandler
*inphand
);
142 virtual bool HandleKey(wxControl
*control
,
143 const wxKeyEvent
& event
,
145 virtual bool HandleMouse(wxControl
*control
,
146 const wxMouseEvent
& event
);
147 virtual bool HandleMouseMove(wxControl
*control
, const wxMouseEvent
& event
);
148 virtual bool HandleFocus(wxControl
*control
, const wxFocusEvent
& event
);
149 virtual bool HandleActivation(wxControl
*control
, bool activated
);
152 // the window (button) which has capture or NULL and the flag telling if
153 // the mouse is inside the button which captured it or not
154 wxWindow
*m_winCapture
;
158 #endif // _WX_UNIV_BUTTON_H_