2002-03-11 17:00:41 +00:00
|
|
|
|
/**
|
2001-03-27 16:03:28 +00:00
|
|
|
|
* \file FormMinipage.C
|
2002-03-11 17:00:41 +00:00
|
|
|
|
* Copyright 2000-2001 The LyX Team.
|
|
|
|
|
* See the file COPYING.
|
|
|
|
|
*
|
2001-03-28 09:28:48 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna, jug@sad.it
|
2001-03-16 15:15:32 +00:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
#include "xformsBC.h"
|
|
|
|
|
#include "ControlMinipage.h"
|
2001-03-16 15:15:32 +00:00
|
|
|
|
#include "FormMinipage.h"
|
|
|
|
|
#include "form_minipage.h"
|
|
|
|
|
#include "support/lstrings.h"
|
2001-03-29 15:00:20 +00:00
|
|
|
|
#include "helper_funcs.h"
|
|
|
|
|
#include "debug.h"
|
2002-01-16 16:34:03 +00:00
|
|
|
|
#include "xforms_helpers.h"
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
FormMinipage::FormMinipage(ControlMinipage & c)
|
|
|
|
|
: base_class(c, _("Minipage Options"))
|
|
|
|
|
{}
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
void FormMinipage::build()
|
2001-03-16 15:15:32 +00:00
|
|
|
|
{
|
2001-03-27 16:03:28 +00:00
|
|
|
|
dialog_.reset(build_minipage());
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
|
2002-03-11 18:24:31 +00:00
|
|
|
|
setPrehandler(dialog_->input_width);
|
2001-03-29 15:00:20 +00:00
|
|
|
|
|
2001-10-15 10:28:31 +00:00
|
|
|
|
string const choice = getStringFromVector(getLatexUnits(), "|");
|
2001-03-29 15:00:20 +00:00
|
|
|
|
fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str());
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
// Manage the ok, apply and cancel/close buttons
|
|
|
|
|
bc().setOK(dialog_->button_ok);
|
|
|
|
|
bc().setApply(dialog_->button_apply);
|
|
|
|
|
bc().setCancel(dialog_->button_cancel);
|
2001-04-03 14:30:58 +00:00
|
|
|
|
bc().setRestore(dialog_->button_restore);
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
bc().addReadOnly(dialog_->input_width);
|
2001-03-29 15:00:20 +00:00
|
|
|
|
bc().addReadOnly(dialog_->choice_width_units);
|
2001-08-09 15:10:24 +00:00
|
|
|
|
bc().addReadOnly(dialog_->group_alignment);
|
2001-08-09 15:12:25 +00:00
|
|
|
|
bc().addReadOnly(dialog_->radio_top);
|
|
|
|
|
bc().addReadOnly(dialog_->radio_middle);
|
|
|
|
|
bc().addReadOnly(dialog_->radio_bottom);
|
2001-03-16 15:15:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormMinipage::apply()
|
|
|
|
|
{
|
2002-01-14 16:10:29 +00:00
|
|
|
|
controller().params().pageWidth =
|
2002-01-17 23:09:31 +00:00
|
|
|
|
LyXLength(getLengthFromWidgets(dialog_->input_width,
|
|
|
|
|
dialog_->choice_width_units));
|
2001-03-27 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
if (fl_get_button(dialog_->radio_top))
|
|
|
|
|
controller().params().pos = InsetMinipage::top;
|
|
|
|
|
else if (fl_get_button(dialog_->radio_middle))
|
|
|
|
|
controller().params().pos = InsetMinipage::center;
|
|
|
|
|
else
|
|
|
|
|
controller().params().pos = InsetMinipage::bottom;
|
2001-03-16 15:15:32 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void FormMinipage::update()
|
|
|
|
|
{
|
2002-01-14 16:10:29 +00:00
|
|
|
|
LyXLength len(controller().params().pageWidth);
|
2001-12-05 08:04:20 +00:00
|
|
|
|
fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
|
|
|
|
|
fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
|
2001-03-29 15:00:20 +00:00
|
|
|
|
|
2001-03-27 16:03:28 +00:00
|
|
|
|
switch (controller().params().pos) {
|
2001-03-16 15:15:32 +00:00
|
|
|
|
case InsetMinipage::top:
|
|
|
|
|
fl_set_button(dialog_->radio_top, 1);
|
|
|
|
|
break;
|
|
|
|
|
case InsetMinipage::center:
|
|
|
|
|
fl_set_button(dialog_->radio_middle, 1);
|
|
|
|
|
break;
|
|
|
|
|
case InsetMinipage::bottom:
|
|
|
|
|
fl_set_button(dialog_->radio_bottom, 1);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-01-29 09:38:09 +00:00
|
|
|
|
|
|
|
|
|
ButtonPolicy::SMInput FormMinipage::input(FL_OBJECT * ob, long)
|
|
|
|
|
{
|
|
|
|
|
ButtonPolicy::SMInput action = ButtonPolicy::SMI_NOOP;
|
|
|
|
|
|
2002-02-11 18:43:42 +00:00
|
|
|
|
if (ob == dialog_->radio_top ||
|
|
|
|
|
ob == dialog_->radio_middle ||
|
|
|
|
|
ob == dialog_->radio_bottom ||
|
|
|
|
|
ob == dialog_->choice_width_units)
|
|
|
|
|
return ButtonPolicy::SMI_VALID;
|
|
|
|
|
|
2002-01-29 09:38:09 +00:00
|
|
|
|
// disallow senseless data
|
|
|
|
|
// warnings if input is senseless
|
|
|
|
|
if (ob == dialog_->input_width) {
|
2002-02-11 18:43:42 +00:00
|
|
|
|
string const input = getStringFromInput(dialog_->input_width);
|
|
|
|
|
bool const invalid = !isValidLength(input) && !isStrDbl(input);
|
2002-01-29 09:38:09 +00:00
|
|
|
|
if (invalid) {
|
|
|
|
|
fl_set_object_label(dialog_->text_warning,
|
|
|
|
|
_("Warning: Invalid Length!"));
|
|
|
|
|
fl_show_object(dialog_->text_warning);
|
|
|
|
|
action = ButtonPolicy::SMI_INVALID;
|
|
|
|
|
} else {
|
|
|
|
|
fl_hide_object(dialog_->text_warning);
|
|
|
|
|
action = ButtonPolicy::SMI_VALID;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-11 18:43:42 +00:00
|
|
|
|
|
2002-01-29 09:38:09 +00:00
|
|
|
|
return action;
|
|
|
|
|
}
|