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