X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/232fdc630c42eb165f7659981043e794be03b3b7..9e9574fe45b176ee74bba8fad7574cf9906145d1:/interface/wx/html/htmlwin.h diff --git a/interface/wx/html/htmlwin.h b/interface/wx/html/htmlwin.h index ef7dde2599..330ff938d7 100644 --- a/interface/wx/html/htmlwin.h +++ b/interface/wx/html/htmlwin.h @@ -2,23 +2,128 @@ // Name: html/htmlwin.h // Purpose: interface of wxHtmlWindow // Author: wxWidgets team -// RCS-ID: $Id$ // 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 wxBitmap& 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 HTML pages (either local file or - downloaded via HTTP protocol) in a window. + 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, see instead + wxWebView. + @note wxHtmlWindow uses the wxImage class for displaying images, as such you need to initialize the handlers for any image formats you use before loading a page. @@ -49,7 +154,7 @@ @see wxHtmlLinkEvent, wxHtmlCellEvent */ -class wxHtmlWindow : public wxScrolledWindow +class wxHtmlWindow : public wxScrolledWindow, public wxHtmlWindowInterface { public: /** @@ -360,7 +465,7 @@ public: */ virtual void WriteCustomization(wxConfigBase* cfg, wxString path = wxEmptyString); - + protected: /** @@ -405,6 +510,11 @@ protected: +wxEventType wxEVT_HTML_CELL_CLICKED; +wxEventType wxEVT_HTML_CELL_HOVER; +wxEventType wxEVT_HTML_LINK_CLICKED; + + /** @class wxHtmlLinkEvent