choice.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/choice.h
  3. // Purpose: wxChoice class
  4. // Author: Stefan Csomor
  5. // Modified by:
  6. // Created: 1998-01-01
  7. // Copyright: (c) Stefan Csomor
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CHOICE_H_
  11. #define _WX_CHOICE_H_
  12. #include "wx/control.h"
  13. #include "wx/dynarray.h"
  14. #include "wx/arrstr.h"
  15. WX_DEFINE_ARRAY( char * , wxChoiceDataArray ) ;
  16. // Choice item
  17. class WXDLLIMPEXP_CORE wxChoice: public wxChoiceBase
  18. {
  19. DECLARE_DYNAMIC_CLASS(wxChoice)
  20. public:
  21. wxChoice()
  22. : m_strings(), m_datas()
  23. {}
  24. virtual ~wxChoice() ;
  25. wxChoice(wxWindow *parent, wxWindowID id,
  26. const wxPoint& pos = wxDefaultPosition,
  27. const wxSize& size = wxDefaultSize,
  28. int n = 0, const wxString choices[] = NULL,
  29. long style = 0,
  30. const wxValidator& validator = wxDefaultValidator,
  31. const wxString& name = wxChoiceNameStr)
  32. {
  33. Create(parent, id, pos, size, n, choices, style, validator, name);
  34. }
  35. wxChoice(wxWindow *parent, wxWindowID id,
  36. const wxPoint& pos,
  37. const wxSize& size,
  38. const wxArrayString& choices,
  39. long style = 0,
  40. const wxValidator& validator = wxDefaultValidator,
  41. const wxString& name = wxChoiceNameStr)
  42. {
  43. Create(parent, id, pos, size, choices, style, validator, name);
  44. }
  45. bool Create(wxWindow *parent, wxWindowID id,
  46. const wxPoint& pos = wxDefaultPosition,
  47. const wxSize& size = wxDefaultSize,
  48. int n = 0, const wxString choices[] = NULL,
  49. long style = 0,
  50. const wxValidator& validator = wxDefaultValidator,
  51. const wxString& name = wxChoiceNameStr);
  52. bool Create(wxWindow *parent, wxWindowID id,
  53. const wxPoint& pos,
  54. const wxSize& size,
  55. const wxArrayString& choices,
  56. long style = 0,
  57. const wxValidator& validator = wxDefaultValidator,
  58. const wxString& name = wxChoiceNameStr);
  59. virtual unsigned int GetCount() const ;
  60. virtual int GetSelection() const ;
  61. virtual void SetSelection(int n);
  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 pos, const wxString& s);
  65. // osx specific event handling common for all osx-ports
  66. virtual bool OSXHandleClicked( double timestampsec );
  67. protected:
  68. virtual void DoDeleteOneItem(unsigned int n);
  69. virtual void DoClear();
  70. virtual wxSize DoGetBestSize() const ;
  71. virtual int DoInsertItems(const wxArrayStringsAdapter& items,
  72. unsigned int pos,
  73. void **clientData, wxClientDataType type);
  74. virtual void DoSetItemClientData(unsigned int n, void* clientData);
  75. virtual void* DoGetItemClientData(unsigned int n) const;
  76. wxArrayString m_strings;
  77. wxChoiceDataArray m_datas ;
  78. wxMenu* m_popUpMenu ;
  79. private:
  80. // This should be called when the number of items in the control changes.
  81. void DoAfterItemCountChange();
  82. };
  83. #endif
  84. // _WX_CHOICE_H_