kspread

kspread_editors.h
1/* This file is part of the KDE project
2
3 Copyright 1999-2006 The KSpread Team <koffice-devel@kde.org>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21
22#ifndef __kspread_editors_h__
23#define __kspread_editors_h__
24
25#include <vector>
26
27#include <tqsyntaxhighlighter.h>
28#include <tqwidget.h>
29
30#include <kcombobox.h>
31#include <klineedit.h>
32#include <ksharedptr.h>
33
34class KTextEdit;
35class TQFont;
36class TQButton;
37class TQTextCursor;
38
39namespace KSpread
40{
41class Canvas;
42class Cell;
43class CellEditor;
45class Region;
46class Sheet;
47class Tokens;
48class View;
49
50
55class FormulaEditorHighlighter : public TQSyntaxHighlighter
56{
57public:
64 FormulaEditorHighlighter(TQTextEdit* textEdit, Canvas* canvas);
66
67
71 virtual int highlightParagraph(const TQString& text, int endStateOfLastPara);
75 const Tokens& formulaTokens() const;
79 uint rangeCount() const;
84 bool rangeChanged() const;
85
89 void resetRangeChanged();
90
91
92
93protected:
97 int findMatchingBrace(int pos);
102 void handleBrace(uint index);
103
104private:
105 class Private;
106 Private* d;
107};
108
109
110
120class FunctionCompletion : public TQObject
121{
122 TQ_OBJECT
123
124
125public:
126
127 FunctionCompletion( CellEditor* editor );
128 ~FunctionCompletion();
129
133 bool eventFilter( TQObject *o, TQEvent *e );
134
138 void doneCompletion();
139
144 void showCompletion( const TQStringList &choices );
145
146private slots:
147 void itemSelected( const TQString& item );
148
149signals:
153 void selectedCompletion( const TQString& item );
154
155private:
156 class Private;
157 Private* d;
158 FunctionCompletion( const FunctionCompletion& );
159 FunctionCompletion& operator=( const FunctionCompletion& );
160};
161
162
163
167class CellEditor : public TQWidget
168{
169 TQ_OBJECT
170
171public:
172
180 CellEditor( Cell* cell, Canvas* _parent = 0, bool captureAllKeyEvents = false, const char* _name = 0 );
181 ~CellEditor();
182
183 Cell* cell() const;
184 Canvas* canvas() const;
185
186 void handleKeyPressEvent( TQKeyEvent* _ev );
187 void handleIMEvent( TQIMEvent * _ev );
188 void setEditorFont(TQFont const & font, bool updateSize);
189
190 int cursorPosition() const;
191 void setCursorPosition(int pos);
192
193 void setText(TQString text);
194
196 TQString text() const;
197
199 void cut();
201 void paste();
203 void copy();
204
205 TQPoint globalCursorPosition() const;
206
207 bool checkChoice();
208 void setCheckChoice(bool b);
209
210 void updateChoice();
211 void setUpdateChoice(bool);
212
213 void setCursorToRange(uint);
214
215private slots:
216 void slotTextChanged();
217 void slotCompletionModeChanged(TDEGlobalSettings::Completion _completion);
218 void slotCursorPositionChanged(int para,int pos);
219 void slotTextCursorChanged(TQTextCursor*);
220
221protected:
222 void resizeEvent( TQResizeEvent* );
227 bool eventFilter( TQObject* o, TQEvent* e );
228
229protected slots:
230 void checkFunctionAutoComplete();
231 void triggerFunctionAutoComplete();
232 void functionAutoComplete( const TQString& item );
233
234private:
235 class Private;
236 Private* d;
237};
238
239
240
244class ComboboxLocationEditWidget : public KComboBox
245{
246 TQ_OBJECT
247
248public:
249 ComboboxLocationEditWidget( TQWidget *_parent, View * _canvas );
250
251public slots:
252 void slotAddAreaName( const TQString & );
253 void slotRemoveAreaName( const TQString & );
254private:
255 LocationEditWidget *m_locationWidget;
256};
257
258
259
264class LocationEditWidget : public KLineEdit
265{
266 TQ_OBJECT
267
268public:
269 LocationEditWidget( TQWidget *_parent, View * _canvas );
270 View * view() const { return m_pView;}
271
272 void addCompletionItem( const TQString &_item );
273 void removeCompletionItem( const TQString &_item );
274
275private slots:
276 void slotActivateItem();
277
278protected:
279 virtual void keyPressEvent( TQKeyEvent * _ev );
280private:
281 View * m_pView;
282 TDECompletion completionList;
283 bool activateItem();
284};
285
286
287
292class EditWidget : public TQLineEdit
293{
294 TQ_OBJECT
295
296public:
297 EditWidget( TQWidget *parent, Canvas *canvas,
298 TQButton *cancelButton, TQButton *okButton);
299
300 virtual void setText( const TQString& t );
301
302 // Go into edit mode (enable the buttons)
303 void setEditMode( bool mode );
304
305 void showEditWidget(bool _show);
306public slots:
307 void slotAbortEdit();
308 void slotDoneEdit();
309
310protected:
311 virtual void keyPressEvent ( TQKeyEvent* _ev );
312 virtual void focusOutEvent( TQFocusEvent* ev );
313
314private:
315 TQButton* m_pCancelButton;
316 TQButton* m_pOkButton;
317 Canvas* m_pCanvas;
318 bool isArray;
319};
320
321} // namespace KSpread
322
323#endif
The canvas builds a part of the GUI of KSpread.
class CellEditor
void copy()
wrapper to KTextEdit::copy()
bool eventFilter(TQObject *o, TQEvent *e)
Steals some key events from the TQLineEdit and sends it to the Canvas ( its parent ) instead.
void paste()
wrapper to KTextEdit::paste()
TQString text() const
wrapper to KTextEdit::text()
CellEditor(Cell *cell, Canvas *_parent=0, bool captureAllKeyEvents=false, const char *_name=0)
Creates a new CellEditor.
void cut()
wrapper to KTextEdit::cut()
For every cell in the spread sheet there is a Cell object.
FormulaEditorHighlighter(TQTextEdit *textEdit, Canvas *canvas)
Constructs a FormulaHighlighter to colour-code cell references in a TQTextEdit.
virtual int highlightParagraph(const TQString &text, int endStateOfLastPara)
Called automatically by KTextEditor to highlight text when modified.
bool rangeChanged() const
Returns true if any of the ranges or cells in the formula have changed since the last call to Formula...
void resetRangeChanged()
Sets the highlighter's range changed flag to false.
void handleBrace(uint index)
Examines the brace (Token::LeftPar or Token::RightPar) operator token at the given index in the token...
int findMatchingBrace(int pos)
Returns the position of the brace matching the one found at position pos.
void doneCompletion()
Hides the autocompletion list box if it is visible and emits the selectedCompletion signal.
bool eventFilter(TQObject *o, TQEvent *e)
Handles various keyboard and mouse actions which may occur on the autocompletion popup list.
void selectedCompletion(const TQString &item)
Emitted, if the user selects a function name from the list.
void showCompletion(const TQStringList &choices)
Populates the autocompletion list box with the specified choices and shows it so that the user can vi...
A widget that allows the user to enter an arbitrary cell location to goto or cell selection to highli...
The one for all class for points and ranges.
Definition region.h:44
Class Tokens represents array of tokens.
Definition formula.h:220
The View class displays a KSpread document.
The KSpread namespace.
Definition commands.h:39