fix bug 394

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH-1_2_X@5023 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Jean-Marc Lasgouttes 2002-08-19 10:44:19 +00:00
parent d1d4e77239
commit ed93c2a313
11 changed files with 126 additions and 55 deletions

View File

@ -1,3 +1,11 @@
2002-07-30 Dekel Tsur <dekelts@tau.ac.il>
* buffer.C (parseSingleLyXformat2Token): Use default placement
when reading old floats.
* FloatList.C (FloatList): Change the default placement of figure
and tables to "tbp".
2002-07-26 John Levon <levon@movementarian.org>
* WorkArea.C (work_area_handler): set y_old and x_old to some

View File

@ -30,12 +30,12 @@ FloatList::FloatList()
// (these will later be read from a layout file)
// table
Floating table("table", "htbp", "lot", "", "plain", N_("Table"),
Floating table("table", "tbp", "lot", "", "plain", N_("Table"),
N_("List of Tables"), true);
newFloat(table);
// figure
Floating figure("figure", "htbp", "lof",
Floating figure("figure", "tbp", "lof",
"", "plain", N_("Figure"),
N_("List of Figures"), true);
newFloat(figure);

View File

@ -665,34 +665,29 @@ Buffer::parseSingleLyXformat2Token(LyXLex & lex, Paragraph *& par,
old_float << "collapsed true\n";
} else if (tmptok == "fig") {
inset = new InsetFloat(params, "figure");
old_float << "placement htbp\n"
<< "wide false\n"
old_float << "wide false\n"
<< "collapsed false\n";
} else if (tmptok == "tab") {
inset = new InsetFloat(params, "table");
old_float << "placement htbp\n"
<< "wide false\n"
old_float<< "wide false\n"
<< "collapsed false\n";
} else if (tmptok == "alg") {
inset = new InsetFloat(params, "algorithm");
old_float << "placement htbp\n"
<< "wide false\n"
old_float << "wide false\n"
<< "collapsed false\n";
} else if (tmptok == "wide-fig") {
inset = new InsetFloat(params, "figure");
//InsetFloat * tmp = new InsetFloat("figure");
//tmp->wide(true);
//inset = tmp;
old_float << "placement htbp\n"
<< "wide true\n"
old_float << "wide true\n"
<< "collapsed false\n";
} else if (tmptok == "wide-tab") {
inset = new InsetFloat(params, "table");
//InsetFloat * tmp = new InsetFloat("table");
//tmp->wide(true);
//inset = tmp;
old_float << "placement htbp\n"
<< "wide true\n"
old_float << "wide true\n"
<< "collapsed false\n";
}

View File

@ -1,3 +1,8 @@
2002-06-27 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* forms/form_float.fd
* FormFloat.C: Add checkbox to set default float settings (fix #394).
2002-08-16 Michael Schmitt <Michael.Schmitt@teststep.org>
* FormRef.C (update): fix bug in the cross reference dialog which
@ -21,7 +26,7 @@
2002-06-27 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* FormInclude.C: Comment out unneeded and wrong update mechanism
* FormInclude.C: Comment out unneeded and wrong update mechanism
(related to bug #459)
* forms/form_include.fd: define missing callbacks (bug #459)

View File

@ -27,7 +27,6 @@ FormFloat::FormFloat(ControlFloat & c)
// FIX: Needs to be implemented. (Lgb)
// A way to set to float default is missing.
// A way to set "force[!]" is missing.
void FormFloat::build()
@ -40,6 +39,7 @@ void FormFloat::build()
bc().setCancel(dialog_->button_close);
bc().setRestore(dialog_->button_restore);
bc().addReadOnly(dialog_->check_default);
bc().addReadOnly(dialog_->check_top);
bc().addReadOnly(dialog_->check_bottom);
bc().addReadOnly(dialog_->check_page);
@ -54,6 +54,9 @@ void FormFloat::apply()
if (fl_get_button(dialog_->check_here_definitely)) {
placement += "H";
} else {
if (fl_get_button(dialog_->check_here)) {
placement += "h";
}
if (fl_get_button(dialog_->check_top)) {
placement += "t";
}
@ -63,9 +66,6 @@ void FormFloat::apply()
if (fl_get_button(dialog_->check_page)) {
placement += "p";
}
if (fl_get_button(dialog_->check_here)) {
placement += "h";
}
}
controller().params().placement = placement;
}
@ -73,6 +73,7 @@ void FormFloat::apply()
void FormFloat::update()
{
bool def_placement = false;
bool top = false;
bool bottom = false;
bool page = false;
@ -81,8 +82,12 @@ void FormFloat::update()
string placement(controller().params().placement);
if (contains(placement, "H")) {
if (placement.empty()) {
def_placement = true;
} else if (contains(placement, "H")) {
here_definitely = true;
} else {
if (contains(placement, "t")) {
top = true;
@ -97,18 +102,41 @@ void FormFloat::update()
here = true;
}
}
fl_set_button(dialog_->check_default, def_placement);
fl_set_button(dialog_->check_top, top);
fl_set_button(dialog_->check_bottom, bottom);
fl_set_button(dialog_->check_page, page);
fl_set_button(dialog_->check_here, here);
fl_set_button(dialog_->check_here_definitely, here_definitely);
setEnabled(dialog_->check_here_definitely, controller().params().allow_here_definitely);
setEnabled(dialog_->check_here, !def_placement);
setEnabled(dialog_->check_top, !def_placement);
setEnabled(dialog_->check_bottom, !def_placement);
setEnabled(dialog_->check_page, !def_placement);
setEnabled(dialog_->check_here_definitely,
controller().params().allow_here_definitely && !def_placement);
}
ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
{
if (ob == dialog_->check_here_definitely) {
bool const def_place = fl_get_button(dialog_->check_default);
if (ob == dialog_->check_default) {
if (def_place) {
fl_set_button(dialog_->check_top, false);
fl_set_button(dialog_->check_bottom, false);
fl_set_button(dialog_->check_page, false);
fl_set_button(dialog_->check_here, false);
fl_set_button(dialog_->check_here_definitely, false);
}
setEnabled(dialog_->check_top, !def_place);
setEnabled(dialog_->check_bottom, !def_place);
setEnabled(dialog_->check_page, !def_place);
setEnabled(dialog_->check_here, !def_place);
setEnabled(dialog_->check_here_definitely, !def_place);
} else if (ob == dialog_->check_here_definitely) {
if (fl_get_button(dialog_->check_here_definitely)) {
fl_set_button(dialog_->check_top, false);
fl_set_button(dialog_->check_bottom, false);

View File

@ -22,72 +22,79 @@ FD_form_float * FormFloat::build_float()
FL_OBJECT *obj;
FD_form_float *fdui = new FD_form_float;
fdui->form = fl_bgn_form(FL_NO_BOX, 360, 200);
fdui->form = fl_bgn_form(FL_NO_BOX, 360, 230);
fdui->form->u_vdata = this;
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 360, 200, "");
obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 100, 340, 50, "");
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 20, 340, 80, _("Placement"));
obj = fl_add_box(FL_FLAT_BOX, 0, 0, 360, 230, "");
obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 130, 340, 50, "");
obj = fl_add_labelframe(FL_ENGRAVED_FRAME, 10, 20, 340, 110, _("Placement"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_lstyle(obj, FL_BOLD_STYLE);
{
char const * const dummy = N_("Top of the page|#T");
fdui->check_top = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 30, 152, 30, idex(_(dummy)));
fdui->check_top = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 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);
{
char const * const dummy = N_("Bottom of the page|#B");
fdui->check_bottom = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 60, 152, 30, idex(_(dummy)));
fdui->check_bottom = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 90, 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);
{
char const * const dummy = N_("Page of floats|#P");
fdui->check_page = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 30, 152, 30, idex(_(dummy)));
fdui->check_page = 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);
{
char const * const dummy = N_("Here, if possible|#i");
fdui->check_here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 60, 152, 30, idex(_(dummy)));
fdui->check_here = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 190, 90, 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);
{
char const * const dummy = N_("Here, definitely|#H");
fdui->check_here_definitely = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 110, 152, 30, idex(_(dummy)));
fdui->check_here_definitely = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 140, 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);
{
char const * const dummy = N_("Restore|#R");
fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 160, 80, 30, idex(_(dummy)));
fdui->button_restore = obj = fl_add_button(FL_NORMAL_BUTTON, 10, 190, 80, 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_FormBaseRestoreCB, 0);
fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 120, 160, 70, 30, _("OK"));
fdui->button_ok = obj = fl_add_button(FL_RETURN_BUTTON, 120, 190, 70, 30, _("OK"));
fl_set_object_lsize(obj, FL_NORMAL_SIZE);
fl_set_object_callback(obj, C_FormBaseOKCB, 0);
{
char const * const dummy = N_("Apply|#A");
fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 160, 70, 30, idex(_(dummy)));
fdui->button_apply = obj = fl_add_button(FL_NORMAL_BUTTON, 200, 190, 70, 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_FormBaseApplyCB, 0);
{
char const * const dummy = N_("Cancel|^[");
fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 280, 160, 70, 30, idex(_(dummy)));
fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 280, 190, 70, 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_FormBaseCancelCB, 0);
{
char const * const dummy = N_("Document defaults|#D");
fdui->check_default = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 20, 30, 30, 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);
fl_end_form();
fdui->form->fdui = fdui;

