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