double FLFontSize::pixelSize( const QFontDef &request, QPaintDevice *paintdevice ) { int dpi = GetDeviceCaps( qt_display_dc(), LOGPIXELSY ); double pSize; if ( request.pointSize != -1 ) { if ( paintdevice ) { pSize = request.pointSize * dpi / 72.; dpi = QPaintDeviceMetrics( paintdevice ).logicalDpiY(); pSize = pSize * dpi / 72.; } else pSize = request.pointSize * dpi / 72.; } else pSize = request.pixelSize; return pSize / 10; }
double FLFontSize::pointSize( const QFontDef &fd, QPaintDevice *paintdevice ) { int dpi = GetDeviceCaps( qt_display_dc(), LOGPIXELSY ); double pSize; if ( paintdevice ) { dpi = QPaintDeviceMetrics( paintdevice ).logicalDpiY(); } if ( fd.pointSize < 0 ) { if ( paintdevice ) { pSize = fd.pixelSize * 72. / ( ( float ) dpi ); dpi = QPaintDeviceMetrics( paintdevice ).logicalDpiY(); pSize = pSize * 72. / ( ( float ) dpi ); } else pSize = fd.pixelSize * 72. / ( ( float ) dpi ); } else pSize = fd.pointSize; return pSize / 10; }
static HCURSOR qt_createPixmapCursor( const QCursor &cursor, const QPixmap &pixmap, const QPoint &hotspot ) { QSize size; /* calculate size of cursor */ QPoint pt = hotspot - cursor.hotSpot(); QPoint pixmap_point( 0, 0 ); QPoint cursor_point( 0, 0 ); if ( qWinVersion() <= Qt::WV_95 ) { /* Win95 can only fixed size */ size.setWidth( GetSystemMetrics ( SM_CXCURSOR ) ); size.setHeight ( GetSystemMetrics ( SM_CYCURSOR ) ); } else { /* calculate size (enlarge if needed) */ const QBitmap *tmp = cursor.bitmap(); /* Only bitmap cursors allowed... */ if ( tmp ) { QPoint point; // curent size size = pixmap.size(); // calc position of lower right cursor pos point.setX( pt.x() + tmp->size().width() ); point.setY( pt.y() + tmp->size().height() ); // resize when cursor to large if ( point.x() > pixmap.width() ) size.setWidth( point.x() ); if ( point.y() > pixmap.height() ) size.setHeight( point.y() ); // calc upper left corner where both pixmaps have to be drawn if ( pt.x() >= 0 ) { cursor_point.setX( pt.x() ); } else { pixmap_point.setX( -pt.x() ); // negative position -> resize size.setWidth( size.width() - pt.x() ); } if ( pt.y() >= 0 ) { cursor_point.setX( pt.x() ); } else { pixmap_point.setY( -pt.y() ); // negative position -> resize size.setHeight( size.height() - pt.y() ); } } } /* Mask */ QBitmap andMask( size ); BitBlt( andMask.handle(), 0, 0, size.width(), size.height(), NULL, 0, 0, WHITENESS ); if ( pixmap.mask() ) BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), pixmap.mask() ->handle(), 0, 0, SRCAND ); else BitBlt( andMask.handle(), pixmap_point.x(), pixmap_point.y(), pixmap.width(), pixmap.height(), NULL, 0, 0, BLACKNESS ); const QBitmap *curMsk = cursor.mask(); if ( curMsk ) BitBlt( andMask.handle(), cursor_point.x(), cursor_point.y(), curMsk->width(), curMsk->height(), curMsk->handle(), 0, 0, SRCAND ); /* create Pixmap */ QPixmap xorMask( size ); xorMask.fill ( Qt::color1 ); QPainter paint2( &xorMask ); paint2.drawPixmap( pixmap_point, pixmap ); QPixmap pm; pm.convertFromImage( cursor.bitmap() ->convertToImage().convertDepth( 8 ) ); pm.setMask( *cursor.mask() ); paint2.drawPixmap ( cursor_point, pm ); paint2.end(); #ifdef DEBUG_QDND_SRC andMask.save ( "pand.png", "PNG" ); xorMask.save ( "pxor.png", "PNG" ); #endif HCURSOR cur = qt_createPixmapCursor ( qt_display_dc(), xorMask, andMask, hotspot, size ); if ( !cur ) { qWarning( "Error creating cursor: %d", GetLastError() ); } return cur; }