Moved all interface headers into a 'wx' subdirectory for proper use of Doxygen path settings.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@54385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2008-06-27 16:22:58 +00:00
parent 92b6654b66
commit ae3c17b401
277 changed files with 0 additions and 0 deletions

View File

@@ -0,0 +1,202 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpctrl.h
// Purpose: interface of wxHtmlHelpController
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlHelpController
@headerfile helpctrl.h wx/html/helpctrl.h
This help controller provides an easy way of displaying HTML help in your
application (see @e test sample). 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 here().
Have a look at docs/html/ directory where sample project files are stored.
You can use Tex2RTF to produce these files when generating HTML, if you set @b
htmlWorkshopFiles to @b @true in
your tex2rtf.ini file. The commercial tool HelpBlocks (www.helpblocks.com) can
also create these files.
@library{wxhtml}
@category{help}
@see @ref overview_wxhelpcontroller "Information about wxBestHelpController",
wxHtmlHelpFrame, wxHtmlHelpDialog, wxHtmlHelpWindow, wxHtmlModalHelp
*/
class wxHtmlHelpController
{
public:
/**
Constructor.
*/
wxHtmlHelpController(int style = wxHF_DEFAULT_STYLE,
wxWindow* parentWindow = NULL);
//@{
/**
Adds book (@ref overview_helpformat ".hhp file" - 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 .hhp file or ZIP archive
that contains arbitrary number of .hhp files in
top-level directory. This ZIP archive must have .zip or .htb extension
(the latter stands for "HTML book"). In other words, @c
AddBook(wxFileName("help.zip"))
is possible and is the recommended way.
@param showWaitMsg
If @true then a decoration-less window with progress message is displayed.
@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 bookUrl
Help book URL (note that syntax of filename and URL is
different on most platforms)
*/
bool AddBook(const wxFileName& bookFile, bool showWaitMsg);
bool AddBook(const wxString& bookUrl, bool showWaitMsg);
//@}
/**
This protected virtual method may be overridden so that when specifying the
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);
//@{
/**
This alternative form is used to search help contents by numeric IDs.
*/
void Display(const wxString& x);
void Display(const int id);
//@}
/**
Displays help window and focuses contents panel.
*/
void DisplayContents();
/**
Displays help window and focuses index panel.
*/
void DisplayIndex();
/**
Displays help window, focuses search panel and starts searching. Returns @true
if the keyword was found. Optionally it searches through the index (mode =
wxHELP_SEARCH_INDEX), default the content (mode = wxHELP_SEARCH_ALL).
@b Important: KeywordSearch searches only pages listed in .hhc file(s).
You should list all pages in the contents file.
*/
bool KeywordSearch(const wxString& keyword,
wxHelpSearchMode mode = wxHELP_SEARCH_ALL);
/**
Reads the controller's setting (position of window, etc.)
*/
void ReadCustomization(wxConfigBase* cfg,
wxString path = wxEmptyString);
/**
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 .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 @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 @e UseConfig, wxHtmlHelpController will use
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.)
*/
void WriteCustomization(wxConfigBase* cfg,
wxString path = wxEmptyString);
};
/**
@class wxHtmlModalHelp
@headerfile helpctrl.h wx/html/helpctrl.h
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, wxT("help"), wxT("My topic"));
@endcode
@library{wxhtml}
@category{FIXME}
*/
class wxHtmlModalHelp
{
public:
/**
@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,69 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpdata.h
// Purpose: interface of wxHtmlHelpData
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlHelpData
@headerfile helpdata.h wx/html/helpdata.h
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{FIXME}
*/
class wxHtmlHelpData : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlHelpData();
/**
Adds new book. @e book 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();
/**
Returns reference to array with contents entries.
*/
const wxHtmlHelpDataItems GetContentsArray();
/**
Returns reference to array with index entries.
*/
const wxHtmlHelpDataItems GetIndexArray();
/**
Sets 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,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpdlg.h
// Purpose: interface of wxHtmlHelpDialog
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlHelpDialog
@headerfile helpdlg.h wx/html/helpdlg.h
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{FIXME}
*/
class wxHtmlHelpDialog : public wxFrame
{
public:
//@{
/**
Constructor. For the values of @e style, please see the documentation for
wxHtmlHelpController.
*/
wxHtmlHelpDialog(wxHtmlHelpData* data = NULL);
wxHtmlHelpDialog(wxWindow* parent, int wxWindowID,
const wxString& title = wxEmptyString,
int style = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = NULL);
//@}
/**
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;
/**
Reads the user's settings for this dialog see
wxHtmlHelpController::ReadCustomization)
*/
void ReadCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
/**
Sets the help controller associated with the dialog.
*/
void SetController(wxHtmlHelpController* contoller);
/**
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);
/**
Saves the user's settings for this dialog (see
wxHtmlHelpController::WriteCustomization).
*/
void WriteCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
};

View File

@@ -0,0 +1,82 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpfrm.h
// Purpose: interface of wxHtmlHelpFrame
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlHelpFrame
@headerfile helpfrm.h wx/html/helpfrm.h
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{FIXME}
*/
class wxHtmlHelpFrame : public wxFrame
{
public:
//@{
/**
Constructor. For the values of @e style, please see the documentation for
wxHtmlHelpController.
*/
wxHtmlHelpFrame(wxHtmlHelpData* data = NULL);
wxHtmlHelpFrame(wxWindow* parent, int wxWindowID,
const wxString& title = wxEmptyString,
int style = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = NULL);
//@}
/**
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);
/**
Returns the help controller associated with the frame.
*/
wxHtmlHelpController* GetController() const;
/**
Reads the user's settings for this frame see
wxHtmlHelpController::ReadCustomization)
*/
void ReadCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
/**
Sets the help controller associated with the frame.
*/
void SetController(wxHtmlHelpController* contoller);
/**
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);
/**
Saves the user's settings for this frame (see
wxHtmlHelpController::WriteCustomization).
*/
void WriteCustomization(wxConfigBase* cfg,
const wxString& path = wxEmptyString);
};

168
interface/wx/html/helpwnd.h Normal file
View File

@@ -0,0 +1,168 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/helpwnd.h
// Purpose: interface of wxHtmlHelpWindow
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlHelpWindow
@headerfile helpwnd.h wx/html/helpwnd.h
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(_T("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{FIXME}
*/
class wxHtmlHelpWindow : public wxWindow
{
public:
//@{
/**
Constructor.
Constructor. For the values of @e helpStyle, please see the documentation for
wxHtmlHelpController.
*/
wxHtmlHelpWindow(wxHtmlHelpData* data = NULL);
wxHtmlHelpWindow(wxWindow* parent, int wxWindowID,
const wxPoint& pos = wxDefaultPosition,
const wxSize& pos = wxDefaultSize,
int style = wxTAB_TRAVERSAL|wxBORDER_NONE,
int helpStyle = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = NULL);
//@}
/**
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 @e samples/html/helpview for an example.
*/
virtual void AddToolbarButtons(wxToolBar* toolBar, int style);
/**
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& pos = wxDefaultSize,
int style = wxTAB_TRAVERSAL|wxBORDER_NONE,
int helpStyle = wxHF_DEFAULT_STYLE,
wxHtmlHelpData* data = NULL);
/**
Creates contents panel. (May take some time.)
Protected.
*/
void CreateContents();
/**
Creates index panel. (May take some time.)
Protected.
*/
void CreateIndex();
/**
Creates search panel.
*/
void CreateSearch();
//@{
/**
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 ...")
The second form takes numeric ID as the parameter.
(uses extension to MS format, param name="ID" value=id)
*/
bool Display(const wxString& x);
bool Display(const 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 =
wxHELP_SEARCH_INDEX), default the content (mode = 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);
/**
Refresh all panels. This is necessary if a new book was added.
Protected.
*/
void RefreshLists();
/**
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);
/**
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);
};

View File

@@ -0,0 +1,732 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlcell.h
// Purpose: interface of wxHtmlColourCell
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlColourCell
@headerfile htmlcell.h wx/html/htmlcell.h
This cell changes the colour of either the background or the foreground.
@library{wxhtml}
@category{FIXME}
*/
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(wxColour clr, int flags = wxHTML_CLR_FOREGROUND);
};
/**
@class wxHtmlWidgetCell
@headerfile htmlcell.h wx/html/htmlcell.h
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{FIXME}
*/
class wxHtmlWidgetCell : public wxHtmlCell
{
public:
/**
Constructor.
@param wnd
Connected window. It is parent window 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 wxHtmlCell
@headerfile htmlcell.h wx/html/htmlcell.h
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{FIXME}
@see @ref overview_cells "Cells Overview", wxHtmlContainerCell
*/
class wxHtmlCell : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlCell();
/**
This method is used to adjust pagebreak position. The parameter is
variable that contains y-coordinate of page break (= horizontal line that
should not be crossed by words, images etc.). If this cell cannot be divided
into two pieces (each one on another page) then it moves the pagebreak
few pixels up.
Returns @true if pagebreak was modified, @false otherwise
Usage:
*/
virtual bool AdjustPagebreak(int* pagebreak);
/**
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 : dc - DrawText("hello", x + m_PosX, y + m_PosY)
@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
*/
virtual void Draw(wxDC& dc, int x, int y, int view_y1,
int view_y2);
/**
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 : dc - DrawText("hello", x + m_PosX, y + m_PosY)
*/
virtual void DrawInvisible(wxDC& dc, int x, int y);
/**
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);
/**
Returns descent value of the cell (m_Descent member).
See explanation:
*/
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.
*/
wxHtmlCell* GetFirstChild();
/**
Returns height of the cell (m_Height member).
*/
int GetHeight() const;
/**
Returns unique cell identifier if there is any, empty string otherwise.
*/
virtual 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
*/
virtual wxCursor GetMouseCursor(wxHtmlWindowInterface* window);
/**
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;
/**
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 behavior 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.
*/
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.
*/
void SetPos(int x, int y);
};
/**
@class wxHtmlContainerCell
@headerfile htmlcell.h wx/html/htmlcell.h
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{FIXME}
@see @ref overview_cells "Cells Overview"
*/
class wxHtmlContainerCell : public wxHtmlCell
{
public:
/**
Constructor. @a parent is pointer to parent container or @NULL.
*/
wxHtmlContainerCell(wxHtmlContainerCell parent);
/**
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 new cell into the container.
*/
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
*/
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
*/
void SetBorder(const wxColour& clr1, const wxColour& clr2);
/**
Sets the indentation (free space between borders of container and subcells).
@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
i is number of pixels
wxHTML_UNITS_PERCENT
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
wxHTML_ALIGN_TOP,
wxHTML_ALIGN_BOTTOM, 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 FWA.
@a pixel_scale is number of real pixels that equals to 1 HTML pixel.
@param w
Width of the container. If the value is negative it means
complement to full width of parent container (e.g.
SetWidthFloat(-50, wxHTML_UNITS_PIXELS) 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
w is number of pixels
wxHTML_UNITS_PERCENT
w is interpreted as percents of width
of parent container
@param tag
In the second version of method, w and units
info is extracted from tag's WIDTH parameter.
*/
void SetWidthFloat(int w, int units);
void SetWidthFloat(const wxHtmlTag& tag,
double pixel_scale = 1.0);
//@}
};
/**
@class wxHtmlLinkInfo
@headerfile htmlcell.h wx/html/htmlcell.h
This class stores all necessary information about hypertext
links (as represented by @c A tag in HTML documents). In
current implementation it stores URL and target frame name.
@e Note that frames are not currently supported by wxHTML!
@library{wxhtml}
@category{FIXME}
*/
class wxHtmlLinkInfo : public wxObject
{
public:
//@{
/**
Construct hypertext link from HREF (aka URL) and TARGET (name of target
frame).
*/
wxHtmlLinkInfo();
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();
/**
Return @e HREF value of the @c A tag.
*/
wxString GetHref();
/**
Return pointer to the cell that was clicked. Valid
only within wxHtmlWindow::OnLinkClicked,
@NULL otherwise.
*/
const wxHtmlCell* GetHtmlCell();
/**
Return @e TARGET value of the @c A tag (this value
is used to specify in which frame should be the page pointed
by @ref gethref() Href opened).
*/
wxString GetTarget();
};

View File

@@ -0,0 +1,41 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlfilt.h
// Purpose: interface of wxHtmlFilter
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlFilter
@headerfile htmlfilt.h wx/html/htmlfilt.h
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{FIXME}
@see Overview()
*/
class wxHtmlFilter : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlFilter();
/**
Returns @true if this filter is capable of reading file @e file.
Example:
*/
bool CanRead(const wxFSFile& file);
/**
Reads the file and returns string with HTML document.
Example:
*/
wxString ReadFile(const wxFSFile& file);
};

View File

@@ -0,0 +1,270 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlpars.h
// Purpose: interface of wxHtmlTagHandler
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlTagHandler
@headerfile htmlpars.h wx/html/htmlpars.h
@library{wxhtml}
@category{html}
@see Overview(), 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();
/**
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).
@return @true if ParseInner was called, @false otherwise.
*/
virtual bool HandleTag(const wxHtmlTag& tag);
/**
This method calls parser's wxHtmlParser::DoParsing method
for the string between this tag and the paired ending tag:
In this example, a call to ParseInner (with @a tag pointing to A tag)
will parse 'Hello, world!'.
*/
void ParseInner(const wxHtmlTag& tag);
/**
Assigns @a parser to this handler. Each @b instance of handler
is guaranteed to be called only from the parser.
*/
virtual void SetParser(wxHtmlParser parser);
/**
@b wxHtmlParser* m_Parser
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.
*/
};
/**
@class wxHtmlParser
@headerfile htmlpars.h wx/html/htmlpars.h
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
(Julian Smart's idea of speech-only HTML viewer or wget-like utility -
see InetGet sample for example).
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_cells "Cells Overview", @ref overview_handlers "Tag Handlers
Overview", wxHtmlTag
*/
class wxHtmlParser
{
public:
/**
Constructor.
*/
wxHtmlParser();
/**
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.
*/
void AddTag(const wxHtmlTag& tag);
/**
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 begin_pos to end_pos-1.
(in noparams version it parses whole m_Source)
*/
void DoParsing(int begin_pos, int end_pos);
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
*/
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();
/**
Returns pointer to the source being parsed.
*/
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.
*/
virtual wxFSFile* OpenURL(wxHtmlURLType type,
const wxString& url);
/**
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 @ref initparser() 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).
*/
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).
*/
void StopParsing();
};

