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:
Jean-Paul Chaput 2017-03-15 16:05:30 +01:00
parent 00ea8f0205
commit 210f307270
2 changed files with 18 additions and 6 deletions

View File

@ -162,12 +162,18 @@ namespace Hurricane {
void CellPrinter::pageDecorate ( QPainter& painter )
{
_cartoucheWidth = _scalePixels( _cartoucheWidth , 600 );
_cartoucheHeight = _scalePixels( _cartoucheHeight, 600 );
_titleHeight = _scalePixels( _titleHeight , 600 );
int right = 0;
int bottom = 0;
int userFieldWidth = 150 * _mode;
int dateFieldWidth = 180 * _mode;
int unitFieldWidth = 150 * _mode;
int userFieldWidth = _scalePixels( 150 * _mode, 600 );
int dateFieldWidth = _scalePixels( 180 * _mode, 600 );
int unitFieldWidth = _scalePixels( 150 * _mode, 600 );
int areaFieldWidth = cartoucheWidth() - userFieldWidth - dateFieldWidth - unitFieldWidth;
int thinWidth = _scalePixels( 1, 600 );
int thickWidth = _scalePixels( 2, 600 );
QFont font ( "Bitstream Vera Sans", 18 );
font.setWeight ( QFont::Bold );
@ -208,14 +214,14 @@ namespace Hurricane {
titleRect.adjust( 0, 0, 0, titleHeight() - cartoucheHeight() );
// The cartouche box.
cartouchePen.setWidth( 2 );
cartouchePen.setWidth( thickWidth );
painter.setPen ( cartouchePen );
painter.drawRect( cartoucheRect );
// The title & horizontal separator.
string title = getString(_cellWidget->getCell()->getName());
cartouchePen.setWidth( 1 );
cartouchePen.setWidth( thinWidth );
painter.setPen ( cartouchePen );
painter.drawLine( titleRect.bottomLeft(), titleRect.bottomRight() );
painter.setFont ( font );
@ -290,7 +296,7 @@ namespace Hurricane {
if (_cellWidget->getCell() == NULL) return;
_printer = printer;
_printer->setResolution ( 150 );
_printer->setResolution ( 600 );
_printer->setPageMargins( 0.0, 0.0, 0.0, 0.0, QPrinter::DevicePixel );
_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
{
ostringstream s;

View File

@ -70,6 +70,8 @@ namespace Hurricane {
void pageDecorate ( QPainter& );
void toPdf ( QPrinter* , bool imageOnly=false );
virtual std::string _getString () const;
private:
int _scalePixels ( int pixels, int dpi );
protected:
CellWidget* _screenCellWidget;