lyx_mirror/src/frontends/xforms/FormMinipage.C
Lars Gullik Bjønnes 33a28bdc9c Add string << operators for the other streams as well, and removes
c_str() all places where it is not needed anymore.
(I also add config.h to several files that was missing it)
+ added s string constructor to math_symbolinset

I also change some "while(" to "while ("

mmm ... yes ... I add a "zero()" function to LyXLength... an "empty()"
function did not seem appropriate. changed a couple of places that
checked on length.value() != 0.0.


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@3149 a592a061-630c-0410-9148-cb99ea01b6c8
2001-12-05 08:04:20 +00:00

94 lines
2.4 KiB
C

/* This file is part of
* ======================================================
*
* LyX, The Document Processor
*
* Copyright 2001 The LyX Team.
*
* ======================================================
*
* \file FormMinipage.C
* \author Jürgen Vigna, jug@sad.it
*/
#include <config.h>
#ifdef __GNUG__
#pragma implementation
#endif
#include "xformsBC.h"
#include "ControlMinipage.h"
#include "FormMinipage.h"
#include "form_minipage.h"
#include "support/lstrings.h"
#include "helper_funcs.h"
#include "debug.h"
typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
FormMinipage::FormMinipage(ControlMinipage & c)
: base_class(c, _("Minipage Options"))
{}
void FormMinipage::build()
{
dialog_.reset(build_minipage());
fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
string const choice = getStringFromVector(getLatexUnits(), "|");
fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str());
// Manage the ok, apply and cancel/close buttons
bc().setOK(dialog_->button_ok);
bc().setApply(dialog_->button_apply);
bc().setCancel(dialog_->button_cancel);
bc().setRestore(dialog_->button_restore);
bc().addReadOnly(dialog_->input_width);
bc().addReadOnly(dialog_->choice_width_units);
bc().addReadOnly(dialog_->group_alignment);
bc().addReadOnly(dialog_->radio_top);
bc().addReadOnly(dialog_->radio_middle);
bc().addReadOnly(dialog_->radio_bottom);
}
void FormMinipage::apply()
{
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,"%%","%")));
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;
}
void FormMinipage::update()
{
LyXLength len(controller().params().width);
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;
}
}