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 StorePass;
00107 friend class khtml::RenderCanvas;
00108 friend class khtml::RenderObject;
00109 friend class khtml::RenderLineEdit;
00110 friend class khtml::RenderPartObject;
00111 friend class khtml::RenderWidget;
00112 friend class khtml::KHTMLWidgetPrivate;
00113 friend class khtml::RenderLayer;
00114 friend class khtml::RenderBox;
00115 friend class khtml::CSSStyleSelector;
00116 friend class khtml::LineEditWidget;
00117 friend class KJS::WindowFunc;
00118 friend class KJS::ExternalFunc;
00119 friend void khtml::applyRule(DOM::CSSProperty *prop);
00120
00121
00122 public:
00126 KHTMLView( KHTMLPart *part, QWidget *parent );
00127 virtual ~KHTMLView();
00128
00133 KHTMLPart *part() const { return m_part; }
00134
00135 int frameWidth() const { return _width; }
00136
00140 void setMarginWidth(int x);
00141
00147 int marginWidth() const { return _marginWidth; }
00148
00149
00150
00151
00152 void setMarginHeight(int y);
00153
00159 int marginHeight() { return _marginHeight; }
00160
00168 virtual void setVerticalScrollBarPolicy( Qt::ScrollBarPolicy policy );
00169
00177 virtual void setHorizontalScrollBarPolicy( Qt::ScrollBarPolicy policy );
00178
00183 void print( bool quick = false );
00184
00188 void displayAccessKeys();
00189
00193 int contentsWidth() const;
00194
00198 int contentsHeight() const;
00199
00204 int contentsX() const;
00205
00210 int contentsY() const;
00211
00215 int visibleWidth() const;
00216
00220 int visibleHeight() const;
00221
00226 void setContentsPos(int x, int y);
00227
00233 QPoint contentsToViewport(const QPoint& p) const;
00234
00240 QPoint viewportToContents(const QPoint& p) const;
00241
00250 void viewportToContents(int x, int y, int& cx, int& cy) const;
00251
00260 void contentsToViewport(int x, int y, int& cx, int& cy) const;
00261
00267 void scrollBy(int x, int y);
00268
00273 void updateContents( const QRect& r );
00274 void updateContents(int x, int y, int w, int h);
00275
00276 void addChild(QWidget *child, int dx, int dy);
00277
00282 void repaintContents( const QRect& r );
00283 void repaintContents(int x, int y, int w, int h);
00284
00289 void setZoomLevel( int percent );
00290
00295 int zoomLevel() const;
00296
00303 enum SmoothScrollingMode { SSMDisabled = 0, SSMWhenEfficient, SSMEnabled };
00304
00313 void setSmoothScrollingMode( SmoothScrollingMode m );
00314
00320 SmoothScrollingMode smoothScrollingMode() const;
00321
00322 public Q_SLOTS:
00328 virtual void resizeContents(int w, int h);
00329
00333 void layout();
00334
00335
00336 Q_SIGNALS:
00341 void finishedLayout();
00342 void cleared();
00343 void zoomView( int );
00344 void hideAccessKeys();
00345 void repaintAccessKeys();
00346 void findAheadActive( bool );
00347
00348 protected:
00349 void clear();
00350
00351 virtual bool event ( QEvent * event );
00352 virtual void paintEvent( QPaintEvent * );
00353 virtual void resizeEvent ( QResizeEvent * event );
00354 virtual void showEvent ( QShowEvent * );
00355 virtual void hideEvent ( QHideEvent *);
00356 virtual bool focusNextPrevChild( bool next );
00357 virtual void mousePressEvent( QMouseEvent * );
00358 virtual void focusInEvent( QFocusEvent * );
00359 virtual void focusOutEvent( QFocusEvent * );
00360 virtual void mouseDoubleClickEvent( QMouseEvent * );
00361 virtual void mouseMoveEvent(QMouseEvent *);
00362 virtual void mouseReleaseEvent(QMouseEvent *);
00363 #ifndef QT_NO_WHEELEVENT
00364 virtual void wheelEvent(QWheelEvent*);
00365 #endif
00366 virtual void dragEnterEvent( QDragEnterEvent* );
00367 virtual void dropEvent( QDropEvent* );
00368 virtual void closeEvent ( QCloseEvent * );
00369 virtual bool widgetEvent( QEvent * );
00370 virtual bool viewportEvent( QEvent * e );
00371 virtual bool eventFilter(QObject *, QEvent *);
00372 virtual void scrollContentsBy( int dx, int dy );
00373
00374 void keyPressEvent( QKeyEvent *_ke );
00375 void keyReleaseEvent ( QKeyEvent *_ke );
00376 void doAutoScroll();
00377 void timerEvent ( QTimerEvent * );
00378
00379 void setSmoothScrollingModeDefault( SmoothScrollingMode m );
00380
00381 protected Q_SLOTS:
00382 void slotPaletteChanged();
00383
00384 private Q_SLOTS:
00385 void tripleClickTimeout();
00386 void findTimeout();
00387 void accessKeysTimeout();
00388 void scrollTick();
00389
00394 void slotMouseScrollTimer();
00395
00396 private:
00397 void resizeContentsToViewport();
00398
00399 void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00400 void unscheduleRelayout();
00401
00402 void scheduleRepaint(int x, int y, int w, int h, bool asap=false);
00403 void unscheduleRepaint();
00404
00405 bool needsFullRepaint() const;
00406
00407 void closeChildDialogs();
00408 bool dialogsAllowed();
00409
00410 void setMouseEventsTarget( QWidget* w );
00411 QWidget* mouseEventsTarget() const;
00412
00413 QStack<QRegion>* clipHolder() const;
00414 void setClipHolder( QStack<QRegion>* ch );
00415
00416 void setPart(KHTMLPart *part);
00417
00426 void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
00427
00428 void render(QPainter *p, const QRect& r, const QPoint& off);
00429
00440 void setMediaType( const QString &medium );
00441 QString mediaType() const;
00442
00443 bool pagedMode() const;
00444
00445 bool scrollTo(const QRect &);
00446
00447 bool focusNextPrevNode(bool next);
00448 bool handleAccessKey(const QKeyEvent* ev);
00449 bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
00450 QMap< DOM::ElementImpl*, QChar > buildFallbackAccessKeys() const;
00451 void displayAccessKeys( KHTMLView* caller, KHTMLView* origview, QVector< QChar >& taken, bool use_fallbacks );
00452 bool isScrollingFromMouseWheel() const;
00453 void setHasStaticBackground(bool partial=false);
00454 void setHasNormalBackground();
00455 void addStaticObject(bool fixed);
00456 void removeStaticObject(bool fixed);
00457 void applyTransforms( int& x, int& y, int& w, int& h) const;
00458 void revertTransforms( int& x, int& y, int& w, int& h) const;
00459 void revertTransforms( int& x, int& y ) const;
00460 void checkExternalWidgetsPosition();
00461
00462 void setIgnoreWheelEvents(bool e);
00463
00464 void init();
00465
00466 DOM::NodeImpl *nodeUnderMouse() const;
00467 DOM::NodeImpl *nonSharedNodeUnderMouse() const;
00468
00469 void restoreScrollBar();
00470
00471 QStringList formCompletionItems(const QString &name) const;
00472 void clearCompletionHistory(const QString& name);
00473 void addFormCompletionItem(const QString &name, const QString &value);
00474
00475 void addNonPasswordStorableSite( const QString& host );
00476 void delNonPasswordStorableSite( const QString& host );
00477 bool nonPasswordStorableSite( const QString& host ) const;
00478
00479 bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
00480 DOM::NodeImpl *targetNodeNonShared, bool cancelable,
00481 int detail,QMouseEvent *_mouse, bool setUnder,
00482 int mouseEventType, int orientation=0);
00483 bool dispatchKeyEvent( QKeyEvent *_ke );
00484 bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
00485
00486 void complete( bool pendingAction );
00487
00488 void updateScrollBars();
00489 void setupSmoothScrolling(int dx, int dy);
00490
00491 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00492 void findAhead(bool increase);
00493 void updateFindAheadTimeout();
00494 void startFindAhead( bool linksOnly );
00495 #endif // KHTML_NO_TYPE_AHEAD_FIND
00496
00501 int caretDisplayPolicyNonFocused() const;
00502
00508 void setCaretDisplayPolicyNonFocused(int policy);
00509
00510
00511
00516 bool caretKeyPressEvent(QKeyEvent *);
00517
00518
00519 private:
00520 friend class KHTMLViewPrivate;
00521 enum LinkCursor { LINK_NORMAL, LINK_MAILTO, LINK_NEWWINDOW };
00522
00523 void setWidgetVisible(::khtml::RenderWidget*, bool visible);
00524
00525
00526 int _width;
00527 int _height;
00528
00529 int _marginWidth;
00530 int _marginHeight;
00531
00532 KHTMLPart *m_part;
00533 KHTMLViewPrivate* const d;
00534
00535 QString m_medium;
00536 };
00537
00538 #endif
00539