]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormUrl.C
get rid of broken_header.h and some unneeded tests
[lyx.git] / src / frontends / xforms / FormUrl.C
1 /**
2  * \file FormUrl.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  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "FormUrl.h"
14 #include "ControlCommand.h"
15 #include "forms/form_url.h"
16
17 #include "xformsBC.h"
18
19 #include "lyx_forms.h"
20
21 namespace lyx {
22 namespace frontend {
23
24 typedef  FormController<ControlCommand, FormView<FD_url> > base_class;
25
26 FormUrl::FormUrl(Dialog & parent)
27         : base_class(parent, _("URL"))
28 {}
29
30
31 void FormUrl::build()
32 {
33         dialog_.reset(build_url(this));
34
35         fl_set_input_return(dialog_->input_name, FL_RETURN_CHANGED);
36         fl_set_input_return(dialog_->input_url,  FL_RETURN_CHANGED);
37
38         setPrehandler(dialog_->input_name);
39         setPrehandler(dialog_->input_url);
40
41         // Manage the ok, apply, restore and cancel/close buttons
42         bcview().setOK(dialog_->button_ok);
43         bcview().setApply(dialog_->button_apply);
44         bcview().setCancel(dialog_->button_close);
45         bcview().setRestore(dialog_->button_restore);
46
47         bcview().addReadOnly(dialog_->input_name);
48         bcview().addReadOnly(dialog_->input_url);
49         bcview().addReadOnly(dialog_->check_html);
50 }
51
52
53 void FormUrl::update()
54 {
55         fl_set_input(dialog_->input_url,
56                      controller().params().getContents().c_str());
57         fl_set_input(dialog_->input_name,
58                      controller().params().getOptions().c_str());
59
60         if (controller().params().getCmdName() == "url")
61                 fl_set_button(dialog_->check_html, 0);
62         else
63                 fl_set_button(dialog_->check_html, 1);
64 }
65
66
67 void FormUrl::apply()
68 {
69         controller().params().setContents(fl_get_input(dialog_->input_url));
70         controller().params().setOptions(fl_get_input(dialog_->input_name));
71
72         if (fl_get_button(dialog_->check_html))
73                 controller().params().setCmdName("htmlurl");
74         else
75                 controller().params().setCmdName("url");
76 }
77
78 } // namespace frontend
79 } // namespace lyx