]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBibitem.C
d23831c7536c46197c375b8f58baf83da0f22611
[lyx.git] / src / frontends / xforms / FormBibitem.C
1 /**
2  * \file FormBibitem.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Angus Leeming
7  * \author John Levon
8  */
9
10 #ifdef __GNUG__
11 #pragma implementation
12 #endif
13
14 #include <config.h>
15 #include "ControlBibitem.h"
16 #include "FormBibitem.h"
17 #include "gettext.h"
18 #include "xformsBC.h"
19 #include "support/lstrings.h" // compare
20
21 FormBibitem::FormBibitem(ControlBibitem & c)
22         : FormBase2<ControlBibitem, FD_form_bibitem>(c, _("Bibliography Entry"))
23 {}
24
25
26 void FormBibitem::build()
27 {
28         dialog_.reset(build_bibitem());
29
30         fl_set_input_return(dialog_->key,   FL_RETURN_CHANGED);
31         fl_set_input_return(dialog_->label, FL_RETURN_CHANGED);
32
33         // Manage the ok, apply, restore and cancel/close buttons
34         bc().setOK(dialog_->button_ok);
35         bc().setCancel(dialog_->button_cancel);
36         bc().refresh();
37
38         bc().addReadOnly(dialog_->key);
39         bc().addReadOnly(dialog_->label);
40 }
41
42
43 ButtonPolicy::SMInput FormBibitem::input(FL_OBJECT *, long)
44 {
45         // minimal validation 
46         if (!compare(fl_get_input(dialog_->key), ""))
47                 return ButtonPolicy::SMI_NOOP;
48
49         return ButtonPolicy::SMI_VALID;
50 }
51
52
53 void FormBibitem::update()
54 {
55         fl_set_input(dialog_->key,
56                      controller().params().getContents().c_str());
57         fl_set_input(dialog_->label,
58                      controller().params().getOptions().c_str());
59 }
60
61
62 void FormBibitem::apply()
63 {
64         controller().params().setContents(fl_get_input(dialog_->key));
65         controller().params().setOptions(fl_get_input(dialog_->label));
66 }