1 ///////////////////////////////////////////////////////////////////////////// 2 // Name: control.h 3 // Purpose: 4 // Author: Robert Roebling 5 // Id: $Id: control.h 58191 2009-01-18 12:21:04Z JS $ 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 virtual void SetLabel( const wxString &label ); 47 virtual wxString GetLabel() const; 48 49 virtual wxVisualAttributes GetDefaultAttributes() const; 50 51 virtual void OnInternalIdle(); 52 53 protected: 54 virtual wxSize DoGetBestSize() const; 55 void PostCreation(const wxSize& size); 56 57 // sets the label to the given string and also sets it for the given widget 58 void GTKSetLabelForLabel(GtkLabel *w, const wxString& label); 59 60 // GtkFrame helpers 61 GtkWidget* GTKCreateFrame(const wxString& label); 62 void GTKSetLabelForFrame(GtkFrame *w, const wxString& label); 63 void GTKFrameApplyWidgetStyle(GtkFrame* w, GtkRcStyle* rc); 64 void GTKFrameSetMnemonicWidget(GtkFrame* w, GtkWidget* widget); 65 66 // remove mnemonics ("&"s) from the label 67 static wxString GTKRemoveMnemonics(const wxString& label); 68 69 // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s 70 // 71 // for GTK+ 1 (which doesn't support mnemonics) this is the same as 72 // GTKRemoveMnemonics() 73 static wxString GTKConvertMnemonics(const wxString &label); 74 75 // These are used by GetDefaultAttributes 76 static wxVisualAttributes 77 GetDefaultAttributesFromGTKWidget(GtkWidget* widget, 78 bool useBase = false, 79 int state = -1); 80 static wxVisualAttributes 81 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t, 82 bool useBase = false, 83 int state = -1); 84 static wxVisualAttributes 85 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t, 86 bool useBase = false, 87 int state = -1); 88 89 static wxVisualAttributes 90 GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t, 91 bool useBase = false, 92 int state = -1); 93 94 // Widgets that use the style->base colour for the BG colour should 95 // override this and return true. UseGTKStyleBase()96 virtual bool UseGTKStyleBase() const { return false; } 97 98 // this field contains the label in wx format, i.e. with "&" mnemonics 99 wxString m_label; 100 101 private: 102 DECLARE_DYNAMIC_CLASS(wxControl) 103 }; 104 105 // Fix sensitivity due to bug in GTK+ < 2.14 106 void WXDLLEXPORT wxGtkFixSensitivity(wxWindow* ctrl); 107 108 #endif // _WX_GTK_CONTROL_H_ 109