2 /* This file is part of
3 * ======================================================
5 * LyX, The Document Processor
7 * Copyright 2000 The LyX Team.
9 * ======================================================
14 #include FORMS_H_LOCATION
17 #pragma implementation
23 #include "xform_macros.h"
24 #include "support/LAssert.h"
27 // The current scheme muddles debugging.
28 // Can we please use some other means to create these functions?
29 // I really don't like to use the preprossessor for this.
30 // My suggestion: First of all move these functions into their own
31 // file (that can be included here if wanted, and use m4 to expand
32 // that file. So create a m4 function to do the expansion, a file
33 // that contains the calls to to this function and a script to run
34 // it and create the C++ file with the expanded functions. (Lgb)
35 // Possible startoff point:
36 // define([C_RETURNCB],[extern "C" int C_$1$2(FL_FORM * ob, void * d) { return $1::$2(ob, d); }])
38 C_RETURNCB (FormBase, WMHideCB)
39 C_GENERICCB(FormBase, ApplyCB)
40 C_GENERICCB(FormBase, OKCB)
41 C_GENERICCB(FormBase, CancelCB)
42 C_GENERICCB(FormBase, InputCB)
43 C_GENERICCB(FormBase, RestoreCB)
46 FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
47 ButtonPolicy * bp, char const * close, char const * cancel)
48 : lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), title(t), bp_(bp),
51 Assert(lv && d && bp);
52 Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
58 //lyxerr << "bp_[" << bp_ << "]" << endl;
63 void FormBase::redraw()
65 if (form() && form()->visible)
66 fl_redraw_form(form());
70 void FormBase::connect()
72 fl_set_form_minsize(form(), minw_, minh_);
80 fl_set_form_atclose(form(),
81 C_FormBaseWMHideCB, 0);
84 fl_freeze_form(form());
85 update(); // make sure its up-to-date
86 fl_unfreeze_form(form());
88 if (form()->visible) {
89 fl_raise_form(form());
91 // calls to fl_set_form_minsize/maxsize apply only to the next
92 // fl_show_form(), so connect() comes first.
95 FL_PLACE_MOUSE | FL_FREE_SIZE,
102 void FormBase::hide()
104 if (form() && form()->visible) {
105 // some dialogs might do things to the form first
106 // such as the nested tabfolder problem in Preferences
108 fl_hide_form(form());
113 int FormBase::WMHideCB(FL_FORM * form, void *)
116 // Ensure that the signals (u and h) are disconnected even if the
117 // window manager is used to close the dialog.
118 FormBase * pre = static_cast<FormBase*>(form->u_vdata);
126 void FormBase::ApplyCB(FL_OBJECT * ob, long)
128 Assert(ob && ob->form);
129 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
136 void FormBase::OKCB(FL_OBJECT * ob, long)
138 Assert(ob && ob->form);
139 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
146 void FormBase::CancelCB(FL_OBJECT * ob, long)
148 Assert(ob && ob->form);
149 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
156 void FormBase::InputCB(FL_OBJECT * ob, long data)
158 Assert(ob && ob->form);
159 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
161 pre->bc_.valid(pre->input(ob, data));
165 void FormBase::RestoreCB(FL_OBJECT * ob, long)
167 Assert(ob && ob->form);
168 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
175 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
177 char const * close, char const * cancel)
178 : FormBase(lv, d, t, bp, close, cancel)
182 void FormBaseBI::connect()
184 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
189 void FormBaseBI::disconnect()
195 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
197 char const * close, char const * cancel)
198 : FormBase(lv, d, t, bp, close, cancel),
203 void FormBaseBD::connect()
205 u_ = d_->updateBufferDependent.
206 connect(slot(this, &FormBaseBD::updateSlot));
207 h_ = d_->hideBufferDependent.
208 connect(slot(this, &FormBaseBD::hide));
213 void FormBaseBD::disconnect()