John's per-paragraph line spacing patch.

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@2521 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Angus Leeming 2001-08-16 10:14:48 +00:00
parent 352172a0aa
commit 4aca97ca21
12 changed files with 190 additions and 31 deletions

View File

@ -2384,6 +2384,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
cursor.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE),
cursor.par()->params().spaceBottom(),
cursor.par()->params().spacing(),
cursor.par()->params().align(),
cursor.par()->params().labelWidthString(), 0);
lt->cursorLeft(bv_);
@ -2521,6 +2522,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
cursor.par()->params().pagebreakTop(),
cursor.par()->params().pagebreakBottom(),
VSpace(VSpace::NONE), cursor.par()->params().spaceBottom(),
cursor.par()->params().spacing(),
cursor.par()->params().align(),
cursor.par()->params().labelWidthString(), 0);
update(lt,
@ -2591,6 +2593,7 @@ bool BufferView::Pimpl::Dispatch(kb_action action, string const & argument)
cursor.par()->params().pagebreakTop(),
cursor.par()->params().pagebreakBottom(),
VSpace(VSpace::DEFSKIP), cursor.par()->params().spaceBottom(),
cursor.par()->params().spacing(),
cursor.par()->params().align(),
cursor.par()->params().labelWidthString(), 1);
//update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
@ -3337,6 +3340,7 @@ bool BufferView::Pimpl::insertInset(Inset * inset, string const & lout)
bv_->text->setParagraph(bv_, 0, 0,
0, 0,
VSpace(VSpace::NONE), VSpace(VSpace::NONE),
Spacing(),
LYX_ALIGN_LAYOUT,
string(),
0);

View File

@ -2,6 +2,13 @@
* lyxfunc.C (dispatch): implemented the new FINISHED states.
2001-08-16 John Levon <moz@compsoc.man.ac.uk>
* BufferView_pimpl.C:
* figureForm.C:
* lyxtext.h:
* text2.C: setParagraph takes linespacing now
2001-08-14 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Do not generate errors

View File

@ -88,6 +88,7 @@ void FigureApplyCB(FL_OBJECT *, long)
VSpace (0.3 *
buffer->params.spacing.getValue(),
LyXLength::CM),
Spacing(),
LYX_ALIGN_CENTER, string(), 0);
current_view->update(current_view->text, BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);

View File

@ -5,6 +5,16 @@
* form_math_matrix.C:
* forms/form_math_matrix.fd: new layout
2001-08-16 John Levon <moz@compsoc.man.ac.uk>
* form_paragraph.h:
* form_paragraph.C:
* forms/form_paragraph.fd:
* FormParagraph.C: support per-para linespacing
* forms/form_float.fd:
* form_float.C: fix shortcut typo
2001-08-15 Angus Leeming <a.leeming@ic.ac.uk>
* forms/form_character.fd: small adjustment to the position of John's

View File

