wxHtmlWindow Class Reference
[HTML]

#include <wx/html/htmlwin.h>

Inheritance diagram for wxHtmlWindow:

wxScrolled< wxPanel > wxPanel wxWindow wxEvtHandler wxObject

List of all members.


Detailed Description

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 wxHtmlWindow::setpage SetPage(text), wxHtmlWindow::loadpage LoadPage(filename) or wxHtmlWindow::LoadFile.

Styles:

Library:  wxHTML

Category:  HTML

See also:
wxHtmlLinkEvent, wxHtmlCellEvent

Public Member Functions

bool AppendToPage (const wxString &source)
wxHtmlContainerCellGetInternalRepresentation () const
wxString GetOpenedAnchor ()
wxString GetOpenedPage ()
wxString GetOpenedPageTitle ()
wxFrameGetRelatedFrame () const
bool HistoryBack ()
bool HistoryCanBack ()
bool HistoryCanForward ()
void HistoryClear ()
bool HistoryForward ()
virtual bool LoadFile (const wxFileName &filename)
virtual bool LoadPage (const wxString &location)
virtual bool OnCellClicked (wxHtmlCell cell, wxCoord x, wxCoord y, const wxMouseEvent &event)
virtual void OnCellMouseHover (wxHtmlCell cell, wxCoord x, wxCoord y)
virtual void OnLinkClicked (const wxHtmlLinkInfo &link)
virtual wxHtmlOpeningStatus OnOpeningURL (wxHtmlURLType type, const wxString &url, wxString *redirect)
virtual void OnSetTitle (const wxString &title)
virtual void ReadCustomization (wxConfigBase cfg, wxString path=wxEmptyString)
void SelectAll ()
void SelectLine (const wxPoint &pos)
void SelectWord (const wxPoint &pos)
wxString SelectionToText ()
void SetBorders (int b)
void SetFonts (const wxString &normal_face, const wxString &fixed_face, const int sizes=NULL)
bool SetPage (const wxString &source)
void SetRelatedFrame (wxFrame *frame, const wxString &format)
void SetRelatedStatusBar (int index)
void SetRelatedStatusBar (wxStatusBar *statusbar, int index=0)
wxString ToText ()
virtual void WriteCustomization (wxConfigBase cfg, wxString path=wxEmptyString)
 wxHtmlWindow ()
 wxHtmlWindow (wxWindow parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHW_DEFAULT_STYLE, const wxString &name="htmlWindow")

Static Public Member Functions

static void AddFilter (wxHtmlFilter filter)

Constructor & Destructor Documentation

wxHtmlWindow::wxHtmlWindow (  ) 

Constructor. The parameters are the same as wxScrolled::wxScrolled() constructor.

Parameters:
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" 
)

Constructor. The parameters are the same as wxScrolled::wxScrolled() constructor.

Parameters:
style Window style. See wxHtmlWindow.


Member Function Documentation

static void wxHtmlWindow::AddFilter ( wxHtmlFilter  filter  )  [static]

