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 class WXDLLEXPORT wxInputHandler
;
17 #include "wx/bitmap.h"
19 // ----------------------------------------------------------------------------
20 // the actions supported by this control
21 // ----------------------------------------------------------------------------
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
28 // ----------------------------------------------------------------------------
29 // wxButton: a push button
30 // ----------------------------------------------------------------------------
32 class WXDLLEXPORT wxButton
: public wxButtonBase
35 wxButton() { Init(); }
36 wxButton(wxWindow
*parent
,
38 const wxBitmap
& bitmap
,
39 const wxString
& label
= wxEmptyString
,
40 const wxPoint
& pos
= wxDefaultPosition
,
41 const wxSize
& size
= wxDefaultSize
,
43 const wxValidator
& validator
= wxDefaultValidator
,
44 const wxString
& name
= wxButtonNameStr
)
48 Create(parent
, id
, bitmap
, label
, pos
, size
, style
, validator
, name
);
51 wxButton(wxWindow
*parent
,
53 const wxString
& label
= wxEmptyString
,
54 const wxPoint
& pos
= wxDefaultPosition
,
55 const wxSize
& size
= wxDefaultSize
,
57 const wxValidator
& validator
= wxDefaultValidator
,
58 const wxString
& name
= wxButtonNameStr
)
62 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
65 bool Create(wxWindow
*parent
,
67 const wxString
& label
= wxEmptyString
,
68 const wxPoint
& pos
= wxDefaultPosition
,
69 const wxSize
& size
= wxDefaultSize
,
71 const wxValidator
& validator
= wxDefaultValidator
,
72 const wxString
& name
= wxButtonNameStr
)
74 return Create(parent
, id
, wxNullBitmap
, label
,
75 pos
, size
, style
, validator
, name
);
78 bool Create(wxWindow
*parent
,
80 const wxBitmap
& bitmap
,
81 const wxString
& label
= wxEmptyString
,
82 const wxPoint
& pos
= wxDefaultPosition
,
83 const wxSize
& size
= wxDefaultSize
,
85 const wxValidator
& validator
= wxDefaultValidator
,
86 const wxString
& name
= wxButtonNameStr
);
90 virtual void SetImageLabel(const wxBitmap
& bitmap
);
91 virtual void SetImageMargins(wxCoord x
, wxCoord y
);
92 virtual void SetDefault();
94 virtual bool IsPressed() const { return m_isPressed
; }
95 virtual bool IsDefault() const { return m_isDefault
; }
100 virtual void Release();
101 virtual void Click();
103 virtual bool PerformAction(const wxControlAction
& action
,
105 const wxString
& strArg
= wxEmptyString
);
107 virtual bool CanBeHighlighted() const { return true; }
110 virtual wxSize
DoGetBestClientSize() const;
112 virtual bool DoDrawBackground(wxDC
& dc
);
113 virtual void DoDraw(wxControlRenderer
*renderer
);
115 // common part of all ctors
122 // the (optional) image to show and the margins around it
124 wxCoord m_marginBmpX
,
128 DECLARE_DYNAMIC_CLASS(wxButton
)
131 // ----------------------------------------------------------------------------
132 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
133 // click into button press/release actions
134 // ----------------------------------------------------------------------------
136 class WXDLLEXPORT wxStdButtonInputHandler
: public wxStdInputHandler
139 wxStdButtonInputHandler(wxInputHandler
*inphand
);
141 virtual bool HandleKey(wxInputConsumer
*consumer
,
142 const wxKeyEvent
& event
,
144 virtual bool HandleMouse(wxInputConsumer
*consumer
,
145 const wxMouseEvent
& event
);
146 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
147 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
148 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
151 // the window (button) which has capture or NULL and the flag telling if
152 // the mouse is inside the button which captured it or not
153 wxWindow
*m_winCapture
;
157 #endif // _WX_UNIV_BUTTON_H_