📄 mghtml_part.h
字号:
// part of browser. we keep the name of the class and functions for the compatability. Only rename the file.// It is the core of html view, to control the behavor of view and read, write the data. // Today is Dec 13th, i do not know when i can finish it.#ifndef _MGHTMLPART_H_#define _MGHTMLPART_H_#include <qstringlist.h>#include "dom2_range.h"#include "mgfont.h"class MGHTMLView;class MGHTMLSettings;class MGHTMLPartPrivate;namespace DOM // for dom interpret.{ class HTMLDocument; class HTMLDocumentImpl; class HTMLTitleElementImpl; class HTMLElementImpl; class HTMLFrameElementImpl; class HTMLIFrameElementImpl; class HTMLObjectElementImpl; class HTMLFormElementImpl; class Node;};namespace khtml // for khtml view message loop and paint.{ class RenderPart; // class RenderPartObject; // struct ChildFrame; class DrawContentsEvent; // Remove it. khtml view get message.};namespace KParts{ class PartManager; //};class KURL;class MGHTMLSettings;class FontPair{ public: FontPair () {logfont = NULL;}; MGFont mgfont; PLOGFONT logfont;}; // --------------------------------------------------------------------------------------------------// ------------------------- MGHTMLPart class -------------------------------------------------------// -------------------------------------------------------------------------------------------------- // This class is khtml's main class. It features an almost complete web browser, and html // renderer. The easiest way to use this class (if you just want to display a an HTML page // at some URL) is the following: // KURL url = "http://www.kde.org"; // KHTMLPart *w = new KHTMLPart(); // w->openURL(url); // w->view()->resize(500, 400); // w->show(); // By default Java and JavaScript support are disabled. You can enable them by using the // enableJava() and enableJScript() methods. Some apps want to write their HTML code directly // into the widget instead of it opening an url. You can also do that in the following way: // QString myHTMLCode = ...; // KHTMLPart *w = new KHTMLPart(); // w->begin(); // w->write(myHTMLCode); // ... // w->end(); // You can do as many calls to write as you want. But there are two write() methods, one // accepting a QString one accepting a char argument. You should use one or the other // (but not both) since the method using the char * argument does an additional decoding // step to convert the written data to Unicode.class MGHTMLPart { friend class MGHTMLView; friend class DOM::HTMLTitleElementImpl; friend class DOM::HTMLFrameElementImpl; friend class DOM::HTMLIFrameElementImpl; friend class DOM::HTMLObjectElementImpl; friend class DOM::HTMLElementImpl; friend class DOM::HTMLFormElementImpl; friend class khtml::RenderPartObject;public: MGHTMLPart(MGHTMLView *); virtual ~MGHTMLPart(); // when input address in the address bar. virtual void urlSelected( const QString &url, int button = 0, int state = 0, const QString &_target = QString::null ); PLOGFONT getFont (const MGFont& font); DOM::HTMLDocumentImpl *docImpl() const; // Opens the specified URL url. Reimplemented from KParts::ReadOnlyPart::openURL . virtual bool openURL( const KURL &url ); // Stop loading the document and kill all data requests (for images, etc.) virtual bool closeURL(); DOM::HTMLDocument htmlDocument() const; MGHTMLView *view() const; void enableJScript( bool enable ); bool jScriptEnabled() const;#if JAVASCRIPT_ENABLE // Execute the specified snippet of JavaScript code. //QVariant executeScript( const QString &script ); bool executeScript( const QString &script ); // Same as above except the Node parameter specifying the 'this' value. // QVariant executeScript( const DOM::Node &n, const QString &script ); bool executeScript( DOM::HTMLElementImpl *nimpl, const QString &script ); #endif void setDNDEnabled( bool b ); // ????? bool dndEnabled() const;// void autoloadImages( bool enable ); bool autoloadImages() const; // Clear the widget and prepares it for new content. If you want url() to return for // example "file:/tmp/test.html", you can use the following code: // view->begin( KURL("file:/tmp/test.html" ) ); // url is the url of the document to be displayed. Even if you are generating the HTML // on the fly, it may be useful to specify a directory so that any pixmaps are found. // xOffset is the initial horizontal scrollbar value. Usually you don't want to use this. // yOffset is the initial vertical scrollbar value. Usually you don't want to use this. // All child frames and the old document are removed if you call this method. virtual void begin( const KURL &url = KURL(), int xOffset = 0, int yOffset = 0 ); // Write another part of the HTML code to the widget.You may call this function many times // in sequence. But remember: The fewer calls you make, the faster the widget will be. // The HTML code is send through a decoder which decodes the stream to Unicode. // The len parameter is needed for streams encoded in utf-16,since these can have \0 chars // in them. In case the encoding you're using isn't utf-16, you can safely leave out the // length parameter. // Attention: Don't mix calls to @ref write( const char *) with calls to write( const QString & ). virtual void write( const char *str, int len = -1 ); // Write another part of the HTML code to the widget. You may call this function many // times in sequence. But remember: The fewer calls you make, the faster the widget will be. virtual void write( const QString &str ); // Call this after your last call to write(). virtual void end(); //Mainly used internally. Sets the document's base URL. void setBaseURL( const KURL &url ); KURL getBaseURL(); // Retrieve the base URL of this document. The base URL is ususally set by a <base url=...> // tag in the document head. KURL baseURL() const; // Mainly used internally. Sets the document's base target. void setBaseTarget( const QString &target ); // Retrieve the base target of this document. The base target is ususally set by a <base target=...> // tag in the document head. QString baseTarget() const; // internal KURL completeURL( const QString &url, const QString &target = QString::null ); // @internal// void scheduleRedirection( int delay, const QString &url ); // Set the charset to use for displaying HTML pages. If override is true, it will override // charset specifications of the document.// bool setCharset( const QString &name, bool override = false ); // Set the encoding the page uses. This can be different from the charset. // The widget will try to reload the current page in the new encoding, if url() is not empty.// bool setEncoding( const QString &name, bool override = false ); // Set a user defined style sheet to be used on top of the HTML 4 default style sheet. // This gives a wide range of possibilities to change the layout of the page. void setUserStyleSheet(const KURL &url); void setUserStyleSheet(const QString &styleSheet); // Set point sizes to be associated with the HTML-sizes used in <FONT size=Html-Font-Size> // Html-Font-Sizes range from 0 (smallest) to 6 (biggest), but you can specify up to 15 // font sizes, the bigger ones will get used, if <font size=+1> extends over 7, or if a // 'font-size: larger' style declaration gets into this region. // They are related to the CSS font sizes by 0 == xx-small to 6 == xx-large. */ void setFontSizes(const QValueList<int> &newFontSizes ); // Get point sizes to be associated with the HTML-sizes used in <FONT size=Html-Font-Size> // Html-Font-Sizes range from 0 (smallest) to 6 (biggest). // They are related to the CSS font sizes by 0 == xx-small to 6 == xx-large. QValueList<int> fontSizes() const; // Reset the point sizes to be associated with the HTML-sizes used in <FONT size=Html-Font-Size> // to their default. Html-Font-Sizes range from 1 (smallest) to 7 (biggest). void resetFontSizes(); // Set the standard font style.param name The font name to use for standard text. void setStandardFont( const QString &name ); // Set the fixed font style.param name The font name to use for fixed text, e.g. // the <tt><pre></tt> tag. void setFixedFont( const QString &name ); // Find the anchor named name.If the anchor is found, the widget scrolls to the closest position. // Returns if the anchor has been found. bool gotoAnchor( const QString &name ); // Set the cursor to use when the cursor is on a link. void setURLCursor( const HCURSOR &c ); // Retrieve the cursor which is used when the cursor is on a link. const HCURSOR& urlCursor() const; // Convenience method to show the document's view. Equivalent to widget()->show() or view()->show() . void show(); // Convenience method to hide the document's view. Equivalent to widget()->hide() or view()->hide(). void hide(); // Retrieve the p Node currently under the mouse. DOM::Node nodeUnderMouse() const; const MGHTMLSettings *settings() const; // Retrieve a pointer to the parent KHTMLPart if the part is a frame in an HTML frameset. // Returns 0L otherwise. MGHTMLPart *parentPart(); void setParentPart(MGHTMLPart *);// QStringList frameNames() const;// const QList<KParts::ReadOnlyPart> frames() const; // Find a frame by name. Returns 0L if frame can't be found.// KHTMLPart *findFrame( const QString &f ); // Returns whether a frame with the specified name is exists or not. In contrary to the findFrame // method this one also returns true if the frame is defined but no displaying component has been // found/loaded, yet. bool frameExists( const MGString &frameName );// bool openURLInFrame( const KURL &url, const KParts::URLArgs &urlArgs ); // from now on, the functions below are all response for the message. in term of the message, different // functions will be invoked.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -