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