檢視原始碼 wxHtmlWindow (wx v2.4.3)

wxHtmlWindow 可能是您唯一會直接使用的類別,除非您想做一些特別的事情(例如新增標籤處理器或 MIME 篩選器)。

此類別的目的是在視窗中顯示豐富的內容頁面(可以是本機檔案或透過 HTTP 協定下載),這些內容頁面基於 HTML 標準的子集。視窗的寬度是固定的,在建構函式中給定,而虛擬高度會根據頁面大小動態改變。一旦建立視窗,您可以使用原始 HTML 呼叫 setPage/2、使用 wxFileSystem (在 wx 中未實作)位置呼叫 loadPage/2 或使用檔案名稱呼叫 loadFile/2 來設定其內容。

注意:如果您需要完整的 HTML/CSS 支援以及 Javascript 引擎,請考慮改用 wxWebView

wxHtmlWindow 使用 wxImage 類別來顯示圖片,因此您需要在載入頁面之前,初始化您所使用的任何圖片格式的處理器。請參閱 ?wxInitAllImageHandlers 和 wxImage::AddHandler (在 wx 中未實作)。

樣式

此類別支援以下樣式

  • wxHW_SCROLLBAR_NEVER:永遠不顯示捲軸,即使頁面大於視窗也是如此。

  • wxHW_SCROLLBAR_AUTO:僅在頁面大小超過視窗大小時才顯示捲軸。

  • wxHW_NO_SELECTION:不允許使用者選取文字。

請參閱:wxHtmlLinkEvent

此類別衍生自以下類別,並可使用其函式

wxWidgets 文件:wxHtmlWindow

事件

此類別發出的事件類型

摘要

函式

將 HTML 片段附加到目前顯示的文字並重新整理視窗。

銷毀物件

傳回目前開啟頁面中的錨點(請參閱 getOpenedPage/1)。

傳回開啟頁面的完整位置。

傳回開啟頁面的標題,如果目前頁面不包含 <TITLE> 標籤,則傳回 wxEmptyString。

傳回相關的框架。

返回上一頁。

如果可以返回歷史記錄,則傳回 true,即。

如果可以向前瀏覽歷史記錄,則傳回 true,即。

清除歷史記錄。

移動到歷史記錄中的下一頁。

從檔案載入 HTML 頁面並顯示它。

setPage/2 不同,此函式首先從 location 載入 HTML 頁面,然後顯示它。

預設建構函式。

建構函式。

選取視窗中的所有文字。

以純文字形式傳回目前選取的文字。

選取 pos 指向的文字行。

選取位置 pos 上的單字。

此函式設定視窗邊框與 HTML 內容之間的空間。

此函式設定字型大小和字體。

設定頁面的來源並顯示它,例如

設定將顯示頁面標題的框架。

呼叫 setRelatedFrame/3 之後,此設定會設定將顯示訊息的狀態列插槽。

設定將顯示訊息的相關狀態列。

以純文字形式傳回目前顯示頁面的內容。

類型

-type wxHtmlWindow() :: wx:wx_object().

函式

此函式的連結

appendToPage(This, Source)

檢視原始碼
-spec appendToPage(This, Source) -> boolean() when This :: wxHtmlWindow(), Source :: unicode:chardata().

將 HTML 片段附加到目前顯示的文字並重新整理視窗。

傳回:如果發生錯誤,則傳回 false,否則傳回 true。

-spec destroy(This :: wxHtmlWindow()) -> ok.

銷毀物件

-spec getOpenedAnchor(This) -> unicode:charlist() when This :: wxHtmlWindow().

傳回目前開啟頁面中的錨點(請參閱 getOpenedPage/1)。

如果未開啟任何頁面,或顯示的頁面不是由呼叫 loadPage/2 所產生,則傳回空字串。

-spec getOpenedPage(This) -> unicode:charlist() when This :: wxHtmlWindow().

傳回開啟頁面的完整位置。

如果未開啟任何頁面,或顯示的頁面不是由呼叫 loadPage/2 所產生,則傳回空字串。

此函式的連結

getOpenedPageTitle(This)

檢視原始碼
-spec getOpenedPageTitle(This) -> unicode:charlist() when This :: wxHtmlWindow().

傳回開啟頁面的標題,如果目前頁面不包含 <TITLE> 標籤,則傳回 wxEmptyString。

-spec getRelatedFrame(This) -> wxFrame:wxFrame() when This :: wxHtmlWindow().

傳回相關的框架。

-spec historyBack(This) -> boolean() when This :: wxHtmlWindow().

返回上一頁。

只有使用 loadPage/2 顯示的頁面才會儲存在歷史記錄清單中。

-spec historyCanBack(This) -> boolean() when This :: wxHtmlWindow().

如果可以返回歷史記錄,則傳回 true,即。

historyBack/1 不會失敗。

此函式的連結

historyCanForward(This)

檢視原始碼
-spec historyCanForward(This) -> boolean() when This :: wxHtmlWindow().

如果可以向前瀏覽歷史記錄,則傳回 true,即。

historyForward/1 不會失敗。

-spec historyClear(This) -> ok when This :: wxHtmlWindow().

清除歷史記錄。

-spec historyForward(This) -> boolean() when This :: wxHtmlWindow().

