#include <config.h>
-
#include "insettabular.h"
#include "insettext.h"
#include "BufferView.h"
#include "lfuns.h"
#include "debug.h"
+#include "dimension.h"
#include "funcrequest.h"
#include "gettext.h"
#include "language.h"
#include "LaTeXFeatures.h"
+#include "Lsstream.h"
#include "lyx_cb.h"
#include "lyxfunc.h"
#include "lyxlength.h"
#include "ParagraphParameters.h"
#include "undo_funcs.h"
#include "WordLangTuple.h"
+#include "Lsstream.h"
#include "frontends/Alert.h"
#include "frontends/Dialogs.h"
}
-int InsetTabular::ascent(BufferView *, LyXFont const &) const
-{
- return tabular->GetAscentOfRow(0);
-}
-
-
-int InsetTabular::descent(BufferView *, LyXFont const &) const
-{
- return tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
-}
-
-
-int InsetTabular::width(BufferView *, LyXFont const &) const
+void InsetTabular::dimension(BufferView *, LyXFont const &,
+ Dimension & dim) const
{
- return tabular->GetWidthOfTabular() + (2 * ADD_TO_TABULAR_WIDTH);
+ dim.a = tabular->GetAscentOfRow(0);
+ dim.d = tabular->GetHeightOfTabular() - tabular->GetAscentOfRow(0) + 1;
+ dim.w = tabular->GetWidthOfTabular() + 2 * ADD_TO_TABULAR_WIDTH;
}
}
-void InsetTabular::edit(BufferView * bv, int x, int y, mouse_button::state button)
-{
- UpdatableInset::edit(bv, x, y, button);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
- return;
- }
- locked = true;
- the_locking_inset = 0;
- inset_x = 0;
- inset_y = 0;
- setPos(bv, x, y);
- clearSelection();
- finishUndo();
- if (insetHit(bv, x, y) && (button != mouse_button::button3)) {
- activateCellInsetAbs(bv, x, y, button);
- }
-}
-
-
-void InsetTabular::edit(BufferView * bv, bool front)
-{
- UpdatableInset::edit(bv, front);
-
- if (!bv->lockInset(this)) {
- lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
- return;
- }
- finishUndo();
- locked = true;
- the_locking_inset = 0;
- inset_x = 0;
- inset_y = 0;
- 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();
-}
-
-
void InsetTabular::insetUnlock(BufferView * bv)
{
if (the_locking_inset) {
}
if (in->getInsetFromID(id)) {
actcell = i;
- in->edit(bv);
+ in->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return the_locking_inset->lockInsetInInset(bv, inset);
}
}
// the_locking_inset->localDispatch might unlock it.
old_locking_inset = the_locking_inset;
RESULT result = UpdatableInset::localDispatch(cmd);
-
BufferView * bv = cmd.view();
+
+ if (cmd.action == LFUN_INSET_EDIT) {
+
+ if (!bv->lockInset(this)) {
+ lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
+ return DISPATCHED;
+ }
+
+ finishUndo();
+ locked = true;
+ the_locking_inset = 0;
+ inset_x = 0;
+ inset_y = 0;
+
+ if (cmd.argument.size()) {
+ if (cmd.argument == "left") {
+ 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();
+ }
+
+ else {
+ setPos(bv, cmd.x, cmd.y);
+ clearSelection();
+ finishUndo();
+ if (insetHit(bv, cmd.x, cmd.y) && cmd.button() != mouse_button::button3) {
+ activateCellInsetAbs(bv, cmd.x, cmd.y, cmd.button());
+ }
+ }
+ return DISPATCHED;
+ }
+
if (result == DISPATCHED || result == DISPATCHED_NOUPDATE) {
resetPos(bv);
return result;
int InsetTabular::latex(Buffer const * buf, ostream & os,
- bool fragile, bool fp) const
+ LatexRunParams const & runparams) const
{
- return tabular->latex(buf, os, fragile, fp);
+ return tabular->latex(buf, os, runparams);
}
}
//inset_x = cursor.x() - top_x + tabular->GetBeginningOfTextInCell(actcell);
//inset_y = cursor.y();
- inset->edit(bv, x, y, button);
+ inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT, x, y, button));
if (!the_locking_inset)
return false;
updateLocal(bv, CELL);
// 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, mouse_button::none);
+ inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
WordLangTuple word(selectNextWordInt(bv, value));
nodraw(false);
if (!word.word().empty())
// 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);
+ inset->localDispatch(FuncRequest(bv, LFUN_INSET_EDIT));
return selectNextWordInt(bv, value);
}
int InsetTabularMailer::string2params(string const & in, InsetTabular & inset)
{
- istringstream data(in);
+ istringstream data(STRCONV(in));
LyXLex lex(0,0);
lex.setStream(data);
}
-string const
-InsetTabularMailer::params2string(InsetTabular const & inset)
+string const InsetTabularMailer::params2string(InsetTabular const & inset)
{
BufferView * const bv = inset.view();
Buffer const * const buffer = bv ? bv->buffer() : 0;
data << name_ << " \\active_cell " << inset.getActCell() << '\n';
inset.write(buffer, data);
data << "\\end_inset\n";
-
- return data.str();
+ return STRCONV(data.str());
}