2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
11 * \author Angus Leeming <a.leeming@ic.ac.uk>
17 #pragma implementation
23 #include "support/LAssert.h"
25 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
28 FormBase::FormBase(ControlButtons & c, string const & t)
29 : ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
33 void FormBase::redraw()
35 if (form() && form()->visible)
36 fl_redraw_form(form());
47 // work around dumb xforms sizing bug
51 fl_set_form_atclose(form(),
52 C_FormBaseWMHideCB, 0);
55 fl_freeze_form(form());
56 update(); // make sure its up-to-date
57 fl_unfreeze_form(form());
59 if (form()->visible) {
60 fl_raise_form(form());
61 /* This XMapWindow() will hopefully ensure that
62 * iconified dialogs are de-iconified. Mad props
63 * out to those crazy Xlib guys for forgetting a
64 * XDeiconifyWindow(). At least WindowMaker, when
65 * being notified of the redirected MapRequest will
66 * specifically de-iconify. From source, fvwm2 seems
69 XMapWindow(fl_get_display(), form()->window);
71 // calls to fl_set_form_minsize/maxsize apply only to the next
72 // fl_show_form(), so this comes first.
73 fl_set_form_minsize(form(), minw_, minh_);
75 FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
83 if (form() && form()->visible)
88 void FormBase::InputCB(FL_OBJECT * ob, long data)
90 bc().input(input(ob, data));
94 ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
96 return ButtonPolicy::SMI_VALID;
102 FormBase * GetForm(FL_OBJECT * ob)
104 Assert(ob && ob->form && ob->form->u_vdata);
105 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
112 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *)
114 // Close the dialog cleanly, even if the WM is used to do so.
115 Assert(form && form->u_vdata);
116 FormBase * pre = static_cast<FormBase *>(form->u_vdata);
122 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
124 GetForm(ob)->ApplyButton();
128 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
130 GetForm(ob)->OKButton();
134 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
136 FormBase * form = GetForm(ob);
137 form->CancelButton();
141 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
143 GetForm(ob)->RestoreButton();
147 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
149 GetForm(ob)->InputCB(ob, d);