2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: htmllbox.h
|
2008-03-10 11:24:38 -04:00
|
|
|
// Purpose: interface of wxHtmlListBox
|
2008-03-08 08:52:38 -05:00
|
|
|
// Author: wxWidgets team
|
2010-07-13 09:29:13 -04:00
|
|
|
// Licence: wxWindows licence
|
2008-03-08 08:52:38 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
|
|
|
@class wxHtmlListBox
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
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
|
2018-08-14 11:15:39 -04:00
|
|
|
derive your own class from it (see htlbox sample for the example), but you will
|
2008-11-03 09:37:14 -05:00
|
|
|
only need to override a single wxHtmlListBox::OnGetItem function.
|
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable{wxHtmlCellEvent,wxHtmlLinkEvent}
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{EVT_HTML_CELL_CLICKED(id, func)}
|
|
|
|
A wxHtmlCell was clicked.
|
|
|
|
@event{EVT_HTML_CELL_HOVER(id, func)}
|
|
|
|
The mouse passed over a wxHtmlCell.
|
|
|
|
@event{EVT_HTML_LINK_CLICKED(id, func)}
|
2018-08-14 11:15:39 -04:00
|
|
|
A wxHtmlCell which contains a hyperlink was clicked.
|
2008-11-03 09:37:14 -05:00
|
|
|
@endEventTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{ctrl}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxSimpleHtmlListBox
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
class wxHtmlListBox : public wxVListBox
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-11-03 09:37:14 -05:00
|
|
|
Normal constructor which calls Create() internally.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
|
|
|
wxHtmlListBox(wxWindow* parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxHtmlListBoxNameStr);
|
2008-11-03 09:37:14 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Default constructor, you must call Create() later.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxHtmlListBox();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor cleans up whatever resources we use.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxHtmlListBox();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Creates the control and optionally sets the initial number of items in it
|
2008-11-03 09:37:14 -05:00
|
|
|
(it may also be set or changed later with wxVListBox::SetItemCount).
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
There are no special styles defined for wxHtmlListBox, in particular the
|
2011-03-22 10:17:38 -04:00
|
|
|
wxListBox styles (with the exception of @c wxLB_MULTIPLE) cannot be used here.
|
2008-11-03 09:37:14 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Returns @true on success or @false if the control couldn't be created
|
|
|
|
*/
|
|
|
|
bool Create(wxWindow* parent, wxWindowID id = wxID_ANY,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
long style = 0,
|
|
|
|
const wxString& name = wxHtmlListBoxNameStr);
|
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-11-03 09:37:14 -05:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-03 09:37:14 -05:00
|
|
|
wxFileSystem& GetFileSystem() const;
|
|
|
|
const wxFileSystem& GetFileSystem() const;
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
|
2008-10-29 14:55:57 -04:00
|
|
|
protected:
|
|
|
|
|
|
|
|
/**
|
|
|
|
Called when the user clicks on hypertext link. Does nothing by default.
|
|
|
|
Overloading this method is deprecated; intercept the event instead.
|
|
|
|
|
|
|
|
@param n
|
|
|
|
Index of the item containing the link.
|
|
|
|
@param link
|
|
|
|
Description of the link.
|
|
|
|
|
2008-11-22 10:36:50 -05:00
|
|
|
@see wxHtmlLinkInfo.
|
2008-10-29 14:55:57 -04:00
|
|
|
*/
|
|
|
|
virtual void OnLinkClicked(size_t n, const wxHtmlLinkInfo& link);
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
This virtual function may be overridden to change the appearance of the
|
2008-11-03 09:37:14 -05:00
|
|
|
background of the selected cells in the same way as GetSelectedTextColour().
|
|
|
|
|
|
|
|
It should be rarely, if ever, used because wxVListBox::SetSelectionBackground
|
2019-01-25 21:14:20 -05:00
|
|
|
allows changing the selection background for all cells at once and doing
|
2008-11-03 09:37:14 -05:00
|
|
|
anything more fancy is probably going to look strangely.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetSelectedTextColour()
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual wxColour GetSelectedTextBgColour(const wxColour& colBg) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
This virtual function may be overridden to customize the appearance of the
|
2008-03-09 08:33:59 -04:00
|
|
|
selected cells. It is used to determine how the colour @a colFg is going to
|
2008-03-08 08:52:38 -05:00
|
|
|
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.
|
2008-03-20 09:45:17 -04:00
|
|
|
|
2008-03-09 08:33:59 -04:00
|
|
|
@see GetSelectedTextBgColour(),
|
|
|
|
wxVListBox::SetSelectionBackground, wxSystemSettings::GetColour
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual wxColour GetSelectedTextColour(const wxColour& colFg) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
2008-10-29 14:55:57 -04:00
|
|
|
This function may be overridden to decorate HTML returned by OnGetItem().
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-10-13 07:09:56 -04:00
|
|
|
virtual wxString OnGetItemMarkup(size_t n) const;
|
2008-03-08 08:52:38 -05:00
|
|
|
|
2008-10-13 07:29:37 -04:00
|
|
|
/**
|
|
|
|
This method must be implemented in the derived class and should return
|
2014-12-24 08:57:05 -05:00
|
|
|
the body (i.e.\ without @c html nor @c body tags) of the HTML fragment
|
2008-10-13 07:29:37 -04:00
|
|
|
for the given item.
|
2008-11-03 09:37:14 -05:00
|
|
|
|
2008-10-13 07:29:37 -04:00
|
|
|
Note that this function should always return a text fragment for the @a 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, @c IsSelected(n) to
|
|
|
|
make the items appear differently when they are selected, then you should make
|
2008-11-03 09:37:14 -05:00
|
|
|
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.
|
2008-10-13 07:29:37 -04:00
|
|
|
*/
|
2008-10-13 09:24:43 -04:00
|
|
|
virtual wxString OnGetItem(size_t n) const = 0;
|
2008-03-08 08:52:38 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
/**
|
|
|
|
@class wxSimpleHtmlListBox
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
wxSimpleHtmlListBox is an implementation of wxHtmlListBox which
|
|
|
|
shows HTML content in the listbox rows.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
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.
|
2008-03-08 08:52:38 -05:00
|
|
|
However, it also has the disadvantage that this is not a virtual control and
|
2008-11-03 09:37:14 -05:00
|
|
|
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.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
The interface exposed by wxSimpleHtmlListBox fully implements the
|
2008-11-03 09:37:14 -05:00
|
|
|
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
|
2008-03-08 08:52:38 -05:00
|
|
|
@c protected in wxSimpleHtmlListBox's context so that you cannot call it
|
2008-11-03 09:37:14 -05:00
|
|
|
directly, wxSimpleHtmlListBox will do it for you.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note: in case you need to append a lot of items to the control at once, make
|
|
|
|
sure to use the
|
2008-11-03 09:37:14 -05:00
|
|
|
@ref wxControlWithItems::Append "Append(const wxArrayString&)" function.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Thus the only difference between a wxListBox and a wxSimpleHtmlListBox
|
|
|
|
is that the latter stores strings which can contain HTML fragments (see the
|
2008-11-03 09:37:14 -05:00
|
|
|
list of @ref overview_html_supptags "tags supported by wxHTML").
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
Note that the HTML strings you fetch to wxSimpleHtmlListBox should not contain
|
2008-11-03 09:37:14 -05:00
|
|
|
the @c \<html\> or @c \<body\> tags.
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@beginStyleTable
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHLB_DEFAULT_STYLE}
|
2008-03-08 08:52:38 -05:00
|
|
|
The default style: wxBORDER_SUNKEN
|
2008-04-06 10:43:04 -04:00
|
|
|
@style{wxHLB_MULTIPLE}
|
2008-11-03 09:37:14 -05:00
|
|
|
Multiple-selection list: the user can toggle multiple items on and off.
|
2008-03-08 08:52:38 -05:00
|
|
|
@endStyleTable
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
|
|
|
|
A wxSimpleHtmlListBox emits the same events used by wxListBox and by wxHtmlListBox.
|
|
|
|
|
2009-02-18 12:58:51 -05:00
|
|
|
@beginEventEmissionTable
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{EVT_LISTBOX(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_LISTBOX event, when an item on the list
|
2009-02-18 12:58:51 -05:00
|
|
|
is selected. See wxCommandEvent.
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{EVT_LISTBOX_DCLICK(id, func)}
|
2013-04-25 06:11:03 -04:00
|
|
|
Process a @c wxEVT_LISTBOX_DCLICK event, when the listbox is
|
2009-02-18 12:58:51 -05:00
|
|
|
double-clicked. See wxCommandEvent.
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{EVT_HTML_CELL_CLICKED(id, func)}
|
2009-02-18 12:58:51 -05:00
|
|
|
A wxHtmlCell was clicked. See wxHtmlCellEvent.
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{EVT_HTML_CELL_HOVER(id, func)}
|
2009-02-18 12:58:51 -05:00
|
|
|
The mouse passed over a wxHtmlCell. See wxHtmlCellEvent.
|
2008-11-03 09:37:14 -05:00
|
|
|
@event{EVT_HTML_LINK_CLICKED(id, func)}
|
2018-08-14 11:15:39 -04:00
|
|
|
A wxHtmlCell which contains a hyperlink was clicked. See wxHtmlLinkEvent
|
2008-11-03 09:37:14 -05:00
|
|
|
@endEventTable
|
|
|
|
|
2008-03-08 08:52:38 -05:00
|
|
|
@library{wxhtml}
|
|
|
|
@category{ctrl}
|
2013-10-01 09:03:28 -04:00
|
|
|
@genericAppearance{simplehtmllistbox}
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-03-10 11:24:38 -04:00
|
|
|
@see wxSimpleHtmlListBox::Create
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2016-09-09 00:15:55 -04:00
|
|
|
#define wxHLB_DEFAULT_STYLE wxBORDER_SUNKEN
|
|
|
|
#define wxHLB_MULTIPLE wxLB_MULTIPLE
|
|
|
|
|
2010-11-27 06:34:25 -05:00
|
|
|
class wxSimpleHtmlListBox : public wxHtmlListBox,
|
|
|
|
public wxItemContainer
|
2008-03-08 08:52:38 -05:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
/**
|
2008-11-03 09:37:14 -05:00
|
|
|
Constructor, creating and showing the HTML list box.
|
|
|
|
|
|
|
|
@param parent
|
|
|
|
Parent window. Must not be NULL.
|
|
|
|
@param id
|
|
|
|
Window identifier. A value of -1 indicates a default value.
|
|
|
|
@param pos
|
|
|
|
Window position.
|
2009-04-21 07:21:36 -04:00
|
|
|
If ::wxDefaultPosition is specified then a default position is chosen.
|
2008-11-03 09:37:14 -05:00
|
|
|
@param size
|
2019-01-30 11:28:08 -05:00
|
|
|
Window size.
|
2009-04-21 07:21:36 -04:00
|
|
|
If ::wxDefaultSize is specified then the window is sized appropriately.
|
2008-11-03 09:37:14 -05:00
|
|
|
@param n
|
|
|
|
Number of strings with which to initialise the control.
|
|
|
|
@param choices
|
|
|
|
An array of strings with which to initialise the control.
|
|
|
|
@param style
|
|
|
|
Window style. See wxHLB_* flags.
|
|
|
|
@param validator
|
|
|
|
Window validator.
|
|
|
|
@param name
|
|
|
|
Window name.
|
2008-03-08 08:52:38 -05:00
|
|
|
*/
|
2008-11-13 16:32:53 -05:00
|
|
|
wxSimpleHtmlListBox(wxWindow* parent, wxWindowID id,
|
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
|
|
|
int n = 0,
|
|
|
|
const wxString choices[] = NULL,
|
|
|
|
long style = wxHLB_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
|
|
|
const wxString& name = wxSimpleHtmlListBoxNameStr);
|
2008-11-03 09:37:14 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Constructor, creating and showing the HTML list box.
|
|
|
|
|
|
|
|
@param parent
|
|
|
|
Parent window. Must not be NULL.
|
|
|
|
@param id
|
|
|
|
Window identifier. A value of -1 indicates a default value.
|
|
|
|
@param pos
|
|
|
|
Window position.
|
|
|
|
@param size
|
|
|
|
Window size. If wxDefaultSize is specified then the window is sized appropriately.
|
|
|
|
@param choices
|
|
|
|
An array of strings with which to initialise the control.
|
|
|
|
@param style
|
|
|
|
Window style. See wxHLB_* flags.
|
|
|
|
@param validator
|
|
|
|
Window validator.
|
|
|
|
@param name
|
|
|
|
Window name.
|
|
|
|
*/
|
2008-11-13 16:32:53 -05:00
|
|
|
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);
|
2008-03-08 09:43:31 -05:00
|
|
|
|
2008-11-03 09:37:14 -05:00
|
|
|
/**
|
|
|
|
Default constructor, you must call Create() later.
|
|
|
|
*/
|
2008-03-08 09:43:31 -05:00
|
|
|
wxSimpleHtmlListBox();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
Frees the array of stored items and relative client data.
|
|
|
|
*/
|
2008-09-27 07:21:10 -04:00
|
|
|
virtual ~wxSimpleHtmlListBox();
|
2008-03-08 08:52:38 -05:00
|
|
|
|
|
|
|
//@{
|
|
|
|
/**
|
2008-03-08 09:43:31 -05:00
|
|
|
Creates the HTML listbox for two-step construction.
|
2008-03-08 08:52:38 -05:00
|
|
|
See wxSimpleHtmlListBox() for further details.
|
|
|
|
*/
|
2009-01-10 17:10:54 -05:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
2008-03-08 08:52:38 -05:00
|
|
|
const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxDefaultSize,
|
2009-01-10 17:10:54 -05:00
|
|
|
int n = 0, const wxString choices[] = NULL,
|
2008-03-08 08:52:38 -05:00
|
|
|
long style = wxHLB_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-11-13 16:32:53 -05:00
|
|
|
const wxString& name = wxSimpleHtmlListBoxNameStr);
|
2009-01-10 17:10:54 -05:00
|
|
|
bool Create(wxWindow *parent, wxWindowID id,
|
2008-03-08 09:43:31 -05:00
|
|
|
const wxPoint& pos,
|
|
|
|
const wxSize& size,
|
|
|
|
const wxArrayString& choices,
|
|
|
|
long style = wxHLB_DEFAULT_STYLE,
|
|
|
|
const wxValidator& validator = wxDefaultValidator,
|
2008-11-13 16:32:53 -05:00
|
|
|
const wxString& name = wxSimpleHtmlListBoxNameStr);
|
2008-03-08 08:52:38 -05:00
|
|
|
//@}
|
|
|
|
};
|
2008-03-10 11:24:38 -04:00
|
|
|
|