choice.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk1/choice.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef __GTKCHOICEH__
  9. #define __GTKCHOICEH__
  10. class WXDLLIMPEXP_FWD_BASE wxSortedArrayString;
  11. class WXDLLIMPEXP_FWD_BASE wxArrayString;
  12. //-----------------------------------------------------------------------------
  13. // wxChoice
  14. //-----------------------------------------------------------------------------
  15. class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
  16. {
  17. public:
  18. wxChoice();
  19. wxChoice( wxWindow *parent, wxWindowID id,
  20. const wxPoint& pos = wxDefaultPosition,
  21. const wxSize& size = wxDefaultSize,
  22. int n = 0, const wxString choices[] = (const wxString *) NULL,
  23. long style = 0,
  24. const wxValidator& validator = wxDefaultValidator,
  25. const wxString& name = wxChoiceNameStr )
  26. {
  27. m_strings = NULL;
  28. Create(parent, id, pos, size, n, choices, style, validator, name);
  29. }
  30. wxChoice( wxWindow *parent, wxWindowID id,
  31. const wxPoint& pos,
  32. const wxSize& size,
  33. const wxArrayString& choices,
  34. long style = 0,
  35. const wxValidator& validator = wxDefaultValidator,
  36. const wxString& name = wxChoiceNameStr )
  37. {
  38. m_strings = NULL;
  39. Create(parent, id, pos, size, choices, style, validator, name);
  40. }
  41. virtual ~wxChoice();
  42. bool Create( wxWindow *parent, wxWindowID id,
  43. const wxPoint& pos = wxDefaultPosition,
  44. const wxSize& size = wxDefaultSize,
  45. int n = 0, const wxString choices[] = NULL,
  46. long style = 0,
  47. const wxValidator& validator = wxDefaultValidator,
  48. const wxString& name = wxChoiceNameStr );
  49. bool Create( wxWindow *parent, wxWindowID id,
  50. const wxPoint& pos,
  51. const wxSize& size,
  52. const wxArrayString& choices,
  53. long style = 0,
  54. const wxValidator& validator = wxDefaultValidator,
  55. const wxString& name = wxChoiceNameStr );
  56. // implement base class pure virtuals
  57. void DoDeleteOneItem(unsigned int n);
  58. void DoClear();
  59. int GetSelection() const;
  60. virtual void SetSelection(int n);
  61. virtual unsigned int GetCount() const;
  62. virtual int FindString(const wxString& s, bool bCase = false) const;
  63. virtual wxString GetString(unsigned int n) const;
  64. virtual void SetString(unsigned int n, const wxString& string);
  65. static wxVisualAttributes
  66. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  67. protected:
  68. wxList m_clientList; // contains the client data for the items
  69. void DoApplyWidgetStyle(GtkRcStyle *style);
  70. virtual int DoInsertItems(const wxArrayStringsAdapter& items,
  71. unsigned int pos,
  72. void **clientData, wxClientDataType type);
  73. virtual void DoSetItemClientData(unsigned int n, void* clientData);
  74. virtual void* DoGetItemClientData(unsigned int n) const;
  75. virtual wxSize DoGetBestSize() const;
  76. virtual bool IsOwnGtkWindow( GdkWindow *window );
  77. private:
  78. // DoInsertItems() helper
  79. int GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item);
  80. // this array is only used for controls with wxCB_SORT style, so only
  81. // allocate it if it's needed (hence using pointer)
  82. wxSortedArrayString *m_strings;
  83. public:
  84. // this circumvents a GTK+ 2.0 bug so that the selection is
  85. // invalidated properly
  86. int m_selection_hack;
  87. private:
  88. DECLARE_DYNAMIC_CLASS(wxChoice)
  89. };
  90. #endif // __GTKCHOICEH__