diff --git a/harbour/ChangeLog b/harbour/ChangeLog index f60f97f554..75c7772cc9 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,37 @@ past entries belonging to author(s): Viktor Szakats. */ +2010-02-08 17:16 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * contrib/hbxbp/xbp.ch + * contrib/hbxbp/xbpparthandler.prg + * contrib/hbxbp/xbpstatusbar.prg + * contrib/hbxbp/xbptoolbar.prg + * contrib/hbxbp/xbpwindow.prg + ! Fixed a rare parent/child relation issue in XbpStatusBar() + and XbpToolBar() classes. + + Implemented Harbour extension: + Method :hbLayout( HBPLAYOUT_TYPE_* ) + Currently HBPLAYOUT_TYPE_HORZBOX and + HBPLAYOUT_TYPE_VERTBOX are supported. + This is essentially executed after :create(). + When executed class attemps to all children of + it to be laid accordingly, if some are already created. + Any other Xbp part created with "this" object as parent, + that is also laid appropriately. + + This reduces a lot of code writing. + Example: + oStatic := XbpStatic():new():create( oDlg,... ) + oStatic:hbLayout := HBPLAYOUT_TYPE_HORZBOX + oBtn := XbpPushButton():new( oStatic ):create( ... ) + oBtn1 := XbpPushButton():new( oStatic ):create( ... ) + oBtn2 := XbpPushButton():new( oStatic ):create( ... ) + Then, these buttons will be nicely placed inside + oStatic. No need to go for complex calculations. + + * contrib/hbxbp/tests/demoxbp.prg + + Applied :hbLayout for :drawingArea and tabPages. + 2010-02-09 02:12 UTC+0100 Viktor Szakats (harbour.01 syenar.hu) * src/vm/runner.c * src/vm/garbage.c diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index f766ed05d4..ccb8a1c611 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -157,6 +157,10 @@ DispMem( "oDlg := GuiStdDialog" ) oDa:setFontCompoundName( "10.Tohama italics" ) //oDa:setColorFG( GraMakeRGBColor( { 255,255,255 } ) ) + #ifdef __HARBOUR__ + oDA:hbLayout := HBPLAYOUT_TYPE_VERTBOX + #endif + /* Install menu system */ Build_MenuBar( oDlg ) DispMem( "Build_MenuBar" ) @@ -546,6 +550,9 @@ FUNCTION Build_TabPages( oWnd ) aTabs[ TAB_1 ]:minimized := .F. aTabs[ TAB_1 ]:create() aTabs[ TAB_1 ]:TabActivate := SetMaximized( aTabs, 1 ) + #ifdef __HARBOUR__ + aTabs[ TAB_1 ]:hbLayout := HBPLAYOUT_TYPE_VERTBOX + #endif aTabs[ TAB_2 ] := XbpTabPage():new( oWnd, , aPos, aSize, , .t. ) aTabs[ TAB_2 ]:caption := "MLE" @@ -553,6 +560,9 @@ FUNCTION Build_TabPages( oWnd ) aTabs[ TAB_2 ]:postOffset := 120 aTabs[ TAB_2 ]:create() aTabs[ TAB_2 ]:TabActivate := SetMaximized( aTabs, 2 ) + #ifdef __HARBOUR__ + aTabs[ TAB_2 ]:hbLayout := HBPLAYOUT_TYPE_VERTBOX + #endif aTabs[ TAB_3 ] := XbpTabPage():new( oWnd, , aPos, aSize, , .t. ) aTabs[ TAB_3 ]:caption := "Btns" @@ -560,6 +570,9 @@ FUNCTION Build_TabPages( oWnd ) aTabs[ TAB_3 ]:postOffset := 100 aTabs[ TAB_3 ]:create() aTabs[ TAB_3 ]:TabActivate := SetMaximized( aTabs, 3 ) + #ifdef __HARBOUR__ + aTabs[ TAB_3 ]:hbLayout := HBPLAYOUT_TYPE_HORZBOX + #endif aTabs[ TAB_4 ] := XbpTabPage():new( oWnd, , aPos, aSize, , .t. ) aTabs[ TAB_4 ]:caption := "Tree" @@ -568,6 +581,9 @@ FUNCTION Build_TabPages( oWnd ) aTabs[ TAB_4 ]:create() aTabs[ TAB_4 ]:TabActivate := SetMaximized( aTabs, 4 ) aTabs[ TAB_4 ]:setColorBG( GraMakeRGBColor( {198,198,198} ) ) + #ifdef __HARBOUR__ + aTabs[ TAB_4 ]:hbLayout := HBPLAYOUT_TYPE_HORZBOX + #endif aTabs[ TAB_5 ] := XbpTabPage():new( oWnd, , aPos, aSize, , .t. ) aTabs[ TAB_5 ]:minimized := .F. @@ -586,6 +602,9 @@ FUNCTION Build_TabPages( oWnd ) aTabs[ TAB_6 ]:postOffset := 40 aTabs[ TAB_6 ]:create() aTabs[ TAB_6 ]:TabActivate := SetMaximized( aTabs, 6 ) + #ifdef __HARBOUR__ + // aTabs[ TAB_6 ]:hbLayout := HBPLAYOUT_TYPE_VERTBOX + #endif aTabs[ TAB_7 ] := XbpTabPage():new( oWnd, , aPos, aSize, , .t. ) aTabs[ TAB_7 ]:caption := "Web" @@ -594,6 +613,9 @@ FUNCTION Build_TabPages( oWnd ) aTabs[ TAB_7 ]:minimized := .F. aTabs[ TAB_7 ]:create() aTabs[ TAB_7 ]:TabActivate := SetMaximized( aTabs, 7 ) + #ifdef __HARBOUR__ + aTabs[ TAB_7 ]:hbLayout := HBPLAYOUT_TYPE_VERTBOX + #endif aTabs[ TAB_8 ] := XbpTabPage():new( oWnd, , aPos, aSize, , .t. ) aTabs[ TAB_8 ]:caption := "Statics" diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index 3b10b6efb7..ec9ba13664 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -420,6 +420,17 @@ #define XBPBRW_Pan_LastCol 4 #define XBPBRW_Pan_Track 5 +/*----------------------------------------------------------------------*/ +/* Harbour Specific Constants */ + +#define HBPLAYOUT_TYPE_HORZBOX 1 +#define HBPLAYOUT_TYPE_VERTBOX 2 +#define HBPLAYOUT_TYPE_GRID 3 +#define HBPLAYOUT_TYPE_FORM 4 + +#define HBPLAYOUT_TYPE_MAX 4 + + /*----------------------------------------------------------------------*/ #define _XBP_CH #endif diff --git a/harbour/contrib/hbxbp/xbpparthandler.prg b/harbour/contrib/hbxbp/xbpparthandler.prg index 38bf57a3d8..f5a010f11e 100644 --- a/harbour/contrib/hbxbp/xbpparthandler.prg +++ b/harbour/contrib/hbxbp/xbpparthandler.prg @@ -172,6 +172,9 @@ METHOD addChild( oXbp ) CLASS XbpPartHandler oXbp:nNameID := oXbp:nID aadd( ::aChildren, oXbp ) + IF __objHasMsg( Self, "QLAYOUT" ) .AND. !empty( ::qLayout ) + ::qLayout:addWidget( oXbp:oWidget ) + ENDIF RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpstatusbar.prg b/harbour/contrib/hbxbp/xbpstatusbar.prg index 8c7d904128..e668299049 100644 --- a/harbour/contrib/hbxbp/xbpstatusbar.prg +++ b/harbour/contrib/hbxbp/xbpstatusbar.prg @@ -120,19 +120,20 @@ METHOD XbpStatusBar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ELSE RETURN Self ENDIF + ::oParent := oPar ::oWidget := QStatusBar():new() - oPar:oWidget:setStatusBar( ::oWidget ) + ::oParent:oWidget:setStatusBar( ::oWidget ) ::oWidget:setSizeGripEnabled( ::sizeGrip ) + ::addItem( , , , , , -1 ) + IF ::visible ::show() ENDIF - - ::addItem( , , , , , -1 ) - ::oParent:AddChild( SELF ) + RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbptoolbar.prg b/harbour/contrib/hbxbp/xbptoolbar.prg index e65ad88699..b932cc8953 100644 --- a/harbour/contrib/hbxbp/xbptoolbar.prg +++ b/harbour/contrib/hbxbp/xbptoolbar.prg @@ -150,9 +150,10 @@ METHOD XbpToolbar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ELSE RETURN Self ENDIF + ::oParent := oPar - ::oWidget := QToolBar():new( oPar:oWidget ) - oPar:oWidget:addToolBar_1( ::pWidget ) + ::oWidget := QToolBar():new( ::oParent:oWidget ) + ::oParent:oWidget:addToolBar_1( ::oWidget ) IF ::imageWidth > 0 .and. ::imageHeight > 0 ::oWidget:setIconSize( QSize():new( ::imageWidth, ::imageHeight ) ) @@ -184,8 +185,8 @@ METHOD XbpToolbar:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) IF ::visible ::show() ENDIF - ::oParent:AddChild( SELF ) + RETURN Self /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index fcc5525456..8f9d1132d2 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -266,6 +266,12 @@ CLASS XbpWindow INHERIT XbpPartHandler ACCESS pEvents INLINE hbxbp_GetEventsPtr() METHOD className() INLINE __objGetClsName( Self ) + + /* Harbour Extension */ + DATA qLayout + DATA nLayout + METHOD hbLayout( nTypeLayout ) SETGET + ENDCLASS /*----------------------------------------------------------------------*/ @@ -499,6 +505,11 @@ HBXBP_DBG( hb_threadId(),"Destroy[ B ] "+pad(__ObjGetClsName( self ),12)+ IF(emp ::qtObject:destroy() ::qtObject := NIL ENDIF + + IF !empty( ::qLayout ) + ::qLayout := NIL + ENDIF + ::oWidget := NIL #if 0 @@ -1869,6 +1880,43 @@ METHOD XbpWindow:sendMessage()// nMessage, nlParam, nwParam ) RETURN self +/*----------------------------------------------------------------------*/ + +METHOD XbpWindow:hbLayout( nTypeLayout ) + LOCAL lApply := .f. + LOCAL oldLayout, oXbp + + oldLayout := ::nLayout + + IF hb_isNumeric( nTypeLayout ) .AND. nTypeLayout > 0 .AND. nTypeLayout <= HBPLAYOUT_TYPE_MAX + ::nLayout := nTypeLayout + lApply := .t. + ELSEIF !empty( ::nLayout ) + lApply := .t. + ENDIF + + IF lApply + IF !empty( ::qLayout ) + ::qLayout := NIL + ENDIF + DO CASE + CASE ::nLayout == HBPLAYOUT_TYPE_HORZBOX + ::qLayout := QHBoxLayout():new() + CASE ::nLayout == HBPLAYOUT_TYPE_VERTBOX + ::qLayout := QVBoxLayout():new() + CASE ::nLayout == HBPLAYOUT_TYPE_GRID + ::qLayout := QGridLayout():new() + CASE ::nLayout == HBPLAYOUT_TYPE_FORM + ::qLayout := QFormLayout():new() + ENDCASE + ::oWidget:setLayout( ::qLayout ) + FOR EACH oXbp IN ::aChildren + ::qLayout:addWidget( oXbp:oWidget ) + NEXT + ENDIF + + RETURN oldLayout + /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/