2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
15 #pragma implementation
21 #include "support/LAssert.h"
23 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
26 FormBase::FormBase(ControlBase & c, string const & t)
27 : ViewBC<xformsBC>(c), minw_(0), minh_(0), title_(t)
31 void FormBase::redraw()
33 if (form() && form()->visible)
34 fl_redraw_form(form());
42 fl_set_form_atclose(form(),
43 C_FormBaseWMHideCB, 0);
46 fl_freeze_form(form());
47 update(); // make sure its up-to-date
48 fl_unfreeze_form(form());
50 if (form()->visible) {
51 fl_raise_form(form());
52 /* This XMapWindow() will hopefully ensure that
53 * iconified dialogs are de-iconified. Mad props
54 * out to those crazy Xlib guys for forgetting a
55 * XDeiconifyWindow(). At least WindowMaker, when
56 * being notified of the redirected MapRequest will
57 * specifically de-iconify. From source, fvwm2 seems
60 XMapWindow(fl_get_display(), form()->window);
62 // calls to fl_set_form_minsize/maxsize apply only to the next
63 // fl_show_form(), so this comes first.
64 fl_set_form_minsize(form(), minw_, minh_);
66 FL_PLACE_MOUSE | FL_FREE_SIZE, 0,
74 if (form() && form()->visible)
79 void FormBase::InputCB(FL_OBJECT * ob, long data)
81 bc().input(input(ob, data));
85 static FormBase * GetForm(FL_OBJECT * ob)
87 Assert(ob && ob->form && ob->form->u_vdata);
88 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
93 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *)
95 // Close the dialog cleanly, even if the WM is used to do so.
96 Assert(form && form->u_vdata);
97 FormBase * pre = static_cast<FormBase *>(form->u_vdata);
103 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
105 GetForm(ob)->ApplyButton();
109 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
111 GetForm(ob)->OKButton();
115 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
117 FormBase * form = GetForm(ob);
118 form->CancelButton();
122 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
124 GetForm(ob)->RestoreButton();
128 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
130 GetForm(ob)->InputCB(ob, d);