In CellPrinter makes the cartouche dimension adapt to the DPI.
* Change: In Hurricane::CellPrinter::pageDecorate(), the size of the cartouche was computed for a DPI of 150. Now it is computed to expand as the DPI increase (scale from the 150 DPI values).
This commit is contained in:
parent
00ea8f0205
commit
210f307270
|
@ -162,12 +162,18 @@ namespace Hurricane {
|
||||||
|
|
||||||
void CellPrinter::pageDecorate ( QPainter& painter )
|
void CellPrinter::pageDecorate ( QPainter& painter )
|
||||||
{
|
{
|
||||||
|
_cartoucheWidth = _scalePixels( _cartoucheWidth , 600 );
|
||||||
|
_cartoucheHeight = _scalePixels( _cartoucheHeight, 600 );
|
||||||
|
_titleHeight = _scalePixels( _titleHeight , 600 );
|
||||||
|
|
||||||
int right = 0;
|
int right = 0;
|
||||||
int bottom = 0;
|
int bottom = 0;
|
||||||
int userFieldWidth = 150 * _mode;
|
int userFieldWidth = _scalePixels( 150 * _mode, 600 );
|
||||||
int dateFieldWidth = 180 * _mode;
|
int dateFieldWidth = _scalePixels( 180 * _mode, 600 );
|
||||||
int unitFieldWidth = 150 * _mode;
|
int unitFieldWidth = _scalePixels( 150 * _mode, 600 );
|
||||||
int areaFieldWidth = cartoucheWidth() - userFieldWidth - dateFieldWidth - unitFieldWidth;
|
int areaFieldWidth = cartoucheWidth() - userFieldWidth - dateFieldWidth - unitFieldWidth;
|
||||||
|
int thinWidth = _scalePixels( 1, 600 );
|
||||||
|
int thickWidth = _scalePixels( 2, 600 );
|
||||||
|
|
||||||
QFont font ( "Bitstream Vera Sans", 18 );
|
QFont font ( "Bitstream Vera Sans", 18 );
|
||||||
font.setWeight ( QFont::Bold );
|
font.setWeight ( QFont::Bold );
|
||||||
|
@ -208,14 +214,14 @@ namespace Hurricane {
|
||||||
titleRect.adjust( 0, 0, 0, titleHeight() - cartoucheHeight() );
|
titleRect.adjust( 0, 0, 0, titleHeight() - cartoucheHeight() );
|
||||||
|
|
||||||
// The cartouche box.
|
// The cartouche box.
|
||||||
cartouchePen.setWidth( 2 );
|
cartouchePen.setWidth( thickWidth );
|
||||||
painter.setPen ( cartouchePen );
|
painter.setPen ( cartouchePen );
|
||||||
painter.drawRect( cartoucheRect );
|
painter.drawRect( cartoucheRect );
|
||||||
|
|
||||||
// The title & horizontal separator.
|
// The title & horizontal separator.
|
||||||
string title = getString(_cellWidget->getCell()->getName());
|
string title = getString(_cellWidget->getCell()->getName());
|
||||||
|
|
||||||
cartouchePen.setWidth( 1 );
|
cartouchePen.setWidth( thinWidth );
|
||||||
painter.setPen ( cartouchePen );
|
painter.setPen ( cartouchePen );
|
||||||
painter.drawLine( titleRect.bottomLeft(), titleRect.bottomRight() );
|
painter.drawLine( titleRect.bottomLeft(), titleRect.bottomRight() );
|
||||||
painter.setFont ( font );
|
painter.setFont ( font );
|
||||||
|
@ -290,7 +296,7 @@ namespace Hurricane {
|
||||||
if (_cellWidget->getCell() == NULL) return;
|
if (_cellWidget->getCell() == NULL) return;
|
||||||
|
|
||||||
_printer = printer;
|
_printer = printer;
|
||||||
_printer->setResolution ( 150 );
|
_printer->setResolution ( 600 );
|
||||||
_printer->setPageMargins( 0.0, 0.0, 0.0, 0.0, QPrinter::DevicePixel );
|
_printer->setPageMargins( 0.0, 0.0, 0.0, 0.0, QPrinter::DevicePixel );
|
||||||
|
|
||||||
_paperWidth = _printer->width ();
|
_paperWidth = _printer->width ();
|
||||||
|
@ -352,6 +358,10 @@ namespace Hurricane {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int CellPrinter::_scalePixels ( int pixels, int dpi )
|
||||||
|
{ return (int)( (float)dpi/150.0 * (float)pixels ); }
|
||||||
|
|
||||||
|
|
||||||
string CellPrinter::_getString () const
|
string CellPrinter::_getString () const
|
||||||
{
|
{
|
||||||
ostringstream s;
|
ostringstream s;
|
||||||
|
|
|
@ -70,6 +70,8 @@ namespace Hurricane {
|
||||||
void pageDecorate ( QPainter& );
|
void pageDecorate ( QPainter& );
|
||||||
void toPdf ( QPrinter* , bool imageOnly=false );
|
void toPdf ( QPrinter* , bool imageOnly=false );
|
||||||
virtual std::string _getString () const;
|
virtual std::string _getString () const;
|
||||||
|
private:
|
||||||
|
int _scalePixels ( int pixels, int dpi );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CellWidget* _screenCellWidget;
|
CellWidget* _screenCellWidget;
|
||||||
|
|
Loading…
Reference in New Issue