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 
00179 protected:
00180     void clear();
00181 
00182     virtual void resizeEvent ( QResizeEvent * event );
00183     virtual void showEvent ( QShowEvent * );
00184     virtual void hideEvent ( QHideEvent *);
00185     virtual bool focusNextPrevChild( bool next );
00186     virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
00187     virtual void drawContents( QPainter* );
00188     virtual void viewportMousePressEvent( QMouseEvent * );
00189     virtual void focusInEvent( QFocusEvent * );
00190     virtual void focusOutEvent( QFocusEvent * );
00191     virtual void viewportMouseDoubleClickEvent( QMouseEvent * );
00192     virtual void viewportMouseMoveEvent(QMouseEvent *);
00193     virtual void viewportMouseReleaseEvent(QMouseEvent *);
00194     virtual void viewportResizeEvent(QResizeEvent*);
00195 #ifndef QT_NO_WHEELEVENT
00196     virtual void viewportWheelEvent(QWheelEvent*);
00197 #endif
00198     virtual void dragEnterEvent( QDragEnterEvent* );
00199     virtual void dropEvent( QDropEvent* );
00200     virtual void closeEvent ( QCloseEvent * );
00201     virtual bool eventFilter(QObject *, QEvent *);
00202 
00203     void keyPressEvent( QKeyEvent *_ke );
00204     void keyReleaseEvent ( QKeyEvent *_ke );
00205     void contentsContextMenuEvent ( QContextMenuEvent *_ce );
00206     void doAutoScroll();
00207     void timerEvent ( QTimerEvent * );
00208 
00209 protected slots:
00210     void slotPaletteChanged();
00211     void slotScrollBarMoved();
00212 
00213 private slots:
00214     void tripleClickTimeout();
00215     void findTimeout();
00216     void accessKeysTimeout();
00217     
00223     void slotMouseScrollTimer();
00224     
00225 private:
00226 
00227     void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00228     void unscheduleRelayout();
00229 
00230     void scheduleRepaint(int x, int y, int w, int h, bool asap=false);
00231     void unscheduleRepaint();
00232     
00233     bool needsFullRepaint() const;
00234 
00235     void closeChildDialogs();
00236     bool dialogsAllowed();
00237 
00246     void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
00247 
00258     void setMediaType( const QString &medium );
00259     QString mediaType() const;
00260 
00261     bool scrollTo(const QRect &);
00262 
00263     bool focusNextPrevNode(bool next);
00264     bool handleAccessKey(const QKeyEvent* ev);
00265     bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
00266 
00267     void useSlowRepaints();
00268 
00269     void setIgnoreWheelEvents(bool e);
00270 
00271     void init();
00272 
00273     DOM::NodeImpl *nodeUnderMouse() const;
00274     DOM::NodeImpl *nonSharedNodeUnderMouse() const;
00275 
00276     void restoreScrollBar();
00277 
00278     QStringList formCompletionItems(const QString &name) const;
00279     void clearCompletionHistory(const QString& name);
00280     void addFormCompletionItem(const QString &name, const QString &value);
00281 
00282     void addNonPasswordStorableSite( const QString& host );
00283     bool nonPasswordStorableSite( const QString& host ) const;
00284 
00285     bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
00286                 DOM::NodeImpl *targetNodeNonShared, bool cancelable,
00287                 int detail,QMouseEvent *_mouse, bool setUnder,
00288                 int mouseEventType);
00289     bool dispatchKeyEvent( QKeyEvent *_ke );
00290     bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
00291 
00292     void complete( bool pendingAction );
00293 
00294 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00295     void findAhead(bool increase);
00296 #endif // KHTML_NO_TYPE_AHEAD_FIND
00297 
00298 #ifndef KHTML_NO_CARET
00299     // -- caret-related member functions (for caretMode as well as designMode)
00300 
00311     void initCaret(bool keepSelection = false);
00314     bool caretOverrides() const;
00322     void ensureNodeHasFocus(DOM::NodeImpl *node);
00329     void recalcAndStoreCaretPos(khtml::CaretBox *hintBox = 0);
00336     void caretOn();
00342     void caretOff();
00351     void showCaret(bool forceRepaint = false);
00358     void hideCaret();
00363     void ensureCaretVisible();
00364 
00380     bool foldSelectionToCaret(DOM::NodeImpl *startNode, long startOffset,
00381                     DOM::NodeImpl *endNode, long endOffset);
00382 
00392     bool placeCaret(khtml::CaretBox *hintBox = 0);
00393 
00410     bool extendSelection(DOM::NodeImpl *startNode, long startOffset,
00411                 DOM::NodeImpl *endNode, long endOffset);
00412 
00422     void updateSelection(DOM::NodeImpl *startNode, long startOffset,
00423             DOM::NodeImpl *endNode, long endOffset);
00424 
00429     int caretDisplayPolicyNonFocused() const;
00430 
00437     void setCaretDisplayPolicyNonFocused(int policy);
00438 
00439     // -- caret event handler
00440 
00444     void caretKeyPressEvent(QKeyEvent *);
00445 
00446     // -- caret navigation member functions
00447 
00459     bool moveCaretTo(DOM::NodeImpl *node, long offset, bool clearSelection);
00460 
00466     enum CaretMovement { CaretByCharacter, CaretByWord };
00467 
00478     void moveCaretBy(bool next, CaretMovement cmv, int n);
00479 
00482     void moveCaretByLine(bool next, int n);
00483 
00488     void moveCaretToLineBoundary(bool end);
00489 
00494     void moveCaretToDocumentBoundary(bool end);
00495 
00504     void placeCaretOnChar(khtml::CaretBox *hintBox);
00505 
00522     void placeCaretOnLine(khtml::CaretBox *caretBox, int x, int absx, int absy);
00523 
00527     void moveCaretByPage(bool next);
00528 
00531     void moveCaretPrevWord();
00532 
00535     void moveCaretNextWord();
00536 
00541     void moveCaretPrevLine(int n = 1);
00542 
00547     void moveCaretNextLine(int n = 1);
00548 
00551     void moveCaretPrevPage();
00552 
00555     void moveCaretNextPage();
00556 
00559     void moveCaretToLineBegin();
00560 
00563     void moveCaretToLineEnd();
00564 
00565 #endif // KHTML_NO_CARET
00566 
00567     // ------------------------------------- member variables ------------------------------------
00568  private:
00569 
00570     void setWidgetVisible(::khtml::RenderWidget*, bool visible);
00571 
00572     int _width;
00573     int _height;
00574 
00575     int _marginWidth;
00576     int _marginHeight;
00577 
00578     KHTMLPart *m_part;
00579     KHTMLViewPrivate *d;
00580 
00581     QString m_medium;   // media type
00582 };
00583 
00584 #endif
00585 
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 Sat May 7 22:11:49 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003