kspread
kspread_editors.h00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef __kspread_editors_h__
00023 #define __kspread_editors_h__
00024
00025 #include <vector>
00026
00027 #include <qsyntaxhighlighter.h>
00028 #include <qwidget.h>
00029
00030 #include <kcombobox.h>
00031 #include <klineedit.h>
00032 #include <ksharedptr.h>
00033
00034 class KTextEdit;
00035 class QFont;
00036 class QButton;
00037 class QTextCursor;
00038
00039 namespace KSpread
00040 {
00041 class Canvas;
00042 class Cell;
00043 class CellEditor;
00044 class LocationEditWidget;
00045 class Region;
00046 class Sheet;
00047 class Tokens;
00048 class View;
00049
00050
00055 class FormulaEditorHighlighter : public QSyntaxHighlighter
00056 {
00057 public:
00064 FormulaEditorHighlighter(QTextEdit* textEdit, Canvas* canvas);
00065 virtual ~FormulaEditorHighlighter();
00066
00067
00071 virtual int highlightParagraph(const QString& text, int endStateOfLastPara);
00075 const Tokens& formulaTokens() const;
00079 uint rangeCount() const;
00084 bool rangeChanged() const;
00085
00089 void resetRangeChanged();
00090
00091
00092
00093 protected:
00097 int findMatchingBrace(int pos);
00102 void handleBrace(uint index);
00103
00104 private:
00105 class Private;
00106 Private* d;
00107 };
00108
00109
00110
00120 class FunctionCompletion : public QObject
00121 {
00122 Q_OBJECT
00123
00124 public:
00125
00126 FunctionCompletion( CellEditor* editor );
00127 ~FunctionCompletion();
00128
00132 bool eventFilter( QObject *o, QEvent *e );
00133
00137 void doneCompletion();
00138
00143 void showCompletion( const QStringList &choices );
00144
00145 private slots:
00146 void itemSelected( const QString& item );
00147
00148 signals:
00152 void selectedCompletion( const QString& item );
00153
00154 private:
00155 class Private;
00156 Private* d;
00157 FunctionCompletion( const FunctionCompletion& );
00158 FunctionCompletion& operator=( const FunctionCompletion& );
00159 };
00160
00161
00162
00166 class CellEditor : public QWidget
00167 {
00168 Q_OBJECT
00169 public:
00170
00178 CellEditor( Cell* cell, Canvas* _parent = 0, bool captureAllKeyEvents = false, const char* _name = 0 );
00179 ~CellEditor();
00180
00181 Cell* cell() const;
00182 Canvas* canvas() const;
00183
00184 void handleKeyPressEvent( QKeyEvent* _ev );
00185 void handleIMEvent( QIMEvent * _ev );
00186 void setEditorFont(QFont const & font, bool updateSize);
00187
00188 int cursorPosition() const;
00189 void setCursorPosition(int pos);
00190
00191 void setText(QString text);
00192
00194 QString text() const;
00195
00197 void cut();
00199 void paste();
00201 void copy();
00202
00203 QPoint globalCursorPosition() const;
00204
00205 bool checkChoice();
00206 void setCheckChoice(bool b);
00207
00208 void updateChoice();
00209 void setUpdateChoice(bool);
00210
00211 void setCursorToRange(uint);
00212
00213 private slots:
00214 void slotTextChanged();
00215 void slotCompletionModeChanged(KGlobalSettings::Completion _completion);
00216 void slotCursorPositionChanged(int para,int pos);
00217 void slotTextCursorChanged(QTextCursor*);
00218
00219 protected:
00220 void resizeEvent( QResizeEvent* );
00225 bool eventFilter( QObject* o, QEvent* e );
00226
00227 protected slots:
00228 void checkFunctionAutoComplete();
00229 void triggerFunctionAutoComplete();
00230 void functionAutoComplete( const QString& item );
00231
00232 private:
00233 class Private;
00234 Private* d;
00235 };
00236
00237
00238
00242 class ComboboxLocationEditWidget : public KComboBox
00243 {
00244 Q_OBJECT
00245 public:
00246 ComboboxLocationEditWidget( QWidget *_parent, View * _canvas );
00247
00248 public slots:
00249 void slotAddAreaName( const QString & );
00250 void slotRemoveAreaName( const QString & );
00251 private:
00252 LocationEditWidget *m_locationWidget;
00253 };
00254
00255
00256
00261 class LocationEditWidget : public KLineEdit
00262 {
00263 Q_OBJECT
00264 public:
00265 LocationEditWidget( QWidget *_parent, View * _canvas );
00266 View * view() const { return m_pView;}
00267
00268 void addCompletionItem( const QString &_item );
00269 void removeCompletionItem( const QString &_item );
00270
00271 private slots:
00272 void slotActivateItem();
00273
00274 protected:
00275 virtual void keyPressEvent( QKeyEvent * _ev );
00276 private:
00277 View * m_pView;
00278 KCompletion completionList;
00279 bool activateItem();
00280 };
00281
00282
00283
00288 class EditWidget : public QLineEdit
00289 {
00290 Q_OBJECT
00291 public:
00292 EditWidget( QWidget *parent, Canvas *canvas,
00293 QButton *cancelButton, QButton *okButton);
00294
00295 virtual void setText( const QString& t );
00296
00297
00298 void setEditMode( bool mode );
00299
00300 void showEditWidget(bool _show);
00301 public slots:
00302 void slotAbortEdit();
00303 void slotDoneEdit();
00304
00305 protected:
00306 virtual void keyPressEvent ( QKeyEvent* _ev );
00307 virtual void focusOutEvent( QFocusEvent* ev );
00308
00309 private:
00310 QButton* m_pCancelButton;
00311 QButton* m_pOkButton;
00312 Canvas* m_pCanvas;
00313 bool isArray;
00314 };
00315
00316 }
00317
00318 #endif
|