]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/control.h
Fix wxMenu::GetTitle() before the menu is appended to the menu bar.
[wxWidgets.git] / include / wx / gtk / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: wx/gtk/control.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Copyright: (c) 1998 Robert Roebling, Julian Smart
6 // Licence: wxWindows licence
7 /////////////////////////////////////////////////////////////////////////////
8
9 #ifndef _WX_GTK_CONTROL_H_
10 #define _WX_GTK_CONTROL_H_
11
12 typedef struct _GtkLabel GtkLabel;
13 typedef struct _GtkFrame GtkFrame;
14 typedef struct _GtkEntry GtkEntry;
15
16 //-----------------------------------------------------------------------------
17 // wxControl
18 //-----------------------------------------------------------------------------
19
20 class WXDLLIMPEXP_CORE wxControl : public wxControlBase
21 {
22 typedef wxControlBase base_type;
23 public:
24 wxControl();
25 wxControl(wxWindow *parent, wxWindowID id,
26 const wxPoint& pos = wxDefaultPosition,
27 const wxSize& size = wxDefaultSize, long style = 0,
28 const wxValidator& validator = wxDefaultValidator,
29 const wxString& name = wxControlNameStr)
30 {
31 Create(parent, id, pos, size, style, validator, name);
32 }
33
34 bool Create(wxWindow *parent, wxWindowID id,
35 const wxPoint& pos = wxDefaultPosition,
36 const wxSize& size = wxDefaultSize, long style = 0,
37 const wxValidator& validator = wxDefaultValidator,
38 const wxString& name = wxControlNameStr);
39
40 virtual wxVisualAttributes GetDefaultAttributes() const;
41 #ifdef __WXGTK3__
42 virtual bool SetFont(const wxFont& font);
43 #endif
44
45 protected:
46 virtual wxSize DoGetBestSize() const;
47 void PostCreation(const wxSize& size);
48
49 // sets the label to the given string and also sets it for the given widget
50 void GTKSetLabelForLabel(GtkLabel *w, const wxString& label);
51 #if wxUSE_MARKUP
52 void GTKSetLabelWithMarkupForLabel(GtkLabel *w, const wxString& label);
53 #endif // wxUSE_MARKUP
54
55 // GtkFrame helpers
56 GtkWidget* GTKCreateFrame(const wxString& label);
57 void GTKSetLabelForFrame(GtkFrame *w, const wxString& label);
58 void GTKFrameApplyWidgetStyle(GtkFrame* w, GtkRcStyle* rc);
59 void GTKFrameSetMnemonicWidget(GtkFrame* w, GtkWidget* widget);
60
61 // remove mnemonics ("&"s) from the label
62 static wxString GTKRemoveMnemonics(const wxString& label);
63
64 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
65 static wxString GTKConvertMnemonics(const wxString &label);
66
67 // converts wx label to GTK+ labels preserving Pango markup
68 static wxString GTKConvertMnemonicsWithMarkup(const wxString& label);
69
70 // These are used by GetDefaultAttributes
71 static wxVisualAttributes
72 GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
73 bool useBase = false,
74 int state = 0);
75
76 // Widgets that use the style->base colour for the BG colour should
77 // override this and return true.
78 virtual bool UseGTKStyleBase() const { return false; }
79
80 // Fix sensitivity due to bug in GTK+ < 2.14
81 void GTKFixSensitivity(bool onlyIfUnderMouse = true);
82
83 // Ask GTK+ for preferred size. Use it after setting the font.
84 wxSize GTKGetPreferredSize(GtkWidget* widget) const;
85
86 // Inner margins in a GtkEntry
87 wxPoint GTKGetEntryMargins(GtkEntry* entry) const;
88
89 private:
90 DECLARE_DYNAMIC_CLASS(wxControl)
91 };
92
93 #endif // _WX_GTK_CONTROL_H_