#include "lyxfunc.h"
#include "debug.h"
#include "LaTeXFeatures.h"
-#include "Painter.h"
-#include "font.h"
+#include "frontends/Painter.h"
+#include "frontends/font_metrics.h"
#include "lyxtext.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
#include "insets/insettext.h"
#include "debug.h"
#include "gettext.h"
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);
}
}
lyxerr[Debug::INSETTEXT] << "InsetTabular::Cannot lock inset" << endl;
return;
}
+ finishUndo();
locked = true;
the_locking_inset = 0;
inset_x = 0;
actcell = tabular->GetNumberOfCells() - 1;
clearSelection();
resetPos(bv);
- finishUndo();
+ bv->fitCursor();
}
{
if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
hideInsetCursor(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;
}
}
-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::insetButtonPress(BufferView * bv, int x, int y, mouse_button::state button)
{
- if (hasSelection() && (button == 3))
+ if (hasSelection() && (button == mouse_button::button3))
return;
if (hasSelection()) {
int const orow = actrow;
hideInsetCursor(bv);
+ if (!locked) {
+ locked = true;
+ the_locking_inset = 0;
+ inset_x = 0;
+ inset_y = 0;
+ }
setPos(bv, x, y);
if (actrow != orow)
updateLocal(bv, NONE, false);
if (button == 3) {
if ((ocell != actcell) && the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
the_locking_inset = 0;
}
showInsetCursor(bv);
return;
} else if (the_locking_inset) {
the_locking_inset->insetUnlock(bv);
+ updateLocal(bv, CELL, false);
+ the_locking_inset = 0;
}
- the_locking_inset = 0;
- if (button == 2) {
+ if (button == mouse_button::button2) {
localDispatch(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;
+ }
+ the_locking_inset->insetButtonPress(
+ bv, x - inset_x, y - inset_y, button);
return;
}
showInsetCursor(bv);
bool InsetTabular::insetButtonRelease(BufferView * bv,
- int x, int y, int button)
+ int x, int y, mouse_button::state button)
{
bool ret = false;
if (the_locking_inset)
ret = the_locking_inset->insetButtonRelease(bv, x - inset_x,
y - inset_y, button);
- if (button == 3 && !ret) {
+ if (button == mouse_button::button3 && !ret) {
bv->owner()->getDialogs()->showTabular(this);
return true;
}
}
-void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, int button)
+void InsetTabular::insetMotionNotify(BufferView * bv, int x, int y, mouse_button::state button)
{
if (the_locking_inset) {
the_locking_inset->insetMotionNotify(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)
}
if (result < FINISHED) {
if (!the_locking_inset) {
-// showInsetCursor(bv);
+ if (bv->fitCursor())
+ updateLocal(bv, FULL, false);
+ if (locked)
+ showInsetCursor(bv);
}
} else
bv->unlockInset(this);
}
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();
else
return;
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);
void InsetTabular::fitInsetCursor(BufferView * bv) const
{
if (the_locking_inset) {
+ int old_first_y = bv->text->first_y;
the_locking_inset->fitInsetCursor(bv);
+ if (old_first_y != bv->text->first_y)
+ need_update = FULL;
return;
}
LyXFont font;
+
+ int const asc = font_metrics::maxAscent(font);
+ int const desc = font_metrics::maxDescent(font);
+ resetPos(bv);
- int const asc = lyxfont::maxAscent(font);
- int const desc = lyxfont::maxDescent(font);
- bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc);
+ if (bv->fitLockedInsetCursor(cursor_.x(), cursor_.y(), asc, desc))
+ need_update = FULL;
}
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);
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;
}
if (!frozen)
unFreezeUndo();
+ if (selectall)
+ clearSelection();
updateLocal(bv, INIT, true);
}
if (the_locking_inset)
}
-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);
// 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);
+ inset->edit(bv, 0, 0, mouse_button::none);
string const str(selectNextWordInt(bv, value));
nodraw(false);
if (!str.empty())
{
if (the_locking_inset)
return the_locking_inset->insetAllowed(code);
- return false;
+ // we return true here because if the inset is not locked someone
+ // wants to insert something in one of our insettexts and we generally
+ // allow to do so.
+ return true;
}
{
if (buf.length() <= 0)
return true;
-
+
int cols = 1;
int rows = 1;
int maxCols = 1;