1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/button.h
3 // Purpose: wxGTK wxButton class declaration
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_BUTTON_H_
11 #define _WX_GTK_BUTTON_H_
13 //-----------------------------------------------------------------------------
15 //-----------------------------------------------------------------------------
17 class WXDLLIMPEXP_CORE wxButton
: public wxButtonBase
20 wxButton() { Init(); }
21 wxButton(wxWindow
*parent
, wxWindowID id
,
22 const wxString
& label
= wxEmptyString
,
23 const wxPoint
& pos
= wxDefaultPosition
,
24 const wxSize
& size
= wxDefaultSize
, long style
= 0,
25 const wxValidator
& validator
= wxDefaultValidator
,
26 const wxString
& name
= wxButtonNameStr
)
30 Create(parent
, id
, label
, pos
, size
, style
, validator
, name
);
33 bool Create(wxWindow
*parent
, wxWindowID id
,
34 const wxString
& label
= wxEmptyString
,
35 const wxPoint
& pos
= wxDefaultPosition
,
36 const wxSize
& size
= wxDefaultSize
, long style
= 0,
37 const wxValidator
& validator
= wxDefaultValidator
,
38 const wxString
& name
= wxButtonNameStr
);
40 virtual wxWindow
*SetDefault();
41 virtual void SetLabel( const wxString
&label
);
42 virtual bool Enable( bool enable
= true );
47 static wxVisualAttributes
48 GetClassDefaultAttributes(wxWindowVariant variant
= wxWINDOW_VARIANT_NORMAL
);
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
); }
53 // called from GTK callbacks: they update the button state and call
55 void GTKMouseEnters();
56 void GTKMouseLeaves();
61 virtual wxSize
DoGetBestSize() const;
62 virtual void DoApplyWidgetStyle(GtkRcStyle
*style
);
64 virtual GdkWindow
*GTKGetWindow(wxArrayGdkWindows
& windows
) const;
66 virtual wxBitmap
DoGetBitmap(State which
) const;
67 virtual void DoSetBitmap(const wxBitmap
& bitmap
, State which
);
68 virtual void DoSetBitmapPosition(wxDirection dir
);
71 virtual bool DoSetLabelMarkup(const wxString
& markup
);
72 #endif // wxUSE_MARKUP
75 typedef wxButtonBase base_type
;
77 // common part of all ctors
84 // focus event handler: calls GTKUpdateBitmap()
85 void GTKOnFocus(wxFocusEvent
& event
);
87 // update the bitmap to correspond to the current button state
88 void GTKUpdateBitmap();
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;
95 // show the given bitmap (must be valid)
96 void GTKDoShowBitmap(const wxBitmap
& bitmap
);
98 // Return the GtkLabel used by this button.
99 GtkLabel
*GTKGetLabel() const;
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
105 wxBitmap m_bitmaps
[State_Max
];
107 // true iff mouse is currently over the button
110 // true iff the button is in pressed state
113 DECLARE_DYNAMIC_CLASS(wxButton
)
116 #endif // _WX_GTK_BUTTON_H_