mirror of
https://git.lyx.org/repos/lyx.git
synced 2024-11-26 11:16:55 +00:00
do not draw to intermediate pixmap
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@15501 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
55c10ff2b5
commit
1852693005
@ -116,9 +116,10 @@ int GuiFontMetrics::smallcapsWidth(QString const & s) const
|
|||||||
int GuiFontMetrics::width(char_type const * s, size_t ls) const
|
int GuiFontMetrics::width(char_type const * s, size_t ls) const
|
||||||
{
|
{
|
||||||
if (ls == 1 && !smallcaps_shape_) {
|
if (ls == 1 && !smallcaps_shape_) {
|
||||||
QChar c = ucs4_to_qchar(s[0]);
|
QChar const c = ucs4_to_qchar(s[0]);
|
||||||
return width(c.unicode());
|
return width(c.unicode());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ucs2;
|
QString ucs2;
|
||||||
ucs4_to_qstring(s, ls, ucs2);
|
ucs4_to_qstring(s, ls, ucs2);
|
||||||
|
|
||||||
|
@ -21,12 +21,19 @@
|
|||||||
#include "LyXView.h"
|
#include "LyXView.h"
|
||||||
|
|
||||||
#include "BufferView.h"
|
#include "BufferView.h"
|
||||||
|
#include "rowpainter.h"
|
||||||
#include "debug.h"
|
#include "debug.h"
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "LColor.h"
|
#include "LColor.h"
|
||||||
|
#include "version.h"
|
||||||
|
#include "lyxrc.h"
|
||||||
|
|
||||||
|
#include "support/filetools.h" // LibFileSearch
|
||||||
#include "support/os.h"
|
#include "support/os.h"
|
||||||
|
|
||||||
|
#include "graphics/GraphicsImage.h"
|
||||||
|
#include "graphics/GraphicsLoader.h"
|
||||||
|
|
||||||
#include <QLayout>
|
#include <QLayout>
|
||||||
#include <QMainWindow>
|
#include <QMainWindow>
|
||||||
#include <QMimeData>
|
#include <QMimeData>
|
||||||
@ -53,6 +60,15 @@ using std::string;
|
|||||||
|
|
||||||
namespace os = lyx::support::os;
|
namespace os = lyx::support::os;
|
||||||
|
|
||||||
|
|
||||||
|
volatile int NN;
|
||||||
|
|
||||||
|
void recCalled()
|
||||||
|
{
|
||||||
|
++NN;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
/// return the LyX key state from Qt's
|
/// return the LyX key state from Qt's
|
||||||
@ -115,17 +131,15 @@ SyntheticMouseEvent::SyntheticMouseEvent()
|
|||||||
|
|
||||||
|
|
||||||
GuiWorkArea::GuiWorkArea(int w, int h, LyXView & lyx_view)
|
GuiWorkArea::GuiWorkArea(int w, int h, LyXView & lyx_view)
|
||||||
: WorkArea(lyx_view), painter_(this)
|
: WorkArea(lyx_view)
|
||||||
{
|
{
|
||||||
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
|
||||||
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
|
||||||
|
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
setMinimumSize(100, 70);
|
setMinimumSize(100, 70);
|
||||||
|
|
||||||
viewport()->setAutoFillBackground(false);
|
//viewport()->setAutoFillBackground(false);
|
||||||
viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
|
//viewport()->setAttribute(Qt::WA_OpaquePaintEvent);
|
||||||
setFocusPolicy(Qt::WheelFocus);
|
setFocusPolicy(Qt::WheelFocus);
|
||||||
|
|
||||||
viewport()->setCursor(Qt::IBeamCursor);
|
viewport()->setCursor(Qt::IBeamCursor);
|
||||||
@ -410,10 +424,11 @@ void GuiWorkArea::mouseDoubleClickEvent(QMouseEvent * e)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiWorkArea::resizeEvent(QResizeEvent *)
|
void GuiWorkArea::resizeEvent(QResizeEvent * ev)
|
||||||
{
|
{
|
||||||
verticalScrollBar()->setPageStep(viewport()->height());
|
verticalScrollBar()->setPageStep(viewport()->height());
|
||||||
paint_device_ = QPixmap(viewport()->width(), viewport()->height());
|
//paint_device_ = QPixmap(viewport()->width(), viewport()->height());
|
||||||
|
QAbstractScrollArea::resizeEvent(ev);
|
||||||
resizeBufferView();
|
resizeBufferView();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,12 +439,93 @@ void GuiWorkArea::update(int x, int y, int w, int h)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void GuiWorkArea::paintEvent(QPaintEvent * e)
|
void GuiWorkArea::doGreyOut(QLPainter & pain)
|
||||||
{
|
{
|
||||||
lyxerr << "paintEvent begin: x: " << e->rect().x()
|
greyed_out_ = true;
|
||||||
<< " y: " << e->rect().y()
|
pain.fillRectangle(0, 0, width(), height(),
|
||||||
<< " w: " << e->rect().width()
|
LColor::bottomarea);
|
||||||
<< " h: " << e->rect().height() << endl;
|
|
||||||
|
//if (!lyxrc.show_banner)
|
||||||
|
// return;
|
||||||
|
lyxerr << "show banner: " << lyxrc.show_banner << endl;
|
||||||
|
/// The text to be written on top of the pixmap
|
||||||
|
string const text = lyx_version ? lyx_version : "unknown";
|
||||||
|
string const file = support::libFileSearch("images", "banner", "ppm");
|
||||||
|
if (file.empty())
|
||||||
|
return;
|
||||||
|
|
||||||
|
QPixmap pm(toqstr(file));
|
||||||
|
if (!pm) {
|
||||||
|
lyxerr << "could not load splash screen: '" << file << "'" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QFont font;
|
||||||
|
// The font used to display the version info
|
||||||
|
font.setStyleHint(QFont::SansSerif);
|
||||||
|
font.setWeight(QFont::Bold);
|
||||||
|
font.setPointSize(LyXFont::SIZE_NORMAL);
|
||||||
|
|
||||||
|
int const w = pm.width();
|
||||||
|
int const h = pm.height();
|
||||||
|
|
||||||
|
int x = (width() - w) / 2;
|
||||||
|
int y = (height() - h) / 2;
|
||||||
|
|
||||||
|
pain.drawPixmap(x, y, pm);
|
||||||
|
|
||||||
|
x += 260;
|
||||||
|
y += 265;
|
||||||
|
|
||||||
|
pain.setPen(QColor(255, 255, 0));
|
||||||
|
pain.setFont(font);
|
||||||
|
pain.drawText(x, y, toqstr(text));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void GuiWorkArea::paintEvent(QPaintEvent * ev)
|
||||||
|
{
|
||||||
|
//setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
|
||||||
|
QRect const rc = ev->rect();
|
||||||
|
lyxerr << "paintEvent begin: x: " << rc.x()
|
||||||
|
<< " y: " << rc.y()
|
||||||
|
<< " w: " << rc.width()
|
||||||
|
<< " h: " << rc.height() << endl;
|
||||||
|
|
||||||
|
if (!buffer_view_) {
|
||||||
|
lyxerr << "no bufferview" << endl;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
QLPainter pain(viewport());
|
||||||
|
|
||||||
|
if (rc.width() == 3) { // FIXME HACK
|
||||||
|
// Assume splash screen drawing is requested when
|
||||||
|
// widht == 3
|
||||||
|
doGreyOut(pain);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!buffer_view_->buffer()) {
|
||||||
|
lyxerr << "no buffer: " << endl;
|
||||||
|
doGreyOut(pain);
|
||||||
|
updateScrollbar();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (rc.width() != 2) { // FIXME HACK
|
||||||
|
// Assumes cursor drawing is requested when the
|
||||||
|
// width is 2
|
||||||
|
lyxerr << "Real drawing requested" << endl;
|
||||||
|
ViewMetricsInfo const & vi = buffer_view_->viewMetricsInfo();
|
||||||
|
paintText(*buffer_view_, vi, pain);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
//
|
||||||
|
lyxerr << "only cursor drawing requested" << endl;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
lyxerr[Debug::GUI] << BOOST_CURRENT_FUNCTION
|
||||||
<< "\n QWidget width\t" << this->width()
|
<< "\n QWidget width\t" << this->width()
|
||||||
@ -445,15 +541,13 @@ void GuiWorkArea::paintEvent(QPaintEvent * e)
|
|||||||
<< endl;
|
<< endl;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QPainter q(viewport());
|
//pain.drawPixmap(e->rect(), paint_device_, e->rect());
|
||||||
q.drawPixmap(e->rect(), paint_device_, e->rect());
|
|
||||||
|
|
||||||
if (show_vcursor_)
|
if (show_vcursor_)
|
||||||
q.drawPixmap(cursor_x_, cursor_y_, vcursor_);
|
pain.drawPixmap(cursor_x_, cursor_y_, vcursor_);
|
||||||
|
|
||||||
if (show_hcursor_)
|
if (show_hcursor_)
|
||||||
q.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
|
pain.drawPixmap(cursor_x_, cursor_y_ + cursor_h_ - 1, hcursor_);
|
||||||
|
|
||||||
lyxerr << "paintEvent end" << endl;
|
lyxerr << "paintEvent end" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -550,8 +644,7 @@ void GuiWorkArea::inputMethodEvent(QInputMethodEvent * e)
|
|||||||
key = Qt::Key_AsciiCircum;
|
key = Qt::Key_AsciiCircum;
|
||||||
// FIXME: Needs for investigation, this key is not really used,
|
// FIXME: Needs for investigation, this key is not really used,
|
||||||
// the ctor below just check if key is different from 0.
|
// the ctor below just check if key is different from 0.
|
||||||
QKeyEvent ev(QEvent::KeyPress, key,
|
QKeyEvent ev(QEvent::KeyPress, key, Qt::NoModifier, text);
|
||||||
Qt::NoModifier, text);
|
|
||||||
keyPressEvent(&ev);
|
keyPressEvent(&ev);
|
||||||
}
|
}
|
||||||
e->accept();
|
e->accept();
|
||||||
|
@ -15,8 +15,6 @@
|
|||||||
|
|
||||||
#include "frontends/WorkArea.h"
|
#include "frontends/WorkArea.h"
|
||||||
|
|
||||||
#include "QLPainter.h"
|
|
||||||
|
|
||||||
#include "funcrequest.h"
|
#include "funcrequest.h"
|
||||||
#include "frontends/Timeout.h"
|
#include "frontends/Timeout.h"
|
||||||
|
|
||||||
@ -36,12 +34,10 @@ class QWheelEvent;
|
|||||||
class QPaintEvent;
|
class QPaintEvent;
|
||||||
|
|
||||||
namespace lyx {
|
namespace lyx {
|
||||||
|
|
||||||
class Painter;
|
|
||||||
|
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
class GuiView;
|
class GuiView;
|
||||||
|
class QLPainter;
|
||||||
|
|
||||||
/// for emulating triple click
|
/// for emulating triple click
|
||||||
class double_click {
|
class double_click {
|
||||||
@ -89,7 +85,7 @@ public:
|
|||||||
* Qt-specific implementation of the work area
|
* Qt-specific implementation of the work area
|
||||||
* (buffer view GUI)
|
* (buffer view GUI)
|
||||||
*/
|
*/
|
||||||
class GuiWorkArea: public QAbstractScrollArea, public WorkArea
|
class GuiWorkArea : public QAbstractScrollArea, public WorkArea
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
@ -104,18 +100,6 @@ public:
|
|||||||
///
|
///
|
||||||
virtual void setScrollbarParams(int height, int pos, int line_height);
|
virtual void setScrollbarParams(int height, int pos, int line_height);
|
||||||
|
|
||||||
///
|
|
||||||
virtual void dragEnterEvent(QDragEnterEvent * event);
|
|
||||||
|
|
||||||
///
|
|
||||||
virtual void dropEvent(QDropEvent* event);
|
|
||||||
|
|
||||||
/// return the widget's painter
|
|
||||||
virtual Painter & getPainter() { return (Painter &) painter_; }
|
|
||||||
|
|
||||||
/// return the backing pixmap
|
|
||||||
QPaintDevice * paintDevice() { return &paint_device_; }
|
|
||||||
|
|
||||||
/// update the passed area.
|
/// update the passed area.
|
||||||
void update(int x, int y, int w, int h);
|
void update(int x, int y, int w, int h);
|
||||||
|
|
||||||
@ -128,8 +112,12 @@ public:
|
|||||||
/// hide the cursor
|
/// hide the cursor
|
||||||
virtual void removeCursor();
|
virtual void removeCursor();
|
||||||
|
|
||||||
protected:
|
private:
|
||||||
|
void doGreyOut(QLPainter & pain);
|
||||||
|
///
|
||||||
|
void dragEnterEvent(QDragEnterEvent * event);
|
||||||
|
///
|
||||||
|
void dropEvent(QDropEvent* event);
|
||||||
/// repaint part of the widget
|
/// repaint part of the widget
|
||||||
void paintEvent(QPaintEvent * e);
|
void paintEvent(QPaintEvent * e);
|
||||||
/// widget has been resized
|
/// widget has been resized
|
||||||
@ -164,10 +152,6 @@ public Q_SLOTS:
|
|||||||
void adjustViewWithScrollBar(int action = 0);
|
void adjustViewWithScrollBar(int action = 0);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
/// Our painter.
|
|
||||||
QLPainter painter_;
|
|
||||||
|
|
||||||
/// The slot connected to SyntheticMouseEvent::timeout.
|
/// The slot connected to SyntheticMouseEvent::timeout.
|
||||||
void generateSyntheticMouseEvent();
|
void generateSyntheticMouseEvent();
|
||||||
|
|
||||||
@ -175,7 +159,7 @@ private:
|
|||||||
SyntheticMouseEvent synthetic_mouse_event_;
|
SyntheticMouseEvent synthetic_mouse_event_;
|
||||||
|
|
||||||
/// Our client side painting device.
|
/// Our client side painting device.
|
||||||
QPixmap paint_device_;
|
//QPixmap paint_device_;
|
||||||
|
|
||||||
/// \todo remove
|
/// \todo remove
|
||||||
QTimer step_timer_;
|
QTimer step_timer_;
|
||||||
|
@ -33,8 +33,6 @@
|
|||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
|
|
||||||
using lyx::char_type;
|
|
||||||
using lyx::docstring;
|
|
||||||
|
|
||||||
using std::endl;
|
using std::endl;
|
||||||
using std::string;
|
using std::string;
|
||||||
@ -42,22 +40,12 @@ using std::string;
|
|||||||
namespace lyx {
|
namespace lyx {
|
||||||
namespace frontend {
|
namespace frontend {
|
||||||
|
|
||||||
QLPainter::~QLPainter()
|
QLPainter::QLPainter(QWidget * qwa)
|
||||||
|
: qwa_(qwa)
|
||||||
{
|
{
|
||||||
}
|
//lyxerr << "QLPainter::start()" << endl;
|
||||||
|
QPainter::begin(qwa_);
|
||||||
|
setRenderHint(QPainter::TextAntialiasing);
|
||||||
QLPainter::QLPainter(GuiWorkArea * qwa)
|
|
||||||
: Painter(), qwa_(qwa)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::start()
|
|
||||||
{
|
|
||||||
lyxerr << "QLPainter::start()" << endl;
|
|
||||||
qp_.reset(new QPainter(qwa_->paintDevice()));
|
|
||||||
qp_->setRenderHint(QPainter::TextAntialiasing);
|
|
||||||
// new QPainter has default QPen:
|
// new QPainter has default QPen:
|
||||||
current_color_ = LColor::black;
|
current_color_ = LColor::black;
|
||||||
current_ls_ = line_solid;
|
current_ls_ = line_solid;
|
||||||
@ -65,24 +53,25 @@ void QLPainter::start()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::end()
|
QLPainter::~QLPainter()
|
||||||
{
|
{
|
||||||
qp_->end();
|
QPainter::end();
|
||||||
lyxerr << "QLPainter::end()" << endl;
|
//lyxerr << "QLPainter::end()" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int QLPainter::paperWidth() const
|
int QLPainter::paperWidth() const
|
||||||
{
|
{
|
||||||
return qwa_->viewport()->width();
|
return qwa_->width();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int QLPainter::paperHeight() const
|
int QLPainter::paperHeight() const
|
||||||
{
|
{
|
||||||
return qwa_->viewport()->height();
|
return qwa_->height();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::setQPainterPen(LColor_color col,
|
void QLPainter::setQPainterPen(LColor_color col,
|
||||||
Painter::line_style ls, Painter::line_width lw)
|
Painter::line_style ls, Painter::line_width lw)
|
||||||
{
|
{
|
||||||
@ -93,7 +82,7 @@ void QLPainter::setQPainterPen(LColor_color col,
|
|||||||
current_ls_ = ls;
|
current_ls_ = ls;
|
||||||
current_lw_ = lw;
|
current_lw_ = lw;
|
||||||
|
|
||||||
QPen pen = qp_.get()->pen();
|
QPen pen = QPainter::pen();
|
||||||
|
|
||||||
pen.setColor(guiApp->colorCache().get(col));
|
pen.setColor(guiApp->colorCache().get(col));
|
||||||
|
|
||||||
@ -107,14 +96,14 @@ void QLPainter::setQPainterPen(LColor_color col,
|
|||||||
case line_thick: pen.setWidth(3); break;
|
case line_thick: pen.setWidth(3); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
qp_.get()->setPen(pen);
|
setPen(pen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::point(int x, int y, LColor_color col)
|
void QLPainter::point(int x, int y, LColor_color col)
|
||||||
{
|
{
|
||||||
setQPainterPen(col);
|
setQPainterPen(col);
|
||||||
qp_->drawPoint(x, y);
|
drawPoint(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -124,7 +113,7 @@ void QLPainter::line(int x1, int y1, int x2, int y2,
|
|||||||
line_width lw)
|
line_width lw)
|
||||||
{
|
{
|
||||||
setQPainterPen(col, ls, lw);
|
setQPainterPen(col, ls, lw);
|
||||||
qp_->drawLine(x1, y1, x2, y2);
|
drawLine(x1, y1, x2, y2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -144,7 +133,7 @@ void QLPainter::lines(int const * xp, int const * yp, int np,
|
|||||||
}
|
}
|
||||||
|
|
||||||
setQPainterPen(col, ls, lw);
|
setQPainterPen(col, ls, lw);
|
||||||
qp_->drawPolyline(points.get(), np);
|
drawPolyline(points.get(), np);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -154,13 +143,13 @@ void QLPainter::rectangle(int x, int y, int w, int h,
|
|||||||
line_width lw)
|
line_width lw)
|
||||||
{
|
{
|
||||||
setQPainterPen(col, ls, lw);
|
setQPainterPen(col, ls, lw);
|
||||||
qp_->drawRect(x, y, w, h);
|
drawRect(x, y, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::fillRectangle(int x, int y, int w, int h, LColor_color col)
|
void QLPainter::fillRectangle(int x, int y, int w, int h, LColor_color col)
|
||||||
{
|
{
|
||||||
qp_->fillRect(x, y, w, h, guiApp->colorCache().get(col));
|
fillRect(x, y, w, h, guiApp->colorCache().get(col));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -169,25 +158,24 @@ void QLPainter::arc(int x, int y, unsigned int w, unsigned int h,
|
|||||||
{
|
{
|
||||||
// LyX usings 1/64ths degree, Qt usings 1/16th
|
// LyX usings 1/64ths degree, Qt usings 1/16th
|
||||||
setQPainterPen(col);
|
setQPainterPen(col);
|
||||||
qp_->drawArc(x, y, w, h, a1 / 4, a2 / 4);
|
drawArc(x, y, w, h, a1 / 4, a2 / 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::image(int x, int y, int w, int h,
|
void QLPainter::image(int x, int y, int w, int h, graphics::Image const & i)
|
||||||
lyx::graphics::Image const & i)
|
|
||||||
{
|
{
|
||||||
lyx::graphics::QLImage const & qlimage =
|
graphics::QLImage const & qlimage =
|
||||||
static_cast<lyx::graphics::QLImage const &>(i);
|
static_cast<graphics::QLImage const &>(i);
|
||||||
|
|
||||||
fillRectangle(x, y, w, h, LColor::graphicsbg);
|
fillRectangle(x, y, w, h, LColor::graphicsbg);
|
||||||
|
|
||||||
qp_->drawImage(x, y, qlimage.qimage(), 0, 0, w, h);
|
drawImage(x, y, qlimage.qimage(), 0, 0, w, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int QLPainter::text(int x, int y, docstring const & s, LyXFont const & f)
|
int QLPainter::text(int x, int y, docstring const & s, LyXFont const & f)
|
||||||
{
|
{
|
||||||
return text(x, y, reinterpret_cast<char_type const *>(s.data()), s.length(), f);
|
return text(x, y, reinterpret_cast<char_type const *>(s.data()), s.length(), f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -209,16 +197,16 @@ int QLPainter::smallCapsText(int x, int y,
|
|||||||
|
|
||||||
setQPainterPen(f.realColor());
|
setQPainterPen(f.realColor());
|
||||||
int textwidth = 0;
|
int textwidth = 0;
|
||||||
size_t ls = s.length();
|
size_t const ls = s.length();
|
||||||
for (unsigned int i = 0; i < ls; ++i) {
|
for (unsigned int i = 0; i < ls; ++i) {
|
||||||
QChar const c = s[i].toUpper();
|
QChar const c = s[i].toUpper();
|
||||||
if (c != s.at(i)) {
|
if (c != s.at(i)) {
|
||||||
qp_->setFont(qsmallfont);
|
setFont(qsmallfont);
|
||||||
} else {
|
} else {
|
||||||
qp_->setFont(qfont);
|
setFont(qfont);
|
||||||
}
|
}
|
||||||
qp_->drawText(x + textwidth, y, c);
|
drawText(x + textwidth, y, c);
|
||||||
textwidth += qp_->fontMetrics().width(c);
|
textwidth += fontMetrics().width(c);
|
||||||
}
|
}
|
||||||
return textwidth;
|
return textwidth;
|
||||||
}
|
}
|
||||||
@ -249,13 +237,12 @@ int QLPainter::text(int x, int y, char_type const * s, size_t ls,
|
|||||||
|
|
||||||
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
|
if (f.realShape() != LyXFont::SMALLCAPS_SHAPE) {
|
||||||
setQPainterPen(f.realColor());
|
setQPainterPen(f.realColor());
|
||||||
if (qp_->font() != fi.font) {
|
if (font() != fi.font)
|
||||||
qp_->setFont(fi.font);
|
setFont(fi.font);
|
||||||
}
|
|
||||||
// We need to draw the text as LTR as we use our own bidi code.
|
// We need to draw the text as LTR as we use our own bidi code.
|
||||||
qp_->setLayoutDirection(Qt::LeftToRight);
|
setLayoutDirection(Qt::LeftToRight);
|
||||||
qp_->drawText(x, y, str);
|
drawText(x, y, str);
|
||||||
textwidth = qp_->fontMetrics().width(str);
|
textwidth = fontMetrics().width(str);
|
||||||
} else {
|
} else {
|
||||||
textwidth = smallCapsText(x, y, str, f);
|
textwidth = smallCapsText(x, y, str, f);
|
||||||
}
|
}
|
||||||
@ -268,16 +255,5 @@ int QLPainter::text(int x, int y, char_type const * s, size_t ls,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::drawPixmap(int x, int y, QPixmap const & pixmap)
|
|
||||||
{
|
|
||||||
qp_->drawPixmap(x, y, pixmap);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void QLPainter::drawImage(int x, int y, QImage const & image)
|
|
||||||
{
|
|
||||||
qp_->drawImage(x, y, image);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace frontend
|
} // namespace frontend
|
||||||
} // namespace lyx
|
} // namespace lyx
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
|
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
class QPaintDevice;
|
class QPaintDevice;
|
||||||
class QPainter;
|
class QPainter;
|
||||||
class QString;
|
class QString;
|
||||||
@ -34,18 +36,8 @@ class GuiWorkArea;
|
|||||||
/**
|
/**
|
||||||
* QLPainter - a painter implementation for Qt4
|
* QLPainter - a painter implementation for Qt4
|
||||||
*/
|
*/
|
||||||
class QLPainter : public Painter {
|
class QLPainter : public QPainter, public Painter {
|
||||||
public:
|
public:
|
||||||
QLPainter(GuiWorkArea *);
|
|
||||||
|
|
||||||
~QLPainter();
|
|
||||||
|
|
||||||
/// begin painting
|
|
||||||
virtual void start();
|
|
||||||
|
|
||||||
/// end painting
|
|
||||||
virtual void end();
|
|
||||||
|
|
||||||
/// return the width of the work area in pixels
|
/// return the width of the work area in pixels
|
||||||
virtual int paperWidth() const;
|
virtual int paperWidth() const;
|
||||||
/// return the height of the work area in pixels
|
/// return the height of the work area in pixels
|
||||||
@ -119,13 +111,11 @@ public:
|
|||||||
virtual int text(int x, int y,
|
virtual int text(int x, int y,
|
||||||
lyx::char_type c, LyXFont const & f);
|
lyx::char_type c, LyXFont const & f);
|
||||||
|
|
||||||
/// draw a pixmap from the image cache
|
|
||||||
virtual void drawPixmap(int x, int y, QPixmap const & pixmap);
|
|
||||||
|
|
||||||
/// draw a pixmap from the image cache
|
|
||||||
virtual void drawImage(int x, int y, QImage const & image);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
friend class GuiWorkArea;
|
||||||
|
QLPainter(QWidget *);
|
||||||
|
~QLPainter();
|
||||||
|
|
||||||
/// draw small caps text
|
/// draw small caps text
|
||||||
/**
|
/**
|
||||||
\return width of the drawn text.
|
\return width of the drawn text.
|
||||||
@ -138,11 +128,8 @@ private:
|
|||||||
line_style ls = line_solid,
|
line_style ls = line_solid,
|
||||||
line_width lw = line_thin);
|
line_width lw = line_thin);
|
||||||
|
|
||||||
/// our qt painter
|
|
||||||
boost::scoped_ptr<QPainter> qp_;
|
|
||||||
|
|
||||||
/// the working area
|
/// the working area
|
||||||
GuiWorkArea * qwa_;
|
QWidget * qwa_;
|
||||||
|
|
||||||
LColor::color current_color_;
|
LColor::color current_color_;
|
||||||
Painter::line_style current_ls_;
|
Painter::line_style current_ls_;
|
||||||
|
Loading…
Reference in New Issue
Block a user