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 licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_BUTTON_H_
13 #define _WX_UNIV_BUTTON_H_
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
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
, wxWindowID id
, wxStockItemID stock
,
56 const wxString
& descriptiveLabel
= wxEmptyString
,
57 const wxPoint
& pos
= wxDefaultPosition
,
59 const wxValidator
& validator
= wxDefaultValidator
,
60 const wxString
& name
= wxButtonNameStr
)
64 Create(parent
, id
, stock
, descriptiveLabel
, pos
, style
, validator
, name
);
67 wxButton(wxWindow
*parent
,
69 const wxString
& label
,
70 const wxPoint
& pos
= wxDefaultPosition
,
71 const wxSize
& size
= wxDefaultSize
,
73 const wxValidator
& validator
= wxDefaultValidator
,
74 const wxString
& name
= wxButtonNameStr
)
78 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
81 bool Create(wxWindow
*parent
,
83 const wxString
& label
,
84 const wxPoint
& pos
= wxDefaultPosition
,
85 const wxSize
& size
= wxDefaultSize
,
87 const wxValidator
& validator
= wxDefaultValidator
,
88 const wxString
& name
= wxButtonNameStr
)
90 return Create(parent
, id
, wxNullBitmap
, label
,
91 pos
, size
, style
, validator
, name
);
94 bool Create(wxWindow
*parent
, wxWindowID id
, wxStockItemID stock
,
95 const wxString
& descriptiveLabel
= wxEmptyString
,
96 const wxPoint
& pos
= wxDefaultPosition
,
98 const wxValidator
& validator
= wxDefaultValidator
,
99 const wxString
& name
= wxButtonNameStr
)
101 return CreateStock(parent
, id
, stock
, descriptiveLabel
,
102 pos
, style
, validator
, name
);
105 bool Create(wxWindow
*parent
,
107 const wxBitmap
& bitmap
,
108 const wxString
& label
,
109 const wxPoint
& pos
= wxDefaultPosition
,
110 const wxSize
& size
= wxDefaultSize
,
112 const wxValidator
& validator
= wxDefaultValidator
,
113 const wxString
& name
= wxButtonNameStr
);
117 virtual void SetImageLabel(const wxBitmap
& bitmap
);
118 virtual void SetImageMargins(wxCoord x
, wxCoord y
);
119 virtual void SetDefault();
121 virtual bool IsPressed() const { return m_isPressed
; }
122 virtual bool IsDefault() const { return m_isDefault
; }
126 virtual void Press();
127 virtual void Release();
128 virtual void Click();
131 virtual bool PerformAction(const wxControlAction
& action
,
133 const wxString
& strArg
= wxEmptyString
);
134 virtual wxSize
DoGetBestClientSize() const;
136 virtual bool DoDrawBackground(wxDC
& dc
);
137 virtual void DoDraw(wxControlRenderer
*renderer
);
139 virtual bool CanBeHighlighted() const { return true; }
141 // common part of all ctors
148 // the (optional) image to show and the margins around it
150 wxCoord m_marginBmpX
,
154 DECLARE_DYNAMIC_CLASS(wxButton
)
157 // ----------------------------------------------------------------------------
158 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
159 // click into button press/release actions
160 // ----------------------------------------------------------------------------
162 class WXDLLEXPORT wxStdButtonInputHandler
: public wxStdInputHandler
165 wxStdButtonInputHandler(wxInputHandler
*inphand
);
167 virtual bool HandleKey(wxInputConsumer
*consumer
,
168 const wxKeyEvent
& event
,
170 virtual bool HandleMouse(wxInputConsumer
*consumer
,
171 const wxMouseEvent
& event
);
172 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
173 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
174 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
177 // the window (button) which has capture or NULL and the flag telling if
178 // the mouse is inside the button which captured it or not
179 wxWindow
*m_winCapture
;
183 #endif // _WX_UNIV_BUTTON_H_