]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBibitem.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormBibitem.C
1 /**
2  * \file FormBibitem.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming 
7  * \author John Levon
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifdef __GNUG__
13 #pragma implementation
14 #endif
15
16 #include <config.h>
17 #include "xformsBC.h"
18 #include "ControlBibitem.h"
19 #include "FormBibitem.h"
20 #include "Tooltips.h"
21 #include "forms/form_bibitem.h"
22 #include FORMS_H_LOCATION
23 #include "gettext.h"
24 #include "support/lstrings.h" // compare
25
26 typedef FormCB<ControlBibitem, FormDB<FD_bibitem> > base_class;
27
28 FormBibitem::FormBibitem()
29         : base_class(_("Bibliography Entry"))
30 {}
31
32
33 void FormBibitem::build()
34 {
35         dialog_.reset(build_bibitem(this));
36
37         fl_set_input_return(dialog_->input_key,   FL_RETURN_CHANGED);
38         fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
39
40         setPrehandler(dialog_->input_key);
41         setPrehandler(dialog_->input_label);
42
43         // Manage the ok, apply, restore and cancel/close buttons
44         bc().setOK(dialog_->button_ok);
45         bc().setCancel(dialog_->button_close);
46
47         bc().addReadOnly(dialog_->input_key);
48         bc().addReadOnly(dialog_->input_label);
49
50         // set up the tooltips
51         string str = _("Key used within LyX document.");
52         tooltips().init(dialog_->input_key, str);
53         str = _("Label used for final output.");
54         tooltips().init(dialog_->input_label, str);
55 }
56
57
58 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
59 {
60         // minimal validation
61         if (!compare(fl_get_input(dialog_->input_key), ""))
62                 return ButtonPolicy::SMI_NOOP;
63
64         return ButtonPolicy::SMI_VALID;
65 }
66
67
68 void FormBibitem::update()
69 {
70         fl_set_input(dialog_->input_key,
71                      controller().params().getContents().c_str());
72         fl_set_input(dialog_->input_label,
73                      controller().params().getOptions().c_str());
74 }
75
76
77 void FormBibitem::apply()
78 {
79         controller().params().setContents(fl_get_input(dialog_->input_key));
80         controller().params().setOptions(fl_get_input(dialog_->input_label));
81 }