]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/control.h
Upport latest changes from 2_8 branch (print dialog
[wxWidgets.git] / include / wx / gtk / control.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: 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
16 //-----------------------------------------------------------------------------
17 // wxControl
18 //-----------------------------------------------------------------------------
19
20 // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget
21 extern "C" {
22 typedef GtkWidget* (*wxGtkWidgetNew_t)(void);
23 typedef GtkWidget* (*wxGtkWidgetNewFromStr_t)(const gchar*);
24 typedef GtkWidget* (*wxGtkWidgetNewFromAdj_t)(GtkAdjustment*);
25 }
26
27 class WXDLLIMPEXP_CORE wxControl : public wxControlBase
28 {
29 public:
30 wxControl();
31 wxControl(wxWindow *parent, wxWindowID id,
32 const wxPoint& pos = wxDefaultPosition,
33 const wxSize& size = wxDefaultSize, long style = 0,
34 const wxValidator& validator = wxDefaultValidator,
35 const wxString& name = wxControlNameStr)
36 {
37 Create(parent, id, pos, size, style, validator, name);
38 }
39
40 bool Create(wxWindow *parent, wxWindowID id,
41 const wxPoint& pos = wxDefaultPosition,
42 const wxSize& size = wxDefaultSize, long style = 0,
43 const wxValidator& validator = wxDefaultValidator,
44 const wxString& name = wxControlNameStr);
45
46
47 virtual wxVisualAttributes GetDefaultAttributes() const;
48
49 virtual void OnInternalIdle();
50
51 protected:
52 virtual wxSize DoGetBestSize() const;
53 void PostCreation(const wxSize& size);
54
55 // sets the label to the given string and also sets it for the given widget
56 void GTKSetLabelForLabel(GtkLabel *w, const wxString& label);
57 void GTKSetLabelWithMarkupForLabel(GtkLabel *w, const wxString& label);
58
59 // GtkFrame helpers
60 GtkWidget* GTKCreateFrame(const wxString& label);
61 void GTKSetLabelForFrame(GtkFrame *w, const wxString& label);
62 void GTKFrameApplyWidgetStyle(GtkFrame* w, GtkRcStyle* rc);
63 void GTKFrameSetMnemonicWidget(GtkFrame* w, GtkWidget* widget);
64
65 // remove mnemonics ("&"s) from the label
66 static wxString GTKRemoveMnemonics(const wxString& label);
67
68 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
69 static wxString GTKConvertMnemonics(const wxString &label);
70
71 // converts wx label to GTK+ labels preserving Pango markup
72 static wxString GTKConvertMnemonicsWithMarkup(const wxString& label);
73
74 // These are used by GetDefaultAttributes
75 static wxVisualAttributes
76 GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
77 bool useBase = false,
78 int state = -1);
79 static wxVisualAttributes
80 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t,
81 bool useBase = false,
82 int state = -1);
83 static wxVisualAttributes
84 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t,
85 bool useBase = false,
86 int state = -1);
87
88 static wxVisualAttributes
89 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t,
90 bool useBase = false,
91 int state = -1);
92
93 // Widgets that use the style->base colour for the BG colour should
94 // override this and return true.
95 virtual bool UseGTKStyleBase() const { return false; }
96
97 private:
98 DECLARE_DYNAMIC_CLASS(wxControl)
99 };
100
101 #endif // _WX_GTK_CONTROL_H_