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), r_(0), title(t),
49 bp_(bp), minw_(0), minh_(0)
51 Assert(lv && d && bp);
57 //lyxerr << "bp_[" << bp_ << "]" << endl;
62 void FormBase::redraw()
64 if (form() && form()->visible)
65 fl_redraw_form(form());
69 void FormBase::connect()
71 fl_set_form_minsize(form(), minw_, minh_);
72 r_ = Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
76 void FormBase::disconnect()
87 fl_set_form_atclose(form(),
88 C_FormBaseWMHideCB, 0);
91 fl_freeze_form(form());
92 update(); // make sure its up-to-date
93 fl_unfreeze_form(form());
95 if (form()->visible) {
96 fl_raise_form(form());
98 // calls to fl_set_form_minsize/maxsize apply only to the next
99 // fl_show_form(), so connect() comes first.
102 FL_PLACE_MOUSE | FL_FREE_SIZE,
109 void FormBase::hide()
111 if (form() && form()->visible) {
112 // some dialogs might do things to the form first
113 // such as the nested tabfolder problem in Preferences
115 fl_hide_form(form());
120 int FormBase::WMHideCB(FL_FORM * form, void *)
123 // Ensure that the signals (u and h) are disconnected even if the
124 // window manager is used to close the dialog.
125 FormBase * pre = static_cast<FormBase*>(form->u_vdata);
133 void FormBase::ApplyCB(FL_OBJECT * ob, long)
135 Assert(ob && ob->form);
136 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
143 void FormBase::OKCB(FL_OBJECT * ob, long)
145 Assert(ob && ob->form);
146 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
153 void FormBase::CancelCB(FL_OBJECT * ob, long)
155 Assert(ob && ob->form);
156 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
163 void FormBase::InputCB(FL_OBJECT * ob, long data)
165 Assert(ob && ob->form);
166 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
168 pre->bc_.valid(pre->input(ob, data));
172 void FormBase::RestoreCB(FL_OBJECT * ob, long)
174 Assert(ob && ob->form);
175 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
182 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
184 char const * close, char const * cancel)
185 : FormBase(lv, d, t, bp, close, cancel)
189 void FormBaseBI::connect()
191 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
196 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
198 char const * close, char const * cancel)
199 : FormBase(lv, d, t, bp, close, cancel),
204 void FormBaseBD::connect()
206 u_ = d_->updateBufferDependent.
207 connect(slot(this, &FormBaseBD::updateSlot));
208 h_ = d_->hideBufferDependent.
209 connect(slot(this, &FormBaseBD::hide));
214 void FormBaseBD::disconnect()
217 FormBase::disconnect();