]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormBox.C
Change the semantics of 'none' and 'auto' viewers/editors: 'none' means now
[lyx.git] / src / frontends / xforms / FormBox.C
index 333e6cd927f3d5b275183afeacfd7daa59eda4a0..e9ef91b0e9949d07176a861da3aae79447cc0c81 100644 (file)
@@ -17,7 +17,7 @@
 #include "controllers/ButtonPolicies.h"
 #include "controllers/helper_funcs.h"
 #include "support/lstrings.h"
-#include "support/tostr.h"
+#include "support/convert.h"
 
 #include "Tooltips.h"
 #include "xforms_helpers.h"
 
 #include <vector>
 
-using lyx::support::getStringFromVector;
-using lyx::support::isStrDbl;
-using lyx::support::subst;
 using std::string;
 
+namespace lyx {
+
+using support::getStringFromVector;
+using support::isStrDbl;
+using support::subst;
+
+namespace frontend {
+
 
 typedef FormController<ControlBox, FormView<FD_box> > base_class;
 
 FormBox::FormBox(Dialog & parent)
-       : base_class(parent, _("Box"))
+       : base_class(parent, _("Box Settings"))
 {}
 
 
@@ -54,38 +59,38 @@ void FormBox::build()
        }
 
        string str = _("Frameless: No border\n"
-                      "Boxed: Rectangular\n"
-                      "ovalbox: Oval, thin border\n"
-                      "Ovalbox: Oval, thick border\n"
-                      "Shadowbox: Box casting shadow\n"
-                      "Doublebox: Double line border");
+                      "Boxed: Rectangular\n"
+                      "ovalbox: Oval, thin border\n"
+                      "Ovalbox: Oval, thick border\n"
+                      "Shadowbox: Box casting shadow\n"
+                      "Doublebox: Double line border");
        tooltips().init(dialog_->choice_type, str);
 
        bcview().addReadOnly(dialog_->check_inner_box);
 
        str = _("The inner box may be a parbox or a minipage,\n"
-               "with appropriate arguments from this dialog.");
+               "with appropriate arguments from this dialog.");
        tooltips().init(dialog_->check_inner_box, str);
 
        bcview().addReadOnly(dialog_->radio_parbox);
        bcview().addReadOnly(dialog_->radio_minipage);
 
        bcview().addReadOnly(dialog_->choice_pos);
-       fl_addto_choice(dialog_->choice_pos, _("top").c_str());
-       fl_addto_choice(dialog_->choice_pos, _("middle").c_str());
-       fl_addto_choice(dialog_->choice_pos, _("bottom").c_str());
+       fl_addto_choice(dialog_->choice_pos, _("Top").c_str());
+       fl_addto_choice(dialog_->choice_pos, _("Middle").c_str());
+       fl_addto_choice(dialog_->choice_pos, _("Bottom").c_str());
 
        bcview().addReadOnly(dialog_->choice_inner_pos);
-       fl_addto_choice(dialog_->choice_inner_pos, _("top").c_str());
-       fl_addto_choice(dialog_->choice_inner_pos, _("middle").c_str());
-       fl_addto_choice(dialog_->choice_inner_pos, _("bottom").c_str());
-       fl_addto_choice(dialog_->choice_inner_pos, _("stretch").c_str());
+       fl_addto_choice(dialog_->choice_inner_pos, _("Top").c_str());
+       fl_addto_choice(dialog_->choice_inner_pos, _("Middle").c_str());
+       fl_addto_choice(dialog_->choice_inner_pos, _("Bottom").c_str());
+       fl_addto_choice(dialog_->choice_inner_pos, _("Stretch").c_str());
 
        bcview().addReadOnly(dialog_->choice_hor_pos);
-       fl_addto_choice(dialog_->choice_hor_pos, _("left").c_str());
-       fl_addto_choice(dialog_->choice_hor_pos, _("center").c_str());
-       fl_addto_choice(dialog_->choice_hor_pos, _("right").c_str());
-       fl_addto_choice(dialog_->choice_hor_pos, _("stretch").c_str());
+       fl_addto_choice(dialog_->choice_hor_pos, _("Left").c_str());
+       fl_addto_choice(dialog_->choice_hor_pos, _("Center").c_str());
+       fl_addto_choice(dialog_->choice_hor_pos, _("Right").c_str());
+       fl_addto_choice(dialog_->choice_hor_pos, _("Stretch").c_str());
 
        bcview().addReadOnly(dialog_->input_width);
        bcview().addReadOnly(dialog_->choice_width_unit);
