2002-03-11 17:00:41 +00:00
|
|
|
|
/**
|
2001-07-30 11:56:00 +00:00
|
|
|
|
* \file FormFloat.C
|
2002-03-11 17:00:41 +00:00
|
|
|
|
* Copyright 2001 The LyX Team.
|
|
|
|
|
* See the file COPYING.
|
|
|
|
|
*
|
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes, larsbj@lyx.org
|
2002-07-25 11:06:25 +00:00
|
|
|
|
* \author Juergen Spitzmueller j.spitzmueller@gmx.de
|
2001-07-30 11:56:00 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "xformsBC.h"
|
|
|
|
|
#include "ControlFloat.h"
|
|
|
|
|
#include "FormFloat.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
|
#include "forms/form_float.h"
|
2001-07-30 11:56:00 +00:00
|
|
|
|
#include "support/lstrings.h"
|
2002-01-03 13:31:12 +00:00
|
|
|
|
#include "xforms_helpers.h"
|
2002-06-13 13:43:51 +00:00
|
|
|
|
#include FORMS_H_LOCATION
|
2001-07-30 11:56:00 +00:00
|
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
|
typedef FormCB<ControlFloat, FormDB<FD_float> > base_class;
|
2001-07-30 11:56:00 +00:00
|
|
|
|
|
2002-07-02 19:23:10 +00:00
|
|
|
|
FormFloat::FormFloat(ControlFloat & c, Dialogs & d)
|
|
|
|
|
: base_class(c, d, _("Float Options"))
|
2001-07-30 11:56:00 +00:00
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormFloat::build()
|
|
|
|
|
{
|
2002-06-13 13:43:51 +00:00
|
|
|
|
dialog_.reset(build_float(this));
|
2001-07-30 11:56:00 +00:00
|
|
|
|
|
|
|
|
|
// Manage the ok, apply and cancel/close buttons
|
|
|
|
|
bc().setOK(dialog_->button_ok);
|
|
|
|
|
bc().setApply(dialog_->button_apply);
|
2002-03-12 14:11:15 +00:00
|
|
|
|
bc().setCancel(dialog_->button_close);
|
2001-07-30 11:56:00 +00:00
|
|
|
|
bc().setRestore(dialog_->button_restore);
|
|
|
|
|
|
2002-07-25 11:06:25 +00:00
|
|
|
|
bc().addReadOnly(dialog_->check_default);
|
2002-03-12 14:11:15 +00:00
|
|
|
|
bc().addReadOnly(dialog_->check_top);
|
|
|
|
|
bc().addReadOnly(dialog_->check_bottom);
|
|
|
|
|
bc().addReadOnly(dialog_->check_page);
|
|
|
|
|
bc().addReadOnly(dialog_->check_here);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
bc().addReadOnly(dialog_->check_force);
|
2002-03-12 14:11:15 +00:00
|
|
|
|
bc().addReadOnly(dialog_->check_here_definitely);
|
2002-07-24 15:37:17 +00:00
|
|
|
|
bc().addReadOnly(dialog_->check_wide);
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormFloat::apply()
|
|
|
|
|
{
|
|
|
|
|
string placement;
|
2002-03-12 14:11:15 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_here_definitely)) {
|
2001-07-30 11:56:00 +00:00
|
|
|
|
placement += "H";
|
|
|
|
|
} else {
|
2002-07-25 11:06:25 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_force)) {
|
|
|
|
|
placement += "!";
|
|
|
|
|
}
|
|
|
|
|
if (fl_get_button(dialog_->check_here)) {
|
|
|
|
|
placement += "h";
|
|
|
|
|
}
|
2002-03-12 14:11:15 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_top)) {
|
2001-07-30 11:56:00 +00:00
|
|
|
|
placement += "t";
|
|
|
|
|
}
|
2002-03-12 14:11:15 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_bottom)) {
|
2001-07-30 11:56:00 +00:00
|
|
|
|
placement += "b";
|
|
|
|
|
}
|
2002-03-12 14:11:15 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_page)) {
|
2001-07-30 11:56:00 +00:00
|
|
|
|
placement += "p";
|
|
|
|
|
}
|
2002-07-25 11:06:25 +00:00
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
controller().params().placement = placement;
|
2002-07-24 15:37:17 +00:00
|
|
|
|
controller().params().wide = fl_get_button(dialog_->check_wide);
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormFloat::update()
|
|
|
|
|
{
|
2002-07-25 11:06:25 +00:00
|
|
|
|
bool def_placement = false;
|
2001-07-30 11:56:00 +00:00
|
|
|
|
bool top = false;
|
|
|
|
|
bool bottom = false;
|
|
|
|
|
bool page = false;
|
|
|
|
|
bool here = false;
|
2002-07-25 11:06:25 +00:00
|
|
|
|
bool force = false;
|
2001-09-11 17:27:28 +00:00
|
|
|
|
bool here_definitely = false;
|
2001-07-30 11:56:00 +00:00
|
|
|
|
|
|
|
|
|
string placement(controller().params().placement);
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2002-07-25 11:06:25 +00:00
|
|
|
|
if (placement.empty()) {
|
|
|
|
|
def_placement = true;
|
|
|
|
|
|
|
|
|
|
} else if (contains(placement, "H")) {
|
2001-09-11 17:27:28 +00:00
|
|
|
|
here_definitely = true;
|
2002-07-25 11:06:25 +00:00
|
|
|
|
|
2001-07-30 11:56:00 +00:00
|
|
|
|
} else {
|
2002-07-25 11:06:25 +00:00
|
|
|
|
if (contains(placement, "!")) {
|
|
|
|
|
force = true;
|
|
|
|
|
}
|
2001-07-30 11:56:00 +00:00
|
|
|
|
if (contains(placement, "t")) {
|
|
|
|
|
top = true;
|
|
|
|
|
}
|
|
|
|
|
if (contains(placement, "b")) {
|
|
|
|
|
bottom = true;
|
|
|
|
|
}
|
|
|
|
|
if (contains(placement, "p")) {
|
|
|
|
|
page = true;
|
|
|
|
|
}
|
|
|
|
|
if (contains(placement, "h")) {
|
|
|
|
|
here = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-07-25 11:06:25 +00:00
|
|
|
|
fl_set_button(dialog_->check_default, def_placement);
|
2002-03-12 14:11:15 +00:00
|
|
|
|
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);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
fl_set_button(dialog_->check_force, force);
|
2002-03-12 14:11:15 +00:00
|
|
|
|
fl_set_button(dialog_->check_here_definitely, here_definitely);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
setEnabled(dialog_->check_here_definitely, !controller().params().wide
|
|
|
|
|
&& !def_placement);
|
|
|
|
|
if (controller().params().wide) {
|
|
|
|
|
fl_set_button(dialog_->check_here, false);
|
|
|
|
|
fl_set_button(dialog_->check_bottom, false);
|
|
|
|
|
}
|
|
|
|
|
setEnabled(dialog_->check_here, !controller().params().wide && !def_placement);
|
|
|
|
|
setEnabled(dialog_->check_bottom, !controller().params().wide && !def_placement);
|
2002-07-24 15:37:17 +00:00
|
|
|
|
fl_set_button(dialog_->check_wide, controller().params().wide);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
setEnabled(dialog_->check_top, !def_placement);
|
|
|
|
|
setEnabled(dialog_->check_page, !def_placement);
|
|
|
|
|
setEnabled(dialog_->check_force, !def_placement);
|
2001-07-30 11:56:00 +00:00
|
|
|
|
}
|
|
|
|
|
|
2001-09-11 17:27:28 +00:00
|
|
|
|
|
|
|
|
|
ButtonPolicy::SMInput FormFloat::input(FL_OBJECT * ob, long)
|
|
|
|
|
{
|
2002-07-25 11:06:25 +00:00
|
|
|
|
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_force, 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_force, !def_place);
|
|
|
|
|
setEnabled(dialog_->check_here_definitely, !def_place);
|
|
|
|
|
|
|
|
|
|
} else if (ob == dialog_->check_here_definitely) {
|
2002-03-12 14:11:15 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_here_definitely)) {
|
|
|
|
|
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);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
fl_set_button(dialog_->check_force, false);
|
2001-09-11 17:27:28 +00:00
|
|
|
|
}
|
|
|
|
|
} else {
|
2002-03-12 14:11:15 +00:00
|
|
|
|
if (fl_get_button(dialog_->check_here_definitely)) {
|
|
|
|
|
fl_set_button(dialog_->check_here_definitely, false);
|
2001-09-11 17:27:28 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2002-07-25 11:06:25 +00:00
|
|
|
|
|
2002-07-24 15:37:17 +00:00
|
|
|
|
if (ob == dialog_->check_wide) {
|
|
|
|
|
if (fl_get_button(dialog_->check_wide)) {
|
|
|
|
|
fl_set_button(dialog_->check_here_definitely, false);
|
|
|
|
|
setEnabled(dialog_->check_here_definitely, false);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
fl_set_button(dialog_->check_here, false);
|
|
|
|
|
setEnabled(dialog_->check_here, false);
|
|
|
|
|
fl_set_button(dialog_->check_bottom, false);
|
|
|
|
|
setEnabled(dialog_->check_bottom, false);
|
|
|
|
|
|
|
|
|
|
} else {
|
2002-07-24 15:37:17 +00:00
|
|
|
|
setEnabled(dialog_->check_here_definitely, true);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
setEnabled(dialog_->check_here, true);
|
|
|
|
|
setEnabled(dialog_->check_bottom, true);
|
|
|
|
|
}
|
2002-07-24 15:37:17 +00:00
|
|
|
|
}
|
2001-09-12 09:29:46 +00:00
|
|
|
|
|
|
|
|
|
return ButtonPolicy::SMI_VALID;
|
2001-09-11 17:27:28 +00:00
|
|
|
|
}
|