khtml Library API Documentation

khtmlview.h

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 
00009    This library is free software; you can redistribute it and/or
00010    modify it under the terms of the GNU Library General Public
00011    License as published by the Free Software Foundation; either
00012    version 2 of the License, or (at your option) any later version.
00013 
00014    This library is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017    Library General Public License for more details.
00018 
00019    You should have received a copy of the GNU Library General Public License
00020    along with this library; see the file COPYING.LIB.  If not, write to
00021    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022    Boston, MA 02111-1307, USA.
00023 */
00024 
00025 #ifndef KHTMLVIEW_H
00026 #define KHTMLVIEW_H
00027 
00028 // qt includes and classes
00029 #include <qscrollview.h>
00030 
00031 #include <kdelibs_export.h>
00032 
00033 class QPainter;
00034 class QRect;
00035 
00036 namespace DOM {
00037     class HTMLDocumentImpl;
00038     class DocumentImpl;
00039     class ElementImpl;
00040     class HTMLElementImpl;
00041     class HTMLTitleElementImpl;
00042     class HTMLGenericFormElementImpl;
00043     class HTMLFormElementImpl;
00044     class HTMLAnchorElementImpl;
00045     class HTMLInputElementImpl;
00046     class Range;
00047     class NodeImpl;
00048     class CSSProperty;
00049 }
00050 
00051 namespace KJS {
00052     class WindowFunc;
00053     class ExternalFunc;
00054 }
00055 
00056 namespace khtml {
00057     class RenderObject;
00058     class RenderCanvas;
00059     class RenderStyle;
00060     class RenderLineEdit;
00061     class RenderPartObject;
00062     class RenderWidget;
00063     class CSSStyleSelector;
00064     class LineEditWidget;
00065     class CaretBox;
00066     void applyRule(DOM::CSSProperty *prop);
00067 }
00068 
00069 class KHTMLPart;
00070 class KHTMLViewPrivate;
00071 
00077 class KHTML_EXPORT KHTMLView : public QScrollView
00078 {
00079     Q_OBJECT
00080 
00081     friend class DOM::HTMLDocumentImpl;
00082     friend class DOM::HTMLTitleElementImpl;
00083     friend class DOM::HTMLGenericFormElementImpl;
00084     friend class DOM::HTMLFormElementImpl;
00085     friend class DOM::HTMLAnchorElementImpl;
00086     friend class DOM::HTMLInputElementImpl;
00087     friend class DOM::DocumentImpl;
00088     friend class KHTMLPart;
00089     friend class khtml::RenderCanvas;
00090     friend class khtml::RenderObject;
00091     friend class khtml::RenderLineEdit;
00092     friend class khtml::RenderPartObject;
00093     friend class khtml::RenderWidget;
00094     friend class khtml::CSSStyleSelector;
00095     friend class khtml::LineEditWidget;
00096     friend class KJS::WindowFunc;
00097     friend class KJS::ExternalFunc;
00098     friend void khtml::applyRule(DOM::CSSProperty *prop);
00099 
00100 
00101 public:
00105     KHTMLView( KHTMLPart *part, QWidget *parent, const char *name=0 );
00106     virtual ~KHTMLView();
00107 
00112     KHTMLPart *part() const { return m_part; }
00113 
00114     int frameWidth() const { return _width; }
00115 
00119     void setMarginWidth(int x);
00120 
00126     int marginWidth() const { return _marginWidth; }
00127 
00128     /*
00129      * Sets a margin in y direction.
00130      */
00131     void setMarginHeight(int y);
00132 
00138     int marginHeight() { return _marginHeight; }
00139 
00143     virtual void setVScrollBarMode ( ScrollBarMode mode );
00144 
00148     virtual void setHScrollBarMode ( ScrollBarMode mode );
00149 
00153     void print();
00154 
00159     void print( bool quick ); // KDE 4.0: merge with above
00160 
00164     void layout(); // KDE 4.0: make private
00168     void displayAccessKeys();
00169     
00170     
00171 
00172 signals:
00173     void finishedLayout();
00174     void cleared();
00175     void zoomView( int );
00176     void hideAccessKeys();
00177     void repaintAccessKeys();
00178 //#define NO_SMOOTH_SCROLL_HACK
00179 #ifndef NO_SMOOTH_SCROLL_HACK
00180 public slots:
00181     void scrollBy(int dx, int dy);
00182 #endif
00183 
00184 protected:
00185     void clear();
00186 
00187     virtual void resizeEvent ( QResizeEvent * event );
00188     virtual void showEvent ( QShowEvent * );
00189     virtual void hideEvent ( QHideEvent *);
00190     virtual bool focusNextPrevChild( bool next );
00191     virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
00192     virtual void drawContents( QPainter* );
00193     virtual void viewportMousePressEvent( QMouseEvent * );
00194     virtual void focusInEvent( QFocusEvent * );
00195     virtual void focusOutEvent( QFocusEvent * );
00196     virtual void viewportMouseDoubleClickEvent( QMouseEvent * );
00197     virtual void viewportMouseMoveEvent(QMouseEvent *);
00198     virtual void viewportMouseReleaseEvent(QMouseEvent *);
00199     virtual void viewportResizeEvent(QResizeEvent*);
00200 #ifndef QT_NO_WHEELEVENT
00201     virtual void viewportWheelEvent(QWheelEvent*);
00202 #endif
00203     virtual void dragEnterEvent( QDragEnterEvent* );
00204     virtual void dropEvent( QDropEvent* );
00205     virtual void closeEvent ( QCloseEvent * );
00206     virtual bool eventFilter(QObject *, QEvent *);
00207 
00208     void keyPressEvent( QKeyEvent *_ke );
00209     void keyReleaseEvent ( QKeyEvent *_ke );
00210     void contentsContextMenuEvent ( QContextMenuEvent *_ce );
00211     void doAutoScroll();
00212     void timerEvent ( QTimerEvent * );
00213 
00214 #ifndef NO_SMOOTH_SCROLL_HACK
00215     void startScrolling();
00216     void stopScrolling();
00217 #ifndef QT_NO_WHEELEVENT
00218     void scrollViewWheelEvent( QWheelEvent* e );
00219 #endif
00220 #endif
00221 
00222 protected slots:
00223     void slotPaletteChanged();
00224     void slotScrollBarMoved();
00225 #ifndef NO_SMOOTH_SCROLL_HACK
00226     void scrollTick();
00227 #else
00228     void scrollTick() {}; // moc cannot handle #if
00229 #endif
00230 
00231 private slots:
00232     void tripleClickTimeout();
00233     void findTimeout();
00234     void accessKeysTimeout();
00235     
00241     void slotMouseScrollTimer();
00242     
00243 private:
00244 
00245     void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00246     void unscheduleRelayout();
00247 
00248     void scheduleRepaint(int x, int y, int w, int h, bool asap=false);
00249     void unscheduleRepaint();
00250     
00251     bool needsFullRepaint() const;
00252 
00253     void closeChildDialogs();
00254     bool dialogsAllowed();
00255 
00264     void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
00265 
00276     void setMediaType( const QString &medium );
00277     QString mediaType() const;
00278 
00279     bool scrollTo(const QRect &);
00280 
00281     bool focusNextPrevNode(bool next);
00282     bool handleAccessKey(const QKeyEvent* ev);
00283     bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
00284 
00285     void useSlowRepaints();
00286 
00287     void setIgnoreWheelEvents(bool e);
00288 
00289     void init();
00290 
00291     DOM::NodeImpl *nodeUnderMouse() const;
00292     DOM::NodeImpl *nonSharedNodeUnderMouse() const;
00293 
00294     void restoreScrollBar();
00295 
00296     QStringList formCompletionItems(const QString &name) const;
00297     void clearCompletionHistory(const QString& name);
00298     void addFormCompletionItem(const QString &name, const QString &value);
00299 
00300     void addNonPasswordStorableSite( const QString& host );
00301     bool nonPasswordStorableSite( const QString& host ) const;
00302 
00303     bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
00304                 DOM::NodeImpl *targetNodeNonShared, bool cancelable,
00305                 int detail,QMouseEvent *_mouse, bool setUnder,
00306                 int mouseEventType);
00307     bool dispatchKeyEvent( QKeyEvent *_ke );
00308     bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
00309 
00310     void complete( bool pendingAction );
00311 
00312 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00313     void findAhead(bool increase);
00314 #endif // KHTML_NO_TYPE_AHEAD_FIND
00315 
00316 #ifndef KHTML_NO_CARET
00317     // -- caret-related member functions (for caretMode as well as designMode)
00318 
00329     void initCaret(bool keepSelection = false);
00332     bool caretOverrides() const;
00340     void ensureNodeHasFocus(DOM::NodeImpl *node);
00347     void recalcAndStoreCaretPos(khtml::CaretBox *hintBox = 0);
00354     void caretOn();
00360     void caretOff();
00369     void showCaret(bool forceRepaint = false);
00376     void hideCaret();
00381     void ensureCaretVisible();
00382 
00398     bool foldSelectionToCaret(DOM::NodeImpl *startNode, long startOffset,
00399                     DOM::NodeImpl *endNode, long endOffset);
00400 
00410     bool placeCaret(khtml::CaretBox *hintBox = 0);
00411 
00428     bool extendSelection(DOM::NodeImpl *startNode, long startOffset,
00429                 DOM::NodeImpl *endNode, long endOffset);
00430 
00440     void updateSelection(DOM::NodeImpl *startNode, long startOffset,
00441             DOM::NodeImpl *endNode, long endOffset);
00442 
00447     int caretDisplayPolicyNonFocused() const;
00448 
00455     void setCaretDisplayPolicyNonFocused(int policy);
00456 
00457     // -- caret event handler
00458 
00462     void caretKeyPressEvent(QKeyEvent *);
00463 
00464     // -- caret navigation member functions
00465 
00477     bool moveCaretTo(DOM::NodeImpl *node, long offset, bool clearSelection);
00478 
00484     enum CaretMovement { CaretByCharacter, CaretByWord };
00485 
00496     void moveCaretBy(bool next, CaretMovement cmv, int n);
00497 
00500     void moveCaretByLine(bool next, int n);
00501 
00506     void moveCaretToLineBoundary(bool end);
00507 
00512     void moveCaretToDocumentBoundary(bool end);
00513 
00522     void placeCaretOnChar(khtml::CaretBox *hintBox);
00523 
00540     void placeCaretOnLine(khtml::CaretBox *caretBox, int x, int absx, int absy);
00541 
00545     void moveCaretByPage(bool next);
00546 
00549     void moveCaretPrevWord();
00550 
00553     void moveCaretNextWord();
00554 
00559     void moveCaretPrevLine(int n = 1);
00560 
00565     void moveCaretNextLine(int n = 1);
00566 
00569     void moveCaretPrevPage();
00570 
00573     void moveCaretNextPage();
00574 
00577     void moveCaretToLineBegin();
00578 
00581     void moveCaretToLineEnd();
00582 
00583 #endif // KHTML_NO_CARET
00584 
00585     // ------------------------------------- member variables ------------------------------------
00586  private:
00587 
00588     void setWidgetVisible(::khtml::RenderWidget*, bool visible);
00589 
00590     int _width;
00591     int _height;
00592 
00593     int _marginWidth;
00594     int _marginHeight;
00595 
00596     KHTMLPart *m_part;
00597     KHTMLViewPrivate *d;
00598 
00599     QString m_medium;   // media type
00600 };
00601 
00602 #endif
00603 
KDE Logo
This file is part of the documentation for khtml Library Version 3.4.0.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Tue Mar 22 19:54:28 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003