class KHTMLView

Widget for displaying HTML. Manages srcollbars and frames. More...

Definition#include <htmlview.h>
InheritsQWidget (qt)
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Members

Public Slots

Protected Members

Protected Slots

Signals


Detailed Description

This widget makes displaying HTML text very easy. It handles scrollbars and stuff. It is able to handle most HTML 3.x including tables and frames. To fill the widget with content you should do the follwing:


 view->begin( "file:/tmp/test.html" );
 view->parse();
 view->write( "&lt;HTML&gt;&lt;TITLE&gt;...." );
 .....
 view->end();
 view->show();

The widget will care for resize events and paint events and for scrolling. Have a look at the set of signals emitted by this widget. You should connect to most of them.

KHTMLView ( QWidget *_parent = 0L, const char *_name = 0L, int _flags = 0, KHTMLView *_parent_view = 0L )

Created a new HTML View. The widget is empty by default. You must use begin, write, end and parse to fill the widget with content.

Parameters:
_nameis 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.

~KHTMLView ()
[virtual]

Destroys the widget and all of its child widgets.

void begin ( const char *_url = 0L, int _dx = 0, int _dy = 0 )
[virtual]

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:
_dxis the initial horizontal scrollbar value. Usually you don't want to use this.
_dyis the initial vertical scrollbar value. Usually you don't want to use this.

void write ( const char *_text )
[virtual]

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 ()
[virtual]

Call this after your last call to write.

void parse ()
[virtual]

This function will parse the code that has been previously written using the write function. Call this one after calling end.

void openURL ( const char *_url )
[virtual]

Shows '_url' in this view. Usually a documentRequest signal is emitted to load the url.

void print ()
[virtual]

Prints this view to the printer.

KHTMLView* newView ( QWidget *_parent = 0L, const char *_name = 0L, int _flags = 0L )
[virtual]

Creates a new view. This function is not intended to be called by the application that uses this widget. It is intended to be overloaded by some class. If for example you have done this:


 class MyView : public KHTMLView
 {
 ...
    virtual KHTMLView* newView( QWidget *_parent, const char *_name, int _flags );
 };

You may now want to reimplement like this


 KHTMLView* myView::newView( QWidget *_parent, const char *_name, int _flags );
 {
   return new MyView( ... );
 }

This will cause that all frames ( if you have some ) will be an instance of MyView, too.<br> FOR INTERNAL USE ONLY.

void setFrameName ( const char *_name )
[virtual]

Changes the name of the widget. This name is used in the &lt;a href=.. target=... &gt; tag.

See also: findView, name

const char* getFrameName ()
[virtual]

Returns: the name of this window.

See also: findView, name, findView

void setIsFrameSet ( bool _frameset )

Tells the widget that it is a frameset This is for internal use only. FOR INTERNAL USE ONLY.

bool isFrameSet ()

FOR INTERNAL USE ONLY.

Returns: TRUE if the view displays a frameset right now.

void setIsFrame ( bool _frame )

Tells the widget that it is a frame of some frameset. This is for internal use only. FOR INTERNAL USE ONLY.

bool isFrame ()

FOR INTERNAL USE ONLY.

Returns: TRUE if the view displays a frame right now.

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.

bool gotoXY ( int _x, int _y )

Scrolls to the position (_x, _y). Returns TRUE if succeeded.

void setFrameBorder ( int _b )

Sets the width of the border. This is used to implement the tag &lt;frame frameborder=... &gt; tag. FOR INTERNAL USE ONLY.

See also: frameBorder

int getFrameBorder ()

Returns: the width of the border in pixels.

See also: setFrameBorder

void setScrolling ( int _scroll )

Tells the widget to show/hide the scrollbars. This function will have effect only when called before begin. It is used to implement the <tt>&lt;frame scrolling=... &gt;</tt> tag.<br> FOR INTERNAL USE ONLY.

Parameters:
_scrollis 1 for yes, 0 for no and -1 for auto.

See also: scrolling

int getScrolling ()

Returns: 1 for yes, 0 for no and -1 for auto.

See also: setScrolling

void setAllowResize ( bool _allow )

Tells the widget wether it should be resizeable or not. The widget may still resize. Its only intention is to provide information for HTMLFrameSet. HTMLFrameSet looks at this flag to determine wether the separator between this frame and another one may be moved by the user. It is used to impement the <tt>&lt;frame noresize &gt;</tt> tag.<br> FOR INTERNAL USE ONLY.

bool allowResize ()

This function is used in HTMLFrameSet. It is for INTERNAL USE ONLY.

Returns: TRUE if the widget may be resized by the user.

See also: setAllowResize

void setMarginWidth ( int _w )

