]> git.lyx.org Git - lyx.git/blobdiff - src/TableLayout.C
small changes to ButtonController usage
[lyx.git] / src / TableLayout.C
index 56700481db3234e1bc768e4f1256c76550dc9752..06f3f138fc89c281ade81a961079183c8698a47e 100644 (file)
 #include "vspace.h"
 #include "lyx_gui_misc.h"
 #include "BufferView.h"
-#include "lyxscreen.h"
 #include "gettext.h"
 #include "lyxtext.h"
 #include "layout.h"
-
-extern void BeforeChange();
+#include "insets/lyxinset.h"
 
 // Prototypes
 extern FD_form_table_options * fd_form_table_options;
 extern FD_form_table_extra * fd_form_table_extra;
 extern BufferView * current_view;
 
+#ifndef NEW_TABULAR
 static int Confirmed = false;
 static int ActCell;
 
 // hack to keep the cursor from jumping to the end of the text in the Extra
-// form input fields during editing. The values in LyXTable itself is changed in
-// real-time, but we have no callbacks for the input fields, so I simply
-// store and restore the cursor position for now. (too much of a hazzle to
-// do it proper; we'll trash all this code in 1.1 anyway)
+// form input fields during editing. The values in LyXTable itself is
+// changed in real-time, but we have no callbacks for the input fields,
+// so I simply store and restore the cursor position for now.
+// (too much of a hazzle to do it proper; we'll trash all this code
+// in 1.1 anyway)
 static int extra_col_cursor_x; // need no y's, one-line input fields
 static int extra_multicol_cursor_x;
+#endif
 // Joacim
 
+
 bool UpdateLayoutTable(int flag)
 {
     bool update = true;
-    if (!current_view->getScreen() || !current_view->available())
+    if (!current_view->available())
         update = false;
-    
-    if (update && current_view->buffer()->text->cursor.par->table) {
+
+#ifndef NEW_TABULAR
+    if (update && current_view->text->cursor.par()->table) {
         char buf[12];
         string pwidth, special;
    
-        LyXTable * table = current_view->buffer()->text->cursor.par->table;
+        LyXTable * table = current_view->text->cursor.par()->table;
 
-        int cell = current_view->buffer()->text->
-            NumberOfCell(current_view->buffer()->text->cursor.par
-                         current_view->buffer()->text->cursor.pos);
+        int cell = current_view->text->
+            NumberOfCell(current_view->text->cursor.par()
+                         current_view->text->cursor.pos());
         ActCell = cell;
         int column = table->column_of_cell(cell)+1;
         fl_set_object_label(fd_form_table_options->text_warning, "");
@@ -211,7 +214,9 @@ bool UpdateLayoutTable(int flag)
                      table->RotateTable());
        fl_set_focus_object(fd_form_table_options->form_table_options,
                            fd_form_table_options->button_table_delete);
-    } else if (fd_form_table_options->form_table_options->visible) {
+    } else
+#endif
+           if (fd_form_table_options->form_table_options->visible) {
        fl_set_focus_object(fd_form_table_options->form_table_options,
                            fd_form_table_options->button_table_delete);
         fl_hide_form(fd_form_table_options->form_table_options);
@@ -239,7 +244,6 @@ void OpenLayoutTableExtra()
        }
 }
 