Adds input filter to the static list of available filters. These filters are present by default: text/html MIME type image/* MIME types Plain Text filter (this filter is used if no other filter matches)

bool wxHtmlWindow::AppendToPage ( const wxString source  ) 

Appends HTML fragment to currently displayed text and refreshes the window.

Parameters:
source HTML code fragment
Returns:
false if an error occurred, true otherwise.

wxHtmlContainerCell* wxHtmlWindow::GetInternalRepresentation (  )  const

Returns pointer to the top-level container. See also: Cells Overview, Printing Framework Overview

wxString wxHtmlWindow::GetOpenedAnchor (  ) 

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 wxHtmlWindow::GetOpenedPage (  ) 

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 wxHtmlWindow::GetOpenedPageTitle (  ) 

Returns title of the opened page or wxEmptyString if current page does not contain TITLE tag.

wxFrame* wxHtmlWindow::GetRelatedFrame (  )  const

Returns the related frame.

bool wxHtmlWindow::HistoryBack (  ) 

Moves back to the previous page. (each page displayed using LoadPage() is stored in history list.)

bool wxHtmlWindow::HistoryCanBack (  ) 

Returns true if it is possible to go back in the history (i.e. HistoryBack() won't fail).

bool wxHtmlWindow::HistoryCanForward (  ) 

Returns true if it is possible to go forward in the history (i.e. HistoryBack() won't fail).

void wxHtmlWindow::HistoryClear (  ) 

Clears history.

bool wxHtmlWindow::HistoryForward (  ) 

Moves to next page in history.

virtual bool wxHtmlWindow::LoadFile ( const wxFileName filename  )  [virtual]

Loads HTML page from file and displays it.

Returns:
false if an error occurred, true otherwise
See also:
LoadPage()

virtual bool wxHtmlWindow::LoadPage ( const wxString location  )  [virtual]

Unlike SetPage this function first loads HTML page from location and then displays it. See example:

Parameters:
location The address of document. See wxFileSystem for details on address format and behaviour of "opener".
Returns:
false if an error occurred, true otherwise
See also:
LoadFile()

virtual bool wxHtmlWindow::OnCellClicked ( wxHtmlCell  cell,
wxCoord  x,
wxCoord  y,
const wxMouseEvent event 
) [virtual]

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.

Parameters:
cell The cell inside which the mouse was clicked, always a simple (i.e. non-container) cell
x,y The logical coordinates of the click point
event The mouse event containing other information about the click
Returns:
true if a link was clicked, false otherwise.

virtual void wxHtmlWindow::OnCellMouseHover ( wxHtmlCell  cell,
wxCoord  x,
wxCoord  y 
) [virtual]

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.

Parameters:
cell The cell inside which the mouse is currently, always a simple (i.e. non-container) cell
x,y The logical coordinates of the click point

virtual void wxHtmlWindow::OnLinkClicked ( const wxHtmlLinkInfo link  )  [virtual]

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 wxHtmlOpeningStatus wxHtmlWindow::OnOpeningURL ( wxHtmlURLType  type,
const wxString url,
wxString redirect 
) [virtual]

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 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 wxHTML_OPEN.

Parameters:
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.

Parameters:
url URL being opened.
redirect Pointer to wxString variable that must be filled with an URL if OnOpeningURL returns wxHTML_REDIRECT.

virtual void wxHtmlWindow::OnSetTitle ( const wxString title  )  [virtual]

Called on parsing TITLE tag.

virtual void wxHtmlWindow::ReadCustomization ( wxConfigBase  cfg,
wxString  path = wxEmptyString 
) [virtual]

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 wxHtmlWindow Read values: all things set by SetFonts, SetBorders.

Parameters:
cfg wxConfig from which you want to read the configuration.
path Optional path in config tree. If not given current path is used.

void wxHtmlWindow::SelectAll (  ) 

Selects all text in the window.

See also:
SelectLine(), SelectWord()

void wxHtmlWindow::SelectLine ( const wxPoint pos  ) 

Selects the line of text that pos points at. Note that pos is relative to the top of displayed page, not to window's origin, use wxScrolled::CalcUnscrolledPosition() to convert physical coordinate.

See also:
SelectAll(), SelectWord()

void wxHtmlWindow::SelectWord ( const wxPoint pos  ) 

Selects the word at position pos. Note that pos is relative to the top of displayed page, not to window's origin, use wxScrolled::CalcUnscrolledPosition() to convert physical coordinate.

See also:
SelectAll(), SelectLine()

wxString wxHtmlWindow::SelectionToText (  ) 

Returns current selection as plain text. Returns empty string if no text is currently selected.

void wxHtmlWindow::SetBorders ( int  b  ) 

This function sets the space between border of window and HTML contents. See image:

Parameters:
b indentation from borders in pixels

void wxHtmlWindow::SetFonts ( const wxString normal_face,
const wxString fixed_face,
const int  sizes = NULL 
)

This function sets font sizes and faces.

Parameters:
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.
fixed_face The same thing for fixed face ( TT../TT )
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.

bool wxHtmlWindow::SetPage ( const wxString source  ) 

Sets HTML page and display it. This won't load the page!! It will display the source. See example:

If you want to load a document from some location use LoadPage() instead.

Parameters:
source The HTML document source to be displayed.
Returns:
false if an error occurred, true otherwise.

void wxHtmlWindow::SetRelatedFrame ( wxFrame frame,
const wxString format 
)

Sets the frame in which page title will be displayed. 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 wxHtmlWindow::SetRelatedStatusBar ( int  index  ) 

After calling SetRelatedFrame(), this sets statusbar slot where messages will be displayed. (Default is -1 = no messages.)

Parameters:
index Statusbar slot number (0..n)

void wxHtmlWindow::SetRelatedStatusBar ( wxStatusBar statusbar,
int  index = 0 
)

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.

Parameters:
statusbar Statusbar pointer
index Statusbar slot number (0..n)
Since:
2.9.0

wxString wxHtmlWindow::ToText (  ) 

Returns content of currently displayed page as plain text.

virtual void wxHtmlWindow::WriteCustomization ( wxConfigBase  cfg,
wxString  path = wxEmptyString 
) [virtual]

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 wxHtmlWindow. Saved values: all things set by SetFonts, SetBorders.

Parameters:
cfg wxConfig to which you want to save the configuration.
path Optional path in config tree. If not given, the current path is used.



wxWidgets logo

[ top ]