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