KHTML
khtmlview.h
Go to the documentation of this file.
00001 /* This file is part of the KDE project 00002 00003 Copyright (C) 1997 Martin Jones (mjones@kde.org) 00004 (C) 1998 Waldo Bastian (bastian@kde.org) 00005 (C) 1998, 1999 Torben Weis (weis@kde.org) 00006 (C) 1999 Lars Knoll (knoll@kde.org) 00007 (C) 1999 Antti Koivisto (koivisto@kde.org) 00008 (C) 2006 Germain Garand (germain@ebooksfrance.org) 00009 00010 This library is free software; you can redistribute it and/or 00011 modify it under the terms of the GNU Library General Public 00012 License as published by the Free Software Foundation; either 00013 version 2 of the License, or (at your option) any later version. 00014 00015 This library is distributed in the hope that it will be useful, 00016 but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00018 Library General Public License for more details. 00019 00020 You should have received a copy of the GNU Library General Public License 00021 along with this library; see the file COPYING.LIB. If not, write to 00022 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00023 Boston, MA 02110-1301, USA. 00024 */ 00025 00026 #ifndef KHTMLVIEW_H 00027 #define KHTMLVIEW_H 00028 00029 #include <khtml_export.h> 00030 00031 // qt includes and classes 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 HTMLTokenizer; 00069 class KHTMLWidgetPrivate; 00070 class KHTMLWidget 00071 { 00072 public: 00073 KHTMLWidget(); 00074 ~KHTMLWidget(); 00075 KHTMLWidgetPrivate* m_kwp; 00076 }; 00077 void applyRule(DOM::CSSProperty *prop); 00078 } 00079 00080 class KHTMLPart; 00081 class KHTMLViewPrivate; 00082 00083 namespace khtml { 00084 00085 } 00086 00092 class KHTML_EXPORT KHTMLView : public QScrollArea, public khtml::KHTMLWidget 00093 { 00094 Q_OBJECT 00095 00096 friend class DOM::HTMLDocumentImpl; 00097 friend class DOM::HTMLTitleElementImpl; 00098 friend class DOM::HTMLGenericFormElementImpl; 00099 friend class DOM::HTMLFormElementImpl; 00100 friend class DOM::HTMLAnchorElementImpl; 00101 friend class DOM::HTMLInputElementImpl; 00102 friend class DOM::NodeImpl; 00103 friend class DOM::ElementImpl; 00104 friend class DOM::DocumentImpl; 00105 friend class KHTMLPart; 00106 friend class KHTMLFind; 00107 friend class StorePass; 00108 friend class khtml::RenderCanvas; 00109 friend class khtml::RenderObject; 00110 friend class khtml::RenderLineEdit; 00111 friend class khtml::RenderPartObject; 00112 friend class khtml::RenderWidget; 00113 friend class khtml::KHTMLWidgetPrivate; 00114 friend class khtml::RenderLayer; 00115 friend class khtml::RenderBox; 00116 friend class khtml::CSSStyleSelector; 00117 friend class khtml::LineEditWidget; 00118 friend class khtml::HTMLTokenizer; 00119 friend class KJS::WindowFunc; 00120 friend class KJS::ExternalFunc; 00121 friend void khtml::applyRule(DOM::CSSProperty *prop); 00122 00123 00124 public: 00128 KHTMLView( KHTMLPart *part, QWidget *parent ); 00129 virtual ~KHTMLView(); 00130 00135 KHTMLPart *part() const { return m_part; } 00136 00137 int frameWidth() const { return _width; } 00138 00142 void setMarginWidth(int x); 00143 00149 int marginWidth() const { return _marginWidth; } 00150 00151 /* 00152 * Sets a margin in y direction. 00153 */ 00154 void setMarginHeight(int y); 00155 00161 int marginHeight() { return _marginHeight; } 00162 00170 virtual void setVerticalScrollBarPolicy( Qt::ScrollBarPolicy policy ); 00171 00179 virtual void setHorizontalScrollBarPolicy( Qt::ScrollBarPolicy policy ); 00180 00185 void print( bool quick = false ); 00186 00190 void displayAccessKeys(); 00191 00195 int contentsWidth() const; 00196 00200 int contentsHeight() const; 00201 00206 int contentsX() const; 00207 00212 int contentsY() const; 00213 00217 int visibleWidth() const; 00218 00222 int visibleHeight() const; 00223 00228 void setContentsPos(int x, int y); 00229 00235 QPoint contentsToViewport(const QPoint& p) const; 00236 00242 QPoint viewportToContents(const QPoint& p) const; 00243 00252 void viewportToContents(int x, int y, int& cx, int& cy) const; 00253 00262 void contentsToViewport(int x, int y, int& cx, int& cy) const; 00263 00269 void scrollBy(int x, int y); 00270 00275 void updateContents( const QRect& r ); 00276 void updateContents(int x, int y, int w, int h); 00277 00278 void addChild(QWidget *child, int dx, int dy); 00279 00284 void repaintContents( const QRect& r ); 00285 void repaintContents(int x, int y, int w, int h); 00286 00291 void setZoomLevel( int percent ); 00292 00297 int zoomLevel() const; 00298 00305 enum SmoothScrollingMode { SSMDisabled = 0, SSMWhenEfficient, SSMEnabled }; 00306 00315 void setSmoothScrollingMode( SmoothScrollingMode m ); 00316 00322 SmoothScrollingMode smoothScrollingMode() const; 00323 00324 public Q_SLOTS: 00330 virtual void resizeContents(int w, int h); 00331 00335 void layout(); 00336 00337 00338 Q_SIGNALS: 00343 void finishedLayout(); 00344 void cleared(); 00345 void zoomView( int ); 00346 void hideAccessKeys(); 00347 void repaintAccessKeys(); 00348 void findAheadActive( bool ); 00349 00350 protected: 00351 void clear(); 00352 00353 virtual bool event ( QEvent * event ); 00354 virtual void paintEvent( QPaintEvent * ); 00355 virtual void resizeEvent ( QResizeEvent * event ); 00356 virtual void showEvent ( QShowEvent * ); 00357 virtual void hideEvent ( QHideEvent *); 00358 virtual bool focusNextPrevChild( bool next ); 00359 virtual void mousePressEvent( QMouseEvent * ); 00360 virtual void focusInEvent( QFocusEvent * ); 00361 virtual void focusOutEvent( QFocusEvent * ); 00362 virtual void mouseDoubleClickEvent( QMouseEvent * ); 00363 virtual void mouseMoveEvent(QMouseEvent *); 00364 virtual void mouseReleaseEvent(QMouseEvent *); 00365 #ifndef QT_NO_WHEELEVENT 00366 virtual void wheelEvent(QWheelEvent*); 00367 #endif 00368 virtual void dragEnterEvent( QDragEnterEvent* ); 00369 virtual void dropEvent( QDropEvent* ); 00370 virtual void closeEvent ( QCloseEvent * ); 00371 virtual bool widgetEvent( QEvent * ); 00372 virtual bool viewportEvent( QEvent * e ); 00373 virtual bool eventFilter(QObject *, QEvent *); 00374 virtual void scrollContentsBy( int dx, int dy ); 00375 00376 void keyPressEvent( QKeyEvent *_ke ); 00377 void keyReleaseEvent ( QKeyEvent *_ke ); 00378 void doAutoScroll(); 00379 void timerEvent ( QTimerEvent * ); 00380 00381 void setSmoothScrollingModeDefault( SmoothScrollingMode m ); 00382 00383 protected Q_SLOTS: 00384 void slotPaletteChanged(); 00385 00386 private Q_SLOTS: 00387 void tripleClickTimeout(); 00388 void accessKeysTimeout(); 00389 void scrollTick(); 00390 00395 void slotMouseScrollTimer(); 00396 00397 private: 00398 void resizeContentsToViewport(); 00399 00400 void scheduleRelayout(khtml::RenderObject* clippedObj=0); 00401 void unscheduleRelayout(); 00402 00403 bool hasLayoutPending(); 00404 00405 void scheduleRepaint(int x, int y, int w, int h, bool asap=false); 00406 void unscheduleRepaint(); 00407 00408 bool needsFullRepaint() const; 00409 00410 void closeChildDialogs(); 00411 bool dialogsAllowed(); 00412 00413 void setMouseEventsTarget( QWidget* w ); 00414 QWidget* mouseEventsTarget() const; 00415 00416 QStack<QRegion>* clipHolder() const; 00417 void setClipHolder( QStack<QRegion>* ch ); 00418 00419 void setPart(KHTMLPart *part); 00420 00429 void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0); 00430 00431 void render(QPainter *p, const QRect& r, const QPoint& off); 00432 00443 void setMediaType( const QString &medium ); 00444 QString mediaType() const; 00445 00446 bool pagedMode() const; 00447 00448 bool scrollTo(const QRect &); 00449 00450 bool focusNextPrevNode(bool next); 00451 bool handleAccessKey(const QKeyEvent* ev); 00452 bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL); 00453 QMap< DOM::ElementImpl*, QChar > buildFallbackAccessKeys() const; 00454 void displayAccessKeys( KHTMLView* caller, KHTMLView* origview, QVector< QChar >& taken, bool use_fallbacks ); 00455 bool isScrollingFromMouseWheel() const; 00456 void setHasStaticBackground(bool partial=false); 00457 void setHasNormalBackground(); 00458 void addStaticObject(bool fixed); 00459 void removeStaticObject(bool fixed); 00460 void applyTransforms( int& x, int& y, int& w, int& h) const; 00461 void revertTransforms( int& x, int& y, int& w, int& h) const; 00462 void revertTransforms( int& x, int& y ) const; 00463 void checkExternalWidgetsPosition(); 00464 00465 void setIgnoreWheelEvents(bool e); 00466 00467 void init(); 00468 00469 DOM::NodeImpl *nodeUnderMouse() const; 00470 DOM::NodeImpl *nonSharedNodeUnderMouse() const; 00471 00472 void restoreScrollBar(); 00473 00474 QStringList formCompletionItems(const QString &name) const; 00475 void clearCompletionHistory(const QString& name); 00476 void addFormCompletionItem(const QString &name, const QString &value); 00477 00478 void addNonPasswordStorableSite( const QString& host ); 00479 void delNonPasswordStorableSite( const QString& host ); 00480 bool nonPasswordStorableSite( const QString& host ) const; 00481 00482 bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode, 00483 DOM::NodeImpl *targetNodeNonShared, bool cancelable, 00484 int detail,QMouseEvent *_mouse, bool setUnder, 00485 int mouseEventType, int orientation=0); 00486 bool dispatchKeyEvent( QKeyEvent *_ke ); 00487 bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress ); 00488 00489 void complete( bool pendingAction ); 00490 00491 void updateScrollBars(); 00492 void setupSmoothScrolling(int dx, int dy); 00493 00498 int caretDisplayPolicyNonFocused() const; 00499 00505 void setCaretDisplayPolicyNonFocused(int policy); 00506 00507 // -- caret event handler 00508 00513 bool caretKeyPressEvent(QKeyEvent *); 00514 00515 // ------------------------------------- member variables ------------------------------------ 00516 private: 00517 friend class KHTMLViewPrivate; 00518 enum LinkCursor { LINK_NORMAL, LINK_MAILTO, LINK_NEWWINDOW }; 00519 00520 void setWidgetVisible(::khtml::RenderWidget*, bool visible); 00521 00522 00523 int _width; 00524 int _height; 00525 00526 int _marginWidth; 00527 int _marginHeight; 00528 00529 KHTMLPart *m_part; 00530 KHTMLViewPrivate* const d; 00531 00532 QString m_medium; // media type 00533 }; 00534 00535 #endif 00536
KDE 4.6 API Reference