J�rgen Spitzm�ller's changes to the document dialog.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2914 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-10-23 09:00:12 +00:00
parent 6becea79f3
commit 13fbbbdc44
5 changed files with 113 additions and 42 deletions

View File

@ -1,3 +1,13 @@
2001-10-19 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* forms/form_document.fd:
Class: add a value choice for Default Skip.
Some rearrangements (minor tweaks).
* FormDocument.C: Handle that choice, minor tweaks.
* forms/form_paragraph.fd: Add value choices
* FormParagraph.C: Handle that choices.
* FormMinipage.C/FormGraphics.C: Small tweaks.
2001-10-15 Angus Leeming <a.leeming@ic.ac.uk> 2001-10-15 Angus Leeming <a.leeming@ic.ac.uk>
* FormDocument.C: fixed some bugs in the Paper tab. * FormDocument.C: fixed some bugs in the Paper tab.

View File

@ -203,10 +203,16 @@ void FormDocument::build()
"default|empty|plain|headings|fancy"); "default|empty|plain|headings|fancy");
fl_addto_choice(class_->choice_doc_skip, fl_addto_choice(class_->choice_doc_skip,
_(" Smallskip | Medskip | Bigskip | Length ")); _(" Smallskip | Medskip | Bigskip | Length "));
fl_addto_choice(class_->choice_default_skip_units, units.c_str());
fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED); fl_set_input_return(class_->input_doc_extra, FL_RETURN_CHANGED);
fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED); fl_set_input_return(class_->input_doc_skip, FL_RETURN_CHANGED);
fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED); fl_set_input_return(class_->input_doc_spacing, FL_RETURN_CHANGED);
// Set input filters on doc skip to make it accept only
// unsigned numbers.
fl_set_input_filter(class_->input_doc_skip,
fl_unsigned_float_filter);
bc().addReadOnly (class_->radio_doc_indent); bc().addReadOnly (class_->radio_doc_indent);
bc().addReadOnly (class_->radio_doc_skip); bc().addReadOnly (class_->radio_doc_skip);
@ -399,6 +405,31 @@ bool FormDocument::input( FL_OBJECT * ob, long data )
break; break;
} }
bool const length_input = fl_get_choice(class_->choice_doc_skip) == 4;
if (ob == class_->choice_doc_skip) {
setEnabled(class_->input_doc_skip, length_input);
setEnabled(class_->choice_default_skip_units, length_input);
}
if (ob == class_->choice_doc_spacing)
setEnabled(class_->input_doc_spacing,
fl_get_choice(class_->choice_doc_spacing) == 4);
bool const skip_used = fl_get_button(class_->radio_doc_skip);
if (ob == class_->radio_doc_skip ||
ob == class_->radio_doc_indent) {
setEnabled(class_->choice_doc_skip, skip_used);
setEnabled(class_->input_doc_skip, skip_used);
setEnabled(class_->choice_default_skip_units, skip_used);
// Default unit choice is cm if metric, inches if US paper.
int const paperchoice = fl_get_choice(paper_->choice_papersize);
bool const metric = paperchoice < 3 || paperchoice > 5;
int const default_unit = metric ? 8 : 9;
if (strip(fl_get_input(class_->input_doc_skip)).empty())
fl_set_choice(class_->choice_default_skip_units,
default_unit);
}
if (ob == options_->check_use_natbib) { if (ob == options_->check_use_natbib) {
setEnabled(options_->choice_citation_format, setEnabled(options_->choice_citation_format,
fl_get_button(options_->check_use_natbib)); fl_get_button(options_->check_use_natbib));
@ -644,11 +675,16 @@ bool FormDocument::class_apply()
params.setDefSkip(VSpace(VSpace::BIGSKIP)); params.setDefSkip(VSpace(VSpace::BIGSKIP));
break; break;
case 4: case 4:
params.setDefSkip {
(VSpace(LyXGlueLength(fl_get_input(class_->input_doc_skip)))); string const length =
getLengthFromWidgets(class_->input_doc_skip,
class_->choice_default_skip_units);
params.setDefSkip(VSpace(LyXGlueLength(length)));
break; break;
// DocumentDefskipCB assures that this never happens }
default: default:
// DocumentDefskipCB assures that this never happens
params.setDefSkip(VSpace(VSpace::MEDSKIP)); params.setDefSkip(VSpace(VSpace::MEDSKIP));
break; break;
} }
@ -869,6 +905,11 @@ void FormDocument::class_update(BufferParams const & params)
fl_set_button(class_->radio_doc_indent, 1); fl_set_button(class_->radio_doc_indent, 1);
else else
fl_set_button(class_->radio_doc_skip, 1); fl_set_button(class_->radio_doc_skip, 1);
bool const input_length = fl_get_choice(class_->choice_doc_skip) == 4;
setEnabled(class_->choice_default_skip_units, input_length);
setEnabled(class_->input_doc_skip, input_length);
switch (params.getDefSkip().kind()) { switch (params.getDefSkip().kind()) {
case VSpace::SMALLSKIP: case VSpace::SMALLSKIP:
fl_set_choice (class_->choice_doc_skip, 1); fl_set_choice (class_->choice_doc_skip, 1);
@ -879,17 +920,26 @@ void FormDocument::class_update(BufferParams const & params)
case VSpace::BIGSKIP: case VSpace::BIGSKIP:
fl_set_choice (class_->choice_doc_skip, 3); fl_set_choice (class_->choice_doc_skip, 3);
break; break;
case VSpace::LENGTH: case VSpace::LENGTH:
fl_set_choice (class_->choice_doc_skip, 4); {
fl_set_input (class_->input_doc_skip, int const paperchoice = params.papersize2 + 1;
params.getDefSkip().asLyXCommand().c_str()); bool const metric = paperchoice < 3 || paperchoice > 5;
string const default_unit = metric ? "cm" : "in";
string const length = params.getDefSkip().asLyXCommand();
updateWidgetsFromLengthString(class_->input_doc_skip,
class_->choice_default_skip_units,
length, default_unit);
break; break;
}
default: default:
fl_set_choice (class_->choice_doc_skip, 2); fl_set_choice (class_->choice_doc_skip, 2);
break; break;
} }
fl_set_button(class_->radio_doc_sides_one, 0); fl_set_button(class_->radio_doc_sides_one, 0);
fl_set_button(class_->radio_doc_sides_two, 0); fl_set_button(class_->radio_doc_sides_two, 0);
setEnabled(class_->choice_doc_skip,
fl_get_button(class_->radio_doc_skip));
if (params.sides == LyXTextClass::TwoSides) if (params.sides == LyXTextClass::TwoSides)
fl_set_button(class_->radio_doc_sides_two, 1); fl_set_button(class_->radio_doc_sides_two, 1);
else else
@ -901,6 +951,9 @@ void FormDocument::class_update(BufferParams const & params)
else else
fl_set_button(class_->radio_doc_columns_one, 1); fl_set_button(class_->radio_doc_columns_one, 1);
fl_set_input(class_->input_doc_spacing, ""); fl_set_input(class_->input_doc_spacing, "");
setEnabled(class_->input_doc_spacing, input_length);
switch (params.spacing.getSpace()) { switch (params.spacing.getSpace()) {
case Spacing::Default: // nothing bad should happen with this case Spacing::Default: // nothing bad should happen with this
case Spacing::Single: case Spacing::Single:
@ -1097,7 +1150,7 @@ void FormDocument::checkReadOnly()
} }
bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long) bool FormDocument::CheckDocumentInput(FL_OBJECT *, long)
{ {
string str; string str;
bool ok = true; bool ok = true;
@ -1106,20 +1159,6 @@ bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
// "Synchronize" the choice and the input field, so that it // "Synchronize" the choice and the input field, so that it
// is impossible to commit senseless data. // is impossible to commit senseless data.
input = fl_get_input (class_->input_doc_skip); input = fl_get_input (class_->input_doc_skip);
if (ob == class_->input_doc_skip) {
if (!*input) {
fl_set_choice (class_->choice_doc_skip, 2);
} else if (isValidGlueLength (input)) {
fl_set_choice (class_->choice_doc_skip, 4);
} else {
fl_set_choice(class_->choice_doc_skip, 4);
ok = false;
}
} else {
if (*input && !isValidGlueLength(input))
ok = false;
}
if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input) if ((fl_get_choice(class_->choice_doc_skip) == 4) && !*input)
ok = false; ok = false;
else if (fl_get_choice(class_->choice_doc_skip) != 4) else if (fl_get_choice(class_->choice_doc_skip) != 4)
@ -1128,7 +1167,7 @@ bool FormDocument::CheckDocumentInput(FL_OBJECT * ob, long)
input = fl_get_input(class_->input_doc_spacing); input = fl_get_input(class_->input_doc_spacing);
if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input) if ((fl_get_choice(class_->choice_doc_spacing) == 4) && !*input)
ok = false; ok = false;
else if (fl_get_choice(class_->choice_doc_spacing) != 4) else if (fl_get_choice(class_->choice_doc_spacing) != 4)
fl_set_input (class_->input_doc_spacing, ""); fl_set_input (class_->input_doc_spacing, "");
return ok; return ok;
} }

