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
00026 #ifndef KHTMLVIEW_H
00027 #define KHTMLVIEW_H
00028
00029 #include <khtml_export.h>
00030
00031
00032 #include <QtGui/QScrollArea>
00033
00034 class QPainter;
00035 class QRect;
00036 template< typename T > class QVector;
00037 template <class T> class QStack;
00038
00039 namespace DOM {
00040 class HTMLDocumentImpl;
00041 class DocumentImpl;
00042 class ElementImpl;
00043 class HTMLTitleElementImpl;
00044 class HTMLGenericFormElementImpl;
00045 class HTMLFormElementImpl;
00046 class HTMLAnchorElementImpl;
00047 class HTMLInputElementImpl;
00048 class NodeImpl;
00049 class CSSProperty;
00050 }
00051
00052 namespace KJS {
00053 class WindowFunc;
00054 class ExternalFunc;
00055 }
00056
00057 namespace khtml {
00058 class RenderObject;
00059 class RenderCanvas;
00060 class RenderLineEdit;
00061 class RenderPartObject;
00062 class RenderWidget;
00063 class RenderLayer;
00064 class RenderBox;
00065 class CSSStyleSelector;
00066 class LineEditWidget;
00067 class CaretBox;
00068 class KHTMLWidgetPrivate;
00069 class KHTMLWidget
00070 {
00071 public:
00072 KHTMLWidget();
00073 ~KHTMLWidget();
00074 KHTMLWidgetPrivate* m_kwp;
00075 };
00076 void applyRule(DOM::CSSProperty *prop);
00077 }
00078
00079 class KHTMLPart;
00080 class KHTMLViewPrivate;
00081
00082 namespace khtml {
00083
00084 }
00085
00091 class KHTML_EXPORT KHTMLView : public QScrollArea, public khtml::KHTMLWidget
00092 {
00093 Q_OBJECT
00094
00095 friend class DOM::HTMLDocumentImpl;
00096 friend class DOM::HTMLTitleElementImpl;
00097 friend class DOM::HTMLGenericFormElementImpl;
00098 friend class DOM::HTMLFormElementImpl;
00099 friend class DOM::HTMLAnchorElementImpl;
00100 friend class DOM::HTMLInputElementImpl;
00101 friend class DOM::NodeImpl;
00102 friend class DOM::ElementImpl;
00103 friend class DOM::DocumentImpl;
00104 friend class KHTMLPart;
00105 friend class KHTMLFind;
00106 friend class khtml::RenderCanvas;
00107 friend class khtml::RenderObject;
00108 friend class khtml::RenderLineEdit;
00109 friend class khtml::RenderPartObject;
00110 friend class khtml::RenderWidget;
00111 friend class khtml::KHTMLWidgetPrivate;
00112 friend class khtml::RenderLayer;
00113 friend class khtml::RenderBox;
00114 friend class khtml::CSSStyleSelector;
00115 friend class khtml::LineEditWidget;
00116 friend class KJS::WindowFunc;
00117 friend class KJS::ExternalFunc;
00118 friend void khtml::applyRule(DOM::CSSProperty *prop);
00119
00120
00121 public:
00125 KHTMLView( KHTMLPart *part, QWidget *parent );
00126 virtual ~KHTMLView();
00127
00132 KHTMLPart *part() const { return m_part; }
00133
00134 int frameWidth() const { return _width; }
00135
00139 void setMarginWidth(int x);
00140
00146 int marginWidth() const { return _marginWidth; }
00147
00148
00149
00150
00151 void setMarginHeight(int y);
00152
00158 int marginHeight() { return _marginHeight; }
00159
00167 virtual void setVerticalScrollBarPolicy( Qt::ScrollBarPolicy policy );
00168
00176 virtual void setHorizontalScrollBarPolicy( Qt::ScrollBarPolicy policy );
00177
00182 void print( bool quick = false );
00183
00187 void displayAccessKeys();
00188
00192 int contentsWidth() const;
00193
00197 int contentsHeight() const;
00198
00203 int contentsX() const;
00204
00209 int contentsY() const;
00210
00214 int visibleWidth() const;
00215
00219 int visibleHeight() const;
00220
00225 void setContentsPos(int x, int y);
00226
00232 QPoint contentsToViewport(const QPoint& p) const;
00233
00239 QPoint viewportToContents(const QPoint& p) const;
00240
00249 void viewportToContents(int x, int y, int& cx, int& cy) const;
00250
00259 void contentsToViewport(int x, int y, int& cx, int& cy) const;
00260
00266 void scrollBy(int x, int y);
00267
00272 void updateContents( const QRect& r );
00273 void updateContents(int x, int y, int w, int h);
00274
00275 void addChild(QWidget *child, int dx, int dy);
00276
00281 void repaintContents( const QRect& r );
00282 void repaintContents(int x, int y, int w, int h);
00283
00288 void setZoomLevel( int percent );
00289
00294 int zoomLevel() const;
00295
00302 enum SmoothScrollingMode { SSMDisabled = 0, SSMWhenEfficient, SSMEnabled };
00303
00312 void setSmoothScrollingMode( SmoothScrollingMode m );
00313
00319 SmoothScrollingMode smoothScrollingMode() const;
00320
00321 public Q_SLOTS:
00327 virtual void resizeContents(int w, int h);
00328
00332 void layout();
00333
00334
00335 Q_SIGNALS:
00340 void finishedLayout();
00341 void cleared();
00342 void zoomView( int );
00343 void hideAccessKeys();
00344 void repaintAccessKeys();
00345 void findAheadActive( bool );
00346
00347 protected:
00348 void clear();
00349
00350 virtual bool event ( QEvent * event );
00351 virtual void paintEvent( QPaintEvent * );
00352 virtual void resizeEvent ( QResizeEvent * event );
00353 virtual void showEvent ( QShowEvent * );
00354 virtual void hideEvent ( QHideEvent *);
00355 virtual bool focusNextPrevChild( bool next );
00356 virtual void mousePressEvent( QMouseEvent * );
00357 virtual void focusInEvent( QFocusEvent * );
00358 virtual void focusOutEvent( QFocusEvent * );
00359 virtual void mouseDoubleClickEvent( QMouseEvent * );
00360 virtual void mouseMoveEvent(QMouseEvent *);
00361 virtual void mouseReleaseEvent(QMouseEvent *);
00362 #ifndef QT_NO_WHEELEVENT
00363 virtual void wheelEvent(QWheelEvent*);
00364 #endif
00365 virtual void dragEnterEvent( QDragEnterEvent* );
00366 virtual void dropEvent( QDropEvent* );
00367 virtual void closeEvent ( QCloseEvent * );
00368 virtual bool widgetEvent( QEvent * );
00369 virtual bool viewportEvent( QEvent * e );
00370 virtual bool eventFilter(QObject *, QEvent *);
00371 virtual void scrollContentsBy( int dx, int dy );
00372
00373 void keyPressEvent( QKeyEvent *_ke );
00374 void keyReleaseEvent ( QKeyEvent *_ke );
00375 void doAutoScroll();
00376 void timerEvent ( QTimerEvent * );
00377
00378 void setSmoothScrollingModeDefault( SmoothScrollingMode m );
00379
00380 protected Q_SLOTS:
00381 void slotPaletteChanged();
00382
00383 private Q_SLOTS:
00384 void tripleClickTimeout();
00385 void findTimeout();
00386 void accessKeysTimeout();
00387 void scrollTick();
00388
00393 void slotMouseScrollTimer();
00394
00395 private:
00396 void resizeContentsToViewport();
00397
00398 void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00399 void unscheduleRelayout();
00400
00401 void scheduleRepaint(int x, int y, int w, int h, bool asap=false);
00402 void unscheduleRepaint();
00403
00404 bool needsFullRepaint() const;
00405
00406 void closeChildDialogs();
00407 bool dialogsAllowed();
00408
00409 void setMouseEventsTarget( QWidget* w );
00410 QWidget* mouseEventsTarget() const;
00411
00412 QStack<QRegion>* clipHolder() const;
00413 void setClipHolder( QStack<QRegion>* ch );
00414
00415 void setPart(KHTMLPart *part);
00416
00425 void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
00426
00427 void render(QPainter *p, const QRect& r, const QPoint& off);
00428
00439 void setMediaType( const QString &medium );
00440 QString mediaType() const;
00441
00442 bool pagedMode() const;
00443
00444 bool scrollTo(const QRect &);
00445
00446 bool focusNextPrevNode(bool next);
00447 bool handleAccessKey(const QKeyEvent* ev);
00448 bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
00449 QMap< DOM::ElementImpl*, QChar > buildFallbackAccessKeys() const;
00450 void displayAccessKeys( KHTMLView* caller, KHTMLView* origview, QVector< QChar >& taken, bool use_fallbacks );
00451 bool isScrollingFromMouseWheel() const;
00452 void setHasStaticBackground(bool partial=false);
00453 void setHasNormalBackground();
00454 void addStaticObject(bool fixed);
00455 void removeStaticObject(bool fixed);
00456 void applyTransforms( int& x, int& y, int& w, int& h) const;
00457 void revertTransforms( int& x, int& y, int& w, int& h) const;
00458 void revertTransforms( int& x, int& y ) const;
00459 void checkExternalWidgetsPosition();
00460
00461 void setIgnoreWheelEvents(bool e);
00462
00463 void init();
00464
00465 DOM::NodeImpl *nodeUnderMouse() const;
00466 DOM::NodeImpl *nonSharedNodeUnderMouse() const;
00467
00468 void restoreScrollBar();
00469
00470 QStringList formCompletionItems(const QString &name) const;
00471 void clearCompletionHistory(const QString& name);
00472 void addFormCompletionItem(const QString &name, const QString &value);
00473
00474 void addNonPasswordStorableSite( const QString& host );
00475 bool nonPasswordStorableSite( const QString& host ) const;
00476
00477 bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
00478 DOM::NodeImpl *targetNodeNonShared, bool cancelable,
00479 int detail,QMouseEvent *_mouse, bool setUnder,
00480 int mouseEventType, int orientation=0);
00481 bool dispatchKeyEvent( QKeyEvent *_ke );
00482 bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
00483
00484 void complete( bool pendingAction );
00485
00486 void updateScrollBars();
00487 void setupSmoothScrolling(int dx, int dy);
00488
00489 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00490 void findAhead(bool increase);
00491 void updateFindAheadTimeout();
00492 void startFindAhead( bool linksOnly );
00493 #endif // KHTML_NO_TYPE_AHEAD_FIND
00494
00499 int caretDisplayPolicyNonFocused() const;
00500
00506 void setCaretDisplayPolicyNonFocused(int policy);
00507
00508
00509
00514 bool caretKeyPressEvent(QKeyEvent *);
00515
00516
00517 private:
00518 friend class KHTMLViewPrivate;
00519 enum LinkCursor { LINK_NORMAL, LINK_MAILTO, LINK_NEWWINDOW };
00520
00521 void setWidgetVisible(::khtml::RenderWidget*, bool visible);
00522
00523
00524 int _width;
00525 int _height;
00526
00527 int _marginWidth;
00528 int _marginHeight;
00529
00530 KHTMLPart *m_part;
00531 KHTMLViewPrivate* const d;
00532
00533 QString m_medium;
00534 };
00535
00536 #endif
00537