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)
28 : ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
32 void FormBase::redraw()
34 if (form() && form()->visible)
35 fl_redraw_form(form());
46 // work around dumb xforms sizing bug
50 fl_set_form_atclose(form(), 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 lyx::Assert(ob && ob->form && ob->form->u_vdata);
103 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
111 int C_FormBaseWMHideCB(FL_FORM * form, void *)
113 // Close the dialog cleanly, even if the WM is used to do so.
114 lyx::Assert(form && form->u_vdata);
115 FormBase * pre = static_cast<FormBase *>(form->u_vdata);
121 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
123 GetForm(ob)->ApplyButton();
127 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
129 GetForm(ob)->OKButton();
133 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
135 FormBase * form = GetForm(ob);
136 form->CancelButton();
140 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
142 GetForm(ob)->RestoreButton();
146 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
148 GetForm(ob)->InputCB(ob, d);