Sets the width of the margin. This function is used to implement the <tt>&lt;frame marginwidth=... &gt;</tt> tag.<br> FOR INTERNAL USE ONLY.

void setMarginHeight ( int _h )

Sets the width of the margin. This function is used to implement the <tt>&lt;frame marginheight=... &gt;</tt> tag.<br> FOR INTERNAL USE ONLY.

void setSelected ( bool _selected )

Tells the widget that it has been selected. This will result in a black border around the widget. This happens only if this widget represents a frame. FOR INTERNAL USE ONLY.

bool isSelected ()

FOR INTERNAL USE ONLY.

Returns: TRUE if this widget represents a frame and if it has been selected by the user. The selected frame has a black inner border.

int xOffset ()

FOR INTERNAL USE ONLY.

Returns: the x offset of the widget. You may use this function to remeber which part of the document the user is currently looking at.

int yOffset ()

Returns: the y offset of the widget. You may use this function to remeber which part of the document the user is currently looking at.

const char* getURL ( QPoint & p )

Checks out wether there is a URL under the point p and returns a pointer to this URL or 0L if there is none.

KHTMLView* findView ( const char *_name )

Seaerches for a KHTMLView with a specific name as mentioned in the constructor.

See also: setName, name

KHTMLView* getSelectedView ()
[virtual]

Returns: the view that represents the currently selected frame or 0L if we dont have frames or a selected one right now.

void select ( QRegExp& _pattern, bool _select )
[virtual]

Select all objects matching the regular expression.

Parameters:
_selectif TRUE then all matching objects are marked, otherwise they become unmarked.

void getSelected ( QStrList &_list )
[virtual]

Gets a list of all selected URLs. The list may be Null. You can test this using list.isNull().

void getSelectedText ( QString &_str )
[virtual]

Get the text the user has marked.

Parameters:
_stris the QString which will contain the text the user selected. The selected text is appended to any text currently in _str.

bool isTextSelected ()
[const]

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.

bool mouseMoveHook ( QMouseEvent *_ev )
[virtual]

This function allows you to customize the behavior of the KHTMLWidget.

Returns: TRUE if the function handled the event, FALSE otherwise.

See also: mousePressedHook, mouseReleaseHook

bool mouseReleaseHook ( QMouseEvent *_ev )
[virtual]

This function allows you to customize the behavior of the KHTMLWidget.

Returns: TRUE if the function handled the event, FALSE otherwise.

See also: mousePressedHook, mouseMoveHook

bool mousePressedHook ( const char* _url, const char *_target, QMouseEvent *_ev, bool _isselected )
[virtual]

This function is called if the user presses the mouse. If he clicks on a link you get the URL in '_url'.

Parameters:
_urlis the clicked URL or 0L is there was none.
_targetis the target frame if one is mentioned otherwise 0L.
_evthe QMouseEvent. The coordinates of the mouse contained in this event are relational to the upper left corner of the KHTMLWidget, not to this widget!
_isselectedis TRUE of the URL '_url' is already selected.

Returns: TRUE if the function handled the event, FALSE otherwise.

See also: mouseMoveHook, mouseReleaseHook

bool dndHook ( const char *_url, QPoint &_p )
[virtual]

This function is called if the user wants to start a DND action. Overload this function and return TRUE to indicate that you processed the event. By default the function returns FALSE. This causes the KHTMLWidget to process the event. Usually this function calls KHTMLWidget::startDrag like this: <TT>view->startDrag(....)</TT>. Dont call the startDrag function of any other window. KDND would not like it :-)

Parameters:
_urlis the URL the user wants to drag around.
_pis the mouse position in global coordinates.

void select ( QPainter * _painter, QRect &_rect )
[virtual]

Selects all objects in this rectangle and deselects all objects outside the rectangle.

Parameters:
_rectis 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.
_painteris a QPainter or 0L. If it is 0L a new painter is created.

void select ( QPainter * _painter, bool _select )
[virtual]

Selects or deselects all objects.

Parameters:
_painteris a QPainter or 0L. If it is 0L a new painter is created.

void selectByURL ( QPainter * _painter, const char *_url, bool _select )

Selects all objects which refer to '_url'. All selected objects are redrawn if they changed their selection mode.

Parameters:
_paintermay be 0L. In this case a new QPainter is created and destroyed afterwards if no painter already exists.

KHTMLWidget* getKHTMLWidget ()

Returns: a pointer to the low-level KHTMLWidget. You may use this to set default colours, etc. supported by the widget.

See also: view

KHTMLView* getParentView ()

Returns: the parent KHTMLView of this one or 0L is this is the top level view.

See also: parentView

KHTMLView* topView ()

Never returns 0L.

bool URLVisited ( const char * )
[virtual]

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.