移動到歷史記錄中的下一頁。

只有使用 loadPage/2 顯示的頁面才會儲存在歷史記錄清單中。

此函式的連結

loadFile(This, Filename)

檢視原始碼
-spec loadFile(This, Filename) -> boolean() when This :: wxHtmlWindow(), Filename :: unicode:chardata().

從檔案載入 HTML 頁面並顯示它。

傳回:如果發生錯誤,則傳回 false,否則傳回 true

請參閱:loadPage/2

此函式的連結

loadPage(This, Location)

檢視原始碼
-spec loadPage(This, Location) -> boolean() when This :: wxHtmlWindow(), Location :: unicode:chardata().

setPage/2 不同,此函式首先從 location 載入 HTML 頁面,然後顯示它。

傳回:如果發生錯誤,則傳回 false,否則傳回 true

請參閱:loadFile/2

-spec new() -> wxHtmlWindow().

預設建構函式。

-spec new(Parent) -> wxHtmlWindow() when Parent :: wxWindow:wxWindow().

等同於 new(Parent, [])

-spec new(Parent, [Option]) -> wxHtmlWindow()
             when
                 Parent :: wxWindow:wxWindow(),
                 Option ::
                     {id, integer()} |
                     {pos, {X :: integer(), Y :: integer()}} |
                     {size, {W :: integer(), H :: integer()}} |
                     {style, integer()}.

建構函式。

這些參數與 wxScrolled::wxScrolled() (在 wx 中未實作)建構函式相同。

-spec selectAll(This) -> ok when This :: wxHtmlWindow().

選取視窗中的所有文字。

請參閱

-spec selectionToText(This) -> unicode:charlist() when This :: wxHtmlWindow().

以純文字形式傳回目前選取的文字。

如果目前未選取任何文字,則傳回空字串。

-spec selectLine(This, Pos) -> ok when This :: wxHtmlWindow(), Pos :: {X :: integer(), Y :: integer()}.

選取 pos 指向的文字行。

請注意,pos 相對於顯示頁面的頂部,而不是視窗的原點,請使用 wxScrolledWindow:calcUnscrolledPosition/3 來轉換物理座標。

請參閱

-spec selectWord(This, Pos) -> ok when This :: wxHtmlWindow(), Pos :: {X :: integer(), Y :: integer()}.

選取位置 pos 上的單字。

請注意,pos 相對於顯示頁面的頂部,而不是視窗的原點,請使用 wxScrolledWindow:calcUnscrolledPosition/3 來轉換物理座標。

請參閱

-spec setBorders(This, B) -> ok when This :: wxHtmlWindow(), B :: integer().

此函式設定視窗邊框與 HTML 內容之間的空間。

請參閱圖片

此函式的連結

setFonts(This, Normal_face, Fixed_face)

檢視原始碼
-spec setFonts(This, Normal_face, Fixed_face) -> ok
                  when
                      This :: wxHtmlWindow(),
                      Normal_face :: unicode:chardata(),
                      Fixed_face :: unicode:chardata().

等同於 setFonts(This, Normal_face, Fixed_face, [])

-spec setFonts(This, Normal_face, Fixed_face, [Option]) -> ok
                  when
                      This :: wxHtmlWindow(),
                      Normal_face :: unicode:chardata(),
                      Fixed_face :: unicode:chardata(),
                      Option :: {sizes, [integer()]}.

此函式設定字型大小和字體。

請參閱 wxHtmlDCRenderer::SetFonts (在 wx 中未實作)以取得詳細說明。

-spec setPage(This, Source) -> boolean() when This :: wxHtmlWindow(), Source :: unicode:chardata().

設定頁面的來源並顯示它,例如

如果您想從某個位置載入文件,請改用 loadPage/2

傳回:如果發生錯誤,則傳回 false,否則傳回 true。

此函式的連結

setRelatedFrame(This, Frame, Format)

檢視原始碼
-spec setRelatedFrame(This, Frame, Format) -> ok
                         when
                             This :: wxHtmlWindow(),
                             Frame :: wxFrame:wxFrame(),
                             Format :: unicode:chardata().

設定將顯示頁面標題的框架。

format 是框架標題的格式,例如「HtmlHelp : %s」。它必須剛好包含一個 s。此 s 會替換為 HTML 頁面標題。

-spec setRelatedStatusBar(This, Statusbar) -> ok
                             when This :: wxHtmlWindow(), Statusbar :: wxStatusBar:wxStatusBar();
                         (This, Index) -> ok when This :: wxHtmlWindow(), Index :: integer().

呼叫 setRelatedFrame/3 之後,此設定會設定將顯示訊息的狀態列插槽。

(預設值為 -1 = 無訊息。)

-spec setRelatedStatusBar(This, Statusbar, [Option]) -> ok
                             when
                                 This :: wxHtmlWindow(),
                                 Statusbar :: wxStatusBar:wxStatusBar(),
                                 Option :: {index, integer()}.

設定將顯示訊息的相關狀態列。

如果您只想要狀態列更新,而不需要變更框架標題,請呼叫此函式,而不是 setRelatedFrame/3

自:2.9.0

-spec toText(This) -> unicode:charlist() when This :: wxHtmlWindow().

以純文字形式傳回目前顯示頁面的內容。