Re: setting lines in tables
On Sunday 16 March 2008 15:57:28 Edwin Leuven wrote: comments welcome Consistency is a nice word and I like it. :-) I like the idea of the patch although I have not tested it. -- José Abílio
Re: setting lines in tables
On Sunday 16 March 2008 15:57:28 Edwin Leuven wrote: > > comments welcome Consistency is a nice word and I like it. :-) I like the idea of the patch although I have not tested it. -- José Abílio
Re: setting lines in tables
Jürgen Spitzmüller wrote: the lyx2lyx part needs to be done though... yes. attached patch included the lyx2lyx part comments welcome Index: development/FORMAT === --- development/FORMAT (revision 23774) +++ development/FORMAT (working copy) @@ -1,6 +1,9 @@ LyX file-format changes --- +2008-03-15 Edwin Leuven [EMAIL PROTECTED] + * Format incremented to 319: ensure consistency between cell and row/col lines + 2008-03-09 Bo Peng [EMAIL PROTECTED] * Format incremented to 318: add \extra_embedded_files to buffer params @@ -953,3 +956,4 @@ \end_inset + Index: lib/lyx2lyx/LyX.py === --- lib/lyx2lyx/LyX.py (revision 23774) +++ lib/lyx2lyx/LyX.py (working copy) @@ -80,7 +80,7 @@ (1_3, [221], minor_versions(1.3 , 7)), (1_4, range(222,246), minor_versions(1.4 , 5)), (1_5, range(246,277), minor_versions(1.5 , 2)), - (1_6, range(277,319), minor_versions(1.6 , 0))] + (1_6, range(277,320), minor_versions(1.6 , 0))] def formats_list(): Index: lib/lyx2lyx/lyx_1_6.py === --- lib/lyx2lyx/lyx_1_6.py (revision 23774) +++ lib/lyx2lyx/lyx_1_6.py (working copy) @@ -47,6 +47,154 @@ +def get_option(document, m, option, default): +l = document.body[m].find(option) +val = default +if l != -1: +val = document.body[m][l:].split('')[1] +return val + +def remove_option(document, m, option): +l = document.body[m].find(option) +if l != -1: +val = document.body[m][l:].split('')[1] +document.body[m] = document.body[m][:l-1] + document.body[m][l+len(option + '=' + val + ''):] +return l + +def set_option(document, m, option, value): +l = document.body[m].find(option) +if l != -1: +oldval = document.body[m][l:].split('')[1] +l = l + len(option + '=') +document.body[m] = document.body[m][:l] + value + document.body[m][l+len(oldval):] +else: +document.body[m] = document.body[m][:-1] + ' ' + option + '=' + value + '' +return l + +def convert_tablines(document): +i = 0 +while True: +i = find_token(document.body, \\begin_inset Tabular, i) +if i == -1: +return +j = find_end_of_inset(document.body, i + 1) +if j == -1: +document.warning(Malformed LyX document: Could not find end of tabular.) +continue + +m = i + 1 +nrows = int(document.body[i+1].split('')[3]) +ncols = int(document.body[i+1].split('')[5]) + +col_info = [] +for k in range(ncols): +m = find_token(document.body, column, m) +left = get_option(document, m, 'leftline', 'false') +right = get_option(document, m, 'rightline', 'false') +col_info.append([left, right]) +remove_option(document, m, 'leftline') +remove_option(document, m, 'rightline') +m = m + 1 + +row_info = [] +for k in range(nrows): +m = find_token(document.body, row, m) +top = get_option(document, m, 'topline', 'false') +bottom = get_option(document, m, 'bottomline', 'false') +row_info.append([top, bottom]) +remove_option(document, m, 'topline') +remove_option(document, m, 'bottomline') +m = m + 1 + +m = i + 1 +mc_info = [] +for k in range(nrows*ncols): +m = find_token(document.body, cell, m) +mc_info.append(get_option(document, m, 'multicolumn', '0')) +m = m + 1 +m = i + 1 +for l in range(nrows): +for k in range(ncols): +m = find_token(document.body, 'cell', m) +if mc_info[l*ncols + k] == '0': +r = set_option(document, m, 'topline', row_info[l][0]) +r = set_option(document, m, 'bottomline', row_info[l][1]) +r = set_option(document, m, 'leftline', col_info[k][0]) +r = set_option(document, m, 'rightline', col_info[k][1]) + +if mc_info[l*ncols + k] != '0' and l == 0: +r = set_option(document, m, 'topline', row_info[l][0]) + +if mc_info[l*ncols + k] != '0' and l == nrows - 1: +r = set_option(document, m, 'bottomline', row_info[l][1]) + +m = m + 1 +i = j + 1 + + +def revert_tablines(document): +i = 0 +while True: +i = find_token(document.body, \\begin_inset Tabular, i) +if i == -1: +return +j = find_end_of_inset(document.body, i + 1) +if j == -1: +
Re: setting lines in tables
Jürgen Spitzmüller wrote: the lyx2lyx part needs to be done though... yes. attached patch included the lyx2lyx part comments welcome Index: development/FORMAT === --- development/FORMAT (revision 23774) +++ development/FORMAT (working copy) @@ -1,6 +1,9 @@ LyX file-format changes --- +2008-03-15 Edwin Leuven <[EMAIL PROTECTED]> + * Format incremented to 319: ensure consistency between cell and row/col lines + 2008-03-09 Bo Peng <[EMAIL PROTECTED]> * Format incremented to 318: add \extra_embedded_files to buffer params @@ -953,3 +956,4 @@ \end_inset + Index: lib/lyx2lyx/LyX.py === --- lib/lyx2lyx/LyX.py (revision 23774) +++ lib/lyx2lyx/LyX.py (working copy) @@ -80,7 +80,7 @@ ("1_3", [221], minor_versions("1.3" , 7)), ("1_4", range(222,246), minor_versions("1.4" , 5)), ("1_5", range(246,277), minor_versions("1.5" , 2)), - ("1_6", range(277,319), minor_versions("1.6" , 0))] + ("1_6", range(277,320), minor_versions("1.6" , 0))] def formats_list(): Index: lib/lyx2lyx/lyx_1_6.py === --- lib/lyx2lyx/lyx_1_6.py (revision 23774) +++ lib/lyx2lyx/lyx_1_6.py (working copy) @@ -47,6 +47,154 @@ +def get_option(document, m, option, default): +l = document.body[m].find(option) +val = default +if l != -1: +val = document.body[m][l:].split('"')[1] +return val + +def remove_option(document, m, option): +l = document.body[m].find(option) +if l != -1: +val = document.body[m][l:].split('"')[1] +document.body[m] = document.body[m][:l-1] + document.body[m][l+len(option + '="' + val + '"'):] +return l + +def set_option(document, m, option, value): +l = document.body[m].find(option) +if l != -1: +oldval = document.body[m][l:].split('"')[1] +l = l + len(option + '="') +document.body[m] = document.body[m][:l] + value + document.body[m][l+len(oldval):] +else: +document.body[m] = document.body[m][:-1] + ' ' + option + '="' + value + '">' +return l + +def convert_tablines(document): +i = 0 +while True: +i = find_token(document.body, "\\begin_inset Tabular", i) +if i == -1: +return +j = find_end_of_inset(document.body, i + 1) +if j == -1: +document.warning("Malformed LyX document: Could not find end of tabular.") +continue + +m = i + 1 +nrows = int(document.body[i+1].split('"')[3]) +ncols = int(document.body[i+1].split('"')[5]) + +col_info = [] +for k in range(ncols): +m = find_token(document.body, "
Re: setting lines in tables
latest version attached this would imply a format change because current cell and row/col lines are not consistent unfortunately i don't know any python and was wondering whether someone could give me a hand? the logic would be the following: get col line settings get row line settings don't write col + row line settings foreach (cell) if !cell.multicol cell.topline = row.topline cell.bottomline = row.bottomline if !cell.multicol || (cell.multicol !nextcell.multicol) cell.rightline = col.rightline if !cell.multicol || (cell.multicol !prevcell.multicol) cell.leftline = col.leftline edwin Index: development/FORMAT === --- development/FORMAT (revision 23764) +++ development/FORMAT (working copy) @@ -1,6 +1,9 @@ LyX file-format changes --- +2008-03-15 Edwin Leuven [EMAIL PROTECTED] + * Format incremented to 319: ensure consistency between cell and row/col lines + 2008-03-09 Bo Peng [EMAIL PROTECTED] * Format incremented to 318: add \extra_embedded_files to buffer params @@ -953,3 +956,4 @@ \end_inset + Index: lib/lyx2lyx/LyX.py === --- lib/lyx2lyx/LyX.py (revision 23764) +++ lib/lyx2lyx/LyX.py (working copy) @@ -80,7 +80,7 @@ (1_3, [221], minor_versions(1.3 , 7)), (1_4, range(222,246), minor_versions(1.4 , 5)), (1_5, range(246,277), minor_versions(1.5 , 2)), - (1_6, range(277,319), minor_versions(1.6 , 0))] + (1_6, range(277,320), minor_versions(1.6 , 0))] def formats_list(): Index: lib/lyx2lyx/lyx_1_6.py === --- lib/lyx2lyx/lyx_1_6.py (revision 23764) +++ lib/lyx2lyx/lyx_1_6.py (working copy) @@ -47,6 +47,10 @@ +def convert_tablines(document): +return + + def fix_wrong_tables(document): i = 0 while True: @@ -1435,9 +1439,11 @@ [316, [convert_subfig]], [317, []], [318, []], + [319, [convert_tablines]], ] -revert = [[317, [remove_extra_embedded_files]], +revert = [[318, []], + [317, [remove_extra_embedded_files]], [316, [revert_wrapplacement]], [315, [revert_subfig]], [314, [revert_colsep]], Index: src/Buffer.cpp === --- src/Buffer.cpp (revision 23764) +++ src/Buffer.cpp (working copy) @@ -116,7 +116,7 @@ namespace { -int const LYX_FORMAT = 318; +int const LYX_FORMAT = 319; typedef mapstring, bool DepClean; typedef mapdocstring, pairInsetLabel const *, Buffer::References RefCache; Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23764) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders-setLeftEnabled(true); - borders-setRightEnabled(true); - borders-setTop(tabular_.topLine(cell, true)); - borders-setBottom(tabular_.bottomLine(cell, true)); - borders-setLeft(tabular_.leftLine(cell, true)); - borders-setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders-update(); - return; - } - borders-setTop(tabular_.topLine(cell)); borders-setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders-setLeftEnabled(true); - borders-setLeft(tabular_.leftLine(cell)); - } else { - borders-setLeft(false); - borders-setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders-setRightEnabled(true); - borders-setRight(tabular_.rightLine(cell)); - } else { - borders-setRight(false); - borders-setRightEnabled(false); - } + borders-setLeft(tabular_.leftLine(cell)); +
Re: setting lines in tables
Edwin Leuven wrote: any objections if i apply the attached? I think you shouldn't change the default settings of the lines. Jürgen
Re: setting lines in tables
Jürgen Spitzmüller wrote: I think you shouldn't change the default settings of the lines. fixed in attached. the lyx2lyx part needs to be done though... Index: intl/localename.c === --- intl/localename.c (revision 23764) +++ intl/localename.c (working copy) @@ -1357,7 +1357,6 @@ switch (sub) { case SUBLANG_PUNJABI_INDIA: return pa_IN; /* Gurmukhi script */ - case SUBLANG_PUNJABI_PAKISTAN: return pa_PK; /* Arabic script */ } return pa; case LANG_RHAETO_ROMANCE: return rm_CH; @@ -1365,7 +1364,6 @@ switch (sub) { case SUBLANG_ROMANIAN_ROMANIA: return ro_RO; - case SUBLANG_ROMANIAN_MOLDOVA: return ro_MD; } return ro; case LANG_RUSSIAN:
Re: setting lines in tables
Edwin Leuven wrote: fixed in attached. really? the lyx2lyx part needs to be done though... yes. Jürgen
Re: setting lines in tables
Jürgen Spitzmüller wrote: Edwin Leuven wrote: fixed in attached. really? ahum Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23764) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders-setLeftEnabled(true); - borders-setRightEnabled(true); - borders-setTop(tabular_.topLine(cell, true)); - borders-setBottom(tabular_.bottomLine(cell, true)); - borders-setLeft(tabular_.leftLine(cell, true)); - borders-setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders-update(); - return; - } - borders-setTop(tabular_.topLine(cell)); borders-setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders-setLeftEnabled(true); - borders-setLeft(tabular_.leftLine(cell)); - } else { - borders-setLeft(false); - borders-setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders-setRightEnabled(true); - borders-setRight(tabular_.rightLine(cell)); - } else { - borders-setRight(false); - borders-setRightEnabled(false); - } + borders-setLeft(tabular_.leftLine(cell)); + borders-setRight(tabular_.rightLine(cell)); // repaint the setborder widget borders-update(); } @@ -988,42 +959,6 @@ } -void GuiTabular::toggleTopLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_TOP); - else - set(Tabular::TOGGLE_LINE_TOP); -} - - -void GuiTabular::toggleBottomLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_BOTTOM); - else - set(Tabular::TOGGLE_LINE_BOTTOM); -} - - -void GuiTabular::toggleLeftLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_LEFT); - else - set(Tabular::TOGGLE_LINE_LEFT); -} - - -void GuiTabular::toggleRightLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_RIGHT); - else - set(Tabular::TOGGLE_LINE_RIGHT); -} - - void GuiTabular::setSpecial(string const special) { if (tabular_.isMultiColumn(getActiveCell())) Index: src/frontends/qt4/GuiTabular.h === --- src/frontends/qt4/GuiTabular.h (revision 23764) +++ src/frontends/qt4/GuiTabular.h (working copy) @@ -95,12 +95,6 @@ /// set a parameter void set(Tabular::Feature, std::string const arg = std::string()); - /// borders - void toggleTopLine(); - void toggleBottomLine(); - void toggleLeftLine(); - void toggleRightLine(); - void setSpecial(std::string const special); void setWidth(std::string const width); Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23764) +++ src/insets/InsetTabular.cpp (working copy) @@ -86,10 +86,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -121,10 +121,6 @@ { Tabular::VALIGN_TOP, valign-top }, { Tabular::VALIGN_BOTTOM, valign-bottom }, { Tabular::VALIGN_MIDDLE, valign-middle }, - { Tabular::M_TOGGLE_LINE_TOP, m-toggle-line-top }, - { Tabular::M_TOGGLE_LINE_BOTTOM, m-toggle-line-bottom }, - { Tabular::M_TOGGLE_LINE_LEFT, m-toggle-line-left }, - { Tabular::M_TOGGLE_LINE_RIGHT, m-toggle-line-right }, { Tabular::M_ALIGN_LEFT, m-align-left }, { Tabular::M_ALIGN_RIGHT, m-align-right }, { Tabular::M_ALIGN_CENTER, m-align-center }, @@ -479,9 +475,9 @@ multicolumn(Tabular::CELL_NORMAL), alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - top_line(true), + top_line(false), bottom_line(false), - left_line(true), + left_line(false), right_line(false), usebox(BOX_NONE), rotate(false), @@ -539,8 +535,6 @@
Re: setting lines in tables
latest version attached this would imply a format change because current cell and row/col lines are not consistent unfortunately i don't know any python and was wondering whether someone could give me a hand? the logic would be the following: get col line settings get row line settings don't write col + row line settings foreach (cell) if !cell.multicol cell.topline = row.topline cell.bottomline = row.bottomline if !cell.multicol || (cell.multicol && !nextcell.multicol) cell.rightline = col.rightline if !cell.multicol || (cell.multicol && !prevcell.multicol) cell.leftline = col.leftline edwin Index: development/FORMAT === --- development/FORMAT (revision 23764) +++ development/FORMAT (working copy) @@ -1,6 +1,9 @@ LyX file-format changes --- +2008-03-15 Edwin Leuven <[EMAIL PROTECTED]> + * Format incremented to 319: ensure consistency between cell and row/col lines + 2008-03-09 Bo Peng <[EMAIL PROTECTED]> * Format incremented to 318: add \extra_embedded_files to buffer params @@ -953,3 +956,4 @@ \end_inset + Index: lib/lyx2lyx/LyX.py === --- lib/lyx2lyx/LyX.py (revision 23764) +++ lib/lyx2lyx/LyX.py (working copy) @@ -80,7 +80,7 @@ ("1_3", [221], minor_versions("1.3" , 7)), ("1_4", range(222,246), minor_versions("1.4" , 5)), ("1_5", range(246,277), minor_versions("1.5" , 2)), - ("1_6", range(277,319), minor_versions("1.6" , 0))] + ("1_6", range(277,320), minor_versions("1.6" , 0))] def formats_list(): Index: lib/lyx2lyx/lyx_1_6.py === --- lib/lyx2lyx/lyx_1_6.py (revision 23764) +++ lib/lyx2lyx/lyx_1_6.py (working copy) @@ -47,6 +47,10 @@ +def convert_tablines(document): +return + + def fix_wrong_tables(document): i = 0 while True: @@ -1435,9 +1439,11 @@ [316, [convert_subfig]], [317, []], [318, []], + [319, [convert_tablines]], ] -revert = [[317, [remove_extra_embedded_files]], +revert = [[318, []], + [317, [remove_extra_embedded_files]], [316, [revert_wrapplacement]], [315, [revert_subfig]], [314, [revert_colsep]], Index: src/Buffer.cpp === --- src/Buffer.cpp (revision 23764) +++ src/Buffer.cpp (working copy) @@ -116,7 +116,7 @@ namespace { -int const LYX_FORMAT = 318; +int const LYX_FORMAT = 319; typedef mapDepClean; typedef map RefCache; Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23764) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders->setLeftEnabled(true); - borders->setRightEnabled(true); - borders->setTop(tabular_.topLine(cell, true)); - borders->setBottom(tabular_.bottomLine(cell, true)); - borders->setLeft(tabular_.leftLine(cell, true)); - borders->setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders->update(); - return; - } - borders->setTop(tabular_.topLine(cell)); borders->setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders->setLeftEnabled(true); - borders->setLeft(tabular_.leftLine(cell)); - } else { - borders->setLeft(false); - borders->setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders->setRightEnabled(true); - borders->setRight(tabular_.rightLine(cell)); - } else { - borders->setRight(false); - borders->setRightEnabled(false); - } + borders->setLeft(tabular_.leftLine(cell)); +
Re: setting lines in tables
Edwin Leuven wrote: > any objections if i apply the attached? I think you shouldn't change the default settings of the lines. Jürgen
Re: setting lines in tables
Jürgen Spitzmüller wrote: I think you shouldn't change the default settings of the lines. fixed in attached. the lyx2lyx part needs to be done though... Index: intl/localename.c === --- intl/localename.c (revision 23764) +++ intl/localename.c (working copy) @@ -1357,7 +1357,6 @@ switch (sub) { case SUBLANG_PUNJABI_INDIA: return "pa_IN"; /* Gurmukhi script */ - case SUBLANG_PUNJABI_PAKISTAN: return "pa_PK"; /* Arabic script */ } return "pa"; case LANG_RHAETO_ROMANCE: return "rm_CH"; @@ -1365,7 +1364,6 @@ switch (sub) { case SUBLANG_ROMANIAN_ROMANIA: return "ro_RO"; - case SUBLANG_ROMANIAN_MOLDOVA: return "ro_MD"; } return "ro"; case LANG_RUSSIAN:
Re: setting lines in tables
Edwin Leuven wrote: > fixed in attached. really? > the lyx2lyx part needs to be done though... yes. Jürgen
Re: setting lines in tables
Jürgen Spitzmüller wrote: Edwin Leuven wrote: fixed in attached. really? ahum Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23764) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders->setLeftEnabled(true); - borders->setRightEnabled(true); - borders->setTop(tabular_.topLine(cell, true)); - borders->setBottom(tabular_.bottomLine(cell, true)); - borders->setLeft(tabular_.leftLine(cell, true)); - borders->setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders->update(); - return; - } - borders->setTop(tabular_.topLine(cell)); borders->setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders->setLeftEnabled(true); - borders->setLeft(tabular_.leftLine(cell)); - } else { - borders->setLeft(false); - borders->setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders->setRightEnabled(true); - borders->setRight(tabular_.rightLine(cell)); - } else { - borders->setRight(false); - borders->setRightEnabled(false); - } + borders->setLeft(tabular_.leftLine(cell)); + borders->setRight(tabular_.rightLine(cell)); // repaint the setborder widget borders->update(); } @@ -988,42 +959,6 @@ } -void GuiTabular::toggleTopLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_TOP); - else - set(Tabular::TOGGLE_LINE_TOP); -} - - -void GuiTabular::toggleBottomLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_BOTTOM); - else - set(Tabular::TOGGLE_LINE_BOTTOM); -} - - -void GuiTabular::toggleLeftLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_LEFT); - else - set(Tabular::TOGGLE_LINE_LEFT); -} - - -void GuiTabular::toggleRightLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_RIGHT); - else - set(Tabular::TOGGLE_LINE_RIGHT); -} - - void GuiTabular::setSpecial(string const & special) { if (tabular_.isMultiColumn(getActiveCell())) Index: src/frontends/qt4/GuiTabular.h === --- src/frontends/qt4/GuiTabular.h (revision 23764) +++ src/frontends/qt4/GuiTabular.h (working copy) @@ -95,12 +95,6 @@ /// set a parameter void set(Tabular::Feature, std::string const & arg = std::string()); - /// borders - void toggleTopLine(); - void toggleBottomLine(); - void toggleLeftLine(); - void toggleRightLine(); - void setSpecial(std::string const & special); void setWidth(std::string const & width); Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23764) +++ src/insets/InsetTabular.cpp (working copy) @@ -86,10 +86,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -121,10 +121,6 @@ { Tabular::VALIGN_TOP, "valign-top" }, { Tabular::VALIGN_BOTTOM, "valign-bottom" }, { Tabular::VALIGN_MIDDLE, "valign-middle" }, - { Tabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" }, - { Tabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" }, - { Tabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" }, - { Tabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" }, { Tabular::M_ALIGN_LEFT, "m-align-left" }, { Tabular::M_ALIGN_RIGHT, "m-align-right" }, { Tabular::M_ALIGN_CENTER, "m-align-center" }, @@ -479,9 +475,9 @@ multicolumn(Tabular::CELL_NORMAL), alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - top_line(true), + top_line(false), bottom_line(false), - left_line(true), + left_line(false), right_line(false), usebox(BOX_NONE),
Re: setting lines in tables
Edwin Leuven wrote: it is not completely finished yet, but works pretty ok and comments would be more than welcome small update attached give it a try: it is nice to be finally able to easily set the lines you want Index: src/insets/InsetTabular.h === --- src/insets/InsetTabular.h (revision 23714) +++ src/insets/InsetTabular.h (working copy) @@ -106,14 +106,6 @@ /// VALIGN_MIDDLE, /// - M_TOGGLE_LINE_TOP, - /// - M_TOGGLE_LINE_BOTTOM, - /// - M_TOGGLE_LINE_LEFT, - /// - M_TOGGLE_LINE_RIGHT, - /// M_ALIGN_LEFT, /// M_ALIGN_RIGHT, @@ -244,13 +236,13 @@ Tabular(Buffer const , col_type columns_arg, row_type rows_arg); /// Returns true if there is a topline, returns false if not - bool topLine(idx_type cell, bool wholerow = false) const; + bool topLine(idx_type cell) const; /// Returns true if there is a topline, returns false if not - bool bottomLine(idx_type cell, bool wholerow = false) const; + bool bottomLine(idx_type cell) const; /// Returns true if there is a topline, returns false if not - bool leftLine(idx_type cell, bool wholecolumn = false) const; + bool leftLine(idx_type cell) const; /// Returns true if there is a topline, returns false if not - bool rightLine(idx_type cell, bool wholecolumn = false) const; + bool rightLine(idx_type cell) const; /// bool topAlreadyDrawn(idx_type cell) const; @@ -285,13 +277,13 @@ /// void setAllLines(idx_type cell, bool line); /// - void setTopLine(idx_type cell, bool line, bool wholerow = false); + void setTopLine(idx_type cell, bool line); /// - void setBottomLine(idx_type cell, bool line, bool wholerow = false); + void setBottomLine(idx_type cell, bool line); /// - void setLeftLine(idx_type cell, bool line, bool wholecolumn = false); + void setLeftLine(idx_type cell, bool line); /// - void setRightLine(idx_type cell, bool line, bool wholecolumn = false); + void setRightLine(idx_type cell, bool line); /// void setAlignment(idx_type cell, LyXAlignment align, bool onlycolumn = false); @@ -330,6 +322,7 @@ /// void copyRow(row_type); /// + /// void appendColumn(idx_type cell); /// void deleteColumn(col_type column); @@ -743,6 +736,10 @@ /// lock cell with given index void edit(Cursor cur, bool front, EntryDirection entry_from); + /// get table rom from x coordinate + int getRowFromY(Cursor cur, int y) const; + /// get table column from y coordinate + int getColumnFromX(Cursor cur, int x) const; /// Inset * editXY(Cursor cur, int x, int y); /// can we go further down on mouse click? @@ -772,7 +769,6 @@ idx_type cell, bool erased) const; /// void setCursorFromCoordinates(Cursor cur, int x, int y) const; - /// void moveNextCell(Cursor cur); /// Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23714) +++ src/insets/InsetTabular.cpp (working copy) @@ -85,10 +85,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -120,10 +120,6 @@ { Tabular::VALIGN_TOP, valign-top }, { Tabular::VALIGN_BOTTOM, valign-bottom }, { Tabular::VALIGN_MIDDLE, valign-middle }, - { Tabular::M_TOGGLE_LINE_TOP, m-toggle-line-top }, - { Tabular::M_TOGGLE_LINE_BOTTOM, m-toggle-line-bottom }, - { Tabular::M_TOGGLE_LINE_LEFT, m-toggle-line-left }, - { Tabular::M_TOGGLE_LINE_RIGHT, m-toggle-line-right }, { Tabular::M_ALIGN_LEFT, m-align-left }, { Tabular::M_ALIGN_RIGHT, m-align-right }, { Tabular::M_ALIGN_CENTER, m-align-center }, @@ -478,9 +474,9 @@ multicolumn(Tabular::CELL_NORMAL), alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - top_line(true), + top_line(false), bottom_line(false), - left_line(true), + left_line(false), right_line(false), usebox(BOX_NONE), rotate(false), @@ -538,7 +534,7 @@ Tabular::RowData::RowData() : ascent(0), descent(0), - top_line(true), + top_line(false), bottom_line(false), top_space_default(false), bottom_space_default(false), @@ -554,7 +550,7 @@ Tabular::ColumnData::ColumnData() : alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - left_line(true), + left_line(false), right_line(false), width(0) { @@ -592,11 +588,7 @@ column_info.reserve(10); cell_info.reserve(100); fixCellNums(); - for (row_type i = 0; i rows_arg; ++i) - cell_info[i].back().right_line = true; - row_info.back().bottom_line = true; - row_info.front().bottom_line = true; - column_info.back().right_line = true; + // FIXME: set LyX silly default lines is_long_tabular = false; rotate = false;
Re: setting lines in tables
Edwin Leuven wrote: give it a try: it is nice to be finally able to easily set the lines you want any objections if i apply the attached? Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23727) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders-setLeftEnabled(true); - borders-setRightEnabled(true); - borders-setTop(tabular_.topLine(cell, true)); - borders-setBottom(tabular_.bottomLine(cell, true)); - borders-setLeft(tabular_.leftLine(cell, true)); - borders-setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders-update(); - return; - } - borders-setTop(tabular_.topLine(cell)); borders-setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders-setLeftEnabled(true); - borders-setLeft(tabular_.leftLine(cell)); - } else { - borders-setLeft(false); - borders-setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders-setRightEnabled(true); - borders-setRight(tabular_.rightLine(cell)); - } else { - borders-setRight(false); - borders-setRightEnabled(false); - } + borders-setLeft(tabular_.leftLine(cell)); + borders-setRight(tabular_.rightLine(cell)); // repaint the setborder widget borders-update(); } @@ -988,42 +959,6 @@ } -void GuiTabular::toggleTopLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_TOP); - else - set(Tabular::TOGGLE_LINE_TOP); -} - - -void GuiTabular::toggleBottomLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_BOTTOM); - else - set(Tabular::TOGGLE_LINE_BOTTOM); -} - - -void GuiTabular::toggleLeftLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_LEFT); - else - set(Tabular::TOGGLE_LINE_LEFT); -} - - -void GuiTabular::toggleRightLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_RIGHT); - else - set(Tabular::TOGGLE_LINE_RIGHT); -} - - void GuiTabular::setSpecial(string const special) { if (tabular_.isMultiColumn(getActiveCell())) Index: src/frontends/qt4/GuiTabular.h === --- src/frontends/qt4/GuiTabular.h (revision 23727) +++ src/frontends/qt4/GuiTabular.h (working copy) @@ -95,12 +95,6 @@ /// set a parameter void set(Tabular::Feature, std::string const arg = std::string()); - /// borders - void toggleTopLine(); - void toggleBottomLine(); - void toggleLeftLine(); - void toggleRightLine(); - void setSpecial(std::string const special); void setWidth(std::string const width); Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23727) +++ src/insets/InsetTabular.cpp (working copy) @@ -85,10 +85,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -120,10 +120,6 @@ { Tabular::VALIGN_TOP, valign-top }, { Tabular::VALIGN_BOTTOM, valign-bottom }, { Tabular::VALIGN_MIDDLE, valign-middle }, - { Tabular::M_TOGGLE_LINE_TOP, m-toggle-line-top }, - { Tabular::M_TOGGLE_LINE_BOTTOM, m-toggle-line-bottom }, - { Tabular::M_TOGGLE_LINE_LEFT, m-toggle-line-left }, - { Tabular::M_TOGGLE_LINE_RIGHT, m-toggle-line-right }, { Tabular::M_ALIGN_LEFT, m-align-left }, { Tabular::M_ALIGN_RIGHT, m-align-right }, { Tabular::M_ALIGN_CENTER, m-align-center }, @@ -478,9 +474,9 @@ multicolumn(Tabular::CELL_NORMAL), alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - top_line(true), + top_line(false), bottom_line(false), - left_line(true), + left_line(false), right_line(false),
Re: setting lines in tables
Edwin Leuven wrote: it is not completely finished yet, but works pretty ok and comments would be more than welcome small update attached give it a try: it is nice to be finally able to easily set the lines you want Index: src/insets/InsetTabular.h === --- src/insets/InsetTabular.h (revision 23714) +++ src/insets/InsetTabular.h (working copy) @@ -106,14 +106,6 @@ /// VALIGN_MIDDLE, /// - M_TOGGLE_LINE_TOP, - /// - M_TOGGLE_LINE_BOTTOM, - /// - M_TOGGLE_LINE_LEFT, - /// - M_TOGGLE_LINE_RIGHT, - /// M_ALIGN_LEFT, /// M_ALIGN_RIGHT, @@ -244,13 +236,13 @@ Tabular(Buffer const &, col_type columns_arg, row_type rows_arg); /// Returns true if there is a topline, returns false if not - bool topLine(idx_type cell, bool wholerow = false) const; + bool topLine(idx_type cell) const; /// Returns true if there is a topline, returns false if not - bool bottomLine(idx_type cell, bool wholerow = false) const; + bool bottomLine(idx_type cell) const; /// Returns true if there is a topline, returns false if not - bool leftLine(idx_type cell, bool wholecolumn = false) const; + bool leftLine(idx_type cell) const; /// Returns true if there is a topline, returns false if not - bool rightLine(idx_type cell, bool wholecolumn = false) const; + bool rightLine(idx_type cell) const; /// bool topAlreadyDrawn(idx_type cell) const; @@ -285,13 +277,13 @@ /// void setAllLines(idx_type cell, bool line); /// - void setTopLine(idx_type cell, bool line, bool wholerow = false); + void setTopLine(idx_type cell, bool line); /// - void setBottomLine(idx_type cell, bool line, bool wholerow = false); + void setBottomLine(idx_type cell, bool line); /// - void setLeftLine(idx_type cell, bool line, bool wholecolumn = false); + void setLeftLine(idx_type cell, bool line); /// - void setRightLine(idx_type cell, bool line, bool wholecolumn = false); + void setRightLine(idx_type cell, bool line); /// void setAlignment(idx_type cell, LyXAlignment align, bool onlycolumn = false); @@ -330,6 +322,7 @@ /// void copyRow(row_type); /// + /// void appendColumn(idx_type cell); /// void deleteColumn(col_type column); @@ -743,6 +736,10 @@ /// lock cell with given index void edit(Cursor & cur, bool front, EntryDirection entry_from); + /// get table rom from x coordinate + int getRowFromY(Cursor & cur, int y) const; + /// get table column from y coordinate + int getColumnFromX(Cursor & cur, int x) const; /// Inset * editXY(Cursor & cur, int x, int y); /// can we go further down on mouse click? @@ -772,7 +769,6 @@ idx_type cell, bool erased) const; /// void setCursorFromCoordinates(Cursor & cur, int x, int y) const; - /// void moveNextCell(Cursor & cur); /// Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23714) +++ src/insets/InsetTabular.cpp (working copy) @@ -85,10 +85,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -120,10 +120,6 @@ { Tabular::VALIGN_TOP, "valign-top" }, { Tabular::VALIGN_BOTTOM, "valign-bottom" }, { Tabular::VALIGN_MIDDLE, "valign-middle" }, - { Tabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" }, - { Tabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" }, - { Tabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" }, - { Tabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" }, { Tabular::M_ALIGN_LEFT, "m-align-left" }, { Tabular::M_ALIGN_RIGHT, "m-align-right" }, { Tabular::M_ALIGN_CENTER, "m-align-center" }, @@ -478,9 +474,9 @@ multicolumn(Tabular::CELL_NORMAL), alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - top_line(true), + top_line(false), bottom_line(false), - left_line(true), + left_line(false), right_line(false), usebox(BOX_NONE), rotate(false), @@ -538,7 +534,7 @@ Tabular::RowData::RowData() : ascent(0), descent(0), - top_line(true), + top_line(false), bottom_line(false), top_space_default(false), bottom_space_default(false), @@ -554,7 +550,7 @@ Tabular::ColumnData::ColumnData() : alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - left_line(true), + left_line(false), right_line(false), width(0) { @@ -592,11 +588,7 @@ column_info.reserve(10); cell_info.reserve(100); fixCellNums(); - for (row_type i = 0; i < rows_arg; ++i) - cell_info[i].back().right_line = true; - row_info.back().bottom_line = true; - row_info.front().bottom_line = true; - column_info.back().right_line = true; + // FIXME: set LyX silly default lines
Re: setting lines in tables
Edwin Leuven wrote: give it a try: it is nice to be finally able to easily set the lines you want any objections if i apply the attached? Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23727) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders->setLeftEnabled(true); - borders->setRightEnabled(true); - borders->setTop(tabular_.topLine(cell, true)); - borders->setBottom(tabular_.bottomLine(cell, true)); - borders->setLeft(tabular_.leftLine(cell, true)); - borders->setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders->update(); - return; - } - borders->setTop(tabular_.topLine(cell)); borders->setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders->setLeftEnabled(true); - borders->setLeft(tabular_.leftLine(cell)); - } else { - borders->setLeft(false); - borders->setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders->setRightEnabled(true); - borders->setRight(tabular_.rightLine(cell)); - } else { - borders->setRight(false); - borders->setRightEnabled(false); - } + borders->setLeft(tabular_.leftLine(cell)); + borders->setRight(tabular_.rightLine(cell)); // repaint the setborder widget borders->update(); } @@ -988,42 +959,6 @@ } -void GuiTabular::toggleTopLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_TOP); - else - set(Tabular::TOGGLE_LINE_TOP); -} - - -void GuiTabular::toggleBottomLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_BOTTOM); - else - set(Tabular::TOGGLE_LINE_BOTTOM); -} - - -void GuiTabular::toggleLeftLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_LEFT); - else - set(Tabular::TOGGLE_LINE_LEFT); -} - - -void GuiTabular::toggleRightLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_RIGHT); - else - set(Tabular::TOGGLE_LINE_RIGHT); -} - - void GuiTabular::setSpecial(string const & special) { if (tabular_.isMultiColumn(getActiveCell())) Index: src/frontends/qt4/GuiTabular.h === --- src/frontends/qt4/GuiTabular.h (revision 23727) +++ src/frontends/qt4/GuiTabular.h (working copy) @@ -95,12 +95,6 @@ /// set a parameter void set(Tabular::Feature, std::string const & arg = std::string()); - /// borders - void toggleTopLine(); - void toggleBottomLine(); - void toggleLeftLine(); - void toggleRightLine(); - void setSpecial(std::string const & special); void setWidth(std::string const & width); Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23727) +++ src/insets/InsetTabular.cpp (working copy) @@ -85,10 +85,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -120,10 +120,6 @@ { Tabular::VALIGN_TOP, "valign-top" }, { Tabular::VALIGN_BOTTOM, "valign-bottom" }, { Tabular::VALIGN_MIDDLE, "valign-middle" }, - { Tabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" }, - { Tabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" }, - { Tabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" }, - { Tabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" }, { Tabular::M_ALIGN_LEFT, "m-align-left" }, { Tabular::M_ALIGN_RIGHT, "m-align-right" }, { Tabular::M_ALIGN_CENTER, "m-align-center" }, @@ -478,9 +474,9 @@ multicolumn(Tabular::CELL_NORMAL), alignment(LYX_ALIGN_CENTER), valignment(LYX_VALIGN_TOP), - top_line(true), + top_line(false), bottom_line(false), - left_line(true), +
setting lines in tables
atm we are pretty limited when setting lines in tables clines are only possible when explicitly setting cells to multicol and only through the dialog (which has different behavior from the toolbar) setting vertical lines spanning less than a whole column is also problematic the attached patch takes a first stab at free line setting, it - gets rid of the M_TOGGLE_LINE_... functions - allows arbitrary clines without multicol - sets arbitrary vertical lines through multicol it is not completely finished yet, but works pretty ok and comments would be more than welcome edwin PS note that to set a line on a whole row you need to select the row, this can be achieved (thanks to stefan) by clicking in front of the row. dragging the mouse down selects several rows Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23713) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders-setLeftEnabled(true); - borders-setRightEnabled(true); - borders-setTop(tabular_.topLine(cell, true)); - borders-setBottom(tabular_.bottomLine(cell, true)); - borders-setLeft(tabular_.leftLine(cell, true)); - borders-setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders-update(); - return; - } - borders-setTop(tabular_.topLine(cell)); borders-setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders-setLeftEnabled(true); - borders-setLeft(tabular_.leftLine(cell)); - } else { - borders-setLeft(false); - borders-setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders-setRightEnabled(true); - borders-setRight(tabular_.rightLine(cell)); - } else { - borders-setRight(false); - borders-setRightEnabled(false); - } + borders-setLeft(tabular_.leftLine(cell)); + borders-setRight(tabular_.rightLine(cell)); // repaint the setborder widget borders-update(); } @@ -988,42 +959,6 @@ } -void GuiTabular::toggleTopLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_TOP); - else - set(Tabular::TOGGLE_LINE_TOP); -} - - -void GuiTabular::toggleBottomLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_BOTTOM); - else - set(Tabular::TOGGLE_LINE_BOTTOM); -} - - -void GuiTabular::toggleLeftLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_LEFT); - else - set(Tabular::TOGGLE_LINE_LEFT); -} - - -void GuiTabular::toggleRightLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_RIGHT); - else - set(Tabular::TOGGLE_LINE_RIGHT); -} - - void GuiTabular::setSpecial(string const special) { if (tabular_.isMultiColumn(getActiveCell())) Index: src/frontends/qt4/GuiTabular.h === --- src/frontends/qt4/GuiTabular.h (revision 23713) +++ src/frontends/qt4/GuiTabular.h (working copy) @@ -95,12 +95,6 @@ /// set a parameter void set(Tabular::Feature, std::string const arg = std::string()); - /// borders - void toggleTopLine(); - void toggleBottomLine(); - void toggleLeftLine(); - void toggleRightLine(); - void setSpecial(std::string const special); void setWidth(std::string const width); Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23713) +++ src/insets/InsetTabular.cpp (working copy) @@ -85,10 +85,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -120,10 +120,6 @@ { Tabular::VALIGN_TOP, valign-top }, { Tabular::VALIGN_BOTTOM, valign-bottom }, { Tabular::VALIGN_MIDDLE, valign
setting lines in tables
atm we are pretty limited when setting lines in tables clines are only possible when explicitly setting cells to multicol and only through the dialog (which has different behavior from the toolbar) setting vertical lines spanning less than a whole column is also problematic the attached patch takes a first stab at free line setting, it - gets rid of the M_TOGGLE_LINE_... functions - allows arbitrary clines without multicol - sets arbitrary vertical lines through multicol it is not completely finished yet, but works pretty ok and comments would be more than welcome edwin PS note that to set a line on a whole row you need to select the row, this can be achieved (thanks to stefan) by clicking in front of the row. dragging the mouse down selects several rows Index: src/frontends/qt4/GuiTabular.cpp === --- src/frontends/qt4/GuiTabular.cpp (revision 23713) +++ src/frontends/qt4/GuiTabular.cpp (working copy) @@ -283,28 +283,28 @@ void GuiTabular::leftBorder_changed() { - toggleLeftLine(); + set(Tabular::TOGGLE_LINE_LEFT); changed(); } void GuiTabular::rightBorder_changed() { - toggleRightLine(); + set(Tabular::TOGGLE_LINE_RIGHT); changed(); } void GuiTabular::topBorder_changed() { - toggleTopLine(); + set(Tabular::TOGGLE_LINE_TOP); changed(); } void GuiTabular::bottomBorder_changed() { - toggleBottomLine(); + set(Tabular::TOGGLE_LINE_BOTTOM); changed(); } @@ -554,39 +554,10 @@ void GuiTabular::update_borders() { Tabular::idx_type const cell = getActiveCell(); - bool const isMulticolumnCell = tabular_.isMultiColumn(cell); - - if (!isMulticolumnCell) { - borders->setLeftEnabled(true); - borders->setRightEnabled(true); - borders->setTop(tabular_.topLine(cell, true)); - borders->setBottom(tabular_.bottomLine(cell, true)); - borders->setLeft(tabular_.leftLine(cell, true)); - borders->setRight(tabular_.rightLine(cell, true)); - // repaint the setborder widget - borders->update(); - return; - } - borders->setTop(tabular_.topLine(cell)); borders->setBottom(tabular_.bottomLine(cell)); - // pay attention to left/right lines: they are only allowed - // to set if we are in first/last cell of row or if the left/right - // cell is also a multicolumn. - if (tabular_.isFirstCellInRow(cell) || tabular_.isMultiColumn(cell - 1)) { - borders->setLeftEnabled(true); - borders->setLeft(tabular_.leftLine(cell)); - } else { - borders->setLeft(false); - borders->setLeftEnabled(false); - } - if (tabular_.isLastCellInRow(cell) || tabular_.isMultiColumn(cell + 1)) { - borders->setRightEnabled(true); - borders->setRight(tabular_.rightLine(cell)); - } else { - borders->setRight(false); - borders->setRightEnabled(false); - } + borders->setLeft(tabular_.leftLine(cell)); + borders->setRight(tabular_.rightLine(cell)); // repaint the setborder widget borders->update(); } @@ -988,42 +959,6 @@ } -void GuiTabular::toggleTopLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_TOP); - else - set(Tabular::TOGGLE_LINE_TOP); -} - - -void GuiTabular::toggleBottomLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_BOTTOM); - else - set(Tabular::TOGGLE_LINE_BOTTOM); -} - - -void GuiTabular::toggleLeftLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_LEFT); - else - set(Tabular::TOGGLE_LINE_LEFT); -} - - -void GuiTabular::toggleRightLine() -{ - if (tabular_.isMultiColumn(getActiveCell())) - set(Tabular::M_TOGGLE_LINE_RIGHT); - else - set(Tabular::TOGGLE_LINE_RIGHT); -} - - void GuiTabular::setSpecial(string const & special) { if (tabular_.isMultiColumn(getActiveCell())) Index: src/frontends/qt4/GuiTabular.h === --- src/frontends/qt4/GuiTabular.h (revision 23713) +++ src/frontends/qt4/GuiTabular.h (working copy) @@ -95,12 +95,6 @@ /// set a parameter void set(Tabular::Feature, std::string const & arg = std::string()); - /// borders - void toggleTopLine(); - void toggleBottomLine(); - void toggleLeftLine(); - void toggleRightLine(); - void setSpecial(std::string const & special); void setWidth(std::string const & width); Index: src/insets/InsetTabular.cpp === --- src/insets/InsetTabular.cpp (revision 23713) +++ src/insets/InsetTabular.cpp (working copy) @@ -85,10 +85,10 @@ namespace { -int const ADD_TO_HEIGHT = 2; -int const ADD_TO_TABULAR_WIDTH = 2; -int const default_line_space = 10; -int const WIDTH_OF_LINE = 5; +int const ADD_TO_HEIGHT = 2; // in cell +int const ADD_TO_TABULAR_WIDTH = 6; // horiz space before and after the table +int const default_line_space = 10; // ? +int const WIDTH_OF_LINE = 5; // space between double lines /// @@ -120,10 +120,6 @@ { Tabular::VALIGN_TOP