initial commit

Signed-off-by: Peter Siegmund <mars3142@noreply.mars3142.dev>
This commit is contained in:
2025-10-31 23:37:30 +01:00
commit bf6b52fd94
9654 changed files with 4035664 additions and 0 deletions

View File

@@ -0,0 +1,328 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpctrl.h
// Purpose: interface of wxHtmlHelpController
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#define wxID_HTML_HELPFRAME (wxID_HIGHEST + 1)
/// This style indicates that the window is
/// embedded in the application and must not be
/// destroyed by the help controller.
#define wxHF_EMBEDDED 0x00008000
/// Create a dialog for the help window.
#define wxHF_DIALOG 0x00010000
/// Create a frame for the help window.
#define wxHF_FRAME 0x00020000
/// Make the dialog modal when displaying help.
#define wxHF_MODAL 0x00040000
/**
@class wxHtmlHelpController
This help controller provides an easy way of displaying HTML help in your
application (see @sample{html}, test example).
The help system is based on @b books (see wxHtmlHelpController::AddBook).
A book is a logical section of documentation (for example "User's Guide" or
"Programmer's Guide" or "C++ Reference" or "wxWidgets Reference").
The help controller can handle as many books as you want.
Although this class has an API compatible with other wxWidgets help controllers
as documented by wxHelpController, it is recommended that you use the enhanced
capabilities of wxHtmlHelpController's API.
wxHTML uses Microsoft's HTML Help Workshop project files (.hhp, .hhk, .hhc) as
its native format. The file format is described in @ref overview_html_helpformats.
The directory @c helpfiles in the @sample{html} contains sample project files.
Note that the Microsoft's HTML Help Workshop
(http://www.microsoft.com/downloads/details.aspx?FamilyID=00535334-c8a6-452f-9aa0-d597d16580cc)
also runs on other platforms using WINE (http://www.winehq.org/) and it can
be used to create the .hpp, .hhk and .hhc files through a friendly GUI.
The commercial tool HelpBlocks (http://www.helpblocks.com) can also create these files.
@library{wxhtml}
@category{help,html}
@see wxBestHelpController, wxHtmlHelpFrame, wxHtmlHelpDialog,
wxHtmlHelpWindow, wxHtmlModalHelp
*/
class wxHtmlHelpController : public wxHelpControllerBase
{
public:
/**
Constructor.
@param style
This is a combination of these flags:
- wxHF_TOOLBAR: The help window has a toolbar.
- wxHF_FLAT_TOOLBAR: The help window has a toolbar with flat buttons (aka coolbar).
- wxHF_CONTENTS: The help window has a contents panel.
- wxHF_INDEX: The help window has an index panel.
- wxHF_SEARCH: The help window has a search panel.
- wxHF_BOOKMARKS: The help window has bookmarks controls.
- wxHF_OPEN_FILES: Allows user to open arbitrary HTML document.
- wxHF_PRINT: The toolbar contains "print" button.
- wxHF_MERGE_BOOKS: The contents pane does not show book nodes.
All books are merged together and appear as single book to the user.
- wxHF_ICONS_BOOK: All nodes in contents pane have a book icon.
This is how Microsoft's HTML help viewer behaves.
- wxHF_ICONS_FOLDER: Book nodes in contents pane have a book icon, book's
sections have a folder icon. This is the default.
- wxHF_ICONS_BOOK_CHAPTER: Both book nodes and nodes of top-level
sections of a book (i.e. chapters) have a book icon, all other sections
(sections, subsections, ...) have a folder icon.
- wxHF_EMBEDDED: Specifies that the help controller controls an embedded
window of class wxHtmlHelpWindow that should not be destroyed when
the controller is destroyed.
- wxHF_DIALOG: Specifies that the help controller should create a
dialog containing the help window.
- wxHF_FRAME: Specifies that the help controller should create a frame
containing the help window.
This is the default if neither wxHF_DIALOG nor wxHF_EMBEDDED is specified.
- wxHF_MODAL: Specifies that the help controller should create a modal
dialog containing the help window (used with the wxHF_DIALOG style).
- wxHF_DEFAULT_STYLE: wxHF_TOOLBAR | wxHF_CONTENTS | wxHF_INDEX |
wxHF_SEARCH | wxHF_BOOKMARKS | wxHF_PRINT
@param parentWindow
This is an optional window to be used as the parent for the help window.
*/
wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE,
wxWindow* parentWindow = nullptr);
wxHtmlHelpController(wxWindow* parentWindow, int style = wxHF_DEFAULT_STYLE);
/**
Adds a book (i.e. a @ref overview_html_helpformats ".hhp file"; an HTML Help
Workshop project file) into the list of loaded books.
This must be called at least once before displaying any help.
@a bookFile or @a bookUrl may be either @c ".hhp" file or a ZIP archive
that contains an arbitrary number of @c ".hhp" files in its top-level
directory.
This ZIP archive must have @c ".zip" or @c ".htb" extension (the latter
stands for "HTML book"). In other words,
@code
AddBook(wxFileName("help.zip"))
@endcode
is possible and is the recommended way.
@param bookFile
Help book filename. It is recommended to use this prototype
instead of the one taking URL, because it is less error-prone.
@param showWaitMsg
If @true then a decoration-less window with progress message is displayed.
*/
bool AddBook(const wxFileName& bookFile, bool showWaitMsg = false);
/**
Adds a book (i.e. a @ref overview_html_helpformats ".hhp file"; an HTML Help
Workshop project file) into the list of loaded books.
See the other overload for additional info.
@param bookUrl
Help book URL (note that syntax of filename and URL is
different on most platforms).
@param showWaitMsg
If @true then a decoration-less window with progress message is displayed.
*/
bool AddBook(const wxString& bookUrl, bool showWaitMsg = false);
/**
Displays page @a x.
This is THE important function - it is used to display the help in application.
You can specify the page in many ways:
- as direct filename of HTML document
- as chapter name (from contents) or as a book name
- as some word from index
- even as any word (will be searched)
Looking for the page runs in these steps:
-# try to locate file named x (if x is for example "doc/howto.htm")
-# try to open starting page of book named x
-# try to find x in contents (if x is for example "How To ...")
-# try to find x in index (if x is for example "How To ...")
-# switch to Search panel and start searching
*/
bool Display(const wxString& x);
/**
@overload
This alternative form is used to search help contents by numeric IDs.
*/
bool Display(int id);
/**
Displays help window and focuses contents panel.
*/
virtual bool DisplayContents();
/**
Displays help window and focuses index panel.
*/
bool DisplayIndex();
/**
Displays the help window, focuses search panel and starts searching.
Returns @true if the keyword was found. Optionally it searches through the
index (mode = @c wxHELP_SEARCH_INDEX), default the content
(mode = @c wxHELP_SEARCH_ALL).
@note
KeywordSearch() searches only pages listed in @c ".hhc" file(s).
You should list all pages in the contents file.
*/
virtual bool KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
/**
Reads the controller's setting (position of window, etc.)
*/
virtual void ReadCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
/**
Sets whether the help frame should prevent application from exiting
if it's the only remaining top level window.
@param enable
If @true, the application will not quit unless the help frame is
closed. Default is @false, i.e. the application does exit if only
the help window remains opened.
@see wxApp::SetExitOnFrameDelete()
@since 2.9.2
*/
void SetShouldPreventAppExit(bool enable);
/**
Sets the path for storing temporary files - cached binary versions of index and
contents files.
These binary forms are much faster to read. Default value is empty string
(empty string means that no cached data are stored). Note that these files
are @e not deleted when program exits.
Once created these cached files will be used in all subsequent executions
of your application. If cached files become older than corresponding @c ".hhp"
file (e.g. if you regenerate documentation) it will be refreshed.
*/
void SetTempDir(const wxString& path);
/**
Sets format of title of the frame.
Must contain exactly one "%s" (for title of displayed HTML page).
*/
void SetTitleFormat(const wxString& format);
/**
Associates the @a config object with the controller.
If there is associated config object, wxHtmlHelpController automatically
reads and writes settings (including wxHtmlWindow's settings) when needed.
The only thing you must do is create wxConfig object and call UseConfig().
If you do not use UseConfig(), wxHtmlHelpController will use the default
wxConfig object if available (for details see wxConfigBase::Get and
wxConfigBase::Set).
*/
void UseConfig(wxConfigBase* config,
const wxString& rootpath = wxEmptyString);
/**
Stores controllers setting (position of window etc.)
*/
virtual void WriteCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
/**
Get the current help window
*/
wxHtmlHelpWindow* GetHelpWindow();
/**
Set the help window to be managed by this controller. This makes it
possible to have a help window that might not be in a wxHtmlHelpFrame or
dialog but is embedded in some other window in the application. Be sure
to use the wxHF_EMBEDDED style in this case.
*/
void SetHelpWindow(wxHtmlHelpWindow* helpWindow);
/**
Returns the current help frame. (May be @NULL.)
*/
wxHtmlHelpFrame* GetFrame();
/**
Returns the current help dialog. (May be @NULL.)
*/
wxHtmlHelpDialog* GetDialog();
protected:
/**
This protected virtual method may be overridden so that when specifying the
@c wxHF_DIALOG style, the controller uses a different dialog.
*/
virtual wxHtmlHelpDialog* CreateHelpDialog(wxHtmlHelpData* data);
/**
This protected virtual method may be overridden so that the controller
uses a different frame.
*/
virtual wxHtmlHelpFrame* CreateHelpFrame(wxHtmlHelpData* data);
};
/**
@class wxHtmlModalHelp
This class uses wxHtmlHelpController to display help in a modal dialog.
This is useful on platforms such as wxMac where if you display help from a
modal dialog, the help window must itself be a modal dialog.
Create objects of this class on the stack, for example:
@code
// The help can be browsed during the lifetime of this object; when the
// user quits the help, program execution will continue.
wxHtmlModalHelp help(parent, "help", "My topic");
@endcode
@library{wxhtml}
@category{help,html}
*/
class wxHtmlModalHelp
{
public:
/**
The ctor.
@param parent
is the parent of the dialog.
@param helpFile
is the HTML help file to show.
@param topic
is an optional topic. If this is empty, the help contents will be shown.
@param style
is a combination of the flags described in the wxHtmlHelpController
documentation.
*/
wxHtmlModalHelp(wxWindow* parent, const wxString& helpFile,
const wxString& topic = wxEmptyString,
int style = wxHF_DEFAULT_STYLE | wxHF_DIALOG | wxHF_MODAL);
};

View File

@@ -0,0 +1,134 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpdata.h
// Purpose: interface of wxHtmlHelpData
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlBookRecord
Helper class for wxHtmlHelpData
*/
class wxHtmlBookRecord
{
public:
wxHtmlBookRecord(const wxString& bookfile, const wxString& basepath,
const wxString& title, const wxString& start);
wxString GetBookFile() const;
wxString GetTitle() const;
wxString GetStart() const;
wxString GetBasePath() const;
/* SetContentsRange: store in the bookrecord where in the index/contents lists the
* book's records are stored. This to facilitate searching in a specific book.
* This code will have to be revised when loading/removing books becomes dynamic.
* (as opposed to appending only)
* Note that storing index range is pointless, because the index is alphab. sorted. */
void SetContentsRange(int start, int end);
int GetContentsStart() const;
int GetContentsEnd() const;
void SetTitle(const wxString& title);
void SetBasePath(const wxString& path);
void SetStart(const wxString& start);
// returns full filename of page (which is part of the book),
// i.e. with book's basePath prepended. If page is already absolute
// path, basePath is _not_ prepended.
wxString GetFullPath(const wxString &page) const;
};
/**
@class wxHtmlHelpDataItem
Helper class for wxHtmlHelpData
*/
struct wxHtmlHelpDataItem
{
wxHtmlHelpDataItem();
int level;
wxHtmlHelpDataItem *parent;
int id;
wxString name;
wxString page;
wxHtmlBookRecord *book;
// returns full filename of m_Page, i.e. with book's basePath prepended
wxString GetFullPath() const;
// returns item indented with spaces if it has level>1:
wxString GetIndentedName() const;
};
/**
@class wxHtmlHelpData
This class is used by wxHtmlHelpController and wxHtmlHelpFrame to access HTML
help items.
It is internal class and should not be used directly - except for the case
you're writing your own HTML help controller.
@library{wxhtml}
@category{help,html}
*/
class wxHtmlHelpData : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlHelpData();
/**
Adds new book.
@a book_url is URL (not filename!) of HTML help project (hhp) or ZIP file
that contains arbitrary number of .hhp projects (this zip file can have
either .zip or .htb extension, htb stands for "html book").
Returns success.
*/
bool AddBook(const wxString& book_url);
/**
Returns page's URL based on integer ID stored in project.
*/
wxString FindPageById(int id);
/**
Returns page's URL based on its (file)name.
*/
wxString FindPageByName(const wxString& page);
/**
Returns array with help books info.
*/
const wxHtmlBookRecArray& GetBookRecArray() const;
/**
Returns reference to array with contents entries.
*/
const wxHtmlHelpDataItems& GetContentsArray() const;
/**
Returns reference to array with index entries.
*/
const wxHtmlHelpDataItems& GetIndexArray() const;
/**
Sets the temporary directory where binary cached versions of MS HTML Workshop
files will be stored. (This is turned off by default and you can enable
this feature by setting non-empty temp dir.)
*/
void SetTempDir(const wxString& path);
};

