+/**
+ * \file BufferView_pimpl.C
+ * Copyright 2002 the LyX Team
+ * Read the file COPYING
+ *
+ * \author various
+ */
+
#include <config.h>
#ifdef __GNUG__
#endif
#include "BufferView_pimpl.h"
-#include "WorkArea.h"
-#include "lyxscreen.h"
+#include "frontends/WorkArea.h"
+#include "frontends/screen.h"
+#include "frontends/Dialogs.h"
+#include "frontends/Alert.h"
+#include "frontends/FileDialog.h"
#include "lyxtext.h"
#include "lyxrow.h"
#include "paragraph.h"
-#include "LyXView.h"
+#include "frontends/LyXView.h"
#include "commandtags.h"
#include "lyxfunc.h"
#include "debug.h"
-#include "font.h"
#include "bufferview_funcs.h"
#include "TextCache.h"
#include "bufferlist.h"
#include "undo_funcs.h"
#include "lyxtextclasslist.h"
-#include "frontends/Dialogs.h"
-#include "frontends/Alert.h"
-#include "frontends/FileDialog.h"
-
#include "insets/insetbib.h"
#include "insets/insettext.h"
#include "insets/inseturl.h"
#include "support/filetools.h"
#include "support/lyxfunctional.h"
+#include <boost/bind.hpp>
+
+#include <cstdio>
#include <ctime>
#include <unistd.h>
#include <sys/wait.h>
extern string current_layout;
+#ifndef CXX_GLOBAL_CSTD
+using std::tm;
+using std::localtime;
+using std::time;
+using std::setlocale;
+using std::strftime;
+#endif
+
using std::vector;
using std::find_if;
using std::find;
using std::endl;
using std::make_pair;
using std::min;
-using SigC::slot;
using lyx::pos_type;
using lyx::textclass_type;
BufferView::Pimpl::Pimpl(BufferView * b, LyXView * o,
int xpos, int ypos, int width, int height)
- : bv_(b), owner_(o), buffer_(0),
- current_scrollbar_value(0), cursor_timeout(400),
- workarea_(xpos, ypos, width, height), using_xterm_cursor(false),
- inset_slept(false)
+ : bv_(b), owner_(o), buffer_(0), cursor_timeout(400),
+ using_xterm_cursor(false)
{
+ workarea_.reset(new WorkArea(xpos, ypos, width, height));
+ screen_.reset(new LScreen(workarea()));
+
// Setup the signals
- workarea_.scrollCB.connect(slot(this, &BufferView::Pimpl::scrollCB));
- workarea_.workAreaExpose
- .connect(slot(this, &BufferView::Pimpl::workAreaExpose));
- workarea_.workAreaEnter
- .connect(slot(this, &BufferView::Pimpl::enterView));
- workarea_.workAreaLeave
- .connect(slot(this, &BufferView::Pimpl::leaveView));
- workarea_.workAreaButtonPress
- .connect(slot(this, &BufferView::Pimpl::workAreaButtonPress));
- workarea_.workAreaButtonRelease
- .connect(slot(this,
- &BufferView::Pimpl::workAreaButtonRelease));
- workarea_.workAreaMotionNotify
- .connect(slot(this, &BufferView::Pimpl::workAreaMotionNotify));
- workarea_.workAreaDoubleClick
- .connect(slot(this, &BufferView::Pimpl::doubleClick));
- workarea_.workAreaTripleClick
- .connect(slot(this, &BufferView::Pimpl::tripleClick));
- workarea_.workAreaKeyPress
- .connect(slot(this, &BufferView::Pimpl::workAreaKeyPress));
- workarea_.selectionRequested
- .connect(slot(this, &BufferView::Pimpl::selectionRequested));
- workarea_.selectionLost
- .connect(slot(this, &BufferView::Pimpl::selectionLost));
-
- cursor_timeout.timeout.connect(slot(this,
- &BufferView::Pimpl::cursorToggle));
+ workarea().scrollDocView.connect(boost::bind(&BufferView::Pimpl::scrollDocView, this, _1));
+ workarea().workAreaExpose
+ .connect(boost::bind(&BufferView::Pimpl::workAreaExpose, this));
+ workarea().workAreaButtonPress
+ .connect(boost::bind(&BufferView::Pimpl::workAreaButtonPress, this, _1, _2, _3));
+ workarea().workAreaButtonRelease
+ .connect(boost::bind(&BufferView::Pimpl::workAreaButtonRelease, this, _1, _2, _3));
+ workarea().workAreaMotionNotify
+ .connect(boost::bind(&BufferView::Pimpl::workAreaMotionNotify, this, _1, _2, _3));
+ workarea().workAreaDoubleClick
+ .connect(boost::bind(&BufferView::Pimpl::doubleClick, this, _1, _2, _3));
+ workarea().workAreaTripleClick
+ .connect(boost::bind(&BufferView::Pimpl::tripleClick, this, _1, _2, _3));
+ workarea().workAreaKeyPress
+ .connect(boost::bind(&BufferView::Pimpl::workAreaKeyPress, this, _1, _2));
+ workarea().selectionRequested
+ .connect(boost::bind(&BufferView::Pimpl::selectionRequested, this));
+ workarea().selectionLost
+ .connect(boost::bind(&BufferView::Pimpl::selectionLost, this));
+
+ cursor_timeout.timeout.connect(boost::bind(&BufferView::Pimpl::cursorToggle, this));
cursor_timeout.start();
- workarea_.setFocus();
+ workarea().setFocus();
saved_positions.resize(saved_positions_num);
}
-Painter & BufferView::Pimpl::painter()
+WorkArea & BufferView::Pimpl::workarea() const
+{
+ return *workarea_.get();
+}
+
+
+LScreen & BufferView::Pimpl::screen() const
+{
+ return *screen_.get();
+}
+
+
+Painter & BufferView::Pimpl::painter() const
{
- return workarea_.getPainter();
+ return workarea().getPainter();
}
lyxerr[Debug::INFO] << "Setting buffer in BufferView ("
<< b << ")" << endl;
if (buffer_) {
-#if 0
- insetSleep();
-#endif
buffer_->delUser(bv_);
// Put the old text into the TextCache, but
// only if the buffer is still loaded.
// Also set the owner of the test to 0
// bv_->text->owner(0);
- textcache.add(buffer_, workarea_.workWidth(), bv_->text);
+ textcache.add(buffer_, workarea().workWidth(), bv_->text);
if (lyxerr.debugging())
textcache.show(lyxerr, "BufferView::buffer");
if (bufferlist.getState() == BufferList::CLOSING) return;
- // Nuke old image
- // screen is always deleted when the buffer is changed.
- screen_.reset(0);
-
// If we are closing the buffer, use the first buffer as current
if (!buffer_) {
buffer_ = bufferlist.first();
updateScreen();
updateScrollbar();
}
- bv_->text->first_y = screen_->topCursorVisible(bv_->text);
+ bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
owner_->updateMenubar();
owner_->updateToolbar();
// Similarly, buffer-dependent dialogs should be updated or
// require bv_->text.
owner_->getDialogs()->updateBufferDependent(true);
redraw();
-#if 0
- insetWakeup();
-#endif
} else {
lyxerr[Debug::INFO] << " No Buffer!" << endl;
owner_->updateMenubar();
owner_->updateToolbar();
owner_->getDialogs()->hideBufferDependent();
updateScrollbar();
- workarea_.redraw();
+ workarea().redraw();
// Also remove all remaining text's from the testcache.
// (there should not be any!) (if there is any it is a
void BufferView::Pimpl::resize(int xpos, int ypos, int width, int height)
{
- workarea_.resize(xpos, ypos, width, height);
+ workarea().resize(xpos, ypos, width, height);
update(bv_->text, SELECT);
redraw();
}
void BufferView::Pimpl::redraw()
{
lyxerr[Debug::INFO] << "BufferView::redraw()" << endl;
- workarea_.redraw();
+ workarea().redraw();
}
bool BufferView::Pimpl::fitCursor()
{
- lyx::Assert(screen_.get());
-
bool ret;
if (bv_->theLockingInset()) {
bv_->theLockingInset()->fitInsetCursor(bv_);
ret = true;
} else {
- ret = screen_->fitCursor(bv_->text, bv_);
+ ret = screen().fitCursor(bv_->text, bv_);
}
bv_->owner()->getDialogs()->updateParagraph();
} else {
// See if we have a text in TextCache that fits
// the new buffer_ with the correct width.
- bv_->text = textcache.findFit(buffer_, workarea_.workWidth());
+ bv_->text = textcache.findFit(buffer_, workarea().workWidth());
if (bv_->text) {
if (lyxerr.debugging()) {
lyxerr << "Found a LyXText that fits:\n";
- textcache.show(lyxerr, make_pair(buffer_, make_pair(workarea_.workWidth(), bv_->text)));
+ textcache.show(lyxerr, make_pair(buffer_, make_pair(workarea().workWidth(), bv_->text)));
}
// Set the owner of the newly found text
// bv_->text->owner(bv_);
bv_->theLockingInset(the_locking_inset);
}
- bv_->text->first_y = screen_->topCursorVisible(bv_->text);
+ bv_->text->first_y = screen().topCursorVisible(bv_->text->cursor, bv_->text->first_y);
// this will scroll the screen such that the cursor becomes visible
updateScrollbar();
void BufferView::Pimpl::updateScreen()
{
// Regenerate the screen.
- screen_.reset(new LyXScreen(workarea_));
+ screen().reset();
}
{
if (!bv_->text) {
lyxerr[Debug::GUI] << "no text in updateScrollbar" << endl;
- workarea_.setScrollbar(0, 1.0);
- return;
- }
-
- long const text_height = bv_->text->height;
- long const work_height = workarea_.height();
-
- double const lineh = bv_->text->defaultHeight();
- double const slider_size =
- (text_height == 0) ? 1.0 : 1.0 / double(text_height);
-
- lyxerr[Debug::GUI] << "text_height now " << text_height << endl;
- lyxerr[Debug::GUI] << "work_height " << work_height << endl;
-
- /* If the text is smaller than the working area, the scrollbar
- * maximum must be the working area height. No scrolling will
- * be possible */
- if (text_height <= work_height) {
- lyxerr[Debug::GUI] << "doc smaller than workarea !" << endl;
- workarea_.setScrollbarBounds(0.0, 0.0);
- current_scrollbar_value = bv_->text->first_y;
- workarea_.setScrollbar(current_scrollbar_value, 1.0);
+ workarea().setScrollbarParams(0, 0, 0);
return;
}
- workarea_.setScrollbarBounds(0.0, text_height - work_height);
- workarea_.setScrollbarIncrements(lineh);
- current_scrollbar_value = bv_->text->first_y;
- workarea_.setScrollbar(current_scrollbar_value, slider_size);
+ LyXText const & t = *bv_->text;
+
+ workarea().setScrollbarParams(t.height, t.first_y, t.defaultHeight());
}
-// Callback for scrollbar slider
-void BufferView::Pimpl::scrollCB(double value)
+void BufferView::Pimpl::scrollDocView(int value)
{
- lyxerr[Debug::GUI] << "scrollCB of " << value << endl;
+ lyxerr[Debug::GUI] << "scrollDocView of " << value << endl;
if (!buffer_) return;
- current_scrollbar_value = long(value);
-
- if (current_scrollbar_value < 0)
- current_scrollbar_value = 0;
-
- if (!screen_.get())
- return;
-
- screen_->draw(bv_->text, bv_, current_scrollbar_value);
+ screen().draw(bv_->text, bv_, value);
if (!lyxrc.cursor_follows_scrollbar) {
waitForX();
int const height = vbt->defaultHeight();
int const first = static_cast<int>((bv_->text->first_y + height));
- int const last = static_cast<int>((bv_->text->first_y + workarea_.height() - height));
+ int const last = static_cast<int>((bv_->text->first_y + workarea().workHeight() - height));
if (vbt->cursor.y() < first)
vbt->setCursorFromCoordinates(bv_, 0, first);
}
-int BufferView::Pimpl::scrollUp(long time)
+int BufferView::Pimpl::scroll(long time)
{
- if (!buffer_ || !screen_.get())
- return 0;
-
- double value = workarea_.getScrollbarValue();
-
- if (value == 0)
- return 0;
-
-#if 1
- float add_value = (bv_->text->defaultHeight()
- + float(time) * float(time) * 0.125);
-
- if (add_value > workarea_.height())
- add_value = float(workarea_.height() -
- bv_->text->defaultHeight());
-#else
- float add_value = float(workarea_.height()) * float(time) / 100;
-#endif
-
- value -= add_value;
-
- if (value < 0)
- value = 0;
-
- workarea_.setScrollbarValue(value);
-
- scrollCB(value);
- return 0;
-}
-
-
-int BufferView::Pimpl::scrollDown(long time)
-{
- if (!buffer_ || !screen_.get())
- return 0;
-
- double value = workarea_.getScrollbarValue();
- pair<float, float> p = workarea_.getScrollbarBounds();
- double const max = p.second;
-
- if (value == max)
+ if (!buffer_)
return 0;
-#if 1
- float add_value = (bv_->text->defaultHeight()
- + float(time) * float(time) * 0.125);
-
- if (add_value > workarea_.height())
- add_value = float(workarea_.height() -
- bv_->text->defaultHeight());
-#else
- float add_value = float(workarea_.height()) * float(time) / 100;
-#endif
-
- value += add_value;
-
- if (value > max)
- value = max;
-
- workarea_.setScrollbarValue(value);
-
- scrollCB(value);
+ LyXText const * t = bv_->text;
+
+ double const diff = t->defaultHeight()
+ + double(time) * double(time) * 0.125;
+
+ scrollDocView(int(diff));
+ workarea().setScrollbarParams(t->height, t->first_y, t->defaultHeight());
return 0;
}
-void BufferView::Pimpl::workAreaKeyPress(KeySym keysym, unsigned int state)
+void BufferView::Pimpl::workAreaKeyPress(KeySym key, key_modifier::state state)
{
- bv_->owner()->getLyXFunc()->processKeySym(keysym, state);
+ bv_->owner()->getLyXFunc()->processKeySym(key, state);
}
-void BufferView::Pimpl::workAreaMotionNotify(int x, int y, unsigned int state)
+void BufferView::Pimpl::workAreaMotionNotify(int x, int y, mouse_button::state state)
{
// Only use motion with button 1
- if (!(state & Button1MotionMask))
+ if (!(state & mouse_button::button1))
return;
- if (!buffer_ || !screen_.get()) return;
+ if (!buffer_)
+ return;
// Check for inset locking
if (bv_->theLockingInset()) {
int inset_x = font.isVisibleRightToLeft()
? cursor.ix() - width : cursor.ix();
int start_x = inset_x + bv_->theLockingInset()->scroll();
+
bv_->theLockingInset()->
insetMotionNotify(bv_,
x - start_x,
if (!selection_possible)
return;
- screen_->hideCursor();
-#if 0
- int y_before = bv_->text->cursor.y();
-#endif
+ screen().hideCursor();
+
Row * cursorrow = bv_->text->cursor.row();
bv_->text->setCursorFromCoordinates(bv_, x, y + bv_->text->first_y);
#if 0
#endif
// This is to allow jumping over large insets
if (cursorrow == bv_->text->cursor.row()) {
- if (y >= int(workarea_.height())) {
+ if (y >= int(workarea().workHeight())) {
bv_->text->cursorDown(bv_, false);
} else if (y < 0) {
bv_->text->cursorUp(bv_, false);
update(bv_->text, BufferView::UPDATE); // Maybe an empty line was deleted
bv_->text->setSelection(bv_);
- screen_->toggleToggle(bv_->text, bv_);
+ screen().toggleToggle(bv_->text, bv_);
fitCursor();
showCursor();
}
// Single-click on work area
void BufferView::Pimpl::workAreaButtonPress(int xpos, int ypos,
- unsigned int button)
+ mouse_button::state button)
{
- if (!buffer_ || !screen_.get())
+ if (!buffer_)
return;
- // ok ok, this is a hack.
- // Why??? (Jug20020424)
- if (button == 4 || button == 5) {
- switch (button) {
- case 4:
- scrollUp(lyxrc.wheel_jump); // default 100, set in lyxrc
- break;
- case 5:
- scrollDown(lyxrc.wheel_jump);
- break;
- }
+ // ok ok, this is a hack (for xforms)
+ if (button == mouse_button::button4) {
+ scroll(-lyxrc.wheel_jump);
+ // We shouldn't go further down as we really should only do the
+ // scrolling and be done with this. Otherwise we may open some
+ // dialogs (Jug 20020424).
+ return;
+ } else if (button == mouse_button::button5) {
+ scroll(lyxrc.wheel_jump);
// We shouldn't go further down as we really should only do the
// scrolling and be done with this. Otherwise we may open some
// dialogs (Jug 20020424).
// it could get cleared on the unlocking of the inset so
// we have to check this first
bool paste_internally = false;
- if (button == 2 && bv_->getLyXText()->selection.set()) {
+ if (button == mouse_button::button2 && bv_->getLyXText()->selection.set()) {
owner_->getLyXFunc()->dispatch(LFUN_COPY);
paste_internally = true;
}
otherwise give the event to the inset */
if (inset_hit == bv_->theLockingInset()) {
bv_->theLockingInset()->
- insetButtonPress(bv_,xpos, ypos,button);
+ insetButtonPress(bv_, xpos, ypos, button);
return;
} else {
bv_->unlockInset(bv_->theLockingInset());
if (!inset_hit)
selection_possible = true;
- screen_->hideCursor();
+ screen().hideCursor();
// Clear the selection
- screen_->toggleSelection(bv_->text, bv_);
+ screen().toggleSelection(bv_->text, bv_);
bv_->text->clearSelection();
bv_->text->fullRebreak(bv_);
update();
// I'm not sure we should continue here if we hit an inset (Jug20020403)
// Right click on a footnote flag opens float menu
- if (button == 3) {
+ if (button == mouse_button::button3) {
selection_possible = false;
return;
}
// Insert primary selection with middle mouse
// if there is a local selection in the current buffer,
// insert this
- if (button == 2) {
+ if (button == mouse_button::button2) {
if (paste_internally)
owner_->getLyXFunc()->dispatch(LFUN_PASTE);
else
}
-void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, unsigned int button)
+void BufferView::Pimpl::doubleClick(int /*x*/, int /*y*/, mouse_button::state button)
{
- // select a word
if (!buffer_)
return;
if (text->bv_owner && bv_->theLockingInset())
return;
- if (screen_.get() && button == 1) {
+ if (button == mouse_button::button1) {
if (text->bv_owner) {
- screen_->hideCursor();
- screen_->toggleSelection(text, bv_);
+ screen().hideCursor();
+ screen().toggleSelection(text, bv_);
text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
- screen_->toggleSelection(text, bv_, false);
+ screen().toggleSelection(text, bv_, false);
} else {
text->selectWord(bv_, LyXText::WHOLE_WORD_STRICT);
}
}
-void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, unsigned int button)
+void BufferView::Pimpl::tripleClick(int /*x*/, int /*y*/, mouse_button::state button)
{
- // select a line
if (!buffer_)
return;
if (text->bv_owner && bv_->theLockingInset())
return;
- if (screen_.get() && (button == 1)) {
+ if (button == mouse_button::button1) {
if (text->bv_owner) {
- screen_->hideCursor();
- screen_->toggleSelection(text, bv_);
+ screen().hideCursor();
+ screen().toggleSelection(text, bv_);
}
text->cursorHome(bv_);
text->selection.cursor = text->cursor;
text->cursorEnd(bv_);
text->setSelection(bv_);
if (text->bv_owner) {
- screen_->toggleSelection(text, bv_, false);
+ screen().toggleSelection(text, bv_, false);
}
/* This will fit the cursor on the screen
* if necessary */
bv_->text->xsel_cache.set(false);
}
if (!sel.empty()) {
- workarea_.putClipboard(sel);
+ workarea().putClipboard(sel);
}
}
void BufferView::Pimpl::selectionLost()
{
- if (active() && available()) {
+ if (available()) {
hideCursor();
toggleSelection();
bv_->getLyXText()->clearSelection();
}
-void BufferView::Pimpl::enterView()
-{
- if (active() && available()) {
- SetXtermCursor(workarea_.getWin());
- using_xterm_cursor = true;
- }
-}
-
-
-void BufferView::Pimpl::leaveView()
-{
- if (using_xterm_cursor) {
- XUndefineCursor(fl_get_display(), workarea_.getWin());
- using_xterm_cursor = false;
- }
-}
-
-
void BufferView::Pimpl::workAreaButtonRelease(int x, int y,
- unsigned int button)
+ mouse_button::state button)
{
// do nothing if we used the mouse wheel
- if (!buffer_ || !screen_.get() || button == 4 || button == 5)
+ if (!buffer_ || button == mouse_button::button4 || button == mouse_button::button5)
return;
// If we hit an inset, we have the inset coordinates in these
selection_possible = false;
- if (button == 2)
+ if (button == mouse_button::button2)
return;
// finish selection
- if (button == 1) {
- workarea_.haveSelection(bv_->getLyXText()->selection.set());
+ if (button == mouse_button::button1) {
+ workarea().haveSelection(bv_->getLyXText()->selection.set());
}
setState();
// Maybe we want to edit a bibitem ale970302
if (bv_->text->cursor.par()->bibkey && x < 20 +
bibitemMaxWidth(bv_, textclasslist[buffer_->params.textclass].defaultfont())) {
- bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, 0);
+ bv_->text->cursor.par()->bibkey->edit(bv_, 0, 0, mouse_button::none);
}
return;
Inset * BufferView::Pimpl::checkInsetHit(LyXText * text, int & x, int & y)
{
- if (!screen_.get())
- return 0;
-
int y_tmp = y + text->first_y;
LyXCursor cursor;
static int work_area_width;
static unsigned int work_area_height;
- bool const widthChange = workarea_.workWidth() != work_area_width;
- bool const heightChange = workarea_.height() != work_area_height;
+ bool const widthChange = workarea().workWidth() != work_area_width;
+ bool const heightChange = workarea().workHeight() != work_area_height;
// update from work area
- work_area_width = workarea_.workWidth();
- work_area_height = workarea_.height();
+ work_area_width = workarea().workWidth();
+ work_area_height = workarea().workHeight();
if (buffer_ != 0) {
if (widthChange) {
// The visible LyXView need a resize
- owner_->resize();
+ owner_->view()->resize();
// Remove all texts from the textcache
// This is not _really_ what we want to do. What
// The main window size has changed, repaint most stuff
redraw();
- } else if (screen_.get())
- screen_->redraw(bv_->text, bv_);
+ } else {
+ screen().redraw(bv_->text, bv_);
+ }
} else {
// Grey box when we don't have a buffer
- workarea_.greyOut();
+ workarea().greyOut();
}
// always make sure that the scrollbar is sane.
void BufferView::Pimpl::update()
{
- if (screen_.get() &&
- (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()))
- {
+ if (!bv_->theLockingInset() || !bv_->theLockingInset()->nodraw()) {
LyXText::text_status st = bv_->text->status();
- screen_->update(bv_->text, bv_);
+ screen().update(bv_->text, bv_);
bool fitc = false;
while (bv_->text->status() == LyXText::CHANGED_IN_DRAW) {
bv_->text->fullRebreak(bv_);
}
fitc = true;
bv_->text->status(bv_, st);
- screen_->update(bv_->text, bv_);
+ screen().update(bv_->text, bv_);
}
// do this here instead of in the screen::update because of
// the above loop!
return;
}
- if (!screen_.get()) {
- cursor_timeout.restart();
- return;
- }
-
/* FIXME */
extern void reapSpellchecker(void);
reapSpellchecker();
if (!bv_->theLockingInset()) {
- screen_->cursorToggle(bv_);
+ screen().cursorToggle(bv_);
} else {
bv_->theLockingInset()->toggleInsetCursor(bv_);
}
{
if (!text->cursor.row()->previous()) {
if (text->first_y > 0) {
- int new_y = bv_->text->first_y - workarea_.height();
- screen_->draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
+ int new_y = bv_->text->first_y - workarea().workHeight();
+ screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
updateScrollbar();
}
return;
// as we move the cursor or do something while inside the row (it may
// span several workarea-heights) we'll move to the top again, but this
// is better than just jump down and only display part of the row.
- new_y = bv_->text->first_y - workarea_.height();
+ new_y = bv_->text->first_y - workarea().workHeight();
} else {
if (text->inset_owner) {
new_y = bv_->text->cursor.iy()
+ bv_->theLockingInset()->insetInInsetY() + y
+ text->cursor.row()->height()
- - workarea_.height() + 1;
+ - workarea().workHeight() + 1;
} else {
new_y = text->cursor.y()
- text->cursor.row()->baseline()
+ text->cursor.row()->height()
- - workarea_.height() + 1;
+ - workarea().workHeight() + 1;
}
}
- screen_->draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
+ screen().draw(bv_->text, bv_, new_y < 0 ? 0 : new_y);
if (text->cursor.row()->previous()) {
LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->previous()->par(),
if (!text->cursor.row()->next()) {
int y = text->cursor.y() - text->cursor.row()->baseline() +
text->cursor.row()->height();
- if (y > int(text->first_y + workarea_.height())) {
- screen_->draw(bv_->text, bv_,
- bv_->text->first_y + workarea_.height());
+ if (y > int(text->first_y + workarea().workHeight())) {
+ screen().draw(bv_->text, bv_,
+ bv_->text->first_y + workarea().workHeight());
updateScrollbar();
}
return;
}
- int y = text->first_y + workarea_.height();
+ int y = text->first_y + workarea().workHeight();
if (text->inset_owner && !text->first_y) {
y -= (bv_->text->cursor.iy()
- bv_->text->first_y
+ bv_->theLockingInset()->insetInInsetY());
}
+
text->getRowNearY(y);
Row * cursorrow = text->cursor.row();
- text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y); // + workarea_->height());
+ text->setCursorFromCoordinates(bv_, text->cursor.x_fix(), y); // + workarea().workHeight());
finishUndo();
+
int new_y;
if (cursorrow == bv_->text->cursor.row()) {
// we have a row which is higher than the workarea so we leave the
// as we move the cursor or do something while inside the row (it may
// span several workarea-heights) we'll move to the top again, but this
// is better than just jump down and only display part of the row.
- new_y = bv_->text->first_y + workarea_.height();
+ new_y = bv_->text->first_y + workarea().workHeight();
} else {
if (text->inset_owner) {
new_y = bv_->text->cursor.iy()
new_y = text->cursor.y() - text->cursor.row()->baseline();
}
}
- screen_->draw(bv_->text, bv_, new_y);
+ screen().draw(bv_->text, bv_, new_y);
if (text->cursor.row()->next()) {
LyXCursor cur;
text->setCursor(bv_, cur, text->cursor.row()->next()->par(),
text->cursor.row()->next()->pos(), false);
- if (cur.y() < int(text->first_y + workarea_.height())) {
+ if (cur.y() < int(text->first_y + workarea().workHeight())) {
text->cursorDown(bv_, true);
}
}
}
-#if 0
-void BufferView::Pimpl::insetSleep()
-{
- if (bv_->theLockingInset() && !inset_slept) {
- bv_->theLockingInset()->getCursorPos(bv_, bv_->slx, bv_->sly);
- bv_->theLockingInset()->insetUnlock(bv_);
- inset_slept = true;
- }
-}
-
-
-void BufferView::Pimpl::insetWakeup()
-{
- if (bv_->theLockingInset() && inset_slept) {
- bv_->theLockingInset()->edit(bv_, bv_->slx, bv_->sly, 0);
- inset_slept = false;
- }
-}
-#endif
-
-
void BufferView::Pimpl::insetUnlock()
{
if (bv_->theLockingInset()) {
- if (!inset_slept)
- bv_->theLockingInset()->insetUnlock(bv_);
+ bv_->theLockingInset()->insetUnlock(bv_);
bv_->theLockingInset(0);
finishUndo();
- inset_slept = false;
}
}
bool BufferView::Pimpl::focus() const
{
- return workarea_.hasFocus();
+ return workarea().hasFocus();
}
void BufferView::Pimpl::focus(bool f)
{
- if (f) workarea_.setFocus();
-}
-
-
-bool BufferView::Pimpl::active() const
-{
- return workarea_.active();
-}
-
-
-bool BufferView::Pimpl::belowMouse() const
-{
- return workarea_.belowMouse();
+ if (f) workarea().setFocus();
}
void BufferView::Pimpl::showCursor()
{
- if (screen_.get()) {
- if (bv_->theLockingInset())
- bv_->theLockingInset()->showInsetCursor(bv_);
- else
- screen_->showCursor(bv_->text, bv_);
- }
+ if (bv_->theLockingInset())
+ bv_->theLockingInset()->showInsetCursor(bv_);
+ else
+ screen().showCursor(bv_->text, bv_);
}
void BufferView::Pimpl::hideCursor()
{
- if (screen_.get()) {
- if (!bv_->theLockingInset())
-// bv_->theLockingInset()->hideInsetCursor(bv_);
-// else
- screen_->hideCursor();
- }
+ if (!bv_->theLockingInset())
+ screen().hideCursor();
}
void BufferView::Pimpl::toggleSelection(bool b)
{
- if (screen_.get()) {
- if (bv_->theLockingInset())
- bv_->theLockingInset()->toggleSelection(bv_, b);
- screen_->toggleSelection(bv_->text, bv_, b);
- }
+ if (bv_->theLockingInset())
+ bv_->theLockingInset()->toggleSelection(bv_, b);
+ screen().toggleSelection(bv_->text, bv_, b);
}
void BufferView::Pimpl::toggleToggle()
{
- if (screen_.get())
- screen_->toggleToggle(bv_->text, bv_);
+ screen().toggleToggle(bv_->text, bv_);
}
void BufferView::Pimpl::center()
{
beforeChange(bv_->text);
- if (bv_->text->cursor.y() > static_cast<int>((workarea_.height() / 2))) {
- screen_->draw(bv_->text, bv_, bv_->text->cursor.y() - workarea_.height() / 2);
+ if (bv_->text->cursor.y() > static_cast<int>((workarea().workHeight() / 2))) {
+ screen().draw(bv_->text, bv_, bv_->text->cursor.y() - workarea().workHeight() / 2);
} else {
- screen_->draw(bv_->text, bv_, 0);
+ screen().draw(bv_->text, bv_, 0);
}
update(bv_->text, BufferView::SELECT|BufferView::FITCUR);
redraw();
if (!buffer_)
return;
- screen_->hideCursor();
+ screen().hideCursor();
beforeChange(bv_->text);
- string const clip(workarea_.getClipboard());
+ string const clip(workarea().getClipboard());
if (clip.empty())
return;
void BufferView::Pimpl::stuffClipboard(string const & stuff) const
{
- workarea_.putClipboard(stuff);
+ workarea().putClipboard(stuff);
}
}
if (!lt->selection.set())
- workarea_.haveSelection(false);
-
+ workarea().haveSelection(false);
+
/* ---> Everytime the cursor is moved, show the current font state. */
// should this too me moved out of this func?
//owner->showState();
// This is soooo ugly. Isn`t it possible to make
// it simpler? (Lgb)
LyXText * lt = bv_->getLyXText();
- bool is_rtl = lt->cursor.par()->isRightToLeftPar(buffer_->params);
+ bool const is_rtl = lt->cursor.par()->isRightToLeftPar(buffer_->params);
if (!lt->selection.mark())
beforeChange(lt);
update(lt, BufferView::SELECT|BufferView::FITCUR);
| BufferView::FITCUR
| BufferView::CHANGE);
}
- workarea_.haveSelection(false);
+ workarea().haveSelection(false);
}
beforeChange(lt);