1 /**
2 * \file GuiBox.cpp
3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
5 *
6 * \author Jürgen Vigna (Minipage stuff)
7 * \author Martin Vermeer
8 * \author Jürgen Spitzmüller
9 * \author Uwe Stöhr
10 *
11 * Full author contact details are available in file CREDITS.
12 */
13
14 #include <config.h>
15
16 #include "GuiBox.h"
17
18 #include "GuiApplication.h"
19 #include "ColorCache.h"
20 #include "ColorSet.h"
21 #include "LengthCombo.h"
22 #include "Length.h"
23 #include "qt_helpers.h"
24 #include "Validator.h"
25
26 #include "insets/InsetBox.h"
27
28 #include "support/gettext.h"
29 #include "support/lstrings.h"
30
31 #include <QComboBox>
32 #include <QLineEdit>
33 #include <QPushButton>
34
35 #ifdef IN
36 #undef IN
37 #endif
38
39 using namespace std;
40
41
42 namespace lyx {
43 namespace frontend {
44
boxGuiIds()45 static QStringList boxGuiIds()
46 {
47 return QStringList()
48 << "Frameless" << "Boxed"
49 << "ovalbox" << "Ovalbox"
50 << "Shadowbox" << "Shaded"
51 << "Doublebox";
52 }
53
54
boxGuiNames()55 static QStringList boxGuiNames()
56 {
57 return QStringList()
58 << qt_("No frame") << qt_("Simple rectangular frame")
59 << qt_("Oval frame, thin") << qt_("Oval frame, thick")
60 << qt_("Drop shadow") << qt_("Shaded background")
61 << qt_("Double rectangular frame");
62 }
63
64
boxGuiSpecialLengthIds()65 static QStringList boxGuiSpecialLengthIds()
66 {
67 return QStringList() << "height" << "depth"
68 << "totalheight" << "width";
69 }
70
71
boxGuiSpecialLengthNames()72 static QStringList boxGuiSpecialLengthNames()
73 {
74 return QStringList() << qt_("Height") << qt_("Depth")
75 << qt_("Total Height") << qt_("Width");
76 }
77
78
colors()79 static QList<ColorCode> colors()
80 {
81 QList<ColorCode> colors;
82 colors << Color_black;
83 colors << Color_white;
84 colors << Color_blue;
85 colors << Color_brown;
86 colors << Color_cyan;
87 colors << Color_darkgray;
88 colors << Color_gray;
89 colors << Color_green;
90 colors << Color_lightgray;
91 colors << Color_lime;
92 colors << Color_magenta;
93 colors << Color_olive;
94 colors << Color_orange;
95 colors << Color_pink;
96 colors << Color_purple;
97 colors << Color_red;
98 colors << Color_teal;
99 colors << Color_violet;
100 colors << Color_yellow;
101 return colors;
102 }
103
104
GuiBox(QWidget * parent)105 GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
106 {
107 setupUi(this);
108
109 // fill the box type choice
110 ids_ = boxGuiIds();
111 gui_names_ = boxGuiNames();
112 for (int i = 0; i != ids_.size(); ++i)
113 typeCO->addItem(gui_names_[i], ids_[i]);
114
115 // add the special units to the height choice
116 // width needs different handling
117 ids_spec_ = boxGuiSpecialLengthIds();
118 gui_names_spec_ = boxGuiSpecialLengthNames();
119 for (int i = 0; i != ids_spec_.size(); ++i)
120 heightUnitsLC->addItem(gui_names_spec_[i], ids_spec_[i]);
121
122 connect(widthED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
123 connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
124 this, SIGNAL(changed()));
125 connect(valignCO, SIGNAL(highlighted(QString)), this, SIGNAL(changed()));
126 connect(heightED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
127 connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
128 this, SIGNAL(changed()));
129 connect(halignCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
130 connect(ialignCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
131 connect(thicknessED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
132 connect(thicknessUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
133 this, SIGNAL(changed()));
134 connect(separationED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
135 connect(separationUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
136 this, SIGNAL(changed()));
137 connect(shadowsizeED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
138 connect(shadowsizeUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
139 this, SIGNAL(changed()));
140 connect(backgroundColorCO, SIGNAL(currentIndexChanged(int)),
141 this, SIGNAL(changed()));
142
143 heightED->setValidator(unsignedLengthValidator(heightED));
144 widthED->setValidator(unsignedLengthValidator(widthED));
145 thicknessED->setValidator(unsignedLengthValidator(thicknessED));
146 separationED->setValidator(unsignedLengthValidator(separationED));
147 shadowsizeED->setValidator(unsignedLengthValidator(shadowsizeED));
148
149 // initialize the length validator
150 addCheckedWidget(widthED, widthCB);
151 addCheckedWidget(heightED, heightCB);
152 addCheckedWidget(thicknessED, thicknessLA);
153 addCheckedWidget(separationED, separationLA);
154 addCheckedWidget(shadowsizeED, shadowsizeLA);
155
156 // the background can be uncolored while the frame cannot
157 color_codes_ = colors();
158 qSort(color_codes_.begin(), color_codes_.end(), ColorSorter);
159 fillComboColor(backgroundColorCO, true);
160 fillComboColor(frameColorCO, false);
161
162 initDialog();
163 }
164
165
fillComboColor(QComboBox * combo,bool const is_none)166 void GuiBox::fillComboColor(QComboBox * combo, bool const is_none)
167 {
168 combo->clear();
169 QPixmap coloritem(32, 32);
170 QColor color;
171 // frameColorCO cannot be uncolored
172 if (is_none)
173 combo->addItem(toqstr(translateIfPossible(lcolor.getGUIName(Color_none))),
174 toqstr(lcolor.getLaTeXName(Color_none)));
175 QList<ColorCode>::const_iterator cit = color_codes_.begin();
176 for (; cit != color_codes_.end(); ++cit) {
177 QString const latexname = toqstr(lcolor.getLaTeXName(*cit));
178 QString const guiname = toqstr(translateIfPossible(lcolor.getGUIName(*cit)));
179 color = QColor(guiApp->colorCache().get(*cit, false));
180 coloritem.fill(color);
181 combo->addItem(QIcon(coloritem), guiname, latexname);
182 }
183 }
184
185
on_innerBoxCO_activated(int index)186 void GuiBox::on_innerBoxCO_activated(int index)
187 {
188 QString itype = innerBoxCO->itemData(index).toString();
189 // handle parbox and minipage the same way
190 bool const ibox = (itype != "none" && itype != "makebox");
191 if (heightCB->isChecked() && !ibox)
192 heightCB->setChecked(false);
193 widthCB->setChecked(!widthED->text().isEmpty());
194 setSpecial(ibox);
195 changed();
196 }
197
198
on_typeCO_activated(int index)199 void GuiBox::on_typeCO_activated(int index)
200 {
201 QString const type =
202 typeCO->itemData(index).toString();
203 bool const frameless = (type == "Frameless");
204 QString itype =
205 innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
206 setInnerType(frameless, itype);
207 // refresh itype because it might have been changed in setInnerType
208 itype =
209 innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
210 // handle parbox and minipage the same way
211 bool const ibox = (itype != "none" && itype != "makebox");
212 if (frameless && itype != "makebox") {
213 if (heightCB->isChecked() && !ibox)
214 heightCB->setChecked(false);
215 setSpecial(ibox);
216 }
217 if (type != "Boxed") {
218 if (type != "Frameless")
219 widthCB->setChecked(itype != "none");
220 pagebreakCB->setChecked(false);
221 }
222 // assure that the frame color is black for frameless boxes to
223 // provide the color "none"
224 int const b = frameColorCO->findData("black");
225 if (frameless && frameColorCO->currentIndex() != b)
226 frameColorCO->setCurrentIndex(b);
227 changed();
228 }
229
230
on_frameColorCO_currentIndexChanged(int index)231 void GuiBox::on_frameColorCO_currentIndexChanged(int index)
232 {
233 // if there is a non-black frame color the background cannot be uncolored
234 // therefore remove the entry "none" in this case
235 int const n = backgroundColorCO->findData("none");
236 if (index != frameColorCO->findData("black")) {
237 if (n != -1) {
238 if (backgroundColorCO->currentIndex() == n)
239 backgroundColorCO->setCurrentIndex(
240 backgroundColorCO->findData("white"));
241 backgroundColorCO->removeItem(n);
242 }
243 } else {
244 if (n == -1)
245 backgroundColorCO->insertItem(0, toqstr(translateIfPossible((lcolor.getGUIName(Color_none)))),
246 toqstr(lcolor.getLaTeXName(Color_none)));
247 }
248 changed();
249 }
250
251
initDialog()252 void GuiBox::initDialog()
253 {
254 setInnerType(true, toqstr("minipage"));
255 widthED->setText("100");
256 widthCB->setChecked(true);
257 widthCB->setEnabled(false);
258 widthUnitsLC->setCurrentItem(Length::PCW);
259 heightED->setText("1");
260 heightUnitsLC->setCurrentItem("totalheight");
261 // LaTeX's default for \fboxrule is 0.4 pt
262 thicknessED->setText("0.4");
263 thicknessUnitsLC->setCurrentItem(Length::PT);
264 // LaTeX's default for \fboxsep is 3 pt
265 separationED->setText("3");
266 separationUnitsLC->setCurrentItem(Length::PT);
267 // LaTeX's default for \shadowsize is 4 pt
268 shadowsizeED->setText("4");
269 shadowsizeUnitsLC->setCurrentItem(Length::PT);
270 }
271
272
on_widthCB_stateChanged(int)273 void GuiBox::on_widthCB_stateChanged(int)
274 {
275 changed();
276 }
277
278
on_heightCB_stateChanged(int)279 void GuiBox::on_heightCB_stateChanged(int /*state*/)
280 {
281 changed();
282 }
283
284
on_pagebreakCB_stateChanged()285 void GuiBox::on_pagebreakCB_stateChanged()
286 {
287 bool pbreak = (pagebreakCB->checkState() == Qt::Checked);
288 if (pbreak)
289 widthCB->setChecked(!pbreak);
290 if (!pbreak) {
291 on_typeCO_activated(typeCO->currentIndex());
292 return;
293 }
294 setSpecial(false);
295 changed();
296 }
297
298
paramsToDialog(Inset const * inset)299 void GuiBox::paramsToDialog(Inset const * inset)
300 {
301 InsetBox const * box = static_cast<InsetBox const *>(inset);
302 InsetBoxParams const & params = box->params();
303 QString type = toqstr(params.type);
304 if (type == "Framed") {
305 pagebreakCB->setChecked(true);
306 type = "Boxed";
307 } else {
308 pagebreakCB->setChecked(false);
309 }
310
311 typeCO->setCurrentIndex(typeCO->findData(type));
312
313 // default: minipage
314 QString inner_type = "minipage";
315 if (!params.inner_box)
316 inner_type = "none";
317 if (params.use_parbox)
318 inner_type = "parbox";
319 if (params.use_makebox)
320 inner_type = "makebox";
321 bool const frameless = (params.type == "Frameless");
322 setInnerType(frameless, inner_type);
323
324 char c = params.pos;
325 valignCO->setCurrentIndex(string("tcb").find(c, 0));
326 c = params.inner_pos;
327 ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
328 c = params.hor_pos;
329 halignCO->setCurrentIndex(string("lcrs").find(c, 0));
330
331 bool ibox = (params.inner_box && !params.use_makebox);
332 valignCO->setEnabled(ibox);
333 ialignCO->setEnabled(ibox);
334 setSpecial(ibox);
335
336 // halign is only allowed without inner box and if a width is used and if
337 // pagebreak is not used
338 halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
339 && ((!ibox && type == "Boxed") || inner_type == "makebox"));
340 // add the entry "Stretch" if the box is \makebox or \framebox and if not already there
341 if ((inner_type == "makebox" || (type == "Boxed" && inner_type == "none"))
342 && halignCO->count() < 4)
343 halignCO->addItem(qt_("Stretch"));
344 else if (inner_type != "makebox" && (type != "Boxed" && inner_type != "none"))
345 halignCO->removeItem(3);
346 // pagebreak is only allowed for Boxed without inner box
347 pagebreakCB->setEnabled(!ibox && type == "Boxed");
348
349 Length::UNIT const default_unit = Length::defaultUnit();
350
351 // the width can only be selected for makebox or framebox
352 widthCB->setEnabled(inner_type == "makebox"
353 || (type == "Boxed"
354 && !ibox && !pagebreakCB->isChecked()));
355 if (params.width.empty()) {
356 widthCB->setChecked(false);
357 lengthToWidgets(widthED, widthUnitsLC,
358 params.width, default_unit);
359 } else {
360 widthCB->setChecked(true);
361 lengthToWidgets(widthED, widthUnitsLC,
362 params.width, default_unit);
363 QString const special = toqstr(params.special);
364 if (!special.isEmpty() && special != "none")
365 widthUnitsLC->setCurrentItem(special);
366 }
367
368 widthED->setEnabled(widthCB->isChecked());
369 widthUnitsLC->setEnabled(widthCB->isChecked());
370
371 lengthToWidgets(heightED, heightUnitsLC,
372 (params.height).asString(), default_unit);
373
374 QString const height_special = toqstr(params.height_special);
375 if (!height_special.isEmpty() && height_special != "none")
376 heightUnitsLC->setCurrentItem(height_special);
377 // set no optional height if the value is the default "1\height"
378 // (special units like \height are handled as "in",
379 // FIXME: this is a very bad UI, this check box should be disabled in
380 // this case, not forced to 'unchecked' state.
381 if (height_special == "totalheight" && params.height == Length("1in"))
382 heightCB->setCheckState(Qt::Unchecked);
383 else
384 heightCB->setCheckState(Qt::Checked);
385
386 heightCB->setEnabled(ibox);
387
388 // enable line thickness only for the rectangular frame types and drop shadow
389 thicknessED->setEnabled(type == "Boxed" || type == "Doublebox" || type == "Shadowbox");
390 thicknessUnitsLC->setEnabled(type == "Boxed" || type == "Doublebox" || type == "Shadowbox");
391 lengthToWidgets(thicknessED, thicknessUnitsLC,
392 (params.thickness).asString(), default_unit);
393 // enable line separation for the allowed frame types
394 separationED->setEnabled(type == "Boxed" || type == "ovalbox" || type == "Ovalbox"
395 || type == "Doublebox" || type == "Shadowbox");
396 separationUnitsLC->setEnabled(type == "Boxed" || type == "ovalbox" || type == "Ovalbox"
397 || type == "Doublebox" || type == "Shadowbox");
398 lengthToWidgets(separationED, separationUnitsLC,
399 (params.separation).asString(), default_unit);
400 // enable shadow size for drop shadow
401 shadowsizeED->setEnabled(type == "Shadowbox");
402 shadowsizeUnitsLC->setEnabled(type == "Shadowbox");
403 lengthToWidgets(shadowsizeED, shadowsizeUnitsLC,
404 (params.shadowsize).asString(), default_unit);
405 // set color
406 frameColorCO->setCurrentIndex(frameColorCO->findData(toqstr(params.framecolor)));
407 backgroundColorCO->setCurrentIndex(backgroundColorCO->findData(toqstr(params.backgroundcolor)));
408 }
409
410
dialogToParams() const411 docstring GuiBox::dialogToParams() const
412 {
413 bool const pagebreak =
414 pagebreakCB->isEnabled() && pagebreakCB->isChecked();
415 string box_type;
416 if (pagebreak)
417 box_type = "Framed";
418 else
419 box_type = fromqstr(typeCO->itemData(
420 typeCO->currentIndex()).toString());
421
422 InsetBoxParams params(box_type);
423 params.inner_box =
424 (!pagebreak && innerBoxCO->currentText() != qt_("None"));
425 params.use_parbox =
426 (!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
427 params.use_makebox =
428 (!pagebreak && innerBoxCO->currentText() == qt_("Makebox"));
429
430 params.pos = "tcb"[valignCO->currentIndex()];
431 params.inner_pos = "tcbs"[ialignCO->currentIndex()];
432 params.hor_pos = "lcrs"[halignCO->currentIndex()];
433
434 QString unit =
435 widthUnitsLC->itemData(widthUnitsLC->currentIndex()).toString();
436 QString value = widthED->text();
437
438 if (widthED->isEnabled()) {
439 if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
440 params.special = fromqstr(unit);
441 // Note: the unit is simply ignored in this case
442 params.width = Length(widgetToDouble(widthED), Length::IN);
443 } else {
444 params.special = "none";
445 // we must specify a valid length in this case
446 if (value.isEmpty())
447 widthED->setText("0");
448 params.width = Length(widgetsToLength(widthED, widthUnitsLC));
449 }
450 } else {
451 params.special = "none";
452 params.width = Length();
453 }
454
455 // the height parameter is omitted if the value
456 // is "1in" and "Total Height" is used as unit.
457 // 1in + "Total Height" means "1\height" which is the LaTeX default
458 // if no height is given
459 if (heightCB->checkState() == Qt::Unchecked) {
460 params.height = Length("1in");
461 params.height_special = "totalheight";
462 } else {
463 unit = heightUnitsLC->itemData(heightUnitsLC->currentIndex()).toString();
464 value = heightED->text();
465 if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
466 params.height_special = fromqstr(unit);
467 // Note: the unit is simply ignored in this case
468 params.height = Length(widgetToDouble(heightED), Length::IN);
469 } else {
470 params.height_special = "none";
471 params.height =
472 Length(widgetsToLength(heightED, heightUnitsLC));
473 }
474 }
475
476 // handle the line thickness, line separation and shadow size
477 if (thicknessED->isEnabled())
478 params.thickness = Length(widgetsToLength(thicknessED, thicknessUnitsLC));
479 else
480 params.thickness = Length("0.4pt");
481 if (separationED->isEnabled())
482 params.separation = Length(widgetsToLength(separationED, separationUnitsLC));
483 else
484 params.separation = Length("3pt");
485 if (separationED->isEnabled())
486 params.shadowsize = Length(widgetsToLength(shadowsizeED, shadowsizeUnitsLC));
487 else
488 params.shadowsize = Length("4pt");
489 if (frameColorCO->isEnabled())
490 params.framecolor =
491 fromqstr(frameColorCO->itemData(frameColorCO->currentIndex()).toString());
492 else
493 params.framecolor = "black";
494 if (backgroundColorCO->isEnabled())
495 params.backgroundcolor =
496 fromqstr(backgroundColorCO->itemData(backgroundColorCO->currentIndex()).toString());
497 else
498 params.backgroundcolor = "none";
499
500 return from_ascii(InsetBox::params2string(params));
501 }
502
503
checkWidgets(bool readonly) const504 bool GuiBox::checkWidgets(bool readonly) const
505 {
506 typeCO->setEnabled(!readonly);
507
508 if (readonly) {
509 pagebreakCB->setEnabled(false);
510 innerBoxCO->setEnabled(false);
511 valignCO->setEnabled(false);
512 ialignCO->setEnabled(false);
513 halignCO->setEnabled(false);
514 widthCB->setEnabled(false);
515 widthED->setEnabled(false);
516 widthUnitsLC->setEnabled(false);
517 heightED->setEnabled(false);
518 heightUnitsLC->setEnabled(false);
519 heightCB->setEnabled(false);
520 thicknessED->setEnabled(false);
521 thicknessUnitsLC->setEnabled(false);
522 separationED->setEnabled(false);
523 separationUnitsLC->setEnabled(false);
524 shadowsizeED->setEnabled(false);
525 shadowsizeUnitsLC->setEnabled(false);
526 } else {
527 QString const outer =
528 typeCO->itemData(typeCO->currentIndex()).toString();
529 QString const itype =
530 innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
531 bool const ibox = (itype != "none" && itype != "makebox");
532 valignCO->setEnabled(ibox);
533 ialignCO->setEnabled(ibox);
534 if (heightCB->isChecked() && !ibox)
535 heightCB->setChecked(false);
536 heightCB->setEnabled(ibox);
537 // the width can only be selected for makebox or framebox
538 widthCB->setEnabled(itype == "makebox"
539 || (outer == "Boxed" && itype == "none" && !pagebreakCB->isChecked()));
540 // except for Frameless and Boxed, the width cannot be specified if
541 // there is no inner box
542 bool const width_enabled =
543 ibox || outer == "Frameless" || (outer == "Boxed" && !pagebreakCB->isChecked());
544 // enable if width_enabled
545 widthED->setEnabled(width_enabled);
546 widthUnitsLC->setEnabled(width_enabled);
547 if (!widthCB->isChecked() && widthCB->isEnabled()) {
548 widthED->setEnabled(false);
549 widthUnitsLC->setEnabled(false);
550 }
551 // halign is only allowed without inner box and if a width is used and if
552 // pagebreak is not used
553 halignCO->setEnabled(!pagebreakCB->isChecked() && widthCB->isChecked()
554 && ((!ibox && outer == "Boxed") || itype == "makebox"));
555 // add the entry "Stretch" if the box is \makebox or \framebox and if not already there
556 if ((itype == "makebox" || (outer == "Boxed" && itype == "none"))
557 && halignCO->count() < 4)
558 halignCO->addItem(qt_("Stretch"));
559 else if (itype != "makebox" && (outer != "Boxed" && itype != "none"))
560 halignCO->removeItem(3);
561 // pagebreak is only allowed for Boxed without inner box
562 pagebreakCB->setEnabled(!ibox && outer == "Boxed");
563
564 heightED->setEnabled(itype != "none" && heightCB->isChecked());
565 heightUnitsLC->setEnabled(itype != "none" && heightCB->isChecked());
566 heightCB->setEnabled(ibox);
567
568 // enable line thickness for the rectangular frame types and drop shadow
569 thicknessED->setEnabled(outer == "Boxed" || outer == "Doublebox" || outer == "Shadowbox");
570 thicknessUnitsLC->setEnabled(outer == "Boxed" || outer == "Doublebox" || outer == "Shadowbox");
571 // set default values if empty
572 if (thicknessED->text().isEmpty() && thicknessED->isEnabled()) {
573 thicknessED->setText("0.4");
574 thicknessUnitsLC->setCurrentItem(Length::PT);
575 }
576 // enable line separation for the allowed frame types
577 separationED->setEnabled(outer == "Boxed" || outer == "ovalbox" || outer == "Ovalbox"
578 || outer == "Doublebox" || outer == "Shadowbox");
579 separationUnitsLC->setEnabled(outer == "Boxed" || outer == "ovalbox" || outer == "Ovalbox"
580 || outer == "Doublebox" || outer == "Shadowbox");
581 // set default values if empty
582 if (separationED->text().isEmpty() && separationED->isEnabled()) {
583 separationED->setText("3");
584 separationUnitsLC->setCurrentItem(Length::PT);
585 }
586 // enable shadow size for drop shadow
587 shadowsizeED->setEnabled(outer == "Shadowbox");
588 shadowsizeUnitsLC->setEnabled(outer == "Shadowbox");
589 // set default values if empty
590 if (shadowsizeED->text().isEmpty() && shadowsizeED->isEnabled()) {
591 shadowsizeED->setText("4");
592 shadowsizeUnitsLC->setCurrentItem(Length::PT);
593 }
594 // \fboxcolor and \colorbox cannot be used for fancybox boxes
595 frameColorCO->setEnabled(!pagebreakCB->isChecked() && outer == "Boxed");
596 backgroundColorCO->setEnabled(!pagebreakCB->isChecked() && (frameColorCO->isEnabled() || outer == "Frameless"));
597 }
598
599 return InsetParamsWidget::checkWidgets();
600 }
601
602
setSpecial(bool ibox)603 void GuiBox::setSpecial(bool ibox)
604 {
605 QString const last_item =
606 widthUnitsLC->itemData(heightUnitsLC->currentIndex()).toString();
607
608 // check if the widget contains the special units
609 bool const has_special = (widthUnitsLC->findData("totalheight") != -1);
610 // insert 'em if needed...
611 if (!ibox && !has_special) {
612 for (int i = 1; i < ids_spec_.size(); ++i)
613 widthUnitsLC->addItem(gui_names_spec_[i], ids_spec_[i]);
614 // ... or remove 'em if needed
615 } else if (ibox && has_special) {
616 for (int i = 1; i < ids_spec_.size(); ++i) {
617 int n = widthUnitsLC->findData(ids_spec_[i]);
618 if (n != -1)
619 widthUnitsLC->removeItem(n);
620 }
621 }
622 // restore selected text, if possible
623 widthUnitsLC->setCurrentItem(last_item);
624 }
625
626
setInnerType(bool frameless,QString const & type)627 void GuiBox::setInnerType(bool frameless, QString const & type)
628 {
629 // with "frameless" boxes, inner box is mandatory
630 // (i.e. is the actual box)
631 // we have to remove "none" then and adjust the combo
632 innerBoxCO->clear();
633 if (!frameless)
634 innerBoxCO->addItem(qt_("None"), toqstr("none"));
635 else
636 innerBoxCO->addItem(qt_("Makebox"), toqstr("makebox"));
637 innerBoxCO->addItem(qt_("Parbox"), toqstr("parbox"));
638 innerBoxCO->addItem(qt_("Minipage"), toqstr("minipage"));
639 int i = (innerBoxCO->findData(type) != -1)
640 ? innerBoxCO->findData(type) : 0;
641 innerBoxCO->setCurrentIndex(i);
642 }
643
644 } // namespace frontend
645 } // namespace lyx
646
647
648 #include "moc_GuiBox.cpp"
649