Box fixes from Vincent and me.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@26711 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jürgen Spitzmüller 2008-10-04 09:24:40 +00:00
parent c4570a96da
commit e2fc0d4385
2 changed files with 37 additions and 16 deletions

View File

@ -185,6 +185,8 @@ void GuiBox::typeChanged(int index)
if (index != 1) if (index != 1)
pagebreakCB->setChecked(false); pagebreakCB->setChecked(false);
int itype = innerBoxCO->currentIndex(); int itype = innerBoxCO->currentIndex();
if (innerBoxCO->count() == 2)
++itype;
pagebreakCB->setEnabled(index == 1 && itype == 0); pagebreakCB->setEnabled(index == 1 && itype == 0);
widthED->setEnabled(index != 5); widthED->setEnabled(index != 5);
widthUnitsLC->setEnabled(index != 5); widthUnitsLC->setEnabled(index != 5);
@ -414,8 +416,10 @@ void GuiBox::setSpecial(bool ibox)
ids_spec_ = boxGuiSpecialLengthIds(); ids_spec_ = boxGuiSpecialLengthIds();
gui_names_spec_ = boxGuiSpecialLengthNames(); gui_names_spec_ = boxGuiSpecialLengthNames();
QString const current_text = widthUnitsLC->currentText();
// check if the widget contains the special units // check if the widget contains the special units
int count = widthUnitsLC->count(); int const count = widthUnitsLC->count();
bool has_special = false; bool has_special = false;
for (int i = 0; i != count; ++i) for (int i = 0; i != count; ++i)
if (widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0) if (widthUnitsLC->itemText(i).contains(qt_("Total Height")) > 0)
@ -430,6 +434,10 @@ void GuiBox::setSpecial(bool ibox)
for (int i = 0; i != num_units; ++i) for (int i = 0; i != num_units; ++i)
widthUnitsLC->addItem(qt_(unit_name_gui[i])); widthUnitsLC->addItem(qt_(unit_name_gui[i]));
} }
// restore selected text, if possible
int const idx = widthUnitsLC->findText(current_text);
if (idx != -1)
widthUnitsLC->setCurrentIndex(idx);
} }
@ -446,8 +454,6 @@ void GuiBox::setInnerType(bool frameless, int i)
else else
innerBoxCO->setCurrentIndex(i); innerBoxCO->setCurrentIndex(i);
} else { } else {
if (innerBoxCO->count() == 2)
++i;
innerBoxCO->clear(); innerBoxCO->clear();
innerBoxCO->addItem(qt_("None")); innerBoxCO->addItem(qt_("None"));
innerBoxCO->addItem(qt_("Parbox")); innerBoxCO->addItem(qt_("Parbox"));

View File

@ -28,6 +28,7 @@
#include "support/debug.h" #include "support/debug.h"
#include "support/gettext.h" #include "support/gettext.h"
#include "support/lstrings.h"
#include "support/Translator.h" #include "support/Translator.h"
#include "frontends/Application.h" #include "frontends/Application.h"
@ -35,6 +36,7 @@
#include <sstream> #include <sstream>
using namespace std; using namespace std;
using namespace lyx::support;
namespace lyx { namespace lyx {
@ -139,21 +141,34 @@ void InsetBox::read(Lexer & lex)
void InsetBox::setButtonLabel() void InsetBox::setButtonLabel()
{ {
BoxType btype = boxtranslator().find(params_.type); BoxType const btype = boxtranslator().find(params_.type);
docstring const type = _("Box");
docstring inner;
if (params_.inner_box) {
if (params_.use_parbox)
inner = _("Parbox");
else
inner = _("Minipage");
}
docstring frame;
if (btype != Frameless)
frame = boxtranslator_loc().find(btype);
docstring label; docstring label;
label += _("Box"); if (inner.empty() && frame.empty())
label += " ("; label = type;
if (btype == Frameless) { else if (inner.empty())
if (params_.use_parbox) label = bformat(_("%1$s (%2$s)"),
label += _("Parbox"); type, frame);
else else if (frame.empty())
label += _("Minipage"); label = bformat(_("%1$s (%2$s)"),
} else { type, inner);
label += boxtranslator_loc().find(btype); else
} label = bformat(_("%1$s (%2$s, %3$s)"),
label += ")"; type, inner, frame);
setLabel(label); setLabel(label);
} }