KHTMLWidget Class Reference
[khtmlw Index] [khtmlw Hierarchy]
[Headers]
Basic HTML Widget. Does not handle scrollbars or frames. More...
#include <html.h>
Inherits: KDNDWidget (kdecore)
Public Members
- KHTMLWidget ( QWidget *parent = 0L, const char *name = 0L, const char *pixdir = 0L )
- virtual ~KHTMLWidget ()
- void begin ( const char *_url = 0L, int _x_offset = 0, int _y_offset = 0 )
- void write ( const char * )
- void end ()
- void parse ()
- void stopParser ()
- void print ()
- void calcSize ()
- virtual void selectByURL ( QPainter *_painter, const char *_url, bool _select )
- virtual void select ( QPainter *_painter, bool _select )
- virtual void select ( QPainter * _painter, QRect &_rect )
- virtual void select ( QPainter *_painter, QRegExp& _pattern, bool _select )
- virtual void getSelected ( QStrList &_list )
- virtual void selectText ( int _x1, int _y1, int _x2, int _y2 )
- virtual void getSelectedText ( QString &_str )
- bool isTextSelected () const
- void findTextBegin ()
- bool findTextNext ( const QRegExp &exp )
- void findTextEnd ()
- const char* getURL ( QPoint &_point )
- int docWidth () const
- int docHeight () const
- KURL& getDocumentURL ()
- KURL& getBaseURL ()
- int xOffset () const
- int yOffset () const
- bool gotoAnchor ()
- bool gotoAnchor ( const char *_name )
- bool gotoXY ( int _x_offset, int _y_offset )
- void autoScrollY ( int _delay, int _dy )
- void stopAutoScrollY ()
- bool isAutoScrollingY ()
- void setView ( KHTMLView *_view )
- KHTMLView* getView ()
- bool isFrameSet ()
- void setIsFrameSet ( bool _b )
- KHTMLView* getSelectedFrame ()
- bool isFrame ()
- void setIsFrame ( bool _frame)
- void setMarginWidth ( int _w )
- void setMarginHeight ( int _h )
- bool isSelected ()
- void setSelected ( bool _active )
- void setDefaultFontBase ( int size )
- void setFontSizes (const int *newFontSizes)
- void getFontSizes (int *newFontSizes)
- void resetFontSizes ( void )
- void setStandardFont ( const char *name )
- void setFixedFont ( const char *name )
- void setDefaultBGColor ( const QColor &col )
- void setDefaultTextColors ( const QColor &normal, const QColor &link, const QColor &vlink )
- void setUnderlineLinks ( bool ul )
- void setURLCursor ( const QCursor &c )
- void setForceDefault ( bool force )
- void setGranularity ( int g )
- void requestFile ( HTMLObject *_obj, const char *_url )
- void cancelRequestFile ( HTMLObject *_obj )
- void cancelAllRequests ()
- void requestBackgroundImage ( const char *_url )
- void paintSingleObject ( HTMLObject *_obj )
- void paint ( HTMLChain *_chain, int x, int y, int w, int h )
- void paint ( HTMLCellInfo * )
- void scheduleUpdate ( bool clear )
- void calcAbsolutePos ()
- HTMLMap* getMap ( const char *mapurl )
- static void registerFormats ()
- JSEnvironment* getJSEnvironment ()
- JSWindowObject* getJSWindowObject ()
- QList<KHTMLWidget>* getFrameList ()
- bool setCharset (const char *name)
- void setOverrideCharset (const char *name = 0)
- bool setMarker ( const char *_url )
- bool selectFromMarker ( const char *_url )
- bool cellDown ( bool select )
- bool cellUp ( bool select )
- bool cellLeft ( bool select )
- bool cellRight ( bool select )
- void cellSelected ()
- void cellActivated ()
- void cellContextMenu ()
- void cellSequenceChanged ()
- void resetCurrentKeySeq ()
- void data ( const char *_url, const char *_data, int _len, bool _eof )
- SavedPage* saveYourself (SavedPage *p = 0)
- void restore (SavedPage *)
- void restorePosition ( int x, int y )
- enum ListNumType { Numeric = 0, LowAlpha, UpAlpha, LowRoman, UpRoman }
- enum ListType { Unordered, UnorderedPlain, Ordered, Menu, Dir }
- void drawBackground ( int _xval, int _yval, int _x, int _y, int _w, int _h, QPainter *p = 0 )
Public Slots
Protected Members
- void buildFrameSet (SavedPage *p, QString *s)
- void buildFrameTree (SavedPage *p, HTMLFrameSet *f)
- int initialXPos
- int initialYPos
- virtual void mousePressEvent ( QMouseEvent * )
- virtual void mouseMoveEvent ( QMouseEvent * )
- void setBlob (QPoint pos)
- void clearBlob ()
- virtual void mouseDoubleClickEvent ( QMouseEvent * )
- virtual void dndMouseMoveEvent ( QMouseEvent * _mouse )
- virtual void dndMouseReleaseEvent ( QMouseEvent * )
- virtual void dragEndEvent ()
- virtual bool URLVisited ( const char *_url )
- virtual void paintEvent ( QPaintEvent * )
- virtual void resizeEvent ( QResizeEvent * )
- virtual void keyPressEvent ( QKeyEvent * )
- virtual void timerEvent ( QTimerEvent * )
- virtual void setPalette ( const QPalette & )
- virtual void focusInEvent ( QFocusEvent * )
- virtual void focusOutEvent ( QFocusEvent * )
- void flushKeys ()
- void closeAnchor ()
- void newFlow (HTMLClue *_clue)
- void insertText (char *str, const HTMLFont * fp)
- const char* parseBody ( HTMLClueV *_clue, const char *[], bool toplevel = FALSE )
- const char* parseOneToken ( HTMLClueV *_clue, const char *str )
- void parseA ( HTMLClueV *_clue, const char *str )
- void parseB ( HTMLClueV *_clue, const char *str )
- void parseC ( HTMLClueV *_clue, const char *str )
- void parseD ( HTMLClueV *_clue, const char *str )
- void parseE ( HTMLClueV *_clue, const char *str )
- void parseF ( HTMLClueV *_clue, const char *str )
- void parseG ( HTMLClueV *_clue, const char *str )
- void parseH ( HTMLClueV *_clue, const char *str )
- void parseI ( HTMLClueV *_clue, const char *str )
- void parseJ ( HTMLClueV *_clue, const char *str )
- void parseK ( HTMLClueV *_clue, const char *str )
- void parseL ( HTMLClueV *_clue, const char *str )
- void parseM ( HTMLClueV *_clue, const char *str )
- void parseN ( HTMLClueV *_clue, const char *str )
- void parseO ( HTMLClueV *_clue, const char *str )
- void parseP ( HTMLClueV *_clue, const char *str )
- void parseQ ( HTMLClueV *_clue, const char *str )
- void parseR ( HTMLClueV *_clue, const char *str )
- void parseS ( HTMLClueV *_clue, const char *str )
- void parseT ( HTMLClueV *_clue, const char *str )
- void parseU ( HTMLClueV *_clue, const char *str )
- void parseV ( HTMLClueV *_clue, const char *str )
- void parseW ( HTMLClueV *_clue, const char *str )
- void parseX ( HTMLClueV *_clue, const char *str )
- void parseY ( HTMLClueV *_clue, const char *str )
- void parseZ ( HTMLClueV *_clue, const char *str )
- const char* parseCell ( HTMLClue *_clue, const char *attr )
- const char* parseTable ( HTMLClue *_clue, int _max_width, const char * )
- const char* parseInput ( const char * )
- bool insertVSpace ( HTMLClueV *_clue, bool _space_inserted )
- void positionFormElements ()
- QString currentKeySeq
- QString title
- char *url
- char *target
- QString overURL
- QString reference
- QString overrideCharset
- QPainter *painter
- HTMLClueV *clue
- int autoScrollDY
- int autoScrollYDelay
- QTimer autoScrollYTimer
- QTimer updateTimer
- HTMLTokenizer *ht
- int memPoolMax
- StringTokenizer *stringTok
- void selectFont ( int _relative_font_size )
- void selectFont ()
- void selectFont ( const char *_fontfamily, int _size, int _weight, bool _italic )
- void popFont ()
- const HTMLFont* currentFont ()
- void popColor ()
- int weight
- bool italic
- bool underline
- bool strikeOut
- bool pressed
- QString pressedURL
- QString pressedTarget
- QPixmap dndDefaultPixmap
- QPoint selectPt1
- QPoint selectPt2
- bool bIsTextSelected
- KURL actualURL
- KURL baseURL
- void setBaseURL ( const char *_url)
- QString baseTarget
- int colorContext
- class HTMLStackElem
- typedef void (KHTMLWidget::*blockFunc)
- HTMLStackElem *blockStack
- void pushBlock ( int _id, int _level, blockFunc _exitFunc = 0,
int _miscData1 = 0,
int _miscData2 = 0)
- void popBlock ( int _id, HTMLClueV *_clue)
- void freeBlock ( void)
- void blockEndFont (HTMLClueV *_clue, HTMLStackElem *stackElem)
- void blockEndPre (HTMLClueV *_clue, HTMLStackElem *stackElem)
- void blockEndColorFont (HTMLClueV *_clue, HTMLStackElem *stackElem)
- void blockEndIndent (HTMLClueV *_clue, HTMLStackElem *stackElem)
- void blockEndList (HTMLClueV *_clue, HTMLStackElem *stackElem)
- void blockEndDiv ( HTMLClueV *_clue, HTMLStackElem *Elem)
- int timerId
- bool writing
- bool parsing
- bool bodyParsed
- int indent
- enum GlossaryEntry { GlossaryDL, GlossaryDD }
- HTMLClue::HAlign divAlign
- int parseCount
- int granularity
- bool vspace_inserted
- HTMLClue *flow
- QStrList tempStrings
- QStrList parsedURLs
- QStrList parsedTargets
- QPixmap bgPixmap
- QCursor linkCursor
- HTMLSettings *settings
- HTMLSettings *defaultSettings
- bool bDrawBackground
- QString bgPixmapURL
- bool inTitle
- HTMLForm *form
- HTMLSelect *formSelect
- bool inOption
- HTMLTextArea *formTextArea
- bool inTextArea
- bool inPre
- QString formText
- HTMLFrameSet *frameSet
- bool bIsFrameSet
- bool bIsFrame
- bool bFramesComplete
- bool bInNoframes
- KHTMLView *htmlView
- KHTMLView *selectedFrame
- bool bIsSelected
- int leftBorder
- int rightBorder
- int topBorder
- int bottomBorder
- JSEnvironment *jsEnvironment
- KCharsetConverter *charsetConverter
- HTMLIterator *textFindIter
- QPixmap scrollBlobPixmap
- QWidget *scrollBlob
- QTimer *scrollBlobTimer
- enum ScrollType scrollBlobType
Protected Slots
Signals
- void setTitle ( const char * )
- void goUp ()
- void goLeft ()
- void goRight ()
- void doubleClick ( const char * _url, int _button)
- void scrollVert ( int _y )
- void scrollHorz ( int _x )
- void URLSelected ( const char *_url, int _button )
- void URLSelected ( const char *_url, int _button, const char *_target )
- void onURL ( const char *_url )
- void textSelected ( bool _selected )
- void documentChanged ()
- void documentStarted ()
- void documentDone ()
- void popupMenu ( const char *_url, const QPoint & )
- void mousePressed ( const char *_url, const char *_target, QMouseEvent *_ev )
- void fileRequest ( const char *_url )
- void cancelFileRequest ( const char *_url )
- void formSubmitted ( const char *_method, const char *_url, const char *_data )
- void resized ( const QSize &size )
- void redirect ( int delay, const char * url )
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 ) [public]
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.
- 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.
Note: pixdir should not be used - it is provided only for backward
compatability and has no effect.
|
void begin( const char *_url = 0L, int _x_offset = 0, int _y_offset = 0 ) [public]
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 * ) [public]
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() [public]
Call this after your last call to write
void parse() [public]
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.
Stop parsing the HTML immediately.
void print() [public]
Print current HTML page to the printer.
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 ) [public virtual]
Selects all objects which refer to _url. All selected ojects
are redrawn if they changed their selection mode.
void select( QPainter *_painter, bool _select ) [public virtual]
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 ) [public virtual]
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 ) [public virtual]
Select all objects with a URL matching the regular expression.
If _painter is null a new painter is created.
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 ) [public virtual]
Selects all text between ( _x1, _y1 ) and ( _x2, y2 ). The selection
area selects text line by line, NOT by bounding rectangle.
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.
|
Has the user selected any text? Call getSelectedText to
retrieve the selected text.
- Returns:
-
true if there is text selected.
Initiate a text search.
Find the next occurrance of the expression.
end a text search.
const char* getURL( QPoint &_point ) [public]
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.
|
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 ) [public]
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 ) [public]
Jumps to position _x_offset, _y_offset.
Returns TRUE if the position was available
void autoScrollY( int _delay, int _dy ) [public]
Causes the widget contents to scroll automatically. Call
stopAutoScrollY to stop. Stops automatically when the
top or bottom of the document is reached.
- Parameters:
-
_dy |
The amount to scroll the document when _delay elapses. |
_delay |
Time in milliseconds to wait before scrolling the document again.
|
Stops the document from autoScrollY ing.
Returns if the widget is currently auto scrolling.
If this widget belongs to a HTMLView then this function
is used to tell the widget about its owner.
- See Also:
- htmlView, getView
- Returns:
-
the KHTMLView this widget belongs to.
- See Also:
- setView
Tells this widget that it displays a frameset.
For internal use only.
HTMLFrameSet instances are asked.
- 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
void setIsFrame( bool _frame) [public]
Tell the widget wether it is a frame or not.
For internal use only.
- See Also:
- isFrame
Sets the margin width in pixels. This function is used to implement the
<frame marginwidth=... > tag.
It is called from KHTMLView and is for INTERNAL USE ONLY.
- See Also:
- leftBorder, rightBorder, KHTMLView::setMarginWidth
Sets the margin height in pixels. This function is used
to implement the
<frame marginheight=... > tag.
It is called from KHTMLView and is for INTERNAL USE ONLY.
- See Also:
- topBorder, bottomBorder, KHTMLView::setMarginHeight
- Returns:
-
if the user selected this widget.
- See Also:
- bIsSelected, setSelected
void setSelected( bool _active ) [public]
Switches the 'selected state' of this widget. This results in the
drawing or deleting of the black border around the widget.
- See Also:
- isSelected
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 ) [public]
Sets the standard font style.
- Parameters:
-
name |
is the font name to use for standard text. |
void setFixedFont( const char *name ) [public]
Sets the fixed font style.
- Parameters:
-
name |
is the font name to use for fixed text, e.g. the <pre> tag.
|
Sets the default background color to use when one isn't specified
explicitly by <body bgcolor=...>
Sets the default text colors.
Set whether links are drawn in underlined text.
Sets the cursor to use when the cursor is on a link.
Force use of user defined colors
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.
Internal use - calculates the absolute position of the objects.
- 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
A convenience function to access the JSWindowObject of this html
widget.
- See Also:
- KHTMLWidget::getJSEvironment
- Returns:
-
a list of all frames.
- See Also:
- KHTMLWidget::frameList
bool setCharset(const char *name) [public]
Set document charset.
Any setting charsets overrides this setting
- Returns:
-
TRUE if successfull
set a charset, which will override the setting
void slotScrollVert( int _y ) [public slot]
Scrolls the document to _y.
This is usually connected to a scrollbar.
void slotScrollHorz( int _x ) [public slot]
Scrolls the document to _x.
This is usually connected to a scrollbar.
void slotFileLoaded( const char *_url, const char *_filename ) [public slot]
Call when a file requested by fileRequest has been loaded.
- Parameters:
-
_filename |
is the name of the file that has been stored on the local filesystem.
|
_url |
is the URL of the file that was requested. |
This function emits the 'doubleClick' signal when the user
double clicks a <a href=...> tag.
Overload this method if you dont want any drag actions.
This function emits the 'URLSelected' signal when the user
pressed a <a href=...> tag.
bool URLVisited( const char *_url ) [protected 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.
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
Keeps a list of all pending file.
void setTitle( const char * ) [signal]
This signal is emitted whenever the Widget wants to
change the window's title. Usually this is the text
enclosed in <title>....</title>.
void goUp() [signal]
The user pressed ALT + Up
void goLeft() [signal]
The user pressed ALT + Left
void goRight() [signal]
The user pressed ALT + Right
void doubleClick( const char * _url, int _button) [signal]
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 ) [signal]
Tells the parent, that the widget has scrolled. This may happen if
the user selects an <a href="#anchor">.
void scrollHorz( int _x ) [signal]
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 ) [signal]
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 ) [signal]
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 ) [signal]
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]
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.
|
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.
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
This signal is emitted when document is finished parsing
and all required images arrived.
- See Also:
- documentStarted
void popupMenu( const char *_url, const QPoint & ) [signal]
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 ) [signal]
This signal is emitted if the user presses the mouse. If he clicks on
a link you get the URL in '_url'.
- Parameters:
-
_ev |
the QMouseEvent |
_url |
is the clicked URL or null is there was none. |
_target |
is the target frame if one is mentioned otherwise 0L. |
void fileRequest( const char *_url ) [signal]
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 ) [signal]
used for url redirection
Documentation generated by root@darkstar.lst.de on Wed Sep 8 17:38:46 CEST 1999
|
Kdoc
|