2006-03-05 17:24:44 +00:00
|
|
|
/**
|
2007-08-31 05:53:55 +00:00
|
|
|
* \file GuiBox.cpp
|
2006-03-05 17:24:44 +00:00
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Vigna (Minipage stuff)
|
2006-03-05 17:24:44 +00:00
|
|
|
* \author Martin Vermeer
|
2008-11-14 15:58:50 +00:00
|
|
|
* \author Jürgen Spitzmüller
|
2006-03-05 17:24:44 +00:00
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
#include "GuiBox.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
#include "FuncRequest.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "LengthCombo.h"
|
2007-10-24 22:55:02 +00:00
|
|
|
#include "Length.h"
|
2008-03-27 07:26:37 +00:00
|
|
|
#include "qt_helpers.h"
|
2007-04-26 03:53:02 +00:00
|
|
|
#include "Validator.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-04-25 01:24:38 +00:00
|
|
|
#include "insets/InsetBox.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-03-27 07:26:37 +00:00
|
|
|
#include "support/gettext.h"
|
2008-03-08 13:02:52 +00:00
|
|
|
#include "support/foreach.h"
|
2008-03-27 07:26:37 +00:00
|
|
|
#include "support/lstrings.h"
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2006-05-04 07:31:46 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QLineEdit>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-05-24 21:58:56 +00:00
|
|
|
#ifdef IN
|
|
|
|
#undef IN
|
|
|
|
#endif
|
|
|
|
|
2007-12-12 10:16:00 +00:00
|
|
|
using namespace std;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
namespace lyx {
|
|
|
|
namespace frontend {
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
static QStringList boxGuiIds()
|
|
|
|
{
|
|
|
|
return QStringList()
|
|
|
|
<< "Frameless" << "Boxed"
|
|
|
|
<< "ovalbox" << "Ovalbox"
|
|
|
|
<< "Shadowbox" << "Shaded"
|
|
|
|
<< "Doublebox";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static QStringList boxGuiNames()
|
|
|
|
{
|
|
|
|
return QStringList()
|
|
|
|
<< qt_("No frame") << qt_("Simple rectangular frame")
|
|
|
|
<< qt_("Oval frame, thin") << qt_("Oval frame, thick")
|
|
|
|
<< qt_("Drop shadow") << qt_("Shaded background")
|
|
|
|
<< qt_("Double rectangular frame");
|
|
|
|
}
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
static QStringList boxGuiSpecialLengthIds()
|
2007-10-06 10:23:51 +00:00
|
|
|
{
|
2009-01-14 14:10:52 +00:00
|
|
|
return QStringList() << "height" << "depth"
|
2008-03-08 13:02:52 +00:00
|
|
|
<< "totalheight" << "width";
|
2007-10-06 10:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
static QStringList boxGuiSpecialLengthNames()
|
2007-10-06 10:23:51 +00:00
|
|
|
{
|
2009-01-14 14:10:52 +00:00
|
|
|
return QStringList() << qt_("Height") << qt_("Depth")
|
2008-03-08 13:02:52 +00:00
|
|
|
<< qt_("Total Height") << qt_("Width");
|
2007-10-06 10:23:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-15 23:17:45 +00:00
|
|
|
GuiBox::GuiBox(QWidget * parent) : InsetParamsWidget(parent)
|
2007-04-24 10:56:22 +00:00
|
|
|
{
|
|
|
|
setupUi(this);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
// fill the box type choice
|
2008-03-08 13:02:52 +00:00
|
|
|
ids_ = boxGuiIds();
|
|
|
|
gui_names_ = boxGuiNames();
|
2010-06-25 17:39:53 +00:00
|
|
|
for (int i = 0; i != ids_.size(); ++i)
|
|
|
|
typeCO->addItem(gui_names_[i], ids_[i]);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
// add the special units to the height choice
|
|
|
|
// width needs different handling
|
2008-03-08 13:02:52 +00:00
|
|
|
ids_spec_ = boxGuiSpecialLengthIds();
|
|
|
|
gui_names_spec_ = boxGuiSpecialLengthNames();
|
2009-01-14 12:57:23 +00:00
|
|
|
for (int i = 0; i != ids_spec_.size(); ++i)
|
|
|
|
heightUnitsLC->addItem(gui_names_spec_[i], ids_spec_[i]);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
2010-02-15 23:17:45 +00:00
|
|
|
connect(widthED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
2007-04-28 12:58:49 +00:00
|
|
|
connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-15 23:17:45 +00:00
|
|
|
this, SIGNAL(changed()));
|
|
|
|
connect(valignCO, SIGNAL(highlighted(QString)), this, SIGNAL(changed()));
|
|
|
|
connect(heightED, SIGNAL(textChanged(QString)), this, SIGNAL(changed()));
|
2008-03-08 13:02:52 +00:00
|
|
|
connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-15 23:17:45 +00:00
|
|
|
this, SIGNAL(changed()));
|
|
|
|
connect(halignCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
|
|
|
|
connect(ialignCO, SIGNAL(activated(int)), this, SIGNAL(changed()));
|
2007-04-24 10:56:22 +00:00
|
|
|
|
|
|
|
heightED->setValidator(unsignedLengthValidator(heightED));
|
|
|
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
// initialize the length validator
|
2010-02-07 20:28:41 +00:00
|
|
|
addCheckedWidget(widthED, widthLA);
|
|
|
|
addCheckedWidget(heightED, heightCB);
|
|
|
|
|
|
|
|
initDialog();
|
2007-09-05 20:33:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-26 07:57:54 +00:00
|
|
|
void GuiBox::on_innerBoxCO_activated(int index)
|
2007-04-24 10:56:22 +00:00
|
|
|
{
|
2010-06-26 07:57:54 +00:00
|
|
|
bool const ibox =
|
|
|
|
(innerBoxCO->itemData(index).toString() != "none");
|
2010-06-25 17:39:53 +00:00
|
|
|
QString const outer =
|
|
|
|
typeCO->itemData(typeCO->currentIndex()).toString();
|
2007-04-24 10:56:22 +00:00
|
|
|
valignCO->setEnabled(ibox);
|
|
|
|
ialignCO->setEnabled(ibox);
|
2007-09-27 20:19:06 +00:00
|
|
|
heightCB->setEnabled(ibox);
|
2010-06-25 17:39:53 +00:00
|
|
|
// except for frameless and boxed, the width cannot be specified if
|
2010-05-28 03:01:18 +00:00
|
|
|
// there is no inner box
|
2010-06-25 17:39:53 +00:00
|
|
|
bool const width_disabled = (!ibox && outer != "Frameless" &&
|
|
|
|
outer != "Boxed");
|
2010-05-28 03:01:18 +00:00
|
|
|
widthED->setEnabled(!width_disabled);
|
|
|
|
widthUnitsLC->setEnabled(!width_disabled);
|
2010-06-26 21:02:14 +00:00
|
|
|
// halign and pagebreak are only allowed for Boxed without inner box
|
|
|
|
halignCO->setEnabled(!ibox && outer == "Boxed");
|
2010-06-25 17:39:53 +00:00
|
|
|
pagebreakCB->setEnabled(!ibox && outer == "Boxed");
|
2007-09-05 20:33:29 +00:00
|
|
|
setSpecial(ibox);
|
2010-02-15 23:17:45 +00:00
|
|
|
changed();
|
2007-04-24 10:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
void GuiBox::on_typeCO_activated(int index)
|
2007-04-24 10:56:22 +00:00
|
|
|
{
|
2010-06-25 17:39:53 +00:00
|
|
|
QString const type =
|
|
|
|
typeCO->itemData(index).toString();
|
|
|
|
bool const frameless = (type == "Frameless");
|
2007-04-24 10:56:22 +00:00
|
|
|
if (frameless) {
|
|
|
|
valignCO->setEnabled(true);
|
|
|
|
ialignCO->setEnabled(true);
|
2007-09-27 20:19:06 +00:00
|
|
|
heightCB->setEnabled(true);
|
2007-09-05 20:33:29 +00:00
|
|
|
setSpecial(true);
|
2007-04-24 10:56:22 +00:00
|
|
|
}
|
2010-06-25 17:39:53 +00:00
|
|
|
if (type != "Boxed")
|
2007-12-04 09:25:50 +00:00
|
|
|
pagebreakCB->setChecked(false);
|
2010-06-25 17:39:53 +00:00
|
|
|
QString itype =
|
|
|
|
innerBoxCO->itemData(innerBoxCO->currentIndex()).toString();
|
|
|
|
// except for frameless and boxed, the width cannot be specified if
|
2010-05-28 03:01:18 +00:00
|
|
|
// there is no inner box
|
2010-06-25 17:39:53 +00:00
|
|
|
bool const width_disabled = (itype == "none" && !frameless
|
|
|
|
&& type != "Boxed");
|
2010-05-28 03:01:18 +00:00
|
|
|
widthED->setEnabled(!width_disabled);
|
|
|
|
widthUnitsLC->setEnabled(!width_disabled);
|
2010-06-26 21:02:14 +00:00
|
|
|
// halign and pagebreak are only allowed for Boxed without inner box
|
|
|
|
halignCO->setEnabled(type == "Boxed" && itype == "none");
|
|
|
|
pagebreakCB->setEnabled(type == "Boxed" && itype == "none");
|
2007-09-05 20:33:29 +00:00
|
|
|
setInnerType(frameless, itype);
|
2010-02-15 23:17:45 +00:00
|
|
|
changed();
|
2007-04-24 10:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
void GuiBox::initDialog()
|
2007-04-24 10:56:22 +00:00
|
|
|
{
|
2010-06-25 17:39:53 +00:00
|
|
|
setInnerType(true, toqstr("minipage"));
|
2007-04-24 10:56:22 +00:00
|
|
|
widthED->setText("100");
|
2007-04-28 12:58:49 +00:00
|
|
|
widthUnitsLC->setCurrentItem(Length::PCW);
|
2007-04-24 10:56:22 +00:00
|
|
|
heightED->setText("1");
|
2009-01-14 12:57:23 +00:00
|
|
|
heightUnitsLC->setCurrentItem("totalheight");
|
2007-04-24 10:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
void GuiBox::on_heightCB_stateChanged(int state)
|
|
|
|
{
|
|
|
|
bool const enable = (innerBoxCO->currentText() != qt_("None"))
|
|
|
|
&& (state == Qt::Checked);
|
|
|
|
heightED->setEnabled(enable);
|
|
|
|
heightUnitsLC->setEnabled(enable);
|
2010-02-15 23:17:45 +00:00
|
|
|
changed();
|
2010-02-07 20:28:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void GuiBox::on_pagebreakCB_stateChanged()
|
2007-12-04 09:25:50 +00:00
|
|
|
{
|
|
|
|
bool pbreak = (pagebreakCB->checkState() == Qt::Checked);
|
|
|
|
innerBoxCO->setEnabled(!pbreak);
|
2008-07-20 16:57:37 +00:00
|
|
|
widthED->setEnabled(!pbreak);
|
|
|
|
widthUnitsLC->setEnabled(!pbreak);
|
2010-02-07 21:12:46 +00:00
|
|
|
if (!pbreak) {
|
2010-02-07 20:28:41 +00:00
|
|
|
on_typeCO_activated(typeCO->currentIndex());
|
2010-02-07 21:12:46 +00:00
|
|
|
return;
|
2008-03-08 13:02:52 +00:00
|
|
|
}
|
2010-02-07 21:12:46 +00:00
|
|
|
valignCO->setEnabled(false);
|
|
|
|
ialignCO->setEnabled(false);
|
|
|
|
halignCO->setEnabled(false);
|
|
|
|
heightCB->setEnabled(false);
|
|
|
|
heightED->setEnabled(false);
|
|
|
|
heightUnitsLC->setEnabled(false);
|
|
|
|
setSpecial(false);
|
2010-02-15 23:17:45 +00:00
|
|
|
changed();
|
2007-12-04 09:25:50 +00:00
|
|
|
}
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
void GuiBox::paramsToDialog(Inset const * inset)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2010-02-07 20:28:41 +00:00
|
|
|
InsetBox const * box = static_cast<InsetBox const *>(inset);
|
|
|
|
InsetBoxParams const & params = box->params();
|
|
|
|
QString type = toqstr(params.type);
|
2007-12-04 09:25:50 +00:00
|
|
|
if (type == "Framed") {
|
|
|
|
pagebreakCB->setChecked(true);
|
|
|
|
type = "Boxed";
|
2008-03-08 13:02:52 +00:00
|
|
|
} else {
|
2007-12-04 09:25:50 +00:00
|
|
|
pagebreakCB->setChecked(false);
|
2008-03-08 13:02:52 +00:00
|
|
|
}
|
2007-12-04 09:25:50 +00:00
|
|
|
|
2010-06-25 17:39:53 +00:00
|
|
|
typeCO->setCurrentIndex(typeCO->findData(type));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
// default: minipage
|
2010-06-25 17:39:53 +00:00
|
|
|
QString inner_type = "minipage";
|
2010-02-07 20:28:41 +00:00
|
|
|
if (!params.inner_box)
|
2010-06-25 17:39:53 +00:00
|
|
|
inner_type = "none";
|
2010-02-07 20:28:41 +00:00
|
|
|
if (params.use_parbox)
|
2010-06-25 17:39:53 +00:00
|
|
|
inner_type = "parbox";
|
|
|
|
bool const frameless = (params.type == "Frameless");
|
2006-03-05 17:24:44 +00:00
|
|
|
setInnerType(frameless, inner_type);
|
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
char c = params.pos;
|
2007-09-05 20:33:29 +00:00
|
|
|
valignCO->setCurrentIndex(string("tcb").find(c, 0));
|
2010-02-07 20:28:41 +00:00
|
|
|
c = params.inner_pos;
|
2007-09-05 20:33:29 +00:00
|
|
|
ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
|
2010-02-07 20:28:41 +00:00
|
|
|
c = params.hor_pos;
|
2007-09-05 20:33:29 +00:00
|
|
|
halignCO->setCurrentIndex(string("lcrs").find(c, 0));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
bool ibox = params.inner_box;
|
2007-09-05 20:33:29 +00:00
|
|
|
valignCO->setEnabled(ibox);
|
|
|
|
ialignCO->setEnabled(ibox);
|
2006-03-05 17:24:44 +00:00
|
|
|
setSpecial(ibox);
|
|
|
|
|
2010-06-26 21:02:14 +00:00
|
|
|
// halign and pagebreak are only allowed for Boxed without inner box
|
|
|
|
halignCO->setEnabled(!ibox && type == "Boxed");
|
|
|
|
pagebreakCB->setEnabled(!ibox && type == "Boxed");
|
|
|
|
|
|
|
|
// except for frameless and boxed, the width cannot be specified if
|
|
|
|
// there is no inner box
|
|
|
|
bool const width_disabled = (!ibox && !frameless
|
|
|
|
&& type != "Boxed");
|
|
|
|
widthED->setEnabled(!width_disabled);
|
|
|
|
widthUnitsLC->setEnabled(!width_disabled);
|
|
|
|
|
2009-02-06 21:24:13 +00:00
|
|
|
Length::UNIT const default_unit = Length::defaultUnit();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
lengthToWidgets(widthED, widthUnitsLC,
|
2010-02-07 20:28:41 +00:00
|
|
|
(params.width).asString(), default_unit);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
QString const special = toqstr(params.special);
|
2009-01-14 12:57:23 +00:00
|
|
|
if (!special.isEmpty() && special != "none")
|
|
|
|
widthUnitsLC->setCurrentItem(special);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
lengthToWidgets(heightED, heightUnitsLC,
|
2010-02-07 20:28:41 +00:00
|
|
|
(params.height).asString(), default_unit);
|
2007-10-05 00:36:38 +00:00
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
QString const height_special = toqstr(params.height_special);
|
2009-01-14 12:57:23 +00:00
|
|
|
if (!height_special.isEmpty() && height_special != "none")
|
|
|
|
heightUnitsLC->setCurrentItem(height_special);
|
|
|
|
// set no optional height if the value is the default "1\height"
|
2007-10-05 00:36:38 +00:00
|
|
|
// (special units like \height are handled as "in",
|
2010-02-07 20:28:41 +00:00
|
|
|
// FIXME: this is a very bad UI, this check box should be disabled in
|
|
|
|
// this case, not forced to 'unchecked' state.
|
|
|
|
if (height_special == "totalheight" && params.height == Length("1in"))
|
2007-10-05 00:36:38 +00:00
|
|
|
heightCB->setCheckState(Qt::Unchecked);
|
|
|
|
else
|
|
|
|
heightCB->setCheckState(Qt::Checked);
|
|
|
|
|
2007-09-27 20:19:06 +00:00
|
|
|
heightCB->setEnabled(ibox);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
docstring GuiBox::dialogToParams() const
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2010-02-07 20:28:41 +00:00
|
|
|
bool const pagebreak =
|
2009-01-14 12:57:23 +00:00
|
|
|
pagebreakCB->isEnabled() && pagebreakCB->isChecked();
|
2010-02-07 20:28:41 +00:00
|
|
|
string box_type;
|
2007-12-04 09:25:50 +00:00
|
|
|
if (pagebreak)
|
2010-02-07 20:28:41 +00:00
|
|
|
box_type = "Framed";
|
2007-12-04 09:25:50 +00:00
|
|
|
else
|
2010-06-25 17:39:53 +00:00
|
|
|
box_type = fromqstr(typeCO->itemData(
|
|
|
|
typeCO->currentIndex()).toString());
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
InsetBoxParams params(box_type);
|
|
|
|
params.inner_box =
|
2009-01-14 12:57:23 +00:00
|
|
|
(!pagebreak && innerBoxCO->currentText() != qt_("None"));
|
2010-02-07 20:28:41 +00:00
|
|
|
params.use_parbox =
|
2009-01-14 12:57:23 +00:00
|
|
|
(!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
params.pos = "tcb"[valignCO->currentIndex()];
|
|
|
|
params.inner_pos = "tcbs"[ialignCO->currentIndex()];
|
|
|
|
params.hor_pos = "lcrs"[halignCO->currentIndex()];
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-01-14 12:57:23 +00:00
|
|
|
QString unit =
|
|
|
|
widthUnitsLC->itemData(widthUnitsLC->currentIndex()).toString();
|
2007-09-05 20:33:29 +00:00
|
|
|
QString value = widthED->text();
|
2009-01-14 12:57:23 +00:00
|
|
|
if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
|
2010-02-07 20:28:41 +00:00
|
|
|
params.special = fromqstr(unit);
|
2009-01-14 12:57:23 +00:00
|
|
|
// Note: the unit is simply ignored in this case
|
2010-02-07 20:28:41 +00:00
|
|
|
params.width = Length(value.toDouble(), Length::IN);
|
2007-10-06 10:23:51 +00:00
|
|
|
} else {
|
2010-02-07 20:28:41 +00:00
|
|
|
params.special = "none";
|
|
|
|
params.width = Length(widgetsToLength(widthED, widthUnitsLC));
|
2007-10-06 10:23:51 +00:00
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
2009-11-01 23:23:54 +00:00
|
|
|
// the height parameter is omitted if the value
|
2007-09-27 20:19:06 +00:00
|
|
|
// is "1in" and "Total Height" is used as unit.
|
2009-01-14 12:57:23 +00:00
|
|
|
// 1in + "Total Height" means "1\height" which is the LaTeX default
|
|
|
|
// if no height is given
|
|
|
|
if (heightCB->checkState() == Qt::Unchecked) {
|
2010-02-07 20:28:41 +00:00
|
|
|
params.height = Length("1in");
|
|
|
|
params.height_special = "totalheight";
|
2009-01-14 12:57:23 +00:00
|
|
|
} else {
|
|
|
|
unit = heightUnitsLC->itemData(heightUnitsLC->currentIndex()).toString();
|
|
|
|
value = heightED->text();
|
|
|
|
if (ids_spec_.contains(unit) && !isValidLength(fromqstr(value))) {
|
2010-02-07 20:28:41 +00:00
|
|
|
params.height_special = fromqstr(unit);
|
2009-01-14 12:57:23 +00:00
|
|
|
// Note: the unit is simply ignored in this case
|
2010-02-07 20:28:41 +00:00
|
|
|
params.height = Length(value.toDouble(), Length::IN);
|
2009-01-14 12:57:23 +00:00
|
|
|
} else {
|
2010-02-07 20:28:41 +00:00
|
|
|
params.height_special = "none";
|
|
|
|
params.height =
|
2009-01-14 12:57:23 +00:00
|
|
|
Length(widgetsToLength(heightED, heightUnitsLC));
|
|
|
|
}
|
2007-09-27 20:19:06 +00:00
|
|
|
}
|
2010-02-07 20:28:41 +00:00
|
|
|
return from_ascii(InsetBox::params2string(params));
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
void GuiBox::setSpecial(bool ibox)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2009-01-14 12:57:23 +00:00
|
|
|
QString const last_item =
|
|
|
|
widthUnitsLC->itemData(heightUnitsLC->currentIndex()).toString();
|
2008-10-04 09:24:40 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
// check if the widget contains the special units
|
2009-01-14 12:57:23 +00:00
|
|
|
bool const has_special = (widthUnitsLC->findData("totalheight") != -1);
|
2006-03-05 17:24:44 +00:00
|
|
|
// insert 'em if needed...
|
|
|
|
if (!ibox && !has_special) {
|
2009-01-14 12:57:23 +00:00
|
|
|
for (int i = 1; i < ids_spec_.size(); ++i)
|
|
|
|
widthUnitsLC->addItem(gui_names_spec_[i], ids_spec_[i]);
|
2006-03-05 17:24:44 +00:00
|
|
|
// ... or remove 'em if needed
|
|
|
|
} else if (ibox && has_special) {
|
2009-01-14 12:57:23 +00:00
|
|
|
for (int i = 1; i < ids_spec_.size(); ++i) {
|
|
|
|
int n = widthUnitsLC->findData(ids_spec_[i]);
|
|
|
|
if (n != -1)
|
|
|
|
widthUnitsLC->removeItem(n);
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
2008-10-04 09:24:40 +00:00
|
|
|
// restore selected text, if possible
|
2009-01-14 12:57:23 +00:00
|
|
|
widthUnitsLC->setCurrentItem(last_item);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-06-25 17:39:53 +00:00
|
|
|
void GuiBox::setInnerType(bool frameless, QString const & type)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2010-06-25 17:39:53 +00:00
|
|
|
// with "frameless" boxes, inner box is mandatory
|
|
|
|
// (i.e. is the actual box)
|
2006-03-05 17:24:44 +00:00
|
|
|
// we have to remove "none" then and adjust the combo
|
2010-06-25 17:39:53 +00:00
|
|
|
innerBoxCO->clear();
|
|
|
|
if (!frameless)
|
|
|
|
innerBoxCO->addItem(qt_("None"), toqstr("none"));
|
|
|
|
innerBoxCO->addItem(qt_("Parbox"), toqstr("parbox"));
|
|
|
|
innerBoxCO->addItem(qt_("Minipage"), toqstr("minipage"));
|
|
|
|
int i = (innerBoxCO->findData(type) != -1)
|
|
|
|
? innerBoxCO->findData(type) : 0;
|
|
|
|
innerBoxCO->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace frontend
|
|
|
|
} // namespace lyx
|
2007-04-24 10:56:22 +00:00
|
|
|
|
|
|
|
|
2008-11-14 14:28:50 +00:00
|
|
|
#include "moc_GuiBox.cpp"
|