View File

@@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpdlg.h
// Purpose: interface of wxHtmlHelpDialog
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlHelpDialog
This class is used by wxHtmlHelpController to display help.
It is an internal class and should not be used directly - except for the case
when you're writing your own HTML help controller.
@library{wxhtml}
@category{help,html}
*/
class wxHtmlHelpDialog : public wxDialog
{
public:
wxHtmlHelpDialog(wxHtmlHelpData* data = nullptr);
/**
Constructor.
For the possible values of @a style, please see wxHtmlHelpController.
*/
wxHtmlHelpDialog(wxWindow* parent, wxWindowID id,
const wxString& title = wxEmptyString,
int style = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = nullptr);
/**
You may override this virtual method to add more buttons to the help window's
toolbar. @a toolBar is a pointer to the toolbar and @a style is the style
flag as passed to the Create() method.
wxToolBar::Realize is called immediately after returning from this function.
*/
virtual void AddToolbarButtons(wxToolBar* toolBar, int style);
/**
Creates the dialog. See @ref wxHtmlHelpDialog() "the constructor"
for a description of the parameters.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxString& title = wxEmptyString,
int style = wxHF_DEFAULT_STYLE);
/**
Returns the help controller associated with the dialog.
*/
wxHtmlHelpController* GetController() const;
/**
Sets the help controller associated with the dialog.
*/
void SetController(wxHtmlHelpController* controller);
/**
Sets the dialog's title format.
@a format must contain exactly one "%s" (it will be replaced by the page title).
*/
void SetTitleFormat(const wxString& format);
};

View File

@@ -0,0 +1,88 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpfrm.h
// Purpose: interface of wxHtmlHelpFrame
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/// style flags for the Help Frame
#define wxHF_TOOLBAR 0x0001
#define wxHF_CONTENTS 0x0002
#define wxHF_INDEX 0x0004
#define wxHF_SEARCH 0x0008
#define wxHF_BOOKMARKS 0x0010
#define wxHF_OPEN_FILES 0x0020
#define wxHF_PRINT 0x0040
#define wxHF_FLAT_TOOLBAR 0x0080
#define wxHF_MERGE_BOOKS 0x0100
#define wxHF_ICONS_BOOK 0x0200
#define wxHF_ICONS_BOOK_CHAPTER 0x0400
#define wxHF_ICONS_FOLDER 0x0000 // this is 0 since it is default
#define wxHF_DEFAULT_STYLE (wxHF_TOOLBAR | wxHF_CONTENTS | \
wxHF_INDEX | wxHF_SEARCH | \
wxHF_BOOKMARKS | wxHF_PRINT)
/**
@class wxHtmlHelpFrame
This class is used by wxHtmlHelpController to display help.
It is an internal class and should not be used directly - except for the case
when you're writing your own HTML help controller.
@library{wxhtml}
@category{help,html}
*/
class wxHtmlHelpFrame : public wxFrame
{
public:
wxHtmlHelpFrame(wxHtmlHelpData* data = nullptr);
/**
Constructor.
For the possible values of @a style, please see wxHtmlHelpController.
*/
wxHtmlHelpFrame(wxWindow* parent, wxWindowID id,
const wxString& title = wxEmptyString,
int style = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = nullptr,
wxConfigBase* config = nullptr,
const wxString& rootpath = wxEmptyString);
/**
You may override this virtual method to add more buttons to the help window's
toolbar. @a toolBar is a pointer to the toolbar and @a style is the style
flag as passed to the Create() method.
wxToolBar::Realize is called immediately after returning from this function.
*/
virtual void AddToolbarButtons(wxToolBar* toolBar, int style);
/**
Creates the frame. See @ref wxHtmlHelpFrame() "the constructor"
for a description of the parameters.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxString& title = wxEmptyString, int style = wxHF_DEFAULT_STYLE,
wxConfigBase* config = nullptr,
const wxString& rootpath = wxEmptyString);
/**
Returns the help controller associated with the frame.
*/
wxHtmlHelpController* GetController() const;
/**
Sets the help controller associated with the frame.
*/
void SetController(wxHtmlHelpController* controller);
/**
Sets the frame's title format.
@a format must contain exactly one "%s" (it will be replaced by the page title).
*/
void SetTitleFormat(const wxString& format);
};

View File

@@ -0,0 +1,197 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpwnd.h
// Purpose: interface of wxHtmlHelpWindow
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/*!
* Command IDs
*/
enum
{
//wxID_HTML_HELPFRAME = wxID_HIGHEST + 1,
wxID_HTML_PANEL = wxID_HIGHEST + 10,
wxID_HTML_BACK,
wxID_HTML_FORWARD,
wxID_HTML_UPNODE,
wxID_HTML_UP,
wxID_HTML_DOWN,
wxID_HTML_PRINT,
wxID_HTML_OPENFILE,
wxID_HTML_OPTIONS,
wxID_HTML_BOOKMARKSLIST,
wxID_HTML_BOOKMARKSADD,
wxID_HTML_BOOKMARKSREMOVE,
wxID_HTML_TREECTRL,
wxID_HTML_INDEXPAGE,
wxID_HTML_INDEXLIST,
wxID_HTML_INDEXTEXT,
wxID_HTML_INDEXBUTTON,
wxID_HTML_INDEXBUTTONALL,
wxID_HTML_NOTEBOOK,
wxID_HTML_SEARCHPAGE,
wxID_HTML_SEARCHTEXT,
wxID_HTML_SEARCHLIST,
wxID_HTML_SEARCHBUTTON,
wxID_HTML_SEARCHCHOICE,
wxID_HTML_COUNTINFO
};
/**
@class wxHtmlHelpWindow
This class is used by wxHtmlHelpController to display help within a frame or
dialog, but you can use it yourself to create an embedded HTML help window.
For example:
@code
// m_embeddedHelpWindow is a wxHtmlHelpWindow
// m_embeddedHtmlHelp is a wxHtmlHelpController
// Create embedded HTML Help window
m_embeddedHelpWindow = new wxHtmlHelpWindow;
m_embeddedHtmlHelp.UseConfig(config, rootPath); // Set your own config object here
m_embeddedHtmlHelp.SetHelpWindow(m_embeddedHelpWindow);
m_embeddedHelpWindow->Create(this, wxID_ANY, wxDefaultPosition, GetClientSize(),
wxTAB_TRAVERSAL|wxBORDER_NONE, wxHF_DEFAULT_STYLE);
m_embeddedHtmlHelp.AddBook(wxFileName("doc.zip"));
@endcode
You should pass the style wxHF_EMBEDDED to the style parameter of
wxHtmlHelpController to allow the embedded window to be destroyed
independently of the help controller.
@library{wxhtml}
@category{help,html}
*/
class wxHtmlHelpWindow : public wxWindow
{
public:
wxHtmlHelpWindow(wxHtmlHelpData* data = nullptr);
/**
Constructor.
For the values of @a helpStyle, please see the documentation for
wxHtmlHelpController.
*/
wxHtmlHelpWindow(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
int style = wxTAB_TRAVERSAL|wxBORDER_NONE,
int helpStyle = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = nullptr);
/**
Creates the help window. See @ref wxHtmlHelpWindow() "the constructor"
for a description of the parameters.
*/
bool Create(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, int style = wxTAB_TRAVERSAL|wxBORDER_NONE,
int helpStyle = wxHF_DEFAULT_STYLE);
/**
Displays page x.
If not found it will give the user the choice of searching books.
Looking for the page runs in these steps:
-# try to locate file named x (if x is for example "doc/howto.htm")
-# try to open starting page of book x
-# try to find x in contents (if x is for example "How To ...")
-# try to find x in index (if x is for example "How To ...")
*/
bool Display(const wxString& x);
/**
@overload
This form takes numeric ID as the parameter (uses an extension to MS format,
param name="ID" value=id).
*/
bool Display(int id);
/**
Displays contents panel.
*/
bool DisplayContents();
/**
Displays index panel.
*/
bool DisplayIndex();
/**
Returns the wxHtmlHelpData object, which is usually a pointer to the
controller's data.
*/
wxHtmlHelpData* GetData();
/**
Search for given keyword. Optionally it searches through the index
(mode = @c wxHELP_SEARCH_INDEX), default the content (mode = @c wxHELP_SEARCH_ALL).
*/
bool KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
/**
Reads the user's settings for this window.
@see wxHtmlHelpController::ReadCustomization
*/
void ReadCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
/**
Associates a wxConfig object with the help window. It is recommended that you
use wxHtmlHelpController::UseConfig instead.
*/
void UseConfig(wxConfigBase* config,
const wxString& rootpath = wxEmptyString);
/**
Saves the user's settings for this window.
@see wxHtmlHelpController::WriteCustomization
*/
void WriteCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
/**
Refresh all panels. This is necessary if a new book was added.
*/
void RefreshLists();
wxHtmlHelpController* GetController() const;
void SetController(wxHtmlHelpController* controller);
protected:
/**
Creates search panel.
*/
void CreateSearch();
/**
You may override this virtual method to add more buttons to the help window's
toolbar. @a toolBar is a pointer to the toolbar and @a style is the style
flag as passed to the Create() method.
wxToolBar::Realize is called immediately after returning from this function.
See @c samples/html/helpview for an example.
*/
virtual void AddToolbarButtons(wxToolBar* toolBar, int style);
/**
Creates contents panel. (May take some time.)
*/
void CreateContents();
/**
Creates index panel. (May take some time.)
*/
void CreateIndex();
};

View File

