1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/control.h
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_GTK_CONTROL_H_
11 #define _WX_GTK_CONTROL_H_
13 typedef struct _GtkLabel GtkLabel
;
14 typedef struct _GtkFrame GtkFrame
;
16 //-----------------------------------------------------------------------------
18 //-----------------------------------------------------------------------------
20 // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget
22 typedef GtkWidget
* (*wxGtkWidgetNew_t
)(void);
23 typedef GtkWidget
* (*wxGtkWidgetNewFromStr_t
)(const char*);
24 typedef GtkWidget
* (*wxGtkWidgetNewFromAdj_t
)(GtkAdjustment
*);
27 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
29 typedef wxControlBase base_type
;
32 wxControl(wxWindow
*parent
, wxWindowID id
,
33 const wxPoint
& pos
= wxDefaultPosition
,
34 const wxSize
& size
= wxDefaultSize
, long style
= 0,
35 const wxValidator
& validator
= wxDefaultValidator
,
36 const wxString
& name
= wxControlNameStr
)
38 Create(parent
, id
, pos
, size
, style
, validator
, name
);
41 bool Create(wxWindow
*parent
, wxWindowID id
,
42 const wxPoint
& pos
= wxDefaultPosition
,
43 const wxSize
& size
= wxDefaultSize
, long style
= 0,
44 const wxValidator
& validator
= wxDefaultValidator
,
45 const wxString
& name
= wxControlNameStr
);
47 virtual wxVisualAttributes
GetDefaultAttributes() const;
49 virtual bool SetFont(const wxFont
& font
);
53 virtual wxSize
DoGetBestSize() const;
54 void PostCreation(const wxSize
& size
);
56 // sets the label to the given string and also sets it for the given widget
57 void GTKSetLabelForLabel(GtkLabel
*w
, const wxString
& label
);
59 void GTKSetLabelWithMarkupForLabel(GtkLabel
*w
, const wxString
& label
);
60 #endif // wxUSE_MARKUP
63 GtkWidget
* GTKCreateFrame(const wxString
& label
);
64 void GTKSetLabelForFrame(GtkFrame
*w
, const wxString
& label
);
65 void GTKFrameApplyWidgetStyle(GtkFrame
* w
, GtkRcStyle
* rc
);
66 void GTKFrameSetMnemonicWidget(GtkFrame
* w
, GtkWidget
* widget
);
68 // remove mnemonics ("&"s) from the label
69 static wxString
GTKRemoveMnemonics(const wxString
& label
);
71 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
72 static wxString
GTKConvertMnemonics(const wxString
&label
);
74 // converts wx label to GTK+ labels preserving Pango markup
75 static wxString
GTKConvertMnemonicsWithMarkup(const wxString
& label
);
77 // These are used by GetDefaultAttributes
78 static wxVisualAttributes
79 GetDefaultAttributesFromGTKWidget(GtkWidget
* widget
,
82 static wxVisualAttributes
83 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t
,
86 static wxVisualAttributes
87 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t
,
91 static wxVisualAttributes
92 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t
,
96 // Widgets that use the style->base colour for the BG colour should
97 // override this and return true.
98 virtual bool UseGTKStyleBase() const { return false; }
100 // Fix sensitivity due to bug in GTK+ < 2.14
101 void GTKFixSensitivity(bool onlyIfUnderMouse
= true);
104 DECLARE_DYNAMIC_CLASS(wxControl
)
107 #endif // _WX_GTK_CONTROL_H_