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 // Callback function invoked by xforms when the dialog is closed by the
26 extern "C" int C_FormBaseWMHideCB(FL_FORM * form, void *);
28 // To trigger an input event when pasting in an xforms input object
29 // using the middle mouse button.
30 extern "C" int C_CutandPastePH(FL_OBJECT *, int, FL_Coord, FL_Coord,
34 FormBase::FormBase(ControlButtons & c, string const & t, bool allowResize)
35 : ViewBC<xformsBC>(c), minw_(0), minh_(0), allow_resize_(allowResize),
40 void FormBase::redraw()
42 if (form() && form()->visible)
43 fl_redraw_form(form());
53 // use minw_ to flag whether the dialog has ever been shown
54 // (Needed now that build() is/should be called from the controller)
58 // work around dumb xforms sizing bug
62 fl_set_form_atclose(form(), C_FormBaseWMHideCB, 0);
65 fl_freeze_form(form());
66 update(); // make sure its up-to-date
67 fl_unfreeze_form(form());
69 if (form()->visible) {
70 fl_raise_form(form());
71 /* This XMapWindow() will hopefully ensure that
72 * iconified dialogs are de-iconified. Mad props
73 * out to those crazy Xlib guys for forgetting a
74 * XDeiconifyWindow(). At least WindowMaker, when
75 * being notified of the redirected MapRequest will
76 * specifically de-iconify. From source, fvwm2 seems
79 XMapWindow(fl_get_display(), form()->window);
81 // calls to fl_set_form_minsize/maxsize apply only to the next
82 // fl_show_form(), so this comes first.
83 fl_set_form_minsize(form(), minw_, minh_);
85 fl_set_form_maxsize(form(), minw_, minh_);
88 FL_PLACE_MOUSE | FL_FREE_SIZE,
89 (controller_.IconifyWithMain() ? FL_TRANSIENT : 0),
97 if (form() && form()->visible)
102 void FormBase::InputCB(FL_OBJECT * ob, long data)
104 bc().input(input(ob, data));
108 ButtonPolicy::SMInput FormBase::input(FL_OBJECT *, long)
110 return ButtonPolicy::SMI_VALID;
116 FormBase * GetForm(FL_OBJECT * ob)
118 lyx::Assert(ob && ob->form && ob->form->u_vdata);
119 FormBase * pre = static_cast<FormBase *>(ob->form->u_vdata);
127 int C_FormBaseWMHideCB(FL_FORM * form, void *)
129 // Close the dialog cleanly, even if the WM is used to do so.
130 lyx::Assert(form && form->u_vdata);
131 FormBase * pre = static_cast<FormBase *>(form->u_vdata);
137 extern "C" void C_FormBaseApplyCB(FL_OBJECT * ob, long)
139 GetForm(ob)->ApplyButton();
143 extern "C" void C_FormBaseOKCB(FL_OBJECT * ob, long)
145 GetForm(ob)->OKButton();
149 extern "C" void C_FormBaseCancelCB(FL_OBJECT * ob, long)
151 FormBase * form = GetForm(ob);
152 form->CancelButton();
156 extern "C" void C_FormBaseRestoreCB(FL_OBJECT * ob, long)
158 GetForm(ob)->RestoreButton();
162 extern "C" void C_FormBaseInputCB(FL_OBJECT * ob, long d)
164 GetForm(ob)->InputCB(ob, d);
168 // To trigger an input event when pasting in an xforms input object
169 // using the middle mouse button.
170 extern "C" int C_CutandPastePH(FL_OBJECT * ob, int event,
171 FL_Coord, FL_Coord, int key, void *)
173 if ((event == FL_PUSH) && (key == 2) && (ob->objclass == FL_INPUT)) {
174 C_FormBaseInputCB(ob, 0);