From: Jürgen Vigna Date: Mon, 17 Jul 2000 14:31:07 +0000 (+0000) Subject: Added support for vertical aligment (using array-package) and also better X-Git-Tag: 1.6.10~22115 X-Git-Url: https://git.lyx.org/gitweb/?a=commitdiff_plain;h=9e7821d35b62b8b701ef9b561bfe66c2ddf32998;p=features.git Added support for vertical aligment (using array-package) and also better support for setting header/footer in longtables. The Inset-Tabular-Layout is now fully functionall! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@889 a592a061-630c-0410-9148-cb99ea01b6c8 --- diff --git a/ChangeLog b/ChangeLog index 1a93f9814a..9c8e182729 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2000-07-17 Juergen Vigna + + * src/tabular.C (Validate): check if array-package is needed. + (SetVAlignment): added support for vertical alignment. + (SetLTFoot): better support for longtable header/footers + (Latex): modified to support added features. + + * src/LaTeXFeatures.[Ch]: added array-package. + 2000-07-17 R. Lahaye * src/lyx_gui.C (LyXGUI): make sure that the height is large diff --git a/lib/chkconfig.ltx b/lib/chkconfig.ltx index 9f32874121..720f4be03e 100644 --- a/lib/chkconfig.ltx +++ b/lib/chkconfig.ltx @@ -209,6 +209,7 @@ %%% Packages \TestPackage{a4} \TestPackage{a4wide} +\TestPackage{array} \TestPackage{babel} \TestPackage{color} % this one should be there if graphics.sty is there. \TestPackage{fancyhdr} diff --git a/lib/doc/LaTeXConfig.lyx.in b/lib/doc/LaTeXConfig.lyx.in index 18db6d61aa..c38c76ef29 100644 --- a/lib/doc/LaTeXConfig.lyx.in +++ b/lib/doc/LaTeXConfig.lyx.in @@ -1056,6 +1056,21 @@ a4 Other packages \layout Subsection +array +\layout Description + +Found: @chk_array@ +\layout Description + +CTAN: +\family typewriter +macros/latex/required/tools/array.dtx +\layout Description + +Notes: The package array is needed by LyX to be able to output vertical + alignment other then ''top'' for tabulars. +\layout Subsection + algorithm \layout Description diff --git a/po/POTFILES.in b/po/POTFILES.in index fabdfa0ebe..0961c34f8e 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -33,6 +33,11 @@ src/frontends/xforms/FormPreferences.C src/frontends/xforms/form_preferences.C src/frontends/xforms/FormPrint.C src/frontends/xforms/form_print.C +src/frontends/xforms/forms/form_citation.C +src/frontends/xforms/forms/form_copyright.C +src/frontends/xforms/forms/form_preferences.C +src/frontends/xforms/forms/form_print.C +src/frontends/xforms/forms/form_tabular.C src/frontends/xforms/FormTabular.C src/frontends/xforms/form_tabular.C src/gettext.h diff --git a/src/LaTeXFeatures.C b/src/LaTeXFeatures.C index d64f96b3ee..c7172bfa55 100644 --- a/src/LaTeXFeatures.C +++ b/src/LaTeXFeatures.C @@ -29,6 +29,7 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n) : layout(n, false), params(p) { // packages + array = false; color = false; graphics = false; setspace = false; @@ -73,7 +74,9 @@ LaTeXFeatures::LaTeXFeatures(BufferParams const & p, int n) } void LaTeXFeatures::require(string const & name) { - if (name == "color") { + if (name == "array") { + array = true; + } else if (name == "color") { color = true; } else if (name == "graphics") { #ifdef USE_GRAPHICX @@ -126,6 +129,10 @@ string LaTeXFeatures::getPackages() LyXTextClass const & tclass = textclasslist.TextClass(params.textclass); + // array-package + if (array) + packages += "\\usepackage{array}\n"; + // color.sty if (color) { if (params.graphicsDriver == "default") diff --git a/src/LaTeXFeatures.h b/src/LaTeXFeatures.h index 25b1db14b8..48c4bc198e 100644 --- a/src/LaTeXFeatures.h +++ b/src/LaTeXFeatures.h @@ -55,6 +55,8 @@ struct LaTeXFeatures { //@Man: Packages //@{ /// + bool array; + /// bool color; // color.sty #ifdef USE_GRAPHICX /// diff --git a/src/frontends/xforms/FormTabular.C b/src/frontends/xforms/FormTabular.C index bbe35664ee..5575f86086 100644 --- a/src/frontends/xforms/FormTabular.C +++ b/src/frontends/xforms/FormTabular.C @@ -220,7 +220,7 @@ void FormTabular::InputCB(FL_OBJECT * ob, long l) } -bool FormTabular::local_update(bool flag) +bool FormTabular::local_update(bool) { if (!inset_ || !inset_->tabular) return false; @@ -249,48 +249,158 @@ bool FormTabular::local_update(bool flag) sprintf(buf,"%d",row); fl_set_input(dialog_->input_tabular_row, buf); fl_deactivate_object(dialog_->input_tabular_row); - if (tabular->IsMultiColumn(cell)) + if (tabular->IsMultiColumn(cell)) { fl_set_button(cell_options_->radio_multicolumn, 1); - else + fl_set_button(cell_options_->radio_border_top, + tabular->TopLine(cell)?1:0); + fl_activate_object(cell_options_->radio_border_top); + fl_set_object_lcol(cell_options_->radio_border_top, FL_BLACK); + fl_set_button(cell_options_->radio_border_bottom, + tabular->BottomLine(cell)?1:0); + fl_activate_object(cell_options_->radio_border_bottom); + fl_set_object_lcol(cell_options_->radio_border_bottom, FL_BLACK); + fl_set_button(cell_options_->radio_border_left, + tabular->LeftLine(cell)?1:0); + fl_activate_object(cell_options_->radio_border_left); + fl_set_object_lcol(cell_options_->radio_border_left, FL_BLACK); + fl_set_button(cell_options_->radio_border_right, + tabular->RightLine(cell)?1:0); + fl_activate_object(cell_options_->radio_border_right); + fl_set_object_lcol(cell_options_->radio_border_right, FL_BLACK); + pwidth = tabular->GetMColumnPWidth(cell); + align = tabular->GetAlignment(cell); + if (!pwidth.empty() || (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); + else + fl_set_button(cell_options_->radio_align_center, 1); + fl_activate_object(cell_options_->radio_align_left); + fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK); + fl_activate_object(cell_options_->radio_align_right); + fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK); + fl_activate_object(cell_options_->radio_align_center); + fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK); + align = tabular->GetVAlignment(cell); + fl_set_button(cell_options_->radio_valign_top, 0); + fl_set_button(cell_options_->radio_valign_bottom, 0); + fl_set_button(cell_options_->radio_valign_center, 0); + if (pwidth.empty() || (align == LyXTabular::LYX_VALIGN_CENTER)) + fl_set_button(cell_options_->radio_valign_center, 1); + else if (align == LyXTabular::LYX_VALIGN_BOTTOM) + fl_set_button(cell_options_->radio_valign_bottom, 1); + else + fl_set_button(cell_options_->radio_valign_top, 1); + fl_activate_object(cell_options_->radio_valign_top); + fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK); + fl_activate_object(cell_options_->radio_valign_bottom); + fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK); + fl_activate_object(cell_options_->radio_valign_center); + fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK); + special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_MULTI); + fl_set_input(cell_options_->input_special_multialign, special.c_str()); + fl_set_input(cell_options_->input_mcolumn_width,pwidth.c_str()); + if (!lv_->buffer()->isReadonly()) { + fl_activate_object(cell_options_->input_special_multialign); + fl_set_object_lcol(cell_options_->input_special_multialign, + FL_BLACK); + fl_activate_object(cell_options_->input_mcolumn_width); + fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_BLACK); + } + if (!pwidth.empty()) { + fl_deactivate_object(cell_options_->radio_align_left); + fl_deactivate_object(cell_options_->radio_align_right); + fl_deactivate_object(cell_options_->radio_align_center); + fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE); + fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE); + fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE); + fl_activate_object(cell_options_->radio_valign_top); + fl_activate_object(cell_options_->radio_valign_bottom); + fl_activate_object(cell_options_->radio_valign_center); + fl_set_object_lcol(cell_options_->radio_valign_top, FL_BLACK); + fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_BLACK); + fl_set_object_lcol(cell_options_->radio_valign_center, FL_BLACK); + } else { + fl_activate_object(cell_options_->radio_align_left); + fl_activate_object(cell_options_->radio_align_right); + fl_activate_object(cell_options_->radio_align_center); + fl_set_object_lcol(cell_options_->radio_align_left, FL_BLACK); + fl_set_object_lcol(cell_options_->radio_align_right, FL_BLACK); + fl_set_object_lcol(cell_options_->radio_align_center, FL_BLACK); + fl_deactivate_object(cell_options_->radio_valign_top); + fl_deactivate_object(cell_options_->radio_valign_bottom); + fl_deactivate_object(cell_options_->radio_valign_center); + fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE); + fl_set_object_lcol(cell_options_->radio_valign_bottom,FL_INACTIVE); + fl_set_object_lcol(cell_options_->radio_valign_center,FL_INACTIVE); + } + } else { fl_set_button(cell_options_->radio_multicolumn, 0); + fl_set_button(cell_options_->radio_border_top, 0); + fl_deactivate_object(cell_options_->radio_border_top); + fl_set_object_lcol(cell_options_->radio_border_top, FL_INACTIVE); + fl_set_button(cell_options_->radio_border_bottom, 0); + fl_deactivate_object(cell_options_->radio_border_bottom); + fl_set_object_lcol(cell_options_->radio_border_bottom, FL_INACTIVE); + fl_set_button(cell_options_->radio_border_left, 0); + fl_deactivate_object(cell_options_->radio_border_left); + fl_set_object_lcol(cell_options_->radio_border_left, FL_INACTIVE); + fl_set_button(cell_options_->radio_border_right, 0); + fl_deactivate_object(cell_options_->radio_border_right); + fl_set_object_lcol(cell_options_->radio_border_right, FL_INACTIVE); + fl_set_button(cell_options_->radio_align_left, 0); + fl_deactivate_object(cell_options_->radio_align_left); + fl_set_object_lcol(cell_options_->radio_align_left, FL_INACTIVE); + fl_set_button(cell_options_->radio_align_right, 0); + fl_deactivate_object(cell_options_->radio_align_right); + fl_set_object_lcol(cell_options_->radio_align_right, FL_INACTIVE); + fl_set_button(cell_options_->radio_align_center, 0); + fl_deactivate_object(cell_options_->radio_align_center); + fl_set_object_lcol(cell_options_->radio_align_center, FL_INACTIVE); + fl_set_button(cell_options_->radio_valign_top, 0); + fl_deactivate_object(cell_options_->radio_valign_top); + fl_set_object_lcol(cell_options_->radio_valign_top, FL_INACTIVE); + fl_set_button(cell_options_->radio_valign_bottom, 0); + fl_deactivate_object(cell_options_->radio_valign_bottom); + fl_set_object_lcol(cell_options_->radio_valign_bottom, FL_INACTIVE); + fl_set_button(cell_options_->radio_valign_center, 0); + fl_deactivate_object(cell_options_->radio_valign_center); + fl_set_object_lcol(cell_options_->radio_valign_center, FL_INACTIVE); + fl_set_input(cell_options_->input_special_multialign, ""); + fl_deactivate_object(cell_options_->input_special_multialign); + fl_set_object_lcol(cell_options_->input_special_multialign, FL_INACTIVE); + fl_set_input(cell_options_->input_mcolumn_width,""); + fl_deactivate_object(cell_options_->input_mcolumn_width); + fl_set_object_lcol(cell_options_->input_mcolumn_width, FL_INACTIVE); + } if (tabular->GetRotateCell(cell)) fl_set_button(cell_options_->radio_rotate_cell, 1); else fl_set_button(cell_options_->radio_rotate_cell, 0); - if (tabular->TopLine(cell)) + if (tabular->TopLine(cell, true)) fl_set_button(column_options_->radio_border_top, 1); else fl_set_button(column_options_->radio_border_top, 0); - if (tabular->BottomLine(cell)) + if (tabular->BottomLine(cell, true)) fl_set_button(column_options_->radio_border_bottom, 1); else fl_set_button(column_options_->radio_border_bottom, 0); - if (tabular->LeftLine(cell)) + if (tabular->LeftLine(cell, true)) fl_set_button(column_options_->radio_border_left, 1); else fl_set_button(column_options_->radio_border_left, 0); - if (tabular->RightLine(cell)) + if (tabular->RightLine(cell, true)) fl_set_button(column_options_->radio_border_right, 1); else fl_set_button(column_options_->radio_border_right, 0); - align = tabular->GetAlignment(cell); - 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); special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_COLUMN); - if (flag) - fl_set_input(column_options_->input_special_alignment, - special.c_str()); + fl_set_input(column_options_->input_special_alignment, special.c_str()); if (lv_->buffer()->isReadonly()) fl_deactivate_object(column_options_->input_special_alignment); - special = tabular->GetAlignSpecial(cell,LyXTabular::SET_SPECIAL_MULTI); - if (flag) - fl_set_input(cell_options_->input_special_multialign, special.c_str()); - if (lv_->buffer()->isReadonly()) - fl_deactivate_object(cell_options_->input_special_multialign); - pwidth = tabular->GetPWidth(cell); - if (flag) - fl_set_input(column_options_->input_column_width,pwidth.c_str()); + else + fl_activate_object(column_options_->input_special_alignment); + pwidth = tabular->GetColumnPWidth(cell); + fl_set_input(column_options_->input_column_width,pwidth.c_str()); if (lv_->buffer()->isReadonly()) { fl_deactivate_object(column_options_->input_column_width); } else { @@ -306,20 +416,39 @@ bool FormTabular::local_update(bool flag) fl_set_object_lcol(cell_options_->radio_linebreak_cell, FL_INACTIVE); fl_set_button(cell_options_->radio_linebreak_cell,0); } - if ((!pwidth.empty() && !tabular->IsMultiColumn(cell)) || - (align == LYX_ALIGN_LEFT)) + align = tabular->GetAlignment(cell, true); + 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.empty() || (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); else fl_set_button(column_options_->radio_align_center, 1); - if (!pwidth.empty() && !tabular->IsMultiColumn(cell)) { + align = tabular->GetVAlignment(cell, true); + fl_set_button(column_options_->radio_valign_top, 0); + fl_set_button(column_options_->radio_valign_bottom, 0); + fl_set_button(column_options_->radio_valign_center, 0); + if (pwidth.empty() || (align == LyXTabular::LYX_VALIGN_CENTER)) + fl_set_button(column_options_->radio_valign_center, 1); + else if (align == LyXTabular::LYX_VALIGN_BOTTOM) + fl_set_button(column_options_->radio_valign_bottom, 1); + else + fl_set_button(column_options_->radio_valign_top, 1); + if (!pwidth.empty()) { fl_deactivate_object(column_options_->radio_align_left); fl_deactivate_object(column_options_->radio_align_right); fl_deactivate_object(column_options_->radio_align_center); fl_set_object_lcol(column_options_->radio_align_left, FL_INACTIVE); fl_set_object_lcol(column_options_->radio_align_right, FL_INACTIVE); fl_set_object_lcol(column_options_->radio_align_center, FL_INACTIVE); + fl_activate_object(column_options_->radio_valign_top); + fl_activate_object(column_options_->radio_valign_bottom); + fl_activate_object(column_options_->radio_valign_center); + fl_set_object_lcol(column_options_->radio_valign_top, FL_BLACK); + fl_set_object_lcol(column_options_->radio_valign_bottom, FL_BLACK); + fl_set_object_lcol(column_options_->radio_valign_center, FL_BLACK); } else { fl_activate_object(column_options_->radio_align_left); fl_activate_object(column_options_->radio_align_right); @@ -327,6 +456,12 @@ bool FormTabular::local_update(bool flag) fl_set_object_lcol(column_options_->radio_align_left, FL_BLACK); fl_set_object_lcol(column_options_->radio_align_right, FL_BLACK); fl_set_object_lcol(column_options_->radio_align_center, FL_BLACK); + fl_deactivate_object(column_options_->radio_valign_top); + fl_deactivate_object(column_options_->radio_valign_bottom); + fl_deactivate_object(column_options_->radio_valign_center); + fl_set_object_lcol(column_options_->radio_valign_top, FL_INACTIVE); + fl_set_object_lcol(column_options_->radio_valign_bottom, FL_INACTIVE); + fl_set_object_lcol(column_options_->radio_valign_center, FL_INACTIVE); } fl_set_button(tabular_options_->radio_longtable, tabular->IsLongTabular()); @@ -341,14 +476,15 @@ bool FormTabular::local_update(bool flag) fl_set_object_lcol(longtable_options_->radio_lt_foot, FL_BLACK); fl_set_object_lcol(longtable_options_->radio_lt_lastfoot, FL_BLACK); fl_set_object_lcol(longtable_options_->radio_lt_newpage, FL_BLACK); + int dummy; fl_set_button(longtable_options_->radio_lt_firsthead, - tabular->GetRowOfLTFirstHead(cell)); + tabular->GetRowOfLTFirstHead(cell, dummy)); fl_set_button(longtable_options_->radio_lt_head, - tabular->GetRowOfLTHead(cell)); + tabular->GetRowOfLTHead(cell, dummy)); fl_set_button(longtable_options_->radio_lt_foot, - tabular->GetRowOfLTFoot(cell)); + tabular->GetRowOfLTFoot(cell, dummy)); fl_set_button(longtable_options_->radio_lt_lastfoot, - tabular->GetRowOfLTLastFoot(cell)); + tabular->GetRowOfLTLastFoot(cell, dummy)); fl_set_button(longtable_options_->radio_lt_newpage, tabular->GetLTNewPage(cell)); } else { @@ -416,6 +552,20 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long) local_update(false); // update for alignment return; } + if (ob == cell_options_->input_mcolumn_width) { + string + str; + str = fl_get_input(ob); + if (!str.empty() && !isValidLength(str)) { + fl_set_object_label(dialog_->text_warning, + _("Warning: Invalid Length (valid example: 10mm)")); + fl_show_object(dialog_->text_warning); + return; + } + inset_->TabularFeatures(lv_->view(), LyXTabular::SET_MPWIDTH,str); + local_update(false); // update for alignment + return; + } str = fl_get_input(column_options_->input_column_width); if (!str.empty() && !isValidLength(str)) { fl_set_object_label( @@ -450,6 +600,12 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long) num = LyXTabular::ALIGN_RIGHT; else if (ob == column_options_->radio_align_center) num = LyXTabular::ALIGN_CENTER; + else if (ob == column_options_->radio_valign_top) + num = LyXTabular::VALIGN_TOP; + else if (ob == column_options_->radio_valign_bottom) + num = LyXTabular::VALIGN_BOTTOM; + else if (ob == column_options_->radio_valign_center) + num = LyXTabular::VALIGN_CENTER; else if (ob == cell_options_->radio_multicolumn) num = LyXTabular::MULTICOLUMN; else if (ob == tabular_options_->radio_longtable) { @@ -461,14 +617,15 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long) fl_activate_object(longtable_options_->radio_lt_foot); fl_activate_object(longtable_options_->radio_lt_lastfoot); fl_activate_object(longtable_options_->radio_lt_newpage); + int dummy; fl_set_button(longtable_options_->radio_lt_firsthead, - tabular->GetRowOfLTFirstHead(cell)); + tabular->GetRowOfLTFirstHead(cell, dummy)); fl_set_button(longtable_options_->radio_lt_head, - tabular->GetRowOfLTHead(cell)); + tabular->GetRowOfLTHead(cell, dummy)); fl_set_button(longtable_options_->radio_lt_foot, - tabular->GetRowOfLTFoot(cell)); + tabular->GetRowOfLTFoot(cell, dummy)); fl_set_button(longtable_options_->radio_lt_lastfoot, - tabular->GetRowOfLTLastFoot(cell)); + tabular->GetRowOfLTLastFoot(cell, dummy)); fl_set_button(longtable_options_->radio_lt_firsthead, tabular->GetLTNewPage(cell)); } else { @@ -522,7 +679,27 @@ void FormTabular::SetTabularOptions(FL_OBJECT * ob, long) } else if (ob == cell_options_->input_special_multialign) { special = fl_get_input(cell_options_->input_special_multialign); num = LyXTabular::SET_SPECIAL_MULTI; - } else + } else if (ob == cell_options_->radio_border_top) + num = LyXTabular::M_TOGGLE_LINE_TOP; + else if (ob == cell_options_->radio_border_bottom) + num = LyXTabular::M_TOGGLE_LINE_BOTTOM; + else if (ob == cell_options_->radio_border_left) + num = LyXTabular::M_TOGGLE_LINE_LEFT; + else if (ob == cell_options_->radio_border_right) + num = LyXTabular::M_TOGGLE_LINE_RIGHT; + else if (ob == cell_options_->radio_align_left) + num = LyXTabular::M_ALIGN_LEFT; + else if (ob == cell_options_->radio_align_right) + num = LyXTabular::M_ALIGN_RIGHT; + else if (ob == cell_options_->radio_align_center) + num = LyXTabular::M_ALIGN_CENTER; + else if (ob == cell_options_->radio_valign_top) + num = LyXTabular::M_VALIGN_TOP; + else if (ob == cell_options_->radio_valign_bottom) + num = LyXTabular::M_VALIGN_BOTTOM; + else if (ob == cell_options_->radio_valign_center) + num = LyXTabular::M_VALIGN_CENTER; + else return; inset_->TabularFeatures(lv_->view(), num, special); diff --git a/src/frontends/xforms/form_tabular.C b/src/frontends/xforms/form_tabular.C index 49e1001e12..a6e45438ff 100644 --- a/src/frontends/xforms/form_tabular.C +++ b/src/frontends/xforms/form_tabular.C @@ -23,10 +23,10 @@ FD_form_tabular * FormTabular::build_tabular() fdui->button_close = obj = fl_add_button(FL_NORMAL_BUTTON, 415, 250, 90, 30, idex(_("Close|#C")));fl_set_button_shortcut(obj, scex(_("Close|#C")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularCloseCB, 0); - fdui->input_tabular_column = obj = fl_add_input(FL_NORMAL_INPUT, 5, 250, 60, 30, ""); + fdui->input_tabular_column = obj = fl_add_input(FL_NORMAL_INPUT, 64, 250, 60, 30, ""); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT); - fdui->input_tabular_row = obj = fl_add_input(FL_NORMAL_INPUT, 65, 250, 60, 30, ""); + fdui->input_tabular_row = obj = fl_add_input(FL_NORMAL_INPUT, 5, 250, 60, 30, ""); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_TOP_LEFT); fdui->text_warning = obj = fl_add_text(FL_NORMAL_TEXT, 125, 250, 290, 30, ""); @@ -125,10 +125,10 @@ FD_form_column_options * FormTabular::build_column_options() fdui->radio_align_left = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 205, 30, 110, 25, idex(_("Left|#e")));fl_set_button_shortcut(obj, scex(_("Left|#e")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_align_right = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 205, 55, 115, 25, idex(_("Right|#i")));fl_set_button_shortcut(obj, scex(_("Right|#i")), 1); + fdui->radio_align_right = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 205, 80, 115, 25, idex(_("Right|#i")));fl_set_button_shortcut(obj, scex(_("Right|#i")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_align_center = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 205, 80, 115, 25, idex(_("Center|#c")));fl_set_button_shortcut(obj, scex(_("Center|#c")), 1); + fdui->radio_align_center = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 205, 55, 115, 25, idex(_("Center|#c")));fl_set_button_shortcut(obj, scex(_("Center|#c")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); fdui->input_column_width = obj = fl_add_input(FL_NORMAL_INPUT, 375, 150, 95, 30, _("Width of column:")); @@ -136,15 +136,6 @@ FD_form_column_options * FormTabular::build_column_options() fl_set_object_callback(obj, C_FormTabularInputCB, 0); obj = fl_add_frame(FL_ENGRAVED_FRAME, 340, 20, 130, 105, ""); fl_set_object_color(obj, FL_COL1, FL_COL1); - fdui->radio_valign_top = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 345, 30, 110, 25, idex(_("Top|#p")));fl_set_button_shortcut(obj, scex(_("Top|#p")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_valign_center = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 345, 55, 115, 25, idex(_("Center|#n")));fl_set_button_shortcut(obj, scex(_("Center|#n")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_valign_bottom = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 345, 80, 115, 25, idex(_("Bottom|#o")));fl_set_button_shortcut(obj, scex(_("Bottom|#o")), 1); - fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fl_set_object_callback(obj, C_FormTabularInputCB, 0); obj = fl_add_text(FL_NORMAL_TEXT, 345, 10, 115, 20, _("V. Alignment")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); @@ -159,6 +150,15 @@ FD_form_column_options * FormTabular::build_column_options() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); + fdui->radio_valign_top = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 345, 30, 125, 25, idex(_("Top|#p")));fl_set_button_shortcut(obj, scex(_("Top|#p")), 1); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormTabularInputCB, 0); + fdui->radio_valign_center = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 345, 55, 125, 25, idex(_("Center|#n")));fl_set_button_shortcut(obj, scex(_("Center|#n")), 1); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormTabularInputCB, 0); + fdui->radio_valign_bottom = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 345, 80, 120, 25, idex(_("Bottom|#o")));fl_set_button_shortcut(obj, scex(_("Bottom|#o")), 1); + fl_set_object_lsize(obj, FL_NORMAL_SIZE); + fl_set_object_callback(obj, C_FormTabularInputCB, 0); fl_end_form(); fdui->form_column_options->fdui = fdui; @@ -175,6 +175,7 @@ FD_form_cell_options * FormTabular::build_cell_options() fdui->form_cell_options = fl_bgn_form(FL_NO_BOX, 505, 227); fdui->form_cell_options->u_vdata = this; obj = fl_add_box(FL_UP_BOX, 0, 0, 505, 227, ""); + obj = fl_add_frame(FL_ENGRAVED_FRAME, 335, 110, 155, 100, ""); obj = fl_add_frame(FL_ENGRAVED_FRAME, 10, 110, 180, 100, ""); fl_set_object_color(obj, FL_COL1, FL_COL1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); @@ -188,8 +189,6 @@ FD_form_cell_options * FormTabular::build_cell_options() fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); - obj = fl_add_frame(FL_ENGRAVED_FRAME, 340, 110, 130, 100, ""); - fl_set_object_color(obj, FL_COL1, FL_COL1); obj = fl_add_text(FL_NORMAL_TEXT, 345, 100, 115, 20, _("V. Alignment")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); @@ -205,17 +204,17 @@ FD_form_cell_options * FormTabular::build_cell_options() fl_set_object_callback(obj, C_FormTabularInputCB, 0); fdui->radio_rotate_cell = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 10, 75, 145, 25, _("Rotate 90°")); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - obj = fl_add_frame(FL_ENGRAVED_FRAME, 165, 15, 305, 85, ""); + obj = fl_add_frame(FL_ENGRAVED_FRAME, 165, 15, 325, 85, ""); fl_set_object_color(obj, FL_COL1, FL_COL1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); - fdui->input_special_multialign = obj = fl_add_input(FL_NORMAL_INPUT, 175, 30, 280, 30, ""); + fdui->input_special_multialign = obj = fl_add_input(FL_NORMAL_INPUT, 175, 30, 310, 30, ""); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); obj = fl_add_text(FL_NORMAL_TEXT, 170, 5, 290, 20, _("Special Multicolumn Alignment")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_lalign(obj, FL_ALIGN_LEFT|FL_ALIGN_INSIDE); fl_set_object_lstyle(obj, FL_BOLD_STYLE); - fdui->input_mcolumn_width = obj = fl_add_input(FL_NORMAL_INPUT, 360, 65, 95, 30, _("Width of multi-column:")); + fdui->input_mcolumn_width = obj = fl_add_input(FL_NORMAL_INPUT, 360, 65, 125, 30, _("Width of multi-column:")); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); fdui->radio_border_top = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 75, 135, 25, 25, idex(_("Top|#t")));fl_set_button_shortcut(obj, scex(_("Top|#t")), 1); @@ -237,19 +236,19 @@ FD_form_cell_options * FormTabular::build_cell_options() fdui->radio_align_left = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 195, 120, 110, 25, idex(_("Left|#e")));fl_set_button_shortcut(obj, scex(_("Left|#e")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_align_right = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 195, 145, 115, 25, idex(_("Right|#i")));fl_set_button_shortcut(obj, scex(_("Right|#i")), 1); + fdui->radio_align_right = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 195, 170, 115, 25, idex(_("Right|#i")));fl_set_button_shortcut(obj, scex(_("Right|#i")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_align_center = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 195, 170, 115, 25, idex(_("Center|#c")));fl_set_button_shortcut(obj, scex(_("Center|#c")), 1); + fdui->radio_align_center = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 195, 145, 115, 25, idex(_("Center|#c")));fl_set_button_shortcut(obj, scex(_("Center|#c")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_valign_top = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 340, 120, 110, 25, idex(_("Top|#p")));fl_set_button_shortcut(obj, scex(_("Top|#p")), 1); + fdui->radio_valign_top = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 345, 120, 140, 25, idex(_("Top|#p")));fl_set_button_shortcut(obj, scex(_("Top|#p")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_valign_center = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 340, 145, 115, 25, idex(_("Center|#n")));fl_set_button_shortcut(obj, scex(_("Center|#n")), 1); + fdui->radio_valign_center = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 345, 145, 140, 25, idex(_("Center|#n")));fl_set_button_shortcut(obj, scex(_("Center|#n")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); - fdui->radio_valign_bottom = obj = fl_add_checkbutton(FL_RADIO_BUTTON, 340, 170, 115, 25, idex(_("Bottom|#o")));fl_set_button_shortcut(obj, scex(_("Bottom|#o")), 1); + fdui->radio_valign_bottom = obj = fl_add_checkbutton(FL_PUSH_BUTTON, 345, 170, 140, 25, idex(_("Bottom|#o")));fl_set_button_shortcut(obj, scex(_("Bottom|#o")), 1); fl_set_object_lsize(obj, FL_NORMAL_SIZE); fl_set_object_callback(obj, C_FormTabularInputCB, 0); fl_end_form(); diff --git a/src/frontends/xforms/form_tabular.h b/src/frontends/xforms/form_tabular.h index e4f449e9e5..51e35d5649 100644 --- a/src/frontends/xforms/form_tabular.h +++ b/src/frontends/xforms/form_tabular.h @@ -1,4 +1,4 @@ -/** Header file generated with fdesign on Fri Jul 14 15:53:33 2000.**/ +/** Header file generated with fdesign on Mon Jul 17 13:48:45 2000.**/ #ifndef FD_form_tabular_h_ #define FD_form_tabular_h_ @@ -52,10 +52,10 @@ struct FD_form_column_options { FL_OBJECT *radio_align_right; FL_OBJECT *radio_align_center; FL_OBJECT *input_column_width; + FL_OBJECT *input_special_alignment; FL_OBJECT *radio_valign_top; FL_OBJECT *radio_valign_center; FL_OBJECT *radio_valign_bottom; - FL_OBJECT *input_special_alignment; }; struct FD_form_cell_options { diff --git a/src/frontends/xforms/forms/form_tabular.fd b/src/frontends/xforms/forms/form_tabular.fd index 50d7b0352a..44558ef941 100644 --- a/src/frontends/xforms/forms/form_tabular.fd +++ b/src/frontends/xforms/forms/form_tabular.fd @@ -514,7 +514,7 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: RADIO_BUTTON -box: 205 55 115 25 +box: 205 80 115 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -532,7 +532,7 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: RADIO_BUTTON -box: 205 80 115 25 +box: 205 55 115 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -583,60 +583,6 @@ name: callback: argument: --------------------- -class: FL_CHECKBUTTON -type: RADIO_BUTTON -box: 345 30 110 25 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Top|#p -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: radio_valign_top -callback: C_FormTabularInputCB -argument: 0 - --------------------- -class: FL_CHECKBUTTON -type: RADIO_BUTTON -box: 345 55 115 25 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Center|#n -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: radio_valign_center -callback: C_FormTabularInputCB -argument: 0 - --------------------- -class: FL_CHECKBUTTON -type: RADIO_BUTTON -box: 345 80 115 25 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_YELLOW -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_NORMAL_SIZE -lcol: FL_BLACK -label: Bottom|#o -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: radio_valign_bottom -callback: C_FormTabularInputCB -argument: 0 - -------------------- class: FL_TEXT type: NORMAL_TEXT @@ -709,6 +655,60 @@ name: callback: argument: +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 345 30 125 25 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Top|#p +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_valign_top +callback: C_FormTabularInputCB +argument: 0 + +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 345 55 125 25 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Center|#n +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_valign_center +callback: C_FormTabularInputCB +argument: 0 + +-------------------- +class: FL_CHECKBUTTON +type: PUSH_BUTTON +box: 345 80 120 25 +boxtype: FL_NO_BOX +colors: FL_COL1 FL_YELLOW +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_NORMAL_SIZE +lcol: FL_BLACK +label: Bottom|#o +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: radio_valign_bottom +callback: C_FormTabularInputCB +argument: 0 + =============== FORM =============== Name: form_cell_options Width: 505 @@ -733,6 +733,24 @@ name: callback: argument: +-------------------- +class: FL_FRAME +type: ENGRAVED_FRAME +box: 335 110 155 100 +boxtype: FL_NO_BOX +colors: FL_BLACK FL_COL1 +alignment: FL_ALIGN_CENTER +style: FL_NORMAL_STYLE +size: FL_DEFAULT_SIZE +lcol: FL_BLACK +label: +shortcut: +resize: FL_RESIZE_ALL +gravity: FL_NoGravity FL_NoGravity +name: +callback: +argument: + -------------------- class: FL_FRAME type: ENGRAVED_FRAME @@ -805,24 +823,6 @@ name: callback: argument: --------------------- -class: FL_FRAME -type: ENGRAVED_FRAME -box: 340 110 130 100 -boxtype: FL_NO_BOX -colors: FL_COL1 FL_COL1 -alignment: FL_ALIGN_CENTER -style: FL_NORMAL_STYLE -size: FL_DEFAULT_SIZE -lcol: FL_BLACK -label: -shortcut: -resize: FL_RESIZE_ALL -gravity: FL_NoGravity FL_NoGravity -name: -callback: -argument: - -------------------- class: FL_TEXT type: NORMAL_TEXT @@ -934,7 +934,7 @@ argument: 0 -------------------- class: FL_FRAME type: ENGRAVED_FRAME -box: 165 15 305 85 +box: 165 15 325 85 boxtype: FL_NO_BOX colors: FL_COL1 FL_COL1 alignment: FL_ALIGN_CENTER @@ -952,7 +952,7 @@ argument: -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 175 30 280 30 +box: 175 30 310 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -988,7 +988,7 @@ argument: -------------------- class: FL_INPUT type: NORMAL_INPUT -box: 360 65 95 30 +box: 360 65 125 30 boxtype: FL_DOWN_BOX colors: FL_COL1 FL_MCOL alignment: FL_ALIGN_LEFT @@ -1096,7 +1096,7 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: RADIO_BUTTON -box: 195 145 115 25 +box: 195 170 115 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -1114,7 +1114,7 @@ argument: 0 -------------------- class: FL_CHECKBUTTON type: RADIO_BUTTON -box: 195 170 115 25 +box: 195 145 115 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -1131,8 +1131,8 @@ argument: 0 -------------------- class: FL_CHECKBUTTON -type: RADIO_BUTTON -box: 340 120 110 25 +type: PUSH_BUTTON +box: 345 120 140 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -1149,8 +1149,8 @@ argument: 0 -------------------- class: FL_CHECKBUTTON -type: RADIO_BUTTON -box: 340 145 115 25 +type: PUSH_BUTTON +box: 345 145 140 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER @@ -1167,8 +1167,8 @@ argument: 0 -------------------- class: FL_CHECKBUTTON -type: RADIO_BUTTON -box: 340 170 115 25 +type: PUSH_BUTTON +box: 345 170 140 25 boxtype: FL_NO_BOX colors: FL_COL1 FL_YELLOW alignment: FL_ALIGN_CENTER diff --git a/src/insets/insettabular.C b/src/insets/insettabular.C index 6e6aeac44a..3a582d63ff 100644 --- a/src/insets/insettabular.C +++ b/src/insets/insettabular.C @@ -1038,15 +1038,30 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) what; switch (feature) { + case LyXTabular::M_ALIGN_LEFT: case LyXTabular::ALIGN_LEFT: setAlign=LYX_ALIGN_LEFT; break; + case LyXTabular::M_ALIGN_RIGHT: case LyXTabular::ALIGN_RIGHT: setAlign=LYX_ALIGN_RIGHT; break; + case LyXTabular::M_ALIGN_CENTER: case LyXTabular::ALIGN_CENTER: setAlign=LYX_ALIGN_CENTER; break; + case LyXTabular::M_VALIGN_TOP: + case LyXTabular::VALIGN_TOP: + setAlign=LyXTabular::LYX_VALIGN_TOP; + break; + case LyXTabular::M_VALIGN_BOTTOM: + case LyXTabular::VALIGN_BOTTOM: + setAlign=LyXTabular::LYX_VALIGN_BOTTOM; + break; + case LyXTabular::M_VALIGN_CENTER: + case LyXTabular::VALIGN_CENTER: + setAlign=LyXTabular::LYX_VALIGN_CENTER; + break; default: break; } @@ -1078,16 +1093,30 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) int row = tabular->row_of_cell(actcell); int column = tabular->column_of_cell(actcell); - + bool flag = true; + switch (feature) { case LyXTabular::SET_PWIDTH: + { + bool update = (tabular->GetColumnPWidth(actcell) != val); + tabular->SetColumnPWidth(actcell,val); + if (update) { + for (int i=0; i < tabular->rows(); ++i) { + tabular->GetCellInset(tabular->GetCellNumber(i, column))-> + resizeLyXText(bv); + } + UpdateLocal(bv, INIT, true); + } + } + break; + case LyXTabular::SET_MPWIDTH: { bool update = (tabular->GetPWidth(actcell) != val); - tabular->SetPWidth(actcell,val); + tabular->SetMColumnPWidth(actcell,val); if (update) { for (int i=0; i < tabular->rows(); ++i) { tabular->GetCellInset(tabular->GetCellNumber(i, column))-> - deleteLyXText(bv); + resizeLyXText(bv); } UpdateLocal(bv, INIT, true); } @@ -1123,43 +1152,75 @@ void InsetTabular::TabularFeatures(BufferView * bv, int feature, string val) actcell = tabular->GetCellNumber(row, column); UpdateLocal(bv, INIT, true); break; + case LyXTabular::M_TOGGLE_LINE_TOP: + flag = false; case LyXTabular::TOGGLE_LINE_TOP: - lineSet = !tabular->TopLine(actcell); + lineSet = !tabular->TopLine(actcell, flag); for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) - tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet); + tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet, flag); UpdateLocal(bv, INIT, true); break; + case LyXTabular::M_TOGGLE_LINE_BOTTOM: + flag = false; case LyXTabular::TOGGLE_LINE_BOTTOM: - lineSet = !tabular->BottomLine(actcell); + lineSet = !tabular->BottomLine(actcell, flag); for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) - tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet); + tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet, + flag); UpdateLocal(bv, INIT, true); break; + case LyXTabular::M_TOGGLE_LINE_LEFT: + flag = false; case LyXTabular::TOGGLE_LINE_LEFT: - lineSet = !tabular->LeftLine(actcell); + lineSet = !tabular->LeftLine(actcell, flag); for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) - tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet); + tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet, + flag); UpdateLocal(bv, INIT, true); break; + case LyXTabular::M_TOGGLE_LINE_RIGHT: + flag = false; case LyXTabular::TOGGLE_LINE_RIGHT: - lineSet = !tabular->RightLine(actcell); + lineSet = !tabular->RightLine(actcell, flag); for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) - tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet); + tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet, + flag); UpdateLocal(bv, INIT, true); break; + case LyXTabular::M_ALIGN_LEFT: + case LyXTabular::M_ALIGN_RIGHT: + case LyXTabular::M_ALIGN_CENTER: + flag = false; case LyXTabular::ALIGN_LEFT: case LyXTabular::ALIGN_RIGHT: case LyXTabular::ALIGN_CENTER: for(i=sel_row_start; i<=sel_row_end; ++i) for(j=sel_col_start; j<=sel_col_end; ++j) - tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign); + tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign, + flag); + if (hasSelection()) + UpdateLocal(bv, INIT, true); + else + UpdateLocal(bv, CELL, true); + break; + case LyXTabular::M_VALIGN_TOP: + case LyXTabular::M_VALIGN_BOTTOM: + case LyXTabular::M_VALIGN_CENTER: + flag = false; + case LyXTabular::VALIGN_TOP: + case LyXTabular::VALIGN_BOTTOM: + case LyXTabular::VALIGN_CENTER: + for(i=sel_row_start; i<=sel_row_end; ++i) + for(j=sel_col_start; j<=sel_col_end; ++j) + tabular->SetVAlignment(tabular->GetCellNumber(i,j), setAlign, + flag); if (hasSelection()) UpdateLocal(bv, INIT, true); else diff --git a/src/tabular.C b/src/tabular.C index feb9c652b7..79e65ba99d 100644 --- a/src/tabular.C +++ b/src/tabular.C @@ -187,10 +187,10 @@ void LyXTabular::Init(int rows_arg, int columns_arg) set_row_column_number_info(); is_long_tabular = false; rotate = 0; - endhead = -1; - endfirsthead = -1; - endfoot = -1; - endlastfoot = -1; + endhead = 0; + endfirsthead = 0; + endfoot = 0; + endlastfoot = 0; } @@ -380,36 +380,40 @@ int LyXTabular::NumberOfCellsInRow(int cell) const /* returns 1 if there is a topline, returns 0 if not */ -bool LyXTabular::TopLine(int cell) const +bool LyXTabular::TopLine(int cell, bool onlycolumn) const { int row = row_of_cell(cell); - if (IsMultiColumn(cell)) + if (!onlycolumn && IsMultiColumn(cell)) return cellinfo_of_cell(cell)->top_line; return row_info[row].top_line; } -bool LyXTabular::BottomLine(int cell) const +bool LyXTabular::BottomLine(int cell, bool onlycolumn) const { //no bottom line underneath non-existent cells if you please if(cell >= numberofcells) return false; - if (IsMultiColumn(cell)) + if (!onlycolumn && IsMultiColumn(cell)) return cellinfo_of_cell(cell)->bottom_line; return row_info[row_of_cell(cell)].bottom_line; } -bool LyXTabular::LeftLine(int cell) const +bool LyXTabular::LeftLine(int cell, bool onlycolumn) const { + if (!onlycolumn && IsMultiColumn(cell)) + return cellinfo_of_cell(cell)->left_line; return column_info[column_of_cell(cell)].left_line; } -bool LyXTabular::RightLine(int cell) const +bool LyXTabular::RightLine(int cell, bool onlycolumn) const { + if (!onlycolumn && IsMultiColumn(cell)) + return cellinfo_of_cell(cell)->right_line; return column_info[right_column_of_cell(cell)].right_line; } @@ -604,35 +608,54 @@ bool LyXTabular::SetWidthOfCell(int cell, int new_width) } -bool LyXTabular::SetAlignment(int cell, char align) +bool LyXTabular::SetAlignment(int cell, char align, bool onlycolumn) { - if (!IsMultiColumn(cell)) + if (!IsMultiColumn(cell) || onlycolumn) column_info[column_of_cell(cell)].alignment = align; - cellinfo_of_cell(cell)->alignment = align; + if (!onlycolumn) + cellinfo_of_cell(cell)->alignment = align; + return true; +} + + +bool LyXTabular::SetVAlignment(int cell, char align, bool onlycolumn) +{ + if (!IsMultiColumn(cell) || onlycolumn) + column_info[column_of_cell(cell)].valignment = align; + if (!onlycolumn) + cellinfo_of_cell(cell)->valignment = align; + return true; +} + + +bool LyXTabular::SetColumnPWidth(int cell, string const & width) +{ + bool flag = !width.empty(); + + int j = column_of_cell(cell); + int c; + column_info[j].p_width = width; + if (flag) // do this only if there is a width + SetAlignment(cell, LYX_ALIGN_LEFT); + for(int i=0; i < rows_; ++i) { + c = GetCellNumber(i, j); + flag = !GetPWidth(c).empty(); // because of multicolumns! + GetCellInset(c)->SetAutoBreakRows(flag); + } return true; } -bool LyXTabular::SetPWidth(int cell, string const & width) +bool LyXTabular::SetMColumnPWidth(int cell, string const & width) { bool flag = !width.empty(); + cellinfo_of_cell(cell)->p_width = width; if (IsMultiColumn(cell)) { - cellinfo_of_cell(cell)->p_width = width; GetCellInset(cell)->SetAutoBreakRows(flag); - } else { - int j = column_of_cell(cell); - int c; - column_info[j].p_width = width; - if (flag) // do this only if there is a width - SetAlignment(cell, LYX_ALIGN_LEFT); - for(int i=0; i < rows_; ++i) { - c = GetCellNumber(i, j); - flag = !GetPWidth(c).empty(); // because of multicolumns! - GetCellInset(c)->SetAutoBreakRows(flag); - } + return true; } - return true; + return false; } @@ -656,11 +679,11 @@ bool LyXTabular::SetAllLines(int cell, bool line) } -bool LyXTabular::SetTopLine(int cell, bool line) +bool LyXTabular::SetTopLine(int cell, bool line, bool onlycolumn) { int row = row_of_cell(cell); - if (!IsMultiColumn(cell)) + if (onlycolumn || !IsMultiColumn(cell)) row_info[row].top_line = line; else cellinfo_of_cell(cell)->top_line = line; @@ -668,9 +691,9 @@ bool LyXTabular::SetTopLine(int cell, bool line) } -bool LyXTabular::SetBottomLine(int cell, bool line) +bool LyXTabular::SetBottomLine(int cell, bool line, bool onlycolumn) { - if (!IsMultiColumn(cell)) + if (onlycolumn || !IsMultiColumn(cell)) row_info[row_of_cell(cell)].bottom_line = line; else cellinfo_of_cell(cell)->bottom_line = line; @@ -678,29 +701,44 @@ bool LyXTabular::SetBottomLine(int cell, bool line) } -bool LyXTabular::SetLeftLine(int cell, bool line) +bool LyXTabular::SetLeftLine(int cell, bool line, bool onlycolumn) { - column_info[column_of_cell(cell)].left_line = line; + if (onlycolumn || !IsMultiColumn(cell)) + column_info[column_of_cell(cell)].left_line = line; + else + cellinfo_of_cell(cell)->left_line = line; return true; } -bool LyXTabular::SetRightLine(int cell, bool line) +bool LyXTabular::SetRightLine(int cell, bool line, bool onlycolumn) { - column_info[right_column_of_cell(cell)].right_line = line; + if (onlycolumn || !IsMultiColumn(cell)) + column_info[right_column_of_cell(cell)].right_line = line; + else + cellinfo_of_cell(cell)->right_line = line; return true; } -char LyXTabular::GetAlignment(int cell) const +char LyXTabular::GetAlignment(int cell, bool onlycolumn) const { - if (IsMultiColumn(cell)) + if (!onlycolumn && IsMultiColumn(cell)) return cellinfo_of_cell(cell)->alignment; else return column_info[column_of_cell(cell)].alignment; } +char LyXTabular::GetVAlignment(int cell, bool onlycolumn) const +{ + if (!onlycolumn && IsMultiColumn(cell)) + return cellinfo_of_cell(cell)->valignment; + else + return column_info[column_of_cell(cell)].valignment; +} + + string LyXTabular::GetPWidth(int cell) const { if (IsMultiColumn(cell)) @@ -709,6 +747,20 @@ string LyXTabular::GetPWidth(int cell) const } +string LyXTabular::GetColumnPWidth(int cell) const +{ + return column_info[column_of_cell(cell)].p_width; +} + + +string LyXTabular::GetMColumnPWidth(int cell) const +{ + if (IsMultiColumn(cell)) + return cellinfo_of_cell(cell)->p_width; + return string(); +} + + string LyXTabular::GetAlignSpecial(int cell, int what) const { if (what == SET_SPECIAL_MULTI) @@ -871,6 +923,7 @@ void LyXTabular::Write(Buffer const * buf, ostream & os) const for (j = 0; j < columns_; ++j) { if (!i) { os << " rows_) + row = endhead; + if (abs(endhead) > rows_) return false; - return (row_of_cell(cell) == endhead); + return (row_of_cell(cell) == (abs(endhead)-1)); } -bool LyXTabular::GetRowOfLTFirstHead(int cell) const +bool LyXTabular::GetRowOfLTFirstHead(int cell, int & row) const { - if ((endfirsthead+1) > rows_) + row = endfirsthead; + if (abs(endfirsthead) > rows_) return false; - return (row_of_cell(cell) == endfirsthead); + return (row_of_cell(cell) == (abs(endfirsthead)-1)); } void LyXTabular::SetLTFoot(int cell, bool last) { int row = row_of_cell(cell); + int val = (row + 1) * (column_of_cell(cell)? 1:-1); if (last) { - if (row == endlastfoot) - endlastfoot = -1; + if (endlastfoot == val) + endlastfoot = 0; else - endlastfoot = row; + endlastfoot = val; } else { - if (row == endfoot) - endfoot = -1; + if (endfoot == val) + endfoot = 0; else - endfoot = row; + endfoot = val; } } -bool LyXTabular::GetRowOfLTFoot(int cell) const +bool LyXTabular::GetRowOfLTFoot(int cell, int & row) const { + row = endfoot; if ((endfoot+1) > rows_) return false; - return (row_of_cell(cell) == endfoot); + return (row_of_cell(cell) == (abs(endfoot)-1)); } -bool LyXTabular::GetRowOfLTLastFoot(int cell) const +bool LyXTabular::GetRowOfLTLastFoot(int cell, int & row) const { - if ((endlastfoot+1) > rows_) + row = endlastfoot; + if (abs(endlastfoot) > rows_) return false; - return (row_of_cell(cell) == endlastfoot); + return (row_of_cell(cell) == (abs(endlastfoot)-1)); } @@ -1845,7 +1911,18 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const if (LeftLine(cell)) os << '|'; if (!GetPWidth(cell).empty()) { - os << "p{" << GetPWidth(cell) << '}'; + switch(GetVAlignment(cell)) { + case LYX_VALIGN_TOP: + os << "p"; + break; + case LYX_VALIGN_CENTER: + os << "m"; + break; + case LYX_VALIGN_BOTTOM: + os << "b"; + break; + } + os << "{" << GetPWidth(cell) << '}'; } else { switch (GetAlignment(cell)) { case LYX_ALIGN_LEFT: @@ -1868,7 +1945,19 @@ int LyXTabular::TeXCellPreamble(ostream & os, int cell) const } } if (GetLinebreaks(cell)) { - os << "\\parbox[t]{" << GetPWidth(cell) << "}{\\smallskip{}"; + os << "\\parbox["; + switch(GetVAlignment(cell)) { + case LYX_VALIGN_TOP: + os << "t"; + break; + case LYX_VALIGN_CENTER: + os << "c"; + break; + case LYX_VALIGN_BOTTOM: + os << "b"; + break; + } + os << "]{" << GetPWidth(cell) << "}{\\smallskip{}"; } return ret; } @@ -1916,7 +2005,18 @@ int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) c if (!column_info[i].align_special.empty()) { os << column_info[i].align_special; } else if (!column_info[i].p_width.empty()) { - os << "p{" + switch(column_info[i].valignment) { + case LYX_VALIGN_TOP: + os << "p"; + break; + case LYX_VALIGN_CENTER: + os << "m"; + break; + case LYX_VALIGN_BOTTOM: + os << "b"; + break; + } + os << "{" << column_info[i].p_width << '}'; } else { @@ -1942,8 +2042,33 @@ int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) c //+ the single row and columns (cells) + //+--------------------------------------------------------------------- + int bret; for(i=0; i < rows_; ++i) { ret += TeXTopHLine(os, i); + bret = ret; + if (IsLongTabular()) { + if ((endhead < 0) && (i == (abs(endhead)-1))) { + os << "\\endhead\n"; + ++ret; + } + if ((endfirsthead < 0) && (i == (abs(endfirsthead)-1))) { + os << "\\endfirsthead\n"; + ++ret; + } + if ((endfoot < 0) && (i == (abs(endfoot)-1))) { + os << "\\endfoot\n"; + ++ret; + } + if ((endlastfoot < 0) && (i == (abs(endlastfoot)-1))) { + os << "\\endlastfoot\n"; + ++ret; + } + } + if (ret > bret) { + if (i > 0) + ret += TeXBottomHLine(os, i-1); + ret += TeXTopHLine(os, i); + } for(j=0; j < columns_; ++j) { if (IsPartOfMultiColumn(i,j)) continue; @@ -1958,23 +2083,26 @@ int LyXTabular::Latex(Buffer const * buf, ostream & os, bool fragile, bool fp) c } os << "\\\\" << endl; ret += TeXBottomHLine(os, i); + bret = ret; if (IsLongTabular()) { - if (i == endhead) { + if ((endhead > 0) && (i == (endhead-1))) { os << "\\endhead\n"; ++ret; } - if (i == endfirsthead) { + if ((endfirsthead > 0) && (i == (endfirsthead-1))) { os << "\\endfirsthead\n"; ++ret; } - if (i == endfoot) { + if ((endfoot > 0) && (i == (endfoot-1))) { os << "\\endfoot\n"; ++ret; } - if (i == endlastfoot) { + if ((endlastfoot > 0) && (i == (endlastfoot-1))) { os << "\\endlastfoot\n"; ++ret; } + if (ret > bret) + ret += TeXBottomHLine(os, i); if (row_info[i].newpage) { os << "\\newpage\n"; ++ret; @@ -2010,6 +2138,9 @@ void LyXTabular::Validate(LaTeXFeatures & features) const features.longtable = true; if (NeedRotating()) features.rotating = true; - for(int cell = 0; cell < numberofcells; ++cell) + for(int cell = 0; cell < numberofcells; ++cell) { + if (GetVAlignment(cell) != LYX_VALIGN_TOP) + features.array = true; GetCellInset(cell)->Validate(features); + } } diff --git a/src/tabular.h b/src/tabular.h index 0371e53805..0483d1f55b 100644 --- a/src/tabular.h +++ b/src/tabular.h @@ -30,7 +30,7 @@ class Buffer; /// class LyXTabular { public: - // Are the values of these enums important? (Lgb) + enum { APPEND_ROW = 0, APPEND_COLUMN, @@ -40,9 +40,22 @@ public: TOGGLE_LINE_BOTTOM, TOGGLE_LINE_LEFT, TOGGLE_LINE_RIGHT, - ALIGN_LEFT, // what are these alignment enums used for? + ALIGN_LEFT, ALIGN_RIGHT, ALIGN_CENTER, + VALIGN_TOP, + VALIGN_BOTTOM, + VALIGN_CENTER, + M_TOGGLE_LINE_TOP, + M_TOGGLE_LINE_BOTTOM, + M_TOGGLE_LINE_LEFT, + M_TOGGLE_LINE_RIGHT, + M_ALIGN_LEFT, + M_ALIGN_RIGHT, + M_ALIGN_CENTER, + M_VALIGN_TOP, + M_VALIGN_BOTTOM, + M_VALIGN_CENTER, DELETE_TABULAR, MULTICOLUMN, SET_ALL_LINES, @@ -50,6 +63,7 @@ public: SET_LONGTABULAR, UNSET_LONGTABULAR, SET_PWIDTH, + SET_MPWIDTH, SET_ROTATE_TABULAR, UNSET_ROTATE_TABULAR, SET_ROTATE_CELL, @@ -69,6 +83,17 @@ public: CELL_BEGIN_OF_MULTICOLUMN, CELL_PART_OF_MULTICOLUMN }; + + /// + enum VAlignment { + /// + LYX_VALIGN_TOP = 0, + /// + LYX_VALIGN_BOTTOM = 1, + /// + LYX_VALIGN_CENTER = 2 + }; + /* konstruktor */ /// LyXTabular(InsetTabular *, int columns_arg, int rows_arg); @@ -86,13 +111,13 @@ public: LyXTabular * Clone(InsetTabular *); /// Returns true if there is a topline, returns false if not - bool TopLine(int cell) const; + bool TopLine(int cell, bool onlycolumn=false) const; /// Returns true if there is a topline, returns false if not - bool BottomLine(int cell) const; + bool BottomLine(int cell, bool onlycolumn=false) const; /// Returns true if there is a topline, returns false if not - bool LeftLine(int cell) const; + bool LeftLine(int cell, bool onlycolumn=false) const; /// Returns true if there is a topline, returns false if not - bool RightLine(int cell) const; + bool RightLine(int cell, bool onlycolumn=false) const; /// bool TopAlreadyDrawed(int cell) const; @@ -126,24 +151,34 @@ public: /// Returns true if a complete update is necessary, otherwise false bool SetAllLines(int cell, bool line); /// Returns true if a complete update is necessary, otherwise false - bool SetTopLine(int cell, bool line); + bool SetTopLine(int cell, bool line, bool onlycolumn=false); + /// Returns true if a complete update is necessary, otherwise false + bool SetBottomLine(int cell, bool line, bool onlycolumn=false); /// Returns true if a complete update is necessary, otherwise false - bool SetBottomLine(int cell, bool line); + bool SetLeftLine(int cell, bool line, bool onlycolumn=false); /// Returns true if a complete update is necessary, otherwise false - bool SetLeftLine(int cell, bool line); + bool SetRightLine(int cell, bool line, bool onlycolumn=false); /// Returns true if a complete update is necessary, otherwise false - bool SetRightLine(int cell, bool line); + bool SetAlignment(int cell, char align, bool onlycolumn = false); /// Returns true if a complete update is necessary, otherwise false - bool SetAlignment(int cell, char align); + bool SetVAlignment(int cell, char align, bool onlycolumn = false); /// - bool SetPWidth(int cell, string const & width); + bool SetColumnPWidth(int cell, string const & width); + /// + bool SetMColumnPWidth(int cell, string const & width); /// bool SetAlignSpecial(int cell, string const & special, int what); /// - char GetAlignment(int cell) const; // add approp. signedness + char GetAlignment(int cell, bool onlycolumn = false) const; + /// + char GetVAlignment(int cell, bool onlycolumn = false) const; /// string GetPWidth(int cell) const; /// + string GetColumnPWidth(int cell) const; + /// + string GetMColumnPWidth(int cell) const; + /// string GetAlignSpecial(int cell, int what) const; /// int GetWidthOfCell(int cell) const; @@ -242,15 +277,15 @@ public: /// void SetLTHead(int cell, bool first); /// - bool GetRowOfLTHead(int cell) const; + bool GetRowOfLTHead(int cell, int & row) const; /// - bool GetRowOfLTFirstHead(int cell) const; + bool GetRowOfLTFirstHead(int cell, int & row) const; /// void SetLTFoot(int cell, bool last); /// - bool GetRowOfLTFoot(int cell) const; + bool GetRowOfLTFoot(int cell, int & row) const; /// - bool GetRowOfLTLastFoot(int cell) const; + bool GetRowOfLTLastFoot(int cell, int & row) const; /// void SetLTNewPage(int cell, bool what); /// @@ -284,9 +319,11 @@ private: ////////////////////////////////////////////////////////////////// /// int width_of_cell; /// - int multicolumn; // add approp. signedness + int multicolumn; + /// + int alignment; /// - int alignment; // add approp. signedness + int valignment; /// bool top_line; /// @@ -336,7 +373,8 @@ private: ////////////////////////////////////////////////////////////////// /// //columnstruct & operator=(columnstruct const &); /// - int alignment; // add approp. signedness + int alignment; + int valignment; bool left_line; bool right_line; int width_of_column;