kspread Library API Documentation

kspread_dlg_layout.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 2002-2004 Ariya Hidayat <ariya@kde.org>
00003              (C) 2002-2003 Norbert Andres <nandres@web.de>
00004              (C) 2001-2003 Philipp Mueller <philipp.mueller@gmx.de>
00005              (C) 2002 John Dailey <dailey@vt.edu>
00006              (C) 1999-2002 Laurent Montel <montel@kde.org>
00007              (C) 1999-2002 Harri Porten <porten@kde.org>
00008              (C) 2000-2001 David Faure <faure@kde.org>
00009              (C) 1998-2000 Torben Weis <weis@kde.org>
00010              (C) 2000 Werner Trobin <trobin@kde.org>
00011              (C) 1999 Reginald Stadlbauer <reggie@kde.org>
00012              (C) 1998-1999 Stephan Kulow <coolo@kde.org>
00013 
00014    This library is free software; you can redistribute it and/or
00015    modify it under the terms of the GNU Library General Public
00016    License as published by the Free Software Foundation; either
00017    version 2 of the License, or (at your option) any later version.
00018 
00019    This library is distributed in the hope that it will be useful,
00020    but WITHOUT ANY WARRANTY; without even the implied warranty of
00021    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00022    Library General Public License for more details.
00023 
00024    You should have received a copy of the GNU Library General Public License
00025    along with this library; see the file COPYING.LIB.  If not, write to
00026    the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00027    Boston, MA 02111-1307, USA.
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_cell.h"
00042 #include "kspread_doc.h"
00043 #include "kspread_value.h"
00044 
00045 #include <qpushbutton.h>
00046 #include <qcheckbox.h>
00047 
00048 class QPixmap;
00049 class QRadioButton;
00050 class QPushButton;
00051 class QDate;
00052 class QTime;
00053 class QLabel;
00054 class QWidget;
00055 class CellFormatDlg;
00056 class KSpreadSheet;
00057 class KLineEdit;
00058 class QFrame;
00059 class QListBox;
00060 class QCheckBox;
00061 class KColorButton;
00062 class QComboBox;
00063 class KComboBox;
00064 
00065 class KSpreadCustomStyle;
00066 class KSpreadStyleManager;
00067 
00068 enum BorderType
00069 {
00070   BorderType_Top = 0,
00071   BorderType_Bottom,
00072   BorderType_Left,
00073   BorderType_Right,
00074   BorderType_Vertical,
00075   BorderType_Horizontal,
00076   BorderType_FallingDiagonal,
00077   BorderType_RisingDiagonal,
00078   BorderType_END
00079 };
00080 
00081 enum BorderShortcutType
00082 {
00083   BorderShortcutType_Remove = 0,
00084   BorderShortcutType_All,
00085   BorderShortcutType_Outline,
00086   BorderShortcutType_END
00087 };
00088 class KSpreadPatternSelect : public QFrame
00089 {
00090     Q_OBJECT
00091 public:
00092     KSpreadPatternSelect( QWidget *parent, const char *_name );
00093 
00094     void setPenStyle( PenStyle _pat ) { penStyle = _pat; repaint(); }
00095     PenStyle getPenStyle() { return penStyle; }
00096     void setColor( const QColor &_col ) { penColor = _col; repaint(); }
00097     const QColor& getColor() { return penColor; }
00098     void setPenWidth( int _w ) { penWidth = _w; repaint(); }
00099     int getPenWidth() { return penWidth; }
00100 
00101     void setPattern( const QColor &_color, int _width, PenStyle _style );
00102     void setUndefined();
00103     void setDefined() { undefined = FALSE; repaint(); }
00104 
00105     bool isDefined() { return !undefined; }
00106 
00107 signals:
00108     void clicked( KSpreadPatternSelect *_this );
00109 
00110 public slots:
00111     void slotUnselect();
00112     void slotSelect();
00113 
00114 protected:
00115     virtual void paintEvent( QPaintEvent *_ev );
00116     virtual void mousePressEvent( QMouseEvent *_ev );
00117 
00118     PenStyle penStyle;
00119     QColor penColor;
00120     int penWidth;
00121 
00122     bool selected;
00123     bool undefined;
00124 };
00125 
00126 class GeneralTab : public QWidget
00127 {
00128   Q_OBJECT
00129 
00130  public:
00131   GeneralTab( QWidget * parent, CellFormatDlg * _dlg );
00132   ~GeneralTab();
00133 
00134   bool apply( KSpreadCustomStyle * style );
00135 
00136  protected slots:
00137   void slotNewParent( const QString & parentName );
00138   void slotNameChanged();
00139 
00140  private:
00141   CellFormatDlg * m_dlg;
00142   KComboBox     * m_parentBox;
00143   KLineEdit     * m_nameEdit;
00144 
00145   QString m_name;
00146   QString m_parent;
00147 
00148   bool checkParent( const QString & parentName );
00149   bool checkName();
00150 };
00151 
00154 class CellFormatPageFont : public QWidget
00155 {
00156     Q_OBJECT
00157 public:
00158     CellFormatPageFont( QWidget* parent, CellFormatDlg *_dlg );
00159 
00160     void apply( KSpreadCustomStyle * style );
00161     void apply( KSpreadCell *_cell );
00162     void apply( ColumnFormat *_col );
00163     void apply( RowFormat *_row );
00164     void applyFormat( KSpreadFormat *_obj );
00165 
00166 signals:
00171     void fontSelected( const QFont &font );
00172 
00173 private slots:
00174 
00175     void      family_chosen_slot(const QString & );
00176     void      size_chosen_slot(const QString & );
00177     void      weight_chosen_slot(const QString &);
00178     void      style_chosen_slot(const QString &);
00179     void      underline_chosen_slot();
00180     void      strike_chosen_slot();
00181     void      display_example(const QFont &font);
00182     void      slotSetTextColor( const QColor &_color );
00183     void      slotSearchFont(const QString &);
00184 
00185 private:
00186 
00187     void setCombos();
00188 
00189     QGroupBox    *box1;
00190     QGroupBox    *box2;
00191 
00192     QLabel   *family_label;
00193     QLabel   *size_label;
00194     QLabel       *weight_label;
00195     QLabel       *style_label;
00196 
00197     QLabel   *actual_family_label;
00198     QLabel   *actual_size_label;
00199     QLabel       *actual_weight_label;
00200     QLabel       *actual_style_label;
00201 
00202     QLabel   *actual_family_label_data;
00203     QLabel   *actual_size_label_data;
00204     QLabel       *actual_weight_label_data;
00205     QLabel       *actual_style_label_data;
00206 
00207     //QComboBox    *family_combo;
00208     QListBox     *family_combo;
00209     QComboBox    *size_combo;
00210     QComboBox    *weight_combo;
00211     QComboBox    *style_combo;
00212 
00213     QLabel       *example_label;
00214     QFont         selFont;
00215     QCheckBox* strike;
00216     QCheckBox* underline;
00217     CellFormatDlg *dlg;
00218     QColor textColor;
00219     bool bTextColorUndefined;
00220     KColorButton *textColorButton;
00221     KLineEdit *searchFont;
00222     KCompletion listFont;
00223     bool fontChanged;
00224 };
00225 
00226 class CellFormatPageMisc : public QWidget
00227 {
00228     Q_OBJECT
00229 public:
00230     CellFormatPageMisc( QWidget *parent, CellFormatDlg *_dlg );
00231 
00232     void apply( KSpreadCustomStyle * style );
00233     void apply( KSpreadCell *_cell );
00234     void applyColumn();
00235     void applyRow();
00236     void applyFormat( KSpreadCell *_obj );
00237     bool getDontPrintTextValue(){return dontPrintText->isChecked();}
00238 
00239 public slots:
00240     void slotStyle( int );
00241 protected:
00242     QComboBox* styleButton;
00243     int idStyleNormal;
00244     int idStyleUndef;
00245     int idStyleButton;
00246     int idStyleSelect;
00247 
00248     QLineEdit* actionText;
00249     QCheckBox *dontPrintText;
00250     CellFormatDlg *dlg;
00251 };
00252 
00258 class CellFormatPageFloat : public QWidget
00259 {
00260     Q_OBJECT
00261 public:
00262     CellFormatPageFloat( QWidget *parent, CellFormatDlg *_dlg );
00263 
00264     void apply( KSpreadCustomStyle * style );
00265     void apply( KSpreadCell *_cell );
00266     void apply( ColumnFormat *_col );
00267     void apply( RowFormat *_row );
00268     void applyFormat( KSpreadFormat *_obj );
00269 
00270 public slots:
00271     void slotChangeState();
00272     void makeformat();
00273     void updateFormatType();
00274     void init();
00275     void slotChangeValue(int);
00276     void formatChanged(int);
00277     void currencyChanged(const QString &);
00278 protected:
00279     QLineEdit* postfix;
00280     KIntNumInput* precision;
00281     QLineEdit* prefix;
00282     QComboBox *format;
00283     QComboBox *currency;
00284     QLabel    *currencyLabel;
00285     QRadioButton *generic;
00286     QRadioButton *number;
00287     QRadioButton *percent;
00288     QRadioButton *date;
00289     QRadioButton *money;
00290     QRadioButton *scientific;
00291     QRadioButton *fraction;
00292     QRadioButton *time;
00293     QRadioButton *textFormat;
00294     QRadioButton *customFormat;
00295     QListBox *listFormat;
00296     QLineEdit* customFormatEdit;
00297     QLabel *exampleLabel;
00298     CellFormatDlg *dlg;
00299     FormatType cellFormatType, newFormatType;
00300     //test if value changed
00301     bool m_bFormatTypeChanged;
00302     bool m_bFormatColorChanged;
00303 };
00304 
00305 
00306 
00307 class CellFormatPagePosition : public QWidget
00308 {
00309     Q_OBJECT
00310 public:
00311     CellFormatPagePosition( QWidget *parent, CellFormatDlg *_dlg );
00312 
00313     void apply( KSpreadCustomStyle * style );
00314     void apply( KSpreadCell *_cell );
00315     void apply( ColumnFormat *_col );
00316     void apply( RowFormat *_row );
00317     void applyFormat( KSpreadFormat *_obj );
00318 
00319     double getSizeHeight();
00320     double getSizeWidth();
00321     bool getMergedCellState();
00322 
00323 public slots:
00324     void slotChangeHeightState();
00325     void slotChangeWidthState();
00326     void slotChangeAngle(int);
00327     void slotStateChanged(int);
00328     void slotChangeVerticalState();
00329     void slotChangeMultiState();
00330 
00331 protected:
00332     QRadioButton *bottom;
00333     QRadioButton *top;
00334     QRadioButton *middle;
00335     QRadioButton *left;
00336     QRadioButton *right;
00337     QRadioButton *center;
00338     QRadioButton *standard;
00339     QCheckBox *multi;
00340     QCheckBox *vertical;
00341     KDoubleNumInput *width;
00342     KDoubleNumInput *height;
00343     CellFormatDlg *dlg;
00344     QCheckBox *defaultWidth;
00345     QCheckBox *defaultHeight;
00346     QCheckBox *mergeCell;
00347     KIntNumInput *angleRotation;
00348     KDoubleNumInput *m_indent;
00349     bool m_bOptionText;
00350 };
00351 
00352 
00353 
00354 class KSpreadBorder : public QFrame
00355 {
00356     Q_OBJECT
00357 public:
00358     KSpreadBorder( QWidget *parent,const char *_name,bool _oneCol,bool _oneRow  );
00359 signals:
00360     void redraw();
00361     void choosearea(QMouseEvent * _ev);
00362 protected:
00363     virtual void paintEvent( QPaintEvent *_ev );
00364     virtual void mousePressEvent( QMouseEvent* _ev );
00365     bool oneCol;
00366     bool oneRow;
00367 };
00368 
00369 class KSpreadBorderButton : public QPushButton
00370 {
00371     Q_OBJECT
00372 public:
00373     KSpreadBorderButton( QWidget *parent, const char *_name );
00374     void setPenStyle( PenStyle _pat ) { penStyle = _pat;}
00375     PenStyle getPenStyle() { return penStyle; }
00376     void setColor( const QColor &_col ) { penColor = _col; }
00377     const QColor& getColor() { return penColor; }
00378     void setPenWidth( int _w ) { penWidth = _w; }
00379     int getPenWidth() { return penWidth; }
00380     bool isChanged() { return changed; }
00381     void setChanged(bool _changed ) { changed=_changed;}
00382     void setUndefined();
00383     void unselect();
00384  signals:
00385     void clicked(KSpreadBorderButton *);
00386  protected:
00387     virtual void mousePressEvent( QMouseEvent *_ev );
00388     PenStyle penStyle;
00389     QColor penColor;
00390     int penWidth;
00391     bool changed;
00392 
00393 };
00394 
00395 class CellFormatPageBorder : public QWidget
00396 {
00397   Q_OBJECT
00398 public:
00399     CellFormatPageBorder( QWidget *parent, CellFormatDlg *_dlg );
00400 
00401     void applyOutline();
00402     void invertState(KSpreadBorderButton *_button);
00403     QPixmap paintFormatPixmap(PenStyle _style);
00404 
00405 public slots:
00406     void changeState(KSpreadBorderButton *_this);
00407     void preselect( KSpreadBorderButton *_this);
00408     void draw();
00409     void slotSetColorButton( const QColor &_color );
00410     void slotUnselect2( KSpreadPatternSelect *_select );
00411     void loadIcon( QString pix,KSpreadBorderButton *_button);
00412     void slotPressEvent(QMouseEvent *_ev);
00413     void slotChangeStyle(int );
00414     void slotChangeStyle(const QString & );
00415     void cutomize_chosen_slot();
00416 
00417 protected:
00418 
00419   KSpreadSheet* sheet;
00420   KSpreadBorderButton* borderButtons[BorderType_END];
00421   KSpreadBorderButton* shortcutButtons[BorderShortcutType_END];
00422 #define NUM_BORDER_PATTERNS 10
00423 
00424   /* the patterns to choose from */
00425   KSpreadPatternSelect* pattern[NUM_BORDER_PATTERNS];
00426 
00427   /* the pattern box that is the 'preview' of what is selected above. */
00428   KSpreadPatternSelect* preview;
00429   QComboBox* size;
00430   QComboBox* style;
00431   KColorButton* color;
00432   QCheckBox* customize;
00433   QColor currentColor;
00434   KSpreadBorder *area;
00435   CellFormatDlg *dlg;
00436 private:
00437 
00438   /*some helper functions to space some tasks apart */
00439   void InitializeGrids();
00440   void InitializeBorderButtons();
00441   void InitializePatterns();
00442   void SetConnections();
00443   void applyTopOutline();
00444   void applyBottomOutline();
00445   void applyLeftOutline();
00446   void applyRightOutline();
00447   void applyVerticalOutline();
00448   void applyHorizontalOutline();
00449   void applyDiagonalOutline();
00450 };
00451 
00452 class KSpreadBrushSelect : public QFrame
00453 {
00454     Q_OBJECT
00455 public:
00456     KSpreadBrushSelect( QWidget *parent, const char *_name );
00457 
00458     void setBrushStyle( BrushStyle _pat ) { brushStyle = _pat; repaint(); }
00459     BrushStyle getBrushStyle() const { return brushStyle; }
00460     QColor getBrushColor() const { return brushColor; }
00461     void setBrushColor(const QColor &_c) { brushColor=_c;}
00462     void setPattern( const QColor &_color, BrushStyle _style );
00463 
00464 signals:
00465     void clicked( KSpreadBrushSelect *_this );
00466 
00467 public slots:
00468     void slotUnselect();
00469     void slotSelect();
00470 
00471 protected:
00472     virtual void paintEvent( QPaintEvent *_ev );
00473     virtual void mousePressEvent( QMouseEvent *_ev );
00474 
00475     BrushStyle brushStyle;
00476     QColor brushColor;
00477     bool selected;
00478 };
00479 
00480 
00481 class CellFormatPagePattern : public QWidget
00482 {
00483     Q_OBJECT
00484 public:
00485     CellFormatPagePattern( QWidget *parent, CellFormatDlg *_dlg );
00486 
00487     void apply( KSpreadCustomStyle * style );
00488     void apply( KSpreadCell *_cell );
00489     void apply( ColumnFormat *_col );
00490     void apply( RowFormat *_row );
00491     void applyFormat( KSpreadFormat *_obj );
00492 
00493     void init();
00494 public slots:
00495     void slotUnselect2( KSpreadBrushSelect *_select );
00496     void slotSetColorButton( const QColor &_color );
00497     void slotSetBackgroundColor( const QColor &_color );
00498     void slotNotAnyColor( );
00499 protected:
00500     KSpreadBrushSelect *selectedBrush;
00501     KSpreadBrushSelect *brush1;
00502     KSpreadBrushSelect *brush2;
00503     KSpreadBrushSelect *brush3;
00504     KSpreadBrushSelect *brush4;
00505     KSpreadBrushSelect *brush5;
00506     KSpreadBrushSelect *brush6;
00507     KSpreadBrushSelect *brush7;
00508     KSpreadBrushSelect *brush8;
00509     KSpreadBrushSelect *brush9;
00510     KSpreadBrushSelect *brush10;
00511     KSpreadBrushSelect *brush11;
00512     KSpreadBrushSelect *brush12;
00513     KSpreadBrushSelect *brush13;
00514     KSpreadBrushSelect *brush14;
00515     KSpreadBrushSelect *brush15;
00516     KSpreadBrushSelect *current;
00517     KColorButton* color;
00518     QPushButton* notAnyColor;
00519     QColor currentColor;
00520 
00521     QColor bgColor;
00522     bool bBgColorUndefined;
00523     KColorButton *bgColorButton;
00524     bool b_notAnyColor;
00525     CellFormatDlg *dlg;
00526 };
00527 
00528 class CellFormatPageProtection : public QWidget
00529 {
00530   Q_OBJECT
00531 
00532  public:
00533   CellFormatPageProtection( QWidget * parent, CellFormatDlg * _dlg );
00534   ~CellFormatPageProtection();
00535 
00536   void apply( KSpreadCustomStyle * style );
00537   void apply( KSpreadCell  * _cell );
00538   void apply( ColumnFormat * _col );
00539   void apply( RowFormat    * _row );
00540   void applyFormat( KSpreadFormat * _obj );
00541 
00542  protected:
00543   QCheckBox *     m_bIsProtected;
00544   QCheckBox *     m_bHideFormula;
00545   QCheckBox *     m_bHideAll;
00546   QCheckBox *     m_bDontPrint;
00547 
00548   CellFormatDlg * m_dlg;
00549   bool            m_isProtected;
00550   bool            m_hideFormula;
00551   bool            m_hideAll;
00552   bool            m_dontPrint;
00553 };
00554 
00557 class CellFormatDlg : public QObject
00558 {
00559     Q_OBJECT
00560 public:
00564     CellFormatDlg( KSpreadView * _view, KSpreadSheet * _sheet, int _left, int _top, int _right, int _bottom );
00565     CellFormatDlg( KSpreadView * _view, KSpreadCustomStyle * _style, KSpreadStyleManager * _manager,
00566                    KSpreadDoc * doc );
00567 
00568     ~CellFormatDlg();
00569 
00570     void init();
00571     void initGUI();
00572     void initMembers();
00573 
00574     void initParameters(KSpreadFormat *_obj,int column,int row);
00575     void checkBorderRight(KSpreadFormat *obj,int x,int y);
00576     void checkBorderLeft(KSpreadFormat *obj,int x,int y);
00577     void checkBorderTop(KSpreadFormat *obj,int x,int y);
00578     void checkBorderBottom(KSpreadFormat *obj,int x,int y);
00579     void checkBorderVertical(KSpreadFormat *obj,int x,int y);
00580     void checkBorderHorizontal(KSpreadFormat *obj,int x,int y);
00584     int exec();
00585 
00586     KSpreadDoc * getDoc() const { return m_doc; }
00587     KSpreadSheet * getSheet() const { return m_sheet; }
00588     KSpreadCustomStyle * getStyle() const { return m_style; }
00589     KSpreadStyleManager * getStyleManager() const { return m_styleManager; }
00590 
00591     bool isSingleCell() { return ( left == right && top == bottom ); }
00592     bool checkCircle( QString const & name, QString const & parent );
00593 
00594     KLocale * locale() const { return m_pView->doc()->locale(); }
00595 
00596     struct CellBorderFormat
00597     {
00598       int width;
00599       bool bStyle;
00600       QColor color;
00601       bool bColor;
00602       PenStyle style;
00603     };
00604 
00605     // The format of the selected area
00606     CellBorderFormat borders[BorderType_END];
00607 
00608     BrushStyle brushStyle;
00609     QColor brushColor;
00610 
00611     bool oneCol;
00612     bool oneRow;
00613 
00614     QString prefix;
00615     QString postfix;
00616     int precision;
00617     KSpreadCell::FloatFormat floatFormat;
00618     bool bFloatFormat;
00619     KSpreadCell::FloatColor floatColor;
00620     KSpreadCell::Currency   cCurrency;
00621     bool bFloatColor;
00622     bool bCurrency;
00623     QColor textColor;
00624     bool bTextColor;
00625     bool bTextFontBold;
00626     bool textFontBold;
00627     bool bTextFontItalic;
00628     bool textFontItalic;
00629     bool bTextFontSize;
00630     int textFontSize;
00631     bool bTextFontFamily;
00632     QString textFontFamily;
00633     bool bStrike;
00634     bool strike;
00635     bool bUnderline;
00636     bool underline;
00637     QFont textFont;
00638     QColor bgColor;
00639     bool bBgColor;
00640     QString actionText;
00641     KSpreadCell::Align alignX;
00642     KSpreadCell::AlignY alignY;
00643     QString styleName;
00644     QString styleParent;
00645 
00646     bool bMultiRow;
00647     bool bVerticalText;
00648 
00649     bool bDontPrintText;
00650     bool bHideFormula;
00651     bool bHideAll;
00652     bool bIsProtected;
00653 
00654     double heightSize;
00655     double widthSize;
00656 
00657     double indent;
00658 
00659     QPixmap* formatOnlyNegSignedPixmap;
00660     QPixmap* formatRedOnlyNegSignedPixmap;
00661     QPixmap* formatRedNeverSignedPixmap;
00662     QPixmap* formatAlwaysSignedPixmap;
00663     QPixmap* formatRedAlwaysSignedPixmap;
00664 
00665     int textRotation;
00666     bool bTextRotation;
00667 
00668     FormatType formatType;
00669     bool bFormatType;
00670 
00671     KSpreadValue value;
00672 
00673     bool isMerged;
00674     bool oneCell;
00675 
00676     bool isRowSelected;
00677     bool isColumnSelected;
00678 
00679     // The rectangular area for which this dlg has been opened.
00680     int left;
00681     int right;
00682     int top;
00683     int bottom;
00684 
00685 
00686 public slots:
00687     void slotApply();
00688 
00689 protected:
00690 
00694     QPixmap* paintFormatPixmap( const char *_string1, const QColor & _color1,
00695                 const char *_string2, const QColor & _color2 );
00696 
00697     GeneralTab * generalPage;
00698     CellFormatPageFloat *floatPage;
00699     CellFormatPageBorder *borderPage;
00700     CellFormatPageMisc *miscPage;
00701     CellFormatPageFont *fontPage;
00702     CellFormatPagePosition *positionPage;
00703     CellFormatPagePattern *patternPage;
00704     CellFormatPageProtection *protectPage;
00705     QTabDialog *tab;
00706 
00707     KSpreadDoc   * m_doc;
00708     KSpreadSheet * m_sheet;
00709     KSpreadView  * m_pView;
00710     KSpreadCustomStyle * m_style;
00711     KSpreadStyleManager * m_styleManager;
00712 
00713     void applyStyle();
00714 };
00715 
00716 #endif
KDE Logo
This file is part of the documentation for kspread Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:43:02 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003