bmpcbox.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: bmpcbox.h
  3. // Purpose: interface of wxBitmapComboBox
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. /**
  8. @class wxBitmapComboBox
  9. A combobox that displays bitmap in front of the list items.
  10. It currently only allows using bitmaps of one size, and resizes itself
  11. so that a bitmap can be shown next to the text field.
  12. @remarks
  13. While wxBitmapComboBox contains the wxComboBox API, but it might not actually
  14. be derived from that class. In fact, if the platform does not have a native
  15. implementation, wxBitmapComboBox will inherit from wxOwnerDrawnComboBox.
  16. You can determine if the implementation is generic by checking whether
  17. @c wxGENERIC_BITMAPCOMBOBOX is defined. Currently wxBitmapComboBox is
  18. implemented natively for MSW and GTK+.
  19. @beginStyleTable
  20. @style{wxCB_READONLY}
  21. Creates a combobox without a text editor. On some platforms the
  22. control may appear very different when this style is used.
  23. @style{wxCB_SORT}
  24. Sorts the entries in the list alphabetically.
  25. @style{wxTE_PROCESS_ENTER}
  26. The control will generate the event wxEVT_TEXT_ENTER
  27. (otherwise pressing Enter key is either processed internally by the
  28. control or used for navigation between dialog controls).
  29. Windows only.
  30. @endStyleTable
  31. @todo create wxCB_PROCESS_ENTER rather than reusing wxTE_PROCESS_ENTER!
  32. @beginEventEmissionTable{wxCommandEvent}
  33. @event{EVT_COMBOBOX(id, func)}
  34. Process a @c wxEVT_COMBOBOX event, when an item on
  35. the list is selected.
  36. @event{EVT_TEXT(id, func)}
  37. Process a @c wxEVT_TEXT event, when the combobox text changes.
  38. @event{EVT_TEXT_ENTER(id, func)}
  39. Process a @c wxEVT_TEXT_ENTER event, when RETURN is pressed in
  40. the combobox.
  41. @endEventTable
  42. @library{wxadv}
  43. @category{ctrl}
  44. @appearance{bitmapcombobox}
  45. @see wxComboBox, wxChoice, wxOwnerDrawnComboBox, wxCommandEvent
  46. */
  47. class wxBitmapComboBox : public wxComboBox
  48. {
  49. public:
  50. /**
  51. Default ctor.
  52. */
  53. wxBitmapComboBox();
  54. /**
  55. Constructor, creating and showing a combobox.
  56. @param parent
  57. Parent window. Must not be @NULL.
  58. @param id
  59. Window identifier. The value wxID_ANY indicates a default value.
  60. @param value
  61. Initial selection string. An empty string indicates no selection.
  62. @param pos
  63. Initial position.
  64. @param size
  65. Initial size.
  66. @param n
  67. Number of strings with which to initialise the control.
  68. @param choices
  69. An array of strings with which to initialise the control.
  70. @param style
  71. The window style, see wxCB_* flags.
  72. @param validator
  73. Validator which can be used for additional data checks.
  74. @param name
  75. Control name.
  76. @see Create(), wxValidator
  77. */
  78. wxBitmapComboBox(wxWindow* parent, wxWindowID id = wxID_ANY,
  79. const wxString& value = wxEmptyString,
  80. const wxPoint& pos = wxDefaultPosition,
  81. const wxSize& size = wxDefaultSize,
  82. int n = 0,
  83. const wxString choices[] = NULL,
  84. long style = 0,
  85. const wxValidator& validator = wxDefaultValidator,
  86. const wxString& name = wxBitmapComboBoxNameStr);
  87. /**
  88. Constructor, creating and showing a combobox.
  89. @param parent
  90. Parent window. Must not be @NULL.
  91. @param id
  92. Window identifier. The value wxID_ANY indicates a default value.
  93. @param value
  94. Initial selection string. An empty string indicates no selection.
  95. @param pos
  96. Initial position.
  97. @param size
  98. Initial size.
  99. @param choices
  100. An wxArrayString with which to initialise the control.
  101. @param style
  102. The window style, see wxCB_* flags.
  103. @param validator
  104. Validator which can be used for additional data checks.
  105. @param name
  106. Control name.
  107. @see Create(), wxValidator
  108. */
  109. wxBitmapComboBox(wxWindow* parent, wxWindowID id,
  110. const wxString& value,
  111. const wxPoint& pos,
  112. const wxSize& size,
  113. const wxArrayString& choices,
  114. long style,
  115. const wxValidator& validator = wxDefaultValidator,
  116. const wxString& name = wxBitmapComboBoxNameStr);
  117. /**
  118. Destructor, destroying the combobox.
  119. */
  120. virtual ~wxBitmapComboBox();
  121. /**
  122. Adds the item to the end of the combo box.
  123. */
  124. int Append(const wxString& item,
  125. const wxBitmap& bitmap = wxNullBitmap);
  126. /**
  127. Adds the item to the end of the combo box, associating the given
  128. untyped, client data pointer @a clientData with the item.
  129. */
  130. int Append(const wxString& item, const wxBitmap& bitmap,
  131. void* clientData);
  132. /**
  133. Adds the item to the end of the combo box, associating the given typed
  134. client data pointer @a clientData with the item.
  135. */
  136. int Append(const wxString& item, const wxBitmap& bitmap,
  137. wxClientData* clientData);
  138. /**
  139. Creates the combobox for two-step construction.
  140. */
  141. bool Create(wxWindow* parent, wxWindowID id,
  142. const wxString& value,
  143. const wxPoint& pos,
  144. const wxSize& size,
  145. int n, const wxString choices[],
  146. long style = 0,
  147. const wxValidator& validator = wxDefaultValidator,
  148. const wxString& name = wxBitmapComboBoxNameStr);
  149. /**
  150. Creates the combobox for two-step construction.
  151. */
  152. bool Create(wxWindow* parent, wxWindowID id,
  153. const wxString& value,
  154. const wxPoint& pos,
  155. const wxSize& size,
  156. const wxArrayString& choices,
  157. long style = 0,
  158. const wxValidator& validator = wxDefaultValidator,
  159. const wxString& name = wxBitmapComboBoxNameStr);
  160. /**
  161. Returns the size of the bitmaps used in the combo box.
  162. If the combo box is empty, then ::wxDefaultSize is returned.
  163. */
  164. virtual wxSize GetBitmapSize() const;
  165. /**
  166. Returns the bitmap of the item with the given index.
  167. */
  168. virtual wxBitmap GetItemBitmap(unsigned int n) const;
  169. /**
  170. Inserts the item into the list before @a pos.
  171. Not valid for @c wxCB_SORT style, use Append() instead.
  172. */
  173. int Insert(const wxString& item, const wxBitmap& bitmap,
  174. unsigned int pos);
  175. /**
  176. Inserts the item into the list before pos, associating the given
  177. untyped, client data pointer with the item.
  178. Not valid for @c wxCB_SORT style, use Append() instead.
  179. */
  180. int Insert(const wxString& item, const wxBitmap& bitmap,
  181. unsigned int pos,
  182. void* clientData);
  183. /**
  184. Inserts the item into the list before pos, associating the given typed
  185. client data pointer with the item.
  186. Not valid for @c wxCB_SORT style, use Append() instead.
  187. */
  188. int Insert(const wxString& item, const wxBitmap& bitmap,
  189. unsigned int pos,
  190. wxClientData* clientData);
  191. /**
  192. Sets the bitmap for the given item.
  193. */
  194. virtual void SetItemBitmap(unsigned int n, const wxBitmap& bitmap);
  195. };