3 * Copyright 2001 The LyX Team.
4 * See the file COPYING.
6 * \author Edwin Leuven, leuven@fee.uva.nl
11 #include FORMS_H_LOCATION
13 #include "form_preamble.h"
14 #include "FormPreamble.h"
21 #ifdef CXX_WORKING_NAMESPACES
22 using Liason::setMinibuffer;
25 FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
26 : FormBaseBD(lv, d, _("LaTeX preamble"), new NoRepeatedApplyReadOnlyPolicy),
29 // let the popup be shown
30 // This is a permanent connection so we won't bother
31 // storing a copy because we won't be disconnecting.
32 d->showPreamble.connect(slot(this, &FormPreamble::show));
36 FormPreamble::~FormPreamble()
42 FL_FORM * FormPreamble::form() const
44 if (dialog_) return dialog_->form;
48 void FormPreamble::build()
50 dialog_ = build_preamble();
51 // Workaround dumb xforms sizing bug
55 fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
56 // Manage the ok, apply and cancel/close buttons
57 bc_.setOK(dialog_->button_ok);
58 bc_.setApply(dialog_->button_apply);
59 bc_.setCancel(dialog_->button_cancel);
60 bc_.addReadOnly(dialog_->input_preamble);
64 void FormPreamble::apply()
66 if (!lv_->view()->available() || !dialog_)
70 // lv_->view()->update(BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
72 lv_->buffer()->params.preamble = fl_get_input(dialog_->input_preamble);
73 lv_->buffer()->markDirty();
74 setMinibuffer(lv_, _("LaTeX preamble set"));
78 void FormPreamble::update()
83 fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
84 if (lv_->buffer()->isReadonly()) {
85 fl_deactivate_object(dialog_->input_preamble);
86 fl_deactivate_object(dialog_->button_ok);
87 fl_deactivate_object(dialog_->button_apply);
88 fl_set_object_lcol(dialog_->button_ok, FL_INACTIVE);
89 fl_set_object_lcol(dialog_->button_apply, FL_INACTIVE);
91 fl_activate_object(dialog_->input_preamble);
92 fl_activate_object(dialog_->button_ok);
93 fl_activate_object(dialog_->button_apply);
94 fl_set_object_lcol(dialog_->button_ok, FL_BLACK);
95 fl_set_object_lcol(dialog_->button_apply, FL_BLACK);
99 // bc_.readOnly(lv_->buffer()->isReadonly());