@@ -0,0 +1,822 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlcell.h
// Purpose: interface of wxHtml*Cell
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlRenderingStyle
wxHtmlSelection is data holder with information about text selection.
Selection is defined by two positions (beginning and end of the selection)
and two leaf(!) cells at these positions.
@library{wxhtml}
@category{html}
*/
class wxHtmlSelection
{
public:
wxHtmlSelection();
// this version is used for the user selection defined with the mouse
void Set(const wxPoint& fromPos, const wxHtmlCell *fromCell,
const wxPoint& toPos, const wxHtmlCell *toCell);
void Set(const wxHtmlCell *fromCell, const wxHtmlCell *toCell);
const wxHtmlCell *GetFromCell() const;
const wxHtmlCell *GetToCell() const;
// these values are in absolute coordinates:
const wxPoint& GetFromPos() const;
const wxPoint& GetToPos() const;
// these are From/ToCell's private data
void ClearFromToCharacterPos();
bool AreFromToCharacterPosSet() const;
void SetFromCharacterPos (wxCoord pos);
void SetToCharacterPos (wxCoord pos);
wxCoord GetFromCharacterPos () const;
wxCoord GetToCharacterPos () const;
bool IsEmpty() const;
};
enum wxHtmlSelectionState
{
wxHTML_SEL_OUT, // currently rendered cell is outside the selection
wxHTML_SEL_IN, // ... is inside selection
wxHTML_SEL_CHANGING // ... is the cell on which selection state changes
};
/**
@class wxHtmlRenderingState
Selection state is passed to wxHtmlCell::Draw so that it can render itself
differently e.g. when inside text selection or outside it.
@library{wxhtml}
@category{html}
*/
class wxHtmlRenderingState
{
public:
wxHtmlRenderingState();
void SetSelectionState(wxHtmlSelectionState s);
wxHtmlSelectionState GetSelectionState() const;
void SetFgColour(const wxColour& c);
const wxColour& GetFgColour() const;
void SetBgColour(const wxColour& c);
const wxColour& GetBgColour() const;
void SetBgMode(int m);
int GetBgMode() const;
};
/**
@class wxHtmlRenderingStyle
Allows HTML rendering customizations.
This class is used when rendering wxHtmlCells as a callback.
@library{wxhtml}
@category{html}
@see wxHtmlRenderingInfo
*/
class wxHtmlRenderingStyle
{
public:
/**
Returns the colour to use for the selected text.
*/
virtual wxColour GetSelectedTextColour(const wxColour& clr) = 0;
/**
Returns the colour to use for the selected text's background.
*/
virtual wxColour GetSelectedTextBgColour(const wxColour& clr) = 0;
};
/**
@class wxHtmlRenderingInfo
This class contains information given to cells when drawing them.
Contains rendering state, selection information and rendering style object
that can be used to customize the output.
@library{wxhtml}
@category{html}
@see @ref overview_html_cells, wxHtmlCell
*/
class wxHtmlRenderingInfo
{
public:
/**
Default ctor.
*/
wxHtmlRenderingInfo();
//@{
/**
Accessors.
*/
void SetSelection(wxHtmlSelection *s);
wxHtmlSelection *GetSelection() const;
void SetStyle(wxHtmlRenderingStyle *style);
wxHtmlRenderingStyle& GetStyle();
wxHtmlRenderingState& GetState();
//@}
};
// Flags for wxHtmlCell::FindCellByPos
enum
{
wxHTML_FIND_EXACT = 1,
wxHTML_FIND_NEAREST_BEFORE = 2,
wxHTML_FIND_NEAREST_AFTER = 4
};
// Superscript/subscript/normal script mode of a cell
enum wxHtmlScriptMode
{
wxHTML_SCRIPT_NORMAL,
wxHTML_SCRIPT_SUB,
wxHTML_SCRIPT_SUP
};
/**
@class wxHtmlCell
Internal data structure. It represents fragments of parsed HTML page, the
so-called @b cell - a word, picture, table, horizontal line and so on.
It is used by wxHtmlWindow and wxHtmlWinParser to represent HTML page in memory.
You can divide cells into two groups : @e visible cells with non-zero width and
height and @e helper cells (usually with zero width and height) that perform
special actions such as color or font change.
@library{wxhtml}
@category{html}
@see @ref overview_html_cells, wxHtmlContainerCell
*/
class wxHtmlCell : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlCell();
/**
This method is called when paginating HTML, e.g.\ when printing.
User code should never call this function, but may need to override it
in custom HTML cell classes with any specific page breaking
requirements.
On input, @a pagebreak contains y-coordinate of page break (i.e. the
horizontal line that should not be crossed by words, images etc.)
relative to the parent cell on entry and may be modified to request a
page break at a position before it if this cell cannot be divided into
two pieces (each one on its own page).
Note that page break must still happen on the current page, i.e. the
returned value must be strictly greater than @code *pagebreak -
pageHeight @endcode and less or equal to @c *pagebreak for the value of
@a pagebreak on input.
@param pagebreak
position in pixels of the pagebreak.
@param pageHeight
the height in pixels of the page drawable area
@return @true if pagebreak was modified, @false otherwise.
*/
virtual bool AdjustPagebreak(int* pagebreak, int pageHeight) const;
/**
Renders the cell.
@param dc
Device context to which the cell is to be drawn.
@param x,y
Coordinates of parent's upper left corner (origin). You must
add this to m_PosX,m_PosY when passing coordinates to dc's methods
Example:
@code
dc->DrawText("hello", x + m_PosX, y + m_PosY)
@endcode
@param view_y1
y-coord of the first line visible in window.
This is used to optimize rendering speed.
@param view_y2
y-coord of the last line visible in window.
This is used to optimize rendering speed.
@param info
Additional information for the rendering of the cell.
*/
virtual void Draw(wxDC& dc, int x, int y, int view_y1, int view_y2, wxHtmlRenderingInfo& info);
/**
This method is called instead of Draw() when the cell is certainly out of
the screen (and thus invisible). This is not nonsense - some tags (like
wxHtmlColourCell or font setter) must be drawn even if they are invisible!
@param dc
Device context to which the cell is to be drawn.
@param x,y
Coordinates of parent's upper left corner. You must
add this to m_PosX,m_PosY when passing coordinates to dc's methods
Example:
@code
dc->DrawText("hello", x + m_PosX, y + m_PosY)
@endcode
@param info
Additional information for the rendering of the cell.
*/
virtual void DrawInvisible(wxDC& dc, int x , int y, wxHtmlRenderingInfo& info);
/**
Returns pointer to itself if this cell matches condition (or if any of the
cells following in the list matches), @NULL otherwise.
(In other words if you call top-level container's Find() it will
return pointer to the first cell that matches the condition)
It is recommended way how to obtain pointer to particular cell or
to cell of some type (e.g. wxHtmlAnchorCell reacts on wxHTML_COND_ISANCHOR
condition).
@param condition
Unique integer identifier of condition
@param param
Optional parameters
*/
virtual const wxHtmlCell* Find(int condition, const void* param) const;
/**
Find a cell inside this cell positioned at the given coordinates
(relative to this's positions). Returns @NULL if no such cell exists.
The flag can be used to specify whether to look for terminal or
nonterminal cells or both. In either case, returned cell is deepest
cell in cells tree that contains [x,y].
*/
virtual wxHtmlCell *FindCellByPos(wxCoord x, wxCoord y,
unsigned flags = wxHTML_FIND_EXACT) const;
/**
Returns descent value of the cell (m_Descent member).
See explanation:
@image html htmlcell_descent.png
*/
int GetDescent() const;
/**
Returns pointer to the first cell in the list.
You can then use child's GetNext() method to obtain pointer to the next
cell in list.
@note This shouldn't be used by the end user. If you need some way of
finding particular cell in the list, try Find() method instead.
*/
virtual wxHtmlCell* GetFirstChild() const;
/**
Returns height of the cell (m_Height member).
*/
int GetHeight() const;
/**
Returns unique cell identifier if there is any, the empty string otherwise.
*/
const wxString& GetId() const;
/**
Returns hypertext link if associated with this cell or @NULL otherwise.
See wxHtmlLinkInfo. (Note: this makes sense only for visible tags).
@param x,y
Coordinates of position where the user pressed mouse button.
These coordinates are used e.g. by COLORMAP. Values are relative to the
upper left corner of THIS cell (i.e. from 0 to m_Width or m_Height)
*/
virtual wxHtmlLinkInfo* GetLink(int x = 0, int y = 0) const;
/**
Returns cursor to show when mouse pointer is over the cell.
@param window
interface to the parent HTML window
@see GetMouseCursorAt()
*/
virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window) const;
/**
Returns cursor to show when mouse pointer is over the specified point.
This function should be overridden instead of GetMouseCursorAt() if
the cursor should depend on the exact position of the mouse in the
window.
@param window
interface to the parent HTML window
@param rePos
Position to show cursor.
@since 3.0
*/
virtual wxCursor GetMouseCursorAt(wxHtmlWindowInterface* window,
const wxPoint& rePos) const;
/**
Returns pointer to the next cell in list (see htmlcell.h if you're
interested in details).
*/
wxHtmlCell* GetNext() const;
/**
Returns pointer to parent container.
*/
wxHtmlContainerCell* GetParent() const;
/**
Returns X position within parent (the value is relative to parent's
upper left corner). The returned value is meaningful only if
parent's Layout() was called before!
*/
int GetPosX() const;
/**
Returns Y position within parent (the value is relative to parent's
upper left corner). The returned value is meaningful only if
parent's Layout() was called before!
*/
int GetPosY() const;
/**
Returns width of the cell (m_Width member).
*/
int GetWidth() const;
/**
Returns true if this cell has a non-empty ID.
@since 3.3.0
*/
bool HasId() const;
/**
Layouts the cell.
This method performs two actions:
-# adjusts the cell's width according to the fact that maximal possible
width is @e w (this has sense when working with horizontal lines, tables etc.)
-# prepares layout (=fill-in m_PosX, m_PosY (and sometimes m_Height) members)
based on actual width @e w
It must be called before displaying cells structure because m_PosX and
m_PosY are undefined (or invalid) before calling Layout().
*/
virtual void Layout(int w);
/**
This function is simple event handler.
Each time the user clicks mouse button over a cell within wxHtmlWindow
this method of that cell is called.
Default behaviour is to call wxHtmlWindow::LoadPage.
@param window
interface to the parent HTML window
@param pos
coordinates of mouse click (this is relative to cell's origin
@param event
mouse event that triggered the call
@return @true if a link was clicked, @false otherwise.
@since 2.7.0 (before OnMouseClick() method served a similar purpose).
@note
If you need more "advanced" event handling you should use wxHtmlBinderCell instead.
*/
virtual bool ProcessMouseClick(wxHtmlWindowInterface* window,
const wxPoint& pos,
const wxMouseEvent& event);
/**
Sets unique cell identifier. Default value is no identifier, i.e. empty string.
*/
void SetId(const wxString& id);
/**
Sets the hypertext link associated with this cell.
(Default value is wxHtmlLinkInfo("", "") (no link))
*/
void SetLink(const wxHtmlLinkInfo& link);
/**
Sets the next cell in the list. This shouldn't be called by user - it is
to be used only by wxHtmlContainerCell::InsertCell.
*/
void SetNext(wxHtmlCell* cell);
/**
Sets parent container of this cell.
This is called from wxHtmlContainerCell::InsertCell.
*/
void SetParent(wxHtmlContainerCell* p);
/**
Sets the cell's position within parent container.
*/
virtual void SetPos(int x, int y);
/**
Converts the cell into text representation. If sel != nullptr then
only part of the cell inside the selection is converted.
*/
virtual wxString ConvertToText(wxHtmlSelection* sel) const;
};
/**
@class wxHtmlContainerCell
The wxHtmlContainerCell class is an implementation of a cell that may
contain more cells in it. It is heavily used in the wxHTML layout algorithm.
@library{wxhtml}
@category{html}
@see @ref overview_html_cells
*/
class wxHtmlContainerCell : public wxHtmlCell
{
public:
/**
Constructor. @a parent is pointer to parent container or @NULL.
*/
explicit wxHtmlContainerCell(wxHtmlContainerCell* parent);
/**
Detach a child cell.
Detaching a cell removes it from this container and allows reattaching
it to another one by using InsertCell(). Alternatively, this method can
be used to selectively remove some elements of the HTML document tree
by deleting the cell after calling it.
@param cell Must be non-null and an immediate child of this cell.
@since 3.1.2
*/
void Detach(wxHtmlCell* cell);
/**
Returns container's horizontal alignment.
*/
int GetAlignHor() const;
/**
Returns container's vertical alignment.
*/
int GetAlignVer() const;
/**
Returns the background colour of the container or @c wxNullColour if no
background colour is set.
*/
wxColour GetBackgroundColour();
/**
Returns the indentation. @a ind is one of the @b wxHTML_INDENT_* constants.
@note You must call GetIndentUnits() with same @a ind parameter in order
to correctly interpret the returned integer value.
It is NOT always in pixels!
*/
int GetIndent(int ind) const;
/**
Returns the units of indentation for @a ind where @a ind is one
of the @b wxHTML_INDENT_* constants.
*/
int GetIndentUnits(int ind) const;
/**
Inserts a new cell into the container.
Note that the container takes ownership of the cell and will delete it
when it itself is destroyed.
*/
void InsertCell(wxHtmlCell* cell);
/**
Sets the container's alignment (both horizontal and vertical) according to
the values stored in @e tag. (Tags @c ALIGN parameter is extracted.)
In fact it is only a front-end to SetAlignHor() and SetAlignVer().
*/
void SetAlign(const wxHtmlTag& tag);
/**
Sets the container's @e horizontal alignment.
During wxHtmlCell::Layout each line is aligned according to @a al value.
@param al
new horizontal alignment. May be one of these values:
- wxHTML_ALIGN_LEFT: lines are left-aligned (default)
- wxHTML_ALIGN_JUSTIFY: lines are justified
- wxHTML_ALIGN_CENTER: lines are centered
- wxHTML_ALIGN_RIGHT: lines are right-aligned
*/
void SetAlignHor(int al);
/**
Sets the container's @e vertical alignment. This is per-line alignment!
@param al
new vertical alignment. May be one of these values:
- wxHTML_ALIGN_BOTTOM: cells are over the line (default)
- wxHTML_ALIGN_CENTER: cells are centered on line
- wxHTML_ALIGN_TOP: cells are under the line
@image html htmlcontcell_alignv.png
*/
void SetAlignVer(int al);
/**
Sets the background colour for this container.
*/
void SetBackgroundColour(const wxColour& clr);
/**
Sets the border (frame) colours. A border is a rectangle around the container.
@param clr1
Colour of top and left lines
@param clr2
Colour of bottom and right lines
@param border
Size of the border in pixels
*/
void SetBorder(const wxColour& clr1, const wxColour& clr2, int border = 1);
/**
Sets the indentation (free space between borders of container and subcells).
@image html htmlcontcell_indent.png
@param i
Indentation value.
@param what
Determines which of the four borders we're setting. It is OR
combination of following constants:
- wxHTML_INDENT_TOP: top border
- wxHTML_INDENT_BOTTOM: bottom
- wxHTML_INDENT_LEFT: left
- wxHTML_INDENT_RIGHT: right
- wxHTML_INDENT_HORIZONTAL: left and right
- wxHTML_INDENT_VERTICAL: top and bottom
- wxHTML_INDENT_ALL: all 4 borders
@param units
Units of i. This parameter affects interpretation of value.
- wxHTML_UNITS_PIXELS: @a i is number of pixels
- wxHTML_UNITS_PERCENT: @a i is interpreted as percents of width
of parent container
*/
void SetIndent(int i, int what, int units = wxHTML_UNITS_PIXELS);
/**
Sets minimal height of the container.
When container's wxHtmlCell::Layout is called, m_Height is set depending
on layout of subcells to the height of area covered by layed-out subcells.
Calling this method guarantees you that the height of container is never
smaller than @a h - even if the subcells cover much smaller area.
@param h
The minimal height.
@param align
If height of the container is lower than the minimum height, empty space
must be inserted somewhere in order to ensure minimal height.
This parameter is one of @c wxHTML_ALIGN_TOP, @c wxHTML_ALIGN_BOTTOM,
@c wxHTML_ALIGN_CENTER. It refers to the contents, not to the
empty place.
*/
void SetMinHeight(int h, int align = wxHTML_ALIGN_TOP);
/**
Sets floating width adjustment.
The normal behaviour of container is that its width is the same as the width of
parent container (and thus you can have only one sub-container per line).
You can change this by setting the floating width adjustment.
@param w
Width of the container. If the value is negative it means
complement to full width of parent container.
E.g. @code SetWidthFloat(-50, wxHTML_UNITS_PIXELS) @endcode sets the
width of container to parent's width minus 50 pixels. This is useful when
creating tables - you can call SetWidthFloat(50) and SetWidthFloat(-50).
@param units
Units of w This parameter affects the interpretation of value.
- wxHTML_UNITS_PIXELS: @a w is number of pixels
- wxHTML_UNITS_PERCENT: @a w is interpreted as percents of width
of parent container
*/
void SetWidthFloat(int w, int units);
/**
Sets floating width adjustment.
The normal behaviour of container is that its width is the same as the width of
parent container (and thus you can have only one sub-container per line).
You can change this by setting the floating width adjustment.
@param tag
In the second version of method, @a w and @a units info is extracted
from tag's WIDTH parameter.
@param pixel_scale
This is number of real pixels that equals to 1 HTML pixel.
*/
void SetWidthFloat(const wxHtmlTag& tag,
double pixel_scale = 1.0);
};
/**
@class wxHtmlLinkInfo
This class stores all necessary information about hypertext links
(as represented by \<A\> tag in HTML documents).
In current implementation it stores URL and target frame name.
@note Frames are not currently supported by wxHTML!
@library{wxhtml}
@category{html}
*/
class wxHtmlLinkInfo : public wxObject
{
public:
/**
Default ctor.
*/
wxHtmlLinkInfo();
/**
Construct hypertext link from HREF (aka URL) and TARGET (name of target frame).
*/
wxHtmlLinkInfo(const wxString& href,
const wxString& target = wxEmptyString);
/**
Return pointer to event that generated OnLinkClicked() event.
Valid only within wxHtmlWindow::OnLinkClicked, @NULL otherwise.
*/
const wxMouseEvent* GetEvent() const;
/**
Return @e HREF value of the \<A\> tag.
*/
wxString GetHref() const;
/**
Return pointer to the cell that was clicked.
Valid only within wxHtmlWindow::OnLinkClicked, @NULL otherwise.
*/
const wxHtmlCell* GetHtmlCell() const;
/**
Return @e TARGET value of the \<A\> tag (this value is used to specify
in which frame should be the page pointed by @ref GetHref() Href opened).
*/
wxString GetTarget() const;
};
/**
@class wxHtmlColourCell
This cell changes the colour of either the background or the foreground.
@library{wxhtml}
@category{html}
*/
class wxHtmlColourCell : public wxHtmlCell
{
public:
/**
Constructor.
@param clr
The color
@param flags
Can be one of following:
- wxHTML_CLR_FOREGROUND: change color of text
- wxHTML_CLR_BACKGROUND: change background color
*/
wxHtmlColourCell(const wxColour& clr, int flags = wxHTML_CLR_FOREGROUND);
};
/**
@class wxHtmlWidgetCell
wxHtmlWidgetCell is a class that provides a connection between HTML cells and
widgets (an object derived from wxWindow).
You can use it to display things like forms, input boxes etc. in an HTML window.
wxHtmlWidgetCell takes care of resizing and moving window.
@library{wxhtml}
@category{html}
*/
class wxHtmlWidgetCell : public wxHtmlCell
{
public:
/**
Constructor.
@param wnd
Connected window. It is parent window @b must be the wxHtmlWindow object
within which it is displayed!
@param w
Floating width. If non-zero width of wnd window is adjusted so that it is
always w percents of parent container's width. (For example w = 100 means
that the window will always have same width as parent container).
*/
wxHtmlWidgetCell(wxWindow* wnd, int w = 0);
};
/**
@class wxHtmlWordCell
This html cell represents a single word or text fragment in the document stream.
@library{wxhtml}
@category{html}
*/
class wxHtmlWordCell : public wxHtmlCell
{
public:
wxHtmlWordCell(const wxString& word, const wxDC& dc);
};
/**
@class wxHtmlWordWithTabsCell
wxHtmlWordCell is a specialization for storing text fragments with
embedded tab characters.
@library{wxhtml}
@category{html}
*/
class wxHtmlWordWithTabsCell : public wxHtmlWordCell
{
public:
wxHtmlWordWithTabsCell(const wxString& word,
const wxString& wordOrig,
size_t linepos,
const wxDC& dc);
};
/**
@class wxHtmlFontCell
This cell represents a font change in the document stream.
@library{wxhtml}
@category{html}
*/
class wxHtmlFontCell : public wxHtmlCell
{
public:
wxHtmlFontCell(wxFont *font);
};

