2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000-2001 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(), C_FormBaseWMHideCB, 0);
54 fl_freeze_form(form());
55 update(); // make sure its up-to-date
56 fl_unfreeze_form(form());
58 if (form()->visible) {
59 fl_raise_form(form());
60 /* This XMapWindow() will hopefully ensure that
61 * iconified dialogs are de-iconified. Mad props
62 * out to those crazy Xlib guys for forgetting a
63 * XDeiconifyWindow(). At least WindowMaker, when
64 * being notified of the redirected MapRequest will
65 * specifically de-iconify. From source, fvwm2 seems
68 XMapWindow(fl_get_display(), form()->window);
70 // calls to fl_set_form_minsize/maxsize apply only to the next
71 // fl_show_form(), so this comes first.
72 fl_set_form_minsize(form(), minw_, minh_);
74 FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
82 if (form() && form()->visible)
87 void FormBase::InputCB(FL_OBJECT * ob, long data)
89 bc().input(input(ob, data));
93 ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
95 return ButtonPolicy::SMI_VALID;
101 FormBase * GetForm(FL_OBJECT * ob)
103 lyx::Assert(ob && ob->form && ob->form->u_vdata);
104 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
112 int C_FormBaseWMHideCB(FL_FORM * form, void *)
114 // Close the dialog cleanly, even if the WM is used to do so.
115 lyx::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);