clntdata.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: clntdata.h
  3. // Purpose: interface of wxClientData[Container] and wxStringClientData
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxClientDataContainer
  9. This class is a mixin that provides storage and management of "client data".
  10. This data can either be of type void - in which case the data
  11. @e container does not take care of freeing the data again or it is of
  12. type wxClientData or its derivatives. In that case the container will free
  13. the memory itself later. Note that you @e must not assign both void data
  14. and data derived from the wxClientData class to a container.
  15. @note This functionality is currently duplicated in wxEvtHandler in order
  16. to avoid having more than one vtable in that class hierarchy.
  17. @library{wxbase}
  18. @category{containers}
  19. @see wxEvtHandler, wxClientData
  20. */
  21. class wxClientDataContainer
  22. {
  23. public:
  24. /**
  25. Default constructor.
  26. */
  27. wxClientDataContainer();
  28. /**
  29. Destructor.
  30. */
  31. virtual ~wxClientDataContainer();
  32. /**
  33. Get the untyped client data.
  34. */
  35. void* GetClientData() const;
  36. /**
  37. Get a pointer to the client data object.
  38. */
  39. wxClientData* GetClientObject() const;
  40. /**
  41. Set the untyped client data.
  42. */
  43. void SetClientData(void* data);
  44. /**
  45. Set the client data object. Any previous object will be deleted.
  46. */
  47. void SetClientObject(wxClientData* data);
  48. };
  49. /**
  50. @class wxClientData
  51. All classes deriving from wxEvtHandler (such as all controls and wxApp) can
  52. hold arbitrary data which is here referred to as "client data". This is
  53. useful e.g. for scripting languages which need to handle shadow objects for
  54. most of wxWidgets' classes and which store a handle to such a shadow class
  55. as client data in that class. This data can either be of type void - in
  56. which case the data @e container does not take care of freeing the data
  57. again or it is of type wxClientData or its derivatives. In that case the
  58. container (e.g. a control) will free the memory itself later. Note that you
  59. @e must not assign both void data and data derived from the wxClientData
  60. class to a container.
  61. Some controls can hold various items and these controls can additionally
  62. hold client data for each item. This is the case for wxChoice, wxComboBox
  63. and wxListBox. wxTreeCtrl has a specialized class wxTreeItemData for each
  64. item in the tree.
  65. If you want to add client data to your own classes, you may use the mix-in
  66. class wxClientDataContainer.
  67. @library{wxbase}
  68. @category{containers}
  69. @see wxEvtHandler, wxTreeItemData, wxStringClientData,
  70. wxClientDataContainer
  71. */
  72. class wxClientData
  73. {
  74. public:
  75. /**
  76. Constructor.
  77. */
  78. wxClientData();
  79. /**
  80. Virtual destructor.
  81. */
  82. virtual ~wxClientData();
  83. };
  84. /**
  85. @class wxStringClientData
  86. Predefined client data class for holding a string.
  87. @library{wxbase}
  88. @category{containers}
  89. */
  90. class wxStringClientData : public wxClientData
  91. {
  92. public:
  93. /**
  94. Default constructor.
  95. */
  96. wxStringClientData();
  97. /**
  98. Create client data with string.
  99. */
  100. wxStringClientData(const wxString& data);
  101. /**
  102. Get string client data.
  103. */
  104. const wxString& GetData() const;
  105. /**
  106. Set string client data.
  107. */
  108. void SetData(const wxString& data);
  109. };