author | ar <ar> | 2004-06-12 09:24:00 (UTC) |
---|---|---|
committer | ar <ar> | 2004-06-12 09:24:00 (UTC) |
commit | 7a62e8e3601ee98f5f06261c361fe8132334cd56 (patch) (unidiff) | |
tree | 72e1e68878e32c70140fe1de478bced96670e348 /noncore/apps/opie-sheet/cellformat.cpp | |
parent | 3fbf3cb264200c5ac11dbef43a51f3ab2a969587 (diff) | |
download | opie-7a62e8e3601ee98f5f06261c361fe8132334cd56.zip opie-7a62e8e3601ee98f5f06261c361fe8132334cd56.tar.gz opie-7a62e8e3601ee98f5f06261c361fe8132334cd56.tar.bz2 |
- rename sheet-qt -> opie-sheet
- format source code for a better readability
Diffstat (limited to 'noncore/apps/opie-sheet/cellformat.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-sheet/cellformat.cpp | 842 |
1 files changed, 430 insertions, 412 deletions
diff --git a/noncore/apps/opie-sheet/cellformat.cpp b/noncore/apps/opie-sheet/cellformat.cpp index 342ebe9..602d20d 100644 --- a/noncore/apps/opie-sheet/cellformat.cpp +++ b/noncore/apps/opie-sheet/cellformat.cpp | |||
@@ -1,11 +1,30 @@ | |||
1 | /*************************************************************************** | 1 | /* |
2 | * * | 2 | =. This file is part of the Opie Project |
3 | * This program is free software; you can redistribute it and/or modify * | 3 | .=l. Copyright (C) 2004 Opie Developer Team <opie-devel@handhelds.org> |
4 | * it under the terms of the GNU General Public License as published by * | 4 | .>+-= |
5 | * the Free Software Foundation; either version 2 of the License, or * | 5 | _;:, .> :=|. This program is free software; you can |
6 | * (at your option) any later version. * | 6 | .> <`_, > . <= redistribute it and/or modify it under |
7 | * * | 7 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
8 | ***************************************************************************/ | 8 | .="- .-=="i, .._ License as published by the Free Software |
9 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
10 | ._= =} : or (at your option) any later version. | ||
11 | .%`+i> _;_. | ||
12 | .i_,=:_. -<s. This program is distributed in the hope that | ||
13 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
14 | : .. .:, . . . without even the implied warranty of | ||
15 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
16 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
17 | ..}^=.= = ; Library General Public License for more | ||
18 | ++= -. .` .: details. | ||
19 | : = ...= . :.=- | ||
20 | -. .:....=;==+<; You should have received a copy of the GNU | ||
21 | -_. . . )=. = Library General Public License along with | ||
22 | -- :-=` this library; see the file COPYING.LIB. | ||
23 | If not, write to the Free Software Foundation, | ||
24 | Inc., 59 Temple Place - Suite 330, | ||
25 | Boston, MA 02111-1307, USA. | ||
26 | |||
27 | */ | ||
9 | 28 | ||
10 | /* | 29 | /* |
11 | * Opie Sheet (formerly Sheet/Qt) | 30 | * Opie Sheet (formerly Sheet/Qt) |
@@ -14,6 +33,7 @@ | |||
14 | 33 | ||
15 | #include "cellformat.h" | 34 | #include "cellformat.h" |
16 | 35 | ||
36 | /* QT */ | ||
17 | #include <qlistbox.h> | 37 | #include <qlistbox.h> |
18 | #include <qlabel.h> | 38 | #include <qlabel.h> |
19 | 39 | ||
@@ -34,298 +54,297 @@ QColor qtColors[COLOR_COUNT]={Qt::black,Qt::white, Qt::darkGray, | |||
34 | Qt::darkMagenta, Qt::darkYellow}; | 54 | Qt::darkMagenta, Qt::darkYellow}; |
35 | 55 | ||
36 | Qt::BrushStyle brushStyles[STYLE_COUNT]={Qt::SolidPattern, | 56 | Qt::BrushStyle brushStyles[STYLE_COUNT]={Qt::SolidPattern, |
37 | Qt::Dense1Pattern, Qt::Dense2Pattern, | 57 | Qt::Dense1Pattern, Qt::Dense2Pattern, |
38 | Qt::Dense3Pattern, Qt::Dense4Pattern, | 58 | Qt::Dense3Pattern, Qt::Dense4Pattern, |
39 | Qt::Dense5Pattern, Qt::Dense6Pattern, | 59 | Qt::Dense5Pattern, Qt::Dense6Pattern, |
40 | Qt::Dense7Pattern, Qt::HorPattern, | 60 | Qt::Dense7Pattern, Qt::HorPattern, |
41 | Qt::VerPattern, Qt::CrossPattern, | 61 | Qt::VerPattern, Qt::CrossPattern, |
42 | Qt::BDiagPattern, Qt::FDiagPattern, | 62 | Qt::BDiagPattern, Qt::FDiagPattern, |
43 | Qt::DiagCrossPattern}; | 63 | Qt::DiagCrossPattern}; |
44 | 64 | ||
45 | QString namesHAlign[HALIGN_COUNT]={"Left", "Right", "Center"}; | 65 | QString namesHAlign[HALIGN_COUNT]={"Left", "Right", "Center"}; |
46 | QString namesVAlign[VALIGN_COUNT]={"Top", "Bottom", "Center"}; | 66 | QString namesVAlign[VALIGN_COUNT]={"Top", "Bottom", "Center"}; |
47 | 67 | ||
48 | Qt::AlignmentFlags flagsHAlign[HALIGN_COUNT]={Qt::AlignLeft, | 68 | Qt::AlignmentFlags flagsHAlign[HALIGN_COUNT]={Qt::AlignLeft, |
49 | Qt::AlignRight, | 69 | Qt::AlignRight, |
50 | Qt::AlignHCenter}; | 70 | Qt::AlignHCenter}; |
51 | 71 | ||
52 | Qt::AlignmentFlags flagsVAlign[VALIGN_COUNT]={Qt::AlignTop, | 72 | Qt::AlignmentFlags flagsVAlign[VALIGN_COUNT]={Qt::AlignTop, |
53 | Qt::AlignBottom, | 73 | Qt::AlignBottom, |
54 | Qt::AlignVCenter}; | 74 | Qt::AlignVCenter}; |
55 | 75 | ||
56 | CellFormat::CellFormat(QWidget *parent) | 76 | CellFormat::CellFormat(QWidget *parent) |
57 | :QDialog(parent, 0, TRUE) | 77 | :QDialog(parent, 0, TRUE) |
58 | { | 78 | { |
59 | // Main widget | 79 | // Main widget |
60 | tabs=new QTabWidget(this); | 80 | tabs=new QTabWidget(this); |
61 | widgetBorders=new QWidget(tabs); | 81 | widgetBorders=new QWidget(tabs); |
62 | widgetBackground=new QWidget(tabs); | 82 | widgetBackground=new QWidget(tabs); |
63 | widgetFont=new QWidget(tabs); | 83 | widgetFont=new QWidget(tabs); |
64 | widgetAlignment=new QWidget(tabs); | 84 | widgetAlignment=new QWidget(tabs); |
65 | tabs->addTab(widgetBorders, tr("&Borders")); | 85 | tabs->addTab(widgetBorders, tr("&Borders")); |
66 | tabs->addTab(widgetBackground, tr("Back&ground")); | 86 | tabs->addTab(widgetBackground, tr("Back&ground")); |
67 | tabs->addTab(widgetFont, tr("&Font")); | 87 | tabs->addTab(widgetFont, tr("&Font")); |
68 | tabs->addTab(widgetAlignment, tr("&Alignment")); | 88 | tabs->addTab(widgetAlignment, tr("&Alignment")); |
69 | 89 | ||
70 | fontDB.loadRenderers(); | 90 | fontDB.loadRenderers(); |
71 | changedFont=changedAlign=changedBrush=FALSE; | 91 | changedFont=changedAlign=changedBrush=FALSE; |
72 | 92 | ||
73 | // Borders tab | 93 | // Borders tab |
74 | borderEditor=new BorderEditor(widgetBorders); | 94 | borderEditor=new BorderEditor(widgetBorders); |
75 | borderEditor->setGeometry(10, 10, 215, 145); | 95 | borderEditor->setGeometry(10, 10, 215, 145); |
76 | connect(borderEditor, SIGNAL(clicked(BorderEditor::BorderArea)), | 96 | connect(borderEditor, SIGNAL(clicked(BorderEditor::BorderArea)), |
77 | this, SLOT(borderClicked(BorderEditor::BorderArea))); | 97 | this, SLOT(borderClicked(BorderEditor::BorderArea))); |
78 | 98 | ||
79 | comboBordersWidth=createCombo(COMBO_WIDTH, widgetBorders, tr("&Width:"), 165); | 99 | comboBordersWidth=createCombo(COMBO_WIDTH, widgetBorders, tr("&Width:"), 165); |
80 | comboBordersColor=createCombo(COMBO_COLOR, widgetBorders, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); | 100 | comboBordersColor=createCombo(COMBO_COLOR, widgetBorders, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); |
81 | 101 | ||
82 | buttonBordersDefaults=new QPushButton(tr("&Default Borders"), widgetBorders); | 102 | buttonBordersDefaults=new QPushButton(tr("&Default Borders"), widgetBorders); |
83 | buttonBordersDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), | 103 | buttonBordersDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), |
84 | 110, COMBO_HEIGHTS); | 104 | 110, COMBO_HEIGHTS); |
85 | 105 | ||
86 | connect(buttonBordersDefaults, SIGNAL(clicked()), | 106 | connect(buttonBordersDefaults, SIGNAL(clicked()), |
87 | this, SLOT(slotBordersDefaults())); | 107 | this, SLOT(slotBordersDefaults())); |
88 | 108 | ||
89 | // Background tab | 109 | // Background tab |
90 | frameBackground=new QFrame(widgetBackground); | 110 | frameBackground=new QFrame(widgetBackground); |
91 | frameBackground->setGeometry(10, 10, 215, 145); | 111 | frameBackground->setGeometry(10, 10, 215, 145); |
92 | frameBackground->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | 112 | frameBackground->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
93 | 113 | ||
94 | comboBackgroundStyle=createCombo(COMBO_STYLE, widgetBackground, tr("&Style:"), 165); | 114 | comboBackgroundStyle=createCombo(COMBO_STYLE, widgetBackground, tr("&Style:"), 165); |
95 | connect(comboBackgroundStyle, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); | 115 | connect(comboBackgroundStyle, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); |
96 | comboBackgroundColor=createCombo(COMBO_COLOR, widgetBackground, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); | 116 | comboBackgroundColor=createCombo(COMBO_COLOR, widgetBackground, tr("&Color:"), 165+(COMBO_HEIGHTS+10)); |
97 | connect(comboBackgroundColor, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); | 117 | connect(comboBackgroundColor, SIGNAL(activated(int)), this, SLOT(backgroundClicked(int))); |
98 | 118 | ||
99 | buttonBackgroundDefaults=new QPushButton(tr("&Default Background"), widgetBackground); | 119 | buttonBackgroundDefaults=new QPushButton(tr("&Default Background"), widgetBackground); |
100 | buttonBackgroundDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); | 120 | buttonBackgroundDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); |
101 | connect(buttonBackgroundDefaults, SIGNAL(clicked()), this, SLOT(slotBackgroundDefaults())); | 121 | connect(buttonBackgroundDefaults, SIGNAL(clicked()), this, SLOT(slotBackgroundDefaults())); |
102 | 122 | ||
103 | // Font tab | 123 | // Font tab |
104 | frameFont=new QFrame(widgetFont); | 124 | frameFont=new QFrame(widgetFont); |
105 | frameFont->setGeometry(10, 10, 215, 125); | 125 | frameFont->setGeometry(10, 10, 215, 125); |
106 | frameFont->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | 126 | frameFont->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
107 | 127 | ||
108 | comboFontFamily=createCombo(COMBO_FONT, widgetFont, tr("&Font:"), 145); | 128 | comboFontFamily=createCombo(COMBO_FONT, widgetFont, tr("&Font:"), 145); |
109 | connect(comboFontFamily, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); | 129 | connect(comboFontFamily, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); |
110 | comboFontSize=createCombo(COMBO_SIZE, widgetFont, tr("&Size:"), 145+(COMBO_HEIGHTS+10)); | 130 | comboFontSize=createCombo(COMBO_SIZE, widgetFont, tr("&Size:"), 145+(COMBO_HEIGHTS+10)); |
111 | connect(comboFontSize, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); | 131 | connect(comboFontSize, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); |
112 | comboFontColor=createCombo(COMBO_COLOR, widgetFont, tr("&Color:"), 145+2*(COMBO_HEIGHTS+10)); | 132 | comboFontColor=createCombo(COMBO_COLOR, widgetFont, tr("&Color:"), 145+2*(COMBO_HEIGHTS+10)); |
113 | connect(comboFontColor, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); | 133 | connect(comboFontColor, SIGNAL(activated(int)), this, SLOT(fontClicked(int))); |
114 | 134 | ||
115 | checkFontBold=new QCheckBox(tr("&Bold"), widgetFont); | 135 | checkFontBold=new QCheckBox(tr("&Bold"), widgetFont); |
116 | checkFontBold->setGeometry(10, 145+3*(COMBO_HEIGHTS+10), 40, COMBO_HEIGHTS); | 136 | checkFontBold->setGeometry(10, 145+3*(COMBO_HEIGHTS+10), 40, COMBO_HEIGHTS); |
117 | connect(checkFontBold, SIGNAL(toggled(bool)), this, SLOT(fontClicked(bool))); | 137 | connect(checkFontBold, SIGNAL(toggled(bool)), this, SLOT(fontClicked(bool))); |
118 | checkFontItalic=new QCheckBox(tr("&Italic"), widgetFont); | 138 | checkFontItalic=new QCheckBox(tr("&Italic"), widgetFont); |
119 | checkFontItalic->setGeometry(60, 145+3*(COMBO_HEIGHTS+10), 40, COMBO_HEIGHTS); | 139 | checkFontItalic->setGeometry(60, 145+3*(COMBO_HEIGHTS+10), 40, COMBO_HEIGHTS); |
120 | connect(checkFontItalic, SIGNAL(toggled(bool)), this, SLOT(fontClicked(bool))); | 140 | connect(checkFontItalic, SIGNAL(toggled(bool)), this, SLOT(fontClicked(bool))); |
121 | 141 | ||
122 | buttonFontDefaults=new QPushButton(tr("&Default Font"), widgetFont); | 142 | buttonFontDefaults=new QPushButton(tr("&Default Font"), widgetFont); |
123 | buttonFontDefaults->setGeometry(115, 145+3*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); | 143 | buttonFontDefaults->setGeometry(115, 145+3*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); |
124 | connect(buttonFontDefaults, SIGNAL(clicked()), this, SLOT(slotFontDefaults())); | 144 | connect(buttonFontDefaults, SIGNAL(clicked()), this, SLOT(slotFontDefaults())); |
125 | 145 | ||
126 | // Alignment tab | 146 | // Alignment tab |
127 | frameAlignment=new QFrame(widgetAlignment); | 147 | frameAlignment=new QFrame(widgetAlignment); |
128 | frameAlignment->setGeometry(10, 10, 215, 145); | 148 | frameAlignment->setGeometry(10, 10, 215, 145); |
129 | frameAlignment->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | 149 | frameAlignment->setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
130 | 150 | ||
131 | comboAlignmentVertical=createCombo(COMBO_VALIGN, widgetAlignment, tr("&Vertical:"), 165); | 151 | comboAlignmentVertical=createCombo(COMBO_VALIGN, widgetAlignment, tr("&Vertical:"), 165); |
132 | connect(comboAlignmentVertical, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); | 152 | connect(comboAlignmentVertical, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); |
133 | comboAlignmentHorizontal=createCombo(COMBO_HALIGN, widgetAlignment, tr("&Horizontal:"), 165+(COMBO_HEIGHTS+10)); | 153 | comboAlignmentHorizontal=createCombo(COMBO_HALIGN, widgetAlignment, tr("&Horizontal:"), 165+(COMBO_HEIGHTS+10)); |
134 | connect(comboAlignmentHorizontal, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); | 154 | connect(comboAlignmentHorizontal, SIGNAL(activated(int)), this, SLOT(alignClicked(int))); |
135 | 155 | ||
136 | checkAlignmentWrap=new QCheckBox(tr("&Word Wrap"), widgetAlignment); | 156 | checkAlignmentWrap=new QCheckBox(tr("&Word Wrap"), widgetAlignment); |
137 | checkAlignmentWrap->setGeometry(10, 165+2*(COMBO_HEIGHTS+10), 90, COMBO_HEIGHTS); | 157 | checkAlignmentWrap->setGeometry(10, 165+2*(COMBO_HEIGHTS+10), 90, COMBO_HEIGHTS); |
138 | connect(checkAlignmentWrap, SIGNAL(toggled(bool)), this, SLOT(alignClicked(bool))); | 158 | connect(checkAlignmentWrap, SIGNAL(toggled(bool)), this, SLOT(alignClicked(bool))); |
139 | 159 | ||
140 | buttonAlignmentDefaults=new QPushButton(tr("&Default Alignment"), widgetAlignment); | 160 | buttonAlignmentDefaults=new QPushButton(tr("&Default Alignment"), widgetAlignment); |
141 | buttonAlignmentDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); | 161 | buttonAlignmentDefaults->setGeometry(115, 165+2*(COMBO_HEIGHTS+10), 110, COMBO_HEIGHTS); |
142 | connect(buttonAlignmentDefaults, SIGNAL(clicked()), this, SLOT(slotAlignmentDefaults())); | 162 | connect(buttonAlignmentDefaults, SIGNAL(clicked()), this, SLOT(slotAlignmentDefaults())); |
143 | 163 | ||
144 | // Main widget | 164 | // Main widget |
145 | box=new QVBoxLayout(this); | 165 | box=new QVBoxLayout(this); |
146 | box->addWidget(tabs); | 166 | box->addWidget(tabs); |
147 | 167 | ||
148 | setCaption(tr("Format Cells")); | 168 | setCaption(tr("Format Cells")); |
149 | } | 169 | } |
150 | 170 | ||
151 | CellFormat::~CellFormat() | 171 | CellFormat::~CellFormat() |
152 | { | 172 | {} |
153 | } | ||
154 | 173 | ||
155 | int CellFormat::findColorIndex(const QColor &color) | 174 | int CellFormat::findColorIndex(const QColor &color) |
156 | { | 175 | { |
157 | for (int i=0; i<COLOR_COUNT; ++i) | 176 | for (int i=0; i<COLOR_COUNT; ++i) |
158 | if (qtColors[i]==color) | 177 | if (qtColors[i]==color) |
159 | return i; | 178 | return i; |
160 | return 0; | 179 | return 0; |
161 | } | 180 | } |
162 | 181 | ||
163 | int CellFormat::findVAlignIndex(Qt::AlignmentFlags flag) | 182 | int CellFormat::findVAlignIndex(Qt::AlignmentFlags flag) |
164 | { | 183 | { |
165 | for (int i=0; i<VALIGN_COUNT; ++i) | 184 | for (int i=0; i<VALIGN_COUNT; ++i) |
166 | if (flagsVAlign[i] & flag) | 185 | if (flagsVAlign[i] & flag) |
167 | return i; | 186 | return i; |
168 | return 0; | 187 | return 0; |
169 | } | 188 | } |
170 | 189 | ||
171 | int CellFormat::findHAlignIndex(Qt::AlignmentFlags flag) | 190 | int CellFormat::findHAlignIndex(Qt::AlignmentFlags flag) |
172 | { | 191 | { |
173 | for (int i=0; i<HALIGN_COUNT; ++i) | 192 | for (int i=0; i<HALIGN_COUNT; ++i) |
174 | if (flagsHAlign[i] & flag) | 193 | if (flagsHAlign[i] & flag) |
175 | return i; | 194 | return i; |
176 | return 0; | 195 | return 0; |
177 | } | 196 | } |
178 | 197 | ||
179 | int CellFormat::findBrushStyleIndex(Qt::BrushStyle style) | 198 | int CellFormat::findBrushStyleIndex(Qt::BrushStyle style) |
180 | { | 199 | { |
181 | for (int i=0; i<STYLE_COUNT; ++i) | 200 | for (int i=0; i<STYLE_COUNT; ++i) |
182 | if (brushStyles[i]==style) | 201 | if (brushStyles[i]==style) |
183 | return i; | 202 | return i; |
184 | return 0; | 203 | return 0; |
185 | } | 204 | } |
186 | 205 | ||
187 | void CellFormat::setBrushBackground(const QBrush &brush) | 206 | void CellFormat::setBrushBackground(const QBrush &brush) |
188 | { | 207 | { |
189 | comboBackgroundColor->setCurrentItem(findColorIndex(brush.color())); | 208 | comboBackgroundColor->setCurrentItem(findColorIndex(brush.color())); |
190 | comboBackgroundStyle->setCurrentItem(findBrushStyleIndex(brush.style())); | 209 | comboBackgroundStyle->setCurrentItem(findBrushStyleIndex(brush.style())); |
191 | 210 | ||
192 | QPixmap pix(frameBackground->contentsRect().width(), frameBackground->contentsRect().height()); | 211 | QPixmap pix(frameBackground->contentsRect().width(), frameBackground->contentsRect().height()); |
193 | QPainter p(&pix); | 212 | QPainter p(&pix); |
194 | pix.fill(); | 213 | pix.fill(); |
195 | p.fillRect(pix.rect(), brush); | 214 | p.fillRect(pix.rect(), brush); |
196 | frameBackground->setBackgroundPixmap(pix); | 215 | frameBackground->setBackgroundPixmap(pix); |
197 | 216 | ||
198 | brushBackground=brush; | 217 | brushBackground=brush; |
199 | } | 218 | } |
200 | 219 | ||
201 | void CellFormat::setTextFont(const QFont &font, const QColor &color) | 220 | void CellFormat::setTextFont(const QFont &font, const QColor &color) |
202 | { | 221 | { |
203 | comboFontColor->setCurrentItem(findColorIndex(color)); | 222 | comboFontColor->setCurrentItem(findColorIndex(color)); |
204 | comboFontFamily->setCurrentItem(findComboItemIndex(comboFontFamily, font.family())); | 223 | comboFontFamily->setCurrentItem(findComboItemIndex(comboFontFamily, font.family())); |
205 | comboFontSize->setCurrentItem(findComboItemIndex(comboFontSize, QString::number(font.pointSize()))); | 224 | comboFontSize->setCurrentItem(findComboItemIndex(comboFontSize, QString::number(font.pointSize()))); |
206 | checkFontBold->setChecked(font.weight()==QFont::Bold); | 225 | checkFontBold->setChecked(font.weight()==QFont::Bold); |
207 | checkFontItalic->setChecked(font.italic()); | 226 | checkFontItalic->setChecked(font.italic()); |
208 | 227 | ||
209 | QPixmap pix(frameFont->contentsRect().width(), frameFont->contentsRect().height()); | 228 | QPixmap pix(frameFont->contentsRect().width(), frameFont->contentsRect().height()); |
210 | QPainter p(&pix); | 229 | QPainter p(&pix); |
211 | pix.fill(); | 230 | pix.fill(); |
212 | p.fillRect(pix.rect(), Qt::white); | 231 | p.fillRect(pix.rect(), Qt::white); |
213 | p.setFont(font); | 232 | p.setFont(font); |
214 | p.setPen(color); | 233 | p.setPen(color); |
215 | p.drawText(pix.rect(), Qt::AlignCenter, tr("Opie Sheet")); | 234 | p.drawText(pix.rect(), Qt::AlignCenter, tr("Opie Sheet")); |
216 | frameFont->setBackgroundPixmap(pix); | 235 | frameFont->setBackgroundPixmap(pix); |
217 | 236 | ||
218 | fontFont=font; | 237 | fontFont=font; |
219 | fontColor=color; | 238 | fontColor=color; |
220 | } | 239 | } |
221 | 240 | ||
222 | void CellFormat::setTextAlign(Qt::AlignmentFlags flags) | 241 | void CellFormat::setTextAlign(Qt::AlignmentFlags flags) |
223 | { | 242 | { |
224 | comboAlignmentVertical->setCurrentItem(findVAlignIndex(flags)); | 243 | comboAlignmentVertical->setCurrentItem(findVAlignIndex(flags)); |
225 | comboAlignmentHorizontal->setCurrentItem(findHAlignIndex(flags)); | 244 | comboAlignmentHorizontal->setCurrentItem(findHAlignIndex(flags)); |
226 | checkAlignmentWrap->setChecked(flags & Qt::WordBreak); | 245 | checkAlignmentWrap->setChecked(flags & Qt::WordBreak); |
227 | 246 | ||
228 | QPixmap pix(frameAlignment->contentsRect().width(), frameAlignment->contentsRect().height()); | 247 | QPixmap pix(frameAlignment->contentsRect().width(), frameAlignment->contentsRect().height()); |
229 | QPainter p(&pix); | 248 | QPainter p(&pix); |
230 | pix.fill(); | 249 | pix.fill(); |
231 | p.fillRect(pix.rect(), Qt::white); | 250 | p.fillRect(pix.rect(), Qt::white); |
232 | p.drawText(10, 10, pix.width()-20, pix.height()-20, flags, tr("Opie Sheet")); | 251 | p.drawText(10, 10, pix.width()-20, pix.height()-20, flags, tr("Opie Sheet")); |
233 | frameAlignment->setBackgroundPixmap(pix); | 252 | frameAlignment->setBackgroundPixmap(pix); |
234 | 253 | ||
235 | textAlignment=flags; | 254 | textAlignment=flags; |
236 | } | 255 | } |
237 | 256 | ||
238 | void CellFormat::slotFontDefaults() | 257 | void CellFormat::slotFontDefaults() |
239 | { | 258 | { |
240 | changedFont=TRUE; | 259 | changedFont=TRUE; |
241 | setTextFont(font(), Qt::black); | 260 | setTextFont(font(), Qt::black); |
242 | } | 261 | } |
243 | 262 | ||
244 | void CellFormat::slotAlignmentDefaults() | 263 | void CellFormat::slotAlignmentDefaults() |
245 | { | 264 | { |
246 | changedAlign=TRUE; | 265 | changedAlign=TRUE; |
247 | setTextAlign((Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop)); | 266 | setTextAlign((Qt::AlignmentFlags)(Qt::AlignLeft | Qt::AlignTop)); |
248 | } | 267 | } |
249 | 268 | ||
250 | void CellFormat::slotBackgroundDefaults() | 269 | void CellFormat::slotBackgroundDefaults() |
251 | { | 270 | { |
252 | changedBrush=TRUE; | 271 | changedBrush=TRUE; |
253 | setBrushBackground(Qt::white); | 272 | setBrushBackground(Qt::white); |
254 | } | 273 | } |
255 | 274 | ||
256 | void CellFormat::slotBordersDefaults() | 275 | void CellFormat::slotBordersDefaults() |
257 | { | 276 | { |
258 | QPen defaultPen(Qt::gray, 1, Qt::SolidLine); | 277 | QPen defaultPen(Qt::gray, 1, Qt::SolidLine); |
259 | borderEditor->setPen(defaultPen, BorderEditor::Top); | 278 | borderEditor->setPen(defaultPen, BorderEditor::Top); |
260 | borderEditor->setPen(defaultPen, BorderEditor::Bottom); | 279 | borderEditor->setPen(defaultPen, BorderEditor::Bottom); |
261 | borderEditor->setPen(defaultPen, BorderEditor::Left); | 280 | borderEditor->setPen(defaultPen, BorderEditor::Left); |
262 | borderEditor->setPen(defaultPen, BorderEditor::Right); | 281 | borderEditor->setPen(defaultPen, BorderEditor::Right); |
263 | borderEditor->setPen(defaultPen, BorderEditor::Vert); | 282 | borderEditor->setPen(defaultPen, BorderEditor::Vert); |
264 | borderEditor->setPen(defaultPen, BorderEditor::Horz); | 283 | borderEditor->setPen(defaultPen, BorderEditor::Horz); |
265 | } | 284 | } |
266 | 285 | ||
267 | void CellFormat::backgroundClicked(int index) | 286 | void CellFormat::backgroundClicked(int index) |
268 | { | 287 | { |
269 | changedBrush=TRUE; | 288 | changedBrush=TRUE; |
270 | setBrushBackground(QBrush(qtColors[comboBackgroundColor->currentItem()], brushStyles[comboBackgroundStyle->currentItem()])); | 289 | setBrushBackground(QBrush(qtColors[comboBackgroundColor->currentItem()], brushStyles[comboBackgroundStyle->currentItem()])); |
271 | } | 290 | } |
272 | 291 | ||
273 | void CellFormat::fontClicked(bool on) | 292 | void CellFormat::fontClicked(bool on) |
274 | { | 293 | { |
275 | fontClicked(0); | 294 | fontClicked(0); |
276 | } | 295 | } |
277 | 296 | ||
278 | void CellFormat::fontClicked(int index) | 297 | void CellFormat::fontClicked(int index) |
279 | { | 298 | { |
280 | changedFont=TRUE; | 299 | changedFont=TRUE; |
281 | setTextFont(QFont(comboFontFamily->currentText(), comboFontSize->currentText().toInt(), checkFontBold->isChecked() ? QFont::Bold : QFont::Normal, checkFontItalic->isChecked(), QFont::AnyCharSet), qtColors[comboFontColor->currentItem()]); | 300 | setTextFont(QFont(comboFontFamily->currentText(), comboFontSize->currentText().toInt(), checkFontBold->isChecked() ? QFont::Bold : QFont::Normal, checkFontItalic->isChecked(), QFont::AnyCharSet), qtColors[comboFontColor->currentItem()]); |
282 | } | 301 | } |
283 | 302 | ||
284 | void CellFormat::alignClicked(bool on) | 303 | void CellFormat::alignClicked(bool on) |
285 | { | 304 | { |
286 | alignClicked(0); | 305 | alignClicked(0); |
287 | } | 306 | } |
288 | 307 | ||
289 | void CellFormat::alignClicked(int index) | 308 | void CellFormat::alignClicked(int index) |
290 | { | 309 | { |
291 | changedAlign=TRUE; | 310 | changedAlign=TRUE; |
292 | setTextAlign((Qt::AlignmentFlags)(flagsVAlign[comboAlignmentVertical->currentItem()] | flagsHAlign[comboAlignmentHorizontal->currentItem()] | (checkAlignmentWrap->isChecked() ? Qt::WordBreak : 0))); | 311 | setTextAlign((Qt::AlignmentFlags)(flagsVAlign[comboAlignmentVertical->currentItem()] | flagsHAlign[comboAlignmentHorizontal->currentItem()] | (checkAlignmentWrap->isChecked() ? Qt::WordBreak : 0))); |
293 | } | 312 | } |
294 | 313 | ||
295 | void CellFormat::createSizeCombo(QComboBox *combo) | 314 | void CellFormat::createSizeCombo(QComboBox *combo) |
296 | { | 315 | { |
297 | combo->clear(); | 316 | combo->clear(); |
298 | QValueList<int> sizes=fontDB.standardSizes(); | 317 | QValueList<int> sizes=fontDB.standardSizes(); |
299 | for (QValueList<int>::ConstIterator i=sizes.begin(); i!=sizes.end(); ++i) | 318 | for (QValueList<int>::ConstIterator i=sizes.begin(); i!=sizes.end(); ++i) |
300 | combo->insertItem(QString::number(*i)); | 319 | combo->insertItem(QString::number(*i)); |
301 | } | 320 | } |
302 | 321 | ||
303 | void CellFormat::borderClicked(BorderEditor::BorderArea area) | 322 | void CellFormat::borderClicked(BorderEditor::BorderArea area) |
304 | { | 323 | { |
305 | QPen newPen(qtColors[comboBordersColor->currentItem()], comboBordersWidth->currentItem()+1, Qt::SolidLine); | 324 | QPen newPen(qtColors[comboBordersColor->currentItem()], comboBordersWidth->currentItem()+1, Qt::SolidLine); |
306 | if (newPen==borderEditor->getPen(area)) | 325 | if (newPen==borderEditor->getPen(area)) |
307 | borderEditor->setPen(QPen(Qt::gray, 1, Qt::NoPen), area); | 326 | borderEditor->setPen(QPen(Qt::gray, 1, Qt::NoPen), area); |
308 | else | 327 | else |
309 | borderEditor->setPen(newPen, area); | 328 | borderEditor->setPen(newPen, area); |
310 | } | 329 | } |
311 | 330 | ||
312 | int CellFormat::findComboItemIndex(QComboBox *combo, const QString &item) | 331 | int CellFormat::findComboItemIndex(QComboBox *combo, const QString &item) |
313 | { | 332 | { |
314 | for (int i=0; i<combo->count(); ++i) | 333 | for (int i=0; i<combo->count(); ++i) |
315 | if (combo->text(i)==item) | 334 | if (combo->text(i)==item) |
316 | return i; | 335 | return i; |
317 | return 0; | 336 | return 0; |
318 | } | 337 | } |
319 | 338 | ||
320 | QComboBox *CellFormat::createCombo(comboType type, QWidget *parent, | 339 | QComboBox *CellFormat::createCombo(comboType type, QWidget *parent, |
321 | const QString &caption, int y) | 340 | const QString &caption, int y) |
322 | { | 341 | { |
323 | QComboBox *combo=new QComboBox(FALSE, parent); | 342 | QComboBox *combo=new QComboBox(FALSE, parent); |
324 | combo->setGeometry(70, y, COMBO_WIDTHS, COMBO_HEIGHTS); | 343 | combo->setGeometry(70, y, COMBO_WIDTHS, COMBO_HEIGHTS); |
325 | combo->setSizeLimit(5); | 344 | combo->setSizeLimit(5); |
326 | 345 | ||
327 | switch (type) | 346 | switch (type) |
328 | { | 347 | { |
329 | case COMBO_WIDTH: createWidthCombo(combo); break; | 348 | case COMBO_WIDTH: createWidthCombo(combo); break; |
330 | case COMBO_STYLE: createStyleCombo(combo); break; | 349 | case COMBO_STYLE: createStyleCombo(combo); break; |
331 | case COMBO_FONT: createFontCombo(combo); break; | 350 | case COMBO_FONT: createFontCombo(combo); break; |
@@ -333,189 +352,189 @@ QComboBox *CellFormat::createCombo(comboType type, QWidget *parent, | |||
333 | case COMBO_COLOR: createColorCombo(combo); break; | 352 | case COMBO_COLOR: createColorCombo(combo); break; |
334 | case COMBO_HALIGN: createHAlignCombo(combo); break; | 353 | case COMBO_HALIGN: createHAlignCombo(combo); break; |
335 | case COMBO_VALIGN: createVAlignCombo(combo); break; | 354 | case COMBO_VALIGN: createVAlignCombo(combo); break; |
336 | default: break; | 355 | default: break; |
337 | } | 356 | } |
338 | 357 | ||
339 | QLabel *label=new QLabel(combo, caption, parent); | 358 | QLabel *label=new QLabel(combo, caption, parent); |
340 | label->setGeometry(10, y, 50, COMBO_HEIGHTS); | 359 | label->setGeometry(10, y, 50, COMBO_HEIGHTS); |
341 | 360 | ||
342 | return combo; | 361 | return combo; |
343 | } | 362 | } |
344 | 363 | ||
345 | void CellFormat::createHAlignCombo(QComboBox *combo) | 364 | void CellFormat::createHAlignCombo(QComboBox *combo) |
346 | { | 365 | { |
347 | for (int i=0; i<HALIGN_COUNT; ++i) | 366 | for (int i=0; i<HALIGN_COUNT; ++i) |
348 | combo->insertItem(namesHAlign[i]); | 367 | combo->insertItem(namesHAlign[i]); |
349 | } | 368 | } |
350 | 369 | ||
351 | void CellFormat::createVAlignCombo(QComboBox *combo) | 370 | void CellFormat::createVAlignCombo(QComboBox *combo) |
352 | { | 371 | { |
353 | for (int i=0; i<VALIGN_COUNT; ++i) | 372 | for (int i=0; i<VALIGN_COUNT; ++i) |
354 | combo->insertItem(namesVAlign[i]); | 373 | combo->insertItem(namesVAlign[i]); |
355 | } | 374 | } |
356 | 375 | ||
357 | void CellFormat::createWidthCombo(QComboBox *combo) | 376 | void CellFormat::createWidthCombo(QComboBox *combo) |
358 | { | 377 | { |
359 | int width=combo->listBox()->maxItemWidth(); | 378 | int width=combo->listBox()->maxItemWidth(); |
360 | QPixmap pix(width, COMBO_HEIGHTS); | 379 | QPixmap pix(width, COMBO_HEIGHTS); |
361 | QPainter p(&pix); | 380 | QPainter p(&pix); |
362 | 381 | ||
363 | for (int i=1; i<=6; ++i) | 382 | for (int i=1; i<=6; ++i) |
364 | { | 383 | { |
365 | pix.fill(); | 384 | pix.fill(); |
366 | p.setPen(QPen(Qt::black, i, Qt::SolidLine)); | 385 | p.setPen(QPen(Qt::black, i, Qt::SolidLine)); |
367 | p.drawLine(5, COMBO_HEIGHTS/2, width-10, COMBO_HEIGHTS/2); | 386 | p.drawLine(5, COMBO_HEIGHTS/2, width-10, COMBO_HEIGHTS/2); |
368 | combo->insertItem(pix); | 387 | combo->insertItem(pix); |
369 | } | 388 | } |
370 | } | 389 | } |
371 | 390 | ||
372 | void CellFormat::createFontCombo(QComboBox *combo) | 391 | void CellFormat::createFontCombo(QComboBox *combo) |
373 | { | 392 | { |
374 | combo->insertStringList(fontDB.families()); | 393 | combo->insertStringList(fontDB.families()); |
375 | } | 394 | } |
376 | 395 | ||
377 | void CellFormat::createStyleCombo(QComboBox *combo) | 396 | void CellFormat::createStyleCombo(QComboBox *combo) |
378 | { | 397 | { |
379 | int width=combo->listBox()->maxItemWidth(); | 398 | int width=combo->listBox()->maxItemWidth(); |
380 | QPixmap pix(width, COMBO_HEIGHTS); | 399 | QPixmap pix(width, COMBO_HEIGHTS); |
381 | QPainter p(&pix); | 400 | QPainter p(&pix); |
382 | 401 | ||
383 | for (int i=0; i<STYLE_COUNT; ++i) | 402 | for (int i=0; i<STYLE_COUNT; ++i) |
384 | { | 403 | { |
385 | pix.fill(); | 404 | pix.fill(); |
386 | p.fillRect(5, 5, width-10, COMBO_HEIGHTS-10, brushStyles[i]); | 405 | p.fillRect(5, 5, width-10, COMBO_HEIGHTS-10, brushStyles[i]); |
387 | combo->insertItem(pix); | 406 | combo->insertItem(pix); |
388 | } | 407 | } |
389 | } | 408 | } |
390 | 409 | ||
391 | void CellFormat::createColorCombo(QComboBox *combo) | 410 | void CellFormat::createColorCombo(QComboBox *combo) |
392 | { | 411 | { |
393 | int width=combo->listBox()->maxItemWidth(); | 412 | int width=combo->listBox()->maxItemWidth(); |
394 | QPixmap pix(width, COMBO_HEIGHTS); | 413 | QPixmap pix(width, COMBO_HEIGHTS); |
395 | QPainter p(&pix); | 414 | QPainter p(&pix); |
396 | 415 | ||
397 | for (int i=0; i<COLOR_COUNT; ++i) | 416 | for (int i=0; i<COLOR_COUNT; ++i) |
398 | { | 417 | { |
399 | pix.fill(); | 418 | pix.fill(); |
400 | p.setPen(QPen(qtColors[i], 3, Qt::SolidLine)); | 419 | p.setPen(QPen(qtColors[i], 3, Qt::SolidLine)); |
401 | p.drawLine(5, COMBO_HEIGHTS/2, width-10, COMBO_HEIGHTS/2); | 420 | p.drawLine(5, COMBO_HEIGHTS/2, width-10, COMBO_HEIGHTS/2); |
402 | combo->insertItem(pix); | 421 | combo->insertItem(pix); |
403 | } | 422 | } |
404 | } | 423 | } |
405 | 424 | ||
406 | int CellFormat::exec(Sheet *s) | 425 | int CellFormat::exec(Sheet *s) |
407 | { | 426 | { |
408 | sheet=s; | 427 | sheet=s; |
409 | int row1, row2, col1, col2, row, col; | 428 | int row1, row2, col1, col2, row, col; |
410 | sheet->getSelection(&row1, &col1, &row2, &col2); | 429 | sheet->getSelection(&row1, &col1, &row2, &col2); |
411 | 430 | ||
412 | QPen penTop=sheet->getPen(row1-1, col1, 0), penBottom=sheet->getPen(row2, col1, 0), | 431 | QPen penTop=sheet->getPen(row1-1, col1, 0), penBottom=sheet->getPen(row2, col1, 0), |
413 | penLeft=sheet->getPen(row1, col1-1, 1), penRight=sheet->getPen(row1, col2, 1), | 432 | penLeft=sheet->getPen(row1, col1-1, 1), penRight=sheet->getPen(row1, col2, 1), |
414 | penVert=sheet->getPen(row1, col1, 1), penHorz=sheet->getPen(row1, col1, 0), | 433 | penVert=sheet->getPen(row1, col1, 1), penHorz=sheet->getPen(row1, col1, 0), |
415 | penDefault=borderEditor->getDefaultPen(); | 434 | penDefault=borderEditor->getDefaultPen(); |
416 | for (row=row1+1; row<=row2; ++row) | 435 | for (row=row1+1; row<=row2; ++row) |
417 | if (sheet->getPen(row, col1-1, 1)!=penLeft) | 436 | if (sheet->getPen(row, col1-1, 1)!=penLeft) |
418 | { | 437 | { |
419 | penLeft=penDefault; | 438 | penLeft=penDefault; |
420 | break; | 439 | break; |
421 | } | 440 | } |
422 | for (row=row1+1; row<=row2; ++row) | 441 | for (row=row1+1; row<=row2; ++row) |
423 | if (sheet->getPen(row, col2, 1)!=penRight) | 442 | if (sheet->getPen(row, col2, 1)!=penRight) |
424 | { | 443 | { |
425 | penRight=penDefault; | 444 | penRight=penDefault; |
426 | break; | 445 | break; |
427 | } | 446 | } |
428 | for (col=col1+1; col<=col2; ++col) | 447 | for (col=col1+1; col<=col2; ++col) |
429 | if (sheet->getPen(row1-1, col, 0)!=penTop) | 448 | if (sheet->getPen(row1-1, col, 0)!=penTop) |
430 | { | 449 | { |
431 | penTop=penDefault; | 450 | penTop=penDefault; |
432 | break; | 451 | break; |
433 | } | 452 | } |
434 | for (col=col1+1; col<=col2; ++col) | 453 | for (col=col1+1; col<=col2; ++col) |
435 | if (sheet->getPen(row2, col, 0)!=penBottom) | 454 | if (sheet->getPen(row2, col, 0)!=penBottom) |
436 | { | 455 | { |
437 | penBottom=penDefault; | 456 | penBottom=penDefault; |
438 | break; | 457 | break; |
439 | } | 458 | } |
440 | for (row=row1; row<=row2; ++row) | 459 | for (row=row1; row<=row2; ++row) |
441 | for (col=col1; col<col2; ++col) | ||
442 | if (sheet->getPen(row, col, 1)!=penVert) | ||
443 | { | ||
444 | penVert=penDefault; | ||
445 | break; | ||
446 | } | ||
447 | for (row=row1; row<row2; ++row) | ||
448 | for (col=col1; col<=col2; ++col) | ||
449 | if (sheet->getPen(row, col, 0)!=penHorz) | ||
450 | { | ||
451 | penHorz=penDefault; | ||
452 | break; | ||
453 | } | ||
454 | |||
455 | borderEditor->setPen(penTop, BorderEditor::Top); | ||
456 | borderEditor->setPen(penBottom, BorderEditor::Bottom); | ||
457 | borderEditor->setPen(penLeft, BorderEditor::Left); | ||
458 | borderEditor->setPen(penRight, BorderEditor::Right); | ||
459 | borderEditor->setPen(penVert, BorderEditor::Vert); | ||
460 | borderEditor->setPen(penHorz, BorderEditor::Horz); | ||
461 | |||
462 | setBrushBackground(sheet->getBrush(row1, col1)); | ||
463 | setTextFont(sheet->getFont(row1, col1), sheet->getFontColor(row1, col1)); | ||
464 | setTextAlign(sheet->getAlignment(row1, col1)); | ||
465 | |||
466 | if (QDialog::exec()==QDialog::Accepted) | ||
467 | { | ||
468 | penTop=borderEditor->getPen(BorderEditor::Top); | ||
469 | penBottom=borderEditor->getPen(BorderEditor::Bottom); | ||
470 | penLeft=borderEditor->getPen(BorderEditor::Left); | ||
471 | penRight=borderEditor->getPen(BorderEditor::Right); | ||
472 | penVert=borderEditor->getPen(BorderEditor::Vert); | ||
473 | penHorz=borderEditor->getPen(BorderEditor::Horz); | ||
474 | |||
475 | if (penTop!=penDefault) | ||
476 | for (col=col1; col<=col2; ++col) | ||
477 | sheet->setPen(row1-1, col, 0, penTop); | ||
478 | if (penBottom!=penDefault) | ||
479 | for (col=col1; col<=col2; ++col) | ||
480 | sheet->setPen(row2, col, 0, penBottom); | ||
481 | if (penLeft!=penDefault) | ||
482 | for (row=row1; row<=row2; ++row) | ||
483 | sheet->setPen(row, col1-1, 1, penLeft); | ||
484 | if (penRight!=penDefault) | ||
485 | for (row=row1; row<=row2; ++row) | ||
486 | sheet->setPen(row, col2, 1, penRight); | ||
487 | if (penVert!=penDefault) | ||
488 | for (row=row1; row<=row2; ++row) | ||
489 | for (col=col1; col<col2; ++col) | 460 | for (col=col1; col<col2; ++col) |
490 | sheet->setPen(row, col, 1, penVert); | 461 | if (sheet->getPen(row, col, 1)!=penVert) |
491 | if (penHorz!=penDefault) | 462 | { |
492 | for (row=row1; row<row2; ++row) | 463 | penVert=penDefault; |
493 | for (col=col1; col<=col2; ++col) | 464 | break; |
494 | sheet->setPen(row, col, 0, penHorz); | 465 | } |
495 | 466 | for (row=row1; row<row2; ++row) | |
496 | if (changedBrush) | ||
497 | { | ||
498 | for (row=row1; row<=row2; ++row) | ||
499 | for (col=col1; col<=col2; ++col) | 467 | for (col=col1; col<=col2; ++col) |
500 | sheet->setBrush(row, col, brushBackground); | 468 | if (sheet->getPen(row, col, 0)!=penHorz) |
501 | } | 469 | { |
502 | 470 | penHorz=penDefault; | |
503 | if (changedAlign) | 471 | break; |
504 | { | 472 | } |
505 | for (row=row1; row<=row2; ++row) | 473 | |
506 | for (col=col1; col<=col2; ++col) | 474 | borderEditor->setPen(penTop, BorderEditor::Top); |
507 | sheet->setTextAlign(row, col, textAlignment); | 475 | borderEditor->setPen(penBottom, BorderEditor::Bottom); |
508 | } | 476 | borderEditor->setPen(penLeft, BorderEditor::Left); |
509 | 477 | borderEditor->setPen(penRight, BorderEditor::Right); | |
510 | if (changedFont) | 478 | borderEditor->setPen(penVert, BorderEditor::Vert); |
479 | borderEditor->setPen(penHorz, BorderEditor::Horz); | ||
480 | |||
481 | setBrushBackground(sheet->getBrush(row1, col1)); | ||
482 | setTextFont(sheet->getFont(row1, col1), sheet->getFontColor(row1, col1)); | ||
483 | setTextAlign(sheet->getAlignment(row1, col1)); | ||
484 | |||
485 | if (QDialog::exec()==QDialog::Accepted) | ||
511 | { | 486 | { |
512 | for (row=row1; row<=row2; ++row) | 487 | penTop=borderEditor->getPen(BorderEditor::Top); |
513 | for (col=col1; col<=col2; ++col) | 488 | penBottom=borderEditor->getPen(BorderEditor::Bottom); |
514 | sheet->setTextFont(row, col, fontFont, fontColor); | 489 | penLeft=borderEditor->getPen(BorderEditor::Left); |
490 | penRight=borderEditor->getPen(BorderEditor::Right); | ||
491 | penVert=borderEditor->getPen(BorderEditor::Vert); | ||
492 | penHorz=borderEditor->getPen(BorderEditor::Horz); | ||
493 | |||
494 | if (penTop!=penDefault) | ||
495 | for (col=col1; col<=col2; ++col) | ||
496 | sheet->setPen(row1-1, col, 0, penTop); | ||
497 | if (penBottom!=penDefault) | ||
498 | for (col=col1; col<=col2; ++col) | ||
499 | sheet->setPen(row2, col, 0, penBottom); | ||
500 | if (penLeft!=penDefault) | ||
501 | for (row=row1; row<=row2; ++row) | ||
502 | sheet->setPen(row, col1-1, 1, penLeft); | ||
503 | if (penRight!=penDefault) | ||
504 | for (row=row1; row<=row2; ++row) | ||
505 | sheet->setPen(row, col2, 1, penRight); | ||
506 | if (penVert!=penDefault) | ||
507 | for (row=row1; row<=row2; ++row) | ||
508 | for (col=col1; col<col2; ++col) | ||
509 | sheet->setPen(row, col, 1, penVert); | ||
510 | if (penHorz!=penDefault) | ||
511 | for (row=row1; row<row2; ++row) | ||
512 | for (col=col1; col<=col2; ++col) | ||
513 | sheet->setPen(row, col, 0, penHorz); | ||
514 | |||
515 | if (changedBrush) | ||
516 | { | ||
517 | for (row=row1; row<=row2; ++row) | ||
518 | for (col=col1; col<=col2; ++col) | ||
519 | sheet->setBrush(row, col, brushBackground); | ||
520 | } | ||
521 | |||
522 | if (changedAlign) | ||
523 | { | ||
524 | for (row=row1; row<=row2; ++row) | ||
525 | for (col=col1; col<=col2; ++col) | ||
526 | sheet->setTextAlign(row, col, textAlignment); | ||
527 | } | ||
528 | |||
529 | if (changedFont) | ||
530 | { | ||
531 | for (row=row1; row<=row2; ++row) | ||
532 | for (col=col1; col<=col2; ++col) | ||
533 | sheet->setTextFont(row, col, fontFont, fontColor); | ||
534 | } | ||
535 | return QDialog::Accepted; | ||
515 | } | 536 | } |
516 | return QDialog::Accepted; | 537 | return QDialog::Rejected; |
517 | } | ||
518 | return QDialog::Rejected; | ||
519 | } | 538 | } |
520 | 539 | ||
521 | // | 540 | // |
@@ -523,104 +542,103 @@ int CellFormat::exec(Sheet *s) | |||
523 | // | 542 | // |
524 | 543 | ||
525 | BorderEditor::BorderEditor(QWidget *parent) | 544 | BorderEditor::BorderEditor(QWidget *parent) |
526 | :QFrame(parent) | 545 | :QFrame(parent) |
527 | { | 546 | { |
528 | setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); | 547 | setFrameStyle(QFrame::StyledPanel | QFrame::Sunken); |
529 | } | 548 | } |
530 | 549 | ||
531 | BorderEditor::~BorderEditor() | 550 | BorderEditor::~BorderEditor() |
532 | { | 551 | {} |
533 | } | ||
534 | 552 | ||
535 | void BorderEditor::drawContents(QPainter *p) | 553 | void BorderEditor::drawContents(QPainter *p) |
536 | { | 554 | { |
537 | QFrame::drawContents(p); | 555 | QFrame::drawContents(p); |
538 | 556 | ||
539 | int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; | 557 | int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; |
540 | int lineFirstX=x+width/6, lineFirstY=y+height/6, lineLastX=contentsRect().right()-width/6, lineLastY=contentsRect().bottom()-height/6; | 558 | int lineFirstX=x+width/6, lineFirstY=y+height/6, lineLastX=contentsRect().right()-width/6, lineLastY=contentsRect().bottom()-height/6; |
541 | 559 | ||
542 | p->fillRect(contentsRect(), Qt::white); | 560 | p->fillRect(contentsRect(), Qt::white); |
543 | 561 | ||
544 | p->fillRect(x+width/3, y+height/3, width, height, Qt::gray); | 562 | p->fillRect(x+width/3, y+height/3, width, height, Qt::gray); |
545 | p->fillRect(x+(5*width/3), y+height/3, width, height, Qt::gray); | 563 | p->fillRect(x+(5*width/3), y+height/3, width, height, Qt::gray); |
546 | p->fillRect(x+width/3, y+(5*height)/3, width, height, Qt::gray); | 564 | p->fillRect(x+width/3, y+(5*height)/3, width, height, Qt::gray); |
547 | p->fillRect(x+(5*width)/3, y+(5*height)/3, width, height, Qt::gray); | 565 | p->fillRect(x+(5*width)/3, y+(5*height)/3, width, height, Qt::gray); |
548 | 566 | ||
549 | if (penTop.width()>0) | 567 | if (penTop.width()>0) |
550 | { | 568 | { |
551 | p->setPen(penTop); | 569 | p->setPen(penTop); |
552 | p->drawLine(lineFirstX, lineFirstY, lineLastX, lineFirstY); | 570 | p->drawLine(lineFirstX, lineFirstY, lineLastX, lineFirstY); |
553 | } | 571 | } |
554 | if (penBottom.width()>0) | 572 | if (penBottom.width()>0) |
555 | { | 573 | { |
556 | p->setPen(penBottom); | 574 | p->setPen(penBottom); |
557 | p->drawLine(lineFirstX, lineLastY, lineLastX, lineLastY); | 575 | p->drawLine(lineFirstX, lineLastY, lineLastX, lineLastY); |
558 | } | 576 | } |
559 | if (penHorz.width()>0) | 577 | if (penHorz.width()>0) |
560 | { | 578 | { |
561 | p->setPen(penHorz); | 579 | p->setPen(penHorz); |
562 | p->drawLine(lineFirstX, y+contentsRect().height()/2, lineLastX, y+contentsRect().height()/2); | 580 | p->drawLine(lineFirstX, y+contentsRect().height()/2, lineLastX, y+contentsRect().height()/2); |
563 | } | 581 | } |
564 | if (penLeft.width()>0) | 582 | if (penLeft.width()>0) |
565 | { | 583 | { |
566 | p->setPen(penLeft); | 584 | p->setPen(penLeft); |
567 | p->drawLine(lineFirstX, lineFirstY, lineFirstX, lineLastY); | 585 | p->drawLine(lineFirstX, lineFirstY, lineFirstX, lineLastY); |
568 | } | 586 | } |
569 | if (penRight.width()>0) | 587 | if (penRight.width()>0) |
570 | { | 588 | { |
571 | p->setPen(penRight); | 589 | p->setPen(penRight); |
572 | p->drawLine(lineLastX, lineFirstY, lineLastX, lineLastY); | 590 | p->drawLine(lineLastX, lineFirstY, lineLastX, lineLastY); |
573 | } | 591 | } |
574 | if (penVert.width()>0) | 592 | if (penVert.width()>0) |
575 | { | 593 | { |
576 | p->setPen(penVert); | 594 | p->setPen(penVert); |
577 | p->drawLine(x+contentsRect().width()/2, lineFirstY, x+contentsRect().width()/2, lineLastY); | 595 | p->drawLine(x+contentsRect().width()/2, lineFirstY, x+contentsRect().width()/2, lineLastY); |
578 | } | 596 | } |
579 | } | 597 | } |
580 | 598 | ||
581 | void BorderEditor::setPen(const QPen &pen, BorderArea area) | 599 | void BorderEditor::setPen(const QPen &pen, BorderArea area) |
582 | { | 600 | { |
583 | switch (area) | 601 | switch (area) |
584 | { | 602 | { |
585 | case Top: penTop=pen; break; | 603 | case Top: penTop=pen; break; |
586 | case Bottom: penBottom=pen; break; | 604 | case Bottom: penBottom=pen; break; |
587 | case Left: penLeft=pen; break; | 605 | case Left: penLeft=pen; break; |
588 | case Right: penRight=pen; break; | 606 | case Right: penRight=pen; break; |
589 | case Horz: penHorz=pen; break; | 607 | case Horz: penHorz=pen; break; |
590 | case Vert: penVert=pen; break; | 608 | case Vert: penVert=pen; break; |
591 | }; | 609 | }; |
592 | update(); | 610 | update(); |
593 | } | 611 | } |
594 | 612 | ||
595 | void BorderEditor::mouseReleaseEvent(QMouseEvent *e) | 613 | void BorderEditor::mouseReleaseEvent(QMouseEvent *e) |
596 | { | 614 | { |
597 | QFrame::mouseReleaseEvent(e); | 615 | QFrame::mouseReleaseEvent(e); |
598 | 616 | ||
599 | int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; | 617 | int x=contentsRect().x(), y=contentsRect().y(), width=contentsRect().width()/3, height=contentsRect().height()/3; |
600 | BorderArea area=None; | 618 | BorderArea area=None; |
601 | 619 | ||
602 | if (e->x()<x+width/3) area=Left; | 620 | if (e->x()<x+width/3) area=Left; |
603 | if (e->x()>x+(8*width)/3) area=Right; | 621 | if (e->x()>x+(8*width)/3) area=Right; |
604 | if (e->x()>x+(4*width)/3 && e->x()<x+(5*width)/3) area=Vert; | 622 | if (e->x()>x+(4*width)/3 && e->x()<x+(5*width)/3) area=Vert; |
605 | 623 | ||
606 | if (e->y()<y+height/3) area=Top; | 624 | if (e->y()<y+height/3) area=Top; |
607 | if (e->y()>y+(8*height)/3) area=Bottom; | 625 | if (e->y()>y+(8*height)/3) area=Bottom; |
608 | if (e->y()>y+(4*height)/3 && e->y()<y+(5*height)/3) area=Horz; | 626 | if (e->y()>y+(4*height)/3 && e->y()<y+(5*height)/3) area=Horz; |
609 | 627 | ||
610 | if (area!=None) | 628 | if (area!=None) |
611 | emit clicked(area); | 629 | emit clicked(area); |
612 | } | 630 | } |
613 | 631 | ||
614 | QPen BorderEditor::getPen(BorderArea area) | 632 | QPen BorderEditor::getPen(BorderArea area) |
615 | { | 633 | { |
616 | switch (area) | 634 | switch (area) |
617 | { | 635 | { |
618 | case Top: return penTop; | 636 | case Top: return penTop; |
619 | case Bottom: return penBottom; | 637 | case Bottom: return penBottom; |
620 | case Left: return penLeft; | 638 | case Left: return penLeft; |
621 | case Right: return penRight; | 639 | case Right: return penRight; |
622 | case Horz: return penHorz; | 640 | case Horz: return penHorz; |
623 | case Vert: return penVert; | 641 | case Vert: return penVert; |
624 | }; | 642 | }; |
625 | return getDefaultPen(); | 643 | return getDefaultPen(); |
626 | } | 644 | } |