khtmlview.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef KHTML_H
00026 #define KHTML_H
00027
00028
00029 #include <qscrollview.h>
00030
00031 class QPainter;
00032 class QRect;
00033
00034 namespace DOM {
00035 class HTMLDocumentImpl;
00036 class DocumentImpl;
00037 class ElementImpl;
00038 class HTMLElementImpl;
00039 class HTMLTitleElementImpl;
00040 class HTMLGenericFormElementImpl;
00041 class HTMLFormElementImpl;
00042 class HTMLAnchorElementImpl;
00043 class HTMLInputElementImpl;
00044 class Range;
00045 class NodeImpl;
00046 class CSSProperty;
00047 }
00048
00049 namespace KJS {
00050 class WindowFunc;
00051 class ExternalFunc;
00052 }
00053
00054 namespace khtml {
00055 class RenderObject;
00056 class RenderCanvas;
00057 class RenderStyle;
00058 class RenderLineEdit;
00059 class RenderPartObject;
00060 class RenderWidget;
00061 class CSSStyleSelector;
00062 class LineEditWidget;
00063 class CaretBox;
00064 void applyRule(DOM::CSSProperty *prop);
00065 }
00066
00067 class KHTMLPart;
00068 class KHTMLViewPrivate;
00069
00075 class KHTMLView : public QScrollView
00076 {
00077 Q_OBJECT
00078
00079 friend class DOM::HTMLDocumentImpl;
00080 friend class DOM::HTMLTitleElementImpl;
00081 friend class DOM::HTMLGenericFormElementImpl;
00082 friend class DOM::HTMLFormElementImpl;
00083 friend class DOM::HTMLAnchorElementImpl;
00084 friend class DOM::HTMLInputElementImpl;
00085 friend class DOM::DocumentImpl;
00086 friend class KHTMLPart;
00087 friend class khtml::RenderCanvas;
00088 friend class khtml::RenderObject;
00089 friend class khtml::RenderLineEdit;
00090 friend class khtml::RenderPartObject;
00091 friend class khtml::RenderWidget;
00092 friend class khtml::CSSStyleSelector;
00093 friend class khtml::LineEditWidget;
00094 friend class KJS::WindowFunc;
00095 friend class KJS::ExternalFunc;
00096 friend void khtml::applyRule(DOM::CSSProperty *prop);
00097
00098
00099 public:
00103 KHTMLView( KHTMLPart *part, QWidget *parent, const char *name=0 );
00104 virtual ~KHTMLView();
00105
00110 KHTMLPart *part() const { return m_part; }
00111
00112 int frameWidth() const { return _width; }
00113
00117 void setMarginWidth(int x);
00118
00124 int marginWidth() const { return _marginWidth; }
00125
00126
00127
00128
00129 void setMarginHeight(int y);
00130
00136 int marginHeight() { return _marginHeight; }
00137
00141 virtual void setVScrollBarMode ( ScrollBarMode mode );
00142
00146 virtual void setHScrollBarMode ( ScrollBarMode mode );
00147
00151 void print();
00152
00157 void print( bool quick );
00158
00162 void layout();
00166 void displayAccessKeys();
00167
00168
00169
00170 signals:
00171 void finishedLayout();
00172 void cleared();
00173 void zoomView( int );
00174 void hideAccessKeys();
00175 void repaintAccessKeys();
00176
00177 protected:
00178 void clear();
00179
00180 virtual void resizeEvent ( QResizeEvent * event );
00181 virtual void showEvent ( QShowEvent * );
00182 virtual void hideEvent ( QHideEvent *);
00183 virtual bool focusNextPrevChild( bool next );
00184 virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
00185 virtual void drawContents( QPainter* );
00186 virtual void viewportMousePressEvent( QMouseEvent * );
00187 virtual void focusInEvent( QFocusEvent * );
00188 virtual void focusOutEvent( QFocusEvent * );
00189 virtual void viewportMouseDoubleClickEvent( QMouseEvent * );
00190 virtual void viewportMouseMoveEvent(QMouseEvent *);
00191 virtual void viewportMouseReleaseEvent(QMouseEvent *);
00192 virtual void viewportResizeEvent(QResizeEvent*);
00193 #ifndef QT_NO_WHEELEVENT
00194 virtual void viewportWheelEvent(QWheelEvent*);
00195 #endif
00196 virtual void dragEnterEvent( QDragEnterEvent* );
00197 virtual void dropEvent( QDropEvent* );
00198 virtual void closeEvent ( QCloseEvent * );
00199 virtual bool eventFilter(QObject *, QEvent *);
00200
00201 void keyPressEvent( QKeyEvent *_ke );
00202 void keyReleaseEvent ( QKeyEvent *_ke );
00203 void contentsContextMenuEvent ( QContextMenuEvent *_ce );
00204 void doAutoScroll();
00205 void timerEvent ( QTimerEvent * );
00206
00207 protected slots:
00208 void slotPaletteChanged();
00209 void slotScrollBarMoved();
00210
00211 private slots:
00212 void tripleClickTimeout();
00213 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00214 void findTimeout();
00215 #endif // KHTML_NO_TYPE_AHEAD_FIND
00216 void accessKeysTimeout();
00217
00218 private:
00219
00220 void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00221 void unscheduleRelayout();
00222
00223 void scheduleRepaint(int x, int y, int w, int h);
00224 void unscheduleRepaint();
00225
00226 void closeChildDialogs();
00227 bool dialogsAllowed();
00228
00237 void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
00238
00249 void setMediaType( const QString &medium );
00250 QString mediaType() const;
00251
00252 bool scrollTo(const QRect &);
00253
00254 bool focusNextPrevNode(bool next);
00255 bool handleAccessKey(const QKeyEvent* ev);
00256 bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
00257
00258 void useSlowRepaints();
00259
00260 void setIgnoreWheelEvents(bool e);
00261
00262 void init();
00263
00264 DOM::NodeImpl *nodeUnderMouse() const;
00265 DOM::NodeImpl *nonSharedNodeUnderMouse() const;
00266
00267 void restoreScrollBar();
00268
00269 QStringList formCompletionItems(const QString &name) const;
00270 void clearCompletionHistory(const QString& name);
00271 void addFormCompletionItem(const QString &name, const QString &value);
00272
00273 void addNonPasswordStorableSite( const QString& host );
00274 bool nonPasswordStorableSite( const QString& host ) const;
00275
00276 bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
00277 DOM::NodeImpl *targetNodeNonShared, bool cancelable,
00278 int detail,QMouseEvent *_mouse, bool setUnder,
00279 int mouseEventType);
00280 bool dispatchKeyEvent( QKeyEvent *_ke );
00281 bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
00282
00283 void complete();
00284
00285 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00286 void findAhead(bool increase);
00287 #endif
00288
00289 #ifndef KHTML_NO_CARET
00290
00291
00302 void initCaret(bool keepSelection = false);
00305 bool caretOverrides() const;
00313 void ensureNodeHasFocus(DOM::NodeImpl *node);
00320 void recalcAndStoreCaretPos(khtml::CaretBox *hintBox = 0);
00327 void caretOn();
00333 void caretOff();
00342 void showCaret(bool forceRepaint = false);
00349 void hideCaret();
00354 void ensureCaretVisible();
00355
00371 bool foldSelectionToCaret(DOM::NodeImpl *startNode, long startOffset,
00372 DOM::NodeImpl *endNode, long endOffset);
00373
00383 bool placeCaret(khtml::CaretBox *hintBox = 0);
00384
00401 bool extendSelection(DOM::NodeImpl *startNode, long startOffset,
00402 DOM::NodeImpl *endNode, long endOffset);
00403
00413 void updateSelection(DOM::NodeImpl *startNode, long startOffset,
00414 DOM::NodeImpl *endNode, long endOffset);
00415
00420 int caretDisplayPolicyNonFocused() const;
00421
00428 void setCaretDisplayPolicyNonFocused(int policy);
00429
00430
00431
00435 void caretKeyPressEvent(QKeyEvent *);
00436
00437
00438
00450 bool moveCaretTo(DOM::NodeImpl *node, long offset, bool clearSelection);
00451
00457 enum CaretMovement { CaretByCharacter, CaretByWord };
00458
00469 void moveCaretBy(bool next, CaretMovement cmv, int n);
00470
00473 void moveCaretByLine(bool next, int n);
00474
00479 void moveCaretToLineBoundary(bool end);
00480
00485 void moveCaretToDocumentBoundary(bool end);
00486
00495 void placeCaretOnChar(khtml::CaretBox *hintBox);
00496
00513 void placeCaretOnLine(khtml::CaretBox *caretBox, int x, int absx, int absy);
00514
00518 void moveCaretByPage(bool next);
00519
00522 void moveCaretPrevWord();
00523
00526 void moveCaretNextWord();
00527
00532 void moveCaretPrevLine(int n = 1);
00533
00538 void moveCaretNextLine(int n = 1);
00539
00542 void moveCaretPrevPage();
00543
00546 void moveCaretNextPage();
00547
00550 void moveCaretToLineBegin();
00551
00554 void moveCaretToLineEnd();
00555
00556 #endif // KHTML_NO_CARET
00557
00558
00559 private:
00560
00561 void setWidgetVisible(::khtml::RenderWidget*, bool visible);
00562
00563 int _width;
00564 int _height;
00565
00566 int _marginWidth;
00567 int _marginHeight;
00568
00569 KHTMLPart *m_part;
00570 KHTMLViewPrivate *d;
00571
00572 QString m_medium;
00573 };
00574
00575 #endif
00576
This file is part of the documentation for khtml Library Version 3.3.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Sep 23 17:13:18 2004 by
doxygen 1.3.8-20040913 written by
Dimitri van Heesch, © 1997-2003