130
interface/wx/html/htmltag.h Normal file
View File

@@ -0,0 +1,130 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmltag.h
// Purpose: interface of wxHtmlTag
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlTag
@headerfile htmltag.h wx/html/htmltag.h
This class represents a single HTML tag.
It is used by @ref overview_handlers "tag handlers".
@library{wxhtml}
@category{FIXME}
*/
class wxHtmlTag
{
public:
/**
Constructor. You will probably never have to construct a wxHtmlTag object
yourself. Feel free to ignore the constructor parameters.
Have a look at src/html/htmlpars.cpp if you're interested in creating it.
*/
wxHtmlTag(wxHtmlTag* parent, const wxString& source, int pos,
int end_pos, wxHtmlTagsCache* cache,
wxHtmlEntitiesParser* entParser);
/**
Returns a string containing all parameters.
Example : tag contains @c FONT SIZE=+2 COLOR="#000000". Call to
tag.GetAllParams() would return @c SIZE=+2 COLOR="#000000".
*/
const wxString GetAllParams() const;
/**
Returns beginning position of the text @e between this tag and paired
ending tag.
See explanation (returned position is marked with '|'):
*/
int GetBeginPos() const;
/**
Returns ending position of the text @e between this tag and paired
ending tag.
See explanation (returned position is marked with '|'):
*/
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 '|'):
*/
int GetEndPos2() const;
/**
Returns tag's name. The name is always in uppercase and it doesn't contain
" or '/' characters. (So the name of @c FONT SIZE=+2 tag is "FONT"
and name of @c /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.
@param par
The parameter's name.
@param with_quotes
@true if you want to get quotes as well. See example.
*/
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 @e clr.
Returns @true on success and @false if @a par is not colour specification or
if the tag has no such parameter.
*/
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 @e 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;
/**
Returns @true if this tag is paired with ending tag, @false otherwise.
See the example of HTML document:
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 : @c 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;
/**
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 @e 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
*/
wxString ScanParam(const wxString& par, const wxChar* format,
void* value) const;
};

