-/* 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>
{ 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" },
}
-void InsetTabular::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button)
+void InsetTabular::lfunMousePress(FuncRequest const & cmd)
{
- if (hasSelection() && (button == mouse_button::button3))
+ 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);
if (!locked) {
inset_x = 0;
inset_y = 0;
}
- setPos(bv, x, y);
+ 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);
}
#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;
}
- if (button == mouse_button::button2) {
- localDispatch(bv, FuncRequest(LFUN_PASTESELECTION, "paragraph"));
+
+ if (cmd.button() == mouse_button::button2) {
+ localDispatch(FuncRequest(bv, LFUN_PASTESELECTION, "paragraph"));
return;
}
+
if (inset_hit && bv->theLockingInset()) {
- if (!bv->lockInset(static_cast<UpdatableInset*>(tabular->GetCellInset(actcell)))) {
+ if (!bv->lockInset(static_cast<UpdatableInset*>
+ (tabular->GetCellInset(actcell))))
+ {
lyxerr[Debug::INSETS] << "Cannot lock inset" << endl;
return;
}
- 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;
}
showInsetCursor(bv);
}
-bool InsetTabular::insetButtonRelease(BufferView * bv,
- int x, int y, mouse_button::state 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 == mouse_button::button3 && !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, mouse_button::state 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;
- setPos(bv, x, y);
+ setPos(bv, cmd.x, cmd.y);
if (!hasSelection()) {
setSelection(actcell, actcell);
updateLocal(bv, SELECTION, false);
}
-UpdatableInset::RESULT
-InsetTabular::localDispatch(BufferView * bv, FuncRequest const & ev)
+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, ev);
+ RESULT result = UpdatableInset::localDispatch(cmd);
+
+ BufferView * bv = cmd.view();
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
resetPos(bv);
return result;
}
- if (ev.action < 0 && ev.argument.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 (ev.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 (ev.action == LFUN_TAB)
+ if (cmd.action == LFUN_TAB)
moveNextCell(bv, old_locking_inset != 0);
else
movePrevCell(bv, old_locking_inset != 0);
}
}
- kb_action action = ev.action;
- string arg = ev.argument;
+ kb_action action = cmd.action;
+ string arg = cmd.argument;
if (the_locking_inset) {
- result = the_locking_inset->localDispatch(bv, ev);
+ result = the_locking_inset->localDispatch(cmd);
if (result == DISPATCHED_NOUPDATE) {
int sc = scroll();
resetPos(bv);
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_DEFAULT:
case LFUN_UNDERLINE:
case LFUN_FONT_SIZE:
- if (bv->dispatch(FuncRequest(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, FuncRequest(action, arg));
+ result = the_locking_inset->localDispatch(FuncRequest(bv, action, arg));
if ((result == UNDISPATCHED) || (result >= FINISHED)) {
unlockInsetInInset(bv, the_locking_inset);
nodraw(false);
#warning This should be fixed in the right manner (20011128 Jug)
#endif
// fast hack to fix infinite repaintings!
- if (in_reset_pos > 10)
+ if (in_reset_pos > 0)
return;
int cell = 0;
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);
}
-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)
}
-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);
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(
if (len.zero())
return -1;
- return len.inPixels(latexTextWidth(bv), bv->text->defaultHeight());
+ return len.inPixels(latexTextWidth(bv));
}
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;
}