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(ControlBase & 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());
45 // work around dumb xforms sizing bug
49 fl_set_form_atclose(form(),
50 C_FormBaseWMHideCB, 0);
53 fl_freeze_form(form());
54 update(); // make sure its up-to-date
55 fl_unfreeze_form(form());
57 if (form()->visible) {
58 fl_raise_form(form());
59 /* This XMapWindow() will hopefully ensure that
60 * iconified dialogs are de-iconified. Mad props
61 * out to those crazy Xlib guys for forgetting a
62 * XDeiconifyWindow(). At least WindowMaker, when
63 * being notified of the redirected MapRequest will
64 * specifically de-iconify. From source, fvwm2 seems
67 XMapWindow(fl_get_display(), form()->window);
69 // calls to fl_set_form_minsize/maxsize apply only to the next
70 // fl_show_form(), so this comes first.
71 fl_set_form_minsize(form(), minw_, minh_);
73 FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
81 if (form() && form()->visible)
86 void FormBase::InputCB(FL_OBJECT * ob, long data)
88 bc().input(input(ob, data));
92 ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
94 return ButtonPolicy::SMI_VALID;
100 FormBase * GetForm(FL_OBJECT * ob)
102 Assert(ob && ob->form && ob->form->u_vdata);
103 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
110 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *)
112 // Close the dialog cleanly, even if the WM is used to do so.
113 Assert(form && form->u_vdata);
114 FormBase * pre = static_cast<FormBase *>(form->u_vdata);
120 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
122 GetForm(ob)->ApplyButton();
126 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
128 GetForm(ob)->OKButton();
132 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
134 FormBase * form = GetForm(ob);
135 form->CancelButton();
139 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
141 GetForm(ob)->RestoreButton();
145 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
147 GetForm(ob)->InputCB(ob, d);