From 42f22be28004a77d9828044d3202d3871665685a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Przemys=C5=82aw=20Czerpak?= Date: Wed, 14 Aug 2013 18:10:21 +0200 Subject: [PATCH] 2013-08-14 18:10 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/gtqtc/gtqtc.hbp * do not use system QT directories in android builds * include/hbgtinfo.ch * contrib/gtqtc/gtqtc1.cpp + added new font attributte HB_GTI_FONTA_NOSTRETCH It disables font stretching in some GTs like QTC. On some platforms (i.e. MacOSX) font stretching does not work correctly (at least in my tests) so if someone wants to use GTQTC on MACs then I suggest to set: hb_gtInfo( HB_GTI_FONTATTRIBUTE, ; hb_bitOr( HB_GTI_FONTATTRIBUTE ), HB_GTI_FONTA_NOSTRETCH ) ! do not use QPainter::RasterOp_SourceXorDestination to display cursor and selection in MacOSX builds. RasterOp operations are not supported in MacOSX. --- ChangeLog.txt | 18 ++++++++++++++++++ contrib/gtqtc/gtqtc.hbp | 8 ++++---- contrib/gtqtc/gtqtc1.cpp | 30 ++++++++++++++++++++++++++++-- include/hbgtinfo.ch | 9 +++++---- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/ChangeLog.txt b/ChangeLog.txt index 0466159f36..85566ac4c9 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,24 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2013-08-14 18:10 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/gtqtc/gtqtc.hbp + * do not use system QT directories in android builds + + * include/hbgtinfo.ch + * contrib/gtqtc/gtqtc1.cpp + + added new font attributte HB_GTI_FONTA_NOSTRETCH + It disables font stretching in some GTs like QTC. + On some platforms (i.e. MacOSX) font stretching + does not work correctly (at least in my tests) so + if someone wants to use GTQTC on MACs then I suggest + to set: + hb_gtInfo( HB_GTI_FONTATTRIBUTE, ; + hb_bitOr( HB_GTI_FONTATTRIBUTE ), HB_GTI_FONTA_NOSTRETCH ) + ! do not use QPainter::RasterOp_SourceXorDestination to display + cursor and selection in MacOSX builds. + RasterOp operations are not supported in MacOSX. + 2013-08-07 15:08 UTC+0200 Viktor Szakáts (harbour syenar.net) * ChangeLog.txt ! fixed two wrongly attributed changelog entries diff --git a/contrib/gtqtc/gtqtc.hbp b/contrib/gtqtc/gtqtc.hbp index 7a4479f2bf..d221415ff4 100644 --- a/contrib/gtqtc/gtqtc.hbp +++ b/contrib/gtqtc/gtqtc.hbp @@ -10,13 +10,13 @@ -plugin=hbmk2_qtmoc.hb --deppkgname=qt:QtCore +{!android}-deppkgname=qt:QtCore -depkeyhead=qt:QtCore/qglobal.h -depcontrol=qt:no{HB_BUILD_3RDEXT='no'} -depcontrol=qt:${HB_WITH_QT} -{!darwin}-depincpath=qt:/usr/include/qt4 -{!darwin}-depincpath=qt:/usr/lib/qt4/include -{!darwin}-depincpath=qt:/usr/include +{!darwin&!android}-depincpath=qt:/usr/include/qt4 +{!darwin&!android}-depincpath=qt:/usr/lib/qt4/include +{!darwin&!android}-depincpath=qt:/usr/include {bsd}-depincpath=qt:/usr/local/include/qt4 {darwin}-depincpath=qt:/Developer/qt/include {darwin}-depincpath=qt:/Library/Frameworks diff --git a/contrib/gtqtc/gtqtc1.cpp b/contrib/gtqtc/gtqtc1.cpp index 64998bcbb3..77fef2033e 100644 --- a/contrib/gtqtc/gtqtc1.cpp +++ b/contrib/gtqtc/gtqtc1.cpp @@ -2475,6 +2475,9 @@ void QTConsole::resetWindowSize( void ) void QTConsole::setFontSize( int iFH, int iFW ) { int iDec = 0, iDir, iHeight, iWidth, iAscent; + bool bStretch = ( pQTC->fontAttribute & HB_GTI_FONTA_NOSTRETCH ) == 0; + bool bMaxSize = ( pQTC->qWnd->windowState() & + ( Qt::WindowMaximized | Qt::WindowFullScreen ) ) != 0; if( iFH < 4 ) iFH = 4; @@ -2487,12 +2490,12 @@ void QTConsole::setFontSize( int iFH, int iFW ) iHeight = fm.height(); iWidth = fm.averageCharWidth(); iAscent = fm.ascent(); - if( fm.height() <= iFH ) + if( iHeight <= iFH && ( bStretch || ! bMaxSize || iWidth <= iFW ) ) break; } while( iFH - ++iDec >= 4 ); - if( iFW > 0 ) + if( iFW > 0 && bStretch ) { if( iFW < 2 ) iFW = 2; @@ -2783,8 +2786,16 @@ void QTConsole::paintEvent( QPaintEvent * event ) QRect rSel = hb_gt_qtc_unmapRect( pQTC, hb_gt_qtc_mapRect( pQTC, image, selectRect ) ); if( rSel.intersects( rEvt ) ) { +#if defined( HB_OS_DARWIN ) + /* RasterOp operations are not supported in MacOSX */ + rEvt &= rSel; + image->invertPixels(); + painter.drawImage( rEvt, *image, rEvt.translated( -pQTC->marginLeft, -pQTC->marginTop ) ); + image->invertPixels(); +#else painter.setCompositionMode( QPainter::RasterOp_SourceXorDestination ); painter.fillRect( rSel & rEvt, Qt::color0 ); +#endif } } else if( pQTC->cursorType != SC_NONE ) @@ -2795,9 +2806,24 @@ void QTConsole::paintEvent( QPaintEvent * event ) pQTC->cellX, pQTC->cursorSize ); if( rEvt.intersects( rCrs ) ) { +#if defined( HB_OS_DARWIN ) + /* RasterOp operations are not supported in MacOSX, + * use foreground cell color like hardware VGA cursor + */ + HB_BYTE bAttr; + HB_USHORT usChar; + int iColor; + + if( HB_GTSELF_GETSCRCHAR( pQTC->pGT, pQTC->cursorRow, pQTC->cursorCol, + &iColor, &bAttr, &usChar ) ) + { + painter.fillRect( rCrs, pQTC->colors[ iColor & 0x0F ] ); + } +#else painter.setCompositionMode( QPainter::RasterOp_SourceXorDestination ); /* TODO? use foreground cell color like hardware VGA cursor ? */ painter.fillRect( rCrs, Qt::color0 ); +#endif } } } diff --git a/include/hbgtinfo.ch b/include/hbgtinfo.ch index c3bfb4dfb0..ccc821e18a 100644 --- a/include/hbgtinfo.ch +++ b/include/hbgtinfo.ch @@ -163,10 +163,11 @@ #define HB_GTI_FONTQ_HIGH 3 /* Font attributes */ -#define HB_GTI_FONTA_FIXMETRIC 1 -#define HB_GTI_FONTA_CLRBKG 2 -#define HB_GTI_FONTA_DRAWBOX 4 -#define HB_GTI_FONTA_CTRLCHARS 8 +#define HB_GTI_FONTA_FIXMETRIC 0x0001 +#define HB_GTI_FONTA_CLRBKG 0x0002 +#define HB_GTI_FONTA_DRAWBOX 0x0004 +#define HB_GTI_FONTA_CTRLCHARS 0x0008 +#define HB_GTI_FONTA_NOSTRETCH 0x0010 /* Keyboard shifts states */ #define HB_GTI_KBD_SHIFT 0x000001