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     
00218 private:
00219 
00220     void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00221     void unscheduleRelayout();
00222 
00223     void scheduleRepaint(int x, int y, int w, int h, bool asap=false);
00224     void unscheduleRepaint();
00225     
00226 
00227     void closeChildDialogs();
00228     bool dialogsAllowed();
00229 
00238     void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
00239 
00250     void setMediaType( const QString &medium );
00251     QString mediaType() const;
00252 
00253     bool scrollTo(const QRect &);
00254 
00255     bool focusNextPrevNode(bool next);
00256     bool handleAccessKey(const QKeyEvent* ev);
00257     bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
00258 
00259     void useSlowRepaints();
00260 
00261     void setIgnoreWheelEvents(bool e);
00262 
00263     void init();
00264 
00265     DOM::NodeImpl *nodeUnderMouse() const;
00266     DOM::NodeImpl *nonSharedNodeUnderMouse() const;
00267 
00268     void restoreScrollBar();
00269 
00270     QStringList formCompletionItems(const QString &name) const;
00271     void clearCompletionHistory(const QString& name);
00272     void addFormCompletionItem(const QString &name, const QString &value);
00273 
00274     void addNonPasswordStorableSite( const QString& host );
00275     bool nonPasswordStorableSite( const QString& host ) const;
00276 
00277     bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
00278                 DOM::NodeImpl *targetNodeNonShared, bool cancelable,
00279                 int detail,QMouseEvent *_mouse, bool setUnder,
00280                 int mouseEventType);
00281     bool dispatchKeyEvent( QKeyEvent *_ke );
00282     bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
00283 
00284     void complete( bool pendingAction );
00285 
00286 #ifndef KHTML_NO_TYPE_AHEAD_FIND
00287     void findAhead(bool increase);
00288 #endif // KHTML_NO_TYPE_AHEAD_FIND
00289 
00290 #ifndef KHTML_NO_CARET
00291     // -- caret-related member functions (for caretMode as well as designMode)
00292 
00303     void initCaret(bool keepSelection = false);
00306     bool caretOverrides() const;
00314     void ensureNodeHasFocus(DOM::NodeImpl *node);
00321     void recalcAndStoreCaretPos(khtml::CaretBox *hintBox = 0);
00328     void caretOn();
00334     void caretOff();
00343     void showCaret(bool forceRepaint = false);
00350     void hideCaret();
00355     void ensureCaretVisible();
00356 
00372     bool foldSelectionToCaret(DOM::NodeImpl *startNode, long startOffset,
00373                     DOM::NodeImpl *endNode, long endOffset);
00374 
00384     bool placeCaret(khtml::CaretBox *hintBox = 0);
00385 
00402     bool extendSelection(DOM::NodeImpl *startNode, long startOffset,
00403                 DOM::NodeImpl *endNode, long endOffset);
00404 
00414     void updateSelection(DOM::NodeImpl *startNode, long startOffset,
00415             DOM::NodeImpl *endNode, long endOffset);
00416 
00421     int caretDisplayPolicyNonFocused() const;
00422 
00429     void setCaretDisplayPolicyNonFocused(int policy);
00430 
00431     // -- caret event handler
00432 
00436     void caretKeyPressEvent(QKeyEvent *);
00437 
00438     // -- caret navigation member functions
00439 
00451     bool moveCaretTo(DOM::NodeImpl *node, long offset, bool clearSelection);
00452 
00458     enum CaretMovement { CaretByCharacter, CaretByWord };
00459 
00470     void moveCaretBy(bool next, CaretMovement cmv, int n);
00471 
00474     void moveCaretByLine(bool next, int n);
00475 
00480     void moveCaretToLineBoundary(bool end);
00481 
00486     void moveCaretToDocumentBoundary(bool end);
00487 
00496     void placeCaretOnChar(khtml::CaretBox *hintBox);
00497 
00514     void placeCaretOnLine(khtml::CaretBox *caretBox, int x, int absx, int absy);
00515 
00519     void moveCaretByPage(bool next);
00520 
00523     void moveCaretPrevWord();
00524 
00527     void moveCaretNextWord();
00528 
00533     void moveCaretPrevLine(int n = 1);
00534 
00539     void moveCaretNextLine(int n = 1);
00540 
00543     void moveCaretPrevPage();
00544 
00547     void moveCaretNextPage();
00548 
00551     void moveCaretToLineBegin();
00552 
00555     void moveCaretToLineEnd();
00556 
00557 #endif // KHTML_NO_CARET
00558 
00559     // ------------------------------------- member variables ------------------------------------
00560  private:
00561 
00562     void setWidgetVisible(::khtml::RenderWidget*, bool visible);
00563 
00564     int _width;
00565     int _height;
00566 
00567     int _marginWidth;
00568     int _marginHeight;
00569 
00570     KHTMLPart *m_part;
00571     KHTMLViewPrivate *d;
00572 
00573     QString m_medium;   // media type
00574 };
00575 
00576 #endif
00577 
KDE Logo
This file is part of the documentation for khtml Library Version 3.3.90.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 30 10:22:20 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003