View File

@@ -0,0 +1,78 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmldefs.h
// Purpose: constants for wxhtml library
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
//--------------------------------------------------------------------------------
// ALIGNMENTS
// Describes alignment of text etc. in containers
//--------------------------------------------------------------------------------
#define wxHTML_ALIGN_LEFT 0x0000
#define wxHTML_ALIGN_RIGHT 0x0002
#define wxHTML_ALIGN_JUSTIFY 0x0010
#define wxHTML_ALIGN_TOP 0x0004
#define wxHTML_ALIGN_BOTTOM 0x0008
#define wxHTML_ALIGN_CENTER 0x0001
//--------------------------------------------------------------------------------
// COLOR MODES
// Used by wxHtmlColourCell to determine clr of what is changing
//--------------------------------------------------------------------------------
#define wxHTML_CLR_FOREGROUND 0x0001
#define wxHTML_CLR_BACKGROUND 0x0002
#define wxHTML_CLR_TRANSPARENT_BACKGROUND 0x0004
//--------------------------------------------------------------------------------
// UNITS
// Used to specify units
//--------------------------------------------------------------------------------
#define wxHTML_UNITS_PIXELS 0x0001
#define wxHTML_UNITS_PERCENT 0x0002
//--------------------------------------------------------------------------------
// INDENTS
// Used to specify indetation relatives
//--------------------------------------------------------------------------------
#define wxHTML_INDENT_LEFT 0x0010
#define wxHTML_INDENT_RIGHT 0x0020
#define wxHTML_INDENT_TOP 0x0040
#define wxHTML_INDENT_BOTTOM 0x0080
#define wxHTML_INDENT_HORIZONTAL (wxHTML_INDENT_LEFT | wxHTML_INDENT_RIGHT)
#define wxHTML_INDENT_VERTICAL (wxHTML_INDENT_TOP | wxHTML_INDENT_BOTTOM)
#define wxHTML_INDENT_ALL (wxHTML_INDENT_VERTICAL | wxHTML_INDENT_HORIZONTAL)
//--------------------------------------------------------------------------------
// FIND CONDITIONS
// Identifiers of wxHtmlCell's Find() conditions
//--------------------------------------------------------------------------------
#define wxHTML_COND_ISANCHOR 1
// Finds the anchor of 'param' name (pointer to wxString).
#define wxHTML_COND_ISIMAGEMAP 2
// Finds imagemap of 'param' name (pointer to wxString).
// (used exclusively by m_image.cpp)
#define wxHTML_COND_USER 10000
// User-defined conditions should start from this number

View File

@@ -0,0 +1,52 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlfilt.h
// Purpose: interface of wxHtmlFilter
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlFilter
This class is the parent class of input filters for wxHtmlWindow.
It allows you to read and display files of different file formats.
@library{wxhtml}
@category{html}
@see @ref overview_html_filters
*/
class wxHtmlFilter : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlFilter();
/**
Returns @true if this filter is capable of reading file @e file.
Example:
@code
bool MyFilter::CanRead(const wxFSFile& file)
{
return (file.GetMimeType() == "application/x-ugh");
}
@endcode
*/
virtual bool CanRead(const wxFSFile& file) const = 0;
/**
Reads the file and returns string with HTML document.
Example:
@code
wxString MyImgFilter::ReadFile(const wxFSFile& file)
{
return "<html><body><img src=\"" + file.GetLocation() +
"\"></body></html>";
}
@endcode
*/
virtual wxString ReadFile(const wxFSFile& file) const = 0;
};

View File

