1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2001 The LyX Team.
8 * ======================================================
10 * \file FormMinipage.C
11 * \author Jürgen Vigna, jug@sad.it
17 #pragma implementation
21 #include "ControlMinipage.h"
22 #include "FormMinipage.h"
23 #include "form_minipage.h"
24 #include "support/lstrings.h"
25 #include "helper_funcs.h"
28 typedef FormCB<ControlMinipage, FormDB<FD_form_minipage> > base_class;
30 FormMinipage::FormMinipage(ControlMinipage & c)
31 : base_class(c, _("Minipage Options"))
35 void FormMinipage::build()
37 dialog_.reset(build_minipage());
39 fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
41 string const choice = getStringFromVector(minipage::getUnits(), "|");
42 fl_addto_choice(dialog_->choice_width_units, subst(choice, "%", "%%").c_str());
44 // Manage the ok, apply and cancel/close buttons
45 bc().setOK(dialog_->button_ok);
46 bc().setApply(dialog_->button_apply);
47 bc().setCancel(dialog_->button_cancel);
48 bc().setRestore(dialog_->button_restore);
50 bc().addReadOnly(dialog_->input_width);
51 bc().addReadOnly(dialog_->choice_width_units);
52 bc().addReadOnly(dialog_->group_alignment);
53 bc().addReadOnly(dialog_->radio_top);
54 bc().addReadOnly(dialog_->radio_middle);
55 bc().addReadOnly(dialog_->radio_bottom);
59 void FormMinipage::apply()
61 string const units = fl_get_choice_text(dialog_->choice_width_units);
62 double const val = strToDbl(fl_get_input(dialog_->input_width));
64 controller().params().width =
65 tostr(val) + frontStrip(strip(subst(units,"%%","%")));
67 if (fl_get_button(dialog_->radio_top))
68 controller().params().pos = InsetMinipage::top;
69 else if (fl_get_button(dialog_->radio_middle))
70 controller().params().pos = InsetMinipage::center;
72 controller().params().pos = InsetMinipage::bottom;
76 void FormMinipage::update()
78 LyXLength len(controller().params().width.c_str());
79 fl_set_input(dialog_->input_width,tostr(len.value()).c_str());
80 fl_set_choice(dialog_->choice_width_units, len.unit()+1);
82 switch (controller().params().pos) {
83 case InsetMinipage::top:
84 fl_set_button(dialog_->radio_top, 1);
86 case InsetMinipage::center:
87 fl_set_button(dialog_->radio_middle, 1);
89 case InsetMinipage::bottom:
90 fl_set_button(dialog_->radio_bottom, 1);