]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/button.h
start of alpha transparency support
[wxWidgets.git] / include / wx / univ / button.h
CommitLineData
1e6feb95
VZ
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$
442b35b5 8// Copyright: (c) 2000 SciTech Software, Inc. (www.scitechsoft.com)
1e6feb95
VZ
9// Licence: wxWindows license
10///////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_UNIV_BUTTON_H_
13#define _WX_UNIV_BUTTON_H_
14
15#ifdef __GNUG__
a3870b2f 16 #pragma interface "univbutton.h"
1e6feb95
VZ
17#endif
18
19class 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
36class WXDLLEXPORT wxButton : public wxButtonBase
37{
38public:
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
107protected:
108 virtual bool PerformAction(const wxControlAction& action,
109 long numArg = -1,
110 const wxString& strArg = wxEmptyString);
111 virtual wxSize DoGetBestClientSize() const;
193e19cf
RR
112
113 virtual bool DoDrawBackground(wxDC& dc);
1e6feb95
VZ
114 virtual void DoDraw(wxControlRenderer *renderer);
115
116 virtual bool CanBeHighlighted() const { return TRUE; }
117
118 // common part of all ctors
119 void Init();
120
121 // current state
122 bool m_isPressed,
123 m_isDefault;
124
125 // the (optional) image to show and the margins around it
126 wxBitmap m_bitmap;
127 wxCoord m_marginBmpX,
128 m_marginBmpY;
129
130private:
131 DECLARE_DYNAMIC_CLASS(wxButton)
132};
133
134// ----------------------------------------------------------------------------
135// wxStdButtonInputHandler: translates SPACE and ENTER keys and the left mouse
136// click into button press/release actions
137// ----------------------------------------------------------------------------
138
139class WXDLLEXPORT wxStdButtonInputHandler : public wxStdInputHandler
140{
141public:
142 wxStdButtonInputHandler(wxInputHandler *inphand);
143
23645bfa 144 virtual bool HandleKey(wxInputConsumer *consumer,
1e6feb95
VZ
145 const wxKeyEvent& event,
146 bool pressed);
23645bfa 147 virtual bool HandleMouse(wxInputConsumer *consumer,
1e6feb95 148 const wxMouseEvent& event);
23645bfa
VS
149 virtual bool HandleMouseMove(wxInputConsumer *consumer, const wxMouseEvent& event);
150 virtual bool HandleFocus(wxInputConsumer *consumer, const wxFocusEvent& event);
151 virtual bool HandleActivation(wxInputConsumer *consumer, bool activated);
1e6feb95
VZ
152
153private:
154 // the window (button) which has capture or NULL and the flag telling if
155 // the mouse is inside the button which captured it or not
156 wxWindow *m_winCapture;
157 bool m_winHasMouse;
158};
159
160#endif // _WX_UNIV_BUTTON_H_
161