]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormTabular.C
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[lyx.git] / src / frontends / xforms / FormTabular.C
index 14676f75dce0d9ef3feae71e05ac6fd97b6579d9..9f9afcb501520f081e6bf1bf73cfd94e3d07e92d 100644 (file)
@@ -24,6 +24,7 @@
 #include "insets/insettabular.h"
 #include "buffer.h"
 #include "xforms_helpers.h"
+#include "lyxrc.h" // to set the default length values
 #include "helper_funcs.h"
 #include "input_validators.h"
 #include "support/lstrings.h"
@@ -32,7 +33,7 @@ using SigC::slot;
 
 FormTabular::FormTabular(LyXView * lv, Dialogs * d)
        : FormInset(lv, d, _("Tabular Layout")),
-         inset_(0), actCell_(-1)
+         inset_(0), actCell_(-1), closing_(false)
 {
        // let the dialog be shown
        // This is a permanent connection so we won't bother
@@ -202,9 +203,7 @@ void FormTabular::update()
                        fl_set_button(cell_options_->radio_align_right, 1);
                else
                        fl_set_button(cell_options_->radio_align_center, 1);
-               setEnabled(cell_options_->radio_align_left,   true);
-               setEnabled(cell_options_->radio_align_right,  true);
-               setEnabled(cell_options_->radio_align_center, true);
+
                align = tabular->GetVAlignment(cell);
                fl_set_button(cell_options_->radio_valign_top, 0);
                fl_set_button(cell_options_->radio_valign_bottom, 0);
@@ -215,12 +214,11 @@ void FormTabular::update()
                        fl_set_button(cell_options_->radio_valign_bottom, 1);
                else
                        fl_set_button(cell_options_->radio_valign_top, 1);
-               setEnabled(cell_options_->radio_valign_top,    true);
-               setEnabled(cell_options_->radio_valign_bottom, true);
-               setEnabled(cell_options_->radio_valign_center, true);
+
                special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_MULTI);
                fl_set_input(cell_options_->input_special_multialign, special.c_str());
-               string const default_unit = "cm";
+               bool const metric = lyxrc.default_papersize > 3;
+               string const default_unit = metric ? "cm" : "in";
                updateWidgetsFromLength(cell_options_->input_mcolumn_width,
                                        cell_options_->choice_value_mcolumn_width,
                                        pwidth, default_unit);
@@ -305,7 +303,8 @@ void FormTabular::update()
        setEnabled(column_options_->input_special_alignment, !isReadonly);
 
        pwidth = tabular->GetColumnPWidth(cell);
-       string const default_unit = "cm";
+       bool const metric = lyxrc.default_papersize > 3;
+       string const default_unit = metric ? "cm" : "in";
        updateWidgetsFromLength(column_options_->input_column_width,
                                column_options_->choice_value_column_width,
                                pwidth, default_unit);
@@ -512,20 +511,40 @@ bool FormTabular::input(FL_OBJECT * ob, long)
     if ((ob == column_options_->input_column_width) ||
                (ob == column_options_->choice_value_column_width))
        {
-           string const str =
-                   getLengthFromWidgets(column_options_->input_column_width,
-                                        column_options_->choice_value_column_width);
-        inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+       string const str =
+               getLengthFromWidgets(column_options_->input_column_width,
+                                column_options_->choice_value_column_width);
+               inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+
+       //check if the input is valid
+       string const input =
+                       fl_get_input(column_options_->input_column_width);
+       if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+               fl_set_object_label(dialog_->text_warning,
+                       _("Warning: Invalid Length (valid example: 10mm)"));
+               fl_show_object(dialog_->text_warning);
+               return false;
+       }
         update(); // update for alignment
         return true;
     }
     if ((ob == cell_options_->input_mcolumn_width) ||
                (ob == cell_options_->choice_value_mcolumn_width))
        {
-           string const str =
-                   getLengthFromWidgets(cell_options_->input_mcolumn_width,
-                                        cell_options_->choice_value_mcolumn_width);
-        inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+       string const str =
+               getLengthFromWidgets(cell_options_->input_mcolumn_width,
+                                cell_options_->choice_value_mcolumn_width);
+       inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+
+       //check if the input is valid
+       string const input =
+               fl_get_input(cell_options_->input_mcolumn_width);
+       if (!input.empty() && !isValidLength(input) && !isStrDbl(input)) {
+               fl_set_object_label(dialog_->text_warning,
+                       _("Warning: Invalid Length (valid example: 10mm)"));
+               fl_show_object(dialog_->text_warning);
+               return false;
+       }
         update(); // update for alignment
         return true;
     }