]>
Commit | Line | Data |
---|---|---|
c801d85f | 1 | ///////////////////////////////////////////////////////////////////////////// |
6b0d8a01 | 2 | // Name: wx/gtk/button.h |
7be740a3 | 3 | // Purpose: wxGTK wxButton class declaration |
c801d85f | 4 | // Author: Robert Roebling |
dbf858b5 | 5 | // Id: $Id$ |
01111366 | 6 | // Copyright: (c) 1998 Robert Roebling |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
0416c418 PC |
10 | #ifndef _WX_GTK_BUTTON_H_ |
11 | #define _WX_GTK_BUTTON_H_ | |
c801d85f KB |
12 | |
13 | //----------------------------------------------------------------------------- | |
14 | // wxButton | |
15 | //----------------------------------------------------------------------------- | |
16 | ||
7be740a3 | 17 | class WXDLLIMPEXP_CORE wxButton : public wxButtonBase |
c801d85f | 18 | { |
738f9e5a | 19 | public: |
b4a4eafb | 20 | wxButton() { Init(); } |
5f7bcb48 VS |
21 | wxButton(wxWindow *parent, wxWindowID id, |
22 | const wxString& label = wxEmptyString, | |
6de97a3b RR |
23 | const wxPoint& pos = wxDefaultPosition, |
24 | const wxSize& size = wxDefaultSize, long style = 0, | |
25 | const wxValidator& validator = wxDefaultValidator, | |
26 | const wxString& name = wxButtonNameStr) | |
27 | { | |
b4a4eafb VZ |
28 | Init(); |
29 | ||
401e3b6e | 30 | Create(parent, id, label, pos, size, style, validator, name); |
6de97a3b | 31 | } |
401e3b6e | 32 | |
5f7bcb48 VS |
33 | bool Create(wxWindow *parent, wxWindowID id, |
34 | const wxString& label = wxEmptyString, | |
6de97a3b RR |
35 | const wxPoint& pos = wxDefaultPosition, |
36 | const wxSize& size = wxDefaultSize, long style = 0, | |
37 | const wxValidator& validator = wxDefaultValidator, | |
38 | const wxString& name = wxButtonNameStr); | |
6b0d8a01 | 39 | |
94aff5ff | 40 | virtual wxWindow *SetDefault(); |
6b0d8a01 | 41 | virtual void SetLabel( const wxString &label ); |
7be740a3 | 42 | virtual bool Enable( bool enable = true ); |
8dbf4589 | 43 | |
20e05ffb RR |
44 | // implementation |
45 | // -------------- | |
6b0d8a01 | 46 | |
9d522606 RD |
47 | static wxVisualAttributes |
48 | GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL); | |
49 | ||
6f02a879 VZ |
50 | // helper to allow access to protected member from GTK callback |
51 | void MoveWindow(int x, int y, int width, int height) { DoMoveWindow(x, y, width, height); } | |
52 | ||
b4a4eafb VZ |
53 | // called from GTK callbacks: they update the button state and call |
54 | // GTKUpdateBitmap() | |
55 | void GTKMouseEnters(); | |
56 | void GTKMouseLeaves(); | |
57 | void GTKPressed(); | |
58 | void GTKReleased(); | |
59 | ||
db434467 RR |
60 | protected: |
61 | virtual wxSize DoGetBestSize() const; | |
ef5c70f9 VZ |
62 | virtual void DoApplyWidgetStyle(GtkRcStyle *style); |
63 | ||
64 | virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const; | |
db434467 | 65 | |
7be740a3 VZ |
66 | virtual wxBitmap DoGetBitmap(State which) const; |
67 | virtual void DoSetBitmap(const wxBitmap& bitmap, State which); | |
68 | virtual void DoSetBitmapPosition(wxDirection dir); | |
69 | ||
de1cc378 VZ |
70 | #if wxUSE_MARKUP |
71 | virtual bool DoSetLabelMarkup(const wxString& markup); | |
72 | #endif // wxUSE_MARKUP | |
73 | ||
738f9e5a | 74 | private: |
b545684e PC |
75 | typedef wxButtonBase base_type; |
76 | ||
b4a4eafb VZ |
77 | // common part of all ctors |
78 | void Init() | |
79 | { | |
80 | m_isCurrent = | |
81 | m_isPressed = false; | |
82 | } | |
83 | ||
84 | // focus event handler: calls GTKUpdateBitmap() | |
85 | void GTKOnFocus(wxFocusEvent& event); | |
86 | ||
87 | // update the bitmap to correspond to the current button state | |
88 | void GTKUpdateBitmap(); | |
89 | ||
90 | // return the current button state from m_isXXX flags (which means that it | |
91 | // might not correspond to the real current state as e.g. m_isCurrent will | |
92 | // never be true if we don't have a valid current bitmap) | |
93 | State GTKGetCurrentState() const; | |
94 | ||
95 | // show the given bitmap (must be valid) | |
96 | void GTKDoShowBitmap(const wxBitmap& bitmap); | |
97 | ||
de1cc378 VZ |
98 | // Return the GtkLabel used by this button. |
99 | GtkLabel *GTKGetLabel() const; | |
100 | ||
101 | ||
b4a4eafb VZ |
102 | // the bitmaps for the different state of the buttons, all of them may be |
103 | // invalid and the button only shows a bitmap at all if State_Normal bitmap | |
104 | // is valid | |
7be740a3 VZ |
105 | wxBitmap m_bitmaps[State_Max]; |
106 | ||
b4a4eafb VZ |
107 | // true iff mouse is currently over the button |
108 | bool m_isCurrent; | |
109 | ||
110 | // true iff the button is in pressed state | |
111 | bool m_isPressed; | |
112 | ||
738f9e5a | 113 | DECLARE_DYNAMIC_CLASS(wxButton) |
c801d85f KB |
114 | }; |
115 | ||
0416c418 | 116 | #endif // _WX_GTK_BUTTON_H_ |