@@ -0,0 +1,330 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlpars.h
// Purpose: interface of wxHtmlTagHandler
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
enum wxHtmlURLType
{
wxHTML_URL_PAGE,
wxHTML_URL_IMAGE,
wxHTML_URL_OTHER
};
/**
@class wxHtmlTagHandler
@todo describe me
@library{wxhtml}
@category{html}
@see @ref overview_html_handlers, wxHtmlTag
*/
class wxHtmlTagHandler : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlTagHandler();
/**
Returns list of supported tags.
The list is in uppercase and tags are delimited by ','.
Example: @c "I,B,FONT,P"
*/
virtual wxString GetSupportedTags() = 0;
/**
This is the core method of each handler. It is called each time
one of supported tags is detected. @a tag contains all necessary
info (see wxHtmlTag for details).
Example:
@code
bool MyHandler::HandleTag(const wxHtmlTag& tag)
{
...
// change state of parser (e.g. set bold face)
ParseInner(tag);
...
// restore original state of parser
}
@endcode
You shouldn't call ParseInner() if the tag is not paired with an ending one.
@return @true if ParseInner() was called, @false otherwise.
*/
virtual bool HandleTag(const wxHtmlTag& tag) = 0;
/**
Assigns @a parser to this handler. Each @b instance of handler
is guaranteed to be called only from the one parser.
*/
virtual void SetParser(wxHtmlParser* parser);
/**
Returns the parser associated with this tag handler.
@since 2.9.5
*/
wxHtmlParser* GetParser() const;
protected:
/**
This method calls parser's wxHtmlParser::DoParsing method
for the string between this tag and the paired ending tag:
@code
...<A HREF="x.htm">Hello, world!</A>...
@endcode
In this example, a call to ParseInner() (with @a tag pointing to A tag)
will parse 'Hello, world!'.
*/
void ParseInner(const wxHtmlTag& tag);
/**
Parses given source as if it was tag's inner code (see
wxHtmlParser::GetInnerSource). Unlike ParseInner(), this method lets
you specify the source code to parse. This is useful when you need to
modify the inner text before parsing.
*/
void ParseInnerSource(const wxString& source);
/**
This attribute is used to access parent parser. It is protected so that
it can't be accessed by user but can be accessed from derived classes.
*/
wxHtmlParser* m_Parser;
};
/**
@class wxHtmlParser
Classes derived from this handle the @b generic parsing of HTML documents: it
scans the document and divide it into blocks of tags (where one block consists
of beginning and ending tag and of text between these two tags).
It is independent from wxHtmlWindow and can be used as stand-alone parser.
It uses system of tag handlers to parse the HTML document. Tag handlers
are not statically shared by all instances but are created for each
wxHtmlParser instance. The reason is that the handler may contain
document-specific temporary data used during parsing (e.g. complicated
structures like tables).
Typically the user calls only the wxHtmlParser::Parse method.
@library{wxhtml}
@category{html}
@see @ref overview_html_cells, @ref overview_html_handlers, wxHtmlTag
*/
class wxHtmlParser
{
public:
/**
Constructor.
*/
wxHtmlParser();
/**
Adds handler to the internal list ( hash table) of handlers.
This method should not be called directly by user but rather by derived class'
constructor.
This adds the handler to this @b instance of wxHtmlParser, not to
all objects of this class!
(Static front-end to AddTagHandler is provided by wxHtmlWinParser).
All handlers are deleted on object deletion.
*/
virtual void AddTagHandler(wxHtmlTagHandler* handler);
/**
Must be overwritten in derived class.
This method is called by DoParsing() each time a part of text is parsed.
@a txt is NOT only one word, it is substring of input.
It is not formatted or preprocessed (so white spaces are unmodified).
*/
virtual void AddWord(const wxString& txt);
/**
Parses the m_Source from @a begin_pos to @a end_pos - 1.
*/
void DoParsing(const const_iterator& begin_pos, const const_iterator& end_pos);
/**
Parses the whole m_Source.
*/
void DoParsing();
/**
This must be called after DoParsing().
*/
virtual void DoneParser();
/**
Returns pointer to the file system. Because each tag handler has
reference to it is parent parser it can easily request the file by
calling:
@code
wxFSFile *f = m_Parser -> GetFS() -> OpenFile("image.jpg");
@endcode
*/
wxFileSystem* GetFS() const;
/**
Returns product of parsing.
Returned value is result of parsing of the document.
The type of this result depends on internal representation in derived
parser (but it must be derived from wxObject!).
See wxHtmlWinParser for details.
*/
virtual wxObject* GetProduct() = 0;
/**
Returns pointer to the source being parsed.
*/
const wxString* GetSource();
/**
Setups the parser for parsing the @a source string.
(Should be overridden in derived class)
*/
virtual void InitParser(const wxString& source);
/**
Opens given URL and returns @c wxFSFile object that can be used to read data
from it. This method may return @NULL in one of two cases: either the URL doesn't
point to any valid resource or the URL is blocked by overridden implementation
of @e OpenURL in derived class.
@param type
Indicates type of the resource. Is one of:
- wxHTML_URL_PAGE: Opening a HTML page.
- wxHTML_URL_IMAGE: Opening an image.
- wxHTML_URL_OTHER: Opening a resource that doesn't fall into
any other category.
@param url
URL being opened.
@note
Always use this method in tag handlers instead of GetFS()->OpenFile()
because it can block the URL and is thus more secure.
Default behaviour is to call wxHtmlWindow::OnOpeningURL of the associated
wxHtmlWindow object (which may decide to block the URL or redirect it to
another one),if there's any, and always open the URL if the parser is not
used with wxHtmlWindow.
Returned wxFSFile object is not guaranteed to point to url, it might have
been redirected!
*/
virtual wxFSFile* OpenURL(wxHtmlURLType type, const wxString& url) const;
/**
Proceeds parsing of the document. This is end-user method. You can simply
call it when you need to obtain parsed output (which is parser-specific).
The method does these things:
-# calls InitParser(source)
-# calls DoParsing()
-# calls GetProduct()
-# calls DoneParser()
-# returns value returned by GetProduct()
You shouldn't use InitParser(), DoParsing(), GetProduct() or DoneParser() directly.
*/
wxObject* Parse(const wxString& source);
/**
Restores parser's state before last call to PushTagHandler().
*/
void PopTagHandler();
/**
Forces the handler to handle additional tags
(not returned by wxHtmlTagHandler::GetSupportedTags).
The handler should already be added to this parser.
@param handler
the handler
@param tags
List of tags (in same format as GetSupportedTags()'s return value).
The parser will redirect these tags to handler (until call to PopTagHandler()).
Example:
Imagine you want to parse following pseudo-html structure:
@code
<myitems>
<param name="one" value="1">
<param name="two" value="2">
</myitems>
<execute>
<param program="text.exe">
</execute>
@endcode
It is obvious that you cannot use only one tag handler for \<param\> tag.
Instead you must use context-sensitive handlers for \<param\> inside \<myitems\>
and \<param\> inside \<execute\>.
This is the preferred solution:
@code
TAG_HANDLER_BEGIN(MYITEM, "MYITEMS")
TAG_HANDLER_PROC(tag)
{
// ...something...
m_Parser -> PushTagHandler(this, "PARAM");
ParseInner(tag);
m_Parser -> PopTagHandler();
// ...something...
}
TAG_HANDLER_END(MYITEM)
@endcode
*/
void PushTagHandler(wxHtmlTagHandler* handler,
const wxString& tags);
/**
Sets the virtual file system that will be used to request additional files.
(For example @c IMG tag handler requests wxFSFile with the image data.)
*/
void SetFS(wxFileSystem* fs);
/**
Call this function to interrupt parsing from a tag handler.
No more tags will be parsed afterward. This function may only be called
from Parse() or any function called by it (i.e. from tag handlers).
*/
virtual void StopParsing();
protected:
/**
This may (and may not) be overwritten in derived class.
This method is called each time new tag is about to be added.
@a tag contains information about the tag. (See wxHtmlTag for details.)
Default (wxHtmlParser) behaviour is this: first it finds a handler capable
of handling this tag and then it calls handler's HandleTag() method.
*/
virtual void AddTag(const wxHtmlTag& tag);
};

View File

@@ -0,0 +1,204 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmltag.h
// Purpose: interface of wxHtmlTag
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlTag
This class represents a single HTML tag.
It is used by @ref overview_html_handlers "tag handlers".
@library{wxhtml}
@category{html}
*/
class wxHtmlTag
{
protected:
/**
Constructor. You will probably never have to construct a wxHtmlTag object
yourself. Feel free to ignore the constructor parameters.
Have a look at @c src/html/htmlpars.cpp if you're interested in creating it.
*/
wxHtmlTag(wxHtmlTag* parent, const wxString* source,
const const_iterator& pos, const const_iterator& end_pos,
wxHtmlTagsCache* cache, wxHtmlEntitiesParser* entParser);
public:
/**
Returns a string containing all parameters.
Example: tag contains \<FONT SIZE=+2 COLOR="#000000"\>.
Call to tag.GetAllParams() would return @c 'SIZE=+2 COLOR="#000000"'.
*/
wxString GetAllParams() const;
/**
Returns beginning position of the text @e between this tag and paired
ending tag. See explanation (returned position is marked with '|'):
@code
bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|
@endcode
@deprecated @todo provide deprecation description
*/
int GetBeginPos() const;
/**
Returns ending position of the text @e between this tag and paired
ending tag. See explanation (returned position is marked with '|'):
@code
bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|
@endcode
@deprecated @todo provide deprecation description
*/
int GetEndPos1() const;
/**
Returns ending position 2 of the text @e between this tag and paired
ending tag. See explanation (returned position is marked with '|'):
@code
bla bla bla <MYTAG> bla bla internal text</MYTAG> bla bla
|
@endcode
@deprecated @todo provide deprecation description
*/
int GetEndPos2() const;
/**
Returns tag's name. The name is always in uppercase and it doesn't contain
&quot; or '/' characters. (So the name of \<FONT SIZE=+2\> tag is "FONT"
and name of \</table\> is "TABLE").
*/
wxString GetName() const;
/**
Returns the value of the parameter.
You should check whether the parameter exists or not (use
wxHtmlTag::HasParam) first or use GetParamAsString() if you need to
distinguish between non-specified and empty parameter values.
@param par
The parameter's name.
@param with_quotes
@true if you want to get quotes as well. See example.
Example:
@code
...
// you have wxHtmlTag variable tag which is equal to the
// HTML tag <FONT SIZE=+2 COLOR="#0000FF">
dummy = tag.GetParam("SIZE");
// dummy == "+2"
dummy = tag.GetParam("COLOR");
// dummy == "#0000FF"
dummy = tag.GetParam("COLOR", true);
// dummy == "\"#0000FF\"" -- see the difference!!
@endcode
*/
wxString GetParam(const wxString& par, bool with_quotes = false) const;
/**
Interprets tag parameter @a par as colour specification and saves its value
into wxColour variable pointed by @a clr.
Returns @true on success and @false if @a par is not colour specification or
if the tag has no such parameter.
@see ParseAsColour()
*/
bool GetParamAsColour(const wxString& par, wxColour* clr) const;
/**
Interprets tag parameter @a par as an integer and saves its value
into int variable pointed by @a value.
Returns @true on success and @false if @a par is not an integer or
if the tag has no such parameter.
*/
bool GetParamAsInt(const wxString& par, int* value) const;
/**
Get the value of the parameter.
If the tag doesn't have such parameter at all, simply returns @false.
Otherwise, fills @a value with the parameter value and returns @true.
@param par
The parameter's name.
@param value
Pointer to the string to be filled with the parameter value, must
be non-null.
@since 3.0
*/
bool GetParamAsString(const wxString& par, wxString* value) const;
/**
Returns @true if this tag is paired with ending tag, @false otherwise.
See the example of HTML document:
@code
<html><body>
Hello<p>
How are you?
<p align=center>This is centered...</p>
Oops<br>Oooops!
</body></html>
@endcode
In this example tags HTML and BODY have ending tags, first P and BR
doesn't have ending tag while the second P has.
The third P tag (which is ending itself) of course doesn't have ending tag.
*/
bool HasEnding() const;
/**
Returns @true if the tag has a parameter of the given name.
Example: \<FONT SIZE=+2 COLOR="\#FF00FF"\> has two parameters named
"SIZE" and "COLOR".
@param par
the parameter you're looking for.
*/
bool HasParam(const wxString& par) const;
/**
Parses the given string as an HTML colour.
This function recognizes the standard named HTML 4 colours as well as
the usual RGB syntax.
@since 2.9.1
@see wxColour::Set()
@return @true if the string was successfully parsed and @a clr was
filled with the result or @false otherwise.
*/
static bool ParseAsColour(const wxString& str, wxColour *clr);
//@{
/**
This method scans the given parameter. Usage is exactly the same as sscanf's
usage except that you don't pass a string but a parameter name as the first
argument and you can only retrieve one value (i.e. you can use only one "%"
element in @a format).
@param par
The name of the tag you want to query
@param format
scanf()-like format string.
@param value
pointer to a variable to store the value in
*/
int ScanParam(const wxString& par, const wchar_t* format, void* value) const;
int ScanParam(const wxString& par, const char* format, void* value) const;
//@}
};

View File

