]>
Commit | Line | Data |
---|---|---|
c801d85f KB |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: control.h | |
3 | // Purpose: | |
4 | // Author: Robert Roebling | |
dbf858b5 RR |
5 | // Id: $Id$ |
6 | // Copyright: (c) 1998 Robert Roebling, Julian Smart | |
65571936 | 7 | // Licence: wxWindows licence |
c801d85f KB |
8 | ///////////////////////////////////////////////////////////////////////////// |
9 | ||
c801d85f KB |
10 | #ifndef __GTKCONTROLH__ |
11 | #define __GTKCONTROLH__ | |
12 | ||
c801d85f KB |
13 | #include "wx/defs.h" |
14 | #include "wx/object.h" | |
15 | #include "wx/list.h" | |
16 | #include "wx/window.h" | |
17 | ||
18 | //----------------------------------------------------------------------------- | |
19 | // classes | |
20 | //----------------------------------------------------------------------------- | |
21 | ||
20123d49 | 22 | class WXDLLIMPEXP_CORE wxControl; |
c801d85f | 23 | |
b2ff89d6 VZ |
24 | typedef struct _GtkLabel GtkLabel; |
25 | typedef struct _GtkFrame GtkFrame; | |
26 | ||
c801d85f KB |
27 | //----------------------------------------------------------------------------- |
28 | // wxControl | |
29 | //----------------------------------------------------------------------------- | |
30 | ||
865bb325 VZ |
31 | // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget |
32 | extern "C" { | |
33 | typedef GtkWidget* (*wxGtkWidgetNew_t)(void); | |
34 | typedef GtkWidget* (*wxGtkWidgetNewFromStr_t)(const gchar*); | |
35 | typedef GtkWidget* (*wxGtkWidgetNewFromAdj_t)(GtkAdjustment*); | |
36 | } | |
37 | ||
20123d49 | 38 | class WXDLLIMPEXP_CORE wxControl : public wxControlBase |
c801d85f | 39 | { |
2a4f4a27 | 40 | public: |
8d99be5f | 41 | wxControl(); |
04165bec RR |
42 | wxControl(wxWindow *parent, wxWindowID id, |
43 | const wxPoint& pos = wxDefaultPosition, | |
44 | const wxSize& size = wxDefaultSize, long style = 0, | |
04165bec | 45 | const wxValidator& validator = wxDefaultValidator, |
04165bec RR |
46 | const wxString& name = wxControlNameStr) |
47 | { | |
674ac8b9 | 48 | Create(parent, id, pos, size, style, validator, name); |
04165bec | 49 | } |
8d772832 | 50 | |
04165bec RR |
51 | bool Create(wxWindow *parent, wxWindowID id, |
52 | const wxPoint& pos = wxDefaultPosition, | |
53 | const wxSize& size = wxDefaultSize, long style = 0, | |
04165bec | 54 | const wxValidator& validator = wxDefaultValidator, |
04165bec | 55 | const wxString& name = wxControlNameStr); |
2a4f4a27 | 56 | |
8d99be5f VZ |
57 | virtual void SetLabel( const wxString &label ); |
58 | virtual wxString GetLabel() const; | |
b2ff89d6 | 59 | |
9d522606 RD |
60 | virtual wxVisualAttributes GetDefaultAttributes() const; |
61 | ||
ef5c70f9 VZ |
62 | virtual void OnInternalIdle(); |
63 | ||
2a4f4a27 | 64 | protected: |
f68586e5 | 65 | virtual wxSize DoGetBestSize() const; |
abdeb9e7 RD |
66 | void PostCreation(const wxSize& size); |
67 | ||
b2ff89d6 VZ |
68 | // sets the label to the given string and also sets it for the given widget |
69 | void GTKSetLabelForLabel(GtkLabel *w, const wxString& label); | |
70 | ||
2e1f5012 VZ |
71 | // GtkFrame helpers |
72 | GtkWidget* GTKCreateFrame(const wxString& label); | |
b2ff89d6 | 73 | void GTKSetLabelForFrame(GtkFrame *w, const wxString& label); |
2e1f5012 VZ |
74 | void GTKFrameApplyWidgetStyle(GtkFrame* w, GtkRcStyle* rc); |
75 | void GTKFrameSetMnemonicWidget(GtkFrame* w, GtkWidget* widget); | |
b2ff89d6 VZ |
76 | |
77 | // remove mnemonics ("&"s) from the label | |
78 | static wxString GTKRemoveMnemonics(const wxString& label); | |
79 | ||
80 | // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s | |
81 | // | |
82 | // for GTK+ 1 (which doesn't support mnemonics) this is the same as | |
83 | // GTKRemoveMnemonics() | |
84 | static wxString GTKConvertMnemonics(const wxString &label); | |
f68586e5 | 85 | |
9d522606 RD |
86 | // These are used by GetDefaultAttributes |
87 | static wxVisualAttributes | |
88 | GetDefaultAttributesFromGTKWidget(GtkWidget* widget, | |
89 | bool useBase = false, | |
90 | int state = -1); | |
91 | static wxVisualAttributes | |
865bb325 | 92 | GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t, |
9d522606 RD |
93 | bool useBase = false, |
94 | int state = -1); | |
95 | static wxVisualAttributes | |
865bb325 | 96 | GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t, |
9d522606 RD |
97 | bool useBase = false, |
98 | int state = -1); | |
99 | ||
100 | static wxVisualAttributes | |
865bb325 | 101 | GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t, |
9d522606 RD |
102 | bool useBase = false, |
103 | int state = -1); | |
104 | ||
105 | // Widgets that use the style->base colour for the BG colour should | |
106 | // override this and return true. | |
107 | virtual bool UseGTKStyleBase() const { return false; } | |
108 | ||
b2ff89d6 VZ |
109 | // this field contains the label in wx format, i.e. with "&" mnemonics |
110 | wxString m_label; | |
8d772832 | 111 | |
738f9e5a RR |
112 | private: |
113 | DECLARE_DYNAMIC_CLASS(wxControl) | |
c801d85f KB |
114 | }; |
115 | ||
116 | #endif // __GTKCONTROLH__ |