]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormWrap.C
fix dialog titles to match new menus
[lyx.git] / src / frontends / xforms / FormWrap.C
1 /**
2  * \file FormWrap.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Dekel Tsur
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #include "xformsBC.h"
14 #include "ControlWrap.h"
15 #include "FormWrap.h"
16 #include "forms/form_wrap.h"
17 #include "Tooltips.h"
18
19 #include "helper_funcs.h"
20 #include "xforms_helpers.h"
21 #include "checkedwidgets.h"
22
23 #include "insets/insetwrap.h"
24 #include "support/lstrings.h"
25 #include FORMS_H_LOCATION
26
27 typedef FormController<ControlWrap, FormView<FD_wrap> > base_class;
28
29 FormWrap::FormWrap(Dialog & parent)
30         : base_class(parent, _("Text Wrap Settings"))
31 {}
32
33
34 void FormWrap::build()
35 {
36         dialog_.reset(build_wrap(this));
37
38         // Manage the ok, apply and cancel/close buttons
39         bcview().setOK(dialog_->button_ok);
40         bcview().setApply(dialog_->button_apply);
41         bcview().setCancel(dialog_->button_close);
42         bcview().setRestore(dialog_->button_restore);
43
44         // disable for read-only documents
45         bcview().addReadOnly(dialog_->input_width);
46         bcview().addReadOnly(dialog_->choice_width_units);
47
48         // check validity of "length + unit" input
49         addCheckedGlueLength(bcview(), dialog_->input_width);
50
51         // trigger an input event for cut&paste with middle mouse button.
52         setPrehandler(dialog_->input_width);
53
54         fl_set_input_return(dialog_->input_width, FL_RETURN_CHANGED);
55
56         string const choice = getStringFromVector(getLatexUnits(), "|");
57         fl_addto_choice(dialog_->choice_width_units,
58                         subst(choice, "%", "%%").c_str());
59
60         placement_.init(dialog_->radio_default, 0); // default
61         placement_.init(dialog_->radio_outer, 'p');
62         placement_.init(dialog_->radio_left,  'l');
63         placement_.init(dialog_->radio_right, 'r');
64
65         // set up the tooltips
66         string str = _("Enter width for the float.");
67         tooltips().init(dialog_->input_width, str);
68         str = _("Forces float to the right in a paragraph if the page number "
69                 "is odd, and to the left if page number is even.");
70         tooltips().init(dialog_->radio_default, str);
71         str = _("Forces float to the left in a paragraph if the pagenumber "
72                 "is odd, and to the right if page number is even.");
73         tooltips().init(dialog_->radio_outer, str);
74         str = _("Forces float to the left in the paragraph.");
75         tooltips().init(dialog_->radio_left, str);
76         str = _("Forces float to the right in the paragraph.");
77         tooltips().init(dialog_->radio_right, str);
78 }
79
80
81 void FormWrap::apply()
82 {
83         InsetWrapParams & params = controller().params();
84
85         params.width =
86                 LyXLength(getLengthFromWidgets(dialog_->input_width,
87                                                dialog_->choice_width_units));
88
89         char const c = static_cast<char>(placement_.get());
90         if (c)
91                 params.placement = c;
92         else
93                 params.placement.erase(); // default
94 }
95
96
97 void FormWrap::update()
98 {
99         InsetWrapParams const & params = controller().params();
100         LyXLength len(params.width);
101         fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
102         fl_set_choice(dialog_->choice_width_units, len.unit() + 1);
103
104         if (params.placement.empty())
105                 placement_.set(dialog_->radio_default); // default
106         else
107                 placement_.set(params.placement.c_str()[0]);
108 }