]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreamble.C
Rewrote the maths panel so that ALL the popups now derive from FormBaseBD,
[lyx.git] / src / frontends / xforms / FormPreamble.C
1 /**
2  * \file FormPreamble.C
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  *
6  * \author Edwin Leuven, leuven@fee.uva.nl
7  */
8
9 #include <config.h>
10
11 #include FORMS_H_LOCATION
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "form_preamble.h"
18 #include "FormPreamble.h"
19 #include "Dialogs.h"
20 #include "Liason.h"
21 #include "LyXView.h"
22 #include "buffer.h"
23 #include "gettext.h"
24 #include "xforms_helpers.h"
25
26 using Liason::setMinibuffer;
27 using SigC::slot;
28
29 FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
30         : FormBaseBD(lv, d, _("LaTeX preamble"))
31 {
32     // let the popup be shown
33     // This is a permanent connection so we won't bother
34     // storing a copy because we won't be disconnecting.
35     d->showPreamble.connect(slot(this, &FormPreamble::show));
36 }
37
38
39 FL_FORM * FormPreamble::form() const
40 {
41     if (dialog_.get()) return dialog_->form;
42     return 0;
43 }
44
45
46 void FormPreamble::build()
47 {
48    dialog_.reset(build_preamble());
49    
50    fl_set_input_return(dialog_->input_preamble, FL_RETURN_CHANGED);
51    // Manage the ok, apply and cancel/close buttons
52    bc().setOK(dialog_->button_ok);
53    bc().setApply(dialog_->button_apply);
54    bc().setCancel(dialog_->button_cancel);
55    bc().addReadOnly(dialog_->input_preamble);
56    bc().refresh();
57 }
58
59
60 void FormPreamble::apply()
61 {
62    if (!lv_->view()->available() || !dialog_.get())
63      return;
64    
65    // is this needed?:
66    // lv_->view()->update(BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
67    
68    lv_->buffer()->params.preamble = fl_get_input(dialog_->input_preamble);
69    lv_->buffer()->markDirty();
70    setMinibuffer(lv_, _("LaTeX preamble set"));
71 }
72
73
74 void FormPreamble::update()
75 {
76    if (!dialog_.get())
77      return;
78
79    fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
80
81    bool const enable = (! lv_->buffer()->isReadonly());
82    setEnabled(dialog_->input_preamble, enable);
83    setEnabled(dialog_->button_ok,      enable);
84    setEnabled(dialog_->button_apply,   enable);
85    
86    // need this?
87    // bc().readOnly(lv_->buffer()->isReadonly());
88 }
89
90