From fbd71e39eb359d053d4723436f18dbaa3d0cba3c Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Thu, 31 Mar 2011 17:07:51 +0000 Subject: [PATCH] 2011-03-31 10:03 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbide/hbqreportsmanager.prg * contrib/hbide/idedocks.prg * contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp ! Minors. * contrib/hbqt/qtgui/qth/QPainter.qth ! Rewritten: manually :fillrect() which does not overload proper method with same number and types of arguments. TOFIX: hbmk2_qt.hbs to entertain this construct. --- harbour/ChangeLog | 11 ++ harbour/contrib/hbide/hbqreportsmanager.prg | 107 +++++++++--------- harbour/contrib/hbide/idedocks.prg | 2 + .../hbqt/qtgui/hbqt_hbqgraphicsitem.cpp | 5 +- harbour/contrib/hbqt/qtgui/qth/QPainter.qth | 79 +++++++++++-- 5 files changed, 134 insertions(+), 70 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index d7278f4139..b2c98ae266 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,17 @@ The license applies to all entries newer than 2009-04-28. */ +2011-03-31 10:03 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbide/hbqreportsmanager.prg + * contrib/hbide/idedocks.prg + * contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp + ! Minors. + + * contrib/hbqt/qtgui/qth/QPainter.qth + ! Rewritten: manually :fillrect() which does not overload + proper method with same number and types of arguments. + TOFIX: hbmk2_qt.hbs to entertain this construct. + 2011-03-31 16:36 UTC+0100 Francesco Perillo ( fperillo at gmail.com ) * contrib/hbqt/hbmk2_qt.hbs * contrib/hbqt/qtcore/hbqt.h diff --git a/harbour/contrib/hbide/hbqreportsmanager.prg b/harbour/contrib/hbide/hbqreportsmanager.prg index 3a3a8e5b8f..ce3a16349f 100644 --- a/harbour/contrib/hbide/hbqreportsmanager.prg +++ b/harbour/contrib/hbide/hbqreportsmanager.prg @@ -1696,23 +1696,23 @@ CLASS HqrGraphicsItem METHOD setPos( ... ) SETGET METHOD setLineType( ... ) SETGET - METHOD draw( qPainter, qRect, lDrawSelection ) + METHOD draw( qPainter, qRectF, lDrawSelection ) METHOD setupPainter( qPainter, lDrawSelection ) - METHOD drawBarcode( qPainter, qRect ) - METHOD drawImage( qPainter, qRect ) + METHOD drawBarcode( qPainter, qRectF ) + METHOD drawImage( qPainter, qRectF ) METHOD drawChart( qPainter, qRect ) - METHOD drawText( qPainter, qRect ) - METHOD drawField( qPainter, qRect ) - METHOD drawGradient( qPainter, qRect ) + METHOD drawText( qPainter, qRectF ) + METHOD drawField( qPainter, qRectF ) + METHOD drawGradient( qPainter, qRectF ) METHOD drawLine( qPainter, qRect ) - METHOD drawRect( qPainter, qRect ) - METHOD drawRoundRect( qPainter, qRect ) - METHOD drawEllipse( qPainter, qRect ) - METHOD drawPie( qPainter, qRect ) - METHOD drawArc( qPainter, qRect ) - METHOD drawChord( qPainter, qRect ) - METHOD drawDiamond( qPainter, qRect ) - METHOD drawTriangle( qPainter, qRect ) + METHOD drawRect( qPainter, qRectF ) + METHOD drawRoundRect( qPainter, qRectF ) + METHOD drawEllipse( qPainter, qRectF ) + METHOD drawPie( qPainter, qRectF ) + METHOD drawArc( qPainter, qRectF ) + METHOD drawChord( qPainter, qRectF ) + METHOD drawDiamond( qPainter, qRectF ) + METHOD drawTriangle( qPainter, qRectF ) METHOD drawSelection( qPainter, qRect ) ERROR HANDLER OnError( ... ) @@ -2314,8 +2314,7 @@ METHOD HqrGraphicsItem:drawSelection( qPainter, qRect ) /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:draw( qPainter, qRect, lDrawSelection ) - LOCAL qRectF := QRectF( qRect ) +METHOD HqrGraphicsItem:draw( qPainter, qRectF, lDrawSelection ) DEFAULT lDrawSelection TO .t. @@ -2348,20 +2347,20 @@ METHOD HqrGraphicsItem:draw( qPainter, qRect, lDrawSelection ) /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawRect( qPainter, qRect ) - qPainter:drawRect( qRect ) +METHOD HqrGraphicsItem:drawRect( qPainter, qRectF ) + qPainter:drawRect( qRectF ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawRoundRect( qPainter, qRect ) - qPainter:drawRoundedRect( qRect, 10/UNIT, 10/UNIT ) +METHOD HqrGraphicsItem:drawRoundRect( qPainter, qRectF ) + qPainter:drawRoundedRect( qRectF, 10/UNIT, 10/UNIT ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawEllipse( qPainter, qRect ) - qPainter:drawEllipse( qRect ) +METHOD HqrGraphicsItem:drawEllipse( qPainter, qRectF ) + qPainter:drawEllipse( qRectF ) RETURN Self /*----------------------------------------------------------------------*/ @@ -2386,15 +2385,15 @@ METHOD HqrGraphicsItem:drawLine( qPainter, qRect ) /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawPie( qPainter, qRect ) - qPainter:drawPie( qRect, ::nStartAngle * 16, ::nSpanAngle * 16 ) +METHOD HqrGraphicsItem:drawPie( qPainter, qRectF ) + qPainter:drawPie( qRectF, ::nStartAngle * 16, ::nSpanAngle * 16 ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawDiamond( qPainter, qRect ) +METHOD HqrGraphicsItem:drawDiamond( qPainter, qRectF ) LOCAL p := QPainterPath() - LOCAL x := qRect:x(), y := qRect:y(), w := qRect:width(), h := qRect:height() + LOCAL x := qRectF:x(), y := qRectF:y(), w := qRectF:width(), h := qRectF:height() p:moveTo( x, y + h / 2 ) p:lineTo( x + w / 2, y ) @@ -2408,13 +2407,13 @@ METHOD HqrGraphicsItem:drawDiamond( qPainter, qRect ) /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawTriangle( qPainter, qRect ) +METHOD HqrGraphicsItem:drawTriangle( qPainter, qRectF ) LOCAL p := QPainterPath() - p:moveTo( qRect:x(), qRect:y() + qRect:height() ) - p:lineTo( qRect:x() + qRect:width() / 2, qRect:y() ) - p:lineTo( qRect:x() + qRect:width(), qRect:y() + qRect:height() ) - p:lineTo( qRect:x(), qRect:y() + qRect:height() ) + p:moveTo( qRectF:x(), qRectF:y() + qRectF:height() ) + p:lineTo( qRectF:x() + qRectF:width() / 2, qRectF:y() ) + p:lineTo( qRectF:x() + qRectF:width(), qRectF:y() + qRectF:height() ) + p:lineTo( qRectF:x(), qRectF:y() + qRectF:height() ) qPainter:drawPath( p ) @@ -2422,53 +2421,49 @@ METHOD HqrGraphicsItem:drawTriangle( qPainter, qRect ) /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawArc( qPainter, qRect ) - qPainter:drawArc( qRect, ::nStartAngle * 16, ::nSpanAngle * 16 ) +METHOD HqrGraphicsItem:drawArc( qPainter, qRectF ) + qPainter:drawArc( qRectF, ::nStartAngle * 16, ::nSpanAngle * 16 ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawChord( qPainter, qRect ) - qPainter:drawChord( qRect, ::nStartAngle * 16, ::nSpanAngle * 16 ) +METHOD HqrGraphicsItem:drawChord( qPainter, qRectF ) + qPainter:drawChord( qRectF, ::nStartAngle * 16, ::nSpanAngle * 16 ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawText( qPainter, qRect ) - qPainter:drawText( qRect, ::textFlags(), ::text() ) +METHOD HqrGraphicsItem:drawText( qPainter, qRectF ) + qPainter:drawText( qRectF, ::textFlags(), ::text() ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawField( qPainter, qRect ) - qPainter:drawText( qRect, ::textFlags(), ::text() ) +METHOD HqrGraphicsItem:drawField( qPainter, qRectF ) + qPainter:drawText( qRectF, ::textFlags(), ::text() ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawGradient( qPainter, qRect ) - qPainter:drawRect( qRect ) +METHOD HqrGraphicsItem:drawGradient( qPainter, qRectF ) + qPainter:drawRect( qRectF ) RETURN Self /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawBarcode( qPainter, qRect ) - LOCAL fl, clr, rc, w, x, i, cCode - - rc := qRect:adjusted( 5, 5, -10, -10 ) +METHOD HqrGraphicsItem:drawBarcode( qPainter, qRectF ) + LOCAL rc, w, x, i, cCode + rc := qRectF:adjusted( 5, 5, -10, -10 ) cCode := fetchBarString( ::text() ) - - fl := QColor( Qt_white ) - clr := QColor( Qt_black ) w := rc:width() / len( cCode ) x := 0.0 FOR i := 1 TO len( cCode ) IF substr( cCode, i, 1 ) == "1" - qPainter:fillRect( QRectF( rc:x() + x, rc:y(), w, rc:height() ), clr ) + qPainter:fillRect( QRectF( rc:x() + x, rc:y(), w, rc:height() ), QColor( Qt_black ) ) ELSE - qPainter:fillRect( QRectF( rc:x() + x, rc:y(), w, rc:height() ), fl ) + qPainter:fillRect( QRectF( rc:x() + x, rc:y(), w, rc:height() ), QColor( Qt_white ) ) ENDIF x += w NEXT @@ -2477,7 +2472,7 @@ METHOD HqrGraphicsItem:drawBarcode( qPainter, qRect ) /*----------------------------------------------------------------------*/ -METHOD HqrGraphicsItem:drawImage( qPainter, qRect ) +METHOD HqrGraphicsItem:drawImage( qPainter, qRectF ) LOCAL qPix, image, rc, img, point LOCAL drawTextType := HBQT_GRAPHICSITEM_TEXT_DRAW_ABOVE LOCAL paintType := HBQT_GRAPHICSITEM_RESIZE_PICTURE_TO_ITEM_KEEP_ASPECT_RATIO @@ -2486,7 +2481,7 @@ METHOD HqrGraphicsItem:drawImage( qPainter, qRect ) LOCAL cText := "Picture" LOCAL qObj := ::oWidget - rc := QRectF( qRect:adjusted( 1, 1, -2, -2 ) ) + rc := qRectF:adjusted( 1, 1, -2, -2 ) textH := 0 sw := 0 @@ -2496,14 +2491,14 @@ METHOD HqrGraphicsItem:drawImage( qPainter, qRect ) textH = qPainter:font():pixelSize() ENDIF - qPix := QPixmap( ::pixmap() ) - image := QImage( qPix:toImage() ) + qPix := ::pixmap() + image := qPix:toImage() IF image:isNull() - qPainter:drawRect( qRect ) + qPainter:drawRect( qRectF ) ELSE img := QImage( 0, 0 ) - point := qRect:topLeft() + point := qRectF:topLeft() cx := 0; cy := 0; cw := qPix:width(); ch := qPix:height() SWITCH paintType diff --git a/harbour/contrib/hbide/idedocks.prg b/harbour/contrib/hbide/idedocks.prg index 6794245841..5a0018de1a 100644 --- a/harbour/contrib/hbide/idedocks.prg +++ b/harbour/contrib/hbide/idedocks.prg @@ -712,6 +712,8 @@ HB_TRACE( HB_TR_DEBUG, "editWidget_dropEvent", 0 ) ::oSM:editSource( hbide_pathToOSPath( qUrl:toLocalFile() ) ) ENDIF NEXT + p:setDropAction( Qt_CopyAction ) + p:accept() qList := NIL ENDIF qMime := NIL diff --git a/harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp b/harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp index 925b498200..ac09a6742e 100644 --- a/harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp +++ b/harbour/contrib/hbqt/qtgui/hbqt_hbqgraphicsitem.cpp @@ -67,6 +67,7 @@ HB_EXTERN_BEGIN extern void * hbqt_gcAllocate_QPainter( void * pObj, bool bNew ); +extern void * hbqt_gcAllocate_QRectF( void * pObj, bool bNew ); extern void * hbqt_gcAllocate_QGraphicsSceneContextMenuEvent( void * pObj, bool bNew ); HB_EXTERN_END @@ -777,8 +778,8 @@ void HBQGraphicsItem::paint( QPainter * painter, const QStyleOptionGraphicsItem QRectF rect = ( option->type == QStyleOption::SO_GraphicsItem ) ? boundingRect() : option->exposedRect; PHB_ITEM p1 = hb_itemPutNI( NULL, 21017 ); - PHB_ITEM p2 = hbqt_create_objectGC( hbqt_gcAllocate_QPainter( painter, false ), "hb_QPainter" ); - PHB_ITEM p3 = hb_itemPutPtr( NULL, &rect ); + PHB_ITEM p2 = hb_itemNew( hbqt_create_objectGC( hbqt_gcAllocate_QPainter( painter, false ), "hb_QPainter" ) ); + PHB_ITEM p3 = hb_itemNew( hbqt_create_objectGC( hbqt_gcAllocate_QRectF( &rect, false ), "hb_QRectF" ) ); hb_vmEvalBlockV( block, 3, p1, p2, p3 ); hb_itemRelease( p1 ); hb_itemRelease( p2 ); diff --git a/harbour/contrib/hbqt/qtgui/qth/QPainter.qth b/harbour/contrib/hbqt/qtgui/qth/QPainter.qth index a65e876818..b4ebab61ba 100644 --- a/harbour/contrib/hbqt/qtgui/qth/QPainter.qth +++ b/harbour/contrib/hbqt/qtgui/qth/QPainter.qth @@ -165,11 +165,12 @@ void drawRoundedRect ( int x, int y, int w, int h, qreal xRadius, qreal yRadius, void drawText ( const QPointF & position, const QString & text ) void drawText ( const QPoint & position, const QString & text ) +void drawText ( const QRectF & rectangle, const QString & text, const QTextOption & option = QTextOption() ) void drawText ( const QRectF & rectangle, int flags, const QString & text, QRectF * boundingRect = 0 ) void drawText ( const QRect & rectangle, int flags, const QString & text, QRect * boundingRect = 0 ) void drawText ( int x, int y, const QString & text ) void drawText ( int x, int y, int width, int height, int flags, const QString & text, QRect * boundingRect = 0 ) -void drawText ( const QRectF & rectangle, const QString & text, const QTextOption & option = QTextOption() ) + void drawTiledPixmap ( const QRectF & rectangle, const QPixmap & pixmap, const QPointF & position = QPointF() ) void drawTiledPixmap ( const QRect & rectangle, const QPixmap & pixmap, const QPoint & position = QPoint() ) @@ -183,18 +184,72 @@ void eraseRect ( int x, int y, int width, int height ) void fillPath ( const QPainterPath & path, const QBrush & brush ) -void fillRect ( const QRectF & rectangle, const QBrush & brush ) -//void fillRect ( int x, int y, int width, int height, Qt::BrushStyle style ) -//void fillRect ( const QRect & rectangle, Qt::BrushStyle style ) +//void fillRect ( const QRectF & rectangle, const QBrush & brush ) +//void fillRect ( const QRect & rectangle, const QBrush & brush ) +//void fillRect ( const QRectF & rectangle, const QColor & color ) +//void fillRect ( const QRect & rectangle, const QColor & color ) //void fillRect ( const QRectF & rectangle, Qt::BrushStyle style ) -void fillRect ( const QRect & rectangle, const QBrush & brush ) -void fillRect ( const QRect & rectangle, const QColor & color ) -void fillRect ( const QRectF & rectangle, const QColor & color ) -void fillRect ( int x, int y, int width, int height, const QBrush & brush ) -void fillRect ( int x, int y, int width, int height, const QColor & color ) -void fillRect ( int x, int y, int width, int height, Qt::GlobalColor color ) -void fillRect ( const QRect & rectangle, Qt::GlobalColor color ) -void fillRect ( const QRectF & rectangle, Qt::GlobalColor color ) +//void fillRect ( const QRect & rectangle, Qt::BrushStyle style ) +//void fillRect ( int x, int y, int width, int height, const QBrush & brush ) +//void fillRect ( int x, int y, int width, int height, const QColor & color ) +//void fillRect ( int x, int y, int width, int height, Qt::GlobalColor color ) +//void fillRect ( int x, int y, int width, int height, Qt::BrushStyle style ) +//void fillRect ( const QRect & rectangle, Qt::GlobalColor color ) +void fillRect ( const QRectF & rectangle, Qt::GlobalColor color ){ + QPainter * p = ( QPainter * ) hbqt_pPtrFromObj( 0 ); + if( p ) + { + int pcount = hb_pcount(); + + if( pcount == 2 && HB_ISOBJECT( 1 ) && HB_ISOBJECT( 2 ) ) + { + if( hbqt_isObjectType( 1, HBQT_TYPE_QRectF ) && hbqt_isObjectType( 2, HBQT_TYPE_QBrush ) ) + { + p->fillRect( *hbqt_par_QRectF( 1 ), *hbqt_par_QBrush( 2 ) ); + } + else if( hbqt_isObjectType( 1, HBQT_TYPE_QRect ) && hbqt_isObjectType( 2, HBQT_TYPE_QBrush ) ) + { + p->fillRect( *hbqt_par_QRect( 1 ), *hbqt_par_QBrush( 2 ) ); + } + else if( hbqt_isObjectType( 1, HBQT_TYPE_QRectF ) && hbqt_isObjectType( 2, HBQT_TYPE_QColor ) ) + { + p->fillRect( *hbqt_par_QRectF( 1 ), *hbqt_par_QColor( 2 ) ); + } + else if( hbqt_isObjectType( 1, HBQT_TYPE_QRect ) && hbqt_isObjectType( 2, HBQT_TYPE_QColor ) ) + { + p->fillRect( *hbqt_par_QRect( 1 ), *hbqt_par_QColor( 2 ) ); + } + } + else if( pcount == 2 && HB_ISOBJECT( 1 ) && HB_ISNUM( 2 ) ) + { + if( hbqt_isObjectType( 1, HBQT_TYPE_QRectF ) ) + { + p->fillRect( *hbqt_par_QRectF( 1 ), ( Qt::GlobalColor ) hb_parni( 2 ) ); + } + else if( hbqt_isObjectType( 1, HBQT_TYPE_QRect ) ) + { + p->fillRect( *hbqt_par_QRect( 1 ), ( Qt::GlobalColor ) hb_parni( 2 ) ); + } + } + else if( pcount == 5 && HB_ISNUM( 1 ) && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) && HB_ISNUM( 4 ) && HB_ISOBJECT( 5 ) ) + { + if( hbqt_isObjectType( 5, HBQT_TYPE_QBrush ) ) + { + p->fillRect( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), *hbqt_par_QBrush( 5 ) ); + } + else if( hbqt_isObjectType( 5, HBQT_TYPE_QColor ) ) + { + p->fillRect( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), *hbqt_par_QColor( 5 ) ); + } + } + else if( pcount == 5 && HB_ISNUM( 1 ) && HB_ISNUM( 2 ) && HB_ISNUM( 3 ) && HB_ISNUM( 4 ) && HB_ISNUM( 5 ) ) + { + p->fillRect( hb_parni( 1 ), hb_parni( 2 ), hb_parni( 3 ), hb_parni( 4 ), ( Qt::GlobalColor ) hb_parni( 5 ) ); + } + + hb_itemReturn( hb_stackSelfItem() ); + } +} const QFont & font () const QFontInfo fontInfo () const