control.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk1/control.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling, Julian Smart
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef __GTKCONTROLH__
  9. #define __GTKCONTROLH__
  10. #include "wx/defs.h"
  11. #include "wx/object.h"
  12. #include "wx/list.h"
  13. #include "wx/window.h"
  14. //-----------------------------------------------------------------------------
  15. // classes
  16. //-----------------------------------------------------------------------------
  17. class WXDLLIMPEXP_FWD_CORE wxControl;
  18. typedef struct _GtkLabel GtkLabel;
  19. typedef struct _GtkFrame GtkFrame;
  20. //-----------------------------------------------------------------------------
  21. // wxControl
  22. //-----------------------------------------------------------------------------
  23. // C-linkage function pointer types for GetDefaultAttributesFromGTKWidget
  24. extern "C" {
  25. typedef GtkWidget* (*wxGtkWidgetNew_t)(void);
  26. typedef GtkWidget* (*wxGtkWidgetNewFromStr_t)(const char*);
  27. typedef GtkWidget* (*wxGtkWidgetNewFromAdj_t)(GtkAdjustment*);
  28. }
  29. class WXDLLIMPEXP_CORE wxControl : public wxControlBase
  30. {
  31. public:
  32. wxControl();
  33. wxControl(wxWindow *parent, wxWindowID id,
  34. const wxPoint& pos = wxDefaultPosition,
  35. const wxSize& size = wxDefaultSize, long style = 0,
  36. const wxValidator& validator = wxDefaultValidator,
  37. const wxString& name = wxControlNameStr)
  38. {
  39. Create(parent, id, pos, size, style, validator, name);
  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. virtual void SetLabel( const wxString &label );
  47. virtual wxString GetLabel() const;
  48. virtual wxVisualAttributes GetDefaultAttributes() const;
  49. protected:
  50. virtual wxSize DoGetBestSize() const;
  51. void PostCreation(const wxSize& size);
  52. // sets the label to the given string and also sets it for the given widget
  53. void GTKSetLabelForLabel(GtkLabel *w, const wxString& label);
  54. // as GTKSetLabelForLabel() but for a GtkFrame widget
  55. void GTKSetLabelForFrame(GtkFrame *w, const wxString& label);
  56. // remove mnemonics ("&"s) from the label
  57. static wxString GTKRemoveMnemonics(const wxString& label);
  58. // These are used by GetDefaultAttributes
  59. static wxVisualAttributes
  60. GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
  61. bool useBase = false,
  62. int state = -1);
  63. static wxVisualAttributes
  64. GetDefaultAttributesFromGTKWidget(wxGtkWidgetNew_t,
  65. bool useBase = false,
  66. int state = -1);
  67. static wxVisualAttributes
  68. GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromStr_t,
  69. bool useBase = false,
  70. int state = -1);
  71. static wxVisualAttributes
  72. GetDefaultAttributesFromGTKWidget(wxGtkWidgetNewFromAdj_t,
  73. bool useBase = false,
  74. int state = -1);
  75. // Widgets that use the style->base colour for the BG colour should
  76. // override this and return true.
  77. virtual bool UseGTKStyleBase() const { return false; }
  78. // this field contains the label in wx format, i.e. with "&" mnemonics
  79. wxString m_label;
  80. private:
  81. DECLARE_DYNAMIC_CLASS(wxControl)
  82. };
  83. #endif // __GTKCONTROLH__