]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/control.h
5c288d0aa63bf1cbb7be32d1922becd7bf2ac652
[wxWidgets.git] / include / wx / gtk / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/control.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_GTK_CONTROL_H_
11 #define _WX_GTK_CONTROL_H_
12
13 typedef struct _GtkLabel GtkLabel;
14 typedef struct _GtkFrame GtkFrame;
15 typedef struct _GtkEntry GtkEntry;
16
17 //-----------------------------------------------------------------------------
18 // wxControl
19 //-----------------------------------------------------------------------------
20
21 // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget
22 extern "C" {
23 typedef GtkWidget* (*wxGtkWidgetNew_t)(void);
24 typedef GtkWidget* (*wxGtkWidgetNewFromStr_t)(const char*);
25 typedef GtkWidget* (*wxGtkWidgetNewFromAdj_t)(GtkAdjustment*);
26 }
27
28 class WXDLLIMPEXP_CORE wxControl : public wxControlBase
29 {
30 typedef wxControlBase base_type;
31 public:
32 wxControl();
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)
38 {
39 Create(parent, id, pos, size, style, validator, name);
40 }
41
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);
47
48 virtual wxVisualAttributes GetDefaultAttributes() const;
49 #ifdef __WXGTK3__
50 virtual bool SetFont(const wxFont& font);
51 #endif
52
53 protected:
54 virtual wxSize DoGetBestSize() const;
55 void PostCreation(const wxSize& size);
56
57 // sets the label to the given string and also sets it for the given widget
58 void GTKSetLabelForLabel(GtkLabel *w, const wxString& label);
59 #if wxUSE_MARKUP
60 void GTKSetLabelWithMarkupForLabel(GtkLabel *w, const wxString& label);
61 #endif // wxUSE_MARKUP
62
63 // GtkFrame helpers
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);
68
69 // remove mnemonics ("&"s) from the label
70 static wxString GTKRemoveMnemonics(const wxString& label);
71
72 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
73 static wxString GTKConvertMnemonics(const wxString &label);
74
75 // converts wx label to GTK+ labels preserving Pango markup
76 static wxString GTKConvertMnemonicsWithMarkup(const wxString& label);
77
78 // These are used by GetDefaultAttributes
79 static wxVisualAttributes
80 GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
81 bool useBase = false,
82 int state = 0);
83 static wxVisualAttributes
84 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t,
85 bool useBase = false,
86 int state = 0);
87 static wxVisualAttributes
88 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t,
89 bool useBase = false,
90 int state = 0);
91
92 static wxVisualAttributes
93 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t,
94 bool useBase = false,
95 int state = 0);
96
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; }
100
101 // Fix sensitivity due to bug in GTK+ < 2.14
102 void GTKFixSensitivity(bool onlyIfUnderMouse = true);
103
104 // Ask GTK+ for preferred size. Use it after setting the font.
105 wxSize GTKGetPreferredSize(GtkWidget* widget) const;
106
107 // Inner margins in a GtkEntry
108 wxPoint GTKGetEntryMargins(GtkEntry* entry) const;
109
110 private:
111 DECLARE_DYNAMIC_CLASS(wxControl)
112 };
113
114 #endif // _WX_GTK_CONTROL_H_