]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/button.h
Added MSWPositionForWxMenu() method which is used to translate wxWindows
[wxWidgets.git] / include / wx / univ / button.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/button.h
3 // Purpose: wxButton for wxUniversal
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 15.08.00
7 // RCS-ID: $Id$
8 // Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_BUTTON_H_
13 #define _WX_UNIV_BUTTON_H_
14
15 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
16 #pragma interface "univbutton.h"
17 #endif
18
19 class WXDLLEXPORT wxInputHandler;
20
21 #include "wx/bitmap.h"
22
23 // ----------------------------------------------------------------------------
24 // the actions supported by this control
25 // ----------------------------------------------------------------------------
26
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
31
32 // ----------------------------------------------------------------------------
33 // wxButton: a push button
34 // ----------------------------------------------------------------------------
35
36 class WXDLLEXPORT wxButton : public wxButtonBase
37 {
38 public:
39 wxButton();
40 wxButton(wxWindow *parent,
41 wxWindowID id,
42 const wxBitmap& bitmap,
43 const wxString& label,
44 const wxPoint& pos = wxDefaultPosition,
45 const wxSize& size = wxDefaultSize,
46 long style = 0,
47 const wxValidator& validator = wxDefaultValidator,
48 const wxString& name = wxButtonNameStr);
49
50 wxButton(wxWindow *parent,
51 wxWindowID id,
52 const wxString& label,
53 const wxPoint& pos = wxDefaultPosition,
54 const wxSize& size = wxDefaultSize,
55 long style = 0,
56 const wxValidator& validator = wxDefaultValidator,
57 const wxString& name = wxButtonNameStr);
58
59 bool Create(wxWindow *parent,
60 wxWindowID id,
61 const wxString& label,
62 const wxPoint& pos = wxDefaultPosition,
63 const wxSize& size = wxDefaultSize,
64 long style = 0,
65 const wxValidator& validator = wxDefaultValidator,
66 const wxString& name = wxButtonNameStr)
67 {
68 return Create(parent, id, wxNullBitmap, label,
69 pos, size, style, validator, name);
70 }
71
72 bool Create(wxWindow *parent,
73 wxWindowID id,
74 const wxBitmap& bitmap,
75 const wxString& label,
76 const wxPoint& pos = wxDefaultPosition,
77 const wxSize& size = wxDefaultSize,
78 long style = 0,
79 const wxValidator& validator = wxDefaultValidator,
80 const wxString& name = wxButtonNameStr);
81
82 virtual ~wxButton();
83
84 virtual void SetImageLabel(const wxBitmap& bitmap);
85 virtual void SetImageMargins(wxCoord x, wxCoord y);
86 virtual void SetDefault();
87
88 virtual bool IsPressed() const { return m_isPressed; }
89 virtual bool IsDefault() const { return m_isDefault; }
90
91 // wxButton actions
92 void Toggle();
93 virtual void Press();
94 virtual void Release();
95 virtual void Click();
96
97 protected:
98 virtual bool PerformAction(const wxControlAction& action,
99 long numArg = -1,
100 const wxString& strArg = wxEmptyString);
101 virtual wxSize DoGetBestClientSize() const;
102
103 virtual bool DoDrawBackground(wxDC& dc);
104 virtual void DoDraw(wxControlRenderer *renderer);
105
106 virtual bool CanBeHighlighted() const { return TRUE; }
107
108 // common part of all ctors
109 void Init();
110
111 // current state
112 bool m_isPressed,
113 m_isDefault;
114
115 // the (optional) image to show and the margins around it
116 wxBitmap m_bitmap;
117 wxCoord m_marginBmpX,
118 m_marginBmpY;
119
120 private:
121 DECLARE_DYNAMIC_CLASS(wxButton)
122 };
123
124 // ----------------------------------------------------------------------------
125 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
126 // click into button press/release actions
127 // ----------------------------------------------------------------------------
128
129 class WXDLLEXPORT wxStdButtonInputHandler : public wxStdInputHandler
130 {
131 public:
132 wxStdButtonInputHandler(wxInputHandler *inphand);
133
134 virtual bool HandleKey(wxInputConsumer *consumer,
135 const wxKeyEvent& event,
136 bool pressed);
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);
142
143 private:
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;
147 bool m_winHasMouse;
148 };
149
150 #endif // _WX_UNIV_BUTTON_H_
151