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
00026
00027
00028
00029
00030 #ifndef __kspread_dlg_layout_h__
00031 #define __kspread_dlg_layout_h__
00032
00033
00034 #include <qtabdialog.h>
00035 #include <qapplication.h>
00036 #include <qbuttongroup.h>
00037 #include <qgroupbox.h>
00038 #include <knuminput.h>
00039 #include <kcompletion.h>
00040 #include "kspread_view.h"
00041 #include "kspread_format.h"
00042 #include "kspread_doc.h"
00043 #include "kspread_value.h"
00044 #include "position_cell_format.h"
00045 #include "font_cell_format.h"
00046 #include "protection_cell_format.h"
00047
00048 #include <qpushbutton.h>
00049 #include <qcheckbox.h>
00050
00051 class KoUnitDoubleSpinBox;
00052 class QPixmap;
00053 class QRadioButton;
00054 class QPushButton;
00055 class QDate;
00056 class QTime;
00057 class QLabel;
00058 class QWidget;
00059 class KLineEdit;
00060 class QFrame;
00061 class QListBox;
00062 class QCheckBox;
00063 class KColorButton;
00064 class QComboBox;
00065 class KComboBox;
00066 class KoUnitDoubleSpinBox;
00067
00068 namespace KSpread
00069 {
00070 class Sheet;
00071 class CustomStyle;
00072 class StyleManager;
00073 class CellFormatDialog;
00074 class FormatManipulator;
00075
00076 enum BorderType
00077 {
00078 BorderType_Top = 0,
00079 BorderType_Bottom,
00080 BorderType_Left,
00081 BorderType_Right,
00082 BorderType_Vertical,
00083 BorderType_Horizontal,
00084 BorderType_FallingDiagonal,
00085 BorderType_RisingDiagonal,
00086 BorderType_END
00087 };
00088
00089 enum BorderShortcutType
00090 {
00091 BorderShortcutType_Remove = 0,
00092 BorderShortcutType_All,
00093 BorderShortcutType_Outline,
00094 BorderShortcutType_END
00095 };
00096
00097 class PatternSelect : public QFrame
00098 {
00099 Q_OBJECT
00100 public:
00101 PatternSelect( QWidget *parent, const char *_name );
00102
00103 void setPenStyle( PenStyle _pat ) { penStyle = _pat; repaint(); }
00104 PenStyle getPenStyle() { return penStyle; }
00105 void setColor( const QColor &_col ) { penColor = _col; repaint(); }
00106 const QColor& getColor() { return penColor; }
00107 void setPenWidth( int _w ) { penWidth = _w; repaint(); }
00108 int getPenWidth() { return penWidth; }
00109
00110 void setPattern( const QColor &_color, int _width, PenStyle _style );
00111 void setUndefined();
00112 void setDefined() { undefined = FALSE; repaint(); }
00113
00114 bool isDefined() { return !undefined; }
00115
00116 signals:
00117 void clicked( PatternSelect *_this );
00118
00119 public slots:
00120 void slotUnselect();
00121 void slotSelect();
00122
00123 protected:
00124 virtual void paintEvent( QPaintEvent *_ev );
00125 virtual void mousePressEvent( QMouseEvent *_ev );
00126
00127 PenStyle penStyle;
00128 QColor penColor;
00129 int penWidth;
00130
00131 bool selected;
00132 bool undefined;
00133 };
00134
00135 class GeneralTab : public QWidget
00136 {
00137 Q_OBJECT
00138
00139 public:
00140 GeneralTab( QWidget * parent, CellFormatDialog * _dlg );
00141 ~GeneralTab();
00142
00143 bool apply( CustomStyle * style );
00144
00145 protected slots:
00146 void slotNewParent( const QString & parentName );
00147 void slotNameChanged();
00148
00149 private:
00150 CellFormatDialog * m_dlg;
00151 KComboBox * m_parentBox;
00152 KLineEdit * m_nameEdit;
00153
00154 QString m_name;
00155 QString m_parent;
00156
00157 bool checkParent( const QString & parentName );
00158 bool checkName();
00159 };
00160
00163 class CellFormatPageFont : public FontTab
00164 {
00165 Q_OBJECT
00166 public:
00167 CellFormatPageFont( QWidget* parent, CellFormatDialog *_dlg );
00168
00169 void apply( CustomStyle * style );
00170 void apply( FormatManipulator *_obj );
00171
00172 signals:
00177 void fontSelected( const QFont &font );
00178
00179 private slots:
00180
00181 void family_chosen_slot(const QString & );
00182 void size_chosen_slot(const QString & );
00183 void weight_chosen_slot(const QString &);
00184 void style_chosen_slot(const QString &);
00185 void underline_chosen_slot();
00186 void strike_chosen_slot();
00187 void display_example(const QFont &font);
00188 void slotSetTextColor( const QColor &_color );
00189
00190 private:
00191
00192 void setCombos();
00193 QColor textColor;
00194 QFont selFont;
00195 bool fontChanged;
00196 bool bTextColorUndefined;
00197 CellFormatDialog *dlg;
00198 };
00199
00205 class CellFormatPageFloat : public QWidget
00206 {
00207 Q_OBJECT
00208 public:
00209 CellFormatPageFloat( QWidget *parent, CellFormatDialog *_dlg );
00210 void apply( CustomStyle * style );
00211 void apply( FormatManipulator *_obj );
00212
00213 public slots:
00214 void slotChangeState();
00215 void makeformat();
00216 void updateFormatType();
00217 void init();
00218 void slotChangeValue(int);
00219 void formatChanged(int);
00220 void currencyChanged(const QString &);
00221 protected:
00222 QLineEdit* postfix;
00223 KIntNumInput* precision;
00224 QLineEdit* prefix;
00225 QComboBox *format;
00226 QComboBox *currency;
00227 QLabel *currencyLabel;
00228 QRadioButton *generic;
00229 QRadioButton *number;
00230 QRadioButton *percent;
00231 QRadioButton *date;
00232 QRadioButton *money;
00233 QRadioButton *scientific;
00234 QRadioButton *fraction;
00235 QRadioButton *time;
00236 QRadioButton *textFormat;
00237 QRadioButton *customFormat;
00238 QListBox *listFormat;
00239 QLineEdit* customFormatEdit;
00240 QLabel *exampleLabel;
00241 CellFormatDialog *dlg;
00242 FormatType cellFormatType, newFormatType;
00243
00244 bool m_bFormatTypeChanged;
00245 bool m_bFormatColorChanged;
00246 };
00247
00248 class CellFormatPagePosition : public PositionTab
00249 {
00250 Q_OBJECT
00251 public:
00252 CellFormatPagePosition( QWidget *parent, CellFormatDialog *_dlg );
00253
00254 void apply( CustomStyle * style );
00255 void apply( FormatManipulator *_obj );
00256
00257 double getSizeHeight() const;
00258 double getSizeWidth() const;
00259 bool getMergedCellState() const;
00260
00261 public slots:
00262 void slotChangeHeightState();
00263 void slotChangeWidthState();
00264 void slotChangeAngle(int);
00265 void slotStateChanged(int);
00266 void slotChangeVerticalState();
00267 void slotChangeMultiState();
00268
00269 protected:
00270 KoUnitDoubleSpinBox *width;
00271 KoUnitDoubleSpinBox *height;
00272 KoUnitDoubleSpinBox *m_indent;
00273 CellFormatDialog *dlg;
00274 bool m_bOptionText;
00275 };
00276
00277
00278
00279 class Border : public QFrame
00280 {
00281 Q_OBJECT
00282 public:
00283 Border( QWidget *parent,const char *_name,bool _oneCol,bool _oneRow );
00284 signals:
00285 void redraw();
00286 void choosearea(QMouseEvent * _ev);
00287 protected:
00288 virtual void paintEvent( QPaintEvent *_ev );
00289 virtual void mousePressEvent( QMouseEvent* _ev );
00290 bool oneCol;
00291 bool oneRow;
00292 };
00293
00294 class BorderButton : public QPushButton
00295 {
00296 Q_OBJECT
00297 public:
00298 BorderButton( QWidget *parent, const char *_name );
00299 void setPenStyle( PenStyle _pat ) { penStyle = _pat;}
00300 PenStyle getPenStyle() { return penStyle; }
00301 void setColor( const QColor &_col ) { penColor = _col; }
00302 const QColor& getColor() { return penColor; }
00303 void setPenWidth( int _w ) { penWidth = _w; }
00304 int getPenWidth() { return penWidth; }
00305 bool isChanged() { return changed; }
00306 void setChanged(bool _changed ) { changed=_changed;}
00307 void setUndefined();
00308 void unselect();
00309 signals:
00310 void clicked(BorderButton *);
00311 protected:
00312 virtual void mousePressEvent( QMouseEvent *_ev );
00313 PenStyle penStyle;
00314 QColor penColor;
00315 int penWidth;
00316 bool changed;
00317
00318 };
00319
00320 class CellFormatPageBorder : public QWidget
00321 {
00322 Q_OBJECT
00323 public:
00324 CellFormatPageBorder( QWidget *parent, CellFormatDialog *_dlg );
00325
00326 void apply(FormatManipulator* obj);
00327 void invertState(BorderButton *_button);
00328 QPixmap paintFormatPixmap(PenStyle _style);
00329
00330 public slots:
00331 void changeState(BorderButton *_this);
00332 void preselect( BorderButton *_this);
00333 void draw();
00334 void slotSetColorButton( const QColor &_color );
00335 void slotUnselect2( PatternSelect *_select );
00336 void loadIcon( QString pix,BorderButton *_button);
00337 void slotPressEvent(QMouseEvent *_ev);
00338 void slotChangeStyle(int );
00339 void slotChangeStyle(const QString & );
00340 void cutomize_chosen_slot();
00341
00342 protected:
00343
00344 Sheet* sheet;
00345 BorderButton* borderButtons[BorderType_END];
00346 BorderButton* shortcutButtons[BorderShortcutType_END];
00347 #define NUM_BORDER_PATTERNS 10
00348
00349
00350 PatternSelect* pattern[NUM_BORDER_PATTERNS];
00351
00352
00353 PatternSelect* preview;
00354 QComboBox* size;
00355 QComboBox* style;
00356 KColorButton* color;
00357 QCheckBox* customize;
00358 QColor currentColor;
00359 Border *area;
00360 CellFormatDialog *dlg;
00361 private:
00362
00363
00364 void InitializeGrids();
00365 void InitializeBorderButtons();
00366 void InitializePatterns();
00367 void SetConnections();
00368 void applyTopOutline(FormatManipulator* obj);
00369 void applyBottomOutline(FormatManipulator* obj);
00370 void applyLeftOutline(FormatManipulator* obj);
00371 void applyRightOutline(FormatManipulator* obj);
00372 void applyVerticalOutline(FormatManipulator* obj);
00373 void applyHorizontalOutline(FormatManipulator* obj);
00374 void applyDiagonalOutline(FormatManipulator* obj);
00375 };
00376
00377 class BrushSelect : public QFrame
00378 {
00379 Q_OBJECT
00380 public:
00381 BrushSelect( QWidget *parent, const char *_name );
00382
00383 void setBrushStyle( BrushStyle _pat ) { brushStyle = _pat; repaint(); }
00384 BrushStyle getBrushStyle() const { return brushStyle; }
00385 QColor getBrushColor() const { return brushColor; }
00386 void setBrushColor(const QColor &_c) { brushColor=_c;}
00387 void setPattern( const QColor &_color, BrushStyle _style );
00388
00389 signals:
00390 void clicked( BrushSelect *_this );
00391
00392 public slots:
00393 void slotUnselect();
00394 void slotSelect();
00395
00396 protected:
00397 virtual void paintEvent( QPaintEvent *_ev );
00398 virtual void mousePressEvent( QMouseEvent *_ev );
00399
00400 BrushStyle brushStyle;
00401 QColor brushColor;
00402 bool selected;
00403 };
00404
00405
00406 class CellFormatPagePattern : public QWidget
00407 {
00408 Q_OBJECT
00409 public:
00410 CellFormatPagePattern( QWidget *parent, CellFormatDialog *_dlg );
00411
00412 void apply( CustomStyle * style );
00413 void apply( FormatManipulator *_obj );
00414
00415 void init();
00416 public slots:
00417 void slotUnselect2( BrushSelect *_select );
00418 void slotSetColorButton( const QColor &_color );
00419 void slotSetBackgroundColor( const QColor &_color );
00420 void slotNotAnyColor( );
00421 protected:
00422 BrushSelect *selectedBrush;
00423 BrushSelect *brush1;
00424 BrushSelect *brush2;
00425 BrushSelect *brush3;
00426 BrushSelect *brush4;
00427 BrushSelect *brush5;
00428 BrushSelect *brush6;
00429 BrushSelect *brush7;
00430 BrushSelect *brush8;
00431 BrushSelect *brush9;
00432 BrushSelect *brush10;
00433 BrushSelect *brush11;
00434 BrushSelect *brush12;
00435 BrushSelect *brush13;
00436 BrushSelect *brush14;
00437 BrushSelect *brush15;
00438 BrushSelect *current;
00439 KColorButton* color;
00440 QPushButton* notAnyColor;
00441 QColor currentColor;
00442
00443 QColor bgColor;
00444 bool bBgColorUndefined;
00445 KColorButton *bgColorButton;
00446 bool b_notAnyColor;
00447 CellFormatDialog *dlg;
00448 };
00449
00450 class CellFormatPageProtection : public ProtectionTab
00451 {
00452 Q_OBJECT
00453
00454 public:
00455 CellFormatPageProtection( QWidget * parent, CellFormatDialog * _dlg );
00456 ~CellFormatPageProtection();
00458 void apply( CustomStyle * style );
00459 void apply( FormatManipulator * _obj );
00460
00461 protected:
00462 CellFormatDialog * m_dlg;
00463 bool m_isProtected;
00464 bool m_hideFormula;
00465 bool m_hideAll;
00466 bool m_dontPrint;
00467 };
00468
00472 class CellFormatDialog : public QObject
00473 {
00474 Q_OBJECT
00475 public:
00479 CellFormatDialog( View * _view, Sheet * _sheet );
00480 CellFormatDialog( View * _view, CustomStyle * _style, StyleManager * _manager,
00481 Doc * doc );
00482
00483 ~CellFormatDialog();
00484
00485 void init();
00486 void initGUI();
00487 void initMembers();
00488
00489 void initParameters(Format *_obj,int column,int row);
00490 void checkBorderRight(Format *obj,int x,int y);
00491 void checkBorderLeft(Format *obj,int x,int y);
00492 void checkBorderTop(Format *obj,int x,int y);
00493 void checkBorderBottom(Format *obj,int x,int y);
00494 void checkBorderVertical(Format *obj,int x,int y);
00495 void checkBorderHorizontal(Format *obj,int x,int y);
00499 int exec();
00500
00501 Doc * getDoc() const { return m_doc; }
00502 Sheet * getSheet() const { return m_sheet; }
00503 CustomStyle * getStyle() const { return m_style; }
00504 StyleManager * getStyleManager() const { return m_styleManager; }
00505
00506 bool isSingleCell() { return ( left == right && top == bottom ); }
00507 bool checkCircle( QString const & name, QString const & parent );
00508
00509 KLocale * locale() const { return m_pView->doc()->locale(); }
00510
00511
00512 struct CellBorderFormat
00513 {
00514 int width;
00515 bool bStyle;
00516 QColor color;
00517 bool bColor;
00518 PenStyle style;
00519 };
00520
00521
00522 CellBorderFormat borders[BorderType_END];
00523
00524 BrushStyle brushStyle;
00525 QColor brushColor;
00526
00527 bool oneCol;
00528 bool oneRow;
00529
00530 QString prefix;
00531 QString postfix;
00532 int precision;
00533 Format::FloatFormat floatFormat;
00534 bool bFloatFormat;
00535 Format::FloatColor floatColor;
00536 Format::Currency cCurrency;
00537 bool bFloatColor;
00538 bool bCurrency;
00539 QColor textColor;
00540 bool bTextColor;
00541 bool bTextFontBold;
00542 bool textFontBold;
00543 bool bTextFontItalic;
00544 bool textFontItalic;
00545 bool bTextFontSize;
00546 int textFontSize;
00547 bool bTextFontFamily;
00548 QString textFontFamily;
00549 bool bStrike;
00550 bool strike;
00551 bool bUnderline;
00552 bool underline;
00553 QFont textFont;
00554 QColor bgColor;
00555 bool bBgColor;
00556 QString actionText;
00557 Format::Align alignX;
00558 Format::AlignY alignY;
00559 QString styleName;
00560 QString styleParent;
00561
00562 bool bMultiRow;
00563 bool bVerticalText;
00564
00565 bool bDontPrintText;
00566 bool bHideFormula;
00567 bool bHideAll;
00568 bool bIsProtected;
00569
00570 double defaultHeightSize;
00571 double defaultWidthSize;
00572 double heightSize;
00573 double widthSize;
00574
00575 double indent;
00576
00577 QPixmap* formatOnlyNegSignedPixmap;
00578 QPixmap* formatRedOnlyNegSignedPixmap;
00579 QPixmap* formatRedNeverSignedPixmap;
00580 QPixmap* formatAlwaysSignedPixmap;
00581 QPixmap* formatRedAlwaysSignedPixmap;
00582
00583 int textRotation;
00584 bool bTextRotation;
00585
00586 FormatType formatType;
00587 bool bFormatType;
00588
00589 Value value;
00590
00591 bool isMerged;
00592 bool oneCell;
00593
00594 bool isRowSelected;
00595 bool isColumnSelected;
00596
00597
00598 int left;
00599 int right;
00600 int top;
00601 int bottom;
00602
00603
00604 public slots:
00605 void slotApply();
00606
00607 protected:
00608
00613 QPixmap* paintFormatPixmap( const char *_string1, const QColor & _color1,
00614 const char *_string2, const QColor & _color2 );
00615
00616 GeneralTab * generalPage;
00617 CellFormatPageFloat *floatPage;
00618 CellFormatPageBorder *borderPage;
00619 CellFormatPageFont *fontPage;
00620 CellFormatPagePosition *positionPage;
00621 CellFormatPagePattern *patternPage;
00622 CellFormatPageProtection *protectPage;
00623 QTabDialog *tab;
00624
00625 Doc * m_doc;
00626 Sheet * m_sheet;
00627 View * m_pView;
00628 CustomStyle * m_style;
00629 StyleManager * m_styleManager;
00630
00631 void applyStyle();
00632 };
00633
00634 }
00635
00636 #endif