-/* This file is part of
- * ======================================================
+/**
+ * \file insettabular.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * LyX, The Document Processor
+ * \author Jürgen Vigna
*
- * Copyright 2001 The LyX Team.
- *
- * ======================================================
+ * Full author contact details are available in file CREDITS
*/
#include <config.h>
#endif
#include "insettabular.h"
+#include "insettext.h"
-#include "lyx_cb.h"
#include "buffer.h"
+#include "BufferView.h"
#include "commandtags.h"
-#include "lyxfunc.h"
-#include "debug.h"
-#include "LaTeXFeatures.h"
-#include "Painter.h"
-#include "font.h"
-#include "lyxtext.h"
-#include "LyXView.h"
-#include "insets/insettext.h"
#include "debug.h"
+#include "funcrequest.h"
#include "gettext.h"
#include "language.h"
-#include "BufferView.h"
-#include "undo_funcs.h"
+#include "LaTeXFeatures.h"
+#include "lyx_cb.h"
+#include "lyxfunc.h"
#include "lyxlength.h"
+#include "lyxlex.h"
+#include "lyxtext.h"
#include "ParagraphParameters.h"
+#include "undo_funcs.h"
+#include "WordLangTuple.h"
-#include "frontends/Dialogs.h"
#include "frontends/Alert.h"
+#include "frontends/Dialogs.h"
+#include "frontends/font_metrics.h"
+#include "frontends/LyXView.h"
+#include "frontends/Painter.h"
#include "support/LAssert.h"
#include "support/lstrings.h"
{ LyXTabular::ALIGN_LEFT, "align-left" },
{ LyXTabular::ALIGN_RIGHT, "align-right" },
{ LyXTabular::ALIGN_CENTER, "align-center" },
+ { LyXTabular::ALIGN_BLOCK, "align-block" },
{ LyXTabular::VALIGN_TOP, "valign-top" },
{ LyXTabular::VALIGN_BOTTOM, "valign-bottom" },
{ LyXTabular::VALIGN_CENTER, "valign-center" },
clearSelection();
need_update = INIT;
in_update = false;
- in_reset_pos = false;
+ in_reset_pos = 0;
inset_x = 0;
inset_y = 0;
}
clearSelection();
need_update = INIT;
in_update = false;
- in_reset_pos = false;
+ in_reset_pos = 0;
inset_x = 0;
inset_y = 0;
}
on_off ? Painter::line_onoffdash : Painter::line_solid);
}
on_off = !tabular->BottomLine(cell);
- pain.line(x,baseline + tabular->GetDescentOfRow(row),
- x2, baseline + tabular->GetDescentOfRow(row),
+ pain.line(x, baseline + tabular->GetDescentOfRow(row),
+ x2, baseline + tabular->GetDescentOfRow(row),
on_off ? LColor::tabularonoffline : LColor::tabularline,
on_off ? Painter::line_onoffdash : Painter::line_solid);
if (!tabular->LeftAlreadyDrawed(cell)) {
if ((column >= cs) && (column <= ce) && (row >= rs) && (row <= re)) {
int w = tabular->GetWidthOfColumn(cell);
- int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row);
- pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row),
+ int h = tabular->GetAscentOfRow(row) + tabular->GetDescentOfRow(row)-1;
+ pain.fillRectangle(x, baseline - tabular->GetAscentOfRow(row) + 1,
w, h, LColor::selection);
}
}
case INIT:
case FULL:
case CELL:
- if (calculate_dimensions_of_cells(bv, font, false))
+ if (calculate_dimensions_of_cells(bv, font, false)) {
need_update = INIT;
+ resetPos(bv);
+ }
break;
case SELECTION:
need_update = FULL;
}
-void InsetTabular::edit(BufferView * bv, int x, int y, unsigned int button)
+void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button)
{
UpdatableInset::edit(bv, x, y, button);
setPos(bv, x, y);
clearSelection();
finishUndo();
- if (insetHit(bv, x, y) && (button != 3)) {
+ if (insetHit(bv, x, y) && (button != mouse_button::button3)) {
activateCellInsetAbs(bv, x, y, button);
}
}
the_locking_inset = 0;
inset_x = 0;
inset_y = 0;
- if (front)
- actcell = 0;
- else
- actcell = tabular->GetNumberOfCells() - 1;
+ if (front) {
+ if (isRightToLeft(bv))
+ actcell = tabular->GetLastCellInRow(0);
+ else
+ actcell = 0;
+ } else {
+ if (isRightToLeft(bv))
+ actcell = tabular->GetFirstCellInRow(tabular->rows()-1);
+ else
+ actcell = tabular->GetNumberOfCells() - 1;
+ }
clearSelection();
resetPos(bv);
bv->fitCursor();
{
if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
hideInsetCursor(bv);
+ actcell = 0;
oldcell = -1;
locked = false;
if (scroll(false) || hasSelection()) {
what = FULL;
if (need_update < what) // only set this if it has greater update
need_update = what;
-#if 0 // maybe this should not be done!
- if ((what == INIT) && hasSelection()) {
- clearSelection();
- }
-#endif
// Dirty Cast! (Lgb)
if (need_update != NONE) {
bv->updateInset(const_cast<InsetTabular *>(this), mark_dirty);
- if (locked) // && (what != NONE))
+ if (locked)
resetPos(bv);
}
}
return false;
if (the_locking_inset == inset) {
the_locking_inset->insetUnlock(bv);
- the_locking_inset = 0;
#ifdef WITH_WARNINGS
#warning fix scrolling when cellinset has requested a scroll (Jug)!!!
#endif
scroll(bv, 0.0F);
#endif
updateLocal(bv, CELL, false);
+ // this has to be here otherwise we don't redraw the cell!
+ the_locking_inset = 0;
// showInsetCursor(bv, false);
return true;
}
if (the_locking_inset->unlockInsetInInset(bv, inset, lr)) {
if (inset->lyxCode() == TABULAR_CODE &&
!the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) {
- bv->owner()->getDialogs()->updateTabular(this);
+ bv->owner()->getDialogs().updateTabular(this);
oldcell = actcell;
}
return true;
}
-unsigned int InsetTabular::insetInInsetY()
+int InsetTabular::insetInInsetY() const
{
if (!the_locking_inset)
return 0;
}
-void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, int button)
+void InsetTabular::lfunMousePress(FuncRequest const & cmd)
{
- if (hasSelection() && (button == 3))
+ if (hasSelection() && cmd.button() == mouse_button::button3)
return;
if (hasSelection()) {
clearSelection();
- updateLocal(bv, SELECTION, false);
+ updateLocal(cmd.view(), SELECTION, false);
}
int const ocell = actcell;
int const orow = actrow;
+ BufferView * bv = cmd.view();
hideInsetCursor(bv);
- setPos(bv, x, y);
+ if (!locked) {
+ locked = true;
+ the_locking_inset = 0;
+ inset_x = 0;
+ inset_y = 0;
+ }
+ setPos(bv, cmd.x, cmd.y);
if (actrow != orow)
updateLocal(bv, NONE, false);
clearSelection();
#if 0
- if (button == 3) {
+ if (cmd.button() == mouse_button::button3) {
if ((ocell != actcell) && the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
showInsetCursor(bv);
}
#endif
- bool const inset_hit = insetHit(bv, x, y);
+ bool const inset_hit = insetHit(bv, cmd.x, cmd.y);
if ((ocell == actcell) && the_locking_inset && inset_hit) {
resetPos(bv);
- the_locking_inset->insetButtonPress(bv,
- x - inset_x, y - inset_y,
- button);
+ FuncRequest cmd1 = cmd;
+ cmd1.x -= inset_x;
+ cmd1.y -= inset_y;
+ the_locking_inset->localDispatch(cmd1);
return;
- } else if (the_locking_inset) {
+ }
+
+ if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
+ the_locking_inset = 0;
}
- the_locking_inset = 0;
- if (button == 2) {
- localDispatch(bv, LFUN_PASTESELECTION, "paragraph");
+
+ if (cmd.button() == mouse_button::button2) {
+ localDispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph"));
return;
}
+
if (inset_hit && bv->theLockingInset()) {
- // only activate the Inset so that no internal inset is hit
- // by this call. It should be only hit by the insetButtonPress call.
- if (activateCellInsetAbs(bv, 0, 0, 0))
- the_locking_inset->insetButtonPress(bv,
- x - inset_x,
- y - inset_y,
- button);
+ if (!bv->lockInset(static_cast<UpdatableInset*>
+ (tabular->GetCellInset(actcell))))
+ {
+ lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
+ return;
+ }
+ FuncRequest cmd1 = cmd;
+ cmd1.x -= inset_x;
+ cmd1.y -= inset_y;
+ the_locking_inset->localDispatch(cmd1);
return;
}
showInsetCursor(bv);
}
-bool InsetTabular::insetButtonRelease(BufferView * bv,
- int x, int y, int button)
+bool InsetTabular::lfunMouseRelease(FuncRequest const & cmd)
{
bool ret = false;
- if (the_locking_inset)
- ret = the_locking_inset->insetButtonRelease(bv, x - inset_x,
- y - inset_y, button);
- if (button == 3 && !ret) {
- bv->owner()->getDialogs()->showTabular(this);
+ if (the_locking_inset) {
+ FuncRequest cmd1 = cmd;
+ cmd1.x -= inset_x;
+ cmd1.y -= inset_y;
+ ret = the_locking_inset->localDispatch(cmd1);
+ }
+ if (cmd.button() == mouse_button::button3 && !ret) {
+ cmd.view()->owner()->getDialogs().showTabular(this);
return true;
}
return ret;
}
-void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
+void InsetTabular::lfunMouseMotion(FuncRequest const & cmd)
{
if (the_locking_inset) {
- the_locking_inset->insetMotionNotify(bv,
- x - inset_x,
- y - inset_y,
- button);
+ FuncRequest cmd1 = cmd;
+ cmd1.x -= inset_x;
+ cmd1.y -= inset_y;
+ the_locking_inset->localDispatch(cmd1);
return;
}
+ BufferView * bv = cmd.view();
hideInsetCursor(bv);
-// int const old_cell = actcell;
+ int const old_cell = actcell;
- setPos(bv, x, y);
+ setPos(bv, cmd.x, cmd.y);
if (!hasSelection()) {
setSelection(actcell, actcell);
- } else {
+ updateLocal(bv, SELECTION, false);
+ } else if (old_cell != actcell) {
setSelection(sel_cell_start, actcell);
+ updateLocal(bv, SELECTION, false);
}
- updateLocal(bv, SELECTION, false);
showInsetCursor(bv);
}
-void InsetTabular::insetKeyPress(XKeyEvent * xke)
-{
- if (the_locking_inset) {
- the_locking_inset->insetKeyPress(xke);
- return;
- }
-}
-
-
-UpdatableInset::RESULT
-InsetTabular::localDispatch(BufferView * bv, kb_action action,
- string const & arg)
+Inset::RESULT InsetTabular::localDispatch(FuncRequest const & cmd)
{
// We need to save the value of the_locking_inset as the call to
- // the_locking_inset->LocalDispatch might unlock it.
+ // the_locking_inset->localDispatch might unlock it.
old_locking_inset = the_locking_inset;
- UpdatableInset::RESULT result =
- UpdatableInset::localDispatch(bv, action, arg);
+ RESULT result = UpdatableInset::localDispatch(cmd);
+
+ BufferView * bv = cmd.view();
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
resetPos(bv);
return result;
}
- if ((action < 0) && arg.empty())
+ if (cmd.action < 0 && cmd.argument.empty())
return FINISHED;
bool hs = hasSelection();
// this one have priority over the locked InsetText, if we're not already
// inside another tabular then that one get's priority!
if (getFirstLockingInsetOfType(Inset::TABULAR_CODE) == this) {
- switch (action) {
+ switch (cmd.action) {
+ case LFUN_MOUSE_PRESS:
+ lfunMousePress(cmd);
+ return DISPATCHED;
+
+ case LFUN_MOUSE_MOTION:
+ lfunMouseMotion(cmd);
+ return DISPATCHED;
+
+ case LFUN_MOUSE_RELEASE:
+ return lfunMouseRelease(cmd) ? DISPATCHED : UNDISPATCHED;
+
case LFUN_SHIFT_TAB:
case LFUN_TAB:
hideInsetCursor(bv);
unlockInsetInInset(bv, the_locking_inset);
- if (action == LFUN_TAB)
+ if (cmd.action == LFUN_TAB)
moveNextCell(bv, old_locking_inset != 0);
else
movePrevCell(bv, old_locking_inset != 0);
}
}
+ kb_action action = cmd.action;
+ string arg = cmd.argument;
if (the_locking_inset) {
- result = the_locking_inset->localDispatch(bv, action, arg);
+ result = the_locking_inset->localDispatch(cmd);
if (result == DISPATCHED_NOUPDATE) {
int sc = scroll();
resetPos(bv);
if (bv->text->first_y + bv->painter().paperHeight() <
(top_baseline + tabular->GetHeightOfTabular()))
{
- bv->scrollCB(bv->text->first_y + bv->painter().paperHeight());
+ bv->scrollDocView(bv->text->first_y + bv->painter().paperHeight());
code = FULL;
actcell = tabular->GetCellBelow(first_visible_cell) + column;
} else {
int column = actcol;
unlockInsetInInset(bv, the_locking_inset);
if (top_baseline < 0) {
- bv->scrollCB(bv->text->first_y - bv->painter().paperHeight());
+ bv->scrollDocView(bv->text->first_y - bv->painter().paperHeight());
code = FULL;
if (top_baseline > 0)
actcell = column;
case LFUN_WORDLEFTSEL:
case LFUN_WORDRIGHT:
case LFUN_WORDRIGHTSEL:
+ case LFUN_WORDSEL:
case LFUN_DOWN_PARAGRAPH:
case LFUN_DOWN_PARAGRAPHSEL:
case LFUN_UP_PARAGRAPH:
case LFUN_UP_PARAGRAPHSEL:
case LFUN_BACKSPACE:
- case LFUN_DELETE:
case LFUN_HOME:
case LFUN_HOMESEL:
case LFUN_END:
case LFUN_ENDBUFSEL:
break;
case LFUN_LAYOUT_TABULAR:
- bv->owner()->getDialogs()->showTabular(this);
+ bv->owner()->getDialogs().showTabular(this);
break;
case LFUN_TABULAR_FEATURE:
if (!tabularFeatures(bv, arg))
case LFUN_CUT:
if (!copySelection(bv))
break;
+ // no break here!
+ case LFUN_DELETE:
setUndo(bv, Undo::DELETE,
bv->text->cursor.par(),
bv->text->cursor.par()->next());
case LFUN_DEFAULT:
case LFUN_UNDERLINE:
case LFUN_FONT_SIZE:
- if (bv->Dispatch(action, arg))
+ if (bv->dispatch(FuncRequest(bv, action, arg)))
result = DISPATCHED;
break;
default:
if (activateCellInset(bv)) {
// reset need_update setted in above function!
need_update = NONE;
- result = the_locking_inset->localDispatch(bv, action, arg);
+ result = the_locking_inset->localDispatch(FuncRequest(bv, action, arg));
if ((result == UNDISPATCHED) || (result >= FINISHED)) {
unlockInsetInInset(bv, the_locking_inset);
nodraw(false);
}
-int InsetTabular::docbook(Buffer const * buf, ostream & os) const
+int InsetTabular::docbook(Buffer const * buf, ostream & os, bool mixcont) const
{
int ret = 0;
Inset * master;
master = master->owner());
if (!master) {
- os << "<informaltable>\n";
+ os << "<informaltable>";
+ if (mixcont)
+ os << endl;
ret++;
}
- ret+= tabular->docBook(buf,os);
+ ret+= tabular->docbook(buf, os, mixcont);
if (!master) {
- os << "</informaltable>\n";
+ os << "</informaltable>";
+ if (mixcont)
+ os << endl;
ret++;
}
return ret;
LyXFont font; // = the_locking_inset->GetFont(par, cursor.pos);
- int const asc = lyxfont::maxAscent(font);
- int const desc = lyxfont::maxDescent(font);
+ int const asc = font_metrics::maxAscent(font);
+ int const desc = font_metrics::maxDescent(font);
if (isCursorVisible())
bv->hideLockedInsetCursor();
if (!isCursorVisible()) {
LyXFont font; // = GetFont(par, cursor.pos);
- int const asc = lyxfont::maxAscent(font);
- int const desc = lyxfont::maxDescent(font);
+ int const asc = font_metrics::maxAscent(font);
+ int const desc = font_metrics::maxDescent(font);
bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
if (show)
bv->showLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
}
LyXFont font;
- int const asc = lyxfont::maxAscent(font);
- int const desc = lyxfont::maxDescent(font);
+ int const asc = font_metrics::maxAscent(font);
+ int const desc = font_metrics::maxDescent(font);
+ resetPos(bv);
+
if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
need_update = FULL;
}
#warning This should be fixed in the right manner (20011128 Jug)
#endif
// fast hack to fix infinite repaintings!
- if (in_reset_pos)
+ if (in_reset_pos > 0)
return;
int cell = 0;
return;
}
// we need this only from here on!!!
- in_reset_pos = true;
+ ++in_reset_pos;
static int const offset = ADD_TO_TABULAR_WIDTH + 2;
int new_x = getCellXPos(actcell);
int old_x = cursor_.x();
new_x += offset;
cursor_.x(new_x);
// cursor.x(getCellXPos(actcell) + offset);
- if ((actcol < tabular->columns()-1) && scroll(false) &&
+ if ((actcol < tabular->columns() - 1) && scroll(false) &&
(tabular->GetWidthOfTabular() < bv->workWidth()-20))
{
scroll(bv, 0.0F);
} else if ((cursor_.x() - offset) < 20) {
scroll(bv, 20 - cursor_.x() + offset);
updateLocal(bv, FULL, false);
- } else if (scroll(false) && top_x > 20 &&
+ } else if (scroll() && top_x > 20 &&
(top_x + tabular->GetWidthOfTabular()) > (bv->workWidth() - 20)) {
scroll(bv, old_x - cursor_.x());
updateLocal(bv, FULL, false);
!the_locking_inset->getFirstLockingInsetOfType(TABULAR_CODE)) &&
actcell != oldcell) {
InsetTabular * inset = const_cast<InsetTabular *>(this);
- bv->owner()->getDialogs()->updateTabular(inset);
+ bv->owner()->getDialogs().updateTabular(inset);
oldcell = actcell;
}
- in_reset_pos = false;
+ in_reset_pos = 0;
}
-UpdatableInset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveRight(BufferView * bv, bool lock)
{
if (lock && !old_locking_inset) {
if (activateCellInset(bv))
}
-UpdatableInset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveLeft(BufferView * bv, bool lock)
{
bool moved = isRightToLeft(bv) ? moveNextCell(bv) : movePrevCell(bv);
if (!moved)
return FINISHED;
if (lock) { // behind the inset
- if (activateCellInset(bv, 0, 0, 0, true))
+ if (activateCellInset(bv, 0, 0, mouse_button::none, true))
return DISPATCHED;
}
resetPos(bv);
}
-UpdatableInset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveUp(BufferView * bv, bool lock)
{
int const ocell = actcell;
actcell = tabular->GetCellAbove(actcell);
}
-UpdatableInset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
+Inset::RESULT InsetTabular::moveDown(BufferView * bv, bool lock)
{
int const ocell = actcell;
actcell = tabular->GetCellBelow(actcell);
if (lock) {
bool rtl = tabular->GetCellInset(actcell)->paragraph()->
isRightToLeftPar(bv->buffer()->params);
- activateCellInset(bv, 0, 0, 0, !rtl);
+ activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
}
resetPos(bv);
return true;
if (lock) {
bool rtl = tabular->GetCellInset(actcell)->paragraph()->
isRightToLeftPar(bv->buffer()->params);
- activateCellInset(bv, 0, 0, 0, !rtl);
+ activateCellInset(bv, 0, 0, mouse_button::none, !rtl);
}
resetPos(bv);
return true;
setUndo(bv, Undo::EDIT,
bv->text->cursor.par(),
bv->text->cursor.par()->next());
- bool frozen = undo_frozen;
+ bool const frozen = undo_frozen;
if (!frozen)
freezeUndo();
// apply the fontchange on the whole selection
}
if (!frozen)
unFreezeUndo();
+ if (selectall)
+ clearSelection();
updateLocal(bv, INIT, true);
}
if (the_locking_inset)
return false;
string const val =
- frontStrip(what.substr(tabularFeature[i].feature.length()));
+ ltrim(what.substr(tabularFeature[i].feature.length()));
tabularFeatures(bv, action, val);
return true;
}
case LyXTabular::ALIGN_CENTER:
setAlign = LYX_ALIGN_CENTER;
break;
+ case LyXTabular::ALIGN_BLOCK:
+ setAlign = LYX_ALIGN_BLOCK;
+ break;
case LyXTabular::M_VALIGN_TOP:
case LyXTabular::VALIGN_TOP:
setVAlign = LyXTabular::LYX_VALIGN_TOP;
}
updateLocal(bv, INIT, true);
}
+
+ if (vallen.zero()
+ && tabular->GetAlignment(actcell, true) == LYX_ALIGN_BLOCK)
+ tabularFeatures(bv, LyXTabular::ALIGN_CENTER, string());
+ else if (!vallen.zero()
+ && tabular->GetAlignment(actcell, true) != LYX_ALIGN_BLOCK)
+ tabularFeatures(bv, LyXTabular::ALIGN_BLOCK, string());
}
break;
case LyXTabular::SET_MPWIDTH:
case LyXTabular::ALIGN_LEFT:
case LyXTabular::ALIGN_RIGHT:
case LyXTabular::ALIGN_CENTER:
+ case LyXTabular::ALIGN_BLOCK:
for (int i = sel_row_start; i <= sel_row_end; ++i)
for (int j = sel_col_start; j <= sel_col_end; ++j)
tabular->SetAlignment(
}
-bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, int button,
+bool InsetTabular::activateCellInset(BufferView * bv, int x, int y, mouse_button::state button,
bool behind)
{
UpdatableInset * inset =
bool InsetTabular::activateCellInsetAbs(BufferView * bv, int x, int y,
- int button)
+ mouse_button::state button)
{
inset_x = cursor_.x()
- top_x + tabular->GetBeginningOfTextInCell(actcell);
if (len.zero())
return -1;
- return len.inPixels(latexTextWidth(bv), bv->text->defaultHeight());
+ return len.inPixels(latexTextWidth(bv));
}
bool InsetTabular::showInsetDialog(BufferView * bv) const
{
if (!the_locking_inset || !the_locking_inset->showInsetDialog(bv))
- bv->owner()->getDialogs()
- ->showTabular(const_cast<InsetTabular *>(this));
+ bv->owner()->getDialogs().
+ showTabular(const_cast<InsetTabular *>(this));
return true;
}
return;
}
}
- bv->owner()->getDialogs()->showTabular(
+ bv->owner()->getDialogs().showTabular(
const_cast<InsetTabular *>(this));
}
return status.unknown(true);
}
- string const argument = frontStrip(what.substr(tabularFeature[i].feature.length()));
+ string const argument = ltrim(what.substr(tabularFeature[i].feature.length()));
int sel_row_start;
int sel_row_end;
case LyXTabular::ALIGN_CENTER:
status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_CENTER);
break;
+ case LyXTabular::ALIGN_BLOCK:
+ status.disabled(tabular->GetPWidth(actcell).zero());
+ status.setOnOff(tabular->GetAlignment(actcell, flag) == LYX_ALIGN_BLOCK);
+ break;
case LyXTabular::M_VALIGN_TOP:
flag = false;
case LyXTabular::VALIGN_TOP:
ostringstream sstr;
paste_tabular->ascii(bv->buffer(), sstr,
(int)parOwner()->params().depth(), true, '\t');
- bv->stuffClipboard(sstr.str().c_str());
+ bv->stuffClipboard(STRCONV(sstr.str()));
return true;
}
}
-string const
+WordLangTuple const
InsetTabular::selectNextWordToSpellcheck(BufferView * bv, float & value) const
{
nodraw(true);
if (the_locking_inset) {
- string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
- if (!str.empty()) {
+ WordLangTuple word(the_locking_inset->selectNextWordToSpellcheck(bv, value));
+ if (!word.word().empty()) {
nodraw(false);
- return str;
+ return word;
}
if (tabular->IsLastCell(actcell)) {
bv->unlockInset(const_cast<InsetTabular *>(this));
nodraw(false);
- return string();
+ return WordLangTuple();
}
++actcell;
}
// otherwise we have to lock the next inset and ask for it's selecttion
UpdatableInset * inset =
static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv, 0, 0, 0);
- string const str(selectNextWordInt(bv, value));
+ inset->edit(bv, 0, 0, mouse_button::none);
+ WordLangTuple word(selectNextWordInt(bv, value));
nodraw(false);
- if (!str.empty())
+ if (!word.word().empty())
resetPos(bv);
- return str;
+ return word;
}
-string InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
+WordLangTuple InsetTabular::selectNextWordInt(BufferView * bv, float & value) const
{
// when entering this function the inset should be ALWAYS locked!
lyx::Assert(the_locking_inset);
- string const str(the_locking_inset->selectNextWordToSpellcheck(bv, value));
- if (!str.empty())
- return str;
+ WordLangTuple word(the_locking_inset->selectNextWordToSpellcheck(bv, value));
+ if (!word.word().empty())
+ return word;
if (tabular->IsLastCell(actcell)) {
bv->unlockInset(const_cast<InsetTabular *>(this));
- return string();
+ return WordLangTuple();
}
// otherwise we have to lock the next inset and ask for it's selecttion
bool InsetTabular::searchForward(BufferView * bv, string const & str,
bool cs, bool mw)
{
- nodraw(true);
if (the_locking_inset) {
if (the_locking_inset->searchForward(bv, str, cs, mw)) {
- nodraw(false);
updateLocal(bv, CELL, false);
return true;
}
- if (tabular->IsLastCell(actcell)) {
- nodraw(false);
- bv->unlockInset(const_cast<InsetTabular *>(this));
+ if (tabular->IsLastCell(actcell))
return false;
- }
++actcell;
}
- // otherwise we have to lock the next inset and search there
- UpdatableInset * inset =
- static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv);
- bool const ret = searchForward(bv, str, cs, mw);
- nodraw(false);
- updateLocal(bv, CELL, false);
- return ret;
+ InsetText * inset = tabular->GetCellInset(actcell);
+ if (inset->searchForward(bv, str, cs, mw)) {
+ updateLocal(bv, FULL, false);
+ return true;
+ }
+ while (!tabular->IsLastCell(actcell)) {
+ ++actcell;
+ inset = tabular->GetCellInset(actcell);
+ if (inset->searchForward(bv, str, cs, mw)) {
+ updateLocal(bv, FULL, false);
+ return true;
+ }
+ }
+ return false;
}
bool InsetTabular::searchBackward(BufferView * bv, string const & str,
bool cs, bool mw)
{
- nodraw(true);
if (the_locking_inset) {
if (the_locking_inset->searchBackward(bv, str, cs, mw)) {
- nodraw(false);
updateLocal(bv, CELL, false);
return true;
}
- if (!actcell) { // we are already in the first cell
- nodraw(false);
- bv->unlockInset(const_cast<InsetTabular *>(this));
- return false;
- }
+ }
+ if (!locked)
+ actcell = tabular->GetNumberOfCells();
+
+ while (actcell) {
--actcell;
+ InsetText * inset = tabular->GetCellInset(actcell);
+ if (inset->searchBackward(bv, str, cs, mw)) {
+ updateLocal(bv, CELL, false);
+ return true;
+ }
}
- // otherwise we have to lock the next inset and search there
- UpdatableInset * inset =
- static_cast<UpdatableInset*>(tabular->GetCellInset(actcell));
- inset->edit(bv, false);
- bool const ret = searchBackward(bv, str, cs, mw);
- nodraw(false);
- updateLocal(bv, CELL, false);
- return ret;
+ return false;
}
{
if (buf.length() <= 0)
return true;
-
+
int cols = 1;
int rows = 1;
int maxCols = 1;
return true;
}
+
+
+void InsetTabular::addPreview(grfx::PreviewLoader & loader) const
+{
+ int const rows = tabular->rows();
+ int const columns = tabular->columns();
+ for (int i = 0; i < rows; ++i) {
+ for (int j = 0; j < columns; ++j) {
+ tabular->GetCellInset(i,j)->addPreview(loader);
+ }
+ }
+}