@@ -0,0 +1,643 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlwin.h
// Purpose: interface of wxHtmlWindow
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// wxHtmlWindow flags:
#define wxHW_SCROLLBAR_NEVER 0x0002
#define wxHW_SCROLLBAR_AUTO 0x0004
#define wxHW_NO_SELECTION 0x0008
#define wxHW_DEFAULT_STYLE wxHW_SCROLLBAR_AUTO
/// Enum for wxHtmlWindow::OnOpeningURL and wxHtmlWindowInterface::OnOpeningURL
enum wxHtmlOpeningStatus
{
/// Open the requested URL
wxHTML_OPEN,
/// Do not open the URL
wxHTML_BLOCK,
/// Redirect to another URL (returned from OnOpeningURL)
wxHTML_REDIRECT
};
/**
@class wxHtmlWindowInterface
Abstract interface to a HTML rendering window (such as wxHtmlWindow or
wxHtmlListBox) that is passed to wxHtmlWinParser. It encapsulates all
communication from the parser to the window.
*/
class wxHtmlWindowInterface
{
public:
/// Ctor
wxHtmlWindowInterface();
virtual ~wxHtmlWindowInterface();
/**
Called by the parser to set window's title to given text.
*/
virtual void SetHTMLWindowTitle(const wxString& title) = 0;
/**
Called when a link is clicked.
@param link information about the clicked link
*/
virtual void OnHTMLLinkClicked(const wxHtmlLinkInfo& link) = 0;
/**
Called when the parser needs to open another URL (e.g. an image).
@param type Type of the URL request (e.g. image)
@param url URL the parser wants to open
@param redirect If the return value is wxHTML_REDIRECT, then the
URL to redirect to will be stored in this variable
(the pointer must never be @NULL)
@return indicator of how to treat the request
*/
virtual wxHtmlOpeningStatus OnHTMLOpeningURL(wxHtmlURLType type,
const wxString& url,
wxString *redirect) const = 0;
/**
Converts coordinates @a pos relative to given @a cell to
physical coordinates in the window.
*/
virtual wxPoint HTMLCoordsToWindow(wxHtmlCell *cell,
const wxPoint& pos) const = 0;
/// Returns the window used for rendering (may be @NULL).
virtual wxWindow* GetHTMLWindow() = 0;
/// Returns background colour to use by default.
virtual wxColour GetHTMLBackgroundColour() const = 0;
/// Sets window's background to colour @a clr.
virtual void SetHTMLBackgroundColour(const wxColour& clr) = 0;
/// Sets window's background to given bitmap.
virtual void SetHTMLBackgroundImage(const wxBitmapBundle& bmpBg) = 0;
/// Sets status bar text.
virtual void SetHTMLStatusText(const wxString& text) = 0;
/// Type of mouse cursor
enum HTMLCursor
{
/// Standard mouse cursor (typically an arrow)
HTMLCursor_Default,
/// Cursor shown over links
HTMLCursor_Link,
/// Cursor shown over selectable text
HTMLCursor_Text
};
/**
Returns mouse cursor of given @a type.
*/
virtual wxCursor GetHTMLCursor(wxHtmlWindowInterface::HTMLCursor type) const = 0;
};
/**
@class wxHtmlWindow
wxHtmlWindow is probably the only class you will directly use unless you
want to do something special (like adding new tag handlers or MIME filters).
The purpose of this class is to display rich content pages (either local
file or downloaded via HTTP protocol) in a window based on a subset of the
HTML standard. The width of the window is constant, given in the constructor
and virtual height is changed dynamically depending on page size. Once the
window is created you can set its content by calling SetPage() with raw
HTML, LoadPage() with a wxFileSystem location or LoadFile() with a filename.
@note If you want complete HTML/CSS support as well as a Javascript engine,
consider using wxWebView instead.
wxHtmlWindow uses the wxImage class for displaying images, so you need to
initialize the handlers for any image formats you use before loading a page.
See ::wxInitAllImageHandlers and wxImage::AddHandler.
@beginStyleTable
@style{wxHW_SCROLLBAR_NEVER}
Never display scrollbars, not even when the page is larger than the
window.
@style{wxHW_SCROLLBAR_AUTO}
Display scrollbars only if page's size exceeds window's size.
@style{wxHW_NO_SELECTION}
Don't allow the user to select text.
@endStyleTable
@beginEventEmissionTable{wxHtmlCellEvent, wxHtmlLinkEvent}
@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)}
A wxHtmlCell which contains a hyperlink was clicked.
@endEventTable
@library{wxhtml}
@category{html}
@see wxHtmlLinkEvent, wxHtmlCellEvent
*/
class wxHtmlWindow : public wxScrolledWindow, public wxHtmlWindowInterface
{
public:
/**
Default ctor.
*/
wxHtmlWindow();
/**
Constructor.
The parameters are the same as wxScrolled::wxScrolled() constructor.
*/
wxHtmlWindow(wxWindow *parent, wxWindowID id = wxID_ANY,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHW_DEFAULT_STYLE,
const wxString& name = "htmlWindow");
/**
Adds an @ref overview_html_filters "input filter" to the static list of
available filters. These filters are present by default:
@code
text/html
text/plain
image/*
@endcode
The plain text filter will be used if no other filter matches.
*/
static void AddFilter(wxHtmlFilter* filter);
/**
Appends HTML fragment to currently displayed text and refreshes the window.
@param source
HTML code fragment
@return @false if an error occurred, @true otherwise.
*/
bool AppendToPage(const wxString& source);
/**
Returns pointer to the top-level container.
@see @ref overview_html_cells, @ref overview_printing
*/
wxHtmlContainerCell* GetInternalRepresentation() const;
/**
Returns anchor within currently opened page (see wxHtmlWindow::GetOpenedPage).
If no page is opened or if the displayed page wasn't produced by call to
LoadPage(), empty string is returned.
*/
wxString GetOpenedAnchor() const;
/**
Returns full location of the opened page.
If no page is opened or if the displayed page wasn't produced by call to
LoadPage(), empty string is returned.
*/
wxString GetOpenedPage() const;
/**
Returns title of the opened page or wxEmptyString if the current page does not
contain \<TITLE\> tag.
*/
wxString GetOpenedPageTitle() const;
/**
Returns a pointer to the current parser.
*/
wxHtmlWinParser *GetParser() const;
/**
Returns the related frame.
*/
wxFrame* GetRelatedFrame() const;
/**
Moves back to the previous page. Only pages displayed using LoadPage()
are stored in history list.
*/
bool HistoryBack();
/**
Returns @true if it is possible to go back in the history
i.e. HistoryBack() won't fail.
*/
bool HistoryCanBack();
/**
Returns @true if it is possible to go forward in the history
i.e. HistoryForward() won't fail.
*/
bool HistoryCanForward();
/**
Clears history.
*/
void HistoryClear();
/**
Moves to next page in history. Only pages displayed using LoadPage()
are stored in history list.
*/
bool HistoryForward();
/**
Loads an HTML page from a file and displays it.
@return @false if an error occurred, @true otherwise
@see LoadPage()
*/
bool LoadFile(const wxFileName& filename);
/**
Unlike SetPage() this function first loads the HTML page from @a location
and then displays it.
@param location
The address of the document.
See the @ref overview_fs for details on the address format
and wxFileSystem for a description of how the file is opened.
@return @false if an error occurred, @true otherwise
@see LoadFile()
*/
virtual bool LoadPage(const wxString& location);
/**
Called when user clicks on hypertext link.
Default behaviour is to emit a wxHtmlLinkEvent and, if the event was not
processed or skipped, call LoadPage() and do nothing else.
Overloading this method is deprecated; intercept the event instead.
Also see wxHtmlLinkInfo.
*/
virtual void OnLinkClicked(const wxHtmlLinkInfo& link);
/**
Called when an URL is being opened (either when the user clicks on a link or
an image is loaded). The URL will be opened only if OnOpeningURL() returns
@c wxHTML_OPEN. This method is called by wxHtmlParser::OpenURL.
You can override OnOpeningURL() to selectively block some URLs
(e.g. for security reasons) or to redirect them elsewhere.
Default behaviour is to always return @c wxHTML_OPEN.
@param type
Indicates type of the resource. Is one of
- wxHTML_URL_PAGE: Opening a HTML page.
- wxHTML_URL_IMAGE: Opening an image.
- wxHTML_URL_OTHER: Opening a resource that doesn't fall into
any other category.
@param url
URL being opened.
@param redirect
Pointer to wxString variable that must be filled with an
URL if OnOpeningURL() returns @c wxHTML_REDIRECT.
The return value is:
- wxHTML_OPEN: Open the URL.
- wxHTML_BLOCK: Deny access to the URL, wxHtmlParser::OpenURL will return @NULL.
- wxHTML_REDIRECT: Don't open url, redirect to another URL.
OnOpeningURL() must fill *redirect with the new URL.
OnOpeningURL() will be called again on returned URL.
*/
virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
const wxString& url,
wxString* redirect) const;
/**
Called on parsing \<TITLE\> tag.
*/
virtual void OnSetTitle(const wxString& title);
/**
This reads custom settings from wxConfig. It uses the path 'path'
if given, otherwise it saves info into currently selected path.
The values are stored in sub-path @c wxHtmlWindow.
Read values: all things set by SetFonts(), SetBorders().
@param cfg
wxConfig from which you want to read the configuration.
@param path
Optional path in config tree. If not given current path is used.
*/
virtual void ReadCustomization(wxConfigBase* cfg,
wxString path = wxEmptyString);
/**
Selects all text in the window.
@see SelectLine(), SelectWord()
*/
void SelectAll();
/**
Selects the line of text that @a pos points at. Note that @e pos
is relative to the top of displayed page, not to window's origin, use
wxScrolled::CalcUnscrolledPosition()
to convert physical coordinate.
@see SelectAll(), SelectWord()
*/
void SelectLine(const wxPoint& pos);
/**
Selects the word at position @a pos.
Note that @a pos is relative to the top of displayed page, not to window's
origin, use wxScrolled::CalcUnscrolledPosition() to convert physical coordinate.
@see SelectAll(), SelectLine()
*/
void SelectWord(const wxPoint& pos);
/**
Returns the current selection as plain text.
Returns an empty string if no text is currently selected.
*/
wxString SelectionToText();
/**
This function sets the space between border of window and HTML contents.
See image:
@image html htmlwin_border.png
@param b
indentation from borders in pixels
*/
void SetBorders(int b);
/**
This function sets font sizes and faces. See wxHtmlDCRenderer::SetFonts
for detailed description.
@see SetSize()
*/
void SetFonts(const wxString& normal_face, const wxString& fixed_face,
const int* sizes = nullptr);
/**
Sets default font sizes and/or default font size.
See wxHtmlDCRenderer::SetStandardFonts for detailed description.
@see SetFonts()
*/
void SetStandardFonts(int size = -1,
const wxString& normal_face = wxEmptyString,
const wxString& fixed_face = wxEmptyString);
/**
Sets the source of a page and displays it, for example:
@code
htmlwin -> SetPage("<html><body>Hello, world!</body></html>");
@endcode
If you want to load a document from some location use LoadPage() instead.
@param source
The HTML to be displayed.
@return @false if an error occurred, @true otherwise.
*/
virtual bool SetPage(const wxString& source);
/**
Sets the frame in which page title will be displayed.
@a format is the format of the frame title, e.g. "HtmlHelp : %s".
It must contain exactly one %s.
This %s is substituted with HTML page title.
*/
void SetRelatedFrame(wxFrame* frame, const wxString& format);
/**
@b After calling SetRelatedFrame(), this sets statusbar slot where messages
will be displayed. (Default is -1 = no messages.)
@param index
Statusbar slot number (0..n)
*/
void SetRelatedStatusBar(int index);
/**
@b Sets the associated statusbar where messages will be displayed.
Call this instead of SetRelatedFrame() if you want statusbar updates only,
no changing of the frame title.
@param statusbar
Statusbar pointer
@param index
Statusbar slot number (0..n)
@since 2.9.0
*/
void SetRelatedStatusBar(wxStatusBar* statusbar, int index = 0);
/**
Returns content of currently displayed page as plain text.
*/
wxString ToText();
/**
Saves custom settings into wxConfig.
It uses the path 'path' if given, otherwise it saves info into currently
selected path.
Regardless of whether the path is given or not, the function creates
sub-path @c wxHtmlWindow.
Saved values: all things set by SetFonts(), SetBorders().
@param cfg
wxConfig to which you want to save the configuration.
@param path
Optional path in config tree. If not given, the current path is used.
*/
virtual void WriteCustomization(wxConfigBase* cfg,
wxString path = wxEmptyString);
/**
Retrieves the default cursor for a given HTMLCursor type.
@param type
HTMLCursor type to retrieve.
@param window
The window for which the cursor is requested, should be non-@NULL
to use the appropriate DPI. If @NULL, default application window is
used to determine the desired cursor size. This parameter is new
since wxWidgets 3.3.0.
@since 3.1.0
*/
static wxCursor GetDefaultHTMLCursor(HTMLCursor type,
const wxWindow* window = nullptr);
/**
Sets the default cursor for a given HTMLCursor type.
These cursors are used for all wxHtmlWindow objects by default, but can
be overridden on a per-window basis.
@param type
HTMLCursor type to retrieve.
@param cursor
The default cursor for the specified cursor type.
@since 3.1.0
*/
static void SetDefaultHTMLCursor(HTMLCursor type, const wxCursor& cursor);
protected:
/**
This method is called when a mouse button is clicked inside wxHtmlWindow.
The default behaviour is to emit a wxHtmlCellEvent and, if the event was
not processed or skipped, call OnLinkClicked() if the cell contains a
hypertext link.
Overloading this method is deprecated; intercept the event instead.
@param cell
The cell inside which the mouse was clicked, always a simple
(i.e. non-container) cell
@param x
The logical x coordinate of the click point
@param y
The logical y coordinate of the click point
@param event
The mouse event containing other information about the click
@return @true if a link was clicked, @false otherwise.
*/
virtual bool OnCellClicked(wxHtmlCell* cell, wxCoord x, wxCoord y,
const wxMouseEvent& event);
/**
This method is called when a mouse moves over an HTML cell.
Default behaviour is to emit a wxHtmlCellEvent.
Overloading this method is deprecated; intercept the event instead.
@param cell
The cell inside which the mouse is currently, always a simple
(i.e. non-container) cell
@param x
The logical x coordinate of the click point
@param y
The logical y coordinate of the click point
*/
virtual void OnCellMouseHover(wxHtmlCell* cell, wxCoord x, wxCoord y);
};
wxEventType wxEVT_HTML_CELL_CLICKED;
wxEventType wxEVT_HTML_CELL_HOVER;
wxEventType wxEVT_HTML_LINK_CLICKED;
/**
@class wxHtmlLinkEvent
This event class is used for the events generated by wxHtmlWindow.
@beginEventTable{wxHtmlLinkEvent}
@event{EVT_HTML_LINK_CLICKED(id, func)}
User clicked on a hyperlink.
@endEventTable
@library{wxhtml}
@category{html,events}
*/
class wxHtmlLinkEvent : public wxCommandEvent
{
public:
/**
The constructor is not normally used by the user code.
*/
wxHtmlLinkEvent(int id, const wxHtmlLinkInfo& linkinfo);
/**
Returns the wxHtmlLinkInfo which contains info about the cell clicked
and the hyperlink it contains.
*/
const wxHtmlLinkInfo& GetLinkInfo() const;
};
/**
@class wxHtmlCellEvent
This event class is used for the events generated by wxHtmlWindow.
@beginEventTable{wxHtmlCellEvent}
@event{EVT_HTML_CELL_HOVER(id, func)}
User moved the mouse over a wxHtmlCell.
@event{EVT_HTML_CELL_CLICKED(id, func)}
User clicked on a wxHtmlCell. When handling this event, remember to use
wxHtmlCell::SetLinkClicked(true) if the cell contains a link.
@endEventTable
@library{wxhtml}
@category{html,events}
*/
class wxHtmlCellEvent : public wxCommandEvent
{
public:
/**
The constructor is not normally used by the user code.
*/
wxHtmlCellEvent(wxEventType commandType, int id,
wxHtmlCell* cell,
const wxPoint& point,
const wxMouseEvent& ev);
/**
Returns the wxHtmlCellEvent associated with the event.
*/
wxHtmlCell* GetCell() const;
/**
Returns @true if SetLinkClicked(@true) has previously been called;
@false otherwise.
*/
bool GetLinkClicked() const;
/**
Returns the wxPoint associated with the event.
*/
wxPoint GetPoint() const;
/**
Returns the wxMouseEvent associated with the event.
*/
wxMouseEvent GetMouseEvent() const;
/**
Call this function with @a linkclicked set to @true if the cell which has
been clicked contained a link or @false otherwise (which is the default).
With this function the event handler can return info to the wxHtmlWindow
which sent the event.
*/
void SetLinkClicked(bool linkclicked);
};

