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