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
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
);
50 wxButton(wxWindow
*parent
,
52 const wxString
& label
,
53 const wxPoint
& pos
= wxDefaultPosition
,
54 const wxSize
& size
= wxDefaultSize
,
56 const wxValidator
& validator
= wxDefaultValidator
,
57 const wxString
& name
= wxButtonNameStr
);
59 bool Create(wxWindow
*parent
,
61 const wxString
& label
,
62 const wxPoint
& pos
= wxDefaultPosition
,
63 const wxSize
& size
= wxDefaultSize
,
65 const wxValidator
& validator
= wxDefaultValidator
,
66 const wxString
& name
= wxButtonNameStr
)
68 return Create(parent
, id
, wxNullBitmap
, label
,
69 pos
, size
, style
, validator
, name
);
72 bool Create(wxWindow
*parent
,
74 const wxBitmap
& bitmap
,
75 const wxString
& label
,
76 const wxPoint
& pos
= wxDefaultPosition
,
77 const wxSize
& size
= wxDefaultSize
,
79 const wxValidator
& validator
= wxDefaultValidator
,
80 const wxString
& name
= wxButtonNameStr
);
84 virtual void SetImageLabel(const wxBitmap
& bitmap
);
85 virtual void SetImageMargins(wxCoord x
, wxCoord y
);
86 virtual void SetDefault();
88 virtual bool IsPressed() const { return m_isPressed
; }
89 virtual bool IsDefault() const { return m_isDefault
; }
94 virtual void Release();
98 virtual bool PerformAction(const wxControlAction
& action
,
100 const wxString
& strArg
= wxEmptyString
);
101 virtual wxSize
DoGetBestClientSize() const;
103 virtual bool DoDrawBackground(wxDC
& dc
);
104 virtual void DoDraw(wxControlRenderer
*renderer
);
106 virtual bool CanBeHighlighted() const { return TRUE
; }
108 // common part of all ctors
115 // the (optional) image to show and the margins around it
117 wxCoord m_marginBmpX
,
121 DECLARE_DYNAMIC_CLASS(wxButton
)
124 // ----------------------------------------------------------------------------
125 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
126 // click into button press/release actions
127 // ----------------------------------------------------------------------------
129 class WXDLLEXPORT wxStdButtonInputHandler
: public wxStdInputHandler
132 wxStdButtonInputHandler(wxInputHandler
*inphand
);
134 virtual bool HandleKey(wxInputConsumer
*consumer
,
135 const wxKeyEvent
& event
,
137 virtual bool HandleMouse(wxInputConsumer
*consumer
,
138 const wxMouseEvent
& event
);
139 virtual bool HandleMouseMove(wxInputConsumer
*consumer
, const wxMouseEvent
& event
);
140 virtual bool HandleFocus(wxInputConsumer
*consumer
, const wxFocusEvent
& event
);
141 virtual bool HandleActivation(wxInputConsumer
*consumer
, bool activated
);
144 // the window (button) which has capture or NULL and the flag telling if
145 // the mouse is inside the button which captured it or not
146 wxWindow
*m_winCapture
;
150 #endif // _WX_UNIV_BUTTON_H_