|
|
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:
view->begin( "file:/tmp/test.html" ); view->parse(); view->write( "<HTML><TITLE>...." ); ..... view->end(); view->show();
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.
KHTMLWidget ( QWidget *parent = 0L, const char *name = 0L, const char *pixdir = 0L ) |
Create a new HTML widget. The widget is empty by default. You must use begin, write, end and parse to fill the widget with content.
Note: pixdir should not be used - it is provided only for backward compatability and has no effect.
Parameters:
_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 < href=... target=... > tag. If this argument is 0L then a unique default name is chosen. |
void begin ( const char *_url = 0L, int _x_offset = 0, int _y_offset = 0 ) |
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':
KURL u( "file:/tmp/test.html" ); view->begin( u.directoryURL() );
Parameters:
_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. |
_dx | is the initial horizontal scrollbar value. Usually you don't want to use this. |
_dy | is the initial vertical scrollbar value. Usually you don't want to use this. |
void write ( const char * ) |
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 end () |
Call this after your last call to write.
void parse () |
Begin parsing any HTML that has been written using the write method.
You may call this function immediately after calling 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 stopParser () |
Stop parsing the HTML immediately.
void print () |
Print current HTML page to the printer.
void calcSize () |
Recalculate the size and position of objects in the page. This is mainly intended for internal use.
void selectByURL ( QPainter *_painter, const char *_url, bool _select ) |
Selects all objects which refer to _url. All selected ojects are redrawn if they changed their selection mode.
void select ( QPainter *_painter, 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.
void select ( QPainter * _painter, QRect &_rect ) |
Selects all objects with an associated URL in this rectangle and deselects all objects outside the rectangle.
Parameters:
_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. |
void select ( QPainter *_painter, QRegExp& _pattern, bool _select ) |
Select all objects with a URL matching the regular expression.
If _painter is null a new painter is created.
void getSelected ( QStrList &_list ) |
Gets a list of all selected URLs. The list may be Null. You can test this using list.isNull().
void selectText ( int _x1, int _y1, int _x2, int _y2 ) |
Selects all text between ( _x1, _y1 ) and ( _x2, y2 ). The selection area selects text line by line, NOT by bounding rectangle.
void getSelectedText ( QString &_str ) |
Get the text the user has marked.
Parameters:
_str | is the QString which will contain the text the user selected. The selected text is appended to any text currently in _str. |
bool isTextSelected () |
Has the user selected any text? Call getSelectedText to retrieve the selected text.
Returns: true if there is text selected.
void findTextBegin () |
Initiate a text search.
bool findTextNext ( const QRegExp &exp ) |
Find the next occurrance of the expression.
void findTextEnd () |
end a text search.
const char* getURL ( QPoint &_point ) |
Checks out whether there is a URL under the point and returns a pointer to this URL or 0L if there is none.
Parameters:
_point | the point to test for the presence of a URL. The point is relative to this widget. |
int docWidth () |
Returns: the width of the parsed HTML code. Remember that the documents width depends on the width of the widget.
int docHeight () |
Returns: the height of the parsed HTML code. Remember that the documents height depends on the width of the widget.
KURL & getDocumentURL () |
Returns: the url of this document
KURL & getBaseURL () |
Returns: the base URL of this document
int xOffset () |
Returns: the horizontal position the view has been scrolled to.
int yOffset () |
Returns: the vertical position the view has been scrolled to.
bool gotoAnchor () |
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 ( const char *_name ) |
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 gotoXY ( int _x_offset, int _y_offset ) |
Jumps to position _x_offset, _y_offset. Returns TRUE if the position was available
void autoScrollY ( int _delay, int _dy ) |
Causes the widget contents to scroll automatically. Call stopAutoScrollY to stop. Stops automatically when the top or bottom of the document is reached.
Parameters:
_delay | Time in milliseconds to wait before scrolling the document again. |
_dy | The amount to scroll the document when _delay elapses. |
void stopAutoScrollY () |
Stops the document from autoScrollY ing.
bool isAutoScrollingY () |
Returns if the widget is currently auto scrolling.
void setView ( KHTMLView *_view ) |
If this widget belongs to a HTMLView, then this function is used to tell the widget about its owner.
KHTMLView* getView () |
Returns: the KHTMLView this widget belongs to.
See also: setView
bool isFrameSet () |
Returns: TRUE if the currently displayed document is a frame set.
void setIsFrameSet ( bool _b ) |
Tells this widget that it displays a frameset. For internal use only.
KHTMLView* getSelectedFrame () |
Returns: a pointer to the currently selected frame ( KHTMLView ) if we are displaying a frameset, otherwise 0L. If this widget is the selected one then htmlView is returned. Otherwise all HTMLFrameSet instances are asked.
bool isFrame () |
Returns: TRUE if the currently displayed document is a frame.
void setIsFrame ( bool _frame) |
Tell the widget wether it is a frame or not. For internal use only.
See also: isFrame
void setMarginWidth ( int _w ) |
Sets the margin width in pixels. This function is used to implement the <tt><frame marginwidth=... ></tt> tag. It is called from KHTMLView and is for INTERNAL USE ONLY.
See also: leftBorder, rightBorder, setMarginWidth
void setMarginHeight ( int _h ) |
Sets the margin height in pixels. This function is used to implement the <tt><frame marginheight=... ></tt> tag. It is called from KHTMLView and is for INTERNAL USE ONLY.
See also: topBorder, bottomBorder, setMarginHeight
bool isSelected () |
Returns: if the user selected this widget.
See also: bIsSelected, setSelected
void setSelected ( bool _active ) |
Switches the 'selected state' of this widget. This results in the drawing or deleting of the black border around the widget.
See also: isSelected
void setDefaultFontBase ( int size ) |
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 setStandardFont ( const char *name ) |
Sets the standard font style.
Parameters:
name | is the font name to use for standard text. |
void setFixedFont ( const char *name ) |
Sets the fixed font style.
Parameters:
name | is the font name to use for fixed text, e.g. the <tt><pre></tt> tag. |
void setDefaultBGColor ( const QColor &col ) |
Sets the default background color to use when one isn't specified explicitly by <tt><body bgcolor=...></tt>
void setDefaultTextColors ( const QColor &normal, const QColor &link, const QColor &vlink ) |
Sets the default text colors.
void setUnderlineLinks ( bool ul ) |
Set whether links are drawn in underlined text.
void setURLCursor ( const QCursor &c ) |
Sets the cursor to use when the cursor is on a link.
void setForceDefault ( bool force ) |
Force use of user defined colors
void setGranularity ( int g ) |
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 calcAbsolutePos () |
Internal use - calculates the absolute position of the objects.
JSEnvironment* getJSEnvironment () |
Returns: a pointer to the JSEnvironment instance used by this widget. Every call to this function will result in the same pointer.
See also: jsEnvironment
JSWindowObject* getJSWindowObject () |
A convenience function to access the JSWindowObject of this html widget.
See also: getJSEvironment
QList<KHTMLWidget>* getFrameList () |
Returns: a list of all frames.
See also: frameList
bool setCharset (const char *name) |
Set document charset.
Any <META ...> setting charsets overrides this setting
Returns: TRUE if successfull
void setOverrideCharset (const char *name = 0) |
set a charset, which will override the <meta ...> setting
void setTitle ( const char * ) |
This signal is emitted whenever the Widget wants to change the window's title. Usually this is the text enclosed in <tt><title>....</title></tt>.
void goUp () |
The user pressed ALT + Up
void goLeft () |
The user pressed ALT + Left
void goRight () |
The user pressed ALT + Right
void doubleClick ( const char * _url, int _button) |
The user double clicked on a URL.
Parameters:
_url | the URL that the user clicked on. |
_button | the mouse button that was used. |
void scrollVert ( int _y ) |
Tells the parent, that the widget has scrolled. This may happen if the user selects an <tt><a href="#anchor"></tt>.
void scrollHorz ( int _x ) |
Tells the parent, that the widget has scrolled. This may happen if the user selects an <a href="#anchor">.
void URLSelected ( const char *_url, int _button ) |
Signals that a URL has been selected using a single click.
Parameters:
_url | is the URL clicked on. |
_button | is the mouse button clicked. |
void URLSelected ( const char *_url, int _button, const char *_target ) |
Signals that a URL has been selected using a single click.
Parameters:
_url | is the URL clicked on. |
_button | is the mouse button clicked. |
_target | is the target window or 0L if there is none. ( Used to implement frames ). |
void onURL ( const char *_url ) |
Signals that the mouse cursor has moved on or off a URL.
Parameters:
_url | is the URL that the mouse cursor has moved onto. _url is null if the cursor moved off a URL. |
void textSelected ( bool _selected ) |
Signal that the user has selected text or the existing selection has become unselected. The text may be retrieved using getSelectedText. This is a good signal to connect to for enabling/disabling the Copy menu item or calling XSetSelectionOwner().
Parameters:
_selected | is true if the user has selected text or false if the current selection has been removed. |
void documentChanged () |
Indicates the document has changed due to new URL loaded or progressive update. This signal may be emitted several times while the document is being parsed. It is an ideal opportunity to update any scrollbars.
void documentStarted () |
This signal is emitted if the widget got a call to parse or begin. This indicates that the widget is working. In a Web Browser you can use this to start an animated logo like netscape does. The signal documentDone will tell you that the widget finished its job.
See also: documentDone
void documentDone () |
This signal is emitted when document is finished parsing and all required images arrived.
See also: documentStarted
void popupMenu ( const char *_url, const QPoint & ) |
If the user pressed the right mouse button over a URL than _url points to this URL, otherwise _url will be null. The position is in global coordinates.
void mousePressed ( const char *_url, const char *_target, QMouseEvent *_ev ) |
This signal is emitted if the user presses the mouse. If he clicks on a link you get the URL in '_url'.
Parameters:
_url | is the clicked URL or null is there was none. |
_target | is the target frame if one is mentioned otherwise 0L. |
_ev | the QMouseEvent. |
void fileRequest ( const char *_url ) |
KHTMLWidget can only load files from your local disk. If it finds a object which requires a remote file, it will emit this signal. If the file is loaded at some time, call slotFileLoaded.
If the file is not needed any more, the signal cancelFileRequest is emitted.
Parameters:
_url | is the URL of the image that needs to be loaded. |
void redirect ( int delay, const char * url ) |
used for url redirection
void slotScrollVert ( int _y ) |
Scrolls the document to _y.
This is usually connected to a scrollbar.
void slotScrollHorz ( int _x ) |
Scrolls the document to _x.
This is usually connected to a scrollbar.
void slotFileLoaded ( const char *_url, const char *_filename ) |
Call when a file requested by fileRequest has been loaded.
Parameters:
_url | is the URL of the file that was requested. |
_filename | is the name of the file that has been stored on the local filesystem. |
void mouseDoubleClickEvent ( QMouseEvent * ) |
This function emits the 'doubleClick' signal when the user double clicks a <a href=...> tag.
void dndMouseMoveEvent ( QMouseEvent * _mouse ) |
Overload this method if you dont want any drag actions.
Reimplemented from KDNDWidget
void dndMouseReleaseEvent ( QMouseEvent * ) |
This function emits the 'URLSelected' signal when the user pressed a <a href=...> tag.
Reimplemented from KDNDWidget
bool URLVisited ( const char *_url ) |
Called when a URL is encountered. Overload this method to indicate which links have been visited previously.
Returns: true if the URL has been visited previously. If true is returned the URL will be rendered in the vlink color. If false is returned the URL will be rendered in the link color.
QString pressedTarget |
If the user pressed the mouse button over an URL then this is the name of the target window for this hyper link. Used to implement frames.
See also: pressedURL
QDict<HTMLPendingFile> mapPendingFiles |
Keeps a list of all pending file.
Generated by: root@jedi.mandrakesoft.com on Sat Dec 25 21:35:53 199. |