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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
GuiBox::GuiBox(GuiView & lv)
|
2010-02-07 20:28:41 +00:00
|
|
|
: InsetDialog(lv, BOX_CODE, LFUN_BOX_INSERT, "box", "Box Settings")
|
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();
|
|
|
|
foreach (QString const & str, gui_names_)
|
|
|
|
typeCO->addItem(str);
|
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-07 20:28:41 +00:00
|
|
|
connect(widthED, SIGNAL(textChanged(QString)), this, SLOT(applyView()));
|
2007-04-28 12:58:49 +00:00
|
|
|
connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-07 20:28:41 +00:00
|
|
|
this, SLOT(applyView()));
|
|
|
|
connect(valignCO, SIGNAL(highlighted(QString)), this, SLOT(applyView()));
|
|
|
|
connect(heightCB, SIGNAL(stateChanged(int)), this, SLOT(applyView()));
|
|
|
|
connect(heightED, SIGNAL(textChanged(QString)), this, SLOT(applyView()));
|
2008-03-08 13:02:52 +00:00
|
|
|
connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2010-02-07 20:28:41 +00:00
|
|
|
this, SLOT(applyView()));
|
|
|
|
connect(innerBoxCO, SIGNAL(activated(int)), this, SLOT(applyView()));
|
|
|
|
connect(typeCO, SIGNAL(activated(int)), this, SLOT(applyView()));
|
|
|
|
connect(halignCO, SIGNAL(activated(int)), this, SLOT(applyView()));
|
|
|
|
connect(ialignCO, SIGNAL(activated(int)), this, SLOT(applyView()));
|
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-02-07 20:28:41 +00:00
|
|
|
void GuiBox::enableView(bool enable)
|
2007-04-24 10:56:22 +00:00
|
|
|
{
|
2010-02-07 20:28:41 +00:00
|
|
|
typeCO->setEnabled(enable);
|
|
|
|
innerBoxCO->setEnabled(enable);
|
|
|
|
valignCO->setEnabled(enable);
|
|
|
|
ialignCO->setEnabled(enable);
|
|
|
|
halignCO->setEnabled(enable);
|
|
|
|
widthED->setEnabled(enable);
|
|
|
|
widthUnitsLC->setEnabled(enable);
|
|
|
|
heightCB->setEnabled(enable);
|
|
|
|
heightED->setEnabled(enable);
|
|
|
|
heightUnitsLC->setEnabled(enable);
|
|
|
|
pagebreakCB->setEnabled(enable);
|
2007-04-24 10:56:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-02-07 20:28:41 +00:00
|
|
|
void GuiBox::on_innerBoxCO_activated(QString const & str)
|
2007-04-24 10:56:22 +00:00
|
|
|
{
|
|
|
|
bool const ibox = (str != qt_("None"));
|
|
|
|
valignCO->setEnabled(ibox);
|
|
|
|
ialignCO->setEnabled(ibox);
|
|
|
|
halignCO->setEnabled(!ibox);
|
2007-09-27 20:19:06 +00:00
|
|
|
heightCB->setEnabled(ibox);
|
2008-04-04 13:33:52 +00:00
|
|
|
pagebreakCB->setEnabled(!ibox && typeCO->currentIndex() == 1);
|
2007-09-05 20:33:29 +00:00
|
|
|
setSpecial(ibox);
|
2010-02-07 20:28:41 +00:00
|
|
|
applyView();
|
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
|
|
|
{
|
|
|
|
bool const frameless = (index == 0);
|
|
|
|
if (frameless) {
|
|
|
|
valignCO->setEnabled(true);
|
|
|
|
ialignCO->setEnabled(true);
|
|
|
|
halignCO->setEnabled(false);
|
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
|
|
|
}
|
2007-12-04 09:25:50 +00:00
|
|
|
if (index != 1)
|
|
|
|
pagebreakCB->setChecked(false);
|
2007-04-24 10:56:22 +00:00
|
|
|
int itype = innerBoxCO->currentIndex();
|
2008-10-04 09:24:40 +00:00
|
|
|
if (innerBoxCO->count() == 2)
|
|
|
|
++itype;
|
2008-04-04 13:33:52 +00:00
|
|
|
pagebreakCB->setEnabled(index == 1 && itype == 0);
|
2008-07-20 16:57:37 +00:00
|
|
|
widthED->setEnabled(index != 5);
|
|
|
|
widthUnitsLC->setEnabled(index != 5);
|
2007-09-05 20:33:29 +00:00
|
|
|
setInnerType(frameless, itype);
|
2010-02-07 20:28:41 +00:00
|
|
|
applyView();
|
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
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
setInnerType(true, 2);
|
2007-04-24 10:56:22 +00:00
|
|
|
widthED->setText("100");
|
2007-04-28 12:58:49 +00:00
|
|
|
widthUnitsLC->setCurrentItem(Length::PCW);
|
2007-09-27 20:19:06 +00:00
|
|
|
heightCB->setCheckState(Qt::Checked);
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
2007-12-04 09:25:50 +00:00
|
|
|
if (pbreak) {
|
|
|
|
valignCO->setEnabled(false);
|
|
|
|
ialignCO->setEnabled(false);
|
|
|
|
halignCO->setEnabled(false);
|
|
|
|
heightCB->setEnabled(false);
|
|
|
|
heightED->setEnabled(false);
|
|
|
|
heightUnitsLC->setEnabled(false);
|
|
|
|
setSpecial(false);
|
2008-03-08 13:02:52 +00:00
|
|
|
} else {
|
2010-02-07 20:28:41 +00:00
|
|
|
on_typeCO_activated(typeCO->currentIndex());
|
2008-03-08 13:02:52 +00:00
|
|
|
}
|
2010-02-07 20:28:41 +00:00
|
|
|
applyView();
|
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-02-07 20:28:41 +00:00
|
|
|
pagebreakCB->setEnabled(type == "Boxed" && !params.inner_box);
|
2007-12-04 09:25:50 +00:00
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
for (int i = 0; i != gui_names_.size(); ++i) {
|
2006-03-05 17:24:44 +00:00
|
|
|
if (type == ids_[i])
|
2007-09-05 20:33:29 +00:00
|
|
|
typeCO->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// default: minipage
|
2008-03-08 13:02:52 +00:00
|
|
|
int inner_type = 2;
|
2010-02-07 20:28:41 +00:00
|
|
|
if (!params.inner_box)
|
2006-03-05 17:24:44 +00:00
|
|
|
// none
|
|
|
|
inner_type = 0;
|
2010-02-07 20:28:41 +00:00
|
|
|
if (params.use_parbox)
|
2006-03-05 17:24:44 +00:00
|
|
|
// parbox
|
|
|
|
inner_type = 1;
|
2010-02-07 20:28:41 +00:00
|
|
|
bool 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);
|
|
|
|
halignCO->setEnabled(!ibox);
|
2006-03-05 17:24:44 +00:00
|
|
|
setSpecial(ibox);
|
|
|
|
|
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-02-07 20:28:41 +00:00
|
|
|
box_type = fromqstr(ids_[typeCO->currentIndex()]);
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
void GuiBox::setInnerType(bool frameless, int i)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
|
|
|
// with "frameless" boxes, inner box is mandatory (i.e. is the actual box)
|
|
|
|
// we have to remove "none" then and adjust the combo
|
|
|
|
if (frameless) {
|
2007-09-05 20:33:29 +00:00
|
|
|
innerBoxCO->clear();
|
|
|
|
innerBoxCO->addItem(qt_("Parbox"));
|
|
|
|
innerBoxCO->addItem(qt_("Minipage"));
|
2007-09-24 11:44:19 +00:00
|
|
|
if (i != 0)
|
|
|
|
innerBoxCO->setCurrentIndex(i - 1);
|
|
|
|
else
|
|
|
|
innerBoxCO->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
innerBoxCO->clear();
|
|
|
|
innerBoxCO->addItem(qt_("None"));
|
|
|
|
innerBoxCO->addItem(qt_("Parbox"));
|
|
|
|
innerBoxCO->addItem(qt_("Minipage"));
|
|
|
|
innerBoxCO->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
2007-11-23 09:44:02 +00:00
|
|
|
Dialog * createGuiBox(GuiView & lv) { return new GuiBox(lv); }
|
2007-10-06 10:23:51 +00:00
|
|
|
|
|
|
|
|
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"
|