Diffstat (limited to 'noncore/apps/opie-sheet/cellformat.h') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/cellformat.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/noncore/apps/opie-sheet/cellformat.h b/noncore/apps/opie-sheet/cellformat.h new file mode 100644 index 0000000..b552153 --- a/dev/null +++ b/noncore/apps/opie-sheet/cellformat.h | |||
@@ -0,0 +1,106 @@ | |||
1 | #ifndef CELLFORMAT_H | ||
2 | #define CELLFORMAT_H | ||
3 | |||
4 | #include <qpe/fontdatabase.h> | ||
5 | #include <qdialog.h> | ||
6 | #include <qtabwidget.h> | ||
7 | #include <qlayout.h> | ||
8 | #include <qcombobox.h> | ||
9 | #include <qcheckbox.h> | ||
10 | #include <qpushbutton.h> | ||
11 | |||
12 | #include "sheet.h" | ||
13 | |||
14 | class BorderEditor: public QFrame | ||
15 | { | ||
16 | Q_OBJECT | ||
17 | |||
18 | // QT objects | ||
19 | QPen penTop, penBottom, penLeft, penRight, penHorz, penVert; | ||
20 | |||
21 | // Private functions | ||
22 | void drawContents(QPainter *p); | ||
23 | |||
24 | // Reimplemented QFrame functions | ||
25 | void mouseReleaseEvent(QMouseEvent *e); | ||
26 | |||
27 | public: | ||
28 | // Definitions | ||
29 | enum BorderArea {None, Top, Bottom, Left, Right, Horz, Vert}; | ||
30 | |||
31 | BorderEditor(QWidget *parent=0); | ||
32 | ~BorderEditor(); | ||
33 | |||
34 | void setPen(const QPen &pen, BorderArea area); | ||
35 | QPen getPen(BorderArea area); | ||
36 | QPen getDefaultPen() { return QPen(Qt::black, 1, Qt::DotLine); } | ||
37 | |||
38 | signals: | ||
39 | void clicked(BorderEditor::BorderArea); | ||
40 | }; | ||
41 | |||
42 | class CellFormat: public QDialog | ||
43 | { | ||
44 | Q_OBJECT | ||
45 | |||
46 | enum comboType {COMBO_OTHER, COMBO_WIDTH, COMBO_FONT, COMBO_SIZE, COMBO_STYLE, COMBO_COLOR, COMBO_VALIGN, COMBO_HALIGN}; | ||
47 | |||
48 | // QT objects | ||
49 | QBoxLayout *box; | ||
50 | QTabWidget *tabs; | ||
51 | QWidget *widgetBorders, *widgetBackground, *widgetFont, *widgetAlignment; | ||
52 | QComboBox *comboBordersWidth, *comboBordersColor, *comboBackgroundColor, *comboBackgroundStyle, *comboFontColor, *comboFontSize, *comboFontFamily, *comboAlignmentVertical, *comboAlignmentHorizontal; | ||
53 | QCheckBox *checkFontBold, *checkFontItalic, *checkAlignmentWrap; | ||
54 | QPushButton *buttonBordersDefaults, *buttonBackgroundDefaults, *buttonFontDefaults, *buttonAlignmentDefaults; | ||
55 | QFrame *frameBackground, *frameFont, *frameAlignment; | ||
56 | QBrush brushBackground; | ||
57 | QFont fontFont; | ||
58 | QColor fontColor; | ||
59 | Qt::AlignmentFlags textAlignment; | ||
60 | FontDatabase fontDB; | ||
61 | |||
62 | // Other objects & variables | ||
63 | Sheet *sheet; | ||
64 | BorderEditor *borderEditor; | ||
65 | bool changedFont, changedAlign, changedBrush; | ||
66 | |||
67 | // Private functions | ||
68 | void createWidthCombo(QComboBox *combo); | ||
69 | void createFontCombo(QComboBox *combo); | ||
70 | void createHAlignCombo(QComboBox *combo); | ||
71 | void createVAlignCombo(QComboBox *combo); | ||
72 | void createStyleCombo(QComboBox *combo); | ||
73 | void createSizeCombo(QComboBox *combo); | ||
74 | void createColorCombo(QComboBox *combo); | ||
75 | QComboBox *createCombo(comboType type, QWidget *parent, const QString &caption, int y); | ||
76 | |||
77 | int findHAlignIndex(Qt::AlignmentFlags flag); | ||
78 | int findVAlignIndex(Qt::AlignmentFlags flag); | ||
79 | int findComboItemIndex(QComboBox *combo, const QString &item); | ||
80 | int findColorIndex(const QColor &color); | ||
81 | int findBrushStyleIndex(Qt::BrushStyle style); | ||
82 | |||
83 | private slots: | ||
84 | void borderClicked(BorderEditor::BorderArea area); | ||
85 | void backgroundClicked(int index); | ||
86 | void fontClicked(bool on); | ||
87 | void fontClicked(int index); | ||
88 | void alignClicked(bool on); | ||
89 | void alignClicked(int index); | ||
90 | void slotBordersDefaults(); | ||
91 | void slotBackgroundDefaults(); | ||
92 | void slotFontDefaults(); | ||
93 | void slotAlignmentDefaults(); | ||
94 | |||
95 | public: | ||
96 | CellFormat(QWidget *parent=0); | ||
97 | ~CellFormat(); | ||
98 | |||
99 | int exec(Sheet *s); | ||
100 | |||
101 | void setTextAlign(Qt::AlignmentFlags flags); | ||
102 | void setTextFont(const QFont &font, const QColor &color); | ||
103 | void setBrushBackground(const QBrush &brush); | ||
104 | }; | ||
105 | |||
106 | #endif | ||