View File

@ -26,6 +26,7 @@ struct FD_form_float {
FL_OBJECT *button_ok;
FL_OBJECT *button_apply;
FL_OBJECT *button_close;
FL_OBJECT *check_default;
};
#endif /* FD_form_float_h_ */

View File

@ -9,13 +9,13 @@ Unit of measure: FL_COORD_PIXEL
=============== FORM ===============
Name: form_float
Width: 360
Height: 200
Number of Objects: 12
Height: 230
Number of Objects: 13
--------------------
class: FL_BOX
type: FLAT_BOX
box: 0 0 360 200
box: 0 0 360 230
boxtype: FL_FLAT_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -33,7 +33,7 @@ argument:
--------------------
class: FL_FRAME
type: ENGRAVED_FRAME
box: 10 100 340 50
box: 10 130 340 50
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_CENTER
@ -51,7 +51,7 @@ argument:
--------------------
class: FL_LABELFRAME
type: ENGRAVED_FRAME
box: 10 20 340 80
box: 10 20 340 110
boxtype: FL_NO_BOX
colors: FL_BLACK FL_COL1
alignment: FL_ALIGN_TOP_LEFT
@ -69,7 +69,7 @@ argument:
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 30 152 30
box: 20 60 152 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -87,7 +87,7 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 60 152 30
box: 20 90 152 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -105,7 +105,7 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 190 30 152 30
box: 190 60 152 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -123,7 +123,7 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 190 60 152 30
box: 190 90 152 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -141,7 +141,7 @@ argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 110 152 30
box: 20 140 152 30
boxtype: FL_NO_BOX
colors: FL_COL1 FL_YELLOW
alignment: FL_ALIGN_CENTER
@ -159,7 +159,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 10 160 80 30
box: 10 190 80 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -177,7 +177,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: RETURN_BUTTON
box: 120 160 70 30
box: 120 190 70 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -195,7 +195,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 200 160 70 30
box: 200 190 70 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -213,7 +213,7 @@ argument: 0
--------------------
class: FL_BUTTON
type: NORMAL_BUTTON
box: 280 160 70 30
box: 280 190 70 30
boxtype: FL_UP_BOX
colors: FL_COL1 FL_COL1
alignment: FL_ALIGN_CENTER
@ -228,5 +228,23 @@ name: button_close
callback: C_FormBaseCancelCB
argument: 0
--------------------
class: FL_CHECKBUTTON
type: PUSH_BUTTON
box: 20 30 30 30
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: Document defaults|#D
shortcut:
resize: FL_RESIZE_ALL
gravity: FL_NoGravity FL_NoGravity
name: check_default
callback: C_FormBaseInputCB
argument: 0
==============================
create_the_forms

