]> git.saurik.com Git - wxWidgets.git/blob - include/wx/univ/button.h
made the log dialog resizeable (again?)
[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 license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_UNIV_BUTTON_H_
13 #define _WX_UNIV_BUTTON_H_
14
15 #ifdef __GNUG__
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() { Init(); }
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 Init();
51
52 Create(parent, id, bitmap, label, pos, size, style, validator, name);
53 }
54
55 wxButton(wxWindow *parent,
56 wxWindowID id,
57 const wxString& label,
58 const wxPoint& pos = wxDefaultPosition,
59 const wxSize& size = wxDefaultSize,
60 long style = 0,
61 const wxValidator& validator = wxDefaultValidator,
62 const wxString& name = wxButtonNameStr)
63 {
64 Init();
65
66 Create(parent, id, label, pos, size, style, validator, name);
67 }
68
69 bool Create(wxWindow *parent,
70 wxWindowID id,
71 const wxString& label,
72 const wxPoint& pos = wxDefaultPosition,
73 const wxSize& size = wxDefaultSize,
74 long style = 0,
75 const wxValidator& validator = wxDefaultValidator,
76 const wxString& name = wxButtonNameStr)
77 {
78 return Create(parent, id, wxNullBitmap, label,
79 pos, size, style, validator, name);
80 }
81
82 bool Create(wxWindow *parent,
83 wxWindowID id,
84 const wxBitmap& bitmap,
85 const wxString& label,
86 const wxPoint& pos = wxDefaultPosition,
87 const wxSize& size = wxDefaultSize,
88 long style = 0,
89 const wxValidator& validator = wxDefaultValidator,
90 const wxString& name = wxButtonNameStr);
91
92 virtual ~wxButton();
93
94 virtual void SetImageLabel(const wxBitmap& bitmap);
95 virtual void SetImageMargins(wxCoord x, wxCoord y);
96 virtual void SetDefault();
97
98 virtual bool IsPressed() const { return m_isPressed; }
99 virtual bool IsDefault() const { return m_isDefault; }
100
101 // wxButton actions
102 void Toggle();
103 virtual void Press();
104 virtual void Release();
105 virtual void Click();
106
107 protected:
108 virtual bool PerformAction(const wxControlAction& action,
109 long numArg = -1,
110 const wxString& strArg = wxEmptyString);
111 virtual wxSize DoGetBestClientSize() const;
112 virtual void DoDraw(wxControlRenderer *renderer);
113
114 virtual bool CanBeHighlighted() const { return TRUE; }
115
116 // common part of all ctors
117 void Init();
118
119 // current state
120 bool m_isPressed,
121 m_isDefault;
122
123 // the (optional) image to show and the margins around it
124 wxBitmap m_bitmap;
125 wxCoord m_marginBmpX,
126 m_marginBmpY;
127
128 private:
129 DECLARE_DYNAMIC_CLASS(wxButton)
130 };
131
132 // ----------------------------------------------------------------------------
133 // wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
134 // click into button press/release actions
135 // ----------------------------------------------------------------------------
136
137 class WXDLLEXPORT wxStdButtonInputHandler : public wxStdInputHandler
138 {
139 public:
140 wxStdButtonInputHandler(wxInputHandler *inphand);
141
142 virtual bool HandleKey(wxControl *control,
143 const wxKeyEvent& event,
144 bool pressed);
145 virtual bool HandleMouse(wxControl *control,
146 const wxMouseEvent& event);
147 virtual bool HandleMouseMove(wxControl *control, const wxMouseEvent& event);
148 virtual bool HandleFocus(wxControl *control, const wxFocusEvent& event);
149 virtual bool HandleActivation(wxControl *control, bool activated);
150
151 private:
152 // the window (button) which has capture or NULL and the flag telling if
153 // the mouse is inside the button which captured it or not
154 wxWindow *m_winCapture;
155 bool m_winHasMouse;
156 };
157
158 #endif // _WX_UNIV_BUTTON_H_
159