void setCharset ( const char *_c)

Sets charset for the View

void setOverrideCharset (const char *name = 0)

set a charset, which will override the <meta ...> setting

const char* getCookie ()

For internal use only.

See also: cookie

void setCookie ( const char *_c )

For internal use only.

See also: cookie

SavedPage * saveYourself ()

tell the widget to save himself. Returns a struct, that can be used to restore it's contents

See also: restore()

void restore (SavedPage *)

restores the contents of the widget to the state gotten by a call to saveYourself()

void documentRequest ( KHTMLView* _widget, const char* _url )
[signal]

This signal is emitted if we deal with frames ( or one of the child widgets! ). It tells the owner of the widget to provide a certain URL for a widget. The owner has to call <PRE> _widget->begin( .. ); _widget->parse(); _widget->write( .. ); .... _widget->end(); This may happen before returning ( directly after receiving this signal ), or some time later on. You may be notified that the URL is no longer wanted. This is done with the signal cancelDocumentRequest.

Parameters:
_widgetis the widget that requests the document.
_urlis the URL where the document can be found.

See also: cancelDocumentRequest, slotDocumentRequest

void cancelDocumentRequest ( KHTMLView *_view, const char *_url )
[signal]

This signal is emitted if the widget does not need the document any more.

Parameters:
_urlis the URL of the document that we dont need any more.

void setTitle ( const char *_title )
[signal]

This signal is emitted whenever the widget wants to change the windows title. Usually this is the text enclosed in the title tag.

Parameters:
_titleis a string of ASCII characters.

void URLSelected ( KHTMLView *_view, const char *_url, int _button, const char *_target )
[signal]

Signals that the URL '_url' has been selected. The user used the mouse button '_button' for this.

Parameters:
_urlis a full qualified URL.
_buttonis <tt>LeftButton, MiddleButton or RightButton</tt>
_targetis the target window or 0L if none is specified.

void onURL ( KHTMLView *_view, const char *_url )
[signal]

Signals that the mouse cursor is over URL '_url'. If '_url' is null then cursor moved off a URL

Parameters:
_urlis a full qualified URL.

void textSelected ( KHTMLView *_view, bool _selected )
[signal]

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:
_selectedis true if the user has selected text or false if the current selection has been removed.

void popupMenu ( KHTMLView *_view, const char *_url, const QPoint &_point )
[signal]

This signal is Emitted if the user pressed the right mouse button over an URL. '_url' may be 0L to indicate the the user pressed the right mouse button over an area that does not have an anchor tag.

Parameters:
_urlis a full qualified URL or 0L.
_pointis the position where the user pressed the mouse button. This point is already in global cooredinates.

void imageRequest ( KHTMLView *_view, const char *_url )
[signal]

This signal is emitted if the widget requests to load an image. KHTMLWidget can only load image from your local disk. If it finds an image with another protocol in its URL, it will emit this signal. If the image is loaded at some time, call slotImageLoaded. If the image is not needed any more, the signal cancelImageRequest is emitted. It may happen that not the widget itself but one of its children requests the image. To distibuish that you get '_view'.

See also: cancelImageRequest

void imageRequest ( const char *_url )
[signal]

This signal is only emitted if this widget and not one of its children requests an image.

void cancelImageRequest ( KHTMLView *_view, const char *_url )
[signal]

Cancels an image that has been requested before.

See also: imageRequest

void cancelImageRequest ( const char *_url )
[signal]

This signal is only emitted if this widget and not one of its children cancels a requested image.

void formSubmitted ( KHTMLView *_view, const char *_method, const char *_url, const char *_data )
[signal]

The user pressed a forms submit button.

Parameters:
_urlis the <form action=...> value
_methodis the <form method=...> value
_datais the encoded data to send

void frameSelected ( KHTMLView *_view )
[signal]

Emitted if the user presses the mouse button over this widget and if the widget is a frame. In this case this frame became the selected one and this signal is used to tell our parent about this.

See also: setSeleced

void documentStarted ( KHTMLView *_view )
[signal]

The widget started working. You may use this signal to implement an animated logo like netscape has one.

See also: documentDone

void documentDone ( KHTMLView *_view )
[signal]

This signal is emitted if the widget has parsed and if all images arrived. Mention that this is only true or '_view'. The parent widget or any child widget may still parse or wait for an image. This signal is the complement to documentStarted

void goUp ( KHTMLView *_view )
[signal]

The user pressed ALT + Up

void goRight ( KHTMLView *_view )
[signal]

The user pressed ALT + Right

void goLeft ( KHTMLView *_view )
[signal]

The user pressed ALT + Left

void slotImageLoaded ( const char *_url, const char *_filename )
[slot]

