1
/***************************************************************************
2
File : QTeXPaintDevice.cpp
3
Project : QTeXEngine GNU GPL v. 3.0
4
--------------------------------------------------------------------
5
Copyright : (C) 2009 by Ion Vasilief
6
Email (use @ for *) : ion_vasilief*yahoo.fr
7
Description : Enables the export of QPainter grafics to .tex files
8
***************************************************************************/
10
/***************************************************************************
12
* This program is free software; you can redistribute it and/or modify *
13
* it under the terms of the GNU General Public License as published by *
14
* the Free Software Foundation; either version 3 of the License, or *
15
* (at your option) any later version. *
17
* This program is distributed in the hope that it will be useful, *
18
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
19
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
20
* GNU General Public License for more details. *
22
* You should have received a copy of the GNU General Public License *
23
* along with this program; if not, write to the Free Software *
24
* Foundation, Inc., 51 Franklin Street, Fifth Floor, *
25
* Boston, MA 02110-1301 USA *
27
***************************************************************************/
29
#include "QTeXEngine.h"
31
#include <QApplication>
32
#include <QDesktopWidget>
34
QTeXPaintDevice::QTeXPaintDevice(const QString& fileName, const QSize& s, Unit u)
39
if (!d_size.isValid())
40
d_size = QSize(500, 400);
42
engine = new QTeXPaintEngine(fileName, u);
45
QTeXPaintDevice::~QTeXPaintDevice()
50
QPaintEngine * QTeXPaintDevice::paintEngine () const
55
void QTeXPaintDevice::setColorMode(QPrinter::ColorMode mode)
57
engine->setGrayScale(mode == QPrinter::GrayScale);
60
void QTeXPaintDevice::setOutputMode(OutputMode mode)
62
engine->setOutputMode(mode);
65
void QTeXPaintDevice::setUnit(Unit u)
70
void QTeXPaintDevice::setDocumentMode(bool on)
72
engine->setDocumentMode(on);
75
void QTeXPaintDevice::setEscapeTextMode(bool on)
77
engine->setEscapeTextMode(on);
80
void QTeXPaintDevice::exportFontSizes(bool on)
82
engine->exportFontSizes(on);
85
void QTeXPaintDevice::setTextHorizontalAlignment(Qt::Alignment alignment)
87
engine->setTextHorizontalAlignment(alignment);
90
int QTeXPaintDevice::metric ( PaintDeviceMetric metric ) const
92
QDesktopWidget *desktop = QApplication::desktop();
93
int dpi_x = desktop->logicalDpiX();
94
int dpi_y = desktop->logicalDpiY();
96
case QPaintDevice::PdmWidth:
97
return d_size.width();
98
case QPaintDevice::PdmHeight:
99
return d_size.height();
100
case QPaintDevice::PdmWidthMM:
101
return int(25.4*d_size.width()/(double)dpi_x);
102
case QPaintDevice::PdmHeightMM:
103
return int(25.4*d_size.height()/(double)dpi_y);
104
case QPaintDevice::PdmNumColors:
105
return 65536;//should it be millions?
106
case QPaintDevice::PdmDepth:
108
case QPaintDevice::PdmDpiX:
109
case QPaintDevice::PdmPhysicalDpiX:
111
case QPaintDevice::PdmDpiY:
112
case QPaintDevice::PdmPhysicalDpiY:
115
qWarning ("QTeXPaintDevice::Unknown metric asked");