]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormPreamble.C
remove CXX_WORKING_NAMESPACES
[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
28 FormPreamble::FormPreamble(LyXView * lv, Dialogs * d)
29         : FormBaseBD(lv, d, _("LaTeX preamble"))
30 {
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));
35 }
36
37
38 FL_FORM * FormPreamble::form() const
39 {
40     if (dialog_.get()) return dialog_->form;
41     return 0;
42 }
43
44
45 void FormPreamble::build()
46 {
47    dialog_.reset(build_preamble());
48    // Workaround dumb xforms sizing bug
49    minw_ = form()->w;
50    minh_ = form()->h;
51    
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);
58    bc().refresh();
59 }
60
61
62 void FormPreamble::apply()
63 {
64    if (!lv_->view()->available() || !dialog_.get())
65      return;
66    
67    // is this needed?:
68    // lv_->view()->update(BufferView::SELECT | BufferView::FITCUR | BufferView::CHANGE);
69    
70    lv_->buffer()->params.preamble = fl_get_input(dialog_->input_preamble);
71    lv_->buffer()->markDirty();
72    setMinibuffer(lv_, _("LaTeX preamble set"));
73 }
74
75
76 void FormPreamble::update()
77 {
78    if (!dialog_.get())
79      return;
80
81    fl_set_input(dialog_->input_preamble,lv_->buffer()->params.preamble.c_str());
82
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);
87    
88    // need this?
89    // bc().readOnly(lv_->buffer()->isReadonly());
90 }
91
92