choice.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/gtk/choice.h
  3. // Purpose:
  4. // Author: Robert Roebling
  5. // Copyright: (c) 1998 Robert Roebling
  6. // Licence: wxWindows licence
  7. /////////////////////////////////////////////////////////////////////////////
  8. #ifndef _WX_GTK_CHOICE_H_
  9. #define _WX_GTK_CHOICE_H_
  10. class WXDLLIMPEXP_FWD_BASE wxSortedArrayString;
  11. class WXDLLIMPEXP_FWD_BASE wxArrayString;
  12. //-----------------------------------------------------------------------------
  13. // wxChoice
  14. //-----------------------------------------------------------------------------
  15. class wxGtkCollatedArrayString;
  16. class WXDLLIMPEXP_CORE wxChoice : public wxChoiceBase
  17. {
  18. public:
  19. wxChoice()
  20. {
  21. Init();
  22. }
  23. wxChoice( wxWindow *parent, wxWindowID id,
  24. const wxPoint& pos = wxDefaultPosition,
  25. const wxSize& size = wxDefaultSize,
  26. int n = 0, const wxString choices[] = (const wxString *) NULL,
  27. long style = 0,
  28. const wxValidator& validator = wxDefaultValidator,
  29. const wxString& name = wxChoiceNameStr )
  30. {
  31. Init();
  32. Create(parent, id, pos, size, n, choices, style, validator, name);
  33. }
  34. wxChoice( wxWindow *parent, wxWindowID id,
  35. const wxPoint& pos,
  36. const wxSize& size,
  37. const wxArrayString& choices,
  38. long style = 0,
  39. const wxValidator& validator = wxDefaultValidator,
  40. const wxString& name = wxChoiceNameStr )
  41. {
  42. Init();
  43. Create(parent, id, pos, size, choices, style, validator, name);
  44. }
  45. virtual ~wxChoice();
  46. bool Create( wxWindow *parent, wxWindowID id,
  47. const wxPoint& pos = wxDefaultPosition,
  48. const wxSize& size = wxDefaultSize,
  49. int n = 0, const wxString choices[] = NULL,
  50. long style = 0,
  51. const wxValidator& validator = wxDefaultValidator,
  52. const wxString& name = wxChoiceNameStr );
  53. bool Create( wxWindow *parent, wxWindowID id,
  54. const wxPoint& pos,
  55. const wxSize& size,
  56. const wxArrayString& choices,
  57. long style = 0,
  58. const wxValidator& validator = wxDefaultValidator,
  59. const wxString& name = wxChoiceNameStr );
  60. int GetSelection() const;
  61. void SetSelection(int n);
  62. virtual unsigned int GetCount() const;
  63. virtual int FindString(const wxString& s, bool bCase = false) const;
  64. virtual wxString GetString(unsigned int n) const;
  65. virtual void SetString(unsigned int n, const wxString& string);
  66. virtual void SetColumns(int n=1);
  67. virtual int GetColumns() const;
  68. virtual void GTKDisableEvents();
  69. virtual void GTKEnableEvents();
  70. static wxVisualAttributes
  71. GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
  72. protected:
  73. // this array is only used for controls with wxCB_SORT style, so only
  74. // allocate it if it's needed (hence using pointer)
  75. wxGtkCollatedArrayString *m_strings;
  76. // contains the client data for the items
  77. wxArrayPtrVoid m_clientData;
  78. // index to GtkListStore cell which displays the item text
  79. int m_stringCellIndex;
  80. virtual wxSize DoGetBestSize() const;
  81. virtual wxSize DoGetSizeFromTextSize(int xlen, int ylen = -1) const;
  82. virtual int DoInsertItems(const wxArrayStringsAdapter& items,
  83. unsigned int pos,
  84. void **clientData, wxClientDataType type);
  85. virtual void DoSetItemClientData(unsigned int n, void* clientData);
  86. virtual void* DoGetItemClientData(unsigned int n) const;
  87. virtual void DoClear();
  88. virtual void DoDeleteOneItem(unsigned int n);
  89. virtual GdkWindow *GTKGetWindow(wxArrayGdkWindows& windows) const;
  90. virtual void DoApplyWidgetStyle(GtkRcStyle *style);
  91. // in derived classes, implement this to insert list store entry
  92. // with all items default except text
  93. virtual void GTKInsertComboBoxTextItem( unsigned int n, const wxString& text );
  94. private:
  95. void Init();
  96. DECLARE_DYNAMIC_CLASS(wxChoice)
  97. };
  98. #endif // _WX_GTK_CHOICE_H_