⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html.h

📁 PIXIL is a small footprint operating environment, complete with PDA PIM applications, a browser and
💻 H
📖 第 1 页 / 共 3 页
字号:
/* This file is part of the KDE libraries    Copyright (C) 1997 Martin Jones (mjones@kde.org)              (C) 1997 Torben Weis (weis@kde.org)    This library is free software; you can redistribute it and/or    modify it under the terms of the GNU Library General Public    License as published by the Free Software Foundation; either    version 2 of the License, or (at your option) any later version.    This library is distributed in the hope that it will be useful,    but WITHOUT ANY WARRANTY; without even the implied warranty of    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU    Library General Public License for more details.    You should have received a copy of the GNU Library General Public License    along with this library; see the file COPYING.LIB.  If not, write to    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,    Boston, MA 02111-1307, USA.*///----------------------------------------------------------------------------//// KDE HTML Widget// $Id: html.h,v 1.1 2003/09/08 19:42:15 jasonk Exp $#ifndef HTML_H#define HTML_H#define KHTMLW_VERSION    1303		// 00.13.03#define KHTMLW_MAX_URL    1024      // Maximum length of a URL#define KHTMLW_MAX_TARGET 256       // Maximum length of a target window name#include <qpainter.h>#include <qstrlist.h>#include <qpixmap.h>#include <qstack.h>#include <qfont.h>#include <qtimer.h>#include <qlist.h>#include <kurl.h>#include <qdict.h>#include <qstring.h>#include <qbuffer.h>class KHTMLWidget;class HTMLIterator;struct SavedPage;#include "drag.h"#include "htmldata.h"#include "htmlobj.h"#include "htmlclue.h"#include "htmlform.h"#include "htmltoken.h"#include "htmlframe.h"#include "htmlview.h"#include "jscript.h"// Default borders between widgets frame and displayed text#define LEFT_BORDER 10#define RIGHT_BORDER 20#define TOP_BORDER 10#define BOTTOM_BORDER 10//#define TORBENSDEBUG//#define MARTINSDEBUGclass KCharsetConverter;void debugT( const char *msg , ...);void debugM( const char *msg , ...);enum ScrollType {SCROLL_NONE, SCROLL_LEFT, SCROLL_RIGHT, SCROLL_UP, SCROLL_DOWN};struct HTMLPendingFile{public:  HTMLPendingFile();  HTMLPendingFile( const char *_url, HTMLObject *_obj );  QBuffer m_buffer;  QString m_strURL;  QList<HTMLObject> m_lstClients;};struct FrameLayout{    QString rows;    QString cols;    int frameBorder;    bool allowResize;};struct SavedPage{    SavedPage();    ~SavedPage();    QString frameName;    bool isFrame;    int scrolling;    int frameborder;    int marginwidth;    int marginheight;    bool allowresize;    bool isFrameSet;    QString url;    QString title;    int xOffset;    int yOffset;    FrameLayout *frameLayout;    QList<SavedPage> *frames;};  typedef void (KHTMLWidget::*parseFunc)(HTMLClueV *_clue, const char *str);/** * @short Basic HTML Widget.  Does not handle scrollbars or frames. * * This widget is good for use in your custom application which does not * necessarily want to handle frames, or want custom control of scrollbars. * To add content to the widget you should do the follwing: * <PRE> * view->begin( "file:/tmp/test.html" ); * view->parse(); * view->write( "&lt;HTML&gt;&lt;TITLE&gt;...." ); * ..... * view->end(); * view->show(); * </PRE> * The widget will take care of resize events and paint events. * Have a look at the set of signals emitted by this widget. You should connect * to most of them. * * Note: All HTML is parsed in the background using Qt timers, so you will not * see any content displayed until the event loop is running. */class KHTMLWidget : public KDNDWidget{    Q_OBJECTpublic:    /**     * Create a new HTML widget.  The widget is empty by default.     * You must use @ref #begin, @ref #write, @ref #end and @ref #parse     * to fill the widget with content.     *     * @param _name is the name of the widget. Usually this name is only     *              meaningful for Qt but in this case it is the name of     *              the HTML window. This means you can reference this name     *              in the &lt; href=... target=... &gt; tag. If this argument     *              is 0L then a unique default name is chosen.     *     * Note: pixdir should not be used - it is provided only for backward     * compatability and has no effect.     */    KHTMLWidget( QWidget *parent = 0L, const char *name = 0L,		const char *pixdir = 0L );    virtual ~KHTMLWidget();    /**     * Clears the widget and prepares it for new content. If you display     * for example "file:/tmp/test.html", you can use the following code     * to get a value for '_url':     * <PRE>     * KURL u( "file:/tmp/test.html" );     * view->begin( u.directoryURL() );     * </PRE>     *     * @param _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.     * @param _dx is the initial horizontal scrollbar value. Usually you don't     * want to use this.     * @param _dy is the initial vertical scrollbar value. Usually you don't     * want to use this.     */    void begin( const char *_url = 0L, int _x_offset = 0, int _y_offset = 0 );    /**     * Writes another part of the HTML code to the widget. You may call     * this function many times in sequence. But remember: The less calls     * the faster the widget is.     */    void write( const char * );    /**     * Call this after your last call to @ref #write.     */    void end();    /**     * Begin parsing any HTML that has been written using the @ref #write     * method.     *     * You may call this function immediately after calling @ref #begin.      * In this case the HTML will be passed and displayed whenever the     * event loop is active.  This allows background parsing and display     * of the HTML as it arrives.     */    void parse();    /**     * Stop parsing the HTML immediately.     */    void stopParser();    /**     * Print current HTML page to the printer.     */    void print();    /**     * Recalculate the size and position of objects in the page.     * This is mainly intended for internal use.     */    void calcSize();    /**     * Selects all objects which refer to _url. All selected ojects     * are redrawn if they changed their selection mode.     */    virtual void selectByURL( QPainter *_painter, const char *_url, bool _select );    /**     * Selects/Unselects all objects with an associated URL.     * This is usually used to disable     * a selection. All objects are redrawn afterwards if they changed     * their selection mode.     */    virtual void select( QPainter *_painter, bool _select );    /**     * Selects all objects with an associated URL in this rectangle and     * deselects all objects outside the rectangle.      *     * @param _rect is a rectangle in display coordinates. This means     *              that the point (0,0) is the upper/left most point of     *              the widget but must not be this one for the HTML page.     *              This happens if the widget is being scrolled.     */    virtual void select( QPainter * _painter, QRect &_rect );    /**     * Select all objects with a URL matching the regular expression.     *     * If _painter is null a new painter is created.     */    virtual void select( QPainter *_painter, QRegExp& _pattern, bool _select );    /**     * Gets a list of all selected URLs. The list may be Null.     * You can test this using list.isNull().     */    virtual void getSelected( QStrList &_list );    /**     * Selects all text between ( _x1, _y1 ) and ( _x2, y2 ).  The selection     * area selects text line by line, NOT by bounding rectangle.     */    virtual void selectText( int _x1, int _y1, int _x2, int _y2 );    /**     * Get the text the user has marked.     *     * @param _str is the QString which will contain the text the user     * selected.  The selected text is appended to any text currently in     * _str.     */    virtual void getSelectedText( QString &_str );    /**     * Has the user selected any text?  Call @ref #getSelectedText to     * retrieve the selected text.     *     * @return true if there is text selected.     */    bool isTextSelected() const	{	return bIsTextSelected; }     /**     * Initiate a text search.     */    void findTextBegin();    /**     * Find the next occurrance of the expression.     */    bool findTextNext( const QRegExp &exp );    /**     * end a text search.     */    void findTextEnd();    /**     * Checks out whether there is a URL under the point and returns a pointer     * to this URL or 0L if there is none.     *     * @param _point the point to test for the presence of a URL.  The     * point is relative to this widget.     */    const char* getURL( QPoint &_point );    /**     * @return the width of the parsed HTML code. Remember that     * the documents width depends on the width of the widget.     */    int docWidth() const;    /**     * @return the height of the parsed HTML code. Remember that     * the documents height depends on the width of the widget.     */    int docHeight() const;    /**     * @return the url of this document     */    KURL &getDocumentURL()		{	return actualURL; }    /**     * @return the base URL of this document     */    KURL &getBaseURL()		{	return baseURL; }    /**     * @return the horizontal position the view has been scrolled to.     */    int xOffset() const { return x_offset; }    /**     * @return the vertical position the view has been scrolled to.     */    int yOffset() const { return y_offset; }    /**     * Find the default anchor. If the anchor is found, the widget     * scrolls to the closest position. Returns TRUE if the anchor has     * been found.      */     bool gotoAnchor();    /**     * Find the anchor named '_name'. If the anchor is found, the widget     * scrolls to the closest position. Returns TRUE if the anchor has     * been found. If the anchor could not be found it is retried when a     * new part of the document arrives.     */    bool gotoAnchor( const char *_name );    /**     * Jumps to position _x_offset, _y_offset.     * Returns TRUE if the position was available     */    bool gotoXY( int _x_offset, int _y_offset );    /**     * Causes the widget contents to scroll automatically.  Call     * @ref #stopAutoScrollY to stop.  Stops automatically when the     * top or bottom of the document is reached.     *      * @param _delay Time in milliseconds to wait before scrolling the     * document again.     * @param _dy The amount to scroll the document when _delay elapses.     */    void autoScrollY( int _delay, int _dy );    /**     * Stops the document from @ref #autoScrollY ing.     */    void stopAutoScrollY();    /**     * Returns if the widget is currently auto scrolling.     */    bool isAutoScrollingY()	 	{	return autoScrollYTimer.isActive(); }    /**     * If this widget belongs to a @ref HTMLView, then this function     * is used to tell the widget about its owner.     *     * @see #htmlView          * @see #getView     */    void setView( KHTMLView *_view ) { htmlView = _view; }    /**     * @return the @ref KHTMLView this widget belongs to.     *     * @see #setView     */    KHTMLView* getView() { return htmlView; }    /**     * @return TRUE if the currently displayed document is a frame set.     */    bool isFrameSet() { return bIsFrameSet; }    /**     * Tells this widget that it displays a frameset.     * For internal use only.     */    void setIsFrameSet( bool _b );    /**     * @return a pointer to the currently selected frame ( @ref KHTMLView ) if     * we are displaying a frameset, otherwise 0L. If this widget is the     * selected one then @ref htmlView is returned. Otherwise all     * @ref HTMLFrameSet instances are asked.     */    KHTMLView* getSelectedFrame();      /**     * @return TRUE if the currently displayed document is a frame.     */    bool isFrame() { return bIsFrame; }    /**     * Tell the widget wether it is a frame or not.     * For internal use only.     *     * @see #isFrame     */    void setIsFrame( bool _frame);    /**     * Sets the margin width in pixels. This function is used to implement the     * <tt>&lt;frame marginwidth=... &gt;</tt> tag.     * It is called from @ref KHTMLView and is for INTERNAL USE ONLY.     *     * @see #leftBorder     * @see #rightBorder     * @see KHTMLView::setMarginWidth     */    void setMarginWidth( int _w ) { leftBorder = _w; rightBorder = _w + 4; }    /**     * Sets the margin height in pixels. This function is used     * to implement the     * <tt>&lt;frame marginheight=... &gt;</tt> tag.     * It is called from @ref KHTMLView and is for INTERNAL USE ONLY.     *     * @see #topBorder     * @see #bottomBorder     * @see KHTMLView::setMarginHeight     */    void setMarginHeight( int _h ) { topBorder = _h; bottomBorder = _h; }      /**     * @return if the user selected this widget.     *     * @see #bIsSelected     * @see #setSelected     */    bool isSelected()    {      return bIsSelected;    }      /**     * Switches the 'selected state' of this widget. This results in the     * drawing or deleting of the black border around the widget.     *     * @see #isSelected     */    void setSelected( bool _active );      /**     * Sets the base font size ( range: 2-5,  default: 3 ).     *     * Note that font sizes are not defined in points.     * Font sizes range from 1 (smallest) to 7 (biggest).     */    void setDefaultFontBase( int size )    {	if ( size < 2 ) size = 2;        else if ( size > 5 ) size = 5;        defaultSettings->fontBaseSize = size - 1;    }    //    // The new interface:    // use:     //      int newFontSizes[7];     //    void setFontSizes(const int *newFontSizes);    void getFontSizes(int *newFontSizes);    void resetFontSizes( void );    /**     * Sets the standard font style.     *     * @param name is the font name to use for standard text.     */    void setStandardFont( const char *name )	{	defaultSettings->fontBaseFace = name; }    /**     * Sets the fixed font style.     *     * @param name is the font name to use for fixed text, e.g.     * the <tt>&lt;pre&gt;</tt> tag.     */    void setFixedFont( const char *name )	{	defaultSettings->fixedFontFace = name; }    /**     * Sets the default background color to use when one isn't specified     * explicitly by <tt>&lt;body bgcolor=...&gt;</tt>     */    void setDefaultBGColor( const QColor &col )	{	defaultSettings->bgColor = col; }    /**     * Sets the default text colors.     */    void setDefaultTextColors( const QColor &normal, const QColor &link,	const QColor &vlink )    {	defaultSettings->fontBaseColor = normal;	defaultSettings->linkColor = link;	defaultSettings->vLinkColor = vlink;    }    /**     * Set whether links are drawn in underlined text.     */    void setUnderlineLinks( bool ul )	{ defaultSettings->underlineLinks = ul; }    /**     * Sets the cursor to use when the cursor is on a link.     */    void setURLCursor( const QCursor &c )	{	linkCursor = c; }    /**     * Force use of user defined colors     */    void setForceDefault( bool force )    { defaultSettings->forceDefault = force; }    /**     * Cryptic?  This is used to set the number of tokens to parse     * in one timeslice during background processing.     *     * You probably don't need to touch this.     */    void setGranularity( int g )	{   granularity = g; }    /*     * If a HTMLObject object needs a file from the web, it     * calls this function.     */    void requestFile( HTMLObject *_obj, const char *_url );    /*     * Cancels a previous @ref requestFile.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -