-// -*- C++ -*-
/* This file is part of
* ======================================================
*
#include "xformsBC.h"
#include "support/LAssert.h"
-extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
+extern "C" {
+ // Callback function invoked by xforms when the dialog is closed by the
+ // window manager
+ static int C_FormBaseWMHideCB(FL_FORM * form, void *);
+
+}
-FormBase::FormBase(ControlButtons & c, string const & t)
- : ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
+FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize)
+ : ViewBC<xformsBC>(c), minw_(0), minh_(0), allow_resize_(allowResize),
+ title_(t)
{}
{
if (!form()) {
build();
-
+ }
+
+ // use minw_ to flag whether the dialog has ever been shown
+ // (Needed now that build() is/should be called from the controller)
+ if (minw_ == 0) {
bc().refresh();
// work around dumb xforms sizing bug
fl_set_form_atclose(form(), C_FormBaseWMHideCB, 0);
}
-
+
fl_freeze_form(form());
update(); // make sure its up-to-date
fl_unfreeze_form(form());
// calls to fl_set_form_minsize/maxsize apply only to the next
// fl_show_form(), so this comes first.
fl_set_form_minsize(form(), minw_, minh_);
+ if (!allow_resize_)
+ fl_set_form_maxsize(form(), minw_, minh_);
+
fl_show_form(form(),
- FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
- title_.c_str());
+ FL_PLACE_MOUSE | FL_FREE_SIZE,
+ (controller_.IconifyWithMain() ? FL_TRANSIENT : 0),
+ title_.c_str());
}
}
void FormBase::InputCB(FL_OBJECT * ob, long data)
{
+ // It is possible to set the choice to 0 when using the
+ // keyboard shortcuts. This work-around deals with the problem.
+ if (ob && ob->objclass == FL_CHOICE && fl_get_choice(ob) < 1) {
+ fl_set_choice(ob, 1);
+ }
+
bc().input(input(ob, data));
}
} // namespace anon
-extern "C"
-int C_FormBaseWMHideCB(FL_FORM * form, void *)
-{
- // Close the dialog cleanly, even if the WM is used to do so.
- lyx::Assert(form && form->u_vdata);
- FormBase * pre = static_cast<FormBase *>(form->u_vdata);
- pre->CancelButton();
- return FL_CANCEL;
-}
+extern "C" {
+
+ static
+ int C_FormBaseWMHideCB(FL_FORM * form, void *)
+ {
+ // Close the dialog cleanly, even if the WM is used to do so.
+ lyx::Assert(form && form->u_vdata);
+ FormBase * pre = static_cast<FormBase *>(form->u_vdata);
+ pre->CancelButton();
+ return FL_CANCEL;
+ }
-extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
-{
- GetForm(ob)->ApplyButton();
-}
+ void C_FormBaseApplyCB(FL_OBJECT * ob, long)
+ {
+ GetForm(ob)->ApplyButton();
+ }
-extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
-{
- GetForm(ob)->OKButton();
-}
+ void C_FormBaseOKCB(FL_OBJECT * ob, long)
+ {
+ GetForm(ob)->OKButton();
+ }
-extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
-{
- FormBase * form = GetForm(ob);
- form->CancelButton();
-}
+ void C_FormBaseCancelCB(FL_OBJECT * ob, long)
+ {
+ FormBase * form = GetForm(ob);
+ form->CancelButton();
+ }
-extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
-{
- GetForm(ob)->RestoreButton();
-}
+ void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
+ {
+ GetForm(ob)->RestoreButton();
+ }
-extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
-{
- GetForm(ob)->InputCB(ob, d);
+ void C_FormBaseInputCB(FL_OBJECT * ob, long d)
+ {
+ GetForm(ob)->InputCB(ob, d);
+ }
+
+
+ // To trigger an input event when pasting in an xforms input object
+ // using the middle mouse button.
+ int C_CutandPastePH(FL_OBJECT * ob, int event,
+ FL_Coord, FL_Coord, int key, void *)
+ {
+ if ((event == FL_PUSH) && (key == 2)
+ && (ob->objclass == FL_INPUT)) {
+ C_FormBaseInputCB(ob, 0);
+ }
+ return 0;
+ }
+
}