Call this slot if an requested image is available. The rquested image is named '_url' and is stored on the local disk in the file named '_filename'.

Parameters:
_urlis the full qualified URL that was passedd to you by the ref #imageRequest signal.
_filenameis a usual UNIX filename like "/tmp/tmpimage".

void slotDocumentRequest ( KHTMLView* _view, const char* _url )
[slot]

This slot is connected to all children. It emits the signal documentRequest if called. <b>This slot is for internal use only</b>.

void slotCancelDocumentRequest ( KHTMLView* _view, const char* _url )
[slot]

This slot is connected to all children. It emits the signal cancelDocumentRequest if called. <b>This slot is for internal use only</b>.

void slotURLSelected ( KHTMLView* _view, const char* _url, int _button, const char *_target )
[slot]

This slot is connected to all children. It emits the signal URLSelected if called. <b>This slot is for internal use only</b>.

void slotSetTitle ( const char* _text )
[slot]

This slot is connected to all children. It emits the signal setTitle if called. <b>This slot is for internal use only</b>.

void slotOnURL ( KHTMLView *_view, const char *_url )
[slot]

This slot is connected to all children. It emits the signal onURL if called. <b>This slot is for internal use only</b>.

void slotPopupMenu ( KHTMLView *_view, const char *_url, const QPoint &_point )
[slot]

This slot is connected to all children. It emits the signal popupMenu if called. <b>This slot is for internal use only</b>.

void slotImageRequest ( KHTMLView *_view, const char *_url )
[slot]

This slot is connected to all children. It emits the signal imageRequest if called. <b>This slot is for internal use only</b>.

void slotCancelImageRequest ( KHTMLView *_view, const char *_url )
[slot]

This slot is connected to all children. It emits the signal cancelImageRequest if called. <b>This slot is for internal use only</b>.

void slotFormSubmitted ( KHTMLView *_view, const char *_method, const char *_url, const char *_data )
[slot]

This slot is connected to all children. It emits the signal cancelImageRequest if called. <b>This slot is for internal use only</b>.

Parameters:
_methodis the <form method=...> value
_urlis the <form action=...> value
_datais the encoded from data submitted

void slotDocumentStarted ( KHTMLView *_view )
[slot]

This slot is connected to all children. It emits the signal documentStarted if called. <b>This slot is for internal use only</b>.

void slotDocumentDone ( KHTMLView *_view )
[slot]

This slot is connected to all children. It emits the signal documentDone if called. <b>This slot is for internal use only</b>.

void slotVertSubtractLine ()
[slot]

You can move the vertical scrollbar by calling this slot.

void slotVertAddLine ()
[slot]

You can move the vertical scrollbar by calling this slot.

void slotVertSubtractPage ()
[slot]

You can move the vertical scrollbar by calling this slot.

void slotVertAddPage ()
[slot]

You can move the vertical scrollbar by calling this slot.

void slotURLSelected ( const char* _url, int _button, const char *_target )
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal URLSelected if called. <b>This slot is for internal use only</b>.

void slotOnURL ( const char *_url )
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal onURL if called. <b>This slot is for internal use only</b>.

void slotPopupMenu ( const char *_url, const QPoint &_point )
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal popupMenu if called. <b>This slot is for internal use only</b>.

void slotImageRequest ( const char *_url )
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal imageRequest if called. <b>This slot is for internal use only</b>.

void slotCancelImageRequest ( const char *_url )
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal cancelImageRequest if called. <b>This slot is for internal use only</b>.

void slotFormSubmitted ( const char *_url, const char *_method, const char *_data )
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal if the form is submitted

Parameters:
_urlis the <form action=...> value
_methodis the <form method=...> value
_datais the encoded form data submitted

void slotDocumentChanged ()
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal if the document in the HTML Widget changes.<br> <b>For Internal use only</b>.

void slotDocumentStarted ()
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal documentStarted if called. <b>This slot is for internal use only</b>.

void slotDocumentDone ()
[protected virtual slot]

This slot is connected to KHTMLWidget. It emits the signal documentDone if called. <b>This slot is for internal use only</b>.

void slotInternScrollVert ( int )
[protected slot]

Connected to the HTML widget.

void slotInternScrollHorz ( int )
[protected slot]

Connected to the HTML widget

void slotGoUp ()
[protected slot]

The user pressed ALT + Up

void slotGoRight ()
[protected slot]

The user pressed ALT + Right

void slotGoLeft ()
[protected slot]

The user pressed ALT + Left

QString url
[protected]

The currently displayed URL. This is usually the same URL as the one passed to the Constructor of KIDWIindow::KIDWindow.


Generated by: root@jedi.mandrakesoft.com on Sat Dec 25 21:35:53 199.