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"
26 // The current scheme muddles debugging.
27 // Can we please use some other means to create these functions?
28 // I really don't like to use the preprossessor for this.
29 // My suggestion: First of all move these functions into their own
30 // file (that can be included here if wanted, and use m4 to expand
31 // that file. So create a m4 function to do the expansion, a file
32 // that contains the calls to to this function and a script to run
33 // it and create the C++ file with the expanded functions. (Lgb)
34 // Possible startoff point:
35 // define([C_RETURNCB],[extern "C" int C_$1$2(FL_FORM * ob, void * d) { return $1::$2(ob, d); }])
37 C_RETURNCB (FormBase, WMHideCB)
38 C_GENERICCB(FormBase, ApplyCB)
39 C_GENERICCB(FormBase, OKCB)
40 C_GENERICCB(FormBase, CancelCB)
41 C_GENERICCB(FormBase, InputCB)
42 C_GENERICCB(FormBase, RestoreCB)
45 FormBase::FormBase(LyXView * lv, Dialogs * d, string const & t,
46 ButtonPolicy * bp, char const * close, char const * cancel)
47 : lv_(lv), bc_(bp, cancel, close), d_(d), h_(0), title(t), bp_(bp),
50 Assert(lv && d && bp);
51 Dialogs::redrawGUI.connect(slot(this, &FormBase::redraw));
61 void FormBase::redraw()
63 if( form() && form()->visible )
64 fl_redraw_form( form() );
68 void FormBase::connect()
70 fl_set_form_minsize( form(), minw_, minh_ );
78 fl_set_form_atclose(form(),
79 C_FormBaseWMHideCB, 0);
82 fl_freeze_form( form() );
83 update(); // make sure its up-to-date
84 fl_unfreeze_form( form() );
86 if (form()->visible) {
87 fl_raise_form(form());
89 // calls to fl_set_form_minsize/maxsize apply only to the next
90 // fl_show_form(), so connect() comes first.
93 FL_PLACE_MOUSE | FL_FREE_SIZE,
100 void FormBase::hide()
102 if (form() && form()->visible) {
103 // some dialogs might do things to the form first
104 // such as the nested tabfolder problem in Preferences
106 fl_hide_form(form());
111 int FormBase::WMHideCB(FL_FORM * form, void *)
114 // Ensure that the signals (u and h) are disconnected even if the
115 // window manager is used to close the dialog.
116 FormBase * pre = static_cast<FormBase*>(form->u_vdata);
124 void FormBase::ApplyCB(FL_OBJECT * ob, long)
126 Assert(ob && ob->form);
127 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
134 void FormBase::OKCB(FL_OBJECT * ob, long)
136 Assert(ob && ob->form);
137 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
144 void FormBase::CancelCB(FL_OBJECT * ob, long)
146 Assert(ob && ob->form);
147 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
154 void FormBase::InputCB(FL_OBJECT * ob, long data )
156 Assert(ob && ob->form);
157 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
159 pre->bc_.valid(pre->input(ob, data));
163 void FormBase::RestoreCB(FL_OBJECT * ob, long)
165 Assert(ob && ob->form);
166 FormBase * pre = static_cast<FormBase*>(ob->form->u_vdata);
173 FormBaseBI::FormBaseBI(LyXView * lv, Dialogs * d, string const & t,
175 char const * close, char const * cancel)
176 : FormBase( lv, d, t, bp, close, cancel )
180 void FormBaseBI::connect()
182 h_ = d_->hideAll.connect(slot(this, &FormBaseBI::hide));
187 void FormBaseBI::disconnect()
193 FormBaseBD::FormBaseBD(LyXView * lv, Dialogs * d, string const & t,
195 char const * close, char const * cancel)
196 : FormBase( lv, d, t, bp, close, cancel ),
201 void FormBaseBD::connect()
203 u_ = d_->updateBufferDependent.
204 connect(slot(this, &FormBaseBD::updateSlot));
205 h_ = d_->hideBufferDependent.
206 connect(slot(this, &FormBaseBD::hide));
211 void FormBaseBD::disconnect()