move space above/below from Paragraph into a separate vspace inset.

Gui interaction mailer stuff by Angus...


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@8149 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
André Pönitz 2003-11-28 15:53:34 +00:00
parent 741064fa58
commit 7de76711b1
39 changed files with 1242 additions and 1690 deletions

View File

@ -1286,13 +1286,7 @@ bool BufferView::Pimpl::insertInset(InsetOld * inset, string const & lout)
bool hasLayout = tclass.hasLayout(lres);
bv_->text()->setLayout(hasLayout ? lres : tclass.defaultLayoutName());
bv_->text()->setParagraph(
VSpace(VSpace::NONE), VSpace(VSpace::NONE),
Spacing(),
LYX_ALIGN_LAYOUT,
string(),
0);
bv_->text()->setParagraph(Spacing(), LYX_ALIGN_LAYOUT, string(), 0);
}
bv_->cursor().innerText()->insertInset(inset);
unFreezeUndo();

View File

@ -1,4 +1,22 @@
2003-11-28 André Pönitz <poenitz@gmx.net>
* ParagraphParameters.[Ch]:
* ParameterStruct.h: remove space above/below from Paragraph to
InsetVSpace
* BufferView_pimpl.C:
* factory.C:
* lyxfunc.C:
* lyxtext.h:
* output_latex.C:
* paragraph.C:
* paragraph_funcs.C:
* rowpainter.[Ch]:
* text.C:
* text2.C:
* text3.C: adjust
2003-11-28 Martin Vermeer <martin.vermeer@hut.fi>
* factory.C: Syntax change for CharStyles

View File