483
interface/wx/html/htmlwin.h Normal file
View File

@@ -0,0 +1,483 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmlwin.h
// Purpose: interface of wxHtmlWindow
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlWindow
@headerfile htmlwin.h wx/html/htmlwin.h
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 HTML pages (either local
file or downloaded via HTTP protocol) in a window. 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
@ref wxHtmlWindow::setpage SetPage(text),
@ref wxHtmlWindow::loadpage LoadPage(filename) or
wxHtmlWindow::LoadFile.
@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
@library{wxhtml}
@category{html}
@see wxHtmlLinkEvent, wxHtmlCellEvent
*/
class wxHtmlWindow : public wxScrolledWindow
{
public:
//@{
/**
Constructor. The parameters are the same as wxScrolled::wxScrolled()
constructor.
@param style
Window style. See wxHtmlWindow.
*/
wxHtmlWindow();
wxHtmlWindow(wxWindow parent, wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxHW_DEFAULT_STYLE,
const wxString& name = "htmlWindow");
//@}
/**
Adds @ref overview_filters "input filter" to the static list of available
filters. These filters are present by default:
@c text/html MIME type
@c image/* MIME types
Plain Text filter (this filter is 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 also: @ref overview_cells "Cells Overview",
@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();
/**
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();
/**
Returns title of the opened page or wxEmptyString if current page does not
contain @c TITLE tag.
*/
wxString GetOpenedPageTitle();
/**
Returns the related frame.
*/
wxFrame* GetRelatedFrame() const;
/**
Moves back to the previous page. (each page displayed using
LoadPage() is 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. HistoryBack()
won't fail).
*/
bool HistoryCanForward();
/**
Clears history.
*/
void HistoryClear();
/**
Moves to next page in history.
*/
bool HistoryForward();
/**
Loads HTML page from file and displays it.
@return @false if an error occurred, @true otherwise
@see LoadPage()
*/
virtual bool LoadFile(const wxFileName& filename);
/**
Unlike SetPage this function first loads HTML page from @a location
and then displays it. See example:
@param location
The address of document. See wxFileSystem for details on address format and
behaviour of "opener".
@return @false if an error occurred, @true otherwise
@see LoadFile()
*/
virtual bool LoadPage(const wxString& location);
/**
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 an
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, y
The logical coordinates 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, y
The logical coordinates of the click point
*/
virtual void OnCellMouseHover(wxHtmlCell cell, wxCoord x,
wxCoord y);
/**
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 wxHTML_REDIRECT.
*/
virtual wxHtmlOpeningStatus OnOpeningURL(wxHtmlURLType type,
const wxString& url,
wxString* redirect);
/**
Called on parsing @c 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 @e pos. 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(), SelectLine()
*/
void SelectWord(const wxPoint& pos);
/**
Returns current selection as plain text. Returns empty string if no text
is currently selected.
*/
wxString SelectionToText();
/**
This function sets the space between border of window and HTML contents. See
image:
@param b
indentation from borders in pixels
*/
void SetBorders(int b);
/**
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.
*/
void SetFonts(const wxString& normal_face,
const wxString& fixed_face,
const int sizes = NULL);
/**
Sets HTML page and display it. This won't @b load the page!!
It will display the @e source. See example:
If you want to load a document from some location use
LoadPage() instead.
@param source
The HTML document source to be displayed.
@return @false if an error occurred, @true otherwise.
*/
bool SetPage(const wxString& source);
/**
Sets the frame in which page title will be displayed. @a format is format of
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);
};
/**
@class wxHtmlLinkEvent
@headerfile htmlwin.h wx/html/htmlwin.h
This event class is used for the events generated by wxHtmlWindow.
@library{wxhtml}
@category{FIXME}
*/
class wxHtmlLinkEvent : public wxCommandEvent
{
public:
/**
The constructor is not normally used by the user code.
*/
wxHyperlinkEvent(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
@headerfile htmlwin.h wx/html/htmlwin.h
This event class is used for the events generated by wxHtmlWindow.
@library{wxhtml}
@category{FIXME}
*/
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);
/**
Returns the wxHtmlCellEvent associated with the event.
*/
wxHtmlCell* GetCell() const;
/**
Returns @true if @ref setlinkclicked() SetLinkClicked(@true) has previously
been called;
@false otherwise.
*/
bool GetLinkClicked() const;
/**
Returns the wxPoint associated with the event.
*/
wxPoint GetPoint() const;
/**
Call this function with @c 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.
*/
bool SetLinkClicked(bool linkclicked);
};

View File

@@ -0,0 +1,330 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/htmprint.h
// Purpose: interface of wxHtmlDCRenderer
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlDCRenderer
@headerfile htmprint.h wx/html/htmprint.h
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{FIXME}
*/
class wxHtmlDCRenderer : public wxObject
{
public:
/**
Constructor.
*/
wxHtmlDCRenderer();
/**
Returns the height of the HTML text. This is important if area height (see
wxHtmlDCRenderer::SetSize)
is smaller that total height and thus the page cannot fit into it. In that case
you're supposed to
call Render() as long as its return value is smaller than GetTotalHeight's.
*/
int GetTotalHeight();
/**
Renders HTML text to the DC.
@param x,y
position of upper-left corner of printing rectangle (see SetSize)
@param from
y-coordinate of the very first visible cell
@param dont_render
if @true then this method only returns y coordinate of the next page
and does not output anything
*/
int Render(int x, int y, int from = 0, int dont_render = false);
/**
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);
/**
Sets fonts. See wxHtmlWindow::SetFonts for
detailed description.
See also SetSize().
*/
void SetFonts(const wxString& normal_face,
const wxString& fixed_face,
const int sizes = NULL);
/**
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);
/**
Set size of output rectangle, in pixels. Note that you @b can't change
width of the rectangle between calls to wxHtmlDCRenderer::Render!
(You can freely change height.)
*/
void SetSize(int width, int height);
};
/**
@class wxHtmlEasyPrinting
@headerfile htmprint.h wx/html/htmprint.h
This class provides very simple interface to printing
architecture. It allows you to print HTML documents using
only a few commands.
@library{wxhtml}
@category{html}
*/
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 = NULL);
/**
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 wxHtmlWindow::SetFonts for
detailed description.
*/
void SetFonts(const wxString& normal_face,
const wxString& fixed_face,
const int sizes = NULL);
/**
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
@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
@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);
};
/**
@class wxHtmlPrintout
@headerfile htmprint.h wx/html/htmprint.h
This class serves as printout class for HTML documents.
@library{wxhtml}
@category{html}
*/
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);
/**
Sets fonts. See wxHtmlWindow::SetFonts for
detailed description.
*/
void SetFonts(const wxString& normal_face,
const wxString& fixed_face,
const int sizes = NULL);
/**
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
@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
@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);
};

314
interface/wx/html/winpars.h Normal file
View File

@@ -0,0 +1,314 @@
/////////////////////////////////////////////////////////////////////////////
// Name: html/winpars.h
// Purpose: interface of wxHtmlTagsModule
// Author: wxWidgets team
// RCS-ID: $Id$
// Licence: wxWindows license
/////////////////////////////////////////////////////////////////////////////
/**
@class wxHtmlTagsModule
@headerfile winpars.h wx/html/winpars.h
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_handlers "TAGS_MODULE_* macros"
@library{wxhtml}
@category{FIXME}
@see @ref overview_handlers "Tag 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:
I recommend using the @b TAGS_MODULE_* macros.
@param parser
Pointer to the parser that requested tables filling.
*/
virtual void FillHandlersTable(wxHtmlWinParser parser);
};
/**
@class wxHtmlWinTagHandler
@headerfile winpars.h wx/html/winpars.h
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:
/**
@b wxHtmlWinParser* m_WParser
Value of this attribute is identical to value of m_Parser. The only different
is that m_WParser points to wxHtmlWinParser object while m_Parser
points to wxHtmlParser object. (The same object, but overcast.)
*/
};
/**
@class wxHtmlWinParser
@headerfile winpars.h wx/html/winpars.h
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.
@library{wxhtml}
@category{html}
@see @ref overview_handlers "Handlers overview"
*/
class wxHtmlWinParser : public wxHtmlParser
{
public:
//@{
/**
Constructor. Don't use the default one, use 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();
wxHtmlWinParser(wxHtmlWindowInterface wndIface);
//@}
/**
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 Overview()).
*/
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 Overview()).
Common use:
*/
wxHtmlContainerCell* GetContainer() const;
/**
Returns pointer to the DC used during parsing.
*/
wxDC* GetDC();
/**
Returns wxEncodingConverter class used
to do conversion between @ref getinputencoding() "input encoding"
and @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 @c A and @c /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)
*/
wxHtmlWindow* GetWindow();
/**
Opens new container and returns pointer to it (see Overview()).
*/
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.0);
/**
Sets bold flag of actualfont. @a x is either @true of @false.
*/
void SetFontBold(int x);
/**
Sets current font face to @e 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 = NULL);
/**
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);
};