View File

@@ -0,0 +1,520 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmprint.h
// Purpose: interface of wxHtmlDCRenderer
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlDCRenderer
This class can render HTML document into a specified area of a DC.
You can use it in your own printing code, although use of wxHtmlEasyPrinting
or wxHtmlPrintout is strongly recommended.
@library{wxhtml}
@category{html}
*/
class wxHtmlDCRenderer : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlDCRenderer();
/**
Returns the width of the HTML text in pixels.
This can be compared with the width parameter of SetSize() to check if
the document being printed fits into the page boundary.
@see GetTotalHeight()
@since 2.9.0
*/
int GetTotalWidth() const;
/**
Returns the height of the HTML text in pixels.
If the height of the area used with this renderer (see
wxHtmlDCRenderer::SetSize) is smaller that total height, the renderer
will produce more than one page of output.
@see GetTotalWidth()
*/
int GetTotalHeight() const;
/**
Finds the next page break after the specified (vertical) position.
An example of using this method:
@code
std::vector<int> pages;
for ( int pos = 0; pos != wxNOT_FOUND; pos = renderer.FindNextPageBreak(pos) )
{
pages.push_back(pos);
}
// "pages" vector now contains all page break positions and, in
// particular, its size() returns the number of pages
@endcode
@param pos Absolute position of the last page break. For the initial
call of this function, it should be 0 and for the subsequent ones
it should be the previous return value.
@return Position of the next page break or @c wxNOT_FOUND if there are
no more of them.
@since 3.1.2
*/
int FindNextPageBreak(int pos) const;
/**
Renders HTML text to the DC.
When using multi-page documents, FindNextPageBreak() can be used to
find the values for @a from and @a to, which should be the consecutive
page breaks returned by that function.
@param x,y
position of upper-left corner of printing rectangle (see SetSize()).
@param from
y-coordinate of the very first visible cell.
@param to
y-coordinate of the last visible cell or @c INT_MAX to use the full
page height.
@note
The following three methods @b must always be called before any call to
Render(), in this order:
- SetDC()
- SetSize()
- SetHtmlText()
*/
void Render(int x, int y, int from = 0, int to = INT_MAX);
/**
Assign DC instance to the renderer.
@a pixel_scale can be used when rendering to high-resolution DCs (e.g. printer)
to adjust size of pixel metrics.
(Many dimensions in HTML are given in pixels -- e.g. image sizes. 300x300
image would be only one inch wide on typical printer. With pixel_scale = 3.0
it would be 3 inches.)
*/
void SetDC(wxDC* dc, double pixel_scale = 1.0);
/**
This function sets font sizes and faces.
@param normal_face
This is face name for normal (i.e. non-fixed) font.
It can be either empty string (then the default face is chosen) or
platform-specific face name. Examples are "helvetica" under Unix or
"Times New Roman" under Windows.
@param fixed_face
The same thing for fixed face ( \<TT\>..\</TT\> )
@param sizes
This is an array of 7 items of int type.
The values represent size of font with HTML size from -2 to +4
( \<FONT SIZE=-2\> to \<FONT SIZE=+4\> ).
Default sizes are used if sizes is @NULL.
Default font sizes are defined by constants wxHTML_FONT_SIZE_1,
wxHTML_FONT_SIZE_2, ..., wxHTML_FONT_SIZE_7.
Note that they differ among platforms. Default face names are empty strings.
@see SetSize()
*/
void SetFonts(const wxString& normal_face, const wxString& fixed_face,
const int* sizes = nullptr);
/**
Sets font sizes to be relative to the given size or the system
default size; use either specified or default font
@param size
Point size of the default HTML text
@param normal_face
This is face name for normal (i.e. non-fixed) font. It can be
either empty string (then the default face is chosen) or
platform-specific face name. Examples are "helvetica" under
Unix or "Times New Roman" under Windows.
@param fixed_face
The same thing for fixed face ( \<TT\>..\</TT\> )
@see SetSize()
*/
void SetStandardFonts(int size = -1,
const wxString& normal_face = wxEmptyString,
const wxString& fixed_face = wxEmptyString);
/**
Assign text to the renderer. Render() then draws the text onto DC.
@param html
HTML text. This is not a filename.
@param basepath
base directory (html string would be stored there if it was in file).
It is used to determine path for loading images, for example.
@param isdir
@false if basepath is filename, @true if it is directory name
(see wxFileSystem for detailed explanation).
*/
void SetHtmlText(const wxString& html,
const wxString& basepath = wxEmptyString,
bool isdir = true);
/**
Associate the given HTML contents to the renderer.
This is similar to SetHtmlText(), but is more efficient as the text can
be parsed only once, using wxHtmlParser::Parse(), and then passed to
wxHtmlDCRenderer multiple times or already reused for other purposes.
Note that @a cell will be modified (e.g. laid out) by this function.
@since 3.1.2
*/
void SetHtmlCell(wxHtmlContainerCell& cell);
/**
Set size of output rectangle, in pixels. Note that you @b can't change
width of the rectangle between calls to Render() !
(You can freely change height.)
*/
void SetSize(int width, int height);
};
/**
@class wxHtmlEasyPrinting
This class provides very simple interface to printing architecture.
It allows you to print HTML documents using only a few commands.
@note
Do not create this class on the stack only. You should create an instance
on app startup and use this instance for all printing operations.
The reason is that this class stores various settings in it.
@library{wxhtml}
@category{html,printing}
*/
class wxHtmlEasyPrinting : public wxObject
{
public:
/**
Constructor.
@param name
Name of the printing object. Used by preview frames and setup dialogs.
@param parentWindow
pointer to the window that will own the preview frame and setup dialogs.
May be @NULL.
*/
wxHtmlEasyPrinting(const wxString& name = "Printing",
wxWindow* parentWindow = nullptr);
/**
Returns the current name being used for preview frames and setup
dialogs.
@since 2.8.11 / 2.9.1
*/
const wxString& GetName() const;
/**
Returns a pointer to wxPageSetupDialogData instance used by this class.
You can set its parameters (via SetXXXX methods).
*/
wxPageSetupDialogData* GetPageSetupData();
/**
Gets the parent window for dialogs.
*/
wxWindow* GetParentWindow() const;
/**
Returns pointer to wxPrintData instance used by this class.
You can set its parameters (via SetXXXX methods).
*/
wxPrintData* GetPrintData();
/**
Display page setup dialog and allows the user to modify settings.
*/
void PageSetup();
/**
Preview HTML file.
Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
information about the kind of the error.
*/
bool PreviewFile(const wxString& htmlfile);
/**
Preview HTML text (not file!).
Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
information about the kind of the error.
@param htmltext
HTML text.
@param basepath
base directory (html string would be stored there if it was in file).
It is used to determine path for loading images, for example.
*/
bool PreviewText(const wxString& htmltext,
const wxString& basepath = wxEmptyString);
/**
Print HTML file.
Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
information about the kind of the error.
*/
bool PrintFile(const wxString& htmlfile);
/**
Print HTML text (not file!).
Returns @false in case of error -- call wxPrinter::GetLastError to get detailed
information about the kind of the error.
@param htmltext
HTML text.
@param basepath
base directory (html string would be stored there if it was in file).
It is used to determine path for loading images, for example.
*/
bool PrintText(const wxString& htmltext,
const wxString& basepath = wxEmptyString);
/**
Sets fonts. See wxHtmlDCRenderer::SetFonts for detailed description.
*/
void SetFonts(const wxString& normal_face, const wxString& fixed_face,
const int* sizes = nullptr);
/**
Sets the name used for preview frames and setup dialogs.
@since 2.8.11 / 2.9.1
*/
void SetName(const wxString& name);
/**
Sets default font sizes and/or default font size.
See wxHtmlDCRenderer::SetStandardFonts for detailed description.
@see SetFonts()
*/
void SetStandardFonts(int size = -1,
const wxString& normal_face = wxEmptyString,
const wxString& fixed_face = wxEmptyString);
/**
Set page footer. The following macros can be used inside it:
- @@DATE@ is replaced by the current date in default format
- @@PAGENUM@ is replaced by page number
- @@PAGESCNT@ is replaced by total number of pages
- @@TIME@ is replaced by the current time in default format
- @@TITLE@ is replaced with the title of the document
- @@USER@ is replaced with the user's name (support for this
macro was added in wxWidgets 3.2.8)
@param footer
HTML text to be used as footer.
@param pg
one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
*/
void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
/**
Set page header. The following macros can be used inside it:
- @@DATE@ is replaced by the current date in default format
- @@PAGENUM@ is replaced by page number
- @@PAGESCNT@ is replaced by total number of pages
- @@TIME@ is replaced by the current time in default format
- @@TITLE@ is replaced with the title of the document
- @@USER@ is replaced with the user's name (support for this
macro was added in wxWidgets 3.2.8)
@param header
HTML text to be used as header.
@param pg
one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
*/
void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
/**
Sets the parent window for dialogs.
*/
void SetParentWindow(wxWindow* window);
/**
Controls when the print dialog should be shown.
@see SetPromptMode()
@since 3.1.2
*/
enum PromptMode
{
Prompt_Never, //!< Do not show the print dialog.
Prompt_Once, //!< Show the print dialog only the first time.
Prompt_Always //!< Show the print dialog every time (default value).
};
/**
Enable or disable showing the dialog before printing.
The prompt mode determines the value of the @c prompt parameter passed
to wxPrinter::Print() when it is called by this class.
Default prompt mode value is Prompt_Always.
@since 3.1.2
*/
void SetPromptMode(PromptMode promptMode);
private:
/**
Check whether the document fits into the page area.
This function is called by the base class OnPreparePrinting()
implementation and by default checks whether the document fits into
@a pageArea horizontally and warns the user if it does not, giving him
the possibility to cancel printing in this case (presumably in order to
change some layout options and retry it again).
You may override it to either suppress this check if truncation of the
HTML being printed is acceptable or, on the contrary, add more checks to
it, e.g. for the fit in the vertical direction if the document should
always appear on a single page.
@return
@true if wxHtmlPrintout should continue or @false to cancel
printing.
@since 2.9.0
*/
virtual bool CheckFit(const wxSize& pageArea, const wxSize& docArea) const;
};
enum {
wxPAGE_ODD,
wxPAGE_EVEN,
wxPAGE_ALL
};
/**
@class wxHtmlPrintout
This class serves as printout class for HTML documents.
@library{wxhtml}
@category{html,printing}
*/
class wxHtmlPrintout : public wxPrintout
{
public:
/**
Constructor.
*/
wxHtmlPrintout(const wxString& title = "Printout");
/**
Adds a filter to the static list of filters for wxHtmlPrintout.
See wxHtmlFilter for further information.
*/
static void AddFilter(wxHtmlFilter* filter);
/**
This function sets font sizes and faces. See wxHtmlWindow::SetFonts
for detailed description.
*/
void SetFonts(const wxString& normal_face, const wxString& fixed_face,
const int* sizes = nullptr);
/**
Set page footer. The following macros can be used inside it:
- @@DATE@ is replaced by the current date in default format
- @@PAGENUM@ is replaced by page number
- @@PAGESCNT@ is replaced by total number of pages
- @@TIME@ is replaced by the current time in default format
- @@TITLE@ is replaced with the title of the document
- @@USER@ is replaced with the user's name (support for this
macro was added in wxWidgets 3.2.8)
@param footer
HTML text to be used as footer.
@param pg
one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
*/
void SetFooter(const wxString& footer, int pg = wxPAGE_ALL);
/**
Set page header. The following macros can be used inside it:
- @@DATE@ is replaced by the current date in default format
- @@PAGENUM@ is replaced by page number
- @@PAGESCNT@ is replaced by total number of pages
- @@TIME@ is replaced by the current time in default format
- @@TITLE@ is replaced with the title of the document
- @@USER@ is replaced with the user's name (support for this
macro was added in wxWidgets 3.2.8)
@param header
HTML text to be used as header.
@param pg
one of wxPAGE_ODD, wxPAGE_EVEN and wxPAGE_ALL constants.
*/
void SetHeader(const wxString& header, int pg = wxPAGE_ALL);
/**
Prepare the class for printing this HTML @b file.
The file may be located on any virtual file system or it may be normal file.
*/
void SetHtmlFile(const wxString& htmlfile);
/**
Prepare the class for printing this HTML text.
@param html
HTML text. (NOT file!)
@param basepath
base directory (html string would be stored there if it was in file).
It is used to determine path for loading images, for example.
@param isdir
@false if basepath is filename, @true if it is directory name
(see wxFileSystem for detailed explanation).
*/
void SetHtmlText(const wxString& html,
const wxString& basepath = wxEmptyString,
bool isdir = true);
/**
Sets margins in millimeters.
Defaults to 1 inch for margins and 0.5cm for space between text and header
and/or footer.
*/
void SetMargins(float top = 25.2, float bottom = 25.2,
float left = 25.2,
float right = 25.2,
float spaces = 5);
/**
Sets margins from wxPageSetupDialogData.
@since 3.1.0
*/
void SetMargins(const wxPageSetupDialogData& pageSetupData);
};

