2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
12 * FormMinipage Interface Class Implementation
18 #pragma implementation
21 #include "FormMinipage.h"
22 #include "form_minipage.h"
26 #include "insets/insetminipage.h"
27 #include "support/lstrings.h"
29 FormMinipage::FormMinipage(LyXView * lv, Dialogs * d)
30 : FormInset(lv, d, _("Minipage Options")),
33 // let the dialog be shown
34 // This is a permanent connection so we won't bother
35 // storing a copy because we won't be disconnecting.
36 d->showMinipage.connect(SigC::slot(this, &FormMinipage::showInset));
37 d->updateMinipage.connect(SigC::slot(this, &FormMinipage::updateInset));
41 FL_FORM * FormMinipage::form() const
49 void FormMinipage::connect()
52 FormBaseBD::connect();
56 void FormMinipage::showInset(InsetMinipage * inset)
58 if (inset == 0) return;
60 // If connected to another inset, disconnect from it.
61 if (inset_ != inset) {
63 ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
71 void FormMinipage::updateInset(InsetMinipage * inset)
73 if (inset == 0 || inset_ == 0) return;
75 // If connected to another inset, disconnect from it.
76 if (inset_ != inset) {
78 ih_ = inset->hideDialog.connect(SigC::slot(this, &FormMinipage::hide));
85 void FormMinipage::build()
87 dialog_.reset(build_minipage());
89 // Workaround dumb xforms sizing bug
93 fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
94 fl_set_input_return(dialog_->input_widthp, FL_RETURN_CHANGED);
96 // Manage the ok, apply and cancel/close buttons
97 bc().setOK(dialog_->button_ok);
98 bc().setApply(dialog_->button_apply);
99 bc().setCancel(dialog_->button_cancel);
104 void FormMinipage::apply()
107 int ysize = int(fl_get_slider_value(dialog_->slider_columns) + 0.5);
108 int xsize = int(fl_get_slider_value(dialog_->slider_rows) + 0.5);
110 string tmp = tostr(xsize) + " " + tostr(ysize);
111 lv_->getLyXFunc()->Dispatch(LFUN_INSET_TABULAR, tmp);
116 void FormMinipage::update()
120 fl_set_input(dialog_->input_width, inset_->width().c_str());
121 fl_set_input(dialog_->input_widthp, tostr(inset_->widthp()).c_str());
123 switch (inset_->pos()) {
124 case InsetMinipage::top:
125 fl_set_button(dialog_->radio_top, 1);
127 case InsetMinipage::center:
128 fl_set_button(dialog_->radio_middle, 1);
130 case InsetMinipage::bottom:
131 fl_set_button(dialog_->radio_bottom, 1);
134 bc().readOnly(lv_->buffer()->isReadonly());