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.
|
|
|
|
|
*
|
|
|
|
|
* \author J<EFBFBD>rgen Vigna (Minipage stuff)
|
|
|
|
|
* \author Martin Vermeer
|
|
|
|
|
* \author J<EFBFBD>rgen Spitzm<EFBFBD>ller
|
|
|
|
|
*
|
|
|
|
|
* 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"
|
2007-04-26 04:41:58 +00:00
|
|
|
|
#include "LyXRC.h" // to set the default length values
|
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
|
|
|
|
{
|
2008-03-08 13:02:52 +00:00
|
|
|
|
return QStringList() << "none" << "height" << "depth"
|
|
|
|
|
<< "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
|
|
|
|
{
|
2008-03-08 13:02:52 +00:00
|
|
|
|
return QStringList() << qt_("None") << qt_("Height") << qt_("Depth")
|
|
|
|
|
<< 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)
|
2008-02-05 12:43:19 +00:00
|
|
|
|
: GuiDialog(lv, "box", qt_("Box Settings")), params_("")
|
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();
|
|
|
|
|
foreach (QString const & str, gui_names_spec_)
|
|
|
|
|
heightUnitsLC->addItem(str);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
|
|
connect(restorePB, SIGNAL(clicked()), this, SLOT(slotRestore()));
|
|
|
|
|
connect(okPB, SIGNAL(clicked()), this, SLOT(slotOK()));
|
|
|
|
|
connect(applyPB, SIGNAL(clicked()), this, SLOT(slotApply()));
|
|
|
|
|
connect(closePB, SIGNAL(clicked()), this, SLOT(slotClose()));
|
2007-04-24 10:56:22 +00:00
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
connect(widthED, SIGNAL(textChanged(QString)),
|
2007-04-24 10:56:22 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-04-28 12:58:49 +00:00
|
|
|
|
connect(widthUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-24 10:56:22 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-10-06 10:23:51 +00:00
|
|
|
|
connect(valignCO, SIGNAL(highlighted(QString)),
|
2007-04-24 10:56:22 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2007-09-27 20:19:06 +00:00
|
|
|
|
connect(heightCB, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(change_adaptor()));
|
2008-03-08 13:02:52 +00:00
|
|
|
|
connect(heightED, SIGNAL(textChanged(QString)),
|
2007-04-24 10:56:22 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
2008-03-08 13:02:52 +00:00
|
|
|
|
connect(heightUnitsLC, SIGNAL(selectionChanged(lyx::Length::UNIT)),
|
2007-04-24 10:56:22 +00:00
|
|
|
|
this, SLOT(change_adaptor()));
|
|
|
|
|
connect(restorePB, SIGNAL(clicked()), this, SLOT(restoreClicked()));
|
|
|
|
|
connect(typeCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
|
connect(typeCO, SIGNAL(activated(int)), this, SLOT(typeChanged(int)));
|
|
|
|
|
connect(halignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
|
|
|
|
connect(ialignCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
2008-03-08 13:02:52 +00:00
|
|
|
|
connect(innerBoxCO, SIGNAL(activated(QString)),
|
|
|
|
|
this, SLOT(innerBoxChanged(QString)));
|
2007-04-24 10:56:22 +00:00
|
|
|
|
connect(innerBoxCO, SIGNAL(activated(int)), this, SLOT(change_adaptor()));
|
2007-12-04 09:25:50 +00:00
|
|
|
|
connect(pagebreakCB, SIGNAL(stateChanged(int)),
|
|
|
|
|
this, SLOT(pagebreakClicked()));
|
2007-04-24 10:56:22 +00:00
|
|
|
|
|
|
|
|
|
heightED->setValidator(unsignedLengthValidator(heightED));
|
|
|
|
|
widthED->setValidator(unsignedLengthValidator(widthED));
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
|
|
bc().setPolicy(ButtonPolicy::OkApplyCancelReadOnlyPolicy);
|
|
|
|
|
|
|
|
|
|
bc().addReadOnly(typeCO);
|
|
|
|
|
bc().addReadOnly(innerBoxCO);
|
|
|
|
|
bc().addReadOnly(valignCO);
|
|
|
|
|
bc().addReadOnly(ialignCO);
|
|
|
|
|
bc().addReadOnly(halignCO);
|
|
|
|
|
bc().addReadOnly(widthED);
|
|
|
|
|
bc().addReadOnly(widthUnitsLC);
|
2007-09-27 20:19:06 +00:00
|
|
|
|
bc().addReadOnly(heightCB);
|
|
|
|
|
bc().addReadOnly(heightED);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
bc().addReadOnly(heightUnitsLC);
|
2007-12-04 09:25:50 +00:00
|
|
|
|
bc().addReadOnly(pagebreakCB);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
|
|
|
|
|
bc().setRestore(restorePB);
|
|
|
|
|
bc().setOK(okPB);
|
|
|
|
|
bc().setApply(applyPB);
|
|
|
|
|
bc().setCancel(closePB);
|
|
|
|
|
|
|
|
|
|
// initialize the length validator
|
|
|
|
|
bc().addCheckedLineEdit(widthED, widthLA);
|
2007-09-27 20:19:06 +00:00
|
|
|
|
bc().addCheckedLineEdit(heightED, heightCB);
|
2007-09-05 20:33:29 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
void GuiBox::change_adaptor()
|
2007-04-24 10:56:22 +00:00
|
|
|
|
{
|
2007-09-05 20:33:29 +00:00
|
|
|
|
changed();
|
2007-04-24 10:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
|
void GuiBox::innerBoxChanged(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-27 20:19:06 +00:00
|
|
|
|
if (heightCB->checkState() == Qt::Checked && ibox) {
|
|
|
|
|
heightED->setEnabled(true);
|
|
|
|
|
heightUnitsLC->setEnabled(true);
|
|
|
|
|
}
|
2007-09-05 20:33:29 +00:00
|
|
|
|
setSpecial(ibox);
|
2007-04-24 10:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
void GuiBox::typeChanged(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-04-24 10:56:22 +00:00
|
|
|
|
heightED->setEnabled(true);
|
|
|
|
|
heightUnitsLC->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-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);
|
2007-04-24 10:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
void GuiBox::restoreClicked()
|
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");
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != heightUnitsLC->count(); ++i) {
|
|
|
|
|
if (heightUnitsLC->itemText(i) == qt_("Total Height"))
|
|
|
|
|
heightUnitsLC->setCurrentItem(i);
|
2007-04-24 10:56:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-12-04 09:25:50 +00:00
|
|
|
|
void GuiBox::pagebreakClicked()
|
|
|
|
|
{
|
|
|
|
|
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 {
|
2007-12-04 09:25:50 +00:00
|
|
|
|
typeChanged(typeCO->currentIndex());
|
2008-03-08 13:02:52 +00:00
|
|
|
|
}
|
2007-12-04 11:29:43 +00:00
|
|
|
|
change_adaptor();
|
2007-12-04 09:25:50 +00:00
|
|
|
|
}
|
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
void GuiBox::updateContents()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2008-03-08 13:02:52 +00:00
|
|
|
|
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
|
|
|
|
|
2008-04-04 13:33:52 +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;
|
2007-10-06 10:23:51 +00:00
|
|
|
|
if (!params_.inner_box)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
// none
|
|
|
|
|
inner_type = 0;
|
2007-10-06 10:23:51 +00:00
|
|
|
|
if (params_.use_parbox)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
// parbox
|
|
|
|
|
inner_type = 1;
|
2007-10-06 10:23:51 +00:00
|
|
|
|
bool frameless = (params_.type == "Frameless");
|
2006-03-05 17:24:44 +00:00
|
|
|
|
setInnerType(frameless, inner_type);
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
char c = params_.pos;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
valignCO->setCurrentIndex(string("tcb").find(c, 0));
|
2007-10-06 10:23:51 +00:00
|
|
|
|
c = params_.inner_pos;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
ialignCO->setCurrentIndex(string("tcbs").find(c, 0));
|
2007-10-06 10:23:51 +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
|
|
|
|
|
2007-10-06 10:23:51 +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);
|
|
|
|
|
|
2007-04-28 12:58:49 +00:00
|
|
|
|
Length::UNIT default_unit =
|
|
|
|
|
(lyxrc.default_papersize > 3) ? Length::CM : Length::IN;
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
lengthToWidgets(widthED, widthUnitsLC,
|
2007-10-06 10:23:51 +00:00
|
|
|
|
(params_.width).asString(), default_unit);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
|
QString const special = toqstr(params_.special);
|
|
|
|
|
if (!special.isEmpty() && special != "none") {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
QString spc;
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != gui_names_spec_.size(); ++i) {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (special == ids_spec_[i])
|
2008-03-08 13:02:52 +00:00
|
|
|
|
spc = gui_names_spec_[i];
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != widthUnitsLC->count(); ++i) {
|
|
|
|
|
if (widthUnitsLC->itemText(i) == spc)
|
|
|
|
|
widthUnitsLC->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-09-05 20:33:29 +00:00
|
|
|
|
lengthToWidgets(heightED, heightUnitsLC,
|
2007-10-06 10:23:51 +00:00
|
|
|
|
(params_.height).asString(), default_unit);
|
2007-10-05 00:36:38 +00:00
|
|
|
|
|
2008-03-08 13:02:52 +00:00
|
|
|
|
QString const height_special = toqstr(params_.height_special);
|
|
|
|
|
if (!height_special.isEmpty() && height_special != "none") {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
QString hspc;
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != gui_names_spec_.size(); ++i) {
|
2007-10-06 10:23:51 +00:00
|
|
|
|
if (height_special == ids_spec_[i])
|
2008-03-08 13:02:52 +00:00
|
|
|
|
hspc = gui_names_spec_[i];
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != heightUnitsLC->count(); ++i) {
|
|
|
|
|
if (heightUnitsLC->itemText(i) == hspc)
|
|
|
|
|
heightUnitsLC->setCurrentIndex(i);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2007-10-05 00:36:38 +00:00
|
|
|
|
// set no optional height when the value is the default "1\height"
|
|
|
|
|
// (special units like \height are handled as "in",
|
2008-03-08 13:02:52 +00:00
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
void GuiBox::applyView()
|
2006-03-05 17:24:44 +00:00
|
|
|
|
{
|
2008-04-04 13:33:52 +00:00
|
|
|
|
bool pagebreak = pagebreakCB->isEnabled() && pagebreakCB->isChecked();
|
2007-12-04 09:25:50 +00:00
|
|
|
|
if (pagebreak)
|
|
|
|
|
params_.type = "Framed";
|
|
|
|
|
else
|
2008-03-08 13:02:52 +00:00
|
|
|
|
params_.type = fromqstr(ids_[typeCO->currentIndex()]);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-12-04 09:25:50 +00:00
|
|
|
|
params_.inner_box = (!pagebreak && innerBoxCO->currentText() != qt_("None"));
|
|
|
|
|
params_.use_parbox = (!pagebreak && innerBoxCO->currentText() == qt_("Parbox"));
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-06 10:23:51 +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
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
bool spec = false;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
QString special = widthUnitsLC->currentText();
|
|
|
|
|
QString value = widthED->text();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (special == qt_("Height")) {
|
|
|
|
|
i = 1;
|
|
|
|
|
spec = true;
|
|
|
|
|
} else if (special == qt_("Depth")) {
|
|
|
|
|
i = 2;
|
|
|
|
|
spec = true;
|
|
|
|
|
} else if (special == qt_("Total Height")) {
|
|
|
|
|
i = 3;
|
|
|
|
|
spec = true;
|
|
|
|
|
} else if (special == qt_("Width")) {
|
|
|
|
|
i = 4;
|
|
|
|
|
spec = true;
|
|
|
|
|
}
|
|
|
|
|
// the user might insert a non-special value in the line edit
|
|
|
|
|
if (isValidLength(fromqstr(value))) {
|
|
|
|
|
i = 0;
|
|
|
|
|
spec = false;
|
|
|
|
|
}
|
2008-03-08 13:02:52 +00:00
|
|
|
|
params_.special = fromqstr(ids_spec_[i]);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
string width;
|
|
|
|
|
if (spec) {
|
|
|
|
|
width = fromqstr(value);
|
|
|
|
|
// beware: bogosity! the unit is simply ignored in this case
|
|
|
|
|
width += "in";
|
2007-10-06 10:23:51 +00:00
|
|
|
|
} else {
|
2007-09-05 20:33:29 +00:00
|
|
|
|
width = widgetsToLength(widthED, widthUnitsLC);
|
2007-10-06 10:23:51 +00:00
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-10-06 10:23:51 +00:00
|
|
|
|
params_.width = Length(width);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
i = 0;
|
|
|
|
|
spec = false;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
special = heightUnitsLC->currentText();
|
|
|
|
|
value = heightED->text();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
if (special == qt_("Height")) {
|
|
|
|
|
i = 1;
|
|
|
|
|
spec = true;
|
|
|
|
|
} else if (special == qt_("Depth")) {
|
|
|
|
|
i = 2;
|
|
|
|
|
spec = true;
|
|
|
|
|
} else if (special == qt_("Total Height")) {
|
|
|
|
|
i = 3;
|
|
|
|
|
spec = true;
|
|
|
|
|
} else if (special == qt_("Width")) {
|
|
|
|
|
i = 4;
|
|
|
|
|
spec = true;
|
|
|
|
|
}
|
|
|
|
|
// the user might insert a non-special value in the line edit
|
|
|
|
|
if (isValidLength(fromqstr(value))) {
|
|
|
|
|
i = 0;
|
|
|
|
|
spec = false;
|
|
|
|
|
}
|
2008-03-08 13:02:52 +00:00
|
|
|
|
params_.height_special = fromqstr(ids_spec_[i]);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
|
|
string height;
|
2007-09-05 20:33:29 +00:00
|
|
|
|
if (spec && !isValidLength(fromqstr(heightED->text()))) {
|
2006-03-05 17:24:44 +00:00
|
|
|
|
height = fromqstr(value);
|
|
|
|
|
// beware: bogosity! the unit is simply ignored in this case
|
|
|
|
|
height += "in";
|
|
|
|
|
} else
|
2007-09-05 20:33:29 +00:00
|
|
|
|
height = widgetsToLength(heightED, heightUnitsLC);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
2007-09-27 20:19:06 +00:00
|
|
|
|
// the height parameter is omitted in InsetBox.cpp when the value
|
|
|
|
|
// is "1in" and "Total Height" is used as unit.
|
|
|
|
|
// 1in + "Total Height" means "1\height" which is the LaTeX default when
|
|
|
|
|
// no height is given
|
|
|
|
|
if (heightCB->checkState() == Qt::Checked)
|
2007-10-06 10:23:51 +00:00
|
|
|
|
params_.height = Length(height);
|
2007-09-27 20:19:06 +00:00
|
|
|
|
else {
|
2007-10-06 10:23:51 +00:00
|
|
|
|
params_.height = Length("1in");
|
2008-03-08 13:02:52 +00:00
|
|
|
|
params_.height_special = fromqstr(ids_spec_[3]);
|
2007-09-27 20:19:06 +00:00
|
|
|
|
}
|
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
|
|
|
|
{
|
2008-03-08 13:02:52 +00:00
|
|
|
|
// FIXME: Needed? Already done in the constructor
|
|
|
|
|
ids_spec_ = boxGuiSpecialLengthIds();
|
|
|
|
|
gui_names_spec_ = boxGuiSpecialLengthNames();
|
|
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
|
// check if the widget contains the special units
|
2007-09-05 20:33:29 +00:00
|
|
|
|
int count = widthUnitsLC->count();
|
2006-03-05 17:24:44 +00:00
|
|
|
|
bool has_special = false;
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != count; ++i)
|
2007-09-05 20:33:29 +00:00
|
|
|
|
if (widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0)
|
2006-03-05 17:24:44 +00:00
|
|
|
|
has_special = true;
|
|
|
|
|
// insert 'em if needed...
|
|
|
|
|
if (!ibox && !has_special) {
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 1; i < gui_names_spec_.size(); ++i)
|
|
|
|
|
widthUnitsLC->addItem(gui_names_spec_[i]);
|
2006-03-05 17:24:44 +00:00
|
|
|
|
// ... or remove 'em if needed
|
|
|
|
|
} else if (ibox && has_special) {
|
2007-09-05 20:33:29 +00:00
|
|
|
|
widthUnitsLC->clear();
|
2008-03-08 13:02:52 +00:00
|
|
|
|
for (int i = 0; i != num_units; ++i)
|
2007-09-05 20:33:29 +00:00
|
|
|
|
widthUnitsLC->addItem(qt_(unit_name_gui[i]));
|
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
|
|
|
|
if (innerBoxCO->count() == 2)
|
2007-09-11 22:31:24 +00:00
|
|
|
|
++i;
|
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
|
|
|
|
bool GuiBox::initialiseParams(string const & data)
|
|
|
|
|
{
|
2008-03-27 07:26:37 +00:00
|
|
|
|
InsetBox::string2params(data, params_);
|
2007-10-06 10:23:51 +00:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GuiBox::clearParams()
|
|
|
|
|
{
|
|
|
|
|
params_ = InsetBoxParams("");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GuiBox::dispatchParams()
|
|
|
|
|
{
|
2008-03-27 07:26:37 +00:00
|
|
|
|
dispatch(FuncRequest(getLfun(), InsetBox::params2string(params_)));
|
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
|
|
|
|
|
|
|
|
|
|
2007-08-31 05:53:55 +00:00
|
|
|
|
#include "GuiBox_moc.cpp"
|