@@ -97,19 +102,19 @@ void FormBox::build()
        }
 
        string choice = getStringFromVector(getLatexUnits(), "|");
-       fl_addto_choice(dialog_->choice_width_unit, 
+       fl_addto_choice(dialog_->choice_width_unit,
                subst(choice, "%", "%%").c_str());
 
        bcview().addReadOnly(dialog_->input_height);
        bcview().addReadOnly(dialog_->choice_height_unit);
        bcview().addReadOnly(dialog_->choice_height_special);
        for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
-               fl_addto_choice(dialog_->choice_height_special, 
+               fl_addto_choice(dialog_->choice_height_special,
                        gui_names_spec_[i].c_str());
        }
 
        choice = getStringFromVector(getLatexUnits(), "|");
-       fl_addto_choice(dialog_->choice_height_unit, 
+       fl_addto_choice(dialog_->choice_height_unit,
                subst(choice, "%", "%%").c_str());
 
        bcview().setOK(dialog_->button_ok);
@@ -146,33 +151,33 @@ void FormBox::update()
        setEnabled(dialog_->radio_minipage, controller().params().inner_box);
 
        LyXLength len(controller().params().width);
-       fl_set_input(dialog_->input_width, tostr(len.value()).c_str());
+       fl_set_input(dialog_->input_width, convert<string>(len.value()).c_str());
        fl_set_choice(dialog_->choice_width_unit, len.unit() + 1);
        string special(controller().params().special);
        for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
                if (special == ids_spec_[i])
-                       fl_set_choice_text(dialog_->choice_special, 
+                       fl_set_choice_text(dialog_->choice_special,
                                gui_names_spec_[i].c_str());
                }
        // Special width unit must be default for general units to be enabled
-       if(controller().params().special != "none")
+       if (controller().params().special != "none")
                setEnabled(dialog_->choice_width_unit, false);
        setEnabled(dialog_->choice_special, !controller().params().inner_box);
 
        LyXLength ht(controller().params().height);
-       fl_set_input(dialog_->input_height, tostr(ht.value()).c_str());
+       fl_set_input(dialog_->input_height, convert<string>(ht.value()).c_str());
        fl_set_choice(dialog_->choice_height_unit, ht.unit() + 1);
        string const height_special(controller().params().height_special);
        for (unsigned int i = 0; i < gui_names_spec_.size(); ++i) {
                if (height_special == ids_spec_[i])
-                       fl_set_choice_text(dialog_->choice_height_special, 
+                       fl_set_choice_text(dialog_->choice_height_special,
                                gui_names_spec_[i].c_str());
                }
        setEnabled(dialog_->input_height, controller().params().inner_box);
        setEnabled(dialog_->choice_height_unit, controller().params().inner_box);
        setEnabled(dialog_->choice_height_special, controller().params().inner_box);
        // Same here
-       if(height_special != "none")
+       if (height_special != "none")
                setEnabled(dialog_->choice_height_unit, false);
 }
 
@@ -183,46 +188,46 @@ void FormBox::apply()
        controller().params().type = ids_[i - 1];
 
        controller().params().inner_box = fl_get_button(dialog_->check_inner_box);
-       controller().params().use_parbox = 
+       controller().params().use_parbox =
                fl_get_button(dialog_->radio_parbox);
        controller().params().width =
                LyXLength(getLengthFromWidgets(dialog_->input_width,
                dialog_->choice_width_unit));
-       
+
        controller().params().pos =
                "tcb"[fl_get_choice(dialog_->choice_pos) - 1];
        controller().params().inner_pos =
                "tcbs"[fl_get_choice(dialog_->choice_inner_pos) - 1];
        controller().params().hor_pos =
                "lcrs"[fl_get_choice(dialog_->choice_hor_pos) - 1];
-       
-       i = fl_get_choice(dialog_->choice_special);     
+
+       i = fl_get_choice(dialog_->choice_special);
        controller().params().special = ids_spec_[i - 1];
-       
+
        controller().params().height =
                LyXLength(getLengthFromWidgets(dialog_->input_height,
                dialog_->choice_height_unit));
-       i = fl_get_choice(dialog_->choice_height_special);      
+       i = fl_get_choice(dialog_->choice_height_special);
        controller().params().height_special = ids_spec_[i - 1];
 }
 
 ButtonPolicy::SMInput FormBox::input(FL_OBJECT * ob, long)
 {
        if (ob == dialog_->check_inner_box) {
-               setEnabled(dialog_->choice_pos, 
+               setEnabled(dialog_->choice_pos,
                        fl_get_button(dialog_->check_inner_box));
-               setEnabled(dialog_->radio_parbox, 
+               setEnabled(dialog_->radio_parbox,
                        fl_get_button(dialog_->check_inner_box));
-               setEnabled(dialog_->radio_minipage, 
+               setEnabled(dialog_->radio_minipage,
                        fl_get_button(dialog_->check_inner_box));
                setEnabled(dialog_->choice_width_unit, true);
-               setEnabled(dialog_->choice_special, 
+               setEnabled(dialog_->choice_special,
                        !fl_get_button(dialog_->check_inner_box));
                setEnabled(dialog_->input_height,
                        fl_get_button(dialog_->check_inner_box));
                setEnabled(dialog_->choice_height_unit,
                        fl_get_button(dialog_->check_inner_box));
-               setEnabled(dialog_->choice_height_special, 
+               setEnabled(dialog_->choice_height_special,
                        fl_get_button(dialog_->check_inner_box));
                setEnabled(dialog_->choice_hor_pos,
                        !fl_get_button(dialog_->check_inner_box));
@@ -237,15 +242,15 @@ ButtonPolicy::SMInput FormBox::input(FL_OBJECT * ob, long)
        }
 
        if (ob == dialog_->choice_special || ob == dialog_->check_inner_box)
-               setEnabled(dialog_->choice_width_unit, 
+               setEnabled(dialog_->choice_width_unit,
                        fl_get_choice(dialog_->choice_special) == NONE);
        if (ob == dialog_->choice_height_special || ob == dialog_->check_inner_box)
                if (fl_get_choice(dialog_->choice_height_special) != NONE)
                    setEnabled(dialog_->choice_height_unit, false);
                else
-                   setEnabled(dialog_->choice_height_unit, 
+                   setEnabled(dialog_->choice_height_unit,
                                fl_get_button(dialog_->check_inner_box));
-       
+
        // An inner box (parbox, minipage) is mandatory if no outer box
        if (ob == dialog_->choice_type) {
                int i = fl_get_choice(dialog_->choice_type);
@@ -261,20 +266,20 @@ ButtonPolicy::SMInput FormBox::input(FL_OBJECT * ob, long)
                string const input = getString(dialog_->input_width);
                bool const invalid = !isValidLength(input) && !isStrDbl(input);
                if (invalid) {
-                       postWarning(_("Invalid Length!"));
+                       postWarning(_("Invalid length!"));
                        return ButtonPolicy::SMI_INVALID;
-               } 
+               }
        }
        if (ob == dialog_->input_height) {
                string const input = getString(dialog_->input_height);
                bool const invalid = !isValidLength(input) && !isStrDbl(input);
                if (invalid) {
-                       postWarning(_("Invalid Length!"));
+                       postWarning(_("Invalid length!"));
                        return ButtonPolicy::SMI_INVALID;
-               } 
+               }
        }
        if (ob == dialog_->button_defaults) {
-               fl_set_button(dialog_->check_inner_box, true);  
+               fl_set_button(dialog_->check_inner_box, true);
                fl_set_button(dialog_->radio_parbox, false);
                fl_set_input(dialog_->input_width, "100");
                fl_set_choice(dialog_->choice_width_unit, LyXLength::PCW + 1);
@@ -282,7 +287,9 @@ ButtonPolicy::SMInput FormBox::input(FL_OBJECT * ob, long)
                fl_set_input(dialog_->input_height, "1");
                fl_set_choice(dialog_->choice_height_special, TOTALHEIGHT);
        }
-       
+
        return ButtonPolicy::SMI_VALID;
 }
 
+} // namespace frontend
+} // namespace lyx