View File

@ -250,13 +250,13 @@ FD_form_doc_class * FormDocument::build_doc_class()
fdui->form = fl_bgn_form(FL_NO_BOX, 440, 345); fdui->form = fl_bgn_form(FL_NO_BOX, 440, 345);
fdui->form->u_vdata = this; fdui->form->u_vdata = this;
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 440, 345, ""); obj = fl_add_box(FL_FLAT_BOX, 0, 0, 440, 345, "");
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 200, 120, 80, _("Separation")); obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 20, 245, 400, 85, _("Separation"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE); fl_set_object_lstyle(obj, FL_BOLD_STYLE);
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 110, 120, 70, _("Page cols")); obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 110, 115, 80, _("Page cols"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE); fl_set_object_lstyle(obj, FL_BOLD_STYLE);
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 20, 120, 70, _("Sides")); obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 300, 20, 120, 75, _("Sides"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE); fl_set_object_lstyle(obj, FL_BOLD_STYLE);
{ {
@ -293,7 +293,7 @@ FD_form_doc_class * FormDocument::build_doc_class()
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT); fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT);
{ {
char const * const dummy = N_("Spacing|#g"); char const * const dummy = N_("Spacing|#g");
fdui->choice_doc_spacing = obj = fl_add_choice(FL_NORMAL_CHOICE, 120, 240, 90, 30, idex(_(dummy))); fdui->choice_doc_spacing = obj = fl_add_choice(FL_NORMAL_CHOICE, 120, 200, 160, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_boxtype(obj, FL_FRAME_BOX); fl_set_object_boxtype(obj, FL_FRAME_BOX);
@ -306,12 +306,12 @@ FD_form_doc_class * FormDocument::build_doc_class()
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT); fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT);
fdui->input_doc_skip = obj = fl_add_input(FL_NORMAL_INPUT, 220, 200, 60, 30, ""); fdui->input_doc_skip = obj = fl_add_input(FL_NORMAL_INPUT, 285, 290, 60, 30, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT); fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT);
{ {
char const * const dummy = N_("Default Skip:|#u"); char const * const dummy = N_("Default Skip:|#u");
fdui->choice_doc_skip = obj = fl_add_choice(FL_NORMAL_CHOICE, 120, 200, 90, 30, idex(_(dummy))); fdui->choice_doc_skip = obj = fl_add_choice(FL_NORMAL_CHOICE, 285, 255, 125, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_boxtype(obj, FL_FRAME_BOX); fl_set_object_boxtype(obj, FL_FRAME_BOX);
@ -357,14 +357,14 @@ FD_form_doc_class * FormDocument::build_doc_class()
fdui->group_doc_sep = fl_bgn_group(); fdui->group_doc_sep = fl_bgn_group();
{ {
char const * const dummy = N_("Indent|#I"); char const * const dummy = N_("Indent|#I");
fdui->radio_doc_indent = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 300, 210, 110, 30, idex(_(dummy))); fdui->radio_doc_indent = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 50, 260, 110, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT); fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT);
{ {
char const * const dummy = N_("Skip|#K"); char const * const dummy = N_("Skip|#K");
fdui->radio_doc_skip = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 300, 240, 110, 30, idex(_(dummy))); fdui->radio_doc_skip = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 50, 290, 110, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1); fl_set_button_shortcut(obj, scex(_(dummy)), 1);
} }
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@ -372,9 +372,12 @@ FD_form_doc_class * FormDocument::build_doc_class()
fl_set_button(obj, 1); fl_set_button(obj, 1);
fl_end_group(); fl_end_group();
fdui->input_doc_spacing = obj = fl_add_input(FL_NORMAL_INPUT, 220, 240, 60, 30, ""); fdui->input_doc_spacing = obj = fl_add_input(FL_NORMAL_INPUT, 300, 200, 115, 30, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT); fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, INPUT);
fdui->choice_default_skip_units = obj = fl_add_choice(FL_NORMAL_CHOICE, 350, 290, 60, 30, "");
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
fl_end_form(); fl_end_form();
fdui->form->fdui = fdui; fdui->form->fdui = fdui;