View File

@ -1,3 +1,13 @@
2002-07-30 Juergen Spitzmueller <j.spitzmueller@gmx.de>
* insetfloat.C: fix bug with float settings
(document default != float default).
2002-07-30 Dekel Tsur <dekelts@tau.ac.il>
* insetfloat.C (read, write): Allow default placement
(floatPlacement_ is empty).
2002-08-15 Jean-Marc Lasgouttes <lasgouttes@freesurf.fr>
* insetfloat.C (InsetFloat): when creating a new float inset, set

View File

@ -154,10 +154,7 @@ void InsetFloat::write(Buffer const * buf, ostream & os) const
os << "Float " // getInsetName()
<< floatType_ << '\n';
if (floatPlacement_.empty()) {
os << "placement "
<< floatList.getType(floatType_).placement() << "\n";
} else {
if (!floatPlacement_.empty()) {
os << "placement " << floatPlacement_ << "\n";
}
if (wide_) {
@ -179,8 +176,6 @@ void InsetFloat::read(Buffer const * buf, LyXLex & lex)
lex.next();
floatPlacement_ = lex.getString();
} else {
lyxerr << "InsetFloat::Read: Missing placement!"
<< endl;
// take countermeasures
lex.pushToken(token);
}
@ -242,8 +237,9 @@ int InsetFloat::latex(Buffer const * buf,
if (!floatPlacement_.empty()
&& floatPlacement_ != def_placement) {
placement = floatPlacement_;
} else if (!buf_placement.empty()
&& buf_placement != def_placement) {
} else if (floatPlacement_.empty()
&& !buf_placement.empty()
&& buf_placement != def_placement) {
placement = buf_placement;
}

View File

@ -38,6 +38,9 @@ recommended.
table...): the empty paragraph in the float now is a caption. It
seems that 1.2.0 behaviour was confusing too many people
- it is now possible to set the float placement parameters to
"document defaults"
- when the cursor is inside a collapsible inset, `Edit>Open/close
float' will leave it after the inset after closing it (this should
help entering of ERT insets)