]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormUrl.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormUrl.C
1 /**
2  * \file xforms/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 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "xformsBC.h"
19 #include "ControlUrl.h"
20 #include "FormUrl.h"
21 #include "forms/form_url.h"
22 #include FORMS_H_LOCATION
23
24 typedef FormCB<ControlUrl, FormDB<FD_url> > base_class;
25
26 FormUrl::FormUrl()
27         : base_class(_("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         bc().setOK(dialog_->button_ok);
43         bc().setApply(dialog_->button_apply);
44         bc().setCancel(dialog_->button_close);
45         bc().setRestore(dialog_->button_restore);
46
47         bc().addReadOnly(dialog_->input_name);
48         bc().addReadOnly(dialog_->input_url);
49         bc().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 }