2002-03-11 17:00:41 +00:00
|
|
|
|
/**
|
2001-03-27 16:03:28 +00:00
|
|
|
|
* \file FormMinipage.C
|
2002-09-05 15:14:23 +00:00
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
|
* Licence details can be found in the file COPYING.
|
2002-03-11 17:00:41 +00:00
|
|
|
|
*
|
2002-09-05 14:10:50 +00:00
|
|
|
|
* \author J<EFBFBD>rgen Vigna
|
|
|
|
|
*
|
|
|
|
|
* Full author contact details are available in file CREDITS
|
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"
|
2002-06-13 13:43:51 +00:00
|
|
|
|
#include "forms/form_minipage.h"
|
2001-03-16 15:15:32 +00:00
|
|
|
|
#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"
|
2002-06-13 13:43:51 +00:00
|
|
|
|
#include FORMS_H_LOCATION
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2002-06-13 13:43:51 +00:00
|
|
|
|
typedef FormCB<ControlMinipage, FormDB<FD_minipage> > base_class;
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2002-08-12 14:28:43 +00:00
|
|
|
|
FormMinipage::FormMinipage()
|
|
|
|
|
: base_class(_("Minipage Options"))
|
2001-03-27 16:03:28 +00:00
|
|
|
|
{}
|
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
|
|
|
|
{
|
2002-06-13 13:43:51 +00:00
|
|
|
|
dialog_.reset(build_minipage(this));
|
2001-03-16 15:15:32 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
// Allow the base class to control messages
|
|
|
|
|
setMessageWidget(dialog_->text_warning);
|
|
|
|
|
|
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);
|
2002-03-12 14:11:15 +00:00
|
|
|
|
bc().setCancel(dialog_->button_close);
|
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: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,
|
2002-03-20 17:53:39 +00:00
|
|
|
|
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-03-20 17:53:39 +00:00
|
|
|
|
LyXLength len(controller().params().pageWidth);
|
|
|
|
|
fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
|
|
|
|
|
fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
|
|
|
|
|
|
|
|
|
|
switch (controller().params().pos) {
|
|
|
|
|
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;
|
|
|
|
|
}
|
2001-03-16 15:15:32 +00:00
|
|
|
|
}
|
2002-01-29 09:38:09 +00:00
|
|
|
|
|
2002-03-20 17:53:39 +00:00
|
|
|
|
|
2002-01-29 09:38:09 +00:00
|
|
|
|
ButtonPolicy::SMInput FormMinipage::input(FL_OBJECT * ob, long)
|
|
|
|
|
{
|
2002-03-20 17:53:39 +00:00
|
|
|
|
clearMessage();
|
|
|
|
|
|
2002-01-29 09:38:09 +00:00
|
|
|
|
ButtonPolicy::SMInput action = ButtonPolicy::SMI_NOOP;
|
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
if (ob == dialog_->radio_top ||
|
2002-03-20 17:53:39 +00:00
|
|
|
|
ob == dialog_->radio_middle ||
|
|
|
|
|
ob == dialog_->radio_bottom ||
|
|
|
|
|
ob == dialog_->choice_width_units)
|
2002-02-11 18:43:42 +00:00
|
|
|
|
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-07-21 15:51:07 +00:00
|
|
|
|
string const input = getString(dialog_->input_width);
|
2002-02-11 18:43:42 +00:00
|
|
|
|
bool const invalid = !isValidLength(input) && !isStrDbl(input);
|
2002-01-29 09:38:09 +00:00
|
|
|
|
if (invalid) {
|
2002-03-20 17:53:39 +00:00
|
|
|
|
postWarning(_("Invalid Length!"));
|
2002-01-29 09:38:09 +00:00
|
|
|
|
action = ButtonPolicy::SMI_INVALID;
|
|
|
|
|
} else {
|
|
|
|
|
action = ButtonPolicy::SMI_VALID;
|
|
|
|
|
}
|
|
|
|
|
}
|
2002-02-11 18:43:42 +00:00
|
|
|
|
|
2002-01-29 09:38:09 +00:00
|
|
|
|
return action;
|
|
|
|
|
}
|