View File

@ -87,6 +87,7 @@ struct FD_form_doc_class {
FL_OBJECT *radio_doc_indent; FL_OBJECT *radio_doc_indent;
FL_OBJECT *radio_doc_skip; FL_OBJECT *radio_doc_skip;
FL_OBJECT *input_doc_spacing; FL_OBJECT *input_doc_spacing;
FL_OBJECT *choice_default_skip_units;
}; };
struct FD_form_doc_language { struct FD_form_doc_language {
~FD_form_doc_language(); ~FD_form_doc_language();

View File

@ -707,7 +707,7 @@ argument: 0
Name: form_doc_class Name: form_doc_class
Width: 440 Width: 440
Height: 345 Height: 345
Number of Objects: 25 Number of Objects: 26
-------------------- --------------------
class: FL_BOX class: FL_BOX
@ -730,7 +730,7 @@ argument:
-------------------- --------------------
class: FL_LABELFRAME class: FL_LABELFRAME
type: ENGRAVED_FRAME type: ENGRAVED_FRAME
box: 300 200 120 80 box: 20 245 400 85
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1 colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT alignment: FL_ALIGN_TOP_LEFT
@ -748,7 +748,7 @@ argument:
-------------------- --------------------
class: FL_LABELFRAME class: FL_LABELFRAME
type: ENGRAVED_FRAME type: ENGRAVED_FRAME
box: 300 110 120 70 box: 300 110 115 80
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1 colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT alignment: FL_ALIGN_TOP_LEFT
@ -766,7 +766,7 @@ argument:
-------------------- --------------------
class: FL_LABELFRAME class: FL_LABELFRAME
type: ENGRAVED_FRAME type: ENGRAVED_FRAME
box: 300 20 120 70 box: 300 20 120 75
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1 colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT alignment: FL_ALIGN_TOP_LEFT
@ -856,7 +856,7 @@ argument: INPUT
-------------------- --------------------
class: FL_CHOICE class: FL_CHOICE
type: NORMAL_CHOICE type: NORMAL_CHOICE
box: 120 240 90 30 box: 120 200 160 30
boxtype: FL_FRAME_BOX boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT alignment: FL_ALIGN_LEFT
@ -892,7 +892,7 @@ argument: INPUT
-------------------- --------------------
class: FL_INPUT class: FL_INPUT
type: NORMAL_INPUT type: NORMAL_INPUT
box: 220 200 60 30 box: 285 290 60 30
boxtype: FL_DOWN_BOX boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT alignment: FL_ALIGN_LEFT
@ -910,7 +910,7 @@ argument: INPUT
-------------------- --------------------
class: FL_CHOICE class: FL_CHOICE
type: NORMAL_CHOICE type: NORMAL_CHOICE
box: 120 200 90 30 box: 285 255 125 30
boxtype: FL_FRAME_BOX boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT alignment: FL_ALIGN_LEFT
@ -1090,7 +1090,7 @@ argument:
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: RADIO_BUTTON type: RADIO_BUTTON
box: 300 210 110 30 box: 50 260 110 30
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1108,7 +1108,7 @@ argument: INPUT
-------------------- --------------------
class: FL_CHECKBUTTON class: FL_CHECKBUTTON
type: RADIO_BUTTON type: RADIO_BUTTON
box: 300 240 110 30 box: 50 290 110 30
boxtype: FL_NO_BOX boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER alignment: FL_ALIGN_CENTER
@ -1145,7 +1145,7 @@ argument:
-------------------- --------------------
class: FL_INPUT class: FL_INPUT
type: NORMAL_INPUT type: NORMAL_INPUT
box: 220 240 60 30 box: 300 200 115 30
boxtype: FL_DOWN_BOX boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT alignment: FL_ALIGN_LEFT
@ -1160,6 +1160,24 @@ name: input_doc_spacing
callback: C_FormBaseDeprecatedInputCB callback: C_FormBaseDeprecatedInputCB
argument: INPUT argument: INPUT
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 350 290 60 30
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_ALL
gravity: FL_NoGravity FL_NoGravity
name: choice_default_skip_units
callback: C_FormBaseDeprecatedInputCB
argument: 0
=============== FORM =============== =============== FORM ===============
Name: form_doc_language Name: form_doc_language
Width: 440 Width: 440