khtmlview.h
/* This file is part of the KDE project
Copyright (C) 1997 Martin Jones (mjones@kde.org)
(C) 1998 Waldo Bastian (bastian@kde.org)
(C) 1998, 1999 Torben Weis (weis@kde.org)
(C) 1999 Lars Knoll (knoll@kde.org)
(C) 1999 Antti Koivisto (koivisto@kde.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KHTMLVIEW_H
#define KHTMLVIEW_H
// qt includes and classes
#include <qscrollview.h>
#include <kdelibs_export.h>
class QPainter;
class QRect;
template< typename T > class QValueVector;
namespace DOM {
class HTMLDocumentImpl;
class DocumentImpl;
class ElementImpl;
class HTMLElementImpl;
class HTMLTitleElementImpl;
class HTMLGenericFormElementImpl;
class HTMLFormElementImpl;
class HTMLAnchorElementImpl;
class HTMLInputElementImpl;
class Range;
class NodeImpl;
class CSSProperty;
}
namespace KJS {
class WindowFunc;
class ExternalFunc;
}
namespace khtml {
class RenderObject;
class RenderCanvas;
class RenderStyle;
class RenderLineEdit;
class RenderPartObject;
class RenderWidget;
class CSSStyleSelector;
class LineEditWidget;
class CaretBox;
void applyRule(DOM::CSSProperty *prop);
}
class KHTMLPart;
class KHTMLViewPrivate;
class KHTML_EXPORT KHTMLView : public QScrollView
{
Q_OBJECT
friend class DOM::HTMLDocumentImpl;
friend class DOM::HTMLTitleElementImpl;
friend class DOM::HTMLGenericFormElementImpl;
friend class DOM::HTMLFormElementImpl;
friend class DOM::HTMLAnchorElementImpl;
friend class DOM::HTMLInputElementImpl;
friend class DOM::DocumentImpl;
friend class KHTMLPart;
friend class khtml::RenderCanvas;
friend class khtml::RenderObject;
friend class khtml::RenderLineEdit;
friend class khtml::RenderPartObject;
friend class khtml::RenderWidget;
friend class khtml::CSSStyleSelector;
friend class khtml::LineEditWidget;
friend class KJS::WindowFunc;
friend class KJS::ExternalFunc;
friend void khtml::applyRule(DOM::CSSProperty *prop);
public:
KHTMLView( KHTMLPart *part, QWidget *parent, const char *name=0 );
virtual ~KHTMLView();
KHTMLPart *part() const { return m_part; }
int frameWidth() const { return _width; }
void setMarginWidth(int x);
int marginWidth() const { return _marginWidth; }
/*
* Sets a margin in y direction.
*/
void setMarginHeight(int y);
int marginHeight() { return _marginHeight; }
virtual void setVScrollBarMode ( ScrollBarMode mode );
virtual void setHScrollBarMode ( ScrollBarMode mode );
void print();
void print( bool quick ); // KDE 4.0: merge with above
void layout(); // KDE 4.0: make private
void displayAccessKeys();
signals:
void finishedLayout();
void cleared();
void zoomView( int );
void hideAccessKeys();
void repaintAccessKeys();
void findAheadActive( bool );
protected:
void clear();
virtual void resizeEvent ( QResizeEvent * event );
virtual void showEvent ( QShowEvent * );
virtual void hideEvent ( QHideEvent *);
virtual bool focusNextPrevChild( bool next );
virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
virtual void drawContents( QPainter* );
virtual void viewportMousePressEvent( QMouseEvent * );
virtual void focusInEvent( QFocusEvent * );
virtual void focusOutEvent( QFocusEvent * );
virtual void viewportMouseDoubleClickEvent( QMouseEvent * );
virtual void viewportMouseMoveEvent(QMouseEvent *);
virtual void viewportMouseReleaseEvent(QMouseEvent *);
virtual void viewportResizeEvent(QResizeEvent*);
#ifndef QT_NO_WHEELEVENT
virtual void viewportWheelEvent(QWheelEvent*);
#endif
virtual void dragEnterEvent( QDragEnterEvent* );
virtual void dropEvent( QDropEvent* );
virtual void closeEvent ( QCloseEvent * );
virtual bool eventFilter(QObject *, QEvent *);
void keyPressEvent( QKeyEvent *_ke );
void keyReleaseEvent ( QKeyEvent *_ke );
void contentsContextMenuEvent ( QContextMenuEvent *_ce );
void doAutoScroll();
void timerEvent ( QTimerEvent * );
protected slots:
void slotPaletteChanged();
void slotScrollBarMoved();
private slots:
void tripleClickTimeout();
void findTimeout();
void accessKeysTimeout();
void slotMouseScrollTimer();
private:
void scheduleRelayout(khtml::RenderObject* clippedObj=0);
void unscheduleRelayout();
void scheduleRepaint(int x, int y, int w, int h, bool asap=false);
void unscheduleRepaint();
bool needsFullRepaint() const;
void closeChildDialogs();
bool dialogsAllowed();
void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
#if 0
void paint(QPainter *p, int width);
#endif
void setMediaType( const QString &medium );
QString mediaType() const;
bool pagedMode() const;
bool scrollTo(const QRect &);
bool focusNextPrevNode(bool next);
bool handleAccessKey(const QKeyEvent* ev);
bool focusNodeWithAccessKey(QChar c, KHTMLView* caller = NULL);
QMap< DOM::ElementImpl*, QChar > buildFallbackAccessKeys() const;
void displayAccessKeys( KHTMLView* caller, KHTMLView* origview, QValueVector< QChar >& taken, bool use_fallbacks );
void useSlowRepaints();
void setIgnoreWheelEvents(bool e);
void init();
DOM::NodeImpl *nodeUnderMouse() const;
DOM::NodeImpl *nonSharedNodeUnderMouse() const;
void restoreScrollBar();
QStringList formCompletionItems(const QString &name) const;
void clearCompletionHistory(const QString& name);
void addFormCompletionItem(const QString &name, const QString &value);
void addNonPasswordStorableSite( const QString& host );
bool nonPasswordStorableSite( const QString& host ) const;
bool dispatchMouseEvent(int eventId, DOM::NodeImpl *targetNode,
DOM::NodeImpl *targetNodeNonShared, bool cancelable,
int detail,QMouseEvent *_mouse, bool setUnder,
int mouseEventType);
bool dispatchKeyEvent( QKeyEvent *_ke );
bool dispatchKeyEventHelper( QKeyEvent *_ke, bool generate_keypress );
void complete( bool pendingAction );
#ifndef KHTML_NO_TYPE_AHEAD_FIND
void findAhead(bool increase);
void updateFindAheadTimeout();
void startFindAhead( bool linksOnly );
#endif // KHTML_NO_TYPE_AHEAD_FIND
#ifndef KHTML_NO_CARET
// -- caret-related member functions (for caretMode as well as designMode)
void initCaret(bool keepSelection = false);
bool caretOverrides() const;
void ensureNodeHasFocus(DOM::NodeImpl *node);
void recalcAndStoreCaretPos(khtml::CaretBox *hintBox = 0);
void caretOn();
void caretOff();
void showCaret(bool forceRepaint = false);
void hideCaret();
void ensureCaretVisible();
bool foldSelectionToCaret(DOM::NodeImpl *startNode, long startOffset,
DOM::NodeImpl *endNode, long endOffset);
bool placeCaret(khtml::CaretBox *hintBox = 0);
bool extendSelection(DOM::NodeImpl *startNode, long startOffset,
DOM::NodeImpl *endNode, long endOffset);
void updateSelection(DOM::NodeImpl *startNode, long startOffset,
DOM::NodeImpl *endNode, long endOffset);
int caretDisplayPolicyNonFocused() const;
void setCaretDisplayPolicyNonFocused(int policy);
// -- caret event handler
void caretKeyPressEvent(QKeyEvent *);
// -- caret navigation member functions
bool moveCaretTo(DOM::NodeImpl *node, long offset, bool clearSelection);
enum CaretMovement { CaretByCharacter, CaretByWord };
void moveCaretBy(bool next, CaretMovement cmv, int n);
void moveCaretByLine(bool next, int n);
void moveCaretToLineBoundary(bool end);
void moveCaretToDocumentBoundary(bool end);
void placeCaretOnChar(khtml::CaretBox *hintBox);
void placeCaretOnLine(khtml::CaretBox *caretBox, int x, int absx, int absy);
void moveCaretByPage(bool next);
void moveCaretPrevWord();
void moveCaretNextWord();
void moveCaretPrevLine(int n = 1);
void moveCaretNextLine(int n = 1);
void moveCaretPrevPage();
void moveCaretNextPage();
void moveCaretToLineBegin();
void moveCaretToLineEnd();
#endif // KHTML_NO_CARET
// ------------------------------------- member variables ------------------------------------
private:
void setWidgetVisible(::khtml::RenderWidget*, bool visible);
int _width;
int _height;
int _marginWidth;
int _marginHeight;
KHTMLPart *m_part;
KHTMLViewPrivate *d;
QString m_medium; // media type
};
#endif
KHTMLView::marginWidth
int marginWidth() const
Returns the margin width.
Definition: khtmlview.h:127
KHTMLPart
This class is khtml's main class.
Definition: khtml_part.h:184
KHTMLView
Renders and displays HTML in a QScrollView.
Definition: khtmlview.h:78
KHTMLView::part
KHTMLPart * part() const
Returns a pointer to the KHTMLPart that is rendering the page.
Definition: khtmlview.h:113
KHTMLView::marginHeight
int marginHeight()
Returns the margin height.
Definition: khtmlview.h:139

KDE Home | KDE Accessibility Home | Description of Access Keys