From e9e02b01f52ef4f87bfd137fd060046ff7d3b43d Mon Sep 17 00:00:00 2001 From: Pritpal Bedi Date: Sun, 21 Jun 2009 04:10:13 +0000 Subject: [PATCH] 2009-06-20 21:05 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbxbp/Makefile * harbour/contrib/hbxbp/xbp.ch + harbour/contrib/hbxbp/xbpcombobox.prg * harbour/contrib/hbxbp/xbpdataref.prg * harbour/contrib/hbxbp/xbpsle.prg + harbour/contrib/hbxbp/xbptreeview.prg * harbour/contrib/hbxbp/xbpwindow.prg + Implemented XbpComboBox() class. + Added XbpTreeView() class skelton. * harbour/contrib/hbxbp/tests/demoxbp.prg + Demonstrated XbpComboBox() implementation. NOTE: I am not sure about the way I am simulating Xbase++ class behavior. Can someone review xbpcombobox.prg and see if this can be improved. I am not well equipped as far as classes can be exploited to full extent. --- harbour/ChangeLog | 19 + harbour/contrib/hbxbp/Makefile | 2 + harbour/contrib/hbxbp/tests/demoxbp.prg | 49 ++- harbour/contrib/hbxbp/xbp.ch | 3 + harbour/contrib/hbxbp/xbpcombobox.prg | 184 ++++++++++ harbour/contrib/hbxbp/xbpdataref.prg | 14 +- harbour/contrib/hbxbp/xbpsle.prg | 3 +- harbour/contrib/hbxbp/xbptreeview.prg | 447 ++++++++++++++++++++++++ harbour/contrib/hbxbp/xbpwindow.prg | 2 + 9 files changed, 718 insertions(+), 5 deletions(-) create mode 100644 harbour/contrib/hbxbp/xbpcombobox.prg create mode 100644 harbour/contrib/hbxbp/xbptreeview.prg diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 099e57722a..36abc4658e 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -17,6 +17,25 @@ past entries belonging to author(s): Viktor Szakats. */ +2009-06-20 21:05 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) + * harbour/contrib/hbxbp/Makefile + * harbour/contrib/hbxbp/xbp.ch + + harbour/contrib/hbxbp/xbpcombobox.prg + * harbour/contrib/hbxbp/xbpdataref.prg + * harbour/contrib/hbxbp/xbpsle.prg + + harbour/contrib/hbxbp/xbptreeview.prg + * harbour/contrib/hbxbp/xbpwindow.prg + + Implemented XbpComboBox() class. + + Added XbpTreeView() class skelton. + + * harbour/contrib/hbxbp/tests/demoxbp.prg + + Demonstrated XbpComboBox() implementation. + + NOTE: I am not sure about the way I am simulating Xbase++ + class behavior. Can someone review xbpcombobox.prg + and see if this can be improved. I am not well equipped + as far as classes can be exploited to full extent. + 2009-06-20 21:01 UTC-0800 Pritpal Bedi (pritpal@vouchcac.com) * harbour/contrib/hbqt/hbqt_slots.cpp ! A fix non-sense. diff --git a/harbour/contrib/hbxbp/Makefile b/harbour/contrib/hbxbp/Makefile index d6eea26026..43475436e9 100644 --- a/harbour/contrib/hbxbp/Makefile +++ b/harbour/contrib/hbxbp/Makefile @@ -57,6 +57,8 @@ PRG_SOURCES=\ xbpsle.prg \ xbpmle.prg \ xbpspinbutton.prg \ + xbpcombobox.prg \ + xbptreeview.prg \ PRG_HEADERS=\ xbp.ch \ diff --git a/harbour/contrib/hbxbp/tests/demoxbp.prg b/harbour/contrib/hbxbp/tests/demoxbp.prg index 3771901f12..0892847d30 100644 --- a/harbour/contrib/hbxbp/tests/demoxbp.prg +++ b/harbour/contrib/hbxbp/tests/demoxbp.prg @@ -122,6 +122,9 @@ PROCEDURE BuildADialog() /* Install Spin Buttons */ Build_SpinButtons( aTabs[ 3 ] ) + /* Install Combo Box */ + Build_ComboBox( oDlg:drawingArea ) + /* Present the dialog on the screen */ oDlg:Show() @@ -532,7 +535,7 @@ FUNCTION Build_MLE( oWnd ) /*----------------------------------------------------------------------*/ FUNCTION Build_SpinButtons( oWnd ) - LOCAL oSpinRed, oSpinGreen, oSpinBlue, bBlock + LOCAL oSpinRed, oSpinGreen, oSpinBlue, bCallBack LOCAL nGreen := 5, nBlue := 12, nRed := 35 LOCAL nX := 230, nY := 190 @@ -580,8 +583,52 @@ FUNCTION Build_SpinButtons( oWnd ) STATIC FUNCTION RGB( r, g, b ) + HB_SYMBOL_UNUSED( r ) + HB_SYMBOL_UNUSED( g ) + HB_SYMBOL_UNUSED( b ) + // Display a static window with flashing color of rgb RETURN nil /*----------------------------------------------------------------------*/ + +STATIC FUNCTION Build_ComboBox( oWnd ) + LOCAL oCombo, i, bAction + LOCAL cDay := "ZZZZMonday" + LOCAL aDays := { "Monday" , "Tuesday" , "Wednesday", "Thursday", ; + "Friday" , "Saturday" , "Sunday" } + LOCAL aPNG := { 'copy','cut','new','open','paste','save','new' } + + // Create combo box with drop down list box + oCombo := XbpCombobox():new() + oCombo:type := XBPCOMBO_DROPDOWN + //oCombo:editable := .f. + oCombo:create( oWnd,, {30, 20}, {200, 30} ) + + // Link data from entry field to LOCAL variable + oCombo:XbpSLE:dataLink := {|x| IIf( x==NIL, cDay, cDay := x ) } + oCombo:XbpSLE:setData() + + // Code block for selection: + // - assign to LOCAL variable using :getData() + // - display LOCAL variable using DispoutAt() + bAction := {|mp1, mp2, obj| obj:XbpSLE:getData(), hb_outDebug( 'Highlighted: '+cDay ) } + + // Assign code block for selection with Up and Down keys + oCombo:ItemMarked := bAction + + // Assign code block for selection by left mouse click in list box + oCombo:ItemSelected := {|mp1, mp2, obj| obj:XbpSLE:getData(), hb_outDebug( 'Selected: '+cDay ) } + + // Copy data from array to combo box, then discard array + FOR i := 1 TO 7 + oCombo:addItem( aDays[ i ] ) + /* the command below is not Xbase++ compatible - will be documented while extended */ + oCombo:setIcon( i, aPNG[ i ]+'.png' ) + NEXT + + oCombo:XbpSLE:setData() + RETURN nil + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbp.ch b/harbour/contrib/hbxbp/xbp.ch index 78e537f0bc..a8a4709464 100644 --- a/harbour/contrib/hbxbp/xbp.ch +++ b/harbour/contrib/hbxbp/xbp.ch @@ -143,6 +143,9 @@ #define XBPMENUBAR_MIA_DEFAULT 65536 #define XBPMENUBAR_MIA_OWNERDRAW 131072 +#define XBPCOMBO_SIMPLE 1 +#define XBPCOMBO_DROPDOWN 2 +#define XBPCOMBO_DROPDOWNLIST 3 #define _XBP_CH #endif diff --git a/harbour/contrib/hbxbp/xbpcombobox.prg b/harbour/contrib/hbxbp/xbpcombobox.prg new file mode 100644 index 0000000000..901d6e8054 --- /dev/null +++ b/harbour/contrib/hbxbp/xbpcombobox.prg @@ -0,0 +1,184 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Xbp*Classes + * + * Copyright 2009 Pritpal Bedi + * http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* + * EkOnkar + * ( The LORD is ONE ) + * + * Xbase++ xbpComboBox compatible Class + * + * Pritpal Bedi + * 20Jun2009 + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "hbclass.ch" +#include "common.ch" + +#include "xbp.ch" +#include "appevent.ch" +#include "hbqt.ch" + +/*----------------------------------------------------------------------*/ + +CLASS XbpComboBox INHERIT XbpSLE, XbpListBox + + DATA type INIT XBPCOMBO_DROPDOWN + DATA drawMode INIT XBP_DRAW_NORMAL + + METHOD new() + METHOD create() + METHOD configure() VIRTUAL + METHOD destroy() + METHOD exeBlock() + + 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 ) + + #if 0 + METHOD clear() INLINE ::oStrList:clear(),; + ::oStrModel:setStringList( QT_PTROF( ::oStrList ) ) + METHOD delItem( nIndex ) INLINE ::oStrList:removeAt( nIndex-1 ),; + ::oStrModel:setStringList( QT_PTROF( ::oStrList ) ) + METHOD getItem( nIndex ) INLINE ::oStrList:at( nIndex-1 ) + METHOD insItem( nIndex, cItem ) INLINE ::oStrList:insert( nIndex-1, cItem ),; + ::oStrModel:setStringList( QT_PTROF( ::oStrList ) ) + METHOD setItem( nIndex, cItem ) INLINE ::oStrModel:replace( nIndex-1, cItem ),; + ::oStrModel:setStringList( QT_PTROF( ::oStrList ) ) + #endif + + DATA oSLE + ACCESS XbpSLE INLINE ::oSLE + DATA oLB + ACCESS XbpListBox INLINE ::oLB + + DATA sl_itemMarked + ACCESS itemMarked INLINE ::sl_itemMarked + ASSIGN itemMarked( bBlock ) INLINE ::sl_itemMarked := bBlock + + DATA sl_itemSelected + ACCESS itemSelected INLINE ::sl_itemSelected + ASSIGN itemSelected( bBlock ) INLINE ::sl_itemSelected := bBlock + + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpComboBox:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::oSLE := XbpSLE():new():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 ) } ) + + ::setPosAndSize() + IF ::visible + ::show() + ENDIF + ::oParent:AddChild( SELF ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpComboBox:destroy() + + ::xbpWindow:destroy() + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpComboBox:exeBlock( nMsg, p1 ) + + HB_SYMBOL_UNUSED( p1 ) + + DO CASE + CASE nMsg == 1 + IF hb_isBlock( ::sl_itemMarked ) + eval( ::sl_itemMarked, NIL, NIL, self ) + ENDIF + CASE nMsg == 2 + IF hb_isBlock( ::sl_itemSelected ) + eval( ::sl_itemSelected, NIL, NIL, self ) + ENDIF + ENDCASE + + RETURN .t. + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpdataref.prg b/harbour/contrib/hbxbp/xbpdataref.prg index 823c7cc9e3..df33a48500 100644 --- a/harbour/contrib/hbxbp/xbpdataref.prg +++ b/harbour/contrib/hbxbp/xbpdataref.prg @@ -114,11 +114,14 @@ METHOD XbpDataRef:getData() CASE cClass $ "XBPSLE,XBPMLE" ::sl_editBuffer := ::oWidget:text() + // CASE cClass $ "XBPCOMBOBOX" + //::sl_editBuffer := ::oWidget:itemText() + CASE cClass == "XBPRADIOBUTTON" ::sl_editBuffer := ::oWidget:isChecked() -// CASE cClass == "XBPLISTBOX" -// RETURN ::nCurSelected + // CASE cClass == "XBPLISTBOX" + // RETURN ::nCurSelected CASE cClass == "XBPSCROLLBAR" ::sl_editBuffer := ::oWidget:value() @@ -171,7 +174,12 @@ METHOD XbpDataRef:setData( xValue, mp2 ) IF hb_isChar( ::sl_editBuffer ) ::oWidget:setText( ::sl_editBuffer ) ENDIF - + #if 0 + CASE cClass $ "XBPCOMBOBOX" + IF hb_isChar( ::sl_editBuffer ) + ::oWidget:setText( ::sl_editBuffer ) + ENDIF + #endif CASE cClass == "XBPSPINBUTTON" ::oWidget:setValue( ::sl_editBuffer ) diff --git a/harbour/contrib/hbxbp/xbpsle.prg b/harbour/contrib/hbxbp/xbpsle.prg index bd9671dbe4..1f34b022e5 100644 --- a/harbour/contrib/hbxbp/xbpsle.prg +++ b/harbour/contrib/hbxbp/xbpsle.prg @@ -155,7 +155,7 @@ METHOD XbpSLE:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) // ::connect( ::pWidget, "editingFinished()" , {| | ::exeBlock( 2 ) } ) // ::connect( ::pWidget, "returnPressed()" , {| | ::exeBlock( 3 ) } ) // ::connect( ::pWidget, "selectionChanged()" , {| | ::exeBlock( 4 ) } ) - // ::connect( ::pWidget, "textChanged(QString)" , {|o,s | ::exeBlock( 5, s, o ) } ) + ::connect( ::pWidget, "textChanged(QString)" , {|o,s | ::exeBlock( 5, s, o ) } ) ::connect( ::pWidget, "textEdited(QString)" , {|o,s | ::exeBlock( 6, s, o ) } ) ::setPosAndSize() @@ -174,6 +174,7 @@ METHOD XbpSLE:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) METHOD XbpSLE:exeBlock( nMsg, p1, p2 ) +//hb_OutDebug( 'XbpSLE: '+hb_ntos( nMsg ) ) HB_SYMBOL_UNUSED( p1 ) DO CASE diff --git a/harbour/contrib/hbxbp/xbptreeview.prg b/harbour/contrib/hbxbp/xbptreeview.prg new file mode 100644 index 0000000000..1d128964c2 --- /dev/null +++ b/harbour/contrib/hbxbp/xbptreeview.prg @@ -0,0 +1,447 @@ +/* + * $Id$ + */ + +/* + * Harbour Project source code: + * Source file for the Xbp*Classes + * + * Copyright 2009 Pritpal Bedi + * http://www.harbour-project.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2, or (at your option) + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place, Suite 330, + * Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/). + * + * As a special exception, the Harbour Project gives permission for + * additional uses of the text contained in its release of Harbour. + * + * The exception is that, if you link the Harbour libraries with other + * files to produce an executable, this does not by itself cause the + * resulting executable to be covered by the GNU General Public License. + * Your use of that executable is in no way restricted on account of + * linking the Harbour library code into it. + * + * This exception does not however invalidate any other reasons why + * the executable file might be covered by the GNU General Public License. + * + * This exception applies only to the code released by the Harbour + * Project under the name Harbour. If you copy code from other + * Harbour Project or Free Software Foundation releases into a copy of + * Harbour, as the General Public License permits, the exception does + * not apply to the code that you add in this way. To avoid misleading + * anyone as to the status of such modified files, you must delete + * this exception notice from them. + * + * If you write modifications of your own for Harbour, it is your choice + * whether to permit this exception to apply to your modifications. + * If you do not wish that, delete this exception notice. + * + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/* + * EkOnkar + * ( The LORD is ONE ) + * + * Xbase++ xbpTreeView compatible Class + * + * Pritpal Bedi + * 20Jun2009 + */ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ +/*----------------------------------------------------------------------*/ + +#include "hbclass.ch" +#include "common.ch" + +#include "xbp.ch" +#include "appevent.ch" +#include "hbqt.ch" + +/*----------------------------------------------------------------------*/ + +CLASS XbpTreeView INHERIT XbpWindow, XbpDataRef + + DATA alwaysShowSelection INIT .F. + DATA hasButtons INIT .F. + DATA hasLines INIT .F. + + DATA aItems INIT {} + + DATA oRootItem + ACCESS rootItem() INLINE ::oRootItem + + METHOD new() + METHOD create() + METHOD configure() + METHOD destroy() + METHOD handleEvent() + METHOD exeBlock() + + METHOD itemFromPos( aPos ) + + DATA sl_itemCollapsed + DATA sl_itemExpanded + DATA sl_itemMarked + DATA sl_itemSelected + + METHOD itemCollapsed() SETGET + METHOD itemExpanded() SETGET + METHOD itemMarked() SETGET + + DATA oItemSelected + ACCESS itemSelected INLINE ::sl_itemSelected + ASSIGN itemSelected( bBlock ) INLINE ::sl_itemSelected := bBlock + + DATA hParentSelected + DATA hItemSelected + DATA textParentSelected INIT "" + DATA textItemSelected INIT "" + + #if 0 + METHOD setColorFG( nRGB ) INLINE WVG_TreeView_SetTextColor( ::hWnd, nRGB ) + METHOD setColorBG( nRGB ) INLINE WVG_TreeView_SetBkColor( ::hWnd, nRGB ) + METHOD setColorLines( nRGB ) INLINE WVG_TreeView_SetLineColor( ::hWnd, nRGB ) + + + METHOD showExpanded( lExpanded, nLevels ) INLINE Wvg_TreeView_ShowExpanded( ::hWnd, ; + IF( hb_isNil( lExpanded ), .f., lExpanded ), nLevels ) + #endif + ENDCLASS + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::xbpWindow:new( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::xbpWindow:create( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::oWidget := QTreeView():new( ::pParent ) + + + #if 0 + IF ::alwaysShowSelection + ::style += TVS_SHOWSELALWAYS + ENDIF + IF ::hasButtons + ::style += TVS_HASBUTTONS + ENDIF + IF ::hasLines + ::style += TVS_HASLINES + TVS_LINESATROOT + ENDIF + + //::oRootItem := WvgTreeViewItem():New() + ::oRootItem:hTree := ::hWnd + ::oRootItem:oWnd := Self + #endif + + + ::setPosAndSize() + IF ::visible + ::show() + ENDIF + ::oParent:AddChild( SELF ) + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:handleEvent( nEvent, mp1, mp2 ) + + HB_SYMBOL_UNUSED( nEvent ) + HB_SYMBOL_UNUSED( mp1 ) + HB_SYMBOL_UNUSED( 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() + + ::xbpWindow:destroy() + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:configure( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + ::Initialize( oParent, oOwner, aPos, aSize, aPresParams, lVisible ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:itemFromPos( aPos ) + + HB_SYMBOL_UNUSED( aPos ) + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:itemCollapsed( xParam ) + + IF hb_isBlock( xParam ) .or. ( xParam == NIL ) + ::sl_paint := xParam + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:itemExpanded( xParam ) + + IF hb_isBlock( xParam ) .or. ( xParam == NIL ) + ::sl_itemExpanded := xParam + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeView:itemMarked( xParam ) + + IF hb_isBlock( xParam ) .or. ( xParam == NIL ) + ::sl_itemMarked := xParam + ENDIF + + RETURN Self + +/*----------------------------------------------------------------------*/ +#if 0 +METHOD XbpTreeView:itemSelected( xParam ) + + IF hb_isBlock( xParam ) .or. ( xParam == NIL ) + ::sl_itemSelected := xParam + ENDIF + + RETURN Self +#endif +/*----------------------------------------------------------------------*/ +/* Class XbpTreeViewItem */ +/*----------------------------------------------------------------------*/ +CLASS XbpTreeViewItem + + DATA caption INIT "" + DATA dllName INIT NIL + DATA expandedImage INIT -1 + DATA image INIT -1 + DATA markedImage INIT -1 + + DATA hTree + DATA hItem + DATA oParent + DATA oWnd + + METHOD new() + METHOD create() + METHOD configure() + METHOD destroy() + #if 0 + METHOD expand( lExpand ) INLINE WVG_TreeView_Expand( ::hTree, ::hItem, ; + IF( hb_isLogical( lExpand ), lExpand, .t. ) ) + #endif + METHOD isExpanded() + METHOD setCaption( cCaption ) + METHOD setExpandedImage( nResIdoBitmap ) + METHOD setImage( nResIdoBitmap ) + METHOD setMarkedImage( nResIdoBitmap ) + + METHOD addItem() + METHOD delItem() + METHOD getChildItems() + METHOD getParentItem() + METHOD insItem() + + ENDCLASS +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:new() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:create() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:configure() + + RETURN Self + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:destroy() + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:isExpanded() + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:setCaption( cCaption ) + + HB_SYMBOL_UNUSED( cCaption ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:setExpandedImage( nResIdoBitmap ) + + HB_SYMBOL_UNUSED( nResIdoBitmap ) + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:setImage( nResIdoBitmap ) + + HB_SYMBOL_UNUSED( nResIdoBitmap ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:setMarkedImage( nResIdoBitmap ) + + HB_SYMBOL_UNUSED( nResIdoBitmap ) + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +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 + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:getChildItems() + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:getParentItem() + + RETURN NIL + +/*----------------------------------------------------------------------*/ + +METHOD XbpTreeViewItem:insItem() + + RETURN NIL + +/*----------------------------------------------------------------------*/ diff --git a/harbour/contrib/hbxbp/xbpwindow.prg b/harbour/contrib/hbxbp/xbpwindow.prg index de2252f8ee..ee9953dbf9 100644 --- a/harbour/contrib/hbxbp/xbpwindow.prg +++ b/harbour/contrib/hbxbp/xbpwindow.prg @@ -77,6 +77,8 @@ CLASS XbpWindow INHERIT XbpPartHandler + DATA cargo INIT 'HEHEHE' + /* CONFIGURATION */ DATA animate INIT .F. DATA clipChildren INIT .F.