00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#ifndef kotextview_h
00021
#define kotextview_h
00022
00023
#include <qobject.h>
00024
#include <qpoint.h>
00025
#include <qcolor.h>
00026
#include <qfont.h>
00027
#include <koRuler.h>
00028
#include <kotextobject.h>
00029
class KoTextObject;
00030
class KoTextDocument;
00031
class KoTextParag;
00032
class KoTextFormat;
00033
class KoParagCounter;
00034
class KCommand;
00035
class QTimer;
00036
class KAction;
00037
class KInstance;
00038
class KDataToolInfo;
00039
class KoLinkVariable;
00040
class KoVariable;
00041
class KoTextViewIface;
00042
#include "korichtext.h"
00043
class KoBorder;
00044
class KoStyle;
00045
00051 class KoTextView :
public QObject,
public KoTextFormatInterface
00052 {
00053 Q_OBJECT
00054
public:
00059
KoTextView(
KoTextObject *textobj );
00060
virtual ~
KoTextView();
00061
00062
virtual KoTextViewIface* dcopObject();
00063
00066
void terminate(
bool removeselection=
true);
00067
00068
KoTextObject * textObject()
const {
return m_textobj; }
00069 KoTextCursor * cursor()
const {
return m_cursor; }
00070 KoTextDocument * textDocument()
const;
00071
00074 bool isReadWrite()
const {
return m_bReadWrite; }
00076 void setReadWrite(
bool b ) { m_bReadWrite = b; }
00077
00078 virtual KoTextFormat *
currentFormat()
const {
return m_currentFormat; }
00079
void setCurrentFormat(
KoTextFormat *fmt ) { m_currentFormat = fmt; }
00080
00084
virtual const KoParagLayout *
currentParagLayoutFormat() const;
00085
00086 virtual
bool rtl() const;
00087
00088 virtual KCommand *setChangeCaseOfTextCommand(KoChangeCaseDia::TypeOfCase _type);
00089
00090
00091 virtual KCommand* setParagLayoutFormatCommand(
KoParagLayout *newLayout,
int flags,
int marginIndex=-1);
00092
00094
00095 virtual KCommand* setFormatCommand( const
KoTextFormat * newFormat,
int flags,
bool zoomFont = false);
00096
00097
00098 KCommand * setCounterCommand( const
KoParagCounter & counter );
00099 KCommand * setAlignCommand(
int align );
00100 KCommand * setPageBreakingCommand(
int pageBreaking );
00101 KCommand * setLineSpacingCommand(
double spacing,
KoParagLayout::SpacingType _type );
00102 KCommand * setBordersCommand( const
KoBorder& leftBorder, const
KoBorder& rightBorder, const
KoBorder& bottomBorder, const
KoBorder& topBorder );
00103 KCommand * setMarginCommand(
QStyleSheetItem::Margin m,
double margin );
00104 KCommand * setTabListCommand( const
KoTabulatorList & tabList );
00105
void applyStyle( const
KoStyle * style );
00106
00107
void dragStarted();
00108
void focusInEvent();
00109
void focusOutEvent();
00110
void handleKeyPressEvent(
QKeyEvent * e );
00111
void handleKeyReleaseEvent(
QKeyEvent * e );
00112
00113
00114
bool handleMousePressEvent(
QMouseEvent* e, const
QPoint& iPoint,
bool canStartDrag = true,
bool insertDirectCursor = false );
00115
void handleMouseMoveEvent(
QMouseEvent* e, const
QPoint& iPoint );
00116
void handleMouseReleaseEvent();
00117
void handleMouseDoubleClickEvent(
QMouseEvent* e, const
QPoint& iPoint );
00118
void handleMouseTripleClickEvent(
QMouseEvent* e, const
QPoint& );
00119
bool maybeStartDrag(
QMouseEvent* e );
00120
00121 KoTextCursor selectWordUnderCursor( const KoTextCursor& cursor,
int selectionId = KoTextDocument::Standard );
00122 KoTextCursor selectParagUnderCursor( const KoTextCursor& cursor,
int selectionId = KoTextDocument::Standard,
bool copyAndNotify = true );
00123
void extendParagraphSelection( const QPoint& iPoint );
00124
00125
QString wordUnderCursor( const KoTextCursor& cursor );
00126
00128
QPtrList<KAction> dataToolActionList(KInstance * instance, const
QString& word,
bool & _singleWord );
00129
00130
void insertSoftHyphen();
00131
void insertLineBreak();
00132
void insertNonbreakingSpace();
00133
void insertSpecialChar(
QChar _c, const
QString& font);
00134
void changeCaseOfText(KoChangeCaseDia::TypeOfCase _type);
00135
00136
void addBookmarks(const
QString &);
00137
00138
00139
KoVariable *variable();
00140
00141
00142 KoLinkVariable *linkVariable();
00143
00144 KCommand *dropEvent(
KoTextObject *tmp,KoTextCursor dropCursor,
bool dropInSameObj);
00145
00146
void removeComment();
00147
void copyTextOfComment();
00148
00149
00150
KoStyle * createStyleFromSelection(const QString & name);
00151
void updateStyleFromSelection(
KoStyle* style);
00152
00153 QString underCursorWord();
00154
00155 public slots:
00159 virtual
void updateUI(
bool updateFormat,
bool force = false );
00160 virtual
void ensureCursorVisible() = 0;
00161
void showCurrentFormat();
00162
00163
00164
void hideCursor() {
drawCursor(
false ); }
00165
void showCursor() {
drawCursor(
true ); }
00166
00168
void insertText(
const QString &text );
00169
void newParagraph();
00170
00171
QString refLink()const {
return m_refLink;}
00172
00173
void openLink();
00174
void copyLink();
00175
void removeLink();
00176
void completion();
00177
00178
protected slots:
00180
virtual void startDrag() = 0;
00181
void slotToolActivated(
const KDataToolInfo & info,
const QString & command );
00182 signals:
00183
void copy();
00184
void cut();
00185
void paste();
00186
00187
protected:
00192 virtual void doAutoFormat( KoTextCursor* , KoTextParag * ,
00193
int ,
QChar ) { }
00194
00195
virtual void doCompletion( KoTextCursor* , KoTextParag *,
int ) { }
00196
00197
00198
virtual bool doIgnoreDoubleSpace(KoTextParag * ,
00199
int ,
QChar ) {
return false;}
00200
00202
virtual void showFormat(
KoTextFormat *format ) = 0;
00203
00208
virtual void drawCursor(
bool b );
00209
00210
00211
bool placeCursor(
const QPoint &pos ,
bool insertDirectCursor=
false );
00212
00215
virtual bool pgUpKeyPressed() = 0;
00218
virtual bool pgDownKeyPressed() = 0;
00220 virtual void ctrlPgUpKeyPressed() {
pgUpKeyPressed(); }
00222 virtual void ctrlPgDownKeyPressed() {
pgDownKeyPressed(); }
00223
00224
void deleteWordLeft();
00225
void deleteWordRight();
00226
bool insertParagraph(
const QPoint &pos);
00227
00228
private slots:
00229
void blinkCursor();
00230
void setCursor( KoTextCursor * _cursor ) { *m_cursor = *_cursor; }
00231
void tripleClickTimeout();
00232
void afterTripleClickTimeout();
00233
protected:
00234 KoTextViewIface *dcop;
00235
public:
00236
enum CursorAction {
00237 MoveBackward,
00238 MoveForward,
00239 MoveWordBackward,
00240 MoveWordForward,
00241 MoveUp,
00242 MoveDown,
00243 MoveLineStart,
00244 MoveLineEnd,
00245 MoveHome,
00246 MoveEnd,
00247 MovePgUp,
00248 MovePgDown,
00249 MoveParagUp,
00250 MoveParagDown,
00251 MoveViewportUp,
00252 MoveViewportDown
00253 };
00254
00255
void moveCursor( CursorAction action,
bool select );
00256
bool moveCursor( CursorAction action );
00257
00258
private:
00259
KoTextObject *m_textobj;
00260 KoTextCursor *m_cursor;
00261
KoTextFormat *m_currentFormat;
00262
QTimer *blinkTimer, *dragStartTimer;
00263
class KoTextViewPrivate;
00264 KoTextViewPrivate *d;
00265
QPoint dragStartPos;
00266
bool m_cursorVisible;
00267
bool blinkCursorVisible;
00268
bool inDoubleClick;
00269
bool mightStartDrag;
00270
bool m_bReadWrite;
00271
bool possibleTripleClick;
00272
bool afterTripleClick;
00273
00274
bool m_singleWord;
00275
QString m_wordUnderCursor;
00276
QString m_refLink;
00277
00278
00279
int variablePosition;
00280 };
00281
00282
#endif