@ -20,13 +20,16 @@
#include "FormParagraph.h"
#include "form_paragraph.h"
#include "Dialogs.h"
#include "support/lstrings.h"
#include "Liason.h"
#include "LyXView.h"
#include "buffer.h"
#include "lyxtext.h"
#include "xforms_helpers.h"
#include "BufferView.h"
#include "Spacing.h"
#include "ParagraphParameters.h"
#include "input_validators.h"
using Liason::setMinibuffer;
using SigC::slot;
@ -123,6 +126,9 @@ void FormParagraph::build()
_(" None | Defskip | Smallskip "
"| Medskip | Bigskip | VFill | Length "));
fl_addto_choice(general_->choice_linespacing,
_(" Single | OneHalf | Double | Other "));
fl_set_input_return(general_->input_space_above, FL_RETURN_CHANGED);
fl_set_input_return(general_->input_space_below, FL_RETURN_CHANGED);
fl_set_input_return(general_->input_labelwidth, FL_RETURN_CHANGED);
@ -142,9 +148,13 @@ void FormParagraph::build()
bc_.addReadOnly (general_->choice_space_below);
bc_.addReadOnly (general_->input_space_below);
bc_.addReadOnly (general_->check_space_below);
bc_.addReadOnly (general_->choice_linespacing);
bc_.addReadOnly (general_->input_linespacing);
bc_.addReadOnly (general_->check_noindent);
bc_.addReadOnly (general_->input_labelwidth);
fl_set_input_filter(general_->input_linespacing, fl_unsigned_float_filter);
// now make them fit together
fl_addto_tabfolder(dialog_->tabbed_folder,_("General"), general_->form);
}
@ -182,6 +192,8 @@ void FormParagraph::general_apply()
LyXAlignment align;
string labelwidthstring;
bool noindent;
Spacing::Space linespacing;
string other_linespacing;
// If a vspace kind is "Length" but there's no text in
// the input field, reset the kind to "None".
@ -265,15 +277,25 @@ void FormParagraph::general_apply()
labelwidthstring = fl_get_input(general_->input_labelwidth);
noindent = fl_get_button(general_->check_noindent);
switch (fl_get_choice(general_->choice_linespacing)) {
case 1: linespacing = Spacing::Single; break;
case 2: linespacing = Spacing::Onehalf; break;
case 3: linespacing = Spacing::Double; break;
case 4:
linespacing = Spacing::Other;
other_linespacing = fl_get_input(general_->input_linespacing);
break;
}
Spacing const spacing(linespacing, other_linespacing);
LyXText * text = 0;
if (lv_->view()->theLockingInset())
text = lv_->view()->theLockingInset()->getLyXText(lv_->view());
if (!text)
text = lv_->view()->text;
text->setParagraph(lv_->view(), line_top, line_bottom, pagebreak_top,
pagebreak_bottom, space_top, space_bottom, align,
labelwidthstring, noindent);
pagebreak_bottom, space_top, space_bottom, spacing,
align, labelwidthstring, noindent);
}
@ -334,6 +356,40 @@ void FormParagraph::general_update()
fl_set_button(general_->check_noindent,
par_->params().noindent());
int linespacing;
Spacing space = par_->params().spacing();
switch (lv_->buffer()->params.spacing.getSpace()) {
case Spacing::Single: linespacing = 1; break;
case Spacing::Onehalf: linespacing = 2; break;
case Spacing::Double: linespacing = 3; break;
case Spacing::Other: linespacing = 4; break;
}
switch (space.getSpace()) {
case Spacing::Single: linespacing = 1; break;
case Spacing::Onehalf: linespacing = 2; break;
case Spacing::Double: linespacing = 3; break;
case Spacing::Other: linespacing = 4; break;
case Spacing::Default:
space = lv_->buffer()->params.spacing;
break;
}
fl_set_choice(general_->choice_linespacing, linespacing);
if (space.getSpace() == Spacing::Other) {
string sp;
if (space.getSpace() == Spacing::Default)
sp = tostr(lv_->buffer()->params.spacing.getValue());
else
sp = tostr(space.getValue());
fl_set_input(general_->input_linespacing, sp.c_str());
setEnabled(general_->input_linespacing, true);
} else {
fl_set_input(general_->input_linespacing, "");
setEnabled(general_->input_linespacing, false);
}
fl_set_input (general_->input_space_above, "");
switch (par_->params().spaceTop().kind()) {
@ -418,6 +474,13 @@ bool FormParagraph::input(FL_OBJECT * ob, long)
if (fl_get_choice (general_->choice_space_below) != 7)
fl_set_input (general_->input_space_below, "");
if (fl_get_choice (general_->choice_linespacing) == 4)
setEnabled (general_->input_linespacing, true);
else {
setEnabled (general_->input_linespacing, false);
fl_set_input (general_->input_linespacing, "");
}
//
// first the general form
//

View File

@ -74,7 +74,11 @@ FD_form_float * FormFloat::build_float()
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseRestoreCB, 0);
fdui->radio_here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 60, 152, 30, _("Here, if possible#i"));
{
char const * const dummy = N_("Here, if possible|#i");
fdui->radio_here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 60, 152, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseInputCB, 0);
{

View File

@ -22,12 +22,12 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general()
FL_OBJECT *obj;
FD_form_paragraph_general *fdui = new FD_form_paragraph_general;
fdui->form = fl_bgn_form(FL_NO_BOX, 490, 250);
fdui->form = fl_bgn_form(FL_NO_BOX, 490, 335);
fdui->form->u_vdata = this;
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 490, 250, "");
obj = fl_add_frame(FL_ENGRAVED_FRAME, 360, 110, 120, 50, "");
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 490, 335, "");
obj = fl_add_frame(FL_ENGRAVED_FRAME, 360, 260, 120, 40, "");
fl_set_object_color(obj, FL_COL1, FL_COL1);
obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 110, 340, 90, "");
obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 110, 470, 120, "");
fl_set_object_color(obj, FL_COL1, FL_COL1);
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
obj = fl_add_frame(FL_ENGRAVED_FRAME, 360, 20, 120, 70, "");
@ -38,14 +38,14 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general()
fl_set_object_color(obj, FL_COL1, FL_COL1);
{
char const * const dummy = N_("Label Width:|#d");
fdui->input_labelwidth = obj = fl_add_input(FL_NORMAL_INPUT, 100, 210, 360, 30, idex(_(dummy)));
fdui->input_labelwidth = obj = fl_add_input(FL_NORMAL_INPUT, 100, 265, 250, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_gravity(obj, FL_West, FL_East);
fl_set_object_resize(obj, FL_RESIZE_X);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
obj = fl_add_text(FL_NORMAL_TEXT, 370, 100, 60, 20, _("Indent"));
obj = fl_add_text(FL_NORMAL_TEXT, 370, 250, 60, 20, _("Indent"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
@ -79,7 +79,7 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general()
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
{
char const * const dummy = N_("No Indent|#I");
fdui->check_noindent = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 360, 120, 120, 30, idex(_(dummy)));
fdui->check_noindent = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 360, 265, 120, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
@ -116,15 +116,15 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general()
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
fl_end_group();
fdui->input_space_above = obj = fl_add_input(FL_NORMAL_INPUT, 180, 120, 90, 30, "");
fdui->input_space_above = obj = fl_add_input(FL_NORMAL_INPUT, 180, 135, 90, 30, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
fdui->input_space_below = obj = fl_add_input(FL_NORMAL_INPUT, 180, 160, 90, 30, "");
fdui->input_space_below = obj = fl_add_input(FL_NORMAL_INPUT, 180, 185, 90, 30, "");
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
{
char const * const dummy = N_("Above:|#v");
fdui->choice_space_above = obj = fl_add_choice(FL_NORMAL_CHOICE, 70, 120, 100, 30, idex(_(dummy)));
fdui->choice_space_above = obj = fl_add_choice(FL_NORMAL_CHOICE, 70, 135, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_boxtype(obj, FL_FRAME_BOX);
@ -132,7 +132,7 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general()
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
{
char const * const dummy = N_("Below:|#w");
fdui->choice_space_below = obj = fl_add_choice(FL_NORMAL_CHOICE, 70, 160, 100, 30, idex(_(dummy)));
fdui->choice_space_below = obj = fl_add_choice(FL_NORMAL_CHOICE, 70, 185, 100, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_boxtype(obj, FL_FRAME_BOX);
@ -156,18 +156,27 @@ FD_form_paragraph_general * FormParagraph::build_paragraph_general()
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
{
char const * const dummy = N_("Keep|#K");
fdui->check_space_above = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 270, 120, 40, 30, idex(_(dummy)));
fdui->check_space_above = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 270, 135, 40, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
{
char const * const dummy = N_("Keep|#p");
fdui->check_space_below = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 270, 160, 40, 30, idex(_(dummy)));
fdui->check_space_below = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 270, 185, 40, 30, idex(_(dummy)));
fl_set_button_shortcut(obj, scex(_(dummy)), 1);
}
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
fdui->choice_linespacing = obj = fl_add_choice(FL_NORMAL_CHOICE, 355, 150, 115, 30, "");
fl_set_object_boxtype(obj, FL_FRAME_BOX);
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
obj = fl_add_text(FL_NORMAL_TEXT, 350, 125, 100, 20, _("Line Spacing"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
fdui->input_linespacing = obj = fl_add_input(FL_NORMAL_INPUT, 355, 190, 115, 30, "");
fl_set_object_callback(obj, C_FormBaseDeprecatedInputCB, 0);
fl_end_form();
fdui->form->fdui = fdui;

View File

@ -37,6 +37,8 @@ struct FD_form_paragraph_general {
FL_OBJECT *choice_space_below;
FL_OBJECT *check_space_above;
FL_OBJECT *check_space_below;
FL_OBJECT *choice_linespacing;
FL_OBJECT *input_linespacing;
};
struct FD_form_paragraph_extra {
~FD_form_paragraph_extra();

View File

@ -202,7 +202,7 @@ alignment: FL_ALIGN_CENTER
style: FL_NORMAL_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Here, if possible#i
label: Here, if possible|#i
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity

View File

@ -5,17 +5,18 @@ Internal Form Definition File
Number of forms: 3
Unit of measure: FL_COORD_PIXEL
SnapGrid: 5
=============== FORM ===============
Name: form_paragraph_general
Width: 490
Height: 250
Number of Objects: 29
Height: 335
Number of Objects: 32
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 490 250
box: 0 0 490 335
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -33,7 +34,7 @@ argument:
--------------------
class: FL_FRAME
type: ENGRAVED_FRAME
box: 360 110 120 50
box: 360 260 120 40
boxtype: FL_NO_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -51,7 +52,7 @@ argument:
--------------------
class: FL_FRAME
type: ENGRAVED_FRAME
box: 10 110 340 90
box: 10 110 470 120
boxtype: FL_NO_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -123,7 +124,7 @@ argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 100 210 360 30
box: 100 265 250 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -141,7 +142,7 @@ argument: 0
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 370 100 60 20
box: 370 250 60 20
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
@ -231,7 +232,7 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 360 120 120 30
box: 360 265 120 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -357,7 +358,7 @@ argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 180 120 90 30
box: 180 135 90 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -375,7 +376,7 @@ argument: 0
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 180 160 90 30
box: 180 185 90 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT
@ -393,7 +394,7 @@ argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 70 120 100 30
box: 70 135 100 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
@ -411,7 +412,7 @@ argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 70 160 100 30
box: 70 185 100 30
boxtype: FL_FRAME_BOX
colors: FL_COL1 FL_BLACK
alignment: FL_ALIGN_LEFT
@ -501,7 +502,7 @@ argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 270 120 40 30
box: 270 135 40 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -519,7 +520,7 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 270 160 40 30
box: 270 185 40 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -534,6 +535,60 @@ name: check_space_below
callback: C_FormBaseDeprecatedInputCB
argument: 0
--------------------
class: FL_CHOICE
type: NORMAL_CHOICE
box: 355 150 115 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_linespacing
callback: C_FormBaseDeprecatedInputCB
argument: 0
--------------------
class: FL_TEXT
type: NORMAL_TEXT
box: 350 125 100 20
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_MCOL
alignment: FL_ALIGN_LEFT|FL_ALIGN_INSIDE
style: FL_BOLD_STYLE
size: FL_NORMAL_SIZE
lcol: FL_BLACK
label: Line Spacing
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name:
callback:
argument:
--------------------
class: FL_INPUT
type: NORMAL_INPUT
box: 355 190 115 30
boxtype: FL_DOWN_BOX
colors: FL_COL1 FL_MCOL
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: input_linespacing
callback: C_FormBaseDeprecatedInputCB
argument: 0
=============== FORM ===============
Name: form_paragraph_extra
Width: 490

View File

@ -22,6 +22,7 @@
#include "layout.h"
#include "lyxrow.h"
#include "vspace.h"
#include "Spacing.h"
#include "LColor.h"
class Buffer;
@ -418,6 +419,7 @@ public:
bool pagebreak_top, bool pagebreak_bottom,
VSpace const & space_top,
VSpace const & space_bottom,
Spacing const & spacing,
LyXAlignment align,
string labelwidthstring,
bool noindent);

View File

@ -1189,6 +1189,7 @@ void LyXText::setParagraph(BufferView * bview,
bool pagebreak_top, bool pagebreak_bottom,
VSpace const & space_top,
VSpace const & space_bottom,
Spacing const & spacing,
LyXAlignment align,
string labelwidthstring,
bool noindent)
@ -1229,6 +1230,7 @@ void LyXText::setParagraph(BufferView * bview,
cursor.par()->params().pagebreakBottom(pagebreak_bottom);
cursor.par()->params().spaceTop(space_top);
cursor.par()->params().spaceBottom(space_bottom);
cursor.par()->params().spacing(spacing);
// does the layout allow the new alignment?
if (align == LYX_ALIGN_LAYOUT)
align = textclasslist