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