2001-03-16 15:15:32 +00:00
|
|
|
|
/* This file is part of
|
|
|
|
|
* ======================================================
|
|
|
|
|
*
|
|
|
|
|
* LyX, The Document Processor
|
|
|
|
|
*
|
2001-03-27 16:03:28 +00:00
|
|
|
|
* Copyright 2001 The LyX Team.
|
2001-03-16 15:15:32 +00:00
|
|
|
|
*
|
|
|
|
|
* ======================================================
|
2001-03-27 16:03:28 +00:00
|
|
|
|
*
|
|
|
|
|
* \file FormMinipage.C
|
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"
|
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);
|
2001-03-29 15:00:20 +00:00
|
|
|
|
|
|
|
|
|
string const choice = getStringFromVector(minipage::getUnits(), "|");
|
|
|
|
|
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-03-27 16:03:28 +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()
|
|
|
|
|
{
|
2001-03-29 15:00:20 +00:00
|
|
|
|
string const units = fl_get_choice_text(dialog_->choice_width_units);
|
|
|
|
|
double const val = strToDbl(fl_get_input(dialog_->input_width));
|
|
|
|
|
|
|
|
|
|
controller().params().width =
|
|
|
|
|
tostr(val) + frontStrip(strip(subst(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()
|
|
|
|
|
{
|
2001-03-29 15:00:20 +00:00
|
|
|
|
LyXLength len(controller().params().width.c_str());
|
|
|
|
|
fl_set_input(dialog_->input_width,tostr(len.value()).c_str());
|
|
|
|
|
fl_set_choice(dialog_->choice_width_units, len.unit()+1);
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|