]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBibitem.C
This file is part of LyX, the document processor.
[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 "forms/form_bibitem.h"
21 #include FORMS_H_LOCATION
22 #include "gettext.h"
23 #include "support/lstrings.h" // compare
24
25 typedef FormCB<ControlBibitem, FormDB<FD_bibitem> > base_class;
26
27 FormBibitem::FormBibitem()
28         : base_class(_("Bibliography Entry"))
29 {}
30
31
32 void FormBibitem::build()
33 {
34         dialog_.reset(build_bibitem(this));
35
36         fl_set_input_return(dialog_->input_key,   FL_RETURN_CHANGED);
37         fl_set_input_return(dialog_->input_label, FL_RETURN_CHANGED);
38
39         setPrehandler(dialog_->input_key);
40         setPrehandler(dialog_->input_label);
41
42         // Manage the ok, apply, restore and cancel/close buttons
43         bc().setOK(dialog_->button_ok);
44         bc().setCancel(dialog_->button_close);
45
46         bc().addReadOnly(dialog_->input_key);
47         bc().addReadOnly(dialog_->input_label);
48 }
49
50
51 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
52 {
53         // minimal validation
54         if (!compare(fl_get_input(dialog_->input_key), ""))
55                 return ButtonPolicy::SMI_NOOP;
56
57         return ButtonPolicy::SMI_VALID;
58 }
59
60
61 void FormBibitem::update()
62 {
63         fl_set_input(dialog_->input_key,
64                      controller().params().getContents().c_str());
65         fl_set_input(dialog_->input_label,
66                      controller().params().getOptions().c_str());
67 }
68
69
70 void FormBibitem::apply()
71 {
72         controller().params().setContents(fl_get_input(dialog_->input_key));
73         controller().params().setOptions(fl_get_input(dialog_->input_label));
74 }