From 94ce0bf09b18d0d52040987665478024397cc1fb Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 11 Apr 2011 21:18:17 +0000 Subject: [PATCH] 2011-04-11 13:13 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpparthandler.prg * contrib/hbxbp/xbpwindow.prg + Implemented: Xbase++ compatible :moveWithOwner feature. Any dialog with :moveWithOwner set to TRUE will move together with its owner if user moves the window which owns them. --- harbour/contrib/hbxbp/xbpparthandler.prg | 39 +++++++++++++++++++++--- harbour/contrib/hbxbp/xbpwindow.prg | 1 + 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/harbour/contrib/hbxbp/xbpparthandler.prg b/harbour/contrib/hbxbp/xbpparthandler.prg index 5a55623180..da18a94042 100644 --- a/harbour/contrib/hbxbp/xbpparthandler.prg +++ b/harbour/contrib/hbxbp/xbpparthandler.prg @@ -87,16 +87,19 @@ CLASS XbpPartHandler METHOD addChild( oXbp ) METHOD addAsChild() + METHOD addAsOwned( oXbp ) METHOD childFromName( nNameId ) METHOD childList() METHOD delChild( oXbp ) METHOD setName( nNameId ) - METHOD setOwner( oXbp ) + METHOD setOwner( oOwner ) METHOD setParent( oParent ) + METHOD moveOwned( nOffSetX, nOffSetY ) METHOD notifier() DATA aChildren INIT {} + DATA aOwned INIT {} DATA nNameId DATA oParent DATA oOwner @@ -124,6 +127,10 @@ METHOD create( oParent, oOwner ) CLASS XbpPartHandler ::oParent := oParent ::oOwner := oOwner + IF hb_isObject( ::oOwner ) + ::oOwner:addAsOwned( Self ) + ENDIF + RETURN Self /*----------------------------------------------------------------------*/ @@ -196,6 +203,16 @@ METHOD addAsChild() CLASS XbpPartHandler /*----------------------------------------------------------------------*/ +METHOD addAsOwned( oXbp ) CLASS XbpPartHandler + + IF ! empty( oXbp ) + aadd( ::aOwned, oXbp ) + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + METHOD childFromName( nNameId ) CLASS XbpPartHandler LOCAL i @@ -240,11 +257,11 @@ METHOD setName( nNameId ) CLASS XbpPartHandler /*----------------------------------------------------------------------*/ -METHOD setOwner( oXbp ) CLASS XbpPartHandler +METHOD setOwner( oOwner ) CLASS XbpPartHandler LOCAL oOldXbp := ::oOwner - IF valtype( oXbp ) == "O" - ::oOwner := oXbp + IF valtype( oOwner ) == "O" + ::oOwner := oOwner ENDIF RETURN oOldXbp @@ -281,3 +298,17 @@ METHOD notifier() CLASS XbpPartHandler RETURN self /*----------------------------------------------------------------------*/ + +METHOD moveOwned( nOffSetX, nOffSetY ) CLASS XbpPartHandler + LOCAL oXbp, oPos + + FOR EACH oXbp IN ::aOwned + IF oXbp:moveWithOwner + oPos := oXbp:oWidget:pos() + oXbp:oWidget:move( oPos:x() + nOffSetX, oPos:y() + nOffSetY ) + ENDIF + NEXT + + RETURN Self + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index 65a6bead1c..fa4cebe5a9 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -611,6 +611,7 @@ METHOD XbpWindow:grabEvent( nEvent, oEvent ) CASE QEvent_Move // :move() oP0 := oEvent:oldPos() oP1 := oEvent:pos() + ::moveOwned( oP1:x() - oP0:x(), oP1:y() - oP0:y() ) SetAppEvent( xbeP_Move, { oP0:x(), oP0:y() }, { oP1:x(), oP1:y() }, Self ) lRet := .f. EXIT