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
;
15 typedef struct _GtkEntry GtkEntry
;
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget
23 typedef GtkWidget
* (*wxGtkWidgetNew_t
)(void);
24 typedef GtkWidget
* (*wxGtkWidgetNewFromStr_t
)(const char*);
25 typedef GtkWidget
* (*wxGtkWidgetNewFromAdj_t
)(GtkAdjustment
*);
28 class WXDLLIMPEXP_CORE wxControl
: public wxControlBase
30 typedef wxControlBase base_type
;
33 wxControl(wxWindow
*parent
, wxWindowID id
,
34 const wxPoint
& pos
= wxDefaultPosition
,
35 const wxSize
& size
= wxDefaultSize
, long style
= 0,
36 const wxValidator
& validator
= wxDefaultValidator
,
37 const wxString
& name
= wxControlNameStr
)
39 Create(parent
, id
, pos
, size
, style
, validator
, name
);
42 bool Create(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 virtual wxVisualAttributes
GetDefaultAttributes() const;
50 virtual bool SetFont(const wxFont
& font
);
54 virtual wxSize
DoGetBestSize() const;
55 void PostCreation(const wxSize
& size
);
57 // sets the label to the given string and also sets it for the given widget
58 void GTKSetLabelForLabel(GtkLabel
*w
, const wxString
& label
);
60 void GTKSetLabelWithMarkupForLabel(GtkLabel
*w
, const wxString
& label
);
61 #endif // wxUSE_MARKUP
64 GtkWidget
* GTKCreateFrame(const wxString
& label
);
65 void GTKSetLabelForFrame(GtkFrame
*w
, const wxString
& label
);
66 void GTKFrameApplyWidgetStyle(GtkFrame
* w
, GtkRcStyle
* rc
);
67 void GTKFrameSetMnemonicWidget(GtkFrame
* w
, GtkWidget
* widget
);
69 // remove mnemonics ("&"s) from the label
70 static wxString
GTKRemoveMnemonics(const wxString
& label
);
72 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
73 static wxString
GTKConvertMnemonics(const wxString
&label
);
75 // converts wx label to GTK+ labels preserving Pango markup
76 static wxString
GTKConvertMnemonicsWithMarkup(const wxString
& label
);
78 // These are used by GetDefaultAttributes
79 static wxVisualAttributes
80 GetDefaultAttributesFromGTKWidget(GtkWidget
* widget
,
83 static wxVisualAttributes
84 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t
,
87 static wxVisualAttributes
88 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t
,
92 static wxVisualAttributes
93 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t
,
97 // Widgets that use the style->base colour for the BG colour should
98 // override this and return true.
99 virtual bool UseGTKStyleBase() const { return false; }
101 // Fix sensitivity due to bug in GTK+ < 2.14
102 void GTKFixSensitivity(bool onlyIfUnderMouse
= true);
104 // Ask GTK+ for preferred size. Use it after setting the font.
105 wxSize
GTKGetPreferredSize(GtkWidget
* widget
) const;
107 // Inner margins in a GtkEntry
108 wxPoint
GTKGetEntryMargins(GtkEntry
* entry
) const;
111 DECLARE_DYNAMIC_CLASS(wxControl
)
114 #endif // _WX_GTK_CONTROL_H_