From 6caec86f06abfedbdefca2137682c3942d400971 Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Mon, 9 May 2011 07:23:06 +0000 Subject: [PATCH] 2011-05-09 00:16 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpmenubar.prg * contrib/hbxbp/xbpparthandler.prg ! Corrected: many artifacts related to XbpMenu() and :setOwner()/:setParent() functionality. Thanks Shum for insight. --- harbour/ChangeLog | 6 ++++++ harbour/contrib/hbxbp/xbpmenubar.prg | 23 ++++++++++++++++++----- harbour/contrib/hbxbp/xbpparthandler.prg | 20 ++++++++++++++------ 3 files changed, 38 insertions(+), 11 deletions(-) diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 7e96a445a3..780c1e26cc 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -16,6 +16,12 @@ The license applies to all entries newer than 2009-04-28. */ +2011-05-09 00:16 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) + * contrib/hbxbp/xbpmenubar.prg + * contrib/hbxbp/xbpparthandler.prg + ! Corrected: many artifacts related to XbpMenu() and + :setOwner()/:setParent() functionality. Thanks Shum for insight. + 2011-05-07 13:18 UTC-0800 Pritpal Bedi (bedipritpal@hotmail.com) * contrib/hbxbp/xbpmenubar.prg ! Fixed: where XbpMenu() activation was not supplying the documented diff --git a/harbour/contrib/hbxbp/xbpmenubar.prg b/harbour/contrib/hbxbp/xbpmenubar.prg index ee30a873bb..16032e5438 100644 --- a/harbour/contrib/hbxbp/xbpmenubar.prg +++ b/harbour/contrib/hbxbp/xbpmenubar.prg @@ -114,7 +114,7 @@ CLASS xbpMenuBar INHERIT xbpWindow DATA caption INIT "" DATA nItemID INIT 0 DATA aIds INIT {} - DATA className INIT "XbpMenuBar" + DATA className INIT "XBPMENUBAR" METHOD init( oParent, aPresParams, lVisible ) METHOD create( oParent, aPresParams, lVisible ) @@ -245,9 +245,9 @@ METHOD xbpMenuBar:placeItem( xCaption, bAction, nStyle, nAttrb, nMode, nPos ) DO CASE CASE cType == "U" .OR. empty( xCaption ) .OR. nStyle == XBPMENUBAR_MIS_SEPARATOR IF lInsert - oAction := ::oWidget:insertSeparator() + oAction := ::oWidget:insertSeparator( pOldAct ) ELSE - ::oWidget:addSeparator() + oAction := ::oWidget:addSeparator() ENDIF aItem := { QMF_SEPARATOR, 0, 0, NIL, oAction } @@ -370,7 +370,7 @@ METHOD xbpMenuBar:placeItem( xCaption, bAction, nStyle, nAttrb, nMode, nPos ) METHOD xbpMenuBar:addItem( aItem ) LOCAL xCaption, bAction, nStyle, nAttrib - IF PCount() == 1 .and. valtype( aItem ) == "A" + IF PCount() == 1 .AND. hb_isArray( aItem ) ASize( aItem, 4 ) xCaption := aItem[ 1 ] @@ -645,6 +645,7 @@ METHOD xbpMenuBar:setStyle() CLASS xbpMenu INHERIT xbpMenuBar DATA title INIT "" + DATA className INIT "XBPMENU" METHOD init( oParent, aPresParams, lVisible ) METHOD create( oParent, aPresParams, lVisible ) @@ -652,6 +653,7 @@ CLASS xbpMenu INHERIT xbpMenuBar METHOD setTitle( cTitle ) METHOD popUp( oXbp, aPos, nDefaultItem, nControl ) METHOD setStyle() + METHOD normalize( cCaption ) ENDCLASS @@ -670,6 +672,7 @@ METHOD xbpMenu:create( oParent, aPresParams, lVisible ) ::xbpWindow:create( oParent, , , , aPresParams, lVisible ) ::oWidget := QMenu() + ::oWidget:setTitle( ::normalize( ::title ) ) IF hb_isObject( ::oParent ) ::oParent:oWidget:addMenu( ::oWidget ) @@ -689,8 +692,12 @@ METHOD xbpMenu:getTitle() /*----------------------------------------------------------------------*/ METHOD xbpMenu:setTitle( cTitle ) + LOCAL oldTitle := ::title - RETURN ::title := cTitle + ::title := cTitle + ::oWidget:setTitle( ::normalize( ::title ) ) + + RETURN oldTitle /*----------------------------------------------------------------------*/ @@ -708,6 +715,12 @@ METHOD xbpMenu:popUp( oXbp, aPos, nDefaultItem, nControl ) /*----------------------------------------------------------------------*/ +METHOD xbpMenu:normalize( cCaption ) + + RETURN strtran( cCaption, '~', '&' ) + +/*----------------------------------------------------------------------*/ + METHOD xbpMenu:setStyle() LOCAL s, txt_:={} diff --git a/harbour/contrib/hbxbp/xbpparthandler.prg b/harbour/contrib/hbxbp/xbpparthandler.prg index 68ea286ff8..17a0d6a6c1 100644 --- a/harbour/contrib/hbxbp/xbpparthandler.prg +++ b/harbour/contrib/hbxbp/xbpparthandler.prg @@ -128,12 +128,13 @@ METHOD XbpPartHandler:create( oParent, oOwner ) ::oParent := oParent ::oOwner := oOwner - // DEFAULT ::oOwner TO ::oParent - IF hb_isObject( ::oOwner ) ::oOwner:addAsOwned( Self ) ENDIF + DEFAULT ::oParent TO SetAppWindow() + DEFAULT ::oOwner TO ::oParent + RETURN Self /*----------------------------------------------------------------------*/ @@ -217,11 +218,18 @@ METHOD XbpPartHandler:addAsOwned( oXbp ) /*----------------------------------------------------------------------*/ METHOD XbpPartHandler:childFromName( nNameId ) - LOCAL i + LOCAL oXbp, oXbpC - FOR i := 1 TO len( ::aChildren ) - IF ::aChildren[ i ]:nNameID <> NIL .AND. ::aChildren[ i ]:nNameID == nNameID - RETURN ::aChildren[ i ] + FOR EACH oXbp IN ::aChildren + + IF oXbp:nNameID <> NIL .AND. oXbp:nNameID == nNameID + RETURN oXbp + ELSE + FOR EACH oXbpC IN oXbp:aChildren + IF oXbpC:nNameID <> NIL .AND. oXbpC:nNameID == nNameID + RETURN oXbpC + ENDIF + NEXT ENDIF NEXT