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