mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-12-22 13:18:28 +00:00
This patch removes qscreen.[Ch] and simplify the cursor drawing on screen. Basically, we paint now only if needed. So there's no need anymore to handle the "no cursor" pixmap saving.
SConscript: removed qscreen.C frontends/qt4/Makefile.am: removed qscreen.C frontends/screen.h: remove workarea() constness frontends/qt3/qscreen.[Ch]: ditto frontends/gtk/GScreen.[Ch]: ditto frontends/xforms/xscreen.[Ch]: ditto frontends/qt4/LyXScreenFactory.C: now return the QWorkarea directly frontends/qt4/QWorkArea.[Ch]: inherits LyXScreen, handle the cursor painting frontends/qt4/qscreen.[Ch]: removed git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@13981 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
924d8f471c
commit
6a742b7aa0
@ -973,7 +973,6 @@ if build_qt4:
|
||||
qfontexample.C
|
||||
qfont_loader.C
|
||||
qfont_metrics.C
|
||||
qscreen.C
|
||||
qt_helpers.C
|
||||
''')]
|
||||
|
||||
|
@ -58,7 +58,7 @@ GScreen::~GScreen()
|
||||
}
|
||||
|
||||
|
||||
WorkArea & GScreen::workarea() const
|
||||
WorkArea & GScreen::workarea()
|
||||
{
|
||||
return owner_;
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ public:
|
||||
virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
|
||||
protected:
|
||||
/// get the work area
|
||||
virtual WorkArea & workarea() const;
|
||||
virtual WorkArea & workarea();
|
||||
|
||||
/// Copies specified area of pixmap to screen
|
||||
virtual void expose(int x, int y, int w, int h);
|
||||
|
@ -42,7 +42,7 @@ QScreen::~QScreen()
|
||||
}
|
||||
|
||||
|
||||
WorkArea & QScreen::workarea() const
|
||||
WorkArea & QScreen::workarea()
|
||||
{
|
||||
return owner_;
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ public:
|
||||
|
||||
protected:
|
||||
/// get the work area
|
||||
virtual WorkArea & workarea() const;
|
||||
virtual WorkArea & workarea();
|
||||
|
||||
/// repaint the whole content immediately
|
||||
void repaint();
|
||||
|
@ -13,13 +13,12 @@
|
||||
#include "frontends/LyXScreenFactory.h"
|
||||
|
||||
#include "QWorkArea.h"
|
||||
#include "qscreen.h"
|
||||
|
||||
namespace LyXScreenFactory {
|
||||
|
||||
LyXScreen * create(WorkArea & owner)
|
||||
{
|
||||
return new QScreen(static_cast<QWorkArea &>(owner));
|
||||
return &(static_cast<QWorkArea &>(owner));
|
||||
}
|
||||
|
||||
} // namespace LyXScreenFactory
|
||||
|
@ -92,6 +92,5 @@ libqt4_la_SOURCES = \
|
||||
qfont_loader.h qfont_loader.C \
|
||||
qfont_metrics.C \
|
||||
qlkey.h \
|
||||
qscreen.h qscreen.C \
|
||||
qt_helpers.h qt_helpers.C \
|
||||
$(MOCFILES)
|
||||
|
@ -216,6 +216,7 @@ void QWorkArea::setScrollbarParams(int h, int scroll_pos, int scroll_line_step)
|
||||
|
||||
void QWorkArea::adjustViewWithScrollBar(int action)
|
||||
{
|
||||
/*
|
||||
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
||||
<< " verticalScrollBar val=" << verticalScrollBar()->value()
|
||||
<< " verticalScrollBar pos=" << verticalScrollBar()->sliderPosition()
|
||||
@ -224,7 +225,7 @@ void QWorkArea::adjustViewWithScrollBar(int action)
|
||||
<< " pagestep=" << verticalScrollBar()->pageStep()
|
||||
<< " linestep=" << verticalScrollBar()->lineStep()
|
||||
<< endl;
|
||||
|
||||
*/
|
||||
view_.view()->scrollDocView(verticalScrollBar()->sliderPosition());
|
||||
}
|
||||
|
||||
@ -538,6 +539,12 @@ void QWorkArea::paintEvent(QPaintEvent * e)
|
||||
*/
|
||||
QPainter q(viewport());
|
||||
q.drawPixmap(e->rect(), paint_device_, e->rect());
|
||||
|
||||
if (show_vcursor_)
|
||||
q.drawPixmap(cursor_x_, cursor_y_, vcursor_);
|
||||
|
||||
if (show_hcursor_)
|
||||
q.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
|
||||
}
|
||||
|
||||
|
||||
@ -553,6 +560,92 @@ void QWorkArea::drawScreen(int x, int y, QPixmap pixmap)
|
||||
viewport()->update(x, y, pixmap.width(), pixmap.height());
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
// LyXSreen overloaded methods:
|
||||
|
||||
WorkArea & QWorkArea::workarea()
|
||||
{
|
||||
// return static_cast<QWorkArea &> (*this);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
void QWorkArea::expose(int x, int y, int w, int h)
|
||||
{
|
||||
// lyxerr[Debug::GUI] << "expose " << w << 'x' << h
|
||||
// << '+' << x << '+' << y << std::endl;
|
||||
|
||||
update(x, y, w, h);
|
||||
}
|
||||
|
||||
|
||||
void QWorkArea::showCursor(int x, int y, int h, Cursor_Shape shape)
|
||||
{
|
||||
if (!qApp->focusWidget())
|
||||
return;
|
||||
|
||||
show_vcursor_ = true;
|
||||
|
||||
QColor const & required_color = lcolorcache.get(LColor::cursor);
|
||||
|
||||
if (x==cursor_x_ && y==cursor_y_ && h==cursor_h_
|
||||
&& cursor_color_ == required_color
|
||||
&& cursor_shape_ == shape) {
|
||||
show_hcursor_ = lshape_cursor_;
|
||||
viewport()->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache the dimensions of the cursor.
|
||||
cursor_x_ = x;
|
||||
cursor_y_ = y;
|
||||
cursor_h_ = h;
|
||||
cursor_color_ = required_color;
|
||||
cursor_shape_ = shape;
|
||||
|
||||
switch (cursor_shape_) {
|
||||
case BAR_SHAPE:
|
||||
// FIXME the cursor width shouldn't be hard-coded!
|
||||
cursor_w_ = 2;
|
||||
lshape_cursor_ = false;
|
||||
break;
|
||||
case L_SHAPE:
|
||||
cursor_w_ = cursor_h_ / 3;
|
||||
lshape_cursor_ = true;
|
||||
break;
|
||||
case REVERSED_L_SHAPE:
|
||||
cursor_w_ = cursor_h_ / 3;
|
||||
cursor_x_ -= cursor_w_ - 1;
|
||||
lshape_cursor_ = true;
|
||||
break;
|
||||
}
|
||||
|
||||
// We cache two pixmaps:
|
||||
// 1 the vertical line of the cursor.
|
||||
// 2 the horizontal line of the L-shaped cursor (if necessary).
|
||||
|
||||
// Draw the new (vertical) cursor.
|
||||
vcursor_ = QPixmap(cursor_w_, cursor_h_);
|
||||
vcursor_.fill(cursor_color_);
|
||||
|
||||
// Draw the new (horizontal) cursor if necessary.
|
||||
if (lshape_cursor_) {
|
||||
hcursor_ = QPixmap(cursor_w_, 1);
|
||||
hcursor_.fill(cursor_color_);
|
||||
show_hcursor_ = true;
|
||||
}
|
||||
|
||||
viewport()->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
|
||||
}
|
||||
|
||||
|
||||
void QWorkArea::removeCursor()
|
||||
{
|
||||
show_vcursor_ = false;
|
||||
show_hcursor_ = false;
|
||||
|
||||
viewport()->update(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////
|
||||
|
@ -25,6 +25,7 @@
|
||||
#include "WorkArea.h"
|
||||
#include "QLPainter.h"
|
||||
#include "LyXView.h"
|
||||
#include "screen.h"
|
||||
|
||||
#include "funcrequest.h"
|
||||
#include "frontends/Timeout.h"
|
||||
@ -95,7 +96,7 @@ public:
|
||||
* Qt-specific implementation of the work area
|
||||
* (buffer view GUI)
|
||||
*/
|
||||
class QWorkArea : public QAbstractScrollArea, public WorkArea {
|
||||
class QWorkArea : public QAbstractScrollArea, public WorkArea, public LyXScreen {
|
||||
|
||||
Q_OBJECT
|
||||
|
||||
@ -145,10 +146,22 @@ public:
|
||||
*/
|
||||
void drawScreen(int x, int y, QPixmap pixmap);
|
||||
|
||||
LyXView & view()
|
||||
{
|
||||
return view_;
|
||||
}
|
||||
LyXView & view() { return view_; }
|
||||
|
||||
// LyXScreen overloaded methods:
|
||||
|
||||
/// get the work area
|
||||
virtual WorkArea & workarea();
|
||||
|
||||
/// copies specified area of pixmap to screen
|
||||
virtual void expose(int x, int y, int exp_width, int exp_height);
|
||||
|
||||
/// paint the cursor and store the background
|
||||
virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
|
||||
|
||||
/// hide the cursor
|
||||
virtual void removeCursor();
|
||||
|
||||
protected:
|
||||
|
||||
/// repaint part of the widget
|
||||
@ -221,6 +234,29 @@ private:
|
||||
std::queue<boost::shared_ptr<QKeyEvent> > keyeventQueue_;
|
||||
|
||||
double_click dc_event_;
|
||||
|
||||
///
|
||||
int cursor_x_;
|
||||
///
|
||||
int cursor_y_;
|
||||
///
|
||||
int cursor_w_;
|
||||
///
|
||||
int cursor_h_;
|
||||
///
|
||||
QPixmap hcursor_;
|
||||
///
|
||||
QPixmap vcursor_;
|
||||
///
|
||||
bool show_hcursor_;
|
||||
///
|
||||
bool show_vcursor_;
|
||||
///
|
||||
bool lshape_cursor_;
|
||||
///
|
||||
QColor cursor_color_;
|
||||
///
|
||||
Cursor_Shape cursor_shape_;
|
||||
};
|
||||
|
||||
#endif // QWORKAREA_H
|
||||
|
@ -1,136 +0,0 @@
|
||||
/**
|
||||
* \file qscreen.C
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
* \author Abdelrazak Younes
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "QWorkArea.h"
|
||||
#include "qscreen.h"
|
||||
|
||||
#include <QColor>
|
||||
#include <QPainter>
|
||||
#include <QApplication>
|
||||
|
||||
#include "debug.h"
|
||||
#include "lcolorcache.h"
|
||||
|
||||
|
||||
namespace {
|
||||
|
||||
} // namespace anon
|
||||
|
||||
|
||||
QScreen::QScreen(QWorkArea & o)
|
||||
: LyXScreen(), owner_(o), nocursor_(0,0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
QScreen::~QScreen()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
WorkArea & QScreen::workarea() const
|
||||
{
|
||||
return owner_;
|
||||
}
|
||||
|
||||
void QScreen::expose(int x, int y, int w, int h)
|
||||
{
|
||||
lyxerr[Debug::GUI] << "expose " << w << 'x' << h
|
||||
<< '+' << x << '+' << y << std::endl;
|
||||
|
||||
owner_.update(x, y, w, h);
|
||||
}
|
||||
|
||||
void QScreen::showCursor(int x, int y, int h, Cursor_Shape shape)
|
||||
{
|
||||
if (!qApp->focusWidget())
|
||||
return;
|
||||
|
||||
if (x==cursor_x_ && y==cursor_y_ && h==cursor_h_) {
|
||||
// Draw the new (vertical) cursor using the cached store.
|
||||
owner_.drawScreen(cursor_x_, cursor_y_, vcursor_);
|
||||
return;
|
||||
}
|
||||
|
||||
// Cache the dimensions of the cursor.
|
||||
cursor_x_ = x;
|
||||
cursor_y_ = y;
|
||||
cursor_h_ = h;
|
||||
|
||||
switch (shape) {
|
||||
case BAR_SHAPE:
|
||||
cursor_w_ = 2;
|
||||
break;
|
||||
case L_SHAPE:
|
||||
cursor_w_ = cursor_h_ / 3;
|
||||
break;
|
||||
case REVERSED_L_SHAPE:
|
||||
cursor_w_ = cursor_h_ / 3;
|
||||
cursor_x_ = x - cursor_w_ + 1;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// We cache three pixmaps:
|
||||
// 1 the rectangle of the original screen.
|
||||
// 2 the vertical line of the cursor.
|
||||
// 3 the horizontal line of the L-shaped cursor (if necessary).
|
||||
|
||||
QColor const & required_color = lcolorcache.get(LColor::cursor);
|
||||
bool const cursor_color_changed = required_color != cursor_color_;
|
||||
if (cursor_color_changed)
|
||||
cursor_color_ = required_color;
|
||||
|
||||
vcursor_ = QPixmap(cursor_w_, cursor_h_);
|
||||
vcursor_ .fill(cursor_color_);
|
||||
|
||||
switch (shape) {
|
||||
case BAR_SHAPE:
|
||||
break;
|
||||
case REVERSED_L_SHAPE:
|
||||
case L_SHAPE:
|
||||
if (cursor_w_ != hcursor_.width() ||
|
||||
cursor_color_changed) {
|
||||
if (cursor_w_ != hcursor_.width())
|
||||
hcursor_ = QPixmap(cursor_w_, 1);
|
||||
hcursor_.fill(cursor_color_);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Save the old area (no cursor).
|
||||
nocursor_ = owner_.copyScreen(cursor_x_, cursor_y_, cursor_w_, cursor_h_);
|
||||
|
||||
// Draw the new (vertical) cursor using the cached store.
|
||||
owner_.drawScreen(cursor_x_, cursor_y_, vcursor_);
|
||||
|
||||
// Draw the new (horizontal) cursor if necessary.
|
||||
switch (shape) {
|
||||
case BAR_SHAPE:
|
||||
break;
|
||||
case REVERSED_L_SHAPE:
|
||||
case L_SHAPE:
|
||||
owner_.drawScreen(cursor_x_, y + h - 1, hcursor_);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void QScreen::removeCursor()
|
||||
{
|
||||
// before first showCursor
|
||||
if (nocursor_.isNull())
|
||||
return;
|
||||
|
||||
owner_.drawScreen(cursor_x_, cursor_y_, nocursor_);
|
||||
}
|
@ -1,66 +0,0 @@
|
||||
// -*- C++ -*-
|
||||
/**
|
||||
* \file qscreen.h
|
||||
* This file is part of LyX, the document processor.
|
||||
* Licence details can be found in the file COPYING.
|
||||
*
|
||||
* \author John Levon
|
||||
*
|
||||
* Full author contact details are available in file CREDITS.
|
||||
*/
|
||||
|
||||
#ifndef QSCREEN_H
|
||||
#define QSCREEN_H
|
||||
|
||||
|
||||
#include "screen.h"
|
||||
|
||||
#include <QPixmap>
|
||||
|
||||
class QColor;
|
||||
|
||||
class QWorkArea;
|
||||
class WorkArea;
|
||||
|
||||
|
||||
/**
|
||||
* Qt implementation of toolkit-specific parts of LyXScreen.
|
||||
*/
|
||||
class QScreen : public LyXScreen {
|
||||
public:
|
||||
QScreen(QWorkArea &);
|
||||
|
||||
virtual ~QScreen();
|
||||
|
||||
protected:
|
||||
/// get the work area
|
||||
virtual WorkArea & workarea() const;
|
||||
|
||||
/// copies specified area of pixmap to screen
|
||||
virtual void expose(int x, int y, int exp_width, int exp_height);
|
||||
|
||||
/// paint the cursor and store the background
|
||||
virtual void showCursor(int x, int y, int h, Cursor_Shape shape);
|
||||
|
||||
/// hide the cursor
|
||||
virtual void removeCursor();
|
||||
|
||||
private:
|
||||
/// our owning widget
|
||||
QWorkArea & owner_;
|
||||
|
||||
QPixmap nocursor_;
|
||||
QPixmap hcursor_;
|
||||
QPixmap vcursor_;
|
||||
|
||||
//@{ the cursor pixmap position/size
|
||||
int cursor_x_;
|
||||
int cursor_y_;
|
||||
int cursor_w_;
|
||||
int cursor_h_;
|
||||
//@}
|
||||
|
||||
QColor cursor_color_;
|
||||
};
|
||||
|
||||
#endif // QSCREEN_H
|
@ -63,7 +63,7 @@ protected:
|
||||
virtual void expose(int x, int y, int w, int h) = 0;
|
||||
|
||||
/// get the work area
|
||||
virtual WorkArea & workarea() const = 0;
|
||||
virtual WorkArea & workarea() = 0;
|
||||
|
||||
/// types of cursor in work area
|
||||
enum Cursor_Shape {
|
||||
|
@ -59,7 +59,7 @@ XScreen::~XScreen()
|
||||
}
|
||||
|
||||
|
||||
WorkArea & XScreen::workarea() const
|
||||
WorkArea & XScreen::workarea()
|
||||
{
|
||||
return owner_;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public:
|
||||
|
||||
protected:
|
||||
/// get the work area
|
||||
virtual WorkArea & workarea() const;
|
||||
virtual WorkArea & workarea();
|
||||
|
||||
/// Copies specified area of pixmap to screen
|
||||
virtual void expose(int x, int y, int w, int h);
|
||||
|
Loading…
Reference in New Issue
Block a user