-
 void MenuLayoutTable(int flag)
 {
     if (UpdateLayoutTable(flag)) {
@@ -257,23 +261,19 @@ void MenuLayoutTable(int flag)
 
 void TableOptionsCB(FL_OBJECT * ob, long)
 {
+#ifndef NEW_TABULAR
     LyXTable * table = 0;
-    int
-        s,
-        num = 0;
-    string
-        special,
-        str;
+    int s, num = 0;
+    string special, str;
 
     if (!current_view->available()
-       ||
-       !(table = current_view->buffer()->text->cursor.par->table)) {
+       || !(table = current_view->text->cursor.par()->table)) {
         MenuLayoutTable(0);
        return;
       }
-    int cell = current_view->buffer()->text->
-        NumberOfCell(current_view->buffer()->text->cursor.par
-                     current_view->buffer()->text->cursor.pos);
+    int cell = current_view->text->
+        NumberOfCell(current_view->text->cursor.par()
+                     current_view->text->cursor.pos());
     if (ActCell != cell) {
         MenuLayoutTable(0);
         fl_set_object_label(fd_form_table_options->text_warning,
@@ -283,6 +283,7 @@ void TableOptionsCB(FL_OBJECT * ob, long)
        extra_multicol_cursor_x = 0;
         return;
     }
+
     // No point in processing directives that you can't do anything with
     // anyhow, so exit now if the buffer is read-only.
     if (current_view->buffer()->isReadonly()) {
@@ -422,18 +423,18 @@ void TableOptionsCB(FL_OBJECT * ob, long)
         num = LyXTable::SET_SPECIAL_MULTI;
     } else
         return;
-    if (current_view->available()){
-        current_view->getScreen()->HideCursor();
-        if (!current_view->buffer()->text->selection){
-            BeforeChange(); 
-            current_view->buffer()->update(-2);
+    if (current_view->available()) {
+        current_view->hideCursor();
+        if (!current_view->text->selection){
+            current_view->beforeChange();
+            current_view->update(BufferView::SELECT|BufferView::FITCUR);
         }
         if ((num == LyXTable::SET_SPECIAL_COLUMN) ||
             (num == LyXTable::SET_SPECIAL_MULTI))
-            current_view->buffer()->text->TableFeatures(num, special);
+            current_view->text->TableFeatures(current_view, num, special);
         else
-            current_view->buffer()->text->TableFeatures(num);
-        current_view->buffer()->update(1);
+            current_view->text->TableFeatures(current_view, num);
+        current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
     }
     if (num == LyXTable::DELETE_TABLE) {
        fl_set_focus_object(fd_form_table_options->form_table_options,
@@ -442,8 +443,10 @@ void TableOptionsCB(FL_OBJECT * ob, long)
     } else
         UpdateLayoutTable(true);
     return;
+#endif
 }
 
+
 void TableOptCloseCB(FL_OBJECT *, long)
 {
     fl_set_focus_object(fd_form_table_options->form_table_options,
@@ -460,29 +463,29 @@ void TableSpeCloseCB(FL_OBJECT *, long)
     return;
 }
 
-void SetPWidthCB(FL_OBJECT *ob, long)
+void SetPWidthCB(FL_OBJECT * ob, long)
 {
+#ifndef NEW_TABULAR
     fl_set_object_label(fd_form_table_options->text_warning, "");
     Confirmed = false;
     if (ob == fd_form_table_options->input_column_width) {
-        string
-            str;
-        str = fl_get_input(ob);
+        string str = fl_get_input(ob);
         if (!str.empty() && !isValidLength(str)) {
             fl_set_object_label(fd_form_table_options->text_warning,
-                            _("Warning: Invalid Length (valid example: 10mm)"));
+                           _("Warning: Invalid Length (valid example: 10mm)"));
             fl_show_object(fd_form_table_options->text_warning);
             return;
         }
         if (current_view->available()){
-            current_view->getScreen()->HideCursor();
-            if (!current_view->buffer()->text->selection){
-                BeforeChange(); 
-                current_view->buffer()->update(-2);
+            current_view->hideCursor();
+            if (!current_view->text->selection) {
+                current_view->beforeChange(); 
+                current_view->update(BufferView::SELECT|BufferView::FITCUR);
             }
-            current_view->buffer()->text->TableFeatures(LyXTable::SET_PWIDTH, str);
-            current_view->buffer()->update(1);
+            current_view->text->TableFeatures(current_view, LyXTable::SET_PWIDTH, str);
+            current_view->update(BufferView::SELECT|BufferView::FITCUR|BufferView::CHANGE);
         }
         MenuLayoutTable(0); // update for alignment
     }
+#endif
 }