2002-06-18 15:44:30 +00:00
|
|
|
/**
|
|
|
|
* \file screen.C
|
|
|
|
* Copyright 2002 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon <moz@compsoc.man.ac.uk>
|
2002-06-25 15:59:10 +00:00
|
|
|
*
|
|
|
|
* Splash screen code added by Angus Leeming
|
2002-06-18 15:44:30 +00:00
|
|
|
*/
|
1999-09-27 18:44:28 +00:00
|
|
|
|
|
|
|
#ifdef __GNUG__
|
2002-05-23 15:43:25 +00:00
|
|
|
#pragma implementation
|
1999-09-27 18:44:28 +00:00
|
|
|
#endif
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
#include <config.h>
|
2000-02-18 22:22:42 +00:00
|
|
|
|
2002-05-23 15:43:25 +00:00
|
|
|
#include "screen.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
#include "lyxtext.h"
|
2000-02-04 09:38:32 +00:00
|
|
|
#include "lyxrow.h"
|
2001-06-25 00:06:33 +00:00
|
|
|
#include "BufferView.h"
|
2002-06-18 15:44:30 +00:00
|
|
|
#include "buffer.h"
|
|
|
|
#include "WorkArea.h"
|
|
|
|
#include "Painter.h"
|
2002-05-24 14:34:32 +00:00
|
|
|
#include "font_metrics.h"
|
2001-04-05 12:26:41 +00:00
|
|
|
#include "language.h"
|
2002-06-18 15:44:30 +00:00
|
|
|
#include "debug.h"
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-06-25 15:59:10 +00:00
|
|
|
// Splash screen-specific stuff
|
|
|
|
#include "lyxfont.h"
|
|
|
|
#include "version.h"
|
|
|
|
|
2002-06-26 14:15:08 +00:00
|
|
|
#include "graphics/GraphicsLoader.h"
|
2002-06-25 15:59:10 +00:00
|
|
|
#include "graphics/GraphicsImage.h"
|
|
|
|
|
|
|
|
#include "support/filetools.h" // LibFileSearch
|
|
|
|
|
|
|
|
#include <boost/utility.hpp>
|
|
|
|
#include <boost/bind.hpp>
|
2002-06-26 14:15:08 +00:00
|
|
|
#include <boost/signals/trackable.hpp>
|
2002-06-25 15:59:10 +00:00
|
|
|
|
2000-02-18 22:22:42 +00:00
|
|
|
using std::min;
|
2002-06-18 15:44:30 +00:00
|
|
|
using std::max;
|
|
|
|
using std::endl;
|
2002-06-21 17:16:35 +00:00
|
|
|
|
2002-06-25 15:59:10 +00:00
|
|
|
namespace {
|
|
|
|
|
2002-06-26 14:15:08 +00:00
|
|
|
class SplashScreen : boost::noncopyable, boost::signals::trackable {
|
2002-06-25 15:59:10 +00:00
|
|
|
public:
|
|
|
|
/// This is a singleton class. Get the instance.
|
|
|
|
static SplashScreen const & get();
|
|
|
|
///
|
2002-06-26 14:15:08 +00:00
|
|
|
grfx::GImage const * image() const { return loader_.image(); }
|
2002-06-25 15:59:10 +00:00
|
|
|
///
|
|
|
|
string const & text() const { return text_; }
|
|
|
|
///
|
|
|
|
LyXFont const & font() const { return font_; }
|
|
|
|
|
|
|
|
private:
|
2002-06-26 14:15:08 +00:00
|
|
|
/** Make the c-tor private so we can control how many objects
|
2002-06-25 15:59:10 +00:00
|
|
|
* are instantiated.
|
|
|
|
*/
|
|
|
|
SplashScreen();
|
|
|
|
|
2002-06-26 14:15:08 +00:00
|
|
|
///
|
|
|
|
grfx::Loader loader_;
|
2002-06-25 15:59:10 +00:00
|
|
|
/// The text to be written on top of the pixmap
|
|
|
|
string const text_;
|
|
|
|
/// in this font...
|
|
|
|
LyXFont font_;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
SplashScreen const & SplashScreen::get()
|
|
|
|
{
|
|
|
|
static SplashScreen singleton;
|
|
|
|
return singleton;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
SplashScreen::SplashScreen()
|
2002-06-26 14:15:08 +00:00
|
|
|
: text_(lyx_version ? lyx_version : "unknown")
|
2002-06-25 15:59:10 +00:00
|
|
|
{
|
|
|
|
string const file = LibFileSearch("images", "banner", "xpm");
|
|
|
|
if (file.empty())
|
|
|
|
return;
|
|
|
|
|
|
|
|
// The font used to display the version info
|
|
|
|
font_.setFamily(LyXFont::SANS_FAMILY);
|
|
|
|
font_.setSeries(LyXFont::BOLD_SERIES);
|
|
|
|
font_.setSize(LyXFont::SIZE_NORMAL);
|
|
|
|
font_.setColor(LColor::yellow);
|
|
|
|
|
|
|
|
// Load up the graphics file
|
2002-06-26 14:15:08 +00:00
|
|
|
loader_.reset(file);
|
|
|
|
// We aren't interested here in when the image is loaded.
|
|
|
|
// If it isn't ready when we want it, then we ignore it.
|
|
|
|
// loader_->statusChanged.connect(
|
|
|
|
// boost::bind(&SplashScreen::statusChanged, this));
|
|
|
|
if (loader_.status() == grfx::WaitingToLoad)
|
|
|
|
loader_.startLoading();
|
2002-06-25 15:59:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace anon
|
|
|
|
|
2002-06-21 17:16:35 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
LyXScreen::LyXScreen()
|
|
|
|
: force_clear_(true), cursor_visible_(false)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-06-25 15:59:10 +00:00
|
|
|
// Start loading the pixmap as soon as possible
|
|
|
|
SplashScreen::get();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
LyXScreen::~LyXScreen()
|
2001-06-25 00:06:33 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
// FIXME: GUII these cursor methods need to decide
|
|
|
|
// whether the workarea is focused or not
|
2002-03-21 17:27:08 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
void LyXScreen::showCursor(LyXText const * text, BufferView const * bv)
|
2002-06-11 23:47:58 +00:00
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
if (cursor_visible_)
|
|
|
|
return;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().start();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
Cursor_Shape shape = BAR_SHAPE;
|
|
|
|
BufferParams const & bp(bv->buffer()->params);
|
|
|
|
LyXFont const & realfont(text->real_current_font);
|
|
|
|
|
|
|
|
if (realfont.language() != bp.language
|
2002-06-24 20:28:12 +00:00
|
|
|
|| realfont.isVisibleRightToLeft()
|
2002-06-18 15:44:30 +00:00
|
|
|
!= bp.language->RightToLeft()) {
|
|
|
|
shape = (realfont.isVisibleRightToLeft())
|
|
|
|
? REVERSED_L_SHAPE : L_SHAPE;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
showManualCursor(text, text->cursor.x(), text->cursor.y(),
|
|
|
|
font_metrics::maxAscent(realfont),
|
|
|
|
font_metrics::maxDescent(realfont),
|
|
|
|
shape);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().end();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
bool LyXScreen::fitManualCursor(BufferView * bv, LyXText * text,
|
|
|
|
int /*x*/, int y, int asc, int desc)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
int const vheight = workarea().workHeight();
|
2002-03-03 20:25:07 +00:00
|
|
|
int newtop = text->first_y;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
if (y + desc - text->first_y >= vheight)
|
|
|
|
newtop = y - 3 * vheight / 4; // the scroll region must be so big!!
|
2002-03-03 20:25:07 +00:00
|
|
|
else if (y - asc < text->first_y
|
|
|
|
&& text->first_y > 0) {
|
2002-06-18 15:44:30 +00:00
|
|
|
newtop = y - vheight / 4;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-05-20 21:37:05 +00:00
|
|
|
|
2000-09-29 18:44:07 +00:00
|
|
|
newtop = max(newtop, 0); // can newtop ever be < 0? (Lgb)
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
if (newtop != text->first_y) {
|
2001-07-04 07:19:09 +00:00
|
|
|
draw(text, bv, newtop);
|
2002-03-03 20:25:07 +00:00
|
|
|
text->first_y = newtop;
|
2000-04-26 13:57:28 +00:00
|
|
|
return true;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2000-04-26 13:57:28 +00:00
|
|
|
return false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
void LyXScreen::cursorToggle(BufferView * bv) const
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
if (cursor_visible_)
|
2001-08-02 14:55:06 +00:00
|
|
|
bv->hideCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
else
|
2001-08-02 14:55:06 +00:00
|
|
|
bv->showCursor();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
unsigned int LyXScreen::topCursorVisible(LyXCursor const & cursor, int top_y)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
int const vheight = workarea().workHeight();
|
|
|
|
int newtop = top_y;
|
1999-09-27 18:44:28 +00:00
|
|
|
|
2002-06-12 10:31:34 +00:00
|
|
|
Row * row = cursor.row();
|
2001-12-28 21:52:59 +00:00
|
|
|
|
|
|
|
// Is this a hack? Yes, probably... (Lgb)
|
|
|
|
if (!row)
|
|
|
|
return max(newtop, 0);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-12 10:31:34 +00:00
|
|
|
if (cursor.y() - row->baseline() + row->height()
|
|
|
|
- top_y >= vheight) {
|
|
|
|
if (row->height() < vheight
|
|
|
|
&& row->height() > vheight / 4) {
|
|
|
|
newtop = cursor.y()
|
2001-12-28 21:52:59 +00:00
|
|
|
+ row->height()
|
2002-06-12 10:31:34 +00:00
|
|
|
- row->baseline() - vheight;
|
2001-12-02 23:20:56 +00:00
|
|
|
} else {
|
|
|
|
// scroll down
|
2002-06-12 10:31:34 +00:00
|
|
|
newtop = cursor.y()
|
|
|
|
- vheight / 2; /* the scroll region must be so big!! */
|
2001-12-02 23:20:56 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
} else if (static_cast<int>((cursor.y()) - row->baseline()) <
|
2002-06-12 10:31:34 +00:00
|
|
|
top_y && top_y > 0) {
|
|
|
|
if (row->height() < vheight
|
|
|
|
&& row->height() > vheight / 4) {
|
|
|
|
newtop = cursor.y() - row->baseline();
|
2001-12-02 23:20:56 +00:00
|
|
|
} else {
|
|
|
|
// scroll up
|
2002-06-12 10:31:34 +00:00
|
|
|
newtop = cursor.y() - vheight / 2;
|
|
|
|
newtop = min(newtop, top_y);
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
}
|
2000-05-20 21:37:05 +00:00
|
|
|
|
2000-09-29 18:44:07 +00:00
|
|
|
newtop = max(newtop, 0);
|
2000-04-26 13:57:28 +00:00
|
|
|
|
1999-09-27 18:44:28 +00:00
|
|
|
return newtop;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
bool LyXScreen::fitCursor(LyXText * text, BufferView * bv)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-04-26 13:57:28 +00:00
|
|
|
// Is a change necessary?
|
2002-06-12 10:31:34 +00:00
|
|
|
int const newtop = topCursorVisible(text->cursor, text->first_y);
|
2002-03-03 20:25:07 +00:00
|
|
|
bool const result = (newtop != text->first_y);
|
1999-09-27 18:44:28 +00:00
|
|
|
if (result)
|
2001-07-04 07:19:09 +00:00
|
|
|
draw(text, bv, newtop);
|
1999-09-27 18:44:28 +00:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
void LyXScreen::update(LyXText * text, BufferView * bv,
|
|
|
|
int yo, int xo)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
int const vwidth = workarea().workWidth();
|
|
|
|
int const vheight = workarea().workHeight();
|
|
|
|
|
|
|
|
workarea().getPainter().start();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2001-07-06 15:57:54 +00:00
|
|
|
switch (text->status()) {
|
2000-04-26 13:57:28 +00:00
|
|
|
case LyXText::NEED_MORE_REFRESH:
|
|
|
|
{
|
2002-03-03 20:25:07 +00:00
|
|
|
int const y = max(int(text->refresh_y - text->first_y), 0);
|
2002-06-18 15:44:30 +00:00
|
|
|
drawFromTo(text, bv, y, vheight, yo, xo);
|
2000-04-26 13:57:28 +00:00
|
|
|
text->refresh_y = 0;
|
2001-08-03 13:09:59 +00:00
|
|
|
// otherwise this is called ONLY from BufferView_pimpl(update)
|
|
|
|
// or we should see to set this flag accordingly
|
|
|
|
if (text != bv->text)
|
|
|
|
text->status(bv, LyXText::UNCHANGED);
|
2002-06-18 15:44:30 +00:00
|
|
|
expose(0, y, vwidth, vheight - y);
|
2000-04-26 13:57:28 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
case LyXText::NEED_VERY_LITTLE_REFRESH:
|
|
|
|
{
|
2000-05-20 21:37:05 +00:00
|
|
|
// ok I will update the current cursor row
|
2001-07-04 07:19:09 +00:00
|
|
|
drawOneRow(text, bv, text->refresh_row, text->refresh_y,
|
2002-06-18 15:44:30 +00:00
|
|
|
yo, xo);
|
2001-08-02 14:55:06 +00:00
|
|
|
// this because if we had a major update the refresh_row could
|
|
|
|
// have been set to 0!
|
|
|
|
if (text->refresh_row) {
|
2001-08-03 13:09:59 +00:00
|
|
|
// otherwise this is called ONLY from BufferView_pimpl(update)
|
|
|
|
// or we should see to set this flag accordingly
|
|
|
|
if (text != bv->text)
|
|
|
|
text->status(bv, LyXText::UNCHANGED);
|
2002-06-18 15:44:30 +00:00
|
|
|
expose(0, text->refresh_y - text->first_y + yo,
|
|
|
|
vwidth, text->refresh_row->height());
|
2001-08-02 14:55:06 +00:00
|
|
|
}
|
2000-04-26 13:57:28 +00:00
|
|
|
}
|
|
|
|
break;
|
2000-07-07 08:24:42 +00:00
|
|
|
case LyXText::CHANGED_IN_DRAW: // just to remove the warning
|
2000-04-26 13:57:28 +00:00
|
|
|
case LyXText::UNCHANGED:
|
|
|
|
// Nothing needs done
|
|
|
|
break;
|
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().end();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
void LyXScreen::toggleSelection(LyXText * text, BufferView * bv,
|
2001-01-02 16:06:14 +00:00
|
|
|
bool kill_selection,
|
2002-06-18 15:44:30 +00:00
|
|
|
int yo, int xo)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-05-20 21:37:05 +00:00
|
|
|
// only if there is a selection
|
2001-05-31 02:23:46 +00:00
|
|
|
if (!text->selection.set()) return;
|
1999-12-16 06:43:25 +00:00
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
int const bottom = min(
|
2001-05-31 02:23:46 +00:00
|
|
|
max(static_cast<int>(text->selection.end.y()
|
|
|
|
- text->selection.end.row()->baseline()
|
|
|
|
+ text->selection.end.row()->height()),
|
2002-03-03 20:25:07 +00:00
|
|
|
text->first_y),
|
2002-06-18 15:44:30 +00:00
|
|
|
static_cast<int>(text->first_y + workarea().workHeight()));
|
2000-11-21 15:46:13 +00:00
|
|
|
int const top = min(
|
2001-05-31 02:23:46 +00:00
|
|
|
max(static_cast<int>(text->selection.start.y() -
|
|
|
|
text->selection.start.row()->baseline()),
|
2002-03-03 20:25:07 +00:00
|
|
|
text->first_y),
|
2002-06-18 15:44:30 +00:00
|
|
|
static_cast<int>(text->first_y + workarea().workHeight()));
|
2000-02-18 22:22:42 +00:00
|
|
|
|
2000-02-17 19:59:08 +00:00
|
|
|
if (kill_selection)
|
2001-05-31 02:23:46 +00:00
|
|
|
text->selection.set(false);
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().start();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
drawFromTo(text, bv, top - text->first_y, bottom - text->first_y,
|
2002-06-18 15:44:30 +00:00
|
|
|
yo, xo);
|
2002-03-03 20:25:07 +00:00
|
|
|
expose(0, top - text->first_y,
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().workWidth(),
|
2002-06-24 20:28:12 +00:00
|
|
|
bottom - text->first_y - (top - text->first_y));
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().end();
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|
2002-06-24 20:28:12 +00:00
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
void LyXScreen::toggleToggle(LyXText * text, BufferView * bv,
|
|
|
|
int yo, int xo)
|
1999-09-27 18:44:28 +00:00
|
|
|
{
|
2000-06-08 23:16:16 +00:00
|
|
|
if (text->toggle_cursor.par() == text->toggle_end_cursor.par()
|
|
|
|
&& text->toggle_cursor.pos() == text->toggle_end_cursor.pos())
|
1999-09-27 18:44:28 +00:00
|
|
|
return;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
int const top_tmp = text->toggle_cursor.y()
|
2000-06-08 23:16:16 +00:00
|
|
|
- text->toggle_cursor.row()->baseline();
|
2000-11-21 15:46:13 +00:00
|
|
|
int const bottom_tmp = text->toggle_end_cursor.y()
|
2002-03-21 17:27:08 +00:00
|
|
|
- text->toggle_end_cursor.row()->baseline()
|
2000-06-08 23:16:16 +00:00
|
|
|
+ text->toggle_end_cursor.row()->height();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
int const offset = yo < 0 ? yo : 0;
|
2002-03-03 20:25:07 +00:00
|
|
|
int const bottom = min(max(bottom_tmp, text->first_y),
|
2002-06-18 15:44:30 +00:00
|
|
|
static_cast<int>(text->first_y + workarea().workHeight())) - offset;
|
2002-03-03 20:25:07 +00:00
|
|
|
int const top = min(max(top_tmp, text->first_y),
|
2002-06-18 15:44:30 +00:00
|
|
|
static_cast<int>(text->first_y + workarea().workHeight())) - offset;
|
|
|
|
|
|
|
|
workarea().getPainter().start();
|
2002-04-05 15:17:24 +00:00
|
|
|
|
2002-03-03 20:25:07 +00:00
|
|
|
drawFromTo(text, bv, top - text->first_y,
|
2002-06-18 15:44:30 +00:00
|
|
|
bottom - text->first_y, yo,
|
|
|
|
xo);
|
|
|
|
expose(0, top - text->first_y, workarea().workWidth(),
|
2002-03-03 20:25:07 +00:00
|
|
|
bottom - text->first_y - (top - text->first_y));
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().end();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXScreen::redraw(LyXText * text, BufferView * bv)
|
|
|
|
{
|
|
|
|
workarea().getPainter().start();
|
|
|
|
|
|
|
|
if (!text) {
|
|
|
|
greyOut();
|
|
|
|
expose(0, 0, workarea().workWidth(), workarea().workHeight());
|
|
|
|
workarea().getPainter().end();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
drawFromTo(text, bv, 0, workarea().workHeight(), 0, 0, text == bv->text);
|
|
|
|
expose(0, 0, workarea().workWidth(), workarea().workHeight());
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
workarea().getPainter().end();
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
if (cursor_visible_) {
|
|
|
|
cursor_visible_ = false;
|
|
|
|
bv->showCursor();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXScreen::greyOut()
|
|
|
|
{
|
|
|
|
workarea().getPainter().fillRectangle(0, 0,
|
|
|
|
workarea().workWidth(),
|
|
|
|
workarea().workHeight(),
|
|
|
|
LColor::bottomarea);
|
2002-06-21 04:40:40 +00:00
|
|
|
|
|
|
|
// Add a splash screen to the centre of the work area
|
2002-06-25 15:59:10 +00:00
|
|
|
SplashScreen const & splash = SplashScreen::get();
|
|
|
|
grfx::GImage const * const splash_image = splash.image();
|
|
|
|
if (splash_image) {
|
|
|
|
int const w = splash_image->getWidth();
|
|
|
|
int const h = splash_image->getHeight();
|
|
|
|
|
|
|
|
int x = 0.5 * (workarea().workWidth() - w);
|
|
|
|
int y = 0.5 * (workarea().workHeight() - h);
|
2002-06-21 17:16:35 +00:00
|
|
|
|
2002-06-25 15:59:10 +00:00
|
|
|
workarea().getPainter().image(x, y, w, h, *splash_image);
|
2002-06-21 17:16:35 +00:00
|
|
|
|
2002-06-25 15:59:10 +00:00
|
|
|
string const & splash_text = splash.text();
|
|
|
|
LyXFont const & splash_font = splash.font();
|
|
|
|
|
|
|
|
x += 260;
|
|
|
|
y += 265;
|
|
|
|
|
|
|
|
workarea().getPainter().text(x, y, splash_text, splash_font);
|
2002-06-21 17:16:35 +00:00
|
|
|
}
|
2002-06-18 15:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXScreen::drawFromTo(LyXText * text, BufferView * bv,
|
|
|
|
int y1, int y2, int yo, int xo,
|
|
|
|
bool internal)
|
|
|
|
{
|
2002-06-21 02:22:13 +00:00
|
|
|
lyxerr[Debug::GUI] << "screen: drawFromTo " << y1 << "-" << y2 << endl;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
int y_text = text->first_y + y1;
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
// get the first needed row
|
|
|
|
Row * row = text->getRowNearY(y_text);
|
|
|
|
// y_text is now the real beginning of the row
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
int y = y_text - text->first_y;
|
|
|
|
// y1 is now the real beginning of row on the screen
|
2002-06-24 20:28:12 +00:00
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
while (row != 0 && y < y2) {
|
|
|
|
LyXText::text_status st = text->status();
|
|
|
|
text->getVisibleRow(bv, y + yo,
|
2002-06-24 20:28:12 +00:00
|
|
|
xo, row, y + text->first_y);
|
2002-06-18 15:44:30 +00:00
|
|
|
internal = internal && (st != LyXText::CHANGED_IN_DRAW);
|
|
|
|
while (internal && text->status() == LyXText::CHANGED_IN_DRAW) {
|
|
|
|
text->fullRebreak(bv);
|
|
|
|
st = LyXText::NEED_MORE_REFRESH;
|
|
|
|
text->setCursor(bv, text->cursor.par(), text->cursor.pos());
|
|
|
|
text->status(bv, st);
|
|
|
|
text->getVisibleRow(bv, y + yo,
|
2002-06-24 20:28:12 +00:00
|
|
|
xo, row, y + text->first_y);
|
2002-06-18 15:44:30 +00:00
|
|
|
}
|
|
|
|
y += row->height();
|
|
|
|
row = row->next();
|
|
|
|
}
|
|
|
|
force_clear_ = false;
|
|
|
|
|
|
|
|
// maybe we have to clear the screen at the bottom
|
|
|
|
if ((y < y2) && text->bv_owner) {
|
|
|
|
workarea().getPainter().fillRectangle(0, y,
|
|
|
|
workarea().workWidth(), y2 - y,
|
|
|
|
LColor::bottomarea);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void LyXScreen::drawOneRow(LyXText * text, BufferView * bv, Row * row,
|
|
|
|
int y_text, int yo, int xo)
|
|
|
|
{
|
|
|
|
int const y = y_text - text->first_y + yo;
|
|
|
|
|
|
|
|
if (((y + row->height()) > 0) &&
|
|
|
|
((y - row->height()) <= static_cast<int>(workarea().workHeight()))) {
|
|
|
|
text->getVisibleRow(bv, y, xo, row, y + text->first_y);
|
|
|
|
}
|
|
|
|
force_clear_ = false;
|
1999-09-27 18:44:28 +00:00
|
|
|
}
|