#include <wx/htmllbox.h>
wxHtmlListBox is an implementation of wxVListBox which shows HTML content in the listbox rows.
This is still an abstract base class and you will need to derive your own class from it (see htlbox sample for the example), but you will only need to override a single wxHtmlListBox::OnGetItem function.
The following event handler macros redirect the events to member function handlers 'func' with prototypes like:
Event macros for events emitted by this class:
Public Member Functions | |
| 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. | |
Protected Member Functions | |
| 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). | |
| 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::wxHtmlListBox | ( | ) |
Default constructor, you must call Create() later.
|
virtual |
Destructor cleans up whatever resources we use.
| bool wxHtmlListBox::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).
There are no special styles defined for wxHtmlListBox, in particular the wxListBox styles (with the exception of wxLB_MULTIPLE) cannot be used here.
Returns true on success or false if the control couldn't be created
| const wxFileSystem & wxHtmlListBox::GetFileSystem | ( | ) | const |
Returns the wxFileSystem used by the HTML parser of this object.
The file system object is used to resolve the paths in HTML fragments displayed in the control and you should use wxFileSystem::ChangePathTo if you use relative paths for the images or other resources embedded in your HTML.
| wxFileSystem & wxHtmlListBox::GetFileSystem | ( | ) | const |
Returns the wxFileSystem used by the HTML parser of this object.
The file system object is used to resolve the paths in HTML fragments displayed in the control and you should use wxFileSystem::ChangePathTo if you use relative paths for the images or other resources embedded in your HTML.
|
protectedvirtual |
This virtual function may be overridden to change the appearance of the background of the selected cells in the same way as GetSelectedTextColour().
It should be rarely, if ever, used because wxVListBox::SetSelectionBackground allows changing the selection background for all cells at once and doing anything more fancy is probably going to look strangely.
|
protectedvirtual |
This virtual function may be overridden to customize the appearance of the selected cells.
It is used to determine how the colour colFg is going to look inside selection. By default all original colours are completely ignored and the standard, system-dependent, selection colour is used but the program may wish to override this to achieve some custom appearance.
|
protectedpure virtual |
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.
Note that this function should always return a text fragment for the n item which renders with the same height both when it is selected and when it's not: i.e. if you call, inside your OnGetItem() implementation, IsSelected(n) to make the items appear differently when they are selected, then you should make sure that the returned HTML fragment will render with the same height or else you'll see some artifacts when the user selects an item.
Implemented in wxRichTextStyleListBox.
|
protectedvirtual |
This function may be overridden to decorate HTML returned by OnGetItem().
|
protectedvirtual |
Called when the user clicks on hypertext link.
Does nothing by default. Overloading this method is deprecated; intercept the event instead.
| n | Index of the item containing the link. |
| link | Description of the link. |