3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Edwin Leuven, leuven@fee.uva.nl
11 #include FORMS_H_LOCATION
14 #pragma implementation
17 #include "form_preamble.h"
18 #include "FormPreamble.h"
24 #include "xforms_helpers.h"
26 using Liason::setMinibuffer;
28 FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
29 : FormBaseBD(lv, d, _("LaTeX preamble"))
31 // let the popup be shown
32 // This is a permanent connection so we won't bother
33 // storing a copy because we won't be disconnecting.
34 d->showPreamble.connect(slot(this, &FormPreamble::show));
38 FL_FORM * FormPreamble::form() const
40 if (dialog_.get()) return dialog_->form;
45 void FormPreamble::build()
47 dialog_.reset(build_preamble());
48 // Workaround dumb xforms sizing bug
52 fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
53 // Manage the ok, apply and cancel/close buttons
54 bc().setOK(dialog_->button_ok);
55 bc().setApply(dialog_->button_apply);
56 bc().setCancel(dialog_->button_cancel);
57 bc().addReadOnly(dialog_->input_preamble);
62 void FormPreamble::apply()
64 if (!lv_->view()->available() || !dialog_.get())
68 // lv_->view()->update(BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
70 lv_->buffer()->params.preamble = fl_get_input(dialog_->input_preamble);
71 lv_->buffer()->markDirty();
72 setMinibuffer(lv_, _("LaTeX preamble set"));
76 void FormPreamble::update()
81 fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
83 bool const enable = (! lv_->buffer()->isReadonly());
84 setEnabled(dialog_->input_preamble, enable);
85 setEnabled(dialog_->button_ok, enable);
86 setEnabled(dialog_->button_apply, enable);
89 // bc().readOnly(lv_->buffer()->isReadonly());