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