@ -52,8 +52,6 @@ ParagraphParameters::ParagraphParameters()
void ParagraphParameters::clear()
{
ParameterStruct tmp(*param);
tmp.added_space_top = VSpace(VSpace::NONE);
tmp.added_space_bottom = VSpace(VSpace::NONE);
tmp.spacing.set(Spacing::Default);
tmp.align = LYX_ALIGN_LAYOUT;
tmp.depth = 0;
@ -74,8 +72,6 @@ ParagraphParameters::depth_type ParagraphParameters::depth() const
bool ParagraphParameters::sameLayout(ParagraphParameters const & pp) const
{
return param->align == pp.param->align &&
param->added_space_bottom == pp.param->added_space_bottom &&
param->added_space_top == pp.param->added_space_top &&
param->spacing == pp.param->spacing &&
param->noindent == pp.param->noindent &&
param->depth == pp.param->depth;
@ -89,34 +85,6 @@ void ParagraphParameters::set_from_struct(ParameterStruct const & ps)
}
VSpace const & ParagraphParameters::spaceTop() const
{
return param->added_space_top;
}
void ParagraphParameters::spaceTop(VSpace const & vs)
{
ParameterStruct tmp(*param);
tmp.added_space_top = vs;
set_from_struct(tmp);
}
VSpace const & ParagraphParameters::spaceBottom() const
{
return param->added_space_bottom;
}
void ParagraphParameters::spaceBottom(VSpace const & vs)
{
ParameterStruct tmp(*param);
tmp.added_space_bottom = vs;
set_from_struct(tmp);
}
Spacing const & ParagraphParameters::spacing() const
{
return param->spacing;
@ -257,10 +225,6 @@ void ParagraphParameters::read(LyXLex & lex)
lex.nextToken();
LyXLength value(lex.getString());
leftIndent(value);
} else if (token == "\\fill_top") {
spaceTop(VSpace(VSpace::VFILL));
} else if (token == "\\fill_bottom") {
spaceBottom(VSpace(VSpace::VFILL));
} else if (token == "\\start_of_appendix") {
startOfAppendix(true);
} else if (token == "\\paragraph_spacing") {
@ -284,24 +248,6 @@ void ParagraphParameters::read(LyXLex & lex)
if (tmpret == -1)
++tmpret;
align(LyXAlignment(1 << tmpret));
} else if (token == "\\added_space_top") {
lex.nextToken();
VSpace value = VSpace(lex.getString());
// only add the length when value > 0 or
// with option keep
if ((value.length().len().value() != 0) ||
value.keep() ||
(value.kind() != VSpace::LENGTH))
spaceTop(value);
} else if (token == "\\added_space_bottom") {
lex.nextToken();
VSpace value = VSpace(lex.getString());
// only add the length when value > 0 or
// with option keep
if ((value.length().len().value() != 0) ||
value.keep() ||
(value.kind() != VSpace::LENGTH))
spaceBottom(value);
} else if (token == "\\labelwidthstring") {
lex.eatLine();
labelWidthString(lex.getString());
@ -315,14 +261,6 @@ void ParagraphParameters::read(LyXLex & lex)
void ParagraphParameters::write(ostream & os) const
{
// Maybe some vertical spaces.
if (spaceTop().kind() != VSpace::NONE)
os << "\\added_space_top "
<< spaceTop().asLyXCommand() << ' ';
if (spaceBottom().kind() != VSpace::NONE)
os << "\\added_space_bottom "
<< spaceBottom().asLyXCommand() << ' ';
// Maybe the paragraph has special spacing
spacing().writeFile(os, true);
@ -358,7 +296,6 @@ void ParagraphParameters::write(ostream & os) const
}
void setParagraphParams(BufferView & bv, string const & data)
{
istringstream is(data);
@ -370,8 +307,6 @@ void setParagraphParams(BufferView & bv, string const & data)
LyXText * text = bv.getLyXText();
text->setParagraph(
params.spaceTop(),
params.spaceBottom(),
params.spacing(),
params.align(),
params.labelWidthString(),

View File

@ -28,7 +28,6 @@ class LyXLex;
class Paragraph;
class ParameterStruct;
class Spacing;
class VSpace;
///
class ParagraphParameters {
@ -40,14 +39,6 @@ public:
///
bool sameLayout(ParagraphParameters const &) const;
///
VSpace const & spaceTop() const;
///
void spaceTop(VSpace const &);
///
VSpace const & spaceBottom() const;
///
void spaceBottom(VSpace const &);
///
Spacing const & spacing() const;
///
void spacing(Spacing const &);

View File

@ -15,7 +15,6 @@
#include "layout.h"
#include "lyxlength.h"
#include "Spacing.h"
#include "vspace.h"
#include "support/types.h"
@ -27,10 +26,6 @@ struct ParameterStruct {
///
ParameterStruct();
///
VSpace added_space_top;
///
VSpace added_space_bottom;
///
Spacing spacing;
///
bool noindent;
@ -63,9 +58,8 @@ inline
bool operator==(ParameterStruct const & ps1,
ParameterStruct const & ps2)
{
return ps1.added_space_top == ps2.added_space_top
&& ps1.added_space_bottom == ps2.added_space_bottom
&& ps1.spacing == ps2.spacing
return
ps1.spacing == ps2.spacing
&& ps1.noindent == ps2.noindent
&& ps1.align == ps2.align
&& ps1.depth == ps2.depth

View File

@ -51,6 +51,7 @@
#include "insets/insettabular.h"
#include "insets/insettoc.h"
#include "insets/inseturl.h"
#include "insets/insetvspace.h"
#include "insets/insetwrap.h"
#include "mathed/formulamacro.h"
#include "mathed/formula.h"
@ -174,7 +175,7 @@ InsetOld * createInset(FuncRequest const & cmd)
case LFUN_TABULAR_INSERT:
if (!cmd.argument.empty()) {
std::istringstream ss(cmd.argument);
int r, c;
int r = 0, c = 0;
ss >> r >> c;
if (r <= 0) r = 2;
if (c <= 0) c = 2;
@ -184,7 +185,7 @@ InsetOld * createInset(FuncRequest const & cmd)
return 0;
case LFUN_INSET_CAPTION:
if (bv->innerInset()) {
if (!bv->innerInset()) {
auto_ptr<InsetCaption> inset(new InsetCaption(params));
inset->setOwner(bv->innerInset());
inset->setAutoBreakRows(true);
@ -192,6 +193,7 @@ InsetOld * createInset(FuncRequest const & cmd)
inset->setFrameColor(LColor::captionframe);
return inset.release();
}
return 0;
case LFUN_INDEX_PRINT:
return new InsetPrintIndex(InsetCommandParams("printindex"));
@ -280,6 +282,11 @@ InsetOld * createInset(FuncRequest const & cmd)
InsetCommandParams icp;
InsetCommandMailer::string2params(cmd.argument, icp);
return new InsetUrl(icp);
} else if (name == "vspace") {
VSpace vspace;
InsetVSpaceMailer::string2params(cmd.argument, vspace);
return new InsetVSpace(vspace);
}
}
@ -423,6 +430,8 @@ InsetOld * readInset(LyXLex & lex, Buffer const & buf)
inset.reset(new InsetTabular(buf));
} else if (tmptok == "Text") {
inset.reset(new InsetText(buf.params()));
} else if (tmptok == "VSpace") {
inset.reset(new InsetVSpace);
} else if (tmptok == "Foot") {
inset.reset(new InsetFoot(buf.params()));
} else if (tmptok == "Marginal") {

View File

@ -1,3 +1,9 @@
2003-11-28 André Pönitz <poenitz@gmx.net>
* ControlVSpace.[Ch]: new files
* Makefile.am: adjust
2003-11-21 Michael Schmitt <michael.schmitt@teststep.org>
* ControlDocument.C: Change call to insetsOpenCloseBranch

View File

@ -0,0 +1,58 @@
/**
* \file ControlVSpace.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Edwin Leuven
* \author Angus Leeming
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "ControlVSpace.h"
#include "funcrequest.h"
#include "insets/insetvspace.h"
using std::istringstream;
using std::string;
ControlVSpace::ControlVSpace(Dialog & parent)
: Dialog::Controller(parent)
{}
bool ControlVSpace::initialiseParams(string const & data)
{
InsetVSpaceMailer::string2params(data, params_);
return true;
}
void ControlVSpace::clearParams()
{
params_ = VSpace();
}
void ControlVSpace::dispatchParams()
{
string const str = InsetVSpaceMailer::params2string(params_);
kernel().dispatch(FuncRequest(LFUN_INSET_APPLY, str));
}
VSpace & ControlVSpace::params()
{
return params_;
}
VSpace const & ControlVSpace::params() const
{
return params_;
}

View File

@ -0,0 +1,44 @@
// -*- C++ -*-
/**
* \file ControlVSpace.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author Edwin Leuven
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef CONTROLVSPACE_H
#define CONTROLVSPACE_H
#include "Dialog.h"
#include "vspace.h"
class ControlVSpace : public Dialog::Controller {
public:
///
ControlVSpace(Dialog &);
///
virtual bool initialiseParams(std::string const & data);
/// clean-up on hide.
virtual void clearParams();
/// clean-up on hide.
virtual void dispatchParams();
///
virtual bool isBufferDependent() const { return true; }
///
VSpace & params();
///
VSpace const & params() const;
///
bool inInset() const;
private:
///
VSpace params_;
};
#endif // CONTROLPARAGRAPH_H

View File

@ -104,6 +104,8 @@ libcontrollers_la_SOURCES= \
ControlToc.h \
ControlVCLog.C \
ControlVCLog.h \
ControlVSpace.C \
ControlVSpace.h \
ControlWrap.C \
ControlWrap.h \
GUI.h \

View File

@ -65,103 +65,18 @@ void QParagraph::build_dialog()
bind2nd(contains_functor(), "%"));
units_.erase(del, units_.end());
for (vector<string>::const_iterator it = units_.begin();
it != units_.end(); ++it) {
dialog_->unitAbove->insertItem(toqstr(*it));
dialog_->unitBelow->insertItem(toqstr(*it));
}
// Manage the ok, apply, restore and cancel/close buttons
bcview().setOK(dialog_->okPB);
bcview().setApply(dialog_->applyPB);
bcview().setCancel(dialog_->closePB);
bcview().setRestore(dialog_->restorePB);
bcview().addReadOnly(dialog_->paragraphTab);
}
namespace {
VSpace setVSpaceFromWidgets(int spacing,
string value,
string unit,
bool keep)
{
VSpace space;
switch (spacing) {
case 0:
space = VSpace(VSpace::NONE);
break;
case 1:
space = VSpace(VSpace::DEFSKIP);
break;
case 2:
space = VSpace(VSpace::SMALLSKIP);
break;
case 3:
space = VSpace(VSpace::MEDSKIP);
break;
case 4:
space = VSpace(VSpace::BIGSKIP);
break;
case 5:
space = VSpace(VSpace::VFILL);
break;
case 6:
string s;
string const length = trim(value);
if (isValidGlueLength(length)) {
s = length;
} else if (!length.empty()){
string u = trim(unit);
u = subst(u, "%%", "%");
s = length + u;
}
space = VSpace(LyXGlueLength(s));
break;
}
space.setKeep(keep);
return space;
}
} // namespace anon
void QParagraph::apply()
{
ParagraphParameters & params = controller().params();
// SPACING ABOVE
// If a vspace kind is "Length" but there's no text in
// the input field, reset the kind to "None".
if (dialog_->spacingAbove->currentItem() == 6
&& dialog_->valueAbove->text().isEmpty())
dialog_->spacingAbove->setCurrentItem(0);
VSpace const space_top =
setVSpaceFromWidgets(dialog_->spacingAbove->currentItem(),
fromqstr(dialog_->valueAbove->text()),
fromqstr(dialog_->unitAbove->currentText()),
dialog_->keepAbove->isChecked());
params.spaceTop(space_top);
// SPACING BELOW
if (dialog_->spacingBelow->currentItem() == 6
&& dialog_->valueBelow->text().isEmpty())
dialog_->spacingBelow->setCurrentItem(0);
VSpace const space_bottom =
setVSpaceFromWidgets(dialog_->spacingBelow->currentItem(),
fromqstr(dialog_->valueBelow->text()),
fromqstr(dialog_->unitBelow->currentText()),
dialog_->keepBelow->isChecked());
params.spaceBottom(space_bottom);
// alignment
LyXAlignment align;
switch (dialog_->align->currentItem()) {
@ -211,82 +126,9 @@ void QParagraph::apply()
params.labelWidthString(fromqstr(dialog_->labelWidth->text()));
// indendation
params.noindent(!dialog_->indentCB->isChecked());
}
namespace {
void setWidgetsFromVSpace(VSpace const & space,
QComboBox * spacing,
QLineEdit * value,
QComboBox * unit,
QCheckBox * keep, vector<string> units_)
{
value->setText("");
value->setEnabled(false);
unit->setEnabled(false);
int item = 0;
switch (space.kind()) {
case VSpace::NONE:
item = 0;
break;
case VSpace::DEFSKIP:
item = 1;
break;
case VSpace::SMALLSKIP:
item = 2;
break;
case VSpace::MEDSKIP:
item = 3;
break;
case VSpace::BIGSKIP:
item = 4;
break;
case VSpace::VFILL:
item = 5;
break;
case VSpace::LENGTH:
item = 6;
value->setEnabled(true);
unit->setEnabled(true);
string length = space.length().asString();
string const default_unit =
(lyxrc.default_papersize > 3) ? "cm" : "in";
string supplied_unit = default_unit;
LyXLength len(length);
if ((isValidLength(length)
|| isStrDbl(length)) && !len.zero()) {
length = tostr(len.value());
supplied_unit = subst(stringFromUnit(len.unit()),
"%", "%%");
}
int unit_item = 0;
int i = 0;
for (vector<string>::const_iterator it = units_.begin();
it != units_.end(); ++it) {
if (*it == default_unit) {
unit_item = i;
}
if (*it == supplied_unit) {
unit_item = i;
break;
}
i += 1;
}
value->setText(toqstr(length));
unit->setCurrentItem(unit_item);
break;
}
spacing->setCurrentItem(item);
keep->setChecked(space.keep());
}
} // namespace anon
void QParagraph::update_contents()
{
ParagraphParameters const & params = controller().params();
@ -354,18 +196,4 @@ void QParagraph::update_contents()
dialog_->linespacingValue->setText("");
dialog_->linespacingValue->setEnabled(false);
}
// vspace top
setWidgetsFromVSpace(params.spaceTop(),
dialog_->spacingAbove,
dialog_->valueAbove,
dialog_->unitAbove,
dialog_->keepAbove,units_);
// vspace bottom
setWidgetsFromVSpace(params.spaceBottom(),
dialog_->spacingBelow,
dialog_->valueBelow,
dialog_->unitBelow,
dialog_->keepBelow,units_);
}

View File

@ -64,23 +64,6 @@ void QParagraphDialog::change_adaptor()
}
void QParagraphDialog::enableAbove(int)
{
bool const enable = spacingAbove->currentItem()==6;
valueAbove->setEnabled(enable);
unitAbove->setEnabled(enable);
}
void QParagraphDialog::enableBelow(int)
{
bool const enable = spacingBelow->currentItem()==6;
valueBelow->setEnabled(enable);
unitBelow->setEnabled(enable);
}
void QParagraphDialog::enableLinespacingValue(int)
{
bool const enable = linespacing->currentItem()==4;

View File

@ -28,8 +28,6 @@ private:
QParagraph * form_;
protected slots:
void change_adaptor();
void enableAbove(int);
void enableBelow(int);
void enableLinespacingValue(int);
};

File diff suppressed because it is too large Load Diff

View File

@ -1,3 +1,9 @@
2003-11-28 André Pönitz <poenitz@gmx.net>
* FormsVSpace.[Ch]: new file
* forms/form_vspace.fd: new file
2003-11-14 Jean-Marc Lasgouttes <lasgouttes@lyx.org>
* forms/form_maths_panel.fd (label): replace label "Greek" by

View File

@ -37,6 +37,7 @@
#include "ControlTabularCreate.h"
#include "ControlToc.h"
#include "ControlVCLog.h"
#include "ControlVSpace.h"
#include "ControlWrap.h"
#include "FormAboutlyx.h"
@ -72,6 +73,7 @@
#include "FormToc.h"
#include "FormUrl.h"
#include "FormVCLog.h"
#include "FormVSpace.h"
#include "FormWrap.h"
#ifdef HAVE_LIBAIKSAURUS
@ -125,7 +127,7 @@ char const * const dialognames[] = {
"thesaurus",
#endif
"toc", "url", "vclog", "wrap" };
"toc", "url", "vclog", "vspace", "wrap" };
char const * const * const end_dialognames =
dialognames + (sizeof(dialognames) / sizeof(char *));
@ -459,6 +461,10 @@ Dialog * Dialogs::build(string const & name)
dialog->setController(new ControlVCLog(*dialog));
dialog->setView(new FormVCLog(*dialog));
dialog->bc().bp(new OkCancelPolicy);
} else if (name == "vspace") {
dialog->setController(new ControlVSpace(*dialog));
dialog->setView(new FormVSpace(*dialog));
dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
} else if (name == "wrap") {
dialog->setController(new ControlWrap(*dialog));
dialog->setView(new FormWrap(*dialog));

View File

@ -26,7 +26,6 @@
#include "lyxrc.h" // to set the deafult length values
#include "ParagraphParameters.h"
#include "Spacing.h"
#include "vspace.h"
#include "support/lstrings.h"
#include "support/tostr.h"
@ -44,24 +43,10 @@ using std::vector;
using std::string;
namespace
{
namespace {
string defaultUnit("cm");
void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length);
VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type,
FL_OBJECT * input_length,
FL_OBJECT * choice_length,
FL_OBJECT * check_keep);
void setWidgetsFromVSpace(VSpace const & space,
FL_OBJECT * choice_type,
FL_OBJECT * input_length,
FL_OBJECT * choice_length,
FL_OBJECT * check_keep);
} // namespace anon
@ -84,36 +69,16 @@ void FormParagraph::build()
bcview().setRestore(dialog_->button_restore);
// disable for read-only documents
bcview().addReadOnly(dialog_->choice_space_above);
bcview().addReadOnly(dialog_->input_space_above);
bcview().addReadOnly(dialog_->check_space_above);
bcview().addReadOnly(dialog_->check_noindent);
bcview().addReadOnly(dialog_->choice_linespacing);
bcview().addReadOnly(dialog_->input_linespacing);
bcview().addReadOnly(dialog_->choice_space_below);
bcview().addReadOnly(dialog_->input_space_below);
bcview().addReadOnly(dialog_->check_space_below);
bcview().addReadOnly(dialog_->input_labelwidth);
// check validity of "length + unit" input
addCheckedGlueLength(bcview(),
dialog_->input_space_above,
dialog_->choice_space_above);
addCheckedGlueLength(bcview(),
dialog_->input_space_below,
dialog_->choice_space_below);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(dialog_->input_space_above);
setPrehandler(dialog_->input_space_below);
setPrehandler(dialog_->input_linespacing);
setPrehandler(dialog_->input_labelwidth);
fl_set_input_return(dialog_->input_space_above, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_space_below, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_labelwidth, FL_RETURN_CHANGED);
fl_set_input_return(dialog_->input_linespacing, FL_RETURN_CHANGED);
@ -126,10 +91,6 @@ void FormParagraph::build()
alignment_.init(dialog_->radio_align_block, LYX_ALIGN_BLOCK);
alignment_.init(dialog_->radio_align_center, LYX_ALIGN_CENTER);
string const parspacing = _("None|DefSkip|SmallSkip|MedSkip|BigSkip|VFill|Length");
fl_addto_choice(dialog_->choice_space_above, parspacing.c_str());
fl_addto_choice(dialog_->choice_space_below, parspacing.c_str());
string const linespacing = _("Default|Single|OneHalf|Double|Custom");
fl_addto_choice(dialog_->choice_linespacing, linespacing.c_str());
@ -140,21 +101,6 @@ void FormParagraph::build()
bind2nd(contains_functor(), "%"));
units_vec.erase(del, units_vec.end());
string const units = getStringFromVector(units_vec, "|");
fl_addto_choice(dialog_->choice_unit_space_above, units.c_str());
fl_addto_choice(dialog_->choice_unit_space_below, units.c_str());
// set up the tooltips
string str = _("Add additional space above this paragraph.");
tooltips().init(dialog_->choice_space_above, str);
str = _("Never suppress space (e.g. at top of page or new page).");
tooltips().init(dialog_->check_space_above, str);
str = _("Add additional space below this paragraph.");
tooltips().init(dialog_->choice_space_below, str);
str = _("Never suppress space (e.g. at bottom of page or new page).");
tooltips().init(dialog_->check_space_below, str);
// set default unit for custom length
switch (lyxrc.default_papersize) {
case PAPER_DEFAULT:
@ -175,32 +121,8 @@ void FormParagraph::build()
void FormParagraph::apply()
{
if (!form()) return;
// spacing
// If a vspace choice is "Length" but there's no text in
// the input field, reset the choice to "None".
validateVSpaceWidgets(dialog_->choice_space_above,
dialog_->input_space_above);
VSpace const space_above =
setVSpaceFromWidgets(dialog_->choice_space_above,
dialog_->input_space_above,
dialog_->choice_unit_space_above,
dialog_->check_space_above);
controller().params().spaceTop(space_above);
validateVSpaceWidgets(dialog_->choice_space_below,
dialog_->input_space_below);
VSpace const space_below =
setVSpaceFromWidgets(dialog_->choice_space_below,
dialog_->input_space_below,
dialog_->choice_unit_space_below,
dialog_->check_space_below);
controller().params().spaceBottom(space_below);
if (!form())
return;
// alignment
LyXAlignment const alignment =
@ -344,20 +266,6 @@ void FormParagraph::update()
fl_set_input(dialog_->input_linespacing, "");
}
// vspace top
setWidgetsFromVSpace(controller().params().spaceTop(),
dialog_->choice_space_above,
dialog_->input_space_above,
dialog_->choice_unit_space_above,
dialog_->check_space_above);
// vspace bottom
setWidgetsFromVSpace(controller().params().spaceBottom(),
dialog_->choice_space_below,
dialog_->input_space_below,
dialog_->choice_unit_space_below,
dialog_->check_space_below);
// no indent
fl_set_button(dialog_->check_noindent,
controller().params().noindent());
@ -368,27 +276,7 @@ ButtonPolicy::SMInput FormParagraph::input(FL_OBJECT * ob, long)
{
// Enable input when custum length is choosen,
// disable 'keep' when no space is choosen
if (ob == dialog_->choice_space_above) {
bool const custom_length =
fl_get_choice(dialog_->choice_space_above) == 7;
setEnabled(dialog_->input_space_above, custom_length);
setEnabled(dialog_->choice_unit_space_above, custom_length);
bool const space =
fl_get_choice(dialog_->choice_space_above) != 1;
setEnabled(dialog_->check_space_above, space);
} else if (ob == dialog_->choice_space_below) {
bool const custom_length =
fl_get_choice(dialog_->choice_space_below) == 7;
setEnabled(dialog_->input_space_below, custom_length);
setEnabled(dialog_->choice_unit_space_below, custom_length);
bool const space =
fl_get_choice(dialog_->choice_space_below) != 1;
setEnabled(dialog_->check_space_below, space);
} else if (ob == dialog_->choice_linespacing) {
if (ob == dialog_->choice_linespacing) {
bool const custom_spacing =
fl_get_choice(dialog_->choice_linespacing) == 5;
setEnabled(dialog_->input_linespacing, custom_spacing);
@ -396,127 +284,3 @@ ButtonPolicy::SMInput FormParagraph::input(FL_OBJECT * ob, long)
return ButtonPolicy::SMI_VALID;
}
namespace {
void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length)
{
// Paranoia check!
BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT);
if (fl_get_choice(choice_type) != 7)
return;
// If a vspace kind is "Length" but there's no text in
// the input field, reset the kind to "None".
string const input = rtrim(getString(input_length));
if (input.empty())
fl_set_choice(choice_type, 1);
}
VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type,
FL_OBJECT * input_length,
FL_OBJECT * choice_length,
FL_OBJECT * check_keep)
{
// Paranoia check!
BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT &&
choice_length && choice_length->objclass == FL_CHOICE &&
check_keep && check_keep->objclass == FL_CHECKBUTTON);
VSpace space;
switch (fl_get_choice(choice_type)) {
case 1:
space = VSpace(VSpace::NONE);
break;
case 2:
space = VSpace(VSpace::DEFSKIP);
break;
case 3:
space = VSpace(VSpace::SMALLSKIP);
break;
case 4:
space = VSpace(VSpace::MEDSKIP);
break;
case 5:
space = VSpace(VSpace::BIGSKIP);
break;
case 6:
space = VSpace(VSpace::VFILL);
break;
case 7:
{
string const length =
getLengthFromWidgets(input_length, choice_length);
space = VSpace(LyXGlueLength(length));
break;
}
}
if (fl_get_button(check_keep))
space.setKeep(true);
return space;
}
void setWidgetsFromVSpace(VSpace const & space,
FL_OBJECT * choice_type,
FL_OBJECT * input_length,
FL_OBJECT * choice_length,
FL_OBJECT * check_keep)
{
// Paranoia check!
BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT &&
choice_length && choice_length->objclass == FL_CHOICE &&
check_keep && check_keep->objclass == FL_CHECKBUTTON);
fl_set_button(check_keep, space.keep());
int pos = 1;
switch (space.kind()) {
case VSpace::NONE:
pos = 1;
break;
case VSpace::DEFSKIP:
pos = 2;
break;
case VSpace::SMALLSKIP:
pos = 3;
break;
case VSpace::MEDSKIP:
pos = 4;
break;
case VSpace::BIGSKIP:
pos = 5;
break;
case VSpace::VFILL:
pos = 6;
break;
case VSpace::LENGTH:
pos = 7;
break;
}
fl_set_choice(choice_type, pos);
bool const custom_vspace = space.kind() == VSpace::LENGTH;
setEnabled(input_length, custom_vspace);
setEnabled(choice_length, custom_vspace);
if (custom_vspace) {
string const length = space.length().asString();
updateWidgetsFromLengthString(input_length, choice_length,
length, defaultUnit);
} else {
bool const no_vspace = space.kind() == VSpace::NONE;
setEnabled(check_keep, !no_vspace);
fl_set_input(input_length, "");
fl_set_choice_text(choice_length, defaultUnit.c_str());
}
}
} // namespace anon

View File

@ -0,0 +1,251 @@
/**
* \file FormVSpace.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
* \author Jürgen Vigna
* \author Rob Lahaye
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "FormVSpace.h"
#include "ControlVSpace.h"
#include "forms/form_vspace.h"
#include "checkedwidgets.h"
#include "input_validators.h"
#include "Tooltips.h"
#include "xforms_helpers.h"
#include "xformsBC.h"
#include "controllers/helper_funcs.h"
#include "lyxrc.h" // to set the deafult length values
#include "Spacing.h"
#include "vspace.h"
#include "support/lstrings.h"
#include "support/tostr.h"
#include "lyx_forms.h"
using lyx::support::contains_functor;
using lyx::support::getStringFromVector;
using lyx::support::rtrim;
using std::bind2nd;
using std::remove_if;
using std::vector;
using std::string;
namespace {
string defaultUnit("cm");
void validateVSpaceWidgets(FL_OBJECT * choice_type, FL_OBJECT * input_length)
{
// Paranoia check!
BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT);
if (fl_get_choice(choice_type) != 7)
return;
// If a vspace kind is "Length" but there's no text in
// the input field, reset the kind to "None".
string const input = rtrim(getString(input_length));
if (input.empty())
fl_set_choice(choice_type, 1);
}
VSpace const setVSpaceFromWidgets(FL_OBJECT * choice_type,
FL_OBJECT * input_length,
FL_OBJECT * choice_length)
{
// Paranoia check!
BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT &&
choice_length && choice_length->objclass == FL_CHOICE);
switch (fl_get_choice(choice_type)) {
case 1:
return VSpace(VSpace::NONE);
case 2:
return VSpace(VSpace::DEFSKIP);
case 3:
return VSpace(VSpace::SMALLSKIP);
case 4:
return VSpace(VSpace::MEDSKIP);
case 5:
return VSpace(VSpace::BIGSKIP);
case 6:
return VSpace(VSpace::VFILL);
case 7:
return VSpace(LyXGlueLength(
getLengthFromWidgets(input_length, choice_length)));
}
return VSpace(VSpace::NONE);
}
void setWidgetsFromVSpace(VSpace const & space,
FL_OBJECT * choice_type,
FL_OBJECT * input_length,
FL_OBJECT * choice_length)
{
// Paranoia check!
BOOST_ASSERT(choice_type && choice_type->objclass == FL_CHOICE &&
input_length && input_length->objclass == FL_INPUT &&
choice_length && choice_length->objclass == FL_CHOICE);
int pos = 1;
switch (space.kind()) {
case VSpace::NONE:
pos = 1;
break;
case VSpace::DEFSKIP:
pos = 2;
break;
case VSpace::SMALLSKIP:
pos = 3;
break;
case VSpace::MEDSKIP:
pos = 4;
break;
case VSpace::BIGSKIP:
pos = 5;
break;
case VSpace::VFILL:
pos = 6;
break;
case VSpace::LENGTH:
pos = 7;
break;
}
fl_set_choice(choice_type, pos);
bool const custom_vspace = space.kind() == VSpace::LENGTH;
if (custom_vspace) {
string const length = space.length().asString();
updateWidgetsFromLengthString(input_length, choice_length,
length, defaultUnit);
} else {
fl_set_input(input_length, "");
fl_set_choice_text(choice_length, defaultUnit.c_str());
}
}
} // namespace anon
typedef FormController<ControlVSpace, FormView<FD_vspace> > base_class;
FormVSpace::FormVSpace(Dialog & parent)
: base_class(parent, _("VSpace Settings"))
{}
void FormVSpace::build()
{
// the tabbed folder
dialog_.reset(build_vspace(this));
// Manage the ok, apply, restore and cancel/close buttons
bcview().setOK(dialog_->button_ok);
bcview().setApply(dialog_->button_apply);
bcview().setCancel(dialog_->button_close);
bcview().setRestore(dialog_->button_restore);
// disable for read-only documents
bcview().addReadOnly(dialog_->choice_space);
bcview().addReadOnly(dialog_->input_space);
// check validity of "length + unit" input
addCheckedGlueLength(bcview(),
dialog_->input_space,
dialog_->choice_space);
// trigger an input event for cut&paste with middle mouse button.
setPrehandler(dialog_->input_space);
fl_set_input_return(dialog_->input_space, FL_RETURN_CHANGED);
// Create the contents of the unit choices; don't include the "%" terms.
vector<string> units_vec = getLatexUnits();
vector<string>::iterator del =
remove_if(units_vec.begin(), units_vec.end(),
bind2nd(contains_functor(), "%"));
units_vec.erase(del, units_vec.end());
string const units = getStringFromVector(units_vec, "|");
fl_addto_choice(dialog_->choice_unit_space, units.c_str());
// set up the tooltips
string str = _("Additional vertical space.");
tooltips().init(dialog_->choice_space, str);
// set default unit for custom length
switch (lyxrc.default_papersize) {
case PAPER_DEFAULT:
case PAPER_USLETTER:
case PAPER_LEGALPAPER:
case PAPER_EXECUTIVEPAPER:
defaultUnit = "in";
break;
case PAPER_A3PAPER:
case PAPER_A4PAPER:
case PAPER_A5PAPER:
case PAPER_B5PAPER:
defaultUnit = "cm";
break;
}
}
void FormVSpace::apply()
{
if (!form())
return;
// spacing
// If a vspace choice is "Length" but there's no text in
// the input field, reset the choice to "None".
validateVSpaceWidgets(dialog_->choice_space, dialog_->input_space);
VSpace const space =
setVSpaceFromWidgets(dialog_->choice_space,
dialog_->input_space,
dialog_->choice_unit_space);
controller().params() = space;
}
void FormVSpace::update()
{
setWidgetsFromVSpace(controller().params(),
dialog_->choice_space,
dialog_->input_space,
dialog_->choice_unit_space);
}
ButtonPolicy::SMInput FormVSpace::input(FL_OBJECT * ob, long)
{
// Enable input when custum length is choosen,
// disable 'keep' when no space is choosen
if (ob == dialog_->choice_space) {
bool const custom_length =
fl_get_choice(dialog_->choice_space) == 7;
}
return ButtonPolicy::SMI_VALID;
}

View File

@ -0,0 +1,41 @@
// -*- C++ -*-
/**
* \file FormVSpace.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef FORM_VSPACE_H
#define FORM_VSPACE_H
#include "FormDialogView.h"
#include "RadioButtonGroup.h"
struct FD_vspace;
class ControlVSpace;
/** This class provides an XForms implementation of the FormVSpace dialog.
*/
class FormVSpace
: public FormController<ControlVSpace, FormView<FD_vspace> > {
public:
///
FormVSpace(Dialog &);
private:
/// Build the dialog
virtual void build();
/// Apply from dialog
virtual void apply();
/// Update the dialog
virtual void update();
/// Filter the inputs on callback from xforms
virtual ButtonPolicy::SMInput input(FL_OBJECT *, long);
};
#endif

View File

@ -154,6 +154,8 @@ libxforms_la_SOURCES = \
FormUrl.h \
FormVCLog.C \
FormVCLog.h \
FormVSpace.C \
FormVSpace.h \
FormWrap.C \
FormWrap.h \
LyXKeySymFactory.C \

View File

@ -50,6 +50,7 @@ SRCS = form_aboutlyx.fd \
form_thesaurus.fd \
form_toc.fd \
form_url.fd \
form_vspace.fd \
form_wrap.fd
nodist_libfdesign_la_SOURCES = $(SRCS:.fd=.C) $(SRCS:.fd=.h)

View File

@ -10,13 +10,13 @@ SnapGrid: 5
=============== FORM ===============
Name: form_paragraph
Width: 395
Height: 405
Number of Objects: 27
Height: 205
Number of Objects: 17
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 395 405
box: 0 0 395 205
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -34,7 +34,7 @@ argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 205 110 185 115
box: 205 10 185 115
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
@ -52,7 +52,7 @@ argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 5 110 200 115
box: 5 10 200 115
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
@ -67,154 +67,10 @@ name:
callback:
argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 5 235 385 90
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Below
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 5 10 385 90
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Above
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 230 20 120 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Vertical space:|#V
shortcut:
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: choice_space_above
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 230 45 70 25
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_East
name: input_space_above
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 230 70 80 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Keep|#K
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_space_above
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 230 245 120 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Vertical space:|#e
shortcut:
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: choice_space_below
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 230 270 70 25
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: input_space_below
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 230 295 80 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Keep|#p
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_West
name: check_space_below
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 20 185 90 25
box: 20 85 90 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_TOP
@ -232,7 +88,7 @@ argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 110 185 60 25
box: 110 85 60 25
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_CENTER
@ -250,7 +106,7 @@ argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 150 340 235 25
box: 150 140 235 25
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -286,7 +142,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 5 375 90 25
box: 5 175 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -304,7 +160,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 110 375 90 25
box: 110 175 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -322,7 +178,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 205 375 90 25
box: 205 175 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -340,7 +196,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 300 375 90 25
box: 300 175 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -355,42 +211,6 @@ name: button_close
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 300 45 50 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_unit_space_above
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 300 270 50 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_unit_space_below
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_BEGIN_GROUP
type: 0
@ -412,7 +232,7 @@ argument:
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 215 170 170 25
box: 215 70 170 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -430,7 +250,7 @@ argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 215 145 170 25
box: 215 45 170 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -448,7 +268,7 @@ argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 215 120 170 25
box: 215 20 170 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -466,7 +286,7 @@ argument: 0
--------------------
class: FL_ROUND3DBUTTON
type: RADIO_BUTTON
box: 215 195 170 25
box: 215 95 170 25
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER

View File

@ -0,0 +1,161 @@
Magic: 13000
Internal Form Definition File
(do not change)
Number of forms: 1
Unit of measure: FL_COORD_PIXEL
SnapGrid: 5
=============== FORM ===============
Name: form_vspace
Width: 395
Height: 105
Number of Objects: 8
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 395 105
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 230 20 120 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Vertical space:|#V
shortcut:
resize: FL_RESIZE_X
gravity: FL_West FL_East
name: choice_space
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 230 45 70 25
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_West FL_East
name: input_space
callback: C_FormDialogView_InputCB
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 5 75 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Restore|#R
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthWest FL_SouthWest
name: button_restore
callback: C_FormDialogView_RestoreCB
argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 110 75 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: OK
shortcut: ^M
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_ok
callback: C_FormDialogView_OKCB
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 205 75 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Apply|#A
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_apply
callback: C_FormDialogView_ApplyCB
argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 300 75 90 25
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Cancel|^[
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_SouthEast FL_SouthEast
name: button_close
callback: C_FormDialogView_CancelCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 300 45 50 25
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
style: FL_NORMAL_STYLE
size: FL_DEFAULT_SIZE
lcol: FL_BLACK
label:
shortcut:
resize: FL_RESIZE_NONE
gravity: FL_East FL_East
name: choice_unit_space
callback: C_FormDialogView_InputCB
argument: 0
==============================
create_the_forms

View File

@ -1,4 +1,9 @@
2003-11-28 André Pönitz <poenitz@gmx.net>
* Makefile.am:
* insetvspace.[Ch]: new insets
2003-11-28 Martin Vermeer <martin.vermeer@hut.fi>
* insetcharstyle.C: Syntax change for CharStyles

View File

@ -108,6 +108,8 @@ libinsets_la_SOURCES = \
insettoc.h \
inseturl.C \
inseturl.h \
insetvspace.C \
insetvspace.h \
insetwrap.h \
insetwrap.C \
updatableinset.C \

View File

@ -136,7 +136,9 @@ public:
///
BOX_CODE,
///
CHARSTYLE_CODE
CHARSTYLE_CODE,
///
VSPACE_CODE
};
///

233
src/insets/insetvspace.C Normal file
View File

@ -0,0 +1,233 @@
/**
* \file insetvspace.C
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author various
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#include <config.h>
#include "insetvspace.h"
#include "buffer.h"
#include "debug.h"
#include "LColor.h"
#include "lyxlex.h"
#include "lyxtext.h"
#include "metricsinfo.h"
#include "gettext.h"
#include "frontends/Painter.h"
#include "frontends/font_metrics.h"
#include "support/std_sstream.h"
using std::endl;
using std::istringstream;
using std::ostream;
using std::ostringstream;
using std::string;
using std::max;
InsetVSpace::InsetVSpace(VSpace const & space)
: space_(space)
{}
std::auto_ptr<InsetBase> InsetVSpace::clone() const
{
return std::auto_ptr<InsetBase>(new InsetVSpace(*this));
}
void InsetVSpace::read(Buffer const &, LyXLex & lex)
{
if (lex.isOK()) {
lex.next();
space_ = VSpace(lex.getString());
}
}
void InsetVSpace::write(Buffer const &, ostream & os) const
{
os << "VSpace " << space_.asLyXCommand();
}
void InsetVSpace::metrics(MetricsInfo & mi, Dimension & dim) const
{
int size = 10;
if (space_.kind() != VSpace::NONE) {
int const arrow_size = 4;
int const space_size = space_.inPixels(*mi.base.bv);
LyXFont font;
font.decSize();
int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font));
if (space_.length().len().value() < 0.0)
size = min_size;
else
size = max(min_size, space_size);
}
dim.asc = size / 2;
dim.des = size / 2;
dim.wid = 10;
dim_ = dim;
}
void InsetVSpace::draw(PainterInfo & pi, int x, int y) const
{
static std::string const label = _("Vertical Space");
xo_ = x;
yo_ = y;
//if (space_.kind() == VSpace::NONE)
// return 0;
int const arrow_size = 4;
int const start = y - dim_.asc;
int const end = y + dim_.des;
// the label to display (if any)
string str;
// y-values for top arrow
int ty1, ty2;
// y-values for bottom arrow
int by1, by2;
str = label + " (" + space_.asLyXCommand() + ")";
if (space_.kind() == VSpace::VFILL) {
ty1 = ty2 = start;
by1 = by2 = end;
} else {
// adding or removing space
bool const added = space_.kind() != VSpace::LENGTH ||
space_.length().len().value() > 0.0;
ty1 = added ? (start + arrow_size) : start;
ty2 = added ? start : (start + arrow_size);
by1 = added ? (end - arrow_size) : end;
by2 = added ? end : (end - arrow_size);
}
int const midx = xo_ + arrow_size;
int const rightx = midx + arrow_size;
// first the string
int w = 0;
int a = 0;
int d = 0;
LyXFont font;
font.setColor(LColor::added_space);
font.decSize();
font.decSize();
font_metrics::rectText(str, font, w, a, d);
pi.pain.rectText(x + 2 * arrow_size + 5, y + d,
str, font, LColor::none, LColor::none);
// top arrow
pi.pain.line(x, ty1, midx, ty2, LColor::added_space);
pi.pain.line(midx, ty2, rightx, ty1, LColor::added_space);
// bottom arrow
pi.pain.line(x, by1, midx, by2, LColor::added_space);
pi.pain.line(midx, by2, rightx, by1, LColor::added_space);
// joining line
pi.pain.line(midx, ty2, midx, by2, LColor::added_space);
}
int InsetVSpace::latex(Buffer const & buf, ostream & os,
OutputParams const &) const
{
os << space_.asLatexCommand(buf.params()) << '\n';
return 1;
}
int InsetVSpace::plaintext(Buffer const &, ostream & os,
OutputParams const &) const
{
os << "\n\n";
return 2;
}
int InsetVSpace::linuxdoc(Buffer const &, std::ostream & os,
OutputParams const &) const
{
os << '\n';
return 1;
}
int InsetVSpace::docbook(Buffer const &, std::ostream & os,
OutputParams const &) const
{
os << '\n';
return 1;
}
string const InsetVSpaceMailer::name_ = "vspace";
InsetVSpaceMailer::InsetVSpaceMailer(InsetVSpace & inset)
: inset_(inset)
{}
string const InsetVSpaceMailer::inset2string(Buffer const &) const
{
return params2string(inset_.space_);
}
void InsetVSpaceMailer::string2params(string const & in, VSpace & vspace)
{
//lyxerr << "\nInsetVSpaceMailer::string2params, got: '" << in << "'" << endl;
vspace = VSpace();
if (in.empty())
return;
istringstream data(in);
LyXLex lex(0,0);
lex.setStream(data);
if (lex.isOK()) {
lex.next();
string const name = lex.getString();
}
// This is part of the inset proper that is usually swallowed
// by Buffer::readInset
if (lex.isOK()) {
lex.next();
vspace = VSpace(lex.getString());
}
}
string const InsetVSpaceMailer::params2string(VSpace const & vspace)
{
ostringstream data;
data << name_ << ' ' << vspace.asLyXCommand();
return data.str();
}

78
src/insets/insetvspace.h Normal file
View File

@ -0,0 +1,78 @@
// -*- C++ -*-
/**
* \file insetvspace.h
* This file is part of LyX, the document processor.
* Licence details can be found in the file COPYING.
*
* \author André Pönitz
*
* Full author contact details are available in file CREDITS.
*/
#ifndef INSET_VSPACE_H
#define INSET_VSPACE_H
#include "inset.h"
#include "vspace.h"
#include "mailinset.h"
class InsetVSpace : public InsetOld {
public:
///
InsetVSpace() {}
///
InsetVSpace(VSpace const &);
///
std::auto_ptr<InsetBase> clone() const;
///
void metrics(MetricsInfo & mi, Dimension & dim) const;
///
void draw(PainterInfo & pi, int x, int y) const;
///
int latex(Buffer const &, std::ostream &,
OutputParams const &) const;
///
int plaintext(Buffer const &, std::ostream &,
OutputParams const &) const;
///
int linuxdoc(Buffer const &, std::ostream &,
OutputParams const &) const;
///
int docbook(Buffer const &, std::ostream &,
OutputParams const &) const;
///
void read(Buffer const &, LyXLex & lex);
///
void write(Buffer const & buf, std::ostream & os) const;
///
bool display() const { return true; }
public:
/// how much
VSpace space_;
};
class InsetVSpaceMailer : public MailInset {
public:
///
InsetVSpaceMailer(InsetVSpace & inset);
///
virtual InsetBase & inset() const { return inset_; }
///
virtual std::string const & name() const { return name_; }
///
virtual std::string const inset2string(Buffer const &) const;
///
static void string2params(std::string const &, VSpace &);
///
static std::string const params2string(VSpace const &);
private:
///
static std::string const name_;
///
InsetVSpace & inset_;
};
#endif

View File

@ -332,7 +332,7 @@ enum kb_action {
LFUN_FINISHED_UP,
LFUN_FINISHED_DOWN,
LFUN_INSERT_CHARSTYLE,
// 255
LFUN_LASTACTION // end of the table
};

View File

@ -54,6 +54,7 @@
#include "insets/insetcommand.h"
#include "insets/insetexternal.h"
#include "insets/insettabular.h"
#include "insets/insetvspace.h"
#include "mathed/math_cursor.h"
@ -590,6 +591,8 @@ FuncStatus LyXFunc::getStatus(FuncRequest const & ev) const
code = InsetOld::TOC_CODE;
else if (ev.argument == "url")
code = InsetOld::URL_CODE;
else if (ev.argument == "vspace")
code = InsetOld::VSPACE_CODE;
else if (ev.argument == "wrap")
code = InsetOld::WRAP_CODE;
break;
@ -1235,6 +1238,9 @@ void LyXFunc::dispatch(FuncRequest const & func, bool verbose)
} else if (name == "citation") {
InsetCommandParams p("cite");
data = InsetCommandMailer::params2string(name, p);
} else if (name == "vspace") {
VSpace space;
data = InsetVSpaceMailer::params2string(space);
}
owner->getDialogs().show(name, data, 0);
break;

View File

@ -267,8 +267,6 @@ public:
settings are given to the new one.
*/
void setParagraph(
VSpace const & space_top,
VSpace const & space_bottom,
Spacing const & spacing,
LyXAlignment align,
std::string const & labelwidthstring,

View File

@ -244,11 +244,6 @@ TeXOnePar(Buffer const & buf,
texrow.newline();
}
if (pit->params().spaceTop().kind() != VSpace::NONE) {
os << pit->params().spaceTop().asLatexCommand(bparams);
further_blank_line = true;
}
if (further_blank_line) {
os << '\n';
texrow.newline();
@ -389,11 +384,6 @@ TeXOnePar(Buffer const & buf,
if (in == 0 || !in->forceDefaultParagraphs(in)) {
further_blank_line = false;
if (pit->params().spaceBottom().kind() != VSpace::NONE) {
os << pit->params().spaceBottom().asLatexCommand(bparams);
further_blank_line = true;
}
if (further_blank_line) {
os << '\n';
texrow.newline();

View File

@ -45,6 +45,7 @@
#include "support/tostr.h"
#include <boost/tuple/tuple.hpp>
#include <boost/bind.hpp>
#include <list>
#include <stack>
@ -646,8 +647,6 @@ void Paragraph::applyLayout(LyXLayout_ptr const & new_layout)
layout(new_layout);
params().labelWidthString(string());
params().align(LYX_ALIGN_LAYOUT);
params().spaceTop(VSpace(VSpace::NONE));
params().spaceBottom(VSpace(VSpace::NONE));
params().spacing(Spacing(Spacing::Default));
}
@ -1277,6 +1276,7 @@ void Paragraph::simpleLinuxDocOnePar(Buffer const & buf,
char c = getChar(i);
if (c == Paragraph::META_INSET) {
InsetOld const * inset = getInset(i);
inset->linuxdoc(buf, os, runparams);

View File

@ -132,9 +132,6 @@ void breakParagraph(BufferParams const & bparams,
tmp->params().align(par->params().align());
tmp->setLabelWidthString(par->params().labelWidthString());
tmp->params().spaceBottom(par->params().spaceBottom());
par->params().spaceBottom(VSpace(VSpace::NONE));
tmp->params().depth(par->params().depth());
tmp->params().noindent(par->params().noindent());
@ -167,7 +164,6 @@ void breakParagraph(BufferParams const & bparams,
if (pos)
return;
tmp->params().spaceTop(par->params().spaceTop());
par->params().clear();
par->layout(bparams.getLyXTextClass().defaultLayout());
@ -223,9 +219,6 @@ void mergeParagraph(BufferParams const & bparams,
{
ParagraphList::iterator the_next = boost::next(par);
// first the DTP-stuff
par->params().spaceBottom(the_next->params().spaceBottom());
pos_type pos_end = the_next->size() - 1;
pos_type pos_insert = par->size();

View File

@ -71,7 +71,6 @@ private:
void paintArabicComposeChar(lyx::pos_type & vpos);
void paintChars(lyx::pos_type & vpos, bool hebrew, bool arabic);
int paintAppendixStart(int y);
int paintLengthMarker(string const & prefix, VSpace const & vsp, int start);
void paintText();
void paintFromPos(lyx::pos_type & vpos);
void paintInset(lyx::pos_type const pos);
@ -561,73 +560,6 @@ void RowPainter::paintDepthBar()
}
int RowPainter::paintLengthMarker(string const & prefix, VSpace const & vsp,
int start)
{
if (vsp.kind() == VSpace::NONE)
return 0;
int const arrow_size = 4;
int const size = getLengthMarkerHeight(bv_, vsp);
int const end = start + size;
// the label to display (if any)
string str;
// y-values for top arrow
int ty1, ty2;
// y-values for bottom arrow
int by1, by2;
str = prefix + " (" + vsp.asLyXCommand() + ")";
if (vsp.kind() == VSpace::VFILL) {
ty1 = ty2 = start;
by1 = by2 = end;
} else {
// adding or removing space
bool const added = vsp.kind() != VSpace::LENGTH ||
vsp.length().len().value() > 0.0;
ty1 = added ? (start + arrow_size) : start;
ty2 = added ? start : (start + arrow_size);
by1 = added ? (end - arrow_size) : end;
by2 = added ? end : (end - arrow_size);
}
int const leftx = int(xo_) + leftMargin();
int const midx = leftx + arrow_size;
int const rightx = midx + arrow_size;
// first the string
int w = 0;
int a = 0;
int d = 0;
LyXFont font;
font.setColor(LColor::added_space);
font.decSize();
font.decSize();
font_metrics::rectText(str, font, w, a, d);
pain_.rectText(leftx + 2 * arrow_size + 5,
start + (end - start) / 2 + d,
str, font,
LColor::none, LColor::none);
// top arrow
pain_.line(leftx, ty1, midx, ty2, LColor::added_space);
pain_.line(midx, ty2, rightx, ty1, LColor::added_space);
// bottom arrow
pain_.line(leftx, by1, midx, by2, LColor::added_space);
pain_.line(midx, by2, rightx, by1, LColor::added_space);
// joining line
pain_.line(midx, ty2, midx, by2, LColor::added_space);
return size;
}
int RowPainter::paintAppendixStart(int y)
{
LyXFont pb_font;
@ -662,10 +594,6 @@ void RowPainter::paintFirst()
if (parparams.startOfAppendix())
y_top += paintAppendixStart(yo_ + y_top + 2 * defaultRowHeight());
// draw the additional space if needed:
y_top += paintLengthMarker(_("Space above"), parparams.spaceTop(),
yo_ + y_top);
Buffer const & buffer = *bv_.buffer();
LyXLayout_ptr const & layout = pit_->layout();
@ -782,15 +710,7 @@ void RowPainter::paintFirst()
void RowPainter::paintLast()
{
ParagraphParameters const & parparams = pit_->params();
int y_bottom = row_.height() - 1;
int const ww = bv_.workWidth();
// draw the additional space if needed:
int const height = getLengthMarkerHeight(bv_, parparams.spaceBottom());
y_bottom -= paintLengthMarker(_("Space below"), parparams.spaceBottom(),
yo_ + y_bottom - height);
bool const is_rtl = pit_->isRightToLeftPar(bv_.buffer()->params());
int const endlabel = getEndLabel(pit_, text_.ownerParagraphs());
@ -972,22 +892,3 @@ void paintTextInset(BufferView const & bv, LyXText const & text, int xo, int yo)
{
paintPars(bv, text, text.ownerParagraphs().begin(), xo, yo, 0);
}
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp)
{
if (vsp.kind() == VSpace::NONE)
return 0;
int const arrow_size = 4;
int const space_size = vsp.inPixels(bv);
LyXFont font;
font.decSize();
int const min_size = max(3 * arrow_size, font_metrics::maxHeight(font));
if (vsp.length().len().value() < 0.0)
return min_size;
else
return max(min_size, space_size);
}

View File

@ -15,10 +15,6 @@
class LyXText;
class BufferView;
class VSpace;
/// return the pixel height of a space marker before/after a par
int getLengthMarkerHeight(BufferView const & bv, VSpace const & vsp);
/// paint the rows of the main text, return last drawn y value
int paintText(BufferView const & bv);

View File

@ -657,9 +657,6 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
maxasc += bufparams.getDefSkip().inPixels(*bv());
}
// add user added vertical space
maxasc += getLengthMarkerHeight(*bv(), pit->params().spaceTop());
if (pit->params().startOfAppendix())
maxasc += int(3 * dh);
@ -684,7 +681,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
+ (layout->topsep + layout->labelbottomsep) * dh);
}
// And now the layout spaces, for example before and after
// Add the layout spaces, for example before and after
// a section, or between the items of a itemize or enumerate
// environment.
@ -715,10 +712,7 @@ void LyXText::setHeightOfRow(ParagraphList::iterator pit, Row & row)
// is it a bottom line?
if (row.endpos() >= pit->size()) {
// add the vertical spaces, that the user added
maxdesc += getLengthMarkerHeight(*bv(), pit->params().spaceBottom());
// and now the layout spaces, for example before and after
// add the layout spaces, for example before and after
// a section, or between the items of a itemize or enumerate
// environment
ParagraphList::iterator nextpit = boost::next(pit);
@ -1319,16 +1313,7 @@ void LyXText::backspace()
// handle the actual deletion of the paragraph.
if (cursor.par()) {
ParagraphList::iterator tmppit = getPar(cursor.par() - 1);
if (cursorPar()->layout() == tmppit->layout()
&& cursorPar()->getAlign() == tmppit->getAlign()) {
// Inherit bottom DTD from the paragraph below.
// (the one we are deleting)
tmppit->params().spaceBottom(cursorPar()->params().spaceBottom());
}
cursorLeft(bv());
// the layout things can change the height of a row !
redoParagraph();
return;

View File

@ -310,12 +310,6 @@ LyXText::setLayout(LyXCursor & cur, LyXCursor & sstart_cur,
do {
pit->applyLayout(lyxlayout);
makeFontEntriesLayoutSpecific(bufparams, *pit);
pit->params().spaceTop(lyxlayout->fill_top ?
VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE));
pit->params().spaceBottom(lyxlayout->fill_bottom ?
VSpace(VSpace::VFILL)
: VSpace(VSpace::NONE));
if (lyxlayout->margintype == MARGIN_MANUAL)
pit->setLabelWidthString(lyxlayout->labelstring());
cur.par(std::distance(ownerParagraphs().begin(), pit));
@ -611,8 +605,7 @@ string LyXText::getStringToIndex()
// they do not duplicate themself and you cannot play dirty tricks with
// them!
void LyXText::setParagraph(VSpace const & space_top,
VSpace const & space_bottom,
void LyXText::setParagraph(
Spacing const & spacing,
LyXAlignment align,
string const & labelwidthstring,
@ -643,8 +636,6 @@ void LyXText::setParagraph(VSpace const & space_top,
ParagraphList::iterator const pit = cursorPar();
ParagraphParameters & params = pit->params();
params.spaceTop(space_top);
params.spaceBottom(space_bottom);
params.spacing(spacing);
// does the layout allow the new alignment?

View File

@ -415,7 +415,7 @@ void specialChar(LyXText * lt, BufferView * bv, InsetSpecialChar::Kind kind)
}
void doInsertInset(LyXText * lt, FuncRequest const & cmd,
void doInsertInset(LyXText const & lt, FuncRequest const & cmd,
bool edit, bool pastesel)
{
InsetOld * inset = createInset(cmd);
@ -423,7 +423,7 @@ void doInsertInset(LyXText * lt, FuncRequest const & cmd,
if (inset) {
bool gotsel = false;
if (lt->selection.set()) {
if (lt.selection.set()) {
bv->owner()->dispatch(FuncRequest(LFUN_CUT));
gotsel = true;
}
@ -739,21 +739,9 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (!selection.set()) {
if (cursor.pos() == cursorPar()->size()) {
cursorRight(bv);
ParagraphParameters & params = cursorPar()->params();
if (cursor.pos() == 0
&& !(params.spaceTop() == VSpace (VSpace::NONE))) {
setParagraph(
VSpace(VSpace::NONE),
params.spaceBottom(),
params.spacing(),
params.align(),
params.labelWidthString(), 0);
cursorLeft(bv);
} else {
cursorLeft(bv);
Delete();
selection.cursor = cursor;
}
} else {
Delete();
selection.cursor = cursor;
@ -784,19 +772,9 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_BACKSPACE_SKIP:
// Reverse the effect of LFUN_BREAKPARAGRAPH_SKIP.
if (!selection.set()) {
ParagraphParameters & params = cursorPar()->params();
if (cursor.pos() == 0 && !(params.spaceTop() == VSpace(VSpace::NONE))) {
setParagraph(
VSpace(VSpace::NONE),
params.spaceBottom(),
params.spacing(),
params.align(),
params.labelWidthString(), 0);
} else {
LyXCursor cur = cursor;
backspace();
selection.cursor = cur;
}
} else {
cutSelection(true, false);
}
@ -829,15 +807,11 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
replaceSelection(bv->getLyXText());
if (cur.pos() == 0) {
ParagraphParameters & params = getPar(cur)->params();
if (params.spaceTop() == VSpace(VSpace::NONE)) {
setParagraph(
VSpace(VSpace::DEFSKIP), params.spaceBottom(),
params.spacing(),
params.align(),
params.labelWidthString(), 1);
}
}
else {
} else {
breakParagraph(bv->buffer()->paragraphs(), 0);
}
bv->update();
@ -924,7 +898,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
if (cursorPar()->layout()->free_spacing)
insertChar(' ');
else
doInsertInset(this, cmd, false, false);
doInsertInset(*this, cmd, false, false);
moveCursor(bv, false);
break;
@ -1418,12 +1392,12 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_ENVIRONMENT_INSERT:
// Open the inset, and move the current selection
// inside it.
doInsertInset(this, cmd, true, true);
doInsertInset(*this, cmd, true, true);
break;
case LFUN_INDEX_INSERT:
// Just open the inset
doInsertInset(this, cmd, true, false);
doInsertInset(*this, cmd, true, false);
break;
case LFUN_INDEX_PRINT:
@ -1432,7 +1406,7 @@ DispatchResult LyXText::dispatch(FuncRequest const & cmd)
case LFUN_INSERT_LINE:
case LFUN_INSERT_PAGEBREAK:
// do nothing fancy
doInsertInset(this, cmd, false, false);
doInsertInset(*this, cmd, false, false);
break;
case LFUN_DEPTH_MIN: