00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
#ifndef KHTML_H
00026
#define KHTML_H
00027
00028
00029
#include <qscrollview.h>
00030
00031
class QPainter;
00032
class QRect;
00033
00034
namespace DOM {
00035
class HTMLDocumentImpl;
00036
class DocumentImpl;
00037
class ElementImpl;
00038
class HTMLElementImpl;
00039
class HTMLTitleElementImpl;
00040
class HTMLGenericFormElementImpl;
00041
class HTMLFormElementImpl;
00042
class HTMLAnchorElementImpl;
00043
class HTMLInputElementImpl;
00044
class Range;
00045
class NodeImpl;
00046
class CSSProperty;
00047 }
00048
00049
namespace KJS {
00050
class WindowFunc;
00051
class ExternalFunc;
00052 }
00053
00054
namespace khtml {
00055
class RenderObject;
00056
class RenderCanvas;
00057
class RenderStyle;
00058
class RenderLineEdit;
00059
class RenderPartObject;
00060
class RenderWidget;
00061
class CSSStyleSelector;
00062
class LineEditWidget;
00063
class InlineBox;
00064
void applyRule(DOM::CSSProperty *prop);
00065 }
00066
00067
class KHTMLPart;
00068
class KHTMLViewPrivate;
00069
00075 class KHTMLView :
public QScrollView
00076 {
00077 Q_OBJECT
00078
00079
friend class DOM::HTMLDocumentImpl;
00080
friend class DOM::HTMLTitleElementImpl;
00081
friend class DOM::HTMLGenericFormElementImpl;
00082
friend class DOM::HTMLFormElementImpl;
00083
friend class DOM::HTMLAnchorElementImpl;
00084
friend class DOM::HTMLInputElementImpl;
00085
friend class DOM::DocumentImpl;
00086
friend class KHTMLPart;
00087
friend class khtml::RenderCanvas;
00088
friend class khtml::RenderObject;
00089
friend class khtml::RenderLineEdit;
00090
friend class khtml::RenderPartObject;
00091
friend class khtml::RenderWidget;
00092
friend class khtml::CSSStyleSelector;
00093
friend class khtml::LineEditWidget;
00094
friend class KJS::WindowFunc;
00095
friend class KJS::ExternalFunc;
00096
friend void khtml::applyRule(DOM::CSSProperty *prop);
00097
00098
00099
public:
00103
KHTMLView(
KHTMLPart *
part,
QWidget *parent,
const char *name=0 );
00104
virtual ~
KHTMLView();
00105
00110 KHTMLPart *
part()
const {
return m_part; }
00111
00112
int frameWidth()
const {
return _width; }
00113
00117
void setMarginWidth(
int x);
00118
00124 int marginWidth()
const {
return _marginWidth; }
00125
00126
00127
00128
00129
void setMarginHeight(
int y);
00130
00136 int marginHeight() {
return _marginHeight; }
00137
00141
virtual void setVScrollBarMode ( ScrollBarMode mode );
00142
00146
virtual void setHScrollBarMode ( ScrollBarMode mode );
00147
00151
void print();
00152
00157
void print(
bool quick );
00158
00162
void layout();
00163
00164 signals:
00165
void cleared();
00166
void zoomView(
int );
00167
00168
protected:
00169
void clear();
00170
00171
virtual void resizeEvent (
QResizeEvent * event );
00172
virtual void showEvent (
QShowEvent * );
00173
virtual void hideEvent (
QHideEvent *);
00174
virtual bool focusNextPrevChild(
bool next );
00175
virtual void drawContents (
QPainter * p,
int clipx,
int clipy,
int clipw,
int cliph );
00176
virtual void drawContents(
QPainter* );
00177
virtual void viewportMousePressEvent(
QMouseEvent * );
00178
virtual void focusInEvent(
QFocusEvent * );
00179
virtual void focusOutEvent(
QFocusEvent * );
00180
virtual void viewportMouseDoubleClickEvent(
QMouseEvent * );
00181
virtual void viewportMouseMoveEvent(
QMouseEvent *);
00182
virtual void viewportMouseReleaseEvent(
QMouseEvent *);
00183
virtual void viewportResizeEvent(
QResizeEvent*);
00184
#ifndef QT_NO_WHEELEVENT
00185
virtual void viewportWheelEvent(
QWheelEvent*);
00186
#endif
00187
virtual void dragEnterEvent(
QDragEnterEvent* );
00188
virtual void dropEvent(
QDropEvent* );
00189
virtual void closeEvent (
QCloseEvent * );
00190
virtual bool eventFilter(
QObject *,
QEvent *);
00191
00192
void keyPressEvent(
QKeyEvent *_ke );
00193
void keyReleaseEvent (
QKeyEvent *_ke );
00194
void contentsContextMenuEvent (
QContextMenuEvent *_ce );
00195
void doAutoScroll();
00196
00197
void timerEvent (
QTimerEvent * );
00198
00199
protected slots:
00200
void slotPaletteChanged();
00201
void slotScrollBarMoved();
00202
00203
private slots:
00204
void tripleClickTimeout();
00205
00206
private:
00207
void scheduleRelayout(khtml::RenderObject* clippedObj=0);
00208
void unscheduleRelayout();
00209
00210
void scheduleRepaint(
int x,
int y,
int w,
int h);
00211
void unscheduleRepaint();
00212
00213
void closeChildDialogs();
00214
bool dialogsAllowed();
00215
00224
void paint(
QPainter *p,
const QRect &rc,
int yOff = 0,
bool *more = 0);
00225
00236
void setMediaType(
const QString &medium );
00237
QString mediaType() const;
00238
00239
bool scrollTo(const
QRect &);
00240
00241
void focusNextPrevNode(
bool next);
00242
bool handleAccessKey(const
QKeyEvent* ev);
00243
bool focusNodeWithAccessKey(
QChar c,
KHTMLView* caller = NULL);
00244
00245
void useSlowRepaints();
00246
00247
void setIgnoreWheelEvents(
bool e);
00248
00249
void init();
00250
00251 DOM::NodeImpl *nodeUnderMouse() const;
00252
00253
void restoreScrollBar();
00254
00255
QStringList formCompletionItems(const
QString &name) const;
00256
void clearCompletionHistory(const
QString& name);
00257
void addFormCompletionItem(const
QString &name, const
QString &value);
00258
00259
void addNonPasswordStorableSite( const
QString& host );
00260
bool nonPasswordStorableSite( const
QString& host ) const;
00261
00262
bool dispatchMouseEvent(
int eventId, DOM::NodeImpl *targetNode,
bool cancelable,
00263
int detail,
QMouseEvent *_mouse,
bool setUnder,
00264
int mouseEventType);
00265
bool dispatchKeyEvent(
QKeyEvent *_ke );
00266
bool dispatchKeyEventHelper(
QKeyEvent *_ke,
bool generate_keypress );
00267
00268
void complete();
00269
00270 #ifndef KHTML_NO_CARET
00271
00272
00283
void initCaret(
bool keepSelection = false);
00286
bool caretOverrides() const;
00294
void ensureNodeHasFocus(DOM::NodeImpl *node);
00301
void recalcAndStoreCaretPos(khtml::InlineBox *hintBox = 0);
00308
void caretOn();
00314
void caretOff();
00323
void showCaret(
bool forceRepaint = false);
00330
void hideCaret();
00335
void ensureCaretVisible();
00336
00352
bool foldSelectionToCaret(DOM::NodeImpl *startNode,
long startOffset,
00353 DOM::NodeImpl *endNode,
long endOffset);
00354
00364
bool placeCaret(khtml::InlineBox *hintBox = 0);
00365
00382
bool extendSelection(DOM::NodeImpl *startNode,
long startOffset,
00383 DOM::NodeImpl *endNode,
long endOffset);
00384
00394
void updateSelection(DOM::NodeImpl *startNode,
long startOffset,
00395 DOM::NodeImpl *endNode,
long endOffset);
00396
00401
int caretDisplayPolicyNonFocused() const;
00402
00409
void setCaretDisplayPolicyNonFocused(
int policy);
00410
00411
00412
00416
void caretKeyPressEvent(
QKeyEvent *);
00417
00418
00419
00431
bool moveCaretTo(DOM::NodeImpl *node,
long offset,
bool clearSelection);
00432
00438 enum CaretMovement { CaretByCharacter, CaretByWord };
00439
00450
void moveCaretBy(
bool next, CaretMovement cmv,
int n);
00451
00455
void moveCaretByLine(
bool next,
int n);
00456
00461
void moveCaretToLineBoundary(
bool end);
00462
00467
void moveCaretToDocumentBoundary(
bool end);
00468
00477
void placeCaretOnChar(khtml::InlineBox *hintBox);
00478
00495
void placeCaretOnLine(khtml::InlineBox *caretBox,
int x,
int absx,
int absy);
00496
00500
void moveCaretByPage(
bool next);
00501
00504
void moveCaretPrevWord();
00505
00508
void moveCaretNextWord();
00509
00514
void moveCaretPrevLine(
int n = 1);
00515
00520
void moveCaretNextLine(
int n = 1);
00521
00524
void moveCaretPrevPage();
00525
00528
void moveCaretNextPage();
00529
00532
void moveCaretToLineBegin();
00533
00536
void moveCaretToLineEnd();
00537
00538
#endif // KHTML_NO_CARET
00539
00540
00541
private:
00542
00543
void setWidgetVisible(::khtml::RenderWidget*,
bool visible);
00544
00545
int _width;
00546
int _height;
00547
00548
int _marginWidth;
00549
int _marginHeight;
00550
00551
KHTMLPart *m_part;
00552 KHTMLViewPrivate *d;
00553
00554
QString m_medium;
00555 };
00556
00557
#endif
00558