1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKCONTROLH__
11 #define __GTKCONTROLH__
14 #include "wx/object.h"
16 #include "wx/window.h"
18 //-----------------------------------------------------------------------------
20 //-----------------------------------------------------------------------------
22 class WXDLLIMPEXP_CORE wxControl
;
24 typedef struct _GtkLabel GtkLabel
;
25 typedef struct _GtkFrame GtkFrame
;
27 //-----------------------------------------------------------------------------
29 //-----------------------------------------------------------------------------
31 // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget
33 typedef GtkWidget
* (*wxGtkWidgetNew_t
)(void);
34 typedef GtkWidget
* (*wxGtkWidgetNewFromStr_t
)(const gchar
*);
35 typedef GtkWidget
* (*wxGtkWidgetNewFromAdj_t
)(GtkAdjustment
*);
38 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
42 wxControl(wxWindow
*parent
, wxWindowID id
,
43 const wxPoint
& pos
= wxDefaultPosition
,
44 const wxSize
& size
= wxDefaultSize
, long style
= 0,
45 const wxValidator
& validator
= wxDefaultValidator
,
46 const wxString
& name
= wxControlNameStr
)
48 Create(parent
, id
, pos
, size
, style
, validator
, name
);
51 bool Create(wxWindow
*parent
, wxWindowID id
,
52 const wxPoint
& pos
= wxDefaultPosition
,
53 const wxSize
& size
= wxDefaultSize
, long style
= 0,
54 const wxValidator
& validator
= wxDefaultValidator
,
55 const wxString
& name
= wxControlNameStr
);
57 virtual void SetLabel( const wxString
&label
);
58 virtual wxString
GetLabel() const;
60 virtual wxVisualAttributes
GetDefaultAttributes() const;
62 virtual void OnInternalIdle();
65 virtual wxSize
DoGetBestSize() const;
66 void PostCreation(const wxSize
& size
);
68 // sets the label to the given string and also sets it for the given widget
69 void GTKSetLabelForLabel(GtkLabel
*w
, const wxString
& label
);
72 GtkWidget
* GTKCreateFrame(const wxString
& label
);
73 void GTKSetLabelForFrame(GtkFrame
*w
, const wxString
& label
);
74 void GTKFrameApplyWidgetStyle(GtkFrame
* w
, GtkRcStyle
* rc
);
75 void GTKFrameSetMnemonicWidget(GtkFrame
* w
, GtkWidget
* widget
);
77 // remove mnemonics ("&"s) from the label
78 static wxString
GTKRemoveMnemonics(const wxString
& label
);
80 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
82 // for GTK+ 1 (which doesn't support mnemonics) this is the same as
83 // GTKRemoveMnemonics()
84 static wxString
GTKConvertMnemonics(const wxString
&label
);
86 // These are used by GetDefaultAttributes
87 static wxVisualAttributes
88 GetDefaultAttributesFromGTKWidget(GtkWidget
* widget
,
91 static wxVisualAttributes
92 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t
,
95 static wxVisualAttributes
96 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t
,
100 static wxVisualAttributes
101 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t
,
102 bool useBase
= false,
105 // Widgets that use the style->base colour for the BG colour should
106 // override this and return true.
107 virtual bool UseGTKStyleBase() const { return false; }
109 // this field contains the label in wx format, i.e. with "&" mnemonics
113 DECLARE_DYNAMIC_CLASS(wxControl
)
116 #endif // __GTKCONTROLH__