]> git.lyx.org Git - lyx.git/blobdiff - src/frontends/xforms/FormTabular.C
Yet more dialog tweaking from Rob.
[lyx.git] / src / frontends / xforms / FormTabular.C
index 60150d2cc3ba8eb62cba48bf6744da040aafb58e..2056abebacafcd45f70212740b70d2aa6cfc2fd9 100644 (file)
@@ -1,9 +1,11 @@
 /**
  * \file FormTabular.C
- * Copyright 2000-2001 The LyX Team.
- * See the file COPYING.
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
  *
- * \author Jürgen Vigna, jug@sad.it
+ * \author Jürgen Vigna
+ *
+ * Full author contact details are available in file CREDITS
  */
 
 #include <config.h>
@@ -17,7 +19,6 @@
 #include "FormTabular.h"
 #include "forms/form_tabular.h"
 #include "frontends/LyXView.h"
-#include "Dialogs.h"
 #include "buffer.h"
 #include "xforms_helpers.h"
 #include "lyxrc.h" // to set the default length values
@@ -40,16 +41,9 @@ using std::remove_if;
 
 
 FormTabular::FormTabular(LyXView & lv, Dialogs & d)
-       : FormInset(&lv, &d, _("Tabular Layout")),
+       : FormInset(lv, d, _("Tabular Layout")),
          inset_(0), actCell_(-1), closing_(false)
 {
-#if 0
-       // let the dialog be shown
-       // This is a permanent connection so we won't bother
-       // storing a copy because we won't be disconnecting.
-       d->showTabular = boost::bind(&FormTabular::showInset, this, _1);
-       d->updateTabular = boost::bind(&FormTabular::updateInset, this, _1);
-#endif
 }
 
 
@@ -154,18 +148,10 @@ void FormTabular::build()
        // Create the contents of the unit choices
        // Don't include the "%" terms...
        vector<string> units_vec = getLatexUnits();
-#if 0
-       for (vector<string>::iterator it = units_vec.begin();
-            it != units_vec.end(); ++it) {
-               if (contains(*it, "%"))
-                       it = units_vec.erase(it, it + 1) - 1;
-       }
-#else
        vector<string>::iterator ret =
                remove_if(units_vec.begin(), units_vec.end(),
                          bind2nd(contains_functor(), "%"));
        units_vec.erase(ret, units_vec.end());
-#endif
 
        string units = getStringFromVector(units_vec, "|");
 
@@ -236,7 +222,7 @@ void FormTabular::update()
                }
                pwidth = tabular->GetMColumnPWidth(cell);
                align = tabular->GetAlignment(cell);
-               if (!pwidth.zero() || (align == LYX_ALIGN_LEFT))
+               if (align == LYX_ALIGN_LEFT)
                        fl_set_button(cell_options_->radio_align_left, 1);
                else if (align == LYX_ALIGN_RIGHT)
                        fl_set_button(cell_options_->radio_align_right, 1);
@@ -262,7 +248,7 @@ void FormTabular::update()
                                        cell_options_->choice_value_mcolumn_width,
                                        pwidth, default_unit);
 
-               if (!lv_->buffer()->isReadonly()) {
+               if (!lv_.buffer()->isReadonly()) {
                        setEnabled(cell_options_->input_special_multialign, true);
                        setEnabled(cell_options_->input_mcolumn_width, true);
                        setEnabled(cell_options_->choice_value_mcolumn_width, true);
@@ -272,9 +258,9 @@ void FormTabular::update()
                setEnabled(cell_options_->radio_valign_bottom, !pwidth.zero());
                setEnabled(cell_options_->radio_valign_center, !pwidth.zero());
 
-               setEnabled(cell_options_->radio_align_left,   pwidth.zero());
-               setEnabled(cell_options_->radio_align_right,  pwidth.zero());
-               setEnabled(cell_options_->radio_align_center, pwidth.zero());
+               setEnabled(cell_options_->radio_align_left,   true);
+               setEnabled(cell_options_->radio_align_right,  true);
+               setEnabled(cell_options_->radio_align_center, true);
        } else {
                fl_set_button(cell_options_->check_multicolumn, 0);
 
@@ -338,7 +324,7 @@ void FormTabular::update()
        special = tabular->GetAlignSpecial(cell, LyXTabular::SET_SPECIAL_COLUMN);
        fl_set_input(column_options_->input_special_alignment, special.c_str());
 
-       bool const isReadonly = lv_->buffer()->isReadonly();
+       bool const isReadonly = lv_.buffer()->isReadonly();
        setEnabled(column_options_->input_special_alignment, !isReadonly);
 
        pwidth = tabular->GetColumnPWidth(cell);
@@ -363,7 +349,7 @@ void FormTabular::update()
        fl_set_button(column_options_->radio_align_left, 0);
        fl_set_button(column_options_->radio_align_right, 0);
        fl_set_button(column_options_->radio_align_center, 0);
-       if (!pwidth.zero() || (align == LYX_ALIGN_LEFT))
+       if (align == LYX_ALIGN_LEFT)
                fl_set_button(column_options_->radio_align_left, 1);
        else if (align == LYX_ALIGN_RIGHT)
                fl_set_button(column_options_->radio_align_right, 1);
@@ -380,10 +366,9 @@ void FormTabular::update()
        else
                fl_set_button(column_options_->radio_valign_top, 1);
 
-       setEnabled(column_options_->radio_align_left,   pwidth.zero());
-       setEnabled(column_options_->radio_align_right,  pwidth.zero());
-       setEnabled(column_options_->radio_align_center, pwidth.zero());
-
+       setEnabled(column_options_->radio_align_left,   true);
+       setEnabled(column_options_->radio_align_right,  true);
+       setEnabled(column_options_->radio_align_center, true);
        setEnabled(column_options_->radio_valign_top,    !pwidth.zero());
        setEnabled(column_options_->radio_valign_bottom, !pwidth.zero());
        setEnabled(column_options_->radio_valign_center, !pwidth.zero());
@@ -564,7 +549,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
        }
        // No point in processing directives that you can't do anything with
        // anyhow, so exit now if the buffer is read-only.
-       if (lv_->buffer()->isReadonly()) {
+       if (lv_.buffer()->isReadonly()) {
                update();
                return false;
        }
@@ -573,7 +558,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
                string const str =
                        getLengthFromWidgets(column_options_->input_column_width,
                                             column_options_->choice_value_column_width);
-               inset_->tabularFeatures(lv_->view(), LyXTabular::SET_PWIDTH, str);
+               inset_->tabularFeatures(lv_.view().get(), LyXTabular::SET_PWIDTH, str);
 
                //check if the input is valid
                string const input =
@@ -592,7 +577,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
                string const str =
                        getLengthFromWidgets(cell_options_->input_mcolumn_width,
                                             cell_options_->choice_value_mcolumn_width);
-               inset_->tabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH, str);
+               inset_->tabularFeatures(lv_.view().get(), LyXTabular::SET_MPWIDTH, str);
 
                //check if the input is valid
                string const input =
@@ -705,7 +690,7 @@ bool FormTabular::input(FL_OBJECT * ob, long)
        else
                return false;
 
-       inset_->tabularFeatures(lv_->view(), num, special);
+       inset_->tabularFeatures(lv_.view().get(), num, special);
        update();
 
        return true;