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
|
|
|
|
* See the file COPYING.
|
|
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes
|
2002-07-25 11:06:25 +00:00
|
|
|
|
* \author Juergen Spitzmueller j.spitzmueller@gmx.de
|
2002-09-05 14:10:50 +00:00
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS
|
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-08-12 14:28:43 +00:00
|
|
|
|
FormFloat::FormFloat()
|
|
|
|
|
: base_class(_("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);
|
2002-07-25 16:05:31 +00:00
|
|
|
|
setEnabled(dialog_->check_force, top || bottom || page || here);
|
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);
|
2002-07-25 16:05:31 +00:00
|
|
|
|
bool const wide_float = fl_get_button(dialog_->check_wide);
|
|
|
|
|
// with wide floats, h[ere] is not allowed
|
|
|
|
|
// b[ottom] is allowed (only) for figure* in multicolumn, don't
|
|
|
|
|
// disallow it therefore
|
|
|
|
|
bool const wide_options = (fl_get_button(dialog_->check_top)
|
|
|
|
|
|| fl_get_button(dialog_->check_bottom)
|
|
|
|
|
|| fl_get_button(dialog_->check_page));
|
|
|
|
|
// The !-option is only allowed together with h, t, b, or p
|
|
|
|
|
// We have to take this into account
|
|
|
|
|
bool const standard_options = (wide_options || fl_get_button(dialog_->check_here));
|
|
|
|
|
|
2002-07-25 11:06:25 +00:00
|
|
|
|
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);
|
2002-07-25 16:05:31 +00:00
|
|
|
|
setEnabled(dialog_->check_here, !def_place && !wide_float);
|
|
|
|
|
setEnabled(dialog_->check_force, !def_place && standard_options);
|
|
|
|
|
setEnabled(dialog_->check_here_definitely, !def_place && !wide_float);
|
|
|
|
|
|
|
|
|
|
} else if (ob == dialog_->check_wide) {
|
|
|
|
|
if (wide_float) {
|
|
|
|
|
fl_set_button(dialog_->check_here_definitely, false);
|
|
|
|
|
fl_set_button(dialog_->check_here, false);
|
|
|
|
|
if (!wide_options) {
|
|
|
|
|
fl_set_button(dialog_->check_force, false);
|
|
|
|
|
setEnabled(dialog_->check_force, false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
setEnabled(dialog_->check_here, !def_place && !wide_float);
|
|
|
|
|
setEnabled(dialog_->check_force, !def_place && wide_options);
|
|
|
|
|
setEnabled(dialog_->check_here_definitely, !def_place && !wide_float);
|
2002-07-25 11:06:25 +00:00
|
|
|
|
|
|
|
|
|
} 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);
|
2002-07-25 16:05:31 +00:00
|
|
|
|
setEnabled(dialog_->check_force, false);
|
2001-09-11 17:27:28 +00:00
|
|
|
|
}
|
2002-07-25 11:06:25 +00:00
|
|
|
|
|
2002-07-25 16:05:31 +00:00
|
|
|
|
} else if (ob == dialog_->check_here || ob == dialog_->check_top
|
|
|
|
|
|| ob == dialog_->check_bottom || ob == dialog_->check_page) {
|
|
|
|
|
if (!standard_options)
|
|
|
|
|
fl_set_button(dialog_->check_force, false);
|
|
|
|
|
else
|
2002-07-24 15:37:17 +00:00
|
|
|
|
fl_set_button(dialog_->check_here_definitely, false);
|
2002-07-25 16:05:31 +00:00
|
|
|
|
setEnabled(dialog_->check_force, standard_options);
|
|
|
|
|
|
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
|
|
|
|
}
|