1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 2000 The LyX Team.
8 * ======================================================
19 #pragma implementation
22 #include "insettabular.h"
25 #include "commandtags.h"
27 #include "LaTeXFeatures.h"
31 #include "lyx_gui_misc.h"
34 #include "insets/insettext.h"
35 #include "frontends/Dialogs.h"
39 const int ADD_TO_HEIGHT = 2;
40 const int ADD_TO_TABULAR_WIDTH = 2;
49 struct tabular_features {
54 //static tabular_features * tabularFeatures = 0;
56 static tabular_features tabularFeatures[] =
58 { LyXTabular::APPEND_ROW, "append-row" },
59 { LyXTabular::APPEND_COLUMN, "append-column" },
60 { LyXTabular::DELETE_ROW, "delete-row" },
61 { LyXTabular::DELETE_COLUMN, "delete-column" },
62 { LyXTabular::TOGGLE_LINE_TOP, "toggle-line-top" },
63 { LyXTabular::TOGGLE_LINE_BOTTOM, "toggle-line-bottom" },
64 { LyXTabular::TOGGLE_LINE_LEFT, "toggle-line-left" },
65 { LyXTabular::TOGGLE_LINE_RIGHT, "toggle-line-right" },
66 { LyXTabular::ALIGN_LEFT, "align-left" },
67 { LyXTabular::ALIGN_RIGHT, "align-right" },
68 { LyXTabular::ALIGN_CENTER, "align-center" },
69 { LyXTabular::VALIGN_TOP, "valign-top" },
70 { LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
71 { LyXTabular::VALIGN_CENTER, "valign-center" },
72 { LyXTabular::M_TOGGLE_LINE_TOP, "m-toggle-line-top" },
73 { LyXTabular::M_TOGGLE_LINE_BOTTOM, "m-toggle-line-bottom" },
74 { LyXTabular::M_TOGGLE_LINE_LEFT, "m-toggle-line-left" },
75 { LyXTabular::M_TOGGLE_LINE_RIGHT, "m-toggle-line-right" },
76 { LyXTabular::M_ALIGN_LEFT, "m-align-left" },
77 { LyXTabular::M_ALIGN_RIGHT, "m-align-right" },
78 { LyXTabular::M_ALIGN_CENTER, "m-align-center" },
79 { LyXTabular::M_VALIGN_TOP, "m-valign-top" },
80 { LyXTabular::M_VALIGN_BOTTOM, "m-valign-bottom" },
81 { LyXTabular::M_VALIGN_CENTER, "m-valign-center" },
82 { LyXTabular::DELETE_TABULAR, "delete-tabular" },
83 { LyXTabular::MULTICOLUMN, "multicolumn" },
84 { LyXTabular::SET_ALL_LINES, "set-all-lines" },
85 { LyXTabular::UNSET_ALL_LINES, "unset-all-lines" },
86 { LyXTabular::SET_LONGTABULAR, "set-longtabular" },
87 { LyXTabular::UNSET_LONGTABULAR, "unset-longtabular" },
88 { LyXTabular::SET_PWIDTH, "set-pwidth" },
89 { LyXTabular::SET_MPWIDTH, "set-mpwidth" },
90 { LyXTabular::SET_ROTATE_TABULAR, "set-rotate-tabular" },
91 { LyXTabular::UNSET_ROTATE_TABULAR, "unset-rotate-tabular" },
92 { LyXTabular::SET_ROTATE_CELL, "set-rotate-cell" },
93 { LyXTabular::UNSET_ROTATE_CELL, "unset-rotate-cell" },
94 { LyXTabular::SET_USEBOX, "set-usebox" },
95 { LyXTabular::SET_LTHEAD, "set-lthead" },
96 { LyXTabular::SET_LTFIRSTHEAD, "set-ltfirsthead" },
97 { LyXTabular::SET_LTFOOT, "set-ltfoot" },
98 { LyXTabular::SET_LTLASTFOOT, "set-ltlastfoot" },
99 { LyXTabular::SET_LTNEWPAGE, "set-ltnewpage" },
100 { LyXTabular::SET_SPECIAL_COLUMN, "set-special-column" },
101 { LyXTabular::SET_SPECIAL_MULTI, "set-special-multi" },
102 { LyXTabular::LAST_ACTION, "" }
105 //#define cellstart(p) ((p % 2) == 0)
107 bool cellstart(LyXParagraph::size_type p)
109 return ((p % 2) == 0);
113 InsetTabular::InsetTabular(Buffer * buf, int rows, int columns)
120 tabular = new LyXTabular(this, rows,columns);
121 // for now make it always display as display() inset
123 the_locking_inset = 0;
124 locked = no_selection = cursor_visible = false;
129 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
135 InsetTabular::InsetTabular(InsetTabular const & tab, Buffer * buf)
138 tabular = new LyXTabular(this, *(tab.tabular));
139 the_locking_inset = 0;
140 locked = no_selection = cursor_visible = false;
145 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
151 InsetTabular::~InsetTabular()
155 dialogs_->hideTabular(this);
159 Inset * InsetTabular::Clone() const
161 InsetTabular * t = new InsetTabular(*this, buffer);
163 t->tabular = tabular->Clone(t);
168 void InsetTabular::Write(Buffer const * buf, ostream & os) const
170 os << " Tabular" << endl;
171 tabular->Write(buf, os);
175 void InsetTabular::Read(Buffer const * buf, LyXLex & lex)
177 bool old_format = (lex.GetString() == "\\LyXTable");
182 tabular = new LyXTabular(buf, this, lex);
190 token = lex.GetString();
191 while (lex.IsOK() && (token != "\\end_inset")) {
193 token = lex.GetString();
195 if (token != "\\end_inset") {
196 lex.printError("Missing \\end_inset at this point. "
202 int InsetTabular::ascent(BufferView *, LyXFont const &) const
204 return tabular->GetAscentOfRow(0);
208 int InsetTabular::descent(BufferView *, LyXFont const &) const
210 return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
214 int InsetTabular::width(BufferView *, LyXFont const &) const
216 return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
220 void InsetTabular::draw(BufferView * bv, LyXFont const & font, int baseline,
221 float & x, bool cleared) const
223 Painter & pain = bv->painter();
228 UpdatableInset::draw(bv,font,baseline,x,cleared);
229 if (!cleared && ((need_update == INIT) || (need_update == FULL) ||
230 (top_x != int(x)) || (top_baseline != baseline))) {
231 int h = ascent(bv, font) + descent(bv, font);
232 int tx = display()||!owner()? 0:top_x;
233 int w = tx? width(bv, font):pain.paperWidth();
234 int ty = baseline - ascent(bv, font);
238 if ((ty + h) > pain.paperHeight())
239 h = pain.paperHeight();
240 if ((top_x + w) > pain.paperWidth())
241 w = pain.paperWidth();
242 pain.fillRectangle(tx, ty, w, h);
247 top_baseline = baseline;
248 if (bv->text->status == LyXText::CHANGED_IN_DRAW)
251 x += ADD_TO_TABULAR_WIDTH;
252 if (cleared || (need_update == FULL) || (need_update == CELL)) {
253 for(i=0;i<tabular->rows();++i) {
255 dodraw = ((baseline+tabular->GetDescentOfRow(i)) > 0) &&
256 (baseline-tabular->GetAscentOfRow(i)) < pain.paperHeight();
257 for(j=0;j<tabular->columns();++j) {
258 if (tabular->IsPartOfMultiColumn(i,j))
260 cx = nx + tabular->GetBeginningOfTextInCell(cell);
262 DrawCellSelection(pain, nx, baseline, i, j, cell);
263 if (dodraw && !cleared && locked && the_locking_inset) {
264 if (the_locking_inset == tabular->GetCellInset(cell)) {
265 LyXText::text_status st = bv->text->status;
267 bv->text->status = st;
268 if (need_update == CELL) {
269 // clear before the inset
272 baseline - tabular->GetAscentOfRow(i)+1,
274 tabular->GetAscentOfRow(i) +
275 tabular->GetDescentOfRow(i) - 1);
276 // clear behind the inset
278 cx + the_locking_inset->width(bv,font) + 1,
279 baseline - tabular->GetAscentOfRow(i)+1,
280 tabular->GetWidthOfColumn(cell) -
281 tabular->GetBeginningOfTextInCell(cell) -
282 the_locking_inset->width(bv,font) - 1,
283 tabular->GetAscentOfRow(i) +
284 tabular->GetDescentOfRow(i) - 1);
286 tabular->GetCellInset(cell)->draw(
287 bv, font, baseline, cx, false);
288 // if (need_update == CELL)
289 // DrawCellLines(pain, nx, baseline, i, cell);
290 } while(bv->text->status == LyXText::CHANGED_IN_DRAW);
293 tabular->GetCellInset(cell)->draw(bv, font, baseline, cx,
295 DrawCellLines(pain, nx, baseline, i, cell);
297 nx += tabular->GetWidthOfColumn(cell);
300 baseline += tabular->GetDescentOfRow(i) +
301 tabular->GetAscentOfRow(i+1)+
302 tabular->GetAdditionalHeight(cell+1);
305 x += width(bv, font);
306 if (bv->text->status == LyXText::CHANGED_IN_DRAW)
313 void InsetTabular::DrawCellLines(Painter & pain, int x, int baseline,
314 int row, int cell) const
316 int x2 = x + tabular->GetWidthOfColumn(cell);
319 if (!tabular->TopAlreadyDrawed(cell)) {
320 on_off = !tabular->TopLine(cell);
321 pain.line(x, baseline - tabular->GetAscentOfRow(row),
322 x2, baseline - tabular->GetAscentOfRow(row),
323 on_off ? LColor::tabularonoffline:LColor::tabularline,
324 on_off ? Painter::line_onoffdash:Painter::line_solid);
326 on_off = !tabular->BottomLine(cell);
327 pain.line(x,baseline + tabular->GetDescentOfRow(row),
328 x2, baseline + tabular->GetDescentOfRow(row),
329 on_off ? LColor::tabularonoffline:LColor::tabularline,
330 on_off ? Painter::line_onoffdash:Painter::line_solid);
331 if (!tabular->LeftAlreadyDrawed(cell)) {
332 on_off = !tabular->LeftLine(cell);
333 pain.line(x, baseline - tabular->GetAscentOfRow(row),
334 x, baseline + tabular->GetDescentOfRow(row),
335 on_off ? LColor::tabularonoffline:LColor::tabularline,
336 on_off ? Painter::line_onoffdash:Painter::line_solid);
338 on_off = !tabular->RightLine(cell);
339 pain.line(x2 - tabular->GetAdditionalWidth(cell),
340 baseline - tabular->GetAscentOfRow(row),
341 x2 - tabular->GetAdditionalWidth(cell),
342 baseline + tabular->GetDescentOfRow(row),
343 on_off ? LColor::tabularonoffline:LColor::tabularline,
344 on_off ? Painter::line_onoffdash:Painter::line_solid);
348 void InsetTabular::DrawCellSelection(Painter & pain, int x, int baseline,
349 int row, int column, int cell) const
351 int cs = tabular->column_of_cell(sel_cell_start);
352 int ce = tabular->column_of_cell(sel_cell_end);
355 cs = tabular->column_of_cell(sel_cell_end);
357 ce = tabular->right_column_of_cell(sel_cell_end);
360 int rs = tabular->row_of_cell(sel_cell_start);
361 int re = tabular->row_of_cell(sel_cell_end);
362 if (rs > re) swap(rs, re);
364 if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
365 int w = tabular->GetWidthOfColumn(cell);
366 int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
367 pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
368 w, h, LColor::selection);
373 void InsetTabular::update(BufferView * bv, LyXFont const & font, bool reinit)
377 calculate_dimensions_of_cells(bv, font, true);
379 owner()->update(bv, font, true);
382 if (the_locking_inset)
383 the_locking_inset->update(bv, font, reinit);
384 switch(need_update) {
388 if (calculate_dimensions_of_cells(bv, font, false))
400 char const * InsetTabular::EditMessage() const
402 return _("Opened Tabular Inset");
406 void InsetTabular::Edit(BufferView * bv, int x, int y, unsigned int button)
408 UpdatableInset::Edit(bv, x, y, button);
410 if (!bv->lockInset(this)) {
411 lyxerr[Debug::INSETS] << "InsetTabular::Cannot lock inset" << endl;
415 the_locking_inset = 0;
416 inset_pos = inset_x = inset_y = 0;
418 sel_pos_start = sel_pos_end = cursor.pos();
419 sel_cell_start = sel_cell_end = actcell;
420 bv->text->FinishUndo();
421 if (InsetHit(bv, x, y)) {
422 ActivateCellInset(bv, x, y, button);
424 UpdateLocal(bv, NONE, false);
425 // bv->getOwner()->getPopups().updateFormTabular();
429 void InsetTabular::InsetUnlock(BufferView * bv)
431 if (the_locking_inset) {
432 the_locking_inset->InsetUnlock(bv);
433 the_locking_inset = 0;
436 no_selection = false;
439 if (scroll() || hasSelection()) {
441 scroll(bv, (float)0.0);
443 sel_pos_start = sel_pos_end = 0;
444 sel_cell_start = sel_cell_end = 0;
446 UpdateLocal(bv, FULL, false);
451 void InsetTabular::UpdateLocal(BufferView * bv, UpdateCodes what,
452 bool mark_dirty) const
455 bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
456 if (locked && (what != NONE))
461 bool InsetTabular::LockInsetInInset(BufferView * bv, UpdatableInset * inset)
463 lyxerr[Debug::INSETS] << "InsetTabular::LockInsetInInset(" <<inset<< "): ";
467 if (inset == tabular->GetCellInset(actcell)) {
468 lyxerr[Debug::INSETS] << "OK" << endl;
469 the_locking_inset = tabular->GetCellInset(actcell);
471 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
472 inset_y = cursor.y();
473 inset_pos = cursor.pos();
475 } else if (the_locking_inset && (the_locking_inset == inset)) {
476 if (cursor.pos() == inset_pos) {
477 lyxerr[Debug::INSETS] << "OK" << endl;
479 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
480 inset_y = cursor.y();
482 lyxerr[Debug::INSETS] << "cursor.pos != inset_pos" << endl;
484 } else if (the_locking_inset) {
485 lyxerr[Debug::INSETS] << "MAYBE" << endl;
486 return the_locking_inset->LockInsetInInset(bv, inset);
488 lyxerr[Debug::INSETS] << "NOT OK" << endl;
493 bool InsetTabular::UnlockInsetInInset(BufferView * bv, UpdatableInset * inset,
496 if (!the_locking_inset)
498 if (the_locking_inset == inset) {
499 the_locking_inset->InsetUnlock(bv);
500 the_locking_inset = 0;
502 moveRight(bv, false);
503 UpdateLocal(bv, CELL, false);
506 if (the_locking_inset->UnlockInsetInInset(bv, inset, lr)) {
507 if ((inset->LyxCode() == TABULAR_CODE) &&
508 !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))
510 dialogs_ = bv->owner()->getDialogs();
511 dialogs_->updateTabular(const_cast<InsetTabular *>(this));
520 bool InsetTabular::UpdateInsetInInset(BufferView * bv, Inset * inset)
522 if (!the_locking_inset)
524 if (the_locking_inset != inset)
525 return the_locking_inset->UpdateInsetInInset(bv, inset);
526 UpdateLocal(bv, CELL, false);
531 int InsetTabular::InsetInInsetY()
533 if (!the_locking_inset)
536 return (inset_y + the_locking_inset->InsetInInsetY());
540 UpdatableInset * InsetTabular::GetLockingInset()
542 return the_locking_inset ? the_locking_inset->GetLockingInset() : this;
546 UpdatableInset * InsetTabular::GetFirstLockingInsetOfType(Inset::Code c)
550 if (the_locking_inset)
551 return the_locking_inset->GetFirstLockingInsetOfType(c);
556 bool InsetTabular::InsertInset(BufferView * bv, Inset * inset)
558 if (the_locking_inset)
559 return the_locking_inset->InsertInset(bv, inset);
564 void InsetTabular::InsetButtonPress(BufferView * bv, int x, int y, int button)
566 if (hasSelection()) {
567 sel_pos_start = sel_pos_end = sel_cell_start = sel_cell_end = 0;
568 UpdateLocal(bv, SELECTION, false);
570 no_selection = false;
578 UpdateLocal(bv, NONE, false);
579 sel_pos_start = sel_pos_end = cursor.pos();
580 sel_cell_start = sel_cell_end = actcell;
582 bool inset_hit = InsetHit(bv, x, y);
584 if ((ocell == actcell) && the_locking_inset && inset_hit) {
585 the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
587 } else if (the_locking_inset) {
588 the_locking_inset->InsetUnlock(bv);
590 the_locking_inset = 0;
591 if (inset_hit && bv->the_locking_inset) {
592 ActivateCellInset(bv, x, y, button);
593 the_locking_inset->InsetButtonPress(bv, x-inset_x, y-inset_y, button);
599 void InsetTabular::InsetButtonRelease(BufferView * bv,
600 int x, int y, int button)
603 if (the_locking_inset) {
605 if ((i=the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE))) {
606 i->InsetButtonRelease(bv, x, y, button);
610 dialogs_ = bv->owner()->getDialogs();
611 dialogs_->showTabular(this);
613 else if (ocell != actcell)
614 bview->getOwner()->getPopups().updateTabular();
618 if (the_locking_inset) {
619 the_locking_inset->InsetButtonRelease(bv, x-inset_x, y-inset_y,button);
622 no_selection = false;
626 void InsetTabular::InsetMotionNotify(BufferView * bv, int x, int y, int button)
628 if (the_locking_inset) {
629 the_locking_inset->InsetMotionNotify(bv, x - inset_x,
630 y - inset_y, button);
634 // int ocell = actcell,
635 int old = sel_pos_end;
638 sel_pos_end = cursor.pos();
639 sel_cell_end = actcell;
640 if (old != sel_pos_end)
641 UpdateLocal(bv, SELECTION, false);
643 if (ocell != actcell)
644 bview->getOwner()->getPopups().updateFormTabular();
647 no_selection = false;
651 void InsetTabular::InsetKeyPress(XKeyEvent * xke)
653 if (the_locking_inset) {
654 the_locking_inset->InsetKeyPress(xke);
660 UpdatableInset::RESULT InsetTabular::LocalDispatch(BufferView * bv, int action,
663 UpdatableInset::RESULT
666 no_selection = false;
667 if (((result=UpdatableInset::LocalDispatch(bv, action, arg)) == DISPATCHED)
668 || (result == DISPATCHED_NOUPDATE)) {
674 if ((action < 0) && arg.empty())
677 if ((action != LFUN_DOWN) && (action != LFUN_UP) &&
678 (action != LFUN_DOWNSEL) && (action != LFUN_UPSEL))
680 if (the_locking_inset) {
681 result=the_locking_inset->LocalDispatch(bv, action, arg);
682 if (result == DISPATCHED_NOUPDATE)
684 else if (result == DISPATCHED) {
685 the_locking_inset->ToggleInsetCursor(bv);
686 UpdateLocal(bv, CELL, false);
687 the_locking_inset->ToggleInsetCursor(bv);
689 } else if (result == FINISHED) {
690 if ((action == LFUN_RIGHT) || (action == -1)) {
691 cursor.pos(inset_pos + 1);
694 sel_pos_start = sel_pos_end = cursor.pos();
695 sel_cell_start = sel_cell_end = actcell;
702 bool hs = hasSelection();
706 // Normal chars not handled here
709 // --- Cursor Movements ---------------------------------------------
711 if (tabular->IsLastCellInRow(actcell) && !cellstart(cursor.pos()))
713 moveRight(bv, false);
714 sel_pos_end = cursor.pos();
715 if (!cellstart(cursor.pos())) {
716 if (tabular->right_column_of_cell(sel_cell_start) >
717 tabular->right_column_of_cell(actcell))
718 sel_cell_end = actcell+1;
720 sel_cell_end = actcell;
722 UpdateLocal(bv, SELECTION, false);
725 result = moveRight(bv);
726 sel_pos_start = sel_pos_end = cursor.pos();
727 sel_cell_start = sel_cell_end = actcell;
729 UpdateLocal(bv, SELECTION, false);
732 if (tabular->IsFirstCellInRow(actcell) && cellstart(cursor.pos()))
735 sel_pos_end = cursor.pos();
736 if (cellstart(cursor.pos())) {
737 if (tabular->column_of_cell(sel_cell_start) >=
738 tabular->column_of_cell(actcell))
739 sel_cell_end = actcell;
741 sel_cell_end = actcell-1;
743 UpdateLocal(bv, SELECTION, false);
746 result = moveLeft(bv);
747 sel_pos_start = sel_pos_end = cursor.pos();
748 sel_cell_start = sel_cell_end = actcell;
750 UpdateLocal(bv, SELECTION, false);
756 sel_pos_end = cursor.pos();
757 if ((ocell == sel_cell_end) ||
758 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
759 sel_cell_end = tabular->GetCellBelow(sel_cell_end);
761 sel_cell_end = tabular->GetLastCellBelow(sel_cell_end);
762 UpdateLocal(bv, SELECTION, false);
766 result= moveDown(bv);
767 sel_pos_start = sel_pos_end = cursor.pos();
768 sel_cell_start = sel_cell_end = actcell;
770 UpdateLocal(bv, SELECTION, false);
776 sel_pos_end = cursor.pos();
777 if ((ocell == sel_cell_end) ||
778 (tabular->column_of_cell(ocell)>tabular->column_of_cell(actcell)))
779 sel_cell_end = tabular->GetCellAbove(sel_cell_end);
781 sel_cell_end = tabular->GetLastCellAbove(sel_cell_end);
782 UpdateLocal(bv, SELECTION, false);
787 sel_pos_start = sel_pos_end = cursor.pos();
788 sel_cell_start = sel_cell_end = actcell;
790 UpdateLocal(bv, SELECTION, false);
802 if (the_locking_inset) {
803 UnlockInsetInInset(bv, the_locking_inset);
804 the_locking_inset = 0;
806 if (action == LFUN_TAB)
810 sel_pos_start = sel_pos_end = cursor.pos();
811 sel_cell_start = sel_cell_end = actcell;
813 UpdateLocal(bv, SELECTION, false);
815 case LFUN_LAYOUT_TABLE:
817 dialogs_ = bv->owner()->getDialogs();
818 dialogs_->showTabular(this);
821 case LFUN_TABULAR_FEATURE:
822 if (!TabularFeatures(bv, arg))
823 result = UNDISPATCHED;
827 result = UNDISPATCHED;
830 if (result!=FINISHED) {
831 if (!the_locking_inset) {
833 if (ocell != actcell)
834 bview->getOwner()->getPopups().updateFormTabular();
839 bv->unlockInset(this);
844 int InsetTabular::Latex(Buffer const * buf, ostream & os,
845 bool fragile, bool fp) const
847 return tabular->Latex(buf, os, fragile, fp);
851 int InsetTabular::Ascii(Buffer const *, ostream &) const
857 int InsetTabular::Linuxdoc(Buffer const *, ostream &) const
863 int InsetTabular::DocBook(Buffer const *, ostream &) const
869 void InsetTabular::Validate(LaTeXFeatures & features) const
871 tabular->Validate(features);
875 bool InsetTabular::calculate_dimensions_of_cells(BufferView * bv,
876 LyXFont const & font,
882 bool changed = false;
884 for(int i = 0; i < tabular->rows(); ++i) {
885 maxAsc = maxDesc = 0;
886 for(int j= 0; j < tabular->columns(); ++j) {
887 if (tabular->IsPartOfMultiColumn(i,j))
890 inset = tabular->GetCellInset(cell);
892 inset->update(bv, font, false);
893 maxAsc = max(maxAsc, inset->ascent(bv, font));
894 maxDesc = max(maxDesc, inset->descent(bv, font));
895 changed = tabular->SetWidthOfCell(cell, inset->width(bv, font)) || changed;
897 changed = tabular->SetAscentOfRow(i, maxAsc + ADD_TO_HEIGHT) || changed;
898 changed = tabular->SetDescentOfRow(i, maxDesc + ADD_TO_HEIGHT) || changed;
904 void InsetTabular::GetCursorPos(BufferView *, int & x, int & y) const
906 x = cursor.x() - top_x;
911 void InsetTabular::ToggleInsetCursor(BufferView * bv)
913 if (the_locking_inset) {
914 the_locking_inset->ToggleInsetCursor(bv);
918 LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
920 int asc = lyxfont::maxAscent(font);
921 int desc = lyxfont::maxDescent(font);
924 bv->hideLockedInsetCursor();
926 bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
927 cursor_visible = !cursor_visible;
931 void InsetTabular::ShowInsetCursor(BufferView * bv)
933 if (!cursor_visible) {
934 LyXFont font; // = GetFont(par, cursor.pos);
936 int asc = lyxfont::maxAscent(font);
937 int desc = lyxfont::maxDescent(font);
938 bv->fitLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
939 bv->showLockedInsetCursor(cursor.x(), cursor.y(), asc, desc);
940 cursor_visible = true;
945 void InsetTabular::HideInsetCursor(BufferView * bv)
947 if (cursor_visible) {
948 bv->hideLockedInsetCursor();
949 cursor_visible = false;
951 // if (cursor_visible)
952 // ToggleInsetCursor(bv);
956 void InsetTabular::setPos(BufferView * bv, int x, int y) const
961 actcell = actrow = actcol = 0;
962 int ly = tabular->GetDescentOfRow(actrow);
964 // first search the right row
965 while((ly < y) && (actrow < tabular->rows())) {
966 cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
967 tabular->GetAscentOfRow(actrow+1) +
968 tabular->GetAdditionalHeight(tabular->GetCellNumber(actrow + 1,
971 ly = cursor.y() + tabular->GetDescentOfRow(actrow);
973 actcell = tabular->GetCellNumber(actrow, actcol);
975 // now search the right column
976 int lx = tabular->GetWidthOfColumn(actcell) -
977 tabular->GetAdditionalWidth(actcell);
978 for(; !tabular->IsLastCellInRow(actcell) && (lx < x);
979 ++actcell,lx += tabular->GetWidthOfColumn(actcell) +
980 tabular->GetAdditionalWidth(actcell - 1));
983 if ((lx - (tabular->GetWidthOfColumn(actcell)/2)) < x) {
984 cursor.x(lx + top_x - 2);
987 cursor.x(lx - tabular->GetWidthOfColumn(actcell) + top_x + 2);
993 int InsetTabular::getCellXPos(int cell) const
997 for(c=cell;!tabular->IsFirstCellInRow(c);--c)
999 int lx = tabular->GetWidthOfColumn(cell);
1000 for(; (c < cell); ++c) {
1001 lx += tabular->GetWidthOfColumn(c);
1003 return (lx - tabular->GetWidthOfColumn(cell) + top_x);
1007 void InsetTabular::resetPos(BufferView * bv) const
1011 actcol = tabular->column_of_cell(actcell);
1016 for(; (cell<actcell) && !tabular->IsLastRow(cell); ++cell) {
1017 if (tabular->IsLastCellInRow(cell)) {
1018 cursor.y(cursor.y() + tabular->GetDescentOfRow(actrow) +
1019 tabular->GetAscentOfRow(actrow + 1) +
1020 tabular->GetAdditionalHeight(cell + 1));
1024 static int offset = ADD_TO_TABULAR_WIDTH + 2;
1025 cursor.x(getCellXPos(actcell) + offset);
1026 if (((cursor.x() - offset) > 20) &&
1027 ((cursor.x()-offset+tabular->GetWidthOfColumn(actcell)) >
1028 (bv->workWidth()-20)))
1030 scroll(bv, -tabular->GetWidthOfColumn(actcell)-20);
1031 UpdateLocal(bv, FULL, false);
1032 } else if ((cursor.x() - offset) < 20) {
1033 scroll(bv, 20 - cursor.x() + offset);
1034 UpdateLocal(bv, FULL, false);
1035 } else if (!cellstart(cursor.pos())) {
1036 LyXFont font(LyXFont::ALL_SANE);
1037 cursor.x(cursor.x() + tabular->GetCellInset(actcell)->width(bv,font) +
1038 tabular->GetBeginningOfTextInCell(actcell));
1040 if ((!the_locking_inset ||
1041 !the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE)) &&
1042 (actcell != oldcell)) {
1043 dialogs_ = bv->owner()->getDialogs();
1044 dialogs_->updateTabular(const_cast<InsetTabular *>(this));
1050 UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
1052 if (!cellstart(cursor.pos())) {
1053 if (tabular->IsLastCell(actcell))
1056 cursor.pos(cursor.pos() + 1);
1058 if (ActivateCellInset(bv))
1060 } else { // before the inset
1061 cursor.pos(cursor.pos() + 1);
1064 return DISPATCHED_NOUPDATE;
1068 UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
1070 if (!cursor.pos()) {
1075 cursor.pos(cursor.pos() - 1);
1076 if (!cellstart(cursor.pos())) {
1078 } else if (lock) { // behind the inset
1079 if (ActivateCellInset(bv, 0, 0, 0, true))
1083 return DISPATCHED_NOUPDATE;
1087 UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv)
1089 int ocell = actcell;
1090 actcell = tabular->GetCellAbove(actcell);
1091 if (actcell == ocell) // we moved out of the inset
1094 return DISPATCHED_NOUPDATE;
1098 UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv)
1100 int ocell = actcell;
1101 actcell = tabular->GetCellBelow(actcell);
1102 if (actcell == ocell) // we moved out of the inset
1105 return DISPATCHED_NOUPDATE;
1109 bool InsetTabular::moveNextCell(BufferView * bv)
1111 if (tabular->IsLastCell(actcell))
1114 cursor.pos(cursor.pos() + 1);
1115 if (!cellstart(cursor.pos()))
1116 cursor.pos(cursor.pos() + 1);
1122 bool InsetTabular::movePrevCell(BufferView * bv)
1124 if (!actcell) // first cell
1127 cursor.pos(cursor.pos() - 1);
1128 if (cellstart(cursor.pos()))
1129 cursor.pos(cursor.pos() - 1);
1135 bool InsetTabular::Delete()
1141 void InsetTabular::SetFont(BufferView * bv, LyXFont const & font, bool tall)
1143 if (the_locking_inset)
1144 the_locking_inset->SetFont(bv, font, tall);
1148 bool InsetTabular::TabularFeatures(BufferView * bv, string what)
1150 int action = LyXTabular::LAST_ACTION;
1154 for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
1155 if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
1156 tabularFeatures[i].feature.length())) {
1157 action = tabularFeatures[i].action;
1161 if (action == LyXTabular::LAST_ACTION)
1164 val = frontStrip(what.substr(tabularFeatures[i].feature.length()));
1165 TabularFeatures(bv, action, val);
1170 void InsetTabular::TabularFeatures(BufferView * bv, int feature, string value)
1179 setAlign = LYX_ALIGN_LEFT,
1185 case LyXTabular::M_ALIGN_LEFT:
1186 case LyXTabular::ALIGN_LEFT:
1187 setAlign=LYX_ALIGN_LEFT;
1189 case LyXTabular::M_ALIGN_RIGHT:
1190 case LyXTabular::ALIGN_RIGHT:
1191 setAlign=LYX_ALIGN_RIGHT;
1193 case LyXTabular::M_ALIGN_CENTER:
1194 case LyXTabular::ALIGN_CENTER:
1195 setAlign=LYX_ALIGN_CENTER;
1197 case LyXTabular::M_VALIGN_TOP:
1198 case LyXTabular::VALIGN_TOP:
1199 setAlign=LyXTabular::LYX_VALIGN_TOP;
1201 case LyXTabular::M_VALIGN_BOTTOM:
1202 case LyXTabular::VALIGN_BOTTOM:
1203 setAlign=LyXTabular::LYX_VALIGN_BOTTOM;
1205 case LyXTabular::M_VALIGN_CENTER:
1206 case LyXTabular::VALIGN_CENTER:
1207 setAlign=LyXTabular::LYX_VALIGN_CENTER;
1212 if (hasSelection()) {
1214 sel_col_start = tabular->column_of_cell(sel_cell_start);
1215 sel_col_end = tabular->column_of_cell(sel_cell_end);
1216 if (sel_col_start > sel_col_end) {
1217 sel_col_end = sel_col_start;
1218 sel_col_start = tabular->column_of_cell(sel_cell_end);
1220 sel_col_end = tabular->right_column_of_cell(sel_cell_end);
1223 sel_row_start = tabular->row_of_cell(sel_cell_start);
1224 sel_row_end = tabular->row_of_cell(sel_cell_end);
1225 if (sel_row_start > sel_row_end) {
1226 tmp = sel_row_start;
1227 sel_row_start = sel_row_end;
1231 sel_col_start = sel_col_end = tabular->column_of_cell(actcell);
1232 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1234 bv->text->SetUndo(bv->buffer(), Undo::FINISH,
1236 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->previous,
1237 bv->text->cursor.par()->ParFromPos(bv->text->cursor.pos())->next
1239 bv->text->cursor.par()->previous,
1240 bv->text->cursor.par()->next
1244 int row = tabular->row_of_cell(actcell);
1245 int column = tabular->column_of_cell(actcell);
1249 case LyXTabular::SET_PWIDTH:
1251 bool update = (tabular->GetColumnPWidth(actcell) != value);
1252 tabular->SetColumnPWidth(actcell,value);
1254 for (int i=0; i < tabular->rows(); ++i) {
1255 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1258 UpdateLocal(bv, INIT, true);
1262 case LyXTabular::SET_MPWIDTH:
1264 bool update = (tabular->GetPWidth(actcell) != value);
1265 tabular->SetMColumnPWidth(actcell,value);
1267 for (int i=0; i < tabular->rows(); ++i) {
1268 tabular->GetCellInset(tabular->GetCellNumber(i, column))->
1271 UpdateLocal(bv, INIT, true);
1275 case LyXTabular::SET_SPECIAL_COLUMN:
1276 case LyXTabular::SET_SPECIAL_MULTI:
1277 tabular->SetAlignSpecial(actcell,value,feature);
1279 case LyXTabular::APPEND_ROW:
1280 // append the row into the tabular
1281 UnlockInsetInInset(bv, the_locking_inset);
1282 tabular->AppendRow(actcell);
1283 UpdateLocal(bv, INIT, true);
1285 case LyXTabular::APPEND_COLUMN:
1286 // append the column into the tabular
1287 tabular->AppendColumn(actcell);
1288 actcell = tabular->GetCellNumber(row, column);
1289 UpdateLocal(bv, INIT, true);
1291 case LyXTabular::DELETE_ROW:
1292 tabular->DeleteRow(tabular->row_of_cell(actcell));
1293 if ((row+1) > tabular->rows())
1295 actcell = tabular->GetCellNumber(row, column);
1296 UpdateLocal(bv, INIT, true);
1298 case LyXTabular::DELETE_COLUMN:
1299 tabular->DeleteColumn(tabular->column_of_cell(actcell));
1300 if ((column+1) > tabular->columns())
1302 actcell = tabular->GetCellNumber(row, column);
1303 UpdateLocal(bv, INIT, true);
1305 case LyXTabular::M_TOGGLE_LINE_TOP:
1307 case LyXTabular::TOGGLE_LINE_TOP:
1308 lineSet = !tabular->TopLine(actcell, flag);
1309 for(i=sel_row_start; i<=sel_row_end; ++i)
1310 for(j=sel_col_start; j<=sel_col_end; ++j)
1311 tabular->SetTopLine(tabular->GetCellNumber(i,j),lineSet, flag);
1312 UpdateLocal(bv, INIT, true);
1315 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1317 case LyXTabular::TOGGLE_LINE_BOTTOM:
1318 lineSet = !tabular->BottomLine(actcell, flag);
1319 for(i=sel_row_start; i<=sel_row_end; ++i)
1320 for(j=sel_col_start; j<=sel_col_end; ++j)
1321 tabular->SetBottomLine(tabular->GetCellNumber(i,j),lineSet,
1323 UpdateLocal(bv, INIT, true);
1326 case LyXTabular::M_TOGGLE_LINE_LEFT:
1328 case LyXTabular::TOGGLE_LINE_LEFT:
1329 lineSet = !tabular->LeftLine(actcell, flag);
1330 for(i=sel_row_start; i<=sel_row_end; ++i)
1331 for(j=sel_col_start; j<=sel_col_end; ++j)
1332 tabular->SetLeftLine(tabular->GetCellNumber(i,j),lineSet,
1334 UpdateLocal(bv, INIT, true);
1337 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1339 case LyXTabular::TOGGLE_LINE_RIGHT:
1340 lineSet = !tabular->RightLine(actcell, flag);
1341 for(i=sel_row_start; i<=sel_row_end; ++i)
1342 for(j=sel_col_start; j<=sel_col_end; ++j)
1343 tabular->SetRightLine(tabular->GetCellNumber(i,j),lineSet,
1345 UpdateLocal(bv, INIT, true);
1347 case LyXTabular::M_ALIGN_LEFT:
1348 case LyXTabular::M_ALIGN_RIGHT:
1349 case LyXTabular::M_ALIGN_CENTER:
1351 case LyXTabular::ALIGN_LEFT:
1352 case LyXTabular::ALIGN_RIGHT:
1353 case LyXTabular::ALIGN_CENTER:
1354 for(i=sel_row_start; i<=sel_row_end; ++i)
1355 for(j=sel_col_start; j<=sel_col_end; ++j)
1356 tabular->SetAlignment(tabular->GetCellNumber(i,j),setAlign,
1359 UpdateLocal(bv, INIT, true);
1361 UpdateLocal(bv, CELL, true);
1363 case LyXTabular::M_VALIGN_TOP:
1364 case LyXTabular::M_VALIGN_BOTTOM:
1365 case LyXTabular::M_VALIGN_CENTER:
1367 case LyXTabular::VALIGN_TOP:
1368 case LyXTabular::VALIGN_BOTTOM:
1369 case LyXTabular::VALIGN_CENTER:
1370 for(i=sel_row_start; i<=sel_row_end; ++i)
1371 for(j=sel_col_start; j<=sel_col_end; ++j)
1372 tabular->SetVAlignment(tabular->GetCellNumber(i,j), setAlign,
1375 UpdateLocal(bv, INIT, true);
1377 UpdateLocal(bv, CELL, true);
1379 case LyXTabular::MULTICOLUMN:
1381 if (sel_row_start != sel_row_end) {
1382 WriteAlert(_("Impossible Operation!"),
1383 _("Multicolumns can only be horizontally."),
1387 // just multicol for one Single Cell
1388 if (!hasSelection()) {
1389 // check wether we are completly in a multicol
1390 if (tabular->IsMultiColumn(actcell)) {
1391 tabular->UnsetMultiColumn(actcell);
1392 UpdateLocal(bv, INIT, true);
1394 tabular->SetMultiColumn(actcell, 1);
1395 UpdateLocal(bv, CELL, true);
1399 // we have a selection so this means we just add all this
1400 // cells to form a multicolumn cell
1404 if (sel_cell_start > sel_cell_end) {
1405 s_start = sel_cell_end;
1406 s_end = sel_cell_start;
1408 s_start = sel_cell_start;
1409 s_end = sel_cell_end;
1411 tabular->SetMultiColumn(s_start, s_end - s_start + 1);
1414 sel_cell_end = sel_cell_start;
1415 sel_pos_end = sel_pos_start;
1416 UpdateLocal(bv, INIT, true);
1419 case LyXTabular::SET_ALL_LINES:
1421 case LyXTabular::UNSET_ALL_LINES:
1422 for(i=sel_row_start; i<=sel_row_end; ++i)
1423 for(j=sel_col_start; j<=sel_col_end; ++j)
1424 tabular->SetAllLines(tabular->GetCellNumber(i,j), setLines);
1425 UpdateLocal(bv, INIT, true);
1427 case LyXTabular::SET_LONGTABULAR:
1428 tabular->SetLongTabular(true);
1429 UpdateLocal(bv, INIT, true); // because this toggles displayed
1431 case LyXTabular::UNSET_LONGTABULAR:
1432 tabular->SetLongTabular(false);
1433 UpdateLocal(bv, INIT, true); // because this toggles displayed
1435 case LyXTabular::SET_ROTATE_TABULAR:
1436 tabular->SetRotateTabular(true);
1438 case LyXTabular::UNSET_ROTATE_TABULAR:
1439 tabular->SetRotateTabular(false);
1441 case LyXTabular::SET_ROTATE_CELL:
1442 for(i=sel_row_start; i<=sel_row_end; ++i)
1443 for(j=sel_col_start; j<=sel_col_end; ++j)
1444 tabular->SetRotateCell(tabular->GetCellNumber(i,j),true);
1446 case LyXTabular::UNSET_ROTATE_CELL:
1447 for(i=sel_row_start; i<=sel_row_end; ++i)
1448 for(j=sel_col_start; j<=sel_col_end; ++j)
1449 tabular->SetRotateCell(tabular->GetCellNumber(i,j),false);
1451 case LyXTabular::SET_USEBOX:
1453 int val = strToInt(value);
1454 if (val == tabular->GetUsebox(actcell))
1456 for(i=sel_row_start; i<=sel_row_end; ++i)
1457 for(j=sel_col_start; j<=sel_col_end; ++j)
1458 tabular->SetUsebox(tabular->GetCellNumber(i,j),val);
1461 case LyXTabular::SET_LTFIRSTHEAD:
1462 tabular->SetLTHead(actcell,true);
1464 case LyXTabular::SET_LTHEAD:
1465 tabular->SetLTHead(actcell,false);
1467 case LyXTabular::SET_LTFOOT:
1468 tabular->SetLTFoot(actcell,false);
1470 case LyXTabular::SET_LTLASTFOOT:
1471 tabular->SetLTFoot(actcell,true);
1473 case LyXTabular::SET_LTNEWPAGE:
1474 what = !tabular->GetLTNewPage(actcell);
1475 tabular->SetLTNewPage(actcell,what);
1481 bool InsetTabular::ActivateCellInset(BufferView * bv, int x, int y, int button,
1484 // the cursor.pos has to be before the inset so if it isn't now just
1485 // reset the curor pos first!
1486 if (cursor.pos() % 2) { // behind the inset
1487 cursor.pos(cursor.pos() - 1);
1490 UpdatableInset * inset =
1491 static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
1492 LyXFont font(LyXFont::ALL_SANE);
1494 x = inset->x() + inset->width(bv, font);
1495 y = inset->descent(bv, font);
1497 inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
1498 inset_y = cursor.y();
1499 inset->Edit(bv, x - inset_x, y - inset_y, button);
1500 if (!the_locking_inset)
1502 UpdateLocal(bv, CELL, false);
1507 bool InsetTabular::InsetHit(BufferView * bv, int x, int ) const
1509 InsetText * inset = tabular->GetCellInset(actcell);
1512 if (cursor.pos() % 2) { // behind the inset
1513 return (((x + top_x) < cursor.x()) &&
1514 ((x + top_x) > (cursor.x() - inset->width(bv,
1515 LyXFont(LyXFont::ALL_SANE)))));
1517 int x2 = cursor.x() + tabular->GetBeginningOfTextInCell(actcell);
1518 return ((x1 > x2) &&
1519 (x1 < (x2 + inset->width(bv, LyXFont(LyXFont::ALL_SANE)))));
1524 // This returns paperWidth() if the cell-width is unlimited or the width
1525 // in pixels if we have a pwidth for this cell.
1526 int InsetTabular::GetMaxWidthOfCell(Painter &, int cell) const
1528 string s = tabular->GetPWidth(cell);
1532 return VSpace(s).inPixels( 0, 0);
1536 int InsetTabular::getMaxWidth(Painter & pain,
1537 UpdatableInset const * inset) const
1540 int n = tabular->GetNumberOfCells();
1541 for(cell=0; cell < n; ++cell) {
1542 if (tabular->GetCellInset(cell) == inset)
1547 int w = GetMaxWidthOfCell(pain, cell);
1549 // because the inset then subtracts it's top_x and owner->x()
1550 w += (inset->x() - top_x);
1555 void InsetTabular::resizeLyXText(BufferView *) const
1560 LyXText * InsetTabular::getLyXText(BufferView * bv) const
1562 if (the_locking_inset)
1563 return the_locking_inset->getLyXText(bv);
1564 return Inset::getLyXText(bv);
1568 void InsetTabular::OpenLayoutDialog(BufferView * bv) const
1570 if (the_locking_inset) {
1571 InsetTabular * i = static_cast<InsetTabular *>
1572 (the_locking_inset->GetFirstLockingInsetOfType(TABULAR_CODE));
1574 i->OpenLayoutDialog(bv);
1578 dialogs_ = bv->owner()->getDialogs();
1579 dialogs_->showTabular(const_cast<InsetTabular *>(this));
1583 // functions returns:
1587 // 3 ... toggled off
1589 LyXFunc::func_status InsetTabular::getStatus(string what) const
1591 int action = LyXTabular::LAST_ACTION;
1594 LyXFunc::func_status status = LyXFunc::OK;
1596 for(i=0; tabularFeatures[i].action != LyXTabular::LAST_ACTION; ++i) {
1597 if (!strncmp(tabularFeatures[i].feature.c_str(), what.c_str(),
1598 tabularFeatures[i].feature.length())) {
1599 action = tabularFeatures[i].action;
1603 if (action == LyXTabular::LAST_ACTION)
1604 return LyXFunc::Unknown;
1606 argument = frontStrip(what.substr(tabularFeatures[i].feature.length()));
1608 int sel_row_start, sel_row_end;
1612 if (hasSelection()) {
1614 sel_row_start = tabular->row_of_cell(sel_cell_start);
1615 sel_row_end = tabular->row_of_cell(sel_cell_end);
1616 if (sel_row_start > sel_row_end) {
1617 tmp = sel_row_start;
1618 sel_row_start = sel_row_end;
1622 sel_row_start = sel_row_end = tabular->row_of_cell(actcell);
1626 case LyXTabular::SET_PWIDTH:
1627 case LyXTabular::SET_MPWIDTH:
1628 case LyXTabular::SET_SPECIAL_COLUMN:
1629 case LyXTabular::SET_SPECIAL_MULTI:
1630 status |= LyXFunc::Disabled;
1633 case LyXTabular::APPEND_ROW:
1634 case LyXTabular::APPEND_COLUMN:
1635 case LyXTabular::DELETE_ROW:
1636 case LyXTabular::DELETE_COLUMN:
1637 case LyXTabular::SET_ALL_LINES:
1638 case LyXTabular::UNSET_ALL_LINES:
1641 case LyXTabular::MULTICOLUMN:
1642 if (tabular->IsMultiColumn(actcell))
1643 status |= LyXFunc::ToggleOn;
1645 status |= LyXFunc::ToggleOff;
1647 case LyXTabular::M_TOGGLE_LINE_TOP:
1649 case LyXTabular::TOGGLE_LINE_TOP:
1650 if (tabular->TopLine(actcell, flag))
1651 status |= LyXFunc::ToggleOn;
1653 status |= LyXFunc::ToggleOff;
1655 case LyXTabular::M_TOGGLE_LINE_BOTTOM:
1657 case LyXTabular::TOGGLE_LINE_BOTTOM:
1658 if (tabular->BottomLine(actcell, flag))
1659 status |= LyXFunc::ToggleOn;
1661 status |= LyXFunc::ToggleOff;
1663 case LyXTabular::M_TOGGLE_LINE_LEFT:
1665 case LyXTabular::TOGGLE_LINE_LEFT:
1666 if (tabular->LeftLine(actcell, flag))
1667 status |= LyXFunc::ToggleOn;
1669 status |= LyXFunc::ToggleOff;
1671 case LyXTabular::M_TOGGLE_LINE_RIGHT:
1673 case LyXTabular::TOGGLE_LINE_RIGHT:
1674 if (tabular->RightLine(actcell, flag))
1675 status |= LyXFunc::ToggleOn;
1677 status |= LyXFunc::ToggleOff;
1679 case LyXTabular::M_ALIGN_LEFT:
1681 case LyXTabular::ALIGN_LEFT:
1682 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_LEFT)
1683 status |= LyXFunc::ToggleOn;
1685 status |= LyXFunc::ToggleOff;
1687 case LyXTabular::M_ALIGN_RIGHT:
1689 case LyXTabular::ALIGN_RIGHT:
1690 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_RIGHT)
1691 status |= LyXFunc::ToggleOn;
1693 status |= LyXFunc::ToggleOff;
1695 case LyXTabular::M_ALIGN_CENTER:
1697 case LyXTabular::ALIGN_CENTER:
1698 if (tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER)
1699 status |= LyXFunc::ToggleOn;
1701 status |= LyXFunc::ToggleOff;
1703 case LyXTabular::M_VALIGN_TOP:
1705 case LyXTabular::VALIGN_TOP:
1706 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_TOP)
1707 status |= LyXFunc::ToggleOn;
1709 status |= LyXFunc::ToggleOff;
1711 case LyXTabular::M_VALIGN_BOTTOM:
1713 case LyXTabular::VALIGN_BOTTOM:
1714 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_BOTTOM)
1715 status |= LyXFunc::ToggleOn;
1717 status |= LyXFunc::ToggleOff;
1719 case LyXTabular::M_VALIGN_CENTER:
1721 case LyXTabular::VALIGN_CENTER:
1722 if (tabular->GetVAlignment(actcell, flag) == LyXTabular::LYX_VALIGN_CENTER)
1723 status |= LyXFunc::ToggleOn;
1725 status |= LyXFunc::ToggleOff;
1727 case LyXTabular::SET_LONGTABULAR:
1728 if (tabular->IsLongTabular())
1729 status |= LyXFunc::ToggleOn;
1731 status |= LyXFunc::ToggleOff;
1733 case LyXTabular::UNSET_LONGTABULAR:
1734 if (!tabular->IsLongTabular())
1735 status |= LyXFunc::ToggleOn;
1737 status |= LyXFunc::ToggleOff;
1739 case LyXTabular::SET_ROTATE_TABULAR:
1740 if (tabular->GetRotateTabular())
1741 status |= LyXFunc::ToggleOn;
1743 status |= LyXFunc::ToggleOff;
1745 case LyXTabular::UNSET_ROTATE_TABULAR:
1746 if (!tabular->GetRotateTabular())
1747 status |= LyXFunc::ToggleOn;
1749 status |= LyXFunc::ToggleOff;
1751 case LyXTabular::SET_ROTATE_CELL:
1752 if (tabular->GetRotateCell(actcell))
1753 status |= LyXFunc::ToggleOn;
1755 status |= LyXFunc::ToggleOff;
1757 case LyXTabular::UNSET_ROTATE_CELL:
1758 if (!tabular->GetRotateCell(actcell))
1759 status |= LyXFunc::ToggleOn;
1761 status |= LyXFunc::ToggleOff;
1763 case LyXTabular::SET_USEBOX:
1764 if (strToInt(argument) == tabular->GetUsebox(actcell))
1765 status |= LyXFunc::ToggleOn;
1767 status |= LyXFunc::ToggleOff;
1769 case LyXTabular::SET_LTFIRSTHEAD:
1770 if (tabular->GetRowOfLTHead(actcell, dummy))
1771 status |= LyXFunc::ToggleOn;
1773 status |= LyXFunc::ToggleOff;
1775 case LyXTabular::SET_LTHEAD:
1776 if (tabular->GetRowOfLTHead(actcell, dummy))
1777 status |= LyXFunc::ToggleOn;
1779 status |= LyXFunc::ToggleOff;
1781 case LyXTabular::SET_LTFOOT:
1782 if (tabular->GetRowOfLTFoot(actcell, dummy))
1783 status |= LyXFunc::ToggleOn;
1785 status |= LyXFunc::ToggleOff;
1787 case LyXTabular::SET_LTLASTFOOT:
1788 if (tabular->GetRowOfLTFoot(actcell, dummy))
1789 status |= LyXFunc::ToggleOn;
1791 status |= LyXFunc::ToggleOff;
1793 case LyXTabular::SET_LTNEWPAGE:
1794 if (tabular->GetLTNewPage(actcell))
1795 status |= LyXFunc::ToggleOn;
1797 status |= LyXFunc::ToggleOff;
1800 status = LyXFunc::Disabled;