View File

@@ -0,0 +1,320 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/winpars.h
// Purpose: interface of wxHtmlTagsModule
// Author: wxWidgets team
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlTagsModule
This class provides easy way of filling wxHtmlWinParser's table of
tag handlers. It is used almost exclusively together with the set of
@ref overview_html_handlers "TAGS_MODULE_* macros"
@library{wxhtml}
@category{html}
@see @ref overview_html_handlers, wxHtmlTagHandler, wxHtmlWinTagHandler
*/
class wxHtmlTagsModule : public wxModule
{
public:
/**
You must override this method. In most common case its body consists
only of lines of the following type:
@code
parser -> AddTagHandler(new MyHandler);
@endcode
It's recommended to use the @b TAGS_MODULE_* macros.
@param parser
Pointer to the parser that requested tables filling.
*/
virtual void FillHandlersTable(wxHtmlWinParser* parser);
};
/**
@class wxHtmlWinTagHandler
This is basically wxHtmlTagHandler except that it is extended with protected
member m_WParser pointing to the wxHtmlWinParser object (value of this member
is identical to wxHtmlParser's m_Parser).
@library{wxhtml}
@category{html}
*/
class wxHtmlWinTagHandler : public wxHtmlTagHandler
{
public:
/**
Constructor.
*/
wxHtmlWinTagHandler();
/**
Assigns @a parser to this handler. Each @b instance of handler
is guaranteed to be called only from the one parser.
*/
virtual void SetParser(wxHtmlParser* parser);
protected:
/**
Value of this attribute is identical to value of m_Parser.
The only difference is that m_WParser points to wxHtmlWinParser object
while m_Parser points to wxHtmlParser object. (The same object, but overcast.)
*/
wxHtmlWinParser* m_WParser;
};
/**
@class wxHtmlWinParser
This class is derived from wxHtmlParser and its main goal is to parse HTML
input so that it can be displayed in wxHtmlWindow.
It uses a special wxHtmlWinTagHandler.
@note The product of parsing is a wxHtmlCell (resp. wxHtmlContainer) object.
@library{wxhtml}
@category{html}
@see @ref overview_html_handlers
*/
class wxHtmlWinParser : public wxHtmlParser
{
public:
/**
Constructor.
Don't use the default one, use the constructor with @a wndIface parameter
(@a wndIface is a pointer to interface object for the associated wxHtmlWindow
or other HTML rendering window such as wxHtmlListBox).
*/
wxHtmlWinParser(wxHtmlWindowInterface* wndIface = nullptr);
/**
Adds module() to the list of wxHtmlWinParser tag handler.
*/
static void AddModule(wxHtmlTagsModule* module);
/**
Closes the container, sets actual container to the parent one
and returns pointer to it (see @ref overview_html_cells).
*/
wxHtmlContainerCell* CloseContainer();
/**
Creates font based on current setting (see SetFontSize(), SetFontBold(),
SetFontItalic(), SetFontFixed(), wxHtmlWinParser::SetFontUnderlined)
and returns pointer to it.
If the font was already created only a pointer is returned.
*/
virtual wxFont* CreateCurrentFont();
/**
Returns actual text colour.
*/
const wxColour& GetActualColor() const;
/**
Returns default horizontal alignment.
*/
int GetAlign() const;
/**
Returns (average) char height in standard font.
It is used as DC-independent metrics.
@note This function doesn't return the @e actual height. If you want to
know the height of the current font, call @c GetDC->GetCharHeight().
*/
int GetCharHeight() const;
/**
Returns average char width in standard font.
It is used as DC-independent metrics.
@note This function doesn't return the @e actual width. If you want to
know the height of the current font, call @c GetDC->GetCharWidth().
*/
int GetCharWidth() const;
/**
Returns pointer to the currently opened container (see @ref overview_html_cells).
Common use:
@code
m_WParser -> GetContainer() -> InsertCell(new ...);
@endcode
*/
wxHtmlContainerCell* GetContainer() const;
/**
Returns pointer to the DC used during parsing.
*/
wxDC* GetDC();
/**
Returns wxEncodingConverter class used to do conversion between the
@ref GetInputEncoding() "input encoding" and the
@ref GetOutputEncoding() "output encoding".
*/
wxEncodingConverter* GetEncodingConverter() const;
/**
Returns @true if actual font is bold, @false otherwise.
*/
int GetFontBold() const;
/**
Returns actual font face name.
*/
wxString GetFontFace() const;
/**
Returns @true if actual font is fixed face, @false otherwise.
*/
int GetFontFixed() const;
/**
Returns @true if actual font is italic, @false otherwise.
*/
int GetFontItalic() const;
/**
Returns actual font size (HTML size varies from -2 to +4)
*/
int GetFontSize() const;
/**
Returns @true if actual font is underlined, @false otherwise.
*/
int GetFontUnderlined() const;
/**
Returns input encoding.
*/
wxFontEncoding GetInputEncoding() const;
/**
Returns actual hypertext link.
(This value has a non-empty @ref wxHtmlLinkInfo::GetHref Href string
if the parser is between \<A\> and \</A\> tags, wxEmptyString otherwise.)
*/
const wxHtmlLinkInfo& GetLink() const;
/**
Returns the colour of hypertext link text.
*/
const wxColour& GetLinkColor() const;
/**
Returns output encoding, i.e. closest match to document's input encoding
that is supported by operating system.
*/
wxFontEncoding GetOutputEncoding() const;
/**
Returns associated window (wxHtmlWindow). This may be @NULL!
(You should always test if it is non-null.
For example @c TITLE handler sets window title only if some window is
associated, otherwise it does nothing.
*/
wxHtmlWindowInterface* GetWindowInterface();
/**
Opens new container and returns pointer to it (see @ref overview_html_cells).
*/
wxHtmlContainerCell* OpenContainer();
/**
Sets actual text colour. Note: this DOESN'T change the colour!
You must create wxHtmlColourCell yourself.
*/
void SetActualColor(const wxColour& clr);
/**
Sets default horizontal alignment (see wxHtmlContainerCell::SetAlignHor).
Alignment of newly opened container is set to this value.
*/
void SetAlign(int a);
/**
Allows you to directly set opened container.
This is not recommended - you should use OpenContainer() wherever possible.
*/
wxHtmlContainerCell* SetContainer(wxHtmlContainerCell* c);
/**
Sets the DC. This must be called before wxHtmlParser::Parse!
@a pixel_scale can be used when rendering to high-resolution
DCs (e.g. printer) to adjust size of pixel metrics. (Many dimensions in
HTML are given in pixels -- e.g. image sizes. 300x300 image would be only one
inch wide on typical printer. With pixel_scale = 3.0 it would be 3 inches.)
*/
virtual void SetDC(wxDC* dc, double pixel_scale = 1.0e+0);
/**
Sets bold flag of actualfont. @a x is either @true of @false.
*/
void SetFontBold(int x);
/**
Sets current font face to @a face. This affects either fixed size
font or proportional, depending on context (whether the parser is
inside @c \<TT\> tag or not).
*/
void SetFontFace(const wxString& face);
/**
Sets fixed face flag of actualfont. @a x is either @true of @false.
*/
void SetFontFixed(int x);
/**
Sets italic flag of actualfont. @a x is either @true of @false.
*/
void SetFontItalic(int x);
/**
Sets actual font size (HTML size varies from 1 to 7).
*/
void SetFontSize(int s);
/**
Sets underlined flag of actualfont. @a x is either @true of @false.
*/
void SetFontUnderlined(int x);
/**
Sets fonts. See wxHtmlWindow::SetFonts for detailed description.
*/
void SetFonts(const wxString& normal_face, const wxString& fixed_face,
const int* sizes = 0);
/**
Sets input encoding. The parser uses this information to build conversion
tables from document's encoding to some encoding supported by operating system.
*/
void SetInputEncoding(wxFontEncoding enc);
/**
Sets actual hypertext link.
Empty link is represented by wxHtmlLinkInfo with @e Href equal
to wxEmptyString.
*/
void SetLink(const wxHtmlLinkInfo& link);
/**
Sets colour of hypertext link.
*/
void SetLinkColor(const wxColour& clr);
};