diff --git a/harbour/ChangeLog b/harbour/ChangeLog index cbd5531aa9..ba3b8571c3 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,25 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-21 11:42 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/hbxbp/xbpcombobox.prg + ! Changed inheritance to avoid duplicate objects. + + * harbour/contrib/hbxbp/xbpdataref.prg + ! SetData() method normalized. + + * harbour/contrib/hbxbp/xbptabpage.prg + ! Commented out hide(), show() calls. Not needed for QT. + + * harbour/contrib/hbxbp/xbpwindow.prg + ! Optimizations. + + * harbour/contrib/hbxbp/xbptreeview.prg + + Implemented XbpTreeView() class - a work-in-progress but basics working. + + * harbour/contrib/hbxbp/tests/demoxbp.prg + + Demonstrated XbpTreeView() implementation. Please review. + 2009-06-21 13:05 UTC+0200 Viktor Szakats (harbour.01 syenar.hu) * INSTALL * make_gnu.bat diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index 155f83fe2c..7a90888d3d 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -125,13 +125,16 @@ PROCEDURE BuildADialog() /* Install Combo Box */ Build_ComboBox( oDlg:drawingArea ) + /* Install TreeView */ + Build_TreeView( aTabs[ 4 ] ) + /* Present the dialog on the screen */ oDlg:Show() /* Enter Xbase++ Event Loop - still with limited functionality but working */ DO WHILE .t. nEvent := AppEvent( @mp1, @mp2, @oXbp ) - IF nEvent == xbeP_Close .or. ( nEvent == xbeP_Keyboard .and. mp1 == 81 ) + IF nEvent == xbeP_Close .or. ( nEvent == xbeP_Keyboard .and. ( mp1 == 81 .or. mp1 == 113 ) ) EXIT ENDIF oXbp:handleEvent( nEvent, mp1, mp2 ) @@ -148,6 +151,12 @@ PROCEDURE AppSys() RETURN /*----------------------------------------------------------------------*/ +#ifdef __XPP__ +FUNCTION Hb_OutDebug();RETURN nil +FUNCTION Hb_Symbol_Unused();RETURN nil +FUNCTION Hb_NtoS( n );RETURN ltrim( str( n ) ) +#endif +/*----------------------------------------------------------------------*/ STATIC FUNCTION GuiStdDialog( cTitle ) LOCAL oDlg @@ -387,7 +396,7 @@ FUNCTION Build_RadioButton( oStatic ) /*----------------------------------------------------------------------*/ FUNCTION Build_TabPages( oDlg ) - LOCAL oTab1, oTab2, oTab3 + LOCAL oTab1, oTab2, oTab3, oTab4 LOCAL nHeight := 380 // First tab page is maximized @@ -396,20 +405,18 @@ FUNCTION Build_TabPages( oDlg ) /* comment our following line to position tabs at the bottom */ //oTab1:type := XBPTABPAGE_TAB_BOTTOM oTab1:minimized := .F. - oTab1:caption := "Customer" + oTab1:caption := "ListView" oTab1:create() - oTab1:TabActivate := {|| oTab2:minimize(), oTab3:minimize(), oTab1:maximize() } + oTab1:TabActivate := {|| oTab2:minimize(), oTab3:minimize(), oTab4:minimize(), oTab1:maximize() } oTab1:setColorBG( GraMakeRGBColor( {198,198,198} ) ) // Second tab page is minimized oTab2 := XbpTabPage():new( oDlg:drawingArea, , { 510, 20 }, { 360, nHeight } ) - oTab2:caption := "Order" + oTab2:caption := "XbpMLE" oTab2:preOffset := 20 oTab2:postOffset := 60 oTab2:create() - oTab2:TabActivate := ; - {|| oTab1:minimize(), oTab3:minimize(),; - oTab2:maximize() } + oTab2:TabActivate := {|| oTab1:minimize(), oTab3:minimize(), oTab4:minimize(), oTab2:maximize() } // Third tab page is minimized oTab3 := XbpTabPage():new( oDlg:drawingArea, , { 510, 20 }, { 360, nHeight } ) @@ -418,9 +425,18 @@ FUNCTION Build_TabPages( oDlg ) oTab3:postOffset := 40 oTab3:create() oTab3:TabActivate := ; - {|x,y,oTab| x := y, oTab1:minimize(), oTab2:minimize(), oTab3:maximize() } + {|x,y,oTab| x := y, oTab1:minimize(), oTab2:minimize(), oTab4:minimize(), oTab3:maximize() } - RETURN { oTab1, oTab2, oTab3 } + // Third tab page is minimized + oTab4 := XbpTabPage():new( oDlg:drawingArea, , { 510, 20 }, { 360, nHeight } ) + oTab4:caption := "TreeView" + oTab4:preOffset := 60 + oTab4:postOffset := 20 + oTab4:create() + oTab4:TabActivate := ; + {|x,y,oTab| x := y, oTab1:minimize(), oTab2:minimize(), oTab3:minimize(), oTab4:maximize() } + + RETURN { oTab1, oTab2, oTab3, oTab4 } /*----------------------------------------------------------------------*/ @@ -595,7 +611,7 @@ STATIC FUNCTION RGB( r, g, b ) STATIC FUNCTION Build_ComboBox( oWnd ) LOCAL oCombo, i, bAction - LOCAL cDay := "ZZZZMonday" + LOCAL cDay := "< Monday >" LOCAL aDays := { "Monday" , "Tuesday" , "Wednesday", "Thursday", ; "Friday" , "Saturday" , "Sunday" } LOCAL aPNG := { 'copy','cut','new','open','paste','save','new' } @@ -624,11 +640,89 @@ STATIC FUNCTION Build_ComboBox( oWnd ) // Copy data from array to combo box, then discard array FOR i := 1 TO 7 oCombo:addItem( aDays[ i ] ) + #ifdef __HARBOUR__ /* the command below is not Xbase++ compatible - will be documented while extended */ oCombo:setIcon( i, aPNG[ i ]+'.png' ) + #endif NEXT oCombo:XbpSLE:setData() RETURN nil /*----------------------------------------------------------------------*/ + +FUNCTION Build_TreeView( oWnd ) + LOCAL i + LOCAL oTree := XbpTreeView():new( oWnd, , {10,10}, {oWnd:currentSize()[1]-25,oWnd:currentSize()[2]-45} ) + + oTree:hasLines := .T. + oTree:hasButtons := .T. + oTree:create() + + FOR i := 1 TO 5 + WorkAreaInfo( oTree, i ) + NEXT + + RETURN + + ** Build the tree structure for a work area + +PROCEDURE WorkAreaInfo( oTree, iIndex ) + LOCAL oArea, oStatus, oStruct + + // First level in the tree starts with oTree:rootItem + oArea := oTree:rootItem:addItem( 'Alias '+hb_ntos( iIndex ) ) + + // Second level in the tree begins with a XbpTreeViewItem + // Create XbpTreeViewItem explicitly (1st possibility) + oStatus := XbpTreeViewItem():new() + oStatus:caption := "STATUS" + oStatus:create() + + oArea:addItem( oStatus ) + + // Create XbpTreeViewItem implicitly (2nd possibility) + oStruct := oArea:addItem( "STRUCTURE" ) + + // Create third level in the tree + WAStatus( oStatus, iIndex ) + WAStruct( oStruct, iIndex ) + + RETURN + + ** Third level -> status information + +PROCEDURE WAStatus( oItem, iIndex ) + oItem:addItem( "Bof() = " + IIf( iIndex%2 == 0, ".T.", ".F." ) ) + oItem:addItem( "Eof() = " + IIf( iIndex%3 == 0, ".T.", ".F." ) ) + oItem:addItem( "Found() = " + IIf( iIndex%4 == 0, ".T.", ".F." ) ) + oItem:addItem( "Recno() = " + Ltrim( Str( iIndex ) ) ) + oItem:addItem( "LastRec() =" + Ltrim( Str( iIndex )+'....PPP' ) ) + + RETURN + + ** Third level -> field information + +PROCEDURE WAStruct( oItem, iIndex ) + LOCAL aStr := {} + + aadd( aStr, { 'Name__'+hb_ntos( iIndex ), 'C', 20, 0 } ) + aadd( aStr, { 'Birth' , 'D', 8, 0 } ) + aadd( aStr, { 'Salary', 'N', 10, 2 } ) + + AEval( aStr, ; + {|a,i,oSub| oSub := oItem:addItem( "FIELD_NAME = " + a[1] ), FieldStruct( oSub, a ) } ) + + RETURN + + ** Create fourth level in the tree + +PROCEDURE FieldStruct( oItem, aField ) + + oItem:addItem( "FIELD_TYPE = " + aField[2] ) + oItem:addItem( "FIELD_LEN = " + Str( aField[3], 3 ) ) + oItem:addItem( "FIELD_DEC = " + Str( aField[4], 3 ) ) + + RETURN + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpcombobox.prg b/harbour/contrib/hbxbp/xbpcombobox.prg index 901d6e8054..baadf2a452 100644 --- a/harbour/contrib/hbxbp/xbpcombobox.prg +++ b/harbour/contrib/hbxbp/xbpcombobox.prg @@ -74,7 +74,8 @@ /*----------------------------------------------------------------------*/ -CLASS XbpComboBox INHERIT XbpSLE, XbpListBox +//CLASS XbpComboBox INHERIT XbpSLE, XbpListBox +CLASS XbpComboBox INHERIT XbpWindow DATA type INIT XBPCOMBO_DROPDOWN DATA drawMode INIT XBP_DRAW_NORMAL @@ -88,10 +89,6 @@ CLASS XbpComboBox INHERIT XbpSLE, XbpListBox METHOD listBoxFocus( lFocus ) VIRTUAL // -> lOldFocus METHOD sleSize() VIRTUAL // -> aOldSize - DATA sl_xbePDrawItem - ACCESS drawItem INLINE ::sl_xbePDrawItem - ASSIGN drawItem( bBlock ) INLINE ::sl_xbePDrawItem := bBlock - METHOD addItem( cItem ) INLINE ::oWidget:addItem( cItem ) METHOD setIcon( nItem,cIcon ) INLINE ::oWidget:setItemIcon( nItem-1,cIcon ) @@ -107,6 +104,7 @@ CLASS XbpComboBox INHERIT XbpSLE, XbpListBox ::oStrModel:setStringList( QT_PTROF( ::oStrList ) ) #endif + DATA oSLE ACCESS XbpSLE INLINE ::oSLE DATA oLB @@ -120,6 +118,10 @@ CLASS XbpComboBox INHERIT XbpSLE, XbpListBox ACCESS itemSelected INLINE ::sl_itemSelected ASSIGN itemSelected( bBlock ) INLINE ::sl_itemSelected := bBlock + DATA sl_xbePDrawItem + ACCESS drawItem INLINE ::sl_xbePDrawItem + ASSIGN drawItem( bBlock ) INLINE ::sl_xbePDrawItem := bBlock + ENDCLASS /*----------------------------------------------------------------------*/ @@ -140,12 +142,14 @@ METHOD XbpComboBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oLB := XbpListBox():new():create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) ::oWidget := QComboBox():New( ::pParent ) + ::oWidget:setLineEdit( ::XbpSLE:oWidget:pPtr ) ::oWidget:setEditable( ::XbpSLE:editable ) ::oWidget:setFrame( ::XbpSLE:border ) ::connect( ::pWidget, "highlighted(int)" , {|o,i| ::exeBlock( 1,i,o ) } ) - ::connect( ::pWidget, "currentIndexChanged(int)", {|o,i| ::exeBlock( 2,i,o ) } ) + //::connect( ::pWidget, "currentIndexChanged(int)", {|o,i| ::exeBlock( 2,i,o ) } ) + ::connect( ::pWidget, "activated(int)" , {|o,i| ::exeBlock( 2,i,o ) } ) ::setPosAndSize() IF ::visible diff --git a/harbour/contrib/hbxbp/xbpdataref.prg b/harbour/contrib/hbxbp/xbpdataref.prg index df33a48500..09ae0d5b68 100644 --- a/harbour/contrib/hbxbp/xbpdataref.prg +++ b/harbour/contrib/hbxbp/xbpdataref.prg @@ -144,8 +144,10 @@ METHOD XbpDataRef:setData( xValue, mp2 ) HB_SYMBOL_UNUSED( mp2 ) +//hb_outDebug( cClass +' '+ ::cargo +"..."+ IF(empty(xValue)," empty ",valtype(xValue)) ) + IF hb_isBlock( ::dataLink ) - ::sl_editBuffer := eval( ::dataLink ) + ::sl_editBuffer := eval( ::dataLink, xValue ) ELSEIF xValue <> NIL ::sl_editBuffer := xValue diff --git a/harbour/contrib/hbxbp/xbptabpage.prg b/harbour/contrib/hbxbp/xbptabpage.prg index 740afc6c72..5ca1f7d0cb 100644 --- a/harbour/contrib/hbxbp/xbptabpage.prg +++ b/harbour/contrib/hbxbp/xbptabpage.prg @@ -190,13 +190,13 @@ METHOD XbpTabPage:tabActivate( xParam ) /*----------------------------------------------------------------------*/ METHOD XbpTabPage:minimize() - ::hide() + //::hide() RETURN .f. /*----------------------------------------------------------------------*/ METHOD XbpTabPage:maximize() - ::show() + //::show() RETURN .t. /*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg index 1d128964c2..7e61f03835 100644 --- a/harbour/contrib/hbxbp/xbptreeview.prg +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -134,11 +134,13 @@ METHOD XbpTreeView:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + LOCAL oW ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) - ::oWidget := QTreeView():new( ::pParent ) - + ::oWidget := QTreeWidget():new( ::pParent ) + ::oWidget:setColumnCount( 1 ) + ::oWidget:setHeaderHidden( .t. ) #if 0 IF ::alwaysShowSelection @@ -150,12 +152,14 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) IF ::hasLines ::style += TVS_HASLINES + TVS_LINESATROOT ENDIF - - //::oRootItem := WvgTreeViewItem():New() - ::oRootItem:hTree := ::hWnd - ::oRootItem:oWnd := Self #endif + ::oRootItem := XbpTreeViewItem():New() + ::oRootItem:hTree := ::oWidget + + oW := QTreeWidgetItem() + oW:pPtr := ::oWidget:invisibleRootItem() + ::oRootItem:oItemWidget := oW ::setPosAndSize() IF ::visible @@ -166,6 +170,16 @@ METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) /*----------------------------------------------------------------------*/ +METHOD XbpTreeView:ExeBlock( nMsg, p1, p2 ) + + HB_SYMBOL_UNUSED( nMsg ) + HB_SYMBOL_UNUSED( p1 ) + HB_SYMBOL_UNUSED( p2 ) + + RETURN .t. + +/*----------------------------------------------------------------------*/ + METHOD XbpTreeView:handleEvent( nEvent, mp1, mp2 ) HB_SYMBOL_UNUSED( nEvent ) @@ -174,70 +188,6 @@ METHOD XbpTreeView:handleEvent( nEvent, mp1, mp2 ) RETURN HBXBP_EVENT_UNHANDLED -#if 0 -METHOD XbpTreeView:handleEvent( mp1, mp2, nEvent ) - LOCAL hItemSelected, hParentOfSelected, n, aNMHdr - LOCAL cParent := space( 20 ) - LOCAL cText := space( 20 ) - LOCAL aHdr - - SWITCH nMessage - - CASE HB_GTE_RESIZED - ::sendMessage( WM_SIZE, 0, 0 ) - RETURN EVENT_HANDELLED - - CASE HB_GTE_COMMAND - IF hb_isBlock( ::sl_lbClick ) - eval( ::sl_lbClick, NIL, NIL, self ) - RETURN EVENT_HANDELLED - ENDIF - EXIT - - CASE HB_GTE_NOTIFY - aHdr := Wvg_GetNMHdrInfo( aNM[ 2 ] ) - aNMHdr := Wvg_GetNMTreeViewInfo( aNM[ 2 ] ) - - DO CASE - - CASE aHdr[ NMH_code ] == NM_DBLCLK .OR. aHdr[ NMH_code ] == NM_RETURN - ::editBuffer := ::oItemSelected - IF hb_isBlock( ::sl_itemSelected ) - Eval( ::sl_itemSelected, ::oItemSelected, { 0,0,0,0 }, Self ) - ENDIF - - RETURN .t. - - CASE aNMHdr[ NMH_code ] == TVN_SELCHANGED - Wvg_TreeView_GetSelectionInfo( ::hWnd, aNM[ 2 ], @cParent, @cText, @hParentOfSelected, @hItemSelected ) - - ::hParentSelected := hParentOfSelected - ::hItemSelected := hItemSelected - ::textParentSelected := trim( cParent ) - ::textItemSelected := trim( cText ) - - IF ( n := ascan( ::aItems, {|o| o:hItem == hItemSelected } ) ) > 0 - ::oItemSelected := ::aItems[ n ] - ELSE - ::oItemSelected := NIL - ENDIF - - IF hb_isBlock( ::sl_itemMarked ) - Eval( ::sl_itemMarked, ::oItemSelected, { 0,0,0,0 }, Self ) - ENDIF - - RETURN .t. - - OTHERWISE - RETURN .f. - - ENDCASE - - EXIT - END - - RETURN EVENT_UNHANDELLED -#endif /*----------------------------------------------------------------------*/ METHOD XbpTreeView:destroy() @@ -307,6 +257,9 @@ METHOD XbpTreeView:itemSelected( xParam ) /*----------------------------------------------------------------------*/ CLASS XbpTreeViewItem + DATA oItemWidget + ACCESS pItemWidget INLINE IF( hb_isObject( ::oItemWidget ), ::oItemWidget:pPtr, NIL ) + DATA caption INIT "" DATA dllName INIT NIL DATA expandedImage INIT -1 @@ -341,6 +294,29 @@ CLASS XbpTreeViewItem ENDCLASS /*----------------------------------------------------------------------*/ +METHOD XbpTreeViewItem:addItem( xItem ) + Local oItem + + IF valtype( xItem ) == 'C' + oItem := XbpTreeViewItem():New() + + oItem:oParent := self + oItem:caption := xItem + oItem:oItemWidget := QTreeWidgetItem():new() + oItem:oItemWidget:setText( 0, oItem:caption ) + + ::oItemWidget:addChild( oItem:oItemWidget:pPtr ) + ELSE + xItem:oParent := self + ::oItemWidget:addChild( xItem:oItemWidget:pPtr ) + + RETURN xItem + ENDIF + + RETURN oItem + +/*----------------------------------------------------------------------*/ + METHOD XbpTreeViewItem:new() RETURN Self @@ -349,6 +325,9 @@ METHOD XbpTreeViewItem:new() METHOD XbpTreeViewItem:create() + ::oItemWidget := QTreeWidgetItem():new() + ::oItemWidget:setText( 0,::caption ) + RETURN Self /*----------------------------------------------------------------------*/ @@ -402,26 +381,6 @@ METHOD XbpTreeViewItem:setMarkedImage( nResIdoBitmap ) /*----------------------------------------------------------------------*/ -METHOD XbpTreeViewItem:addItem( cCaption ) - Local oItem, hParent - - oItem := XbpTreeViewItem():New() - - oItem:hTree := ::hTree - oItem:oParent := self - oItem:caption := cCaption - oItem:oWnd := ::oWnd - - hParent := if( hb_isObject( oItem:oParent ), oItem:oParent:hItem, NIL ) - - //oItem:hItem := Wvg_TreeView_AddItem( oItem:hTree, hParent, oItem:caption ) - - aadd( oItem:oWnd:aItems, oItem ) - - RETURN oItem - -/*----------------------------------------------------------------------*/ - METHOD XbpTreeViewItem:delItem() RETURN NIL @@ -445,3 +404,4 @@ METHOD XbpTreeViewItem:insItem() RETURN NIL /*----------------------------------------------------------------------*/ + diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index ee9953dbf9..0789329be0 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -77,7 +77,7 @@ CLASS XbpWindow INHERIT XbpPartHandler - DATA cargo INIT 'HEHEHE' + DATA cargo INIT "" /* CONFIGURATION */ DATA animate INIT .F.