#include <wx/htmllbox.h>
Inheritance diagram for wxSimpleHtmlListBox:wxSimpleHtmlListBox is an implementation of wxHtmlListBox which shows HTML content in the listbox rows.
Unlike wxHtmlListBox, this is not an abstract class and thus it has the advantage that you can use it without deriving your own class from it. However, it also has the disadvantage that this is not a virtual control and thus it's not well-suited for those cases where you need to show a huge number of items: every time you add/insert a string, it will be stored internally and thus will take memory.
The interface exposed by wxSimpleHtmlListBox fully implements the wxControlWithItems interface, thus you should refer to wxControlWithItems's documentation for the API reference for adding/removing/retrieving items in the listbox. Also note that the wxVListBox::SetItemCount function is protected in wxSimpleHtmlListBox's context so that you cannot call it directly, wxSimpleHtmlListBox will do it for you.
Note: in case you need to append a lot of items to the control at once, make sure to use the Append(const wxArrayString&) function.
Thus the only difference between a wxListBox and a wxSimpleHtmlListBox is that the latter stores strings which can contain HTML fragments (see the list of tags supported by wxHTML).
Note that the HTML strings you fetch to wxSimpleHtmlListBox should not contain the <html> or <body> tags.
This class supports the following styles:
A wxSimpleHtmlListBox emits the same events used by wxListBox and by wxHtmlListBox.
Event macros for events emitted by this class:
wxEVT_LISTBOX event, when an item on the list is selected. See wxCommandEvent. wxEVT_LISTBOX_DCLICK event, when the listbox is double-clicked. See wxCommandEvent.
Generic Appearance
|
Public Member Functions | |
| wxSimpleHtmlListBox (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=nullptr, long style=wxHLB_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSimpleHtmlListBoxNameStr) | |
| Constructor, creating and showing the HTML list box. | |
| wxSimpleHtmlListBox (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=wxHLB_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSimpleHtmlListBoxNameStr) | |
| Constructor, creating and showing the HTML list box. | |
| wxSimpleHtmlListBox () | |
| Default constructor, you must call Create() later. | |
| virtual | ~wxSimpleHtmlListBox () |
| Frees the array of stored items and relative client data. | |
| bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, int n=0, const wxString choices[]=nullptr, long style=wxHLB_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSimpleHtmlListBoxNameStr) |
| Creates the HTML listbox for two-step construction. | |
| bool | Create (wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, const wxArrayString &choices, long style=wxHLB_DEFAULT_STYLE, const wxValidator &validator=wxDefaultValidator, const wxString &name=wxSimpleHtmlListBoxNameStr) |
| Creates the HTML listbox for two-step construction. | |
Public Member Functions inherited from wxHtmlListBox | |
| wxHtmlListBox (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxHtmlListBoxNameStr) | |
| Normal constructor which calls Create() internally. | |
| wxHtmlListBox () | |
| Default constructor, you must call Create() later. | |
| virtual | ~wxHtmlListBox () |
| Destructor cleans up whatever resources we use. | |
| bool | Create (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxHtmlListBoxNameStr) |
| Creates the control and optionally sets the initial number of items in it (it may also be set or changed later with wxVListBox::SetItemCount). | |
| wxFileSystem & | GetFileSystem () const |
| Returns the wxFileSystem used by the HTML parser of this object. | |
| const wxFileSystem & | GetFileSystem () const |
| Returns the wxFileSystem used by the HTML parser of this object. | |
Public Member Functions inherited from wxVListBox | |
| wxVListBox () | |
| Default constructor, you must call Create() later. | |
| wxVListBox (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxVListBoxNameStr) | |
| Normal constructor which calls Create() internally. | |
| virtual | ~wxVListBox () |
| Destructor. | |
| void | Clear () |
| Deletes all items from the control. | |
| bool | Create (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString &name=wxVListBoxNameStr) |
| Creates the control. | |
| bool | DeselectAll () |
| Deselects all the items in the listbox. | |
| int | GetFirstSelected (unsigned long &cookie) const |
Returns the index of the first selected item in the listbox or wxNOT_FOUND if no items are currently selected. | |
| size_t | GetItemCount () const |
| Get the number of items in the control. | |
| wxPoint | GetMargins () const |
| Returns the margins used by the control. | |
| wxRect | GetItemRect (size_t item) const |
| Returns the rectangle occupied by this item in physical coordinates. | |
| int | GetNextSelected (unsigned long &cookie) const |
Returns the index of the next selected item or wxNOT_FOUND if there are no more. | |
| size_t | GetSelectedCount () const |
| Returns the number of the items currently selected. | |
| int | GetSelection () const |
Get the currently selected item or wxNOT_FOUND if there is no selection. | |
| const wxColour & | GetSelectionBackground () const |
| Returns the background colour used for the selected cells. | |
| bool | HasMultipleSelection () const |
Returns true if the listbox was created with wxLB_MULTIPLE style and so supports multiple selection or false if it is a single selection listbox. | |
| bool | IsCurrent (size_t item) const |
| Returns true if this item is the current one, false otherwise. | |
| int | GetCurrent () const |
Get the current item or wxNOT_FOUND if there is no current item. | |
| void | SetCurrent (int current) |
| Set the specified item as the current item, if it is wxNOT_FOUND the current item is unset. | |
| bool | IsSelected (size_t item) const |
| Returns true if this item is selected, false otherwise. | |
| bool | Select (size_t item, bool select=true) |
Selects or deselects the specified item which must be valid (i.e. not equal to wxNOT_FOUND). | |
| bool | SelectAll () |
| Selects all the items in the listbox. | |
| bool | SelectRange (size_t from, size_t to) |
| Selects all items in the specified range which may be given in any order. | |
| virtual void | SetItemCount (size_t count) |
| Set the number of items to be shown in the control. | |
| void | SetSelection (int selection) |
| Set the selection to the specified item, if it is -1 the selection is unset. | |
| void | SetSelectionBackground (const wxColour &col) |
| Sets the colour to be used for the selected cells background. | |
| void | Toggle (size_t item) |
| Toggles the state of the specified item, i.e. selects it if it was unselected and deselects it if it was selected. | |
| void | SetMargins (const wxPoint &pt) |
| Set the margins: horizontal margin is the distance between the window border and the item contents while vertical margin is half of the distance between items. | |
| void | SetMargins (wxCoord x, wxCoord y) |
| Set the margins: horizontal margin is the distance between the window border and the item contents while vertical margin is half of the distance between items. | |
Public Member Functions inherited from wxItemContainer | |
| void | Clear () |
| Removes all items from the control. | |
| void | Delete (unsigned int n) |
| Deletes an item from the control. | |
| bool | IsSorted () const |
| The control may maintain its items in a sorted order in which case items are automatically inserted at the right position when they are inserted or appended. | |
| wxClientData * | DetachClientObject (unsigned int n) |
| Returns the client object associated with the given item and transfers its ownership to the caller. | |
| bool | HasClientData () const |
Returns true, if either untyped data (void*) or object data (wxClientData*) is associated with the items of the control. | |
| bool | HasClientObjectData () const |
| Returns true, if object data is associated with the items of the control. | |
| bool | HasClientUntypedData () const |
Returns true, if untyped data (void*) is associated with the items of the control. | |
| int | Append (const wxString &item) |
| Appends item into the control. | |
| int | Append (const wxString &item, void *clientData) |
| Appends item into the control. | |
| int | Append (const wxString &item, wxClientData *clientData) |
| Appends item into the control. | |
| int | Append (const wxArrayString &items) |
| Appends several items at once into the control. | |
| int | Append (const std::vector< wxString > &items) |
| Appends several items at once into the control. | |
| int | Append (const wxArrayString &items, void **clientData) |
| Appends several items at once into the control. | |
| int | Append (const wxArrayString &items, wxClientData **clientData) |
| Appends several items at once into the control. | |
| int | Append (unsigned int n, const wxString *items) |
| Appends several items at once into the control. | |
| int | Append (unsigned int n, const wxString *items, void **clientData) |
| Appends several items at once into the control. | |
| int | Append (unsigned int n, const wxString *items, wxClientData **clientData) |
| Appends several items at once into the control. | |
| void * | GetClientData (unsigned int n) const |
| Returns a pointer to the client data associated with the given item (if any). | |
| wxClientData * | GetClientObject (unsigned int n) const |
| Returns a pointer to the client data associated with the given item (if any). | |
| void | SetClientData (unsigned int n, void *data) |
| Associates the given untyped client data pointer with the given item. | |
| void | SetClientObject (unsigned int n, wxClientData *data) |
| Associates the given typed client data pointer with the given item: the data object will be deleted when the item is deleted (either explicitly by using Delete() or implicitly when the control itself is destroyed). | |
| int | Insert (const wxString &item, unsigned int pos) |
| Inserts item into the control. | |
| int | Insert (const wxString &item, unsigned int pos, void *clientData) |
| Inserts item into the control. | |
| int | Insert (const wxString &item, unsigned int pos, wxClientData *clientData) |
| Inserts item into the control. | |
| int | Insert (const wxArrayString &items, unsigned int pos) |
| Inserts several items at once into the control. | |
| int | Insert (const std::vector< wxString > &items) |
| Inserts several items at once into the control. | |
| int | Insert (const wxArrayString &items, unsigned int pos, void **clientData) |
| Inserts several items at once into the control. | |
| int | Insert (const wxArrayString &items, unsigned int pos, wxClientData **clientData) |
| Inserts several items at once into the control. | |
| int | Insert (unsigned int n, const wxString *items, unsigned int pos) |
| Inserts several items at once into the control. | |
| int | Insert (unsigned int n, const wxString *items, unsigned int pos, void **clientData) |
| Inserts several items at once into the control. | |
| int | Insert (unsigned int n, const wxString *items, unsigned int pos, wxClientData **clientData) |
| Inserts several items at once into the control. | |
| void | Set (const wxArrayString &items) |
| Replaces the current control contents with the given items. | |
| void | Set (const std::vector< wxString > &items) |
| Replaces the current control contents with the given items. | |
| void | Set (const wxArrayString &items, void **clientData) |
| Replaces the current control contents with the given items. | |
| void | Set (const wxArrayString &items, wxClientData **clientData) |
| Replaces the current control contents with the given items. | |
| void | Set (unsigned int n, const wxString *items) |
| Replaces the current control contents with the given items. | |
| void | Set (unsigned int n, const wxString *items, void **clientData) |
| Replaces the current control contents with the given items. | |
| void | Set (unsigned int n, const wxString *items, wxClientData **clientData) |
| Replaces the current control contents with the given items. | |
Public Member Functions inherited from wxItemContainerImmutable | |
| wxItemContainerImmutable () | |
| Constructor. | |
| virtual unsigned int | GetCount () const =0 |
| Returns the number of items in the control. | |
| bool | IsEmpty () const |
| Returns true if the control is empty or false if it has some items. | |
| virtual wxString | GetString (unsigned int n) const =0 |
| Returns the label of the item with the given index. | |
| wxArrayString | GetStrings () const |
| Returns the array of the labels of all items in the control. | |
| virtual void | SetString (unsigned int n, const wxString &string)=0 |
| Sets the label for the given item. | |
| virtual int | FindString (const wxString &string, bool caseSensitive=false) const |
| Finds an item whose label matches the given string. | |
| virtual void | SetSelection (int n)=0 |
Sets the selection to the given item n or removes the selection entirely if n == wxNOT_FOUND. | |
| virtual int | GetSelection () const =0 |
Returns the index of the selected item or wxNOT_FOUND if no item is selected. | |
| bool | SetStringSelection (const wxString &string) |
| Selects the item with the specified string in the control. | |
| virtual wxString | GetStringSelection () const |
| Returns the label of the selected item or an empty string if no item is selected. | |
| void | Select (int n) |
| This is the same as SetSelection() and exists only because it is slightly more natural for controls which support multiple selection. | |
Additional Inherited Members | |
Protected Member Functions inherited from wxHtmlListBox | |
| virtual void | OnLinkClicked (size_t n, const wxHtmlLinkInfo &link) |
| Called when the user clicks on hypertext link. | |
| virtual wxColour | GetSelectedTextBgColour (const wxColour &colBg) const |
| This virtual function may be overridden to change the appearance of the background of the selected cells in the same way as GetSelectedTextColour(). | |
| virtual wxColour | GetSelectedTextColour (const wxColour &colFg) const |
| This virtual function may be overridden to customize the appearance of the selected cells. | |
| virtual wxString | OnGetItemMarkup (size_t n) const |
| This function may be overridden to decorate HTML returned by OnGetItem(). | |
| virtual wxString | OnGetItem (size_t n) const =0 |
This method must be implemented in the derived class and should return the body (i.e. without html nor body tags) of the HTML fragment for the given item. | |
Protected Member Functions inherited from wxVListBox | |
| virtual void | OnDrawItem (wxDC &dc, const wxRect &rect, size_t n) const =0 |
| The derived class must implement this function to actually draw the item with the given index on the provided DC. | |
| virtual void | OnDrawBackground (wxDC &dc, const wxRect &rect, size_t n) const |
| This method is used to draw the item's background and, maybe, a border around it. | |
| virtual void | OnDrawSeparator (wxDC &dc, wxRect &rect, size_t n) const |
| This method may be used to draw separators between the lines. | |
| virtual wxCoord | OnMeasureItem (size_t n) const =0 |
| The derived class must implement this method to return the height of the specified item (in pixels). | |
| wxSimpleHtmlListBox::wxSimpleHtmlListBox | ( | wxWindow * | parent, |
| wxWindowID | id, | ||
| const wxPoint & | pos = wxDefaultPosition, | ||
| const wxSize & | size = wxDefaultSize, | ||
| int | n = 0, | ||
| const wxString | choices[] = nullptr, | ||
| long | style = wxHLB_DEFAULT_STYLE, | ||
| const wxValidator & | validator = wxDefaultValidator, | ||
| const wxString & | name = wxSimpleHtmlListBoxNameStr ) |
Constructor, creating and showing the HTML list box.
| parent | Parent window. Must not be nullptr. |
| id | Window identifier. A value of -1 indicates a default value. |
| pos | Window position. If wxDefaultPosition is specified then a default position is chosen. |
| size | Window size. If wxDefaultSize is specified then the window is sized appropriately. |
| n | Number of strings with which to initialise the control. |
| choices | An array of strings with which to initialise the control. |
| style | Window style. See wxHLB_* flags. |
| validator | Window validator. |
| name | Window name. |
| wxSimpleHtmlListBox::wxSimpleHtmlListBox | ( | wxWindow * | parent, |
| wxWindowID | id, | ||
| const wxPoint & | pos, | ||
| const wxSize & | size, | ||
| const wxArrayString & | choices, | ||
| long | style = wxHLB_DEFAULT_STYLE, | ||
| const wxValidator & | validator = wxDefaultValidator, | ||
| const wxString & | name = wxSimpleHtmlListBoxNameStr ) |
Constructor, creating and showing the HTML list box.
| parent | Parent window. Must not be nullptr. |
| id | Window identifier. A value of -1 indicates a default value. |
| pos | Window position. |
| size | Window size. If wxDefaultSize is specified then the window is sized appropriately. |
| choices | An array of strings with which to initialise the control. |
| style | Window style. See wxHLB_* flags. |
| validator | Window validator. |
| name | Window name. |
| wxSimpleHtmlListBox::wxSimpleHtmlListBox | ( | ) |
Default constructor, you must call Create() later.
|
virtual |
Frees the array of stored items and relative client data.
| bool wxSimpleHtmlListBox::Create | ( | wxWindow * | parent, |
| wxWindowID | id, | ||
| const wxPoint & | pos, | ||
| const wxSize & | size, | ||
| const wxArrayString & | choices, | ||
| long | style = wxHLB_DEFAULT_STYLE, | ||
| const wxValidator & | validator = wxDefaultValidator, | ||
| const wxString & | name = wxSimpleHtmlListBoxNameStr ) |
Creates the HTML listbox for two-step construction.
See wxSimpleHtmlListBox() for further details.
| bool wxSimpleHtmlListBox::Create | ( | wxWindow * | parent, |
| wxWindowID | id, | ||
| const wxPoint & | pos = wxDefaultPosition, | ||
| const wxSize & | size = wxDefaultSize, | ||
| int | n = 0, | ||
| const wxString | choices[] = nullptr, | ||
| long | style = wxHLB_DEFAULT_STYLE, | ||
| const wxValidator & | validator = wxDefaultValidator, | ||
| const wxString & | name = wxSimpleHtmlListBoxNameStr ) |
Creates the HTML listbox for two-step construction.
See wxSimpleHtmlListBox() for further details.