1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/button.h
3 // Purpose: wxButton for wxUniversal
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
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;
113 virtual bool DoDrawBackground(wxDC
& dc
);
114 virtual void DoDraw(wxControlRenderer
*renderer
);
116 virtual bool CanBeHighlighted() const { return TRUE
; }
118 // common part of all ctors
125 // the (optional) image to show and the margins around it
127 wxCoord m_marginBmpX
,
131 DECLARE_DYNAMIC_CLASS(wxButton
)
134 // ----------------------------------------------------------------------------
135 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
136 // click into button press/release actions
137 // ----------------------------------------------------------------------------
139 class WXDLLEXPORT wxStdButtonInputHandler
: public wxStdInputHandler
142 wxStdButtonInputHandler(wxInputHandler
*inphand
);
144 virtual bool HandleKey(wxInputConsumer
*consumer
,
145 const wxKeyEvent
& event
,
147 virtual bool HandleMouse(wxInputConsumer
*consumer
,
148 const wxMouseEvent
& event
);
149 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
150 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
151 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
154 // the window (button) which has capture or NULL and the flag telling if
155 // the mouse is inside the button which captured it or not
156 wxWindow
*m_winCapture
;
160 #endif // _WX_UNIV_BUTTON_H_