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
00031
00032
00033
00034 #ifndef CELLFORMAT_H
00035 #define CELLFORMAT_H
00036
00037 #include "sheet.h"
00038
00039
00040 #include <qpe/fontdatabase.h>
00041
00042
00043 #include <qdialog.h>
00044 #include <qtabwidget.h>
00045 #include <qlayout.h>
00046 #include <qcombobox.h>
00047 #include <qcheckbox.h>
00048 #include <qpushbutton.h>
00049
00050 class BorderEditor: public QFrame
00051 {
00052 Q_OBJECT
00053
00054
00055 QPen penTop, penBottom, penLeft, penRight, penHorz, penVert;
00056
00057
00058 void drawContents(QPainter *p);
00059
00060
00061 void mouseReleaseEvent(QMouseEvent *e);
00062
00063 public:
00064
00065 enum BorderArea {None, Top, Bottom, Left, Right, Horz, Vert};
00066
00067 BorderEditor(QWidget *parent=0);
00068 ~BorderEditor();
00069
00070 void setPen(const QPen &pen, BorderArea area);
00071 QPen getPen(BorderArea area);
00072 QPen getDefaultPen() { return QPen(Qt::black, 1, Qt::DotLine); }
00073
00074 signals:
00075 void clicked(BorderEditor::BorderArea);
00076 };
00077
00078 class CellFormat: public QDialog
00079 {
00080 Q_OBJECT
00081
00082 enum comboType {COMBO_OTHER, COMBO_WIDTH, COMBO_FONT, COMBO_SIZE, COMBO_STYLE, COMBO_COLOR, COMBO_VALIGN, COMBO_HALIGN};
00083
00084
00085 QBoxLayout *box;
00086 QTabWidget *tabs;
00087 QWidget *widgetBorders, *widgetBackground, *widgetFont, *widgetAlignment;
00088 QComboBox *comboBordersWidth, *comboBordersColor, *comboBackgroundColor, *comboBackgroundStyle, *comboFontColor, *comboFontSize, *comboFontFamily, *comboAlignmentVertical, *comboAlignmentHorizontal;
00089 QCheckBox *checkFontBold, *checkFontItalic, *checkAlignmentWrap;
00090 QPushButton *buttonBordersDefaults, *buttonBackgroundDefaults, *buttonFontDefaults, *buttonAlignmentDefaults;
00091 QFrame *frameBackground, *frameFont, *frameAlignment;
00092 QBrush brushBackground;
00093 QFont fontFont;
00094 QColor fontColor;
00095 Qt::AlignmentFlags textAlignment;
00096 FontDatabase fontDB;
00097
00098
00099 Sheet *sheet;
00100 BorderEditor *borderEditor;
00101 bool changedFont, changedAlign, changedBrush;
00102
00103
00104 void createWidthCombo(QComboBox *combo);
00105 void createFontCombo(QComboBox *combo);
00106 void createHAlignCombo(QComboBox *combo);
00107 void createVAlignCombo(QComboBox *combo);
00108 void createStyleCombo(QComboBox *combo);
00109 void createSizeCombo(QComboBox *combo);
00110 void createColorCombo(QComboBox *combo);
00111 QComboBox *createCombo(comboType type, QWidget *parent, const QString &caption, int y);
00112
00113 int findHAlignIndex(Qt::AlignmentFlags flag);
00114 int findVAlignIndex(Qt::AlignmentFlags flag);
00115 int findComboItemIndex(QComboBox *combo, const QString &item);
00116 int findColorIndex(const QColor &color);
00117 int findBrushStyleIndex(Qt::BrushStyle style);
00118
00119 private slots:
00120 void borderClicked(BorderEditor::BorderArea area);
00121 void backgroundClicked(int index);
00122 void fontClicked(bool on);
00123 void fontClicked(int index);
00124 void alignClicked(bool on);
00125 void alignClicked(int index);
00126 void slotBordersDefaults();
00127 void slotBackgroundDefaults();
00128 void slotFontDefaults();
00129 void slotAlignmentDefaults();
00130
00131 public:
00132 CellFormat(QWidget *parent=0);
00133 ~CellFormat();
00134
00135 int exec(Sheet *s);
00136
00137 void setTextAlign(Qt::AlignmentFlags flags);
00138 void setTextFont(const QFont &font, const QColor &color);
00139 void setBrushBackground(const QBrush &brush);
00140 };
00141
00142 #endif