1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000-2001 The LyX Team.
8 * ======================================================
10 * \author Angus Leeming <a.leeming@ic.ac.uk>
16 #pragma implementation
22 #include "support/LAssert.h"
24 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
27 FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize)
28 : ViewBC<xformsBC>(c), minw_(0), minh_(0), allow_resize_(allowResize),
33 void FormBase::redraw()
35 if (form() && form()->visible)
36 fl_redraw_form(form());
46 // use minw_ to flag whether the dialog has ever been shown
47 // (Needed now that build() is/should be called from the controller)
51 // work around dumb xforms sizing bug
55 fl_set_form_atclose(form(), C_FormBaseWMHideCB, 0);
58 fl_freeze_form(form());
59 update(); // make sure its up-to-date
60 fl_unfreeze_form(form());
62 if (form()->visible) {
63 fl_raise_form(form());
64 /* This XMapWindow() will hopefully ensure that
65 * iconified dialogs are de-iconified. Mad props
66 * out to those crazy Xlib guys for forgetting a
67 * XDeiconifyWindow(). At least WindowMaker, when
68 * being notified of the redirected MapRequest will
69 * specifically de-iconify. From source, fvwm2 seems
72 XMapWindow(fl_get_display(), form()->window);
74 // calls to fl_set_form_minsize/maxsize apply only to the next
75 // fl_show_form(), so this comes first.
76 fl_set_form_minsize(form(), minw_, minh_);
78 fl_set_form_maxsize(form(), minw_, minh_);
81 FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
89 if (form() && form()->visible)
94 void FormBase::InputCB(FL_OBJECT * ob, long data)
96 bc().input(input(ob, data));
100 ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
102 return ButtonPolicy::SMI_VALID;
108 FormBase * GetForm(FL_OBJECT * ob)
110 lyx::Assert(ob && ob->form && ob->form->u_vdata);
111 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
119 int C_FormBaseWMHideCB(FL_FORM * form, void *)
121 // Close the dialog cleanly, even if the WM is used to do so.
122 lyx::Assert(form && form->u_vdata);
123 FormBase * pre = static_cast<FormBase *>(form->u_vdata);
129 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
131 GetForm(ob)->ApplyButton();
135 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
137 GetForm(ob)->OKButton();
141 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
143 FormBase * form = GetForm(ob);
144 form->CancelButton();
148 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
150 GetForm(ob)->RestoreButton();
154 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
156 GetForm(ob)->InputCB(ob, d);