kspread

kspread_dlg_layout.h
1/* This file is part of the KDE project
2 Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
3 (C) 2002-2003 Norbert Andres <nandres@web.de>
4 (C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
5 (C) 2002 John Dailey <dailey@vt.edu>
6 (C) 1999-2002 Laurent Montel <montel@kde.org>
7 (C) 1999-2002 Harri Porten <porten@kde.org>
8 (C) 2000-2001 David Faure <faure@kde.org>
9 (C) 1998-2000 Torben Weis <weis@kde.org>
10 (C) 2000 Werner Trobin <trobin@kde.org>
11 (C) 1999 Reginald Stadlbauer <reggie@kde.org>
12 (C) 1998-1999 Stephan Kulow <coolo@kde.org>
13
14 This library is free software; you can redistribute it and/or
15 modify it under the terms of the GNU Library General Public
16 License as published by the Free Software Foundation; either
17 version 2 of the License, or (at your option) any later version.
18
19 This library is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 Library General Public License for more details.
23
24 You should have received a copy of the GNU Library General Public License
25 along with this library; see the file COPYING.LIB. If not, write to
26 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
27 * Boston, MA 02110-1301, USA.
28*/
29
30#ifndef __kspread_dlg_layout_h__
31#define __kspread_dlg_layout_h__
32
33
34#include <tqtabdialog.h>
35#include <tqapplication.h>
36#include <tqbuttongroup.h>
37#include <tqgroupbox.h>
38#include <knuminput.h>
39#include <kcompletion.h>
40#include "kspread_view.h"
41#include "kspread_format.h"
42#include "kspread_doc.h"
43#include "kspread_value.h"
44#include "position_cell_format.h"
45#include "font_cell_format.h"
46#include "protection_cell_format.h"
47
48#include <tqpushbutton.h>
49#include <tqcheckbox.h>
50
51class KoUnitDoubleSpinBox;
52class TQPixmap;
53class TQRadioButton;
54class TQPushButton;
55class TQDate;
56class TQTime;
57class TQLabel;
58class TQWidget;
59class KLineEdit;
60class TQFrame;
61class TQListBox;
62class TQCheckBox;
63class KColorButton;
64class TQComboBox;
65class KComboBox;
66class KoUnitDoubleSpinBox;
67
68namespace KSpread
69{
70class Sheet;
71class CustomStyle;
72class StyleManager;
75
76enum BorderType
77{
78 BorderType_Top = 0,
79 BorderType_Bottom,
80 BorderType_Left,
81 BorderType_Right,
82 BorderType_Vertical,
83 BorderType_Horizontal,
84 BorderType_FallingDiagonal,
85 BorderType_RisingDiagonal,
86 BorderType_END
87};
88
89enum BorderShortcutType
90{
91 BorderShortcutType_Remove = 0,
92 BorderShortcutType_All,
93 BorderShortcutType_Outline,
94 BorderShortcutType_END
95};
96
97class PatternSelect : public TQFrame
98{
99 TQ_OBJECT
100
101public:
102 PatternSelect( TQWidget *parent, const char *_name );
103
104 void setPenStyle( TQt::PenStyle _pat ) { penStyle = _pat; repaint(); }
105 TQt::PenStyle getPenStyle() { return penStyle; }
106 void setColor( const TQColor &_col ) { penColor = _col; repaint(); }
107 const TQColor& getColor() { return penColor; }
108 void setPenWidth( int _w ) { penWidth = _w; repaint(); }
109 int getPenWidth() { return penWidth; }
110
111 void setPattern( const TQColor &_color, int _width, TQt::PenStyle _style );
112 void setUndefined();
113 void setDefined() { undefined = false; repaint(); }
114
115 bool isDefined() { return !undefined; }
116
117signals:
118 void clicked( PatternSelect *_this );
119
120public slots:
121 void slotUnselect();
122 void slotSelect();
123
124protected:
125 virtual void paintEvent( TQPaintEvent *_ev );
126 virtual void mousePressEvent( TQMouseEvent *_ev );
127
128 TQt::PenStyle penStyle;
129 TQColor penColor;
130 int penWidth;
131
132 bool selected;
133 bool undefined;
134};
135
136class GeneralTab : public TQWidget
137{
138 TQ_OBJECT
139
140
141 public:
142 GeneralTab( TQWidget * parent, CellFormatDialog * _dlg );
143 ~GeneralTab();
144
145 bool apply( CustomStyle * style );
146
147 protected slots:
148 void slotNewParent( const TQString & parentName );
149 void slotNameChanged();
150
151 private:
152 CellFormatDialog * m_dlg;
153 KComboBox * m_parentBox;
154 KLineEdit * m_nameEdit;
155
156 TQString m_name;
157 TQString m_parent;
158
159 bool checkParent( const TQString & parentName );
160 bool checkName();
161};
162
165class CellFormatPageFont : public FontTab
166{
167 TQ_OBJECT
168
169public:
170 CellFormatPageFont( TQWidget* parent, CellFormatDialog *_dlg );
171
172 void apply( CustomStyle * style );
173 void apply( FormatManipulator *_obj );
174
175signals:
180 void fontSelected( const TQFont &font );
181
182private slots:
183
184 void family_chosen_slot(const TQString & );
185 void size_chosen_slot(const TQString & );
186 void weight_chosen_slot(const TQString &);
187 void style_chosen_slot(const TQString &);
188 void underline_chosen_slot();
189 void strike_chosen_slot();
190 void display_example(const TQFont &font);
191 void slotSetTextColor( const TQColor &_color );
192
193private:
194
195 void setCombos();
196 TQColor textColor;
197 TQFont selFont;
198 bool fontChanged;
199 bool bTextColorUndefined;
200 CellFormatDialog *dlg;
201};
202
208class CellFormatPageFloat : public TQWidget
209{
210 TQ_OBJECT
211
212public:
213 CellFormatPageFloat( TQWidget *parent, CellFormatDialog *_dlg );
214 void apply( CustomStyle * style );
215 void apply( FormatManipulator *_obj );
216
217public slots:
218 void slotChangeState();
219 void makeformat();
220 void updateFormatType();
221 void init();
222 void slotChangeValue(int);
223 void formatChanged(int);
224 void currencyChanged(const TQString &);
225protected:
226 TQLineEdit* postfix;
227 KIntNumInput* precision;
228 TQLineEdit* prefix;
229 TQComboBox *format;
230 TQComboBox *currency;
231 TQLabel *currencyLabel;
232 TQRadioButton *generic;
233 TQRadioButton *number;
234 TQRadioButton *percent;
235 TQRadioButton *date;
236 TQRadioButton *money;
237 TQRadioButton *scientific;
238 TQRadioButton *fraction;
239 TQRadioButton *time;
240 TQRadioButton *textFormat;
241 TQRadioButton *customFormat;
242 TQListBox *listFormat;
243 TQLineEdit* customFormatEdit;
244 TQLabel *exampleLabel;
245 CellFormatDialog *dlg;
246 FormatType cellFormatType, newFormatType;
247 //test if value changed
248 bool m_bFormatTypeChanged;
249 bool m_bFormatColorChanged;
250};
251
252class CellFormatPagePosition : public PositionTab
253{
254 TQ_OBJECT
255
256public:
257 CellFormatPagePosition( TQWidget *parent, CellFormatDialog *_dlg );
258
259 void apply( CustomStyle * style );
260 void apply( FormatManipulator *_obj );
261
262 double getSizeHeight() const;
263 double getSizeWidth() const;
264 bool getMergedCellState() const;
265
266public slots:
267 void slotChangeHeightState();
268 void slotChangeWidthState();
269 void slotChangeAngle(int);
270 void slotStateChanged(int);
271 void slotChangeVerticalState();
272 void slotChangeMultiState();
273
274protected:
275 KoUnitDoubleSpinBox *width;
276 KoUnitDoubleSpinBox *height;
277 KoUnitDoubleSpinBox *m_indent;
278 CellFormatDialog *dlg;
279 bool m_bOptionText;
280};
281
282
283
284class Border : public TQFrame
285{
286 TQ_OBJECT
287
288public:
289 Border( TQWidget *parent,const char *_name,bool _oneCol,bool _oneRow );
290signals:
291 void redraw();
292 void choosearea(TQMouseEvent * _ev);
293protected:
294 virtual void paintEvent( TQPaintEvent *_ev );
295 virtual void mousePressEvent( TQMouseEvent* _ev );
296 bool oneCol;
297 bool oneRow;
298};
299
300class BorderButton : public TQPushButton
301{
302 TQ_OBJECT
303
304public:
305 BorderButton( TQWidget *parent, const char *_name );
306 void setPenStyle( TQt::PenStyle _pat ) { penStyle = _pat;}
307 TQt::PenStyle getPenStyle() { return penStyle; }
308 void setColor( const TQColor &_col ) { penColor = _col; }
309 const TQColor& getColor() { return penColor; }
310 void setPenWidth( int _w ) { penWidth = _w; }
311 int getPenWidth() { return penWidth; }
312 bool isChanged() { return changed; }
313 void setChanged(bool _changed ) { changed=_changed;}
314 void setUndefined();
315 void unselect();
316 signals:
317 void clicked(BorderButton *);
318 protected:
319 virtual void mousePressEvent( TQMouseEvent *_ev );
320 TQt::PenStyle penStyle;
321 TQColor penColor;
322 int penWidth;
323 bool changed;
324
325};
326
327class CellFormatPageBorder : public TQWidget
328{
329 TQ_OBJECT
330
331public:
332 CellFormatPageBorder( TQWidget *parent, CellFormatDialog *_dlg );
333
334 void apply(FormatManipulator* obj);
335 void invertState(BorderButton *_button);
336 TQPixmap paintFormatPixmap(PenStyle _style);
337
338public slots:
339 void changeState(BorderButton *_this);
340 void preselect( BorderButton *_this);
341 void draw();
342 void slotSetColorButton( const TQColor &_color );
343 void slotUnselect2( PatternSelect *_select );
344 void loadIcon( TQString pix,BorderButton *_button);
345 void slotPressEvent(TQMouseEvent *_ev);
346 void slotChangeStyle(int );
347 void slotChangeStyle(const TQString & );
348 void cutomize_chosen_slot();
349
350protected:
351
352 Sheet* sheet;
353 BorderButton* borderButtons[BorderType_END];
354 BorderButton* shortcutButtons[BorderShortcutType_END];
355#define NUM_BORDER_PATTERNS 10
356
357 /* the patterns to choose from */
358 PatternSelect* pattern[NUM_BORDER_PATTERNS];
359
360 /* the pattern box that is the 'preview' of what is selected above. */
361 PatternSelect* preview;
362 TQComboBox* size;
363 TQComboBox* style;
364 KColorButton* color;
365 TQCheckBox* customize;
366 TQColor currentColor;
367 Border *area;
368 CellFormatDialog *dlg;
369private:
370
371 /*some helper functions to space some tasks apart */
372 void InitializeGrids();
373 void InitializeBorderButtons();
374 void InitializePatterns();
375 void SetConnections();
376 void applyTopOutline(FormatManipulator* obj);
377 void applyBottomOutline(FormatManipulator* obj);
378 void applyLeftOutline(FormatManipulator* obj);
379 void applyRightOutline(FormatManipulator* obj);
380 void applyVerticalOutline(FormatManipulator* obj);
381 void applyHorizontalOutline(FormatManipulator* obj);
382 void applyDiagonalOutline(FormatManipulator* obj);
383};
384
385class BrushSelect : public TQFrame
386{
387 TQ_OBJECT
388
389public:
390 BrushSelect( TQWidget *parent, const char *_name );
391
392 void setBrushStyle( TQt::BrushStyle _pat ) { brushStyle = _pat; repaint(); }
393 TQt::BrushStyle getBrushStyle() const { return brushStyle; }
394 TQColor getBrushColor() const { return brushColor; }
395 void setBrushColor(const TQColor &_c) { brushColor=_c;}
396 void setPattern( const TQColor &_color, TQt::BrushStyle _style );
397
398signals:
399 void clicked( BrushSelect *_this );
400
401public slots:
402 void slotUnselect();
403 void slotSelect();
404
405protected:
406 virtual void paintEvent( TQPaintEvent *_ev );
407 virtual void mousePressEvent( TQMouseEvent *_ev );
408
409 TQt::BrushStyle brushStyle;
410 TQColor brushColor;
411 bool selected;
412};
413
414
415class CellFormatPagePattern : public TQWidget
416{
417 TQ_OBJECT
418
419public:
420 CellFormatPagePattern( TQWidget *parent, CellFormatDialog *_dlg );
421
422 void apply( CustomStyle * style );
423 void apply( FormatManipulator *_obj );
424
425 void init();
426public slots:
427 void slotUnselect2( BrushSelect *_select );
428 void slotSetColorButton( const TQColor &_color );
429 void slotSetBackgroundColor( const TQColor &_color );
430 void slotNotAnyColor( );
431protected:
432 BrushSelect *selectedBrush;
433 BrushSelect *brush1;
434 BrushSelect *brush2;
435 BrushSelect *brush3;
436 BrushSelect *brush4;
437 BrushSelect *brush5;
438 BrushSelect *brush6;
439 BrushSelect *brush7;
440 BrushSelect *brush8;
441 BrushSelect *brush9;
442 BrushSelect *brush10;
443 BrushSelect *brush11;
444 BrushSelect *brush12;
445 BrushSelect *brush13;
446 BrushSelect *brush14;
447 BrushSelect *brush15;
448 BrushSelect *current;
449 KColorButton* color;
450 TQPushButton* notAnyColor;
451 TQColor currentColor;
452
453 TQColor bgColor;
454 bool bBgColorUndefined;
455 KColorButton *bgColorButton;
456 bool b_notAnyColor;
457 CellFormatDialog *dlg;
458};
459
460class CellFormatPageProtection : public ProtectionTab
461{
462 TQ_OBJECT
463
464
465 public:
466 CellFormatPageProtection( TQWidget * parent, CellFormatDialog * _dlg );
467 ~CellFormatPageProtection();
469 void apply( CustomStyle * style );
470 void apply( FormatManipulator * _obj );
471
472 protected:
473 CellFormatDialog * m_dlg;
474 bool m_isProtected;
475 bool m_hideFormula;
476 bool m_hideAll;
477 bool m_dontPrint;
478};
479
483class CellFormatDialog : public TQObject
484{
485 TQ_OBJECT
486
487public:
491 CellFormatDialog( View * _view, Sheet * _sheet );
492 CellFormatDialog( View * _view, CustomStyle * _style, StyleManager * _manager,
493 Doc * doc );
494
496
497 void init();
498 void initGUI();
499 void initMembers();
500
501 void initParameters(Format *_obj,int column,int row);
502 void checkBorderRight(Format *obj,int x,int y);
503 void checkBorderLeft(Format *obj,int x,int y);
504 void checkBorderTop(Format *obj,int x,int y);
505 void checkBorderBottom(Format *obj,int x,int y);
506 void checkBorderVertical(Format *obj,int x,int y);
507 void checkBorderHorizontal(Format *obj,int x,int y);
511 int exec();
512
513 Doc * getDoc() const { return m_doc; }
514 Sheet * getSheet() const { return m_sheet; }
515 CustomStyle * getStyle() const { return m_style; }
516 StyleManager * getStyleManager() const { return m_styleManager; }
517
518 bool isSingleCell() { return ( left == right && top == bottom ); }
519 bool checkCircle( TQString const & name, TQString const & parent );
520
521 TDELocale * locale() const { return m_pView->doc()->locale(); }
522
523
524 struct CellBorderFormat
525 {
526 int width;
527 bool bStyle;
528 TQColor color;
529 bool bColor;
530 TQt::PenStyle style;
531 };
532
533 // The format of the selected area
534 CellBorderFormat borders[BorderType_END];
535
536 TQt::BrushStyle brushStyle;
537 TQColor brushColor;
538
539 bool oneCol;
540 bool oneRow;
541
542 TQString prefix;
543 TQString postfix;
544 int precision;
545 Format::FloatFormat floatFormat;
546 bool bFloatFormat;
547 Format::FloatColor floatColor;
548 Format::Currency cCurrency;
549 bool bFloatColor;
550 bool bCurrency;
551 TQColor textColor;
552 bool bTextColor;
553 bool bTextFontBold;
554 bool textFontBold;
555 bool bTextFontItalic;
556 bool textFontItalic;
557 bool bTextFontSize;
558 int textFontSize;
559 bool bTextFontFamily;
560 TQString textFontFamily;
561 bool bStrike;
562 bool strike;
563 bool bUnderline;
564 bool underline;
565 TQFont textFont;
566 TQColor bgColor;
567 bool bBgColor;
568 TQString actionText;
569 Format::Align alignX;
570 Format::AlignY alignY;
571 TQString styleName;
572 TQString styleParent;
573
574 bool bMultiRow;
575 bool bVerticalText;
576
577 bool bDontPrintText;
578 bool bHideFormula;
579 bool bHideAll;
580 bool bIsProtected;
581
582 double defaultHeightSize;
583 double defaultWidthSize;
584 double heightSize;
585 double widthSize;
586
587 double indent;
588
589 TQPixmap* formatOnlyNegSignedPixmap;
590 TQPixmap* formatRedOnlyNegSignedPixmap;
591 TQPixmap* formatRedNeverSignedPixmap;
592 TQPixmap* formatAlwaysSignedPixmap;
593 TQPixmap* formatRedAlwaysSignedPixmap;
594
595 int textRotation;
596 bool bTextRotation;
597
598 FormatType formatType;
599 bool bFormatType;
600
601 Value value;
602
603 bool isMerged;
604 bool oneCell;
605
606 bool isRowSelected;
607 bool isColumnSelected;
608
609 // The rectangular area for which this dlg has been opened.
610 int left;
611 int right;
612 int top;
613 int bottom;
614
615
616public slots:
617 void slotApply();
618
619protected:
620
625 TQPixmap* paintFormatPixmap( const char *_string1, const TQColor & _color1,
626 const char *_string2, const TQColor & _color2 );
627
628 GeneralTab * generalPage;
629 CellFormatPageFloat *floatPage;
630 CellFormatPageBorder *borderPage;
631 CellFormatPageFont *fontPage;
632 CellFormatPagePosition *positionPage;
633 CellFormatPagePattern *patternPage;
634 CellFormatPageProtection *protectPage;
635 TQTabDialog *tab;
636
637 Doc * m_doc;
638 Sheet * m_sheet;
639 View * m_pView;
640 CustomStyle * m_style;
641 StyleManager * m_styleManager;
642
643 void applyStyle();
644};
645
646} // namespace KSpread
647
648#endif
Dialog for the "Cell Format..." action.
CellFormatDialog(View *_view, Sheet *_sheet)
Create a format dlg for the rectangular area in '_sheet'.
int exec()
Run the dialogs event loop and return when closed.
TQPixmap * paintFormatPixmap(const char *_string1, const TQColor &_color1, const char *_string2, const TQColor &_color2)
Draws a pixmap showing a text consisting of two parts, _string1 and _string2 .
Built-in or custom style defined in StyleManager dialog.
This class holds the data that makes up a spreadsheet.
Definition kspread_doc.h:98
FormatManipulator.
Provides a wrapper for cell value.
The View class displays a KSpread document.
The KSpread namespace.
Definition commands.h:39