control.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/control.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling, Julian Smart
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_GTK_CONTROL_H_
  9. #define _WX_GTK_CONTROL_H_
  10. typedef struct _GtkLabel GtkLabel;
  11. typedef struct _GtkFrame GtkFrame;
  12. typedef struct _GtkEntry GtkEntry;
  13. //-----------------------------------------------------------------------------
  14. // wxControl
  15. //-----------------------------------------------------------------------------
  16. class WXDLLIMPEXP_CORE wxControl : public wxControlBase
  17. {
  18. typedef wxControlBase base_type;
  19. public:
  20. wxControl();
  21. wxControl(wxWindow *parent, wxWindowID id,
  22. const wxPoint& pos = wxDefaultPosition,
  23. const wxSize& size = wxDefaultSize, long style = 0,
  24. const wxValidator& validator = wxDefaultValidator,
  25. const wxString& name = wxControlNameStr)
  26. {
  27. Create(parent, id, pos, size, style, validator, name);
  28. }
  29. bool Create(wxWindow *parent, wxWindowID id,
  30. const wxPoint& pos = wxDefaultPosition,
  31. const wxSize& size = wxDefaultSize, long style = 0,
  32. const wxValidator& validator = wxDefaultValidator,
  33. const wxString& name = wxControlNameStr);
  34. virtual wxVisualAttributes GetDefaultAttributes() const;
  35. #ifdef __WXGTK3__
  36. virtual bool SetFont(const wxFont& font);
  37. #endif
  38. protected:
  39. virtual wxSize DoGetBestSize() const;
  40. void PostCreation(const wxSize& size);
  41. // sets the label to the given string and also sets it for the given widget
  42. void GTKSetLabelForLabel(GtkLabel *w, const wxString& label);
  43. #if wxUSE_MARKUP
  44. void GTKSetLabelWithMarkupForLabel(GtkLabel *w, const wxString& label);
  45. #endif // wxUSE_MARKUP
  46. // GtkFrame helpers
  47. GtkWidget* GTKCreateFrame(const wxString& label);
  48. void GTKSetLabelForFrame(GtkFrame *w, const wxString& label);
  49. void GTKFrameApplyWidgetStyle(GtkFrame* w, GtkRcStyle* rc);
  50. void GTKFrameSetMnemonicWidget(GtkFrame* w, GtkWidget* widget);
  51. // remove mnemonics ("&"s) from the label
  52. static wxString GTKRemoveMnemonics(const wxString& label);
  53. // converts wx label to GTK+ label, i.e. basically replace "&"s with "_"s
  54. static wxString GTKConvertMnemonics(const wxString &label);
  55. // converts wx label to GTK+ labels preserving Pango markup
  56. static wxString GTKConvertMnemonicsWithMarkup(const wxString& label);
  57. // These are used by GetDefaultAttributes
  58. static wxVisualAttributes
  59. GetDefaultAttributesFromGTKWidget(GtkWidget* widget,
  60. bool useBase = false,
  61. int state = 0);
  62. // Widgets that use the style->base colour for the BG colour should
  63. // override this and return true.
  64. virtual bool UseGTKStyleBase() const { return false; }
  65. // Fix sensitivity due to bug in GTK+ < 2.14
  66. void GTKFixSensitivity(bool onlyIfUnderMouse = true);
  67. // Ask GTK+ for preferred size. Use it after setting the font.
  68. wxSize GTKGetPreferredSize(GtkWidget* widget) const;
  69. // Inner margins in a GtkEntry
  70. wxPoint GTKGetEntryMargins(GtkEntry* entry) const;
  71. private:
  72. DECLARE_DYNAMIC_CLASS(wxControl)
  73. };
  74. #endif // _WX_GTK_CONTROL_H_