Page 1 of 3

Are there any Treeview samples with associated edit boxes?

Posted: Mon Nov 23, 2020 11:54 pm
by FWExplorer
Hi,

I'd like to build a simple pim using a Treeview as a basis, but am not certain how to start.

Kresin has a 'KS Organizer' in Harbour, but the source isn't available.

http://www.kresin.ru/en/ksorg.html

I'll reinvent the wheel if necessary, but wanted to see if there are some existing snippets that maybe associate a memo field with each node, and save the tree to a database or json or whatever.

Re: Are there any Treeview samples with associated edit boxes?

Posted: Tue Nov 24, 2020 10:24 am
by Antonio Linares
D.

work in progress:
Image

pim.prg

Code: Select all

// FiveWin PIM (personal information manager)

#include "FiveWin.ch"
#include "Splitter.ch"
#include "xbrowse.ch"

static oWnd, oBtnSave, oImageList, oMruRCs
           
//----------------------------------------------------------------------------//
                    
function Main()     
                    
   local oBar, oMenuNew
   local oBmpTiled
    
   DEFINE BITMAP oBmpTiled RESOURCE "background"

   DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
      TITLE FWVERSION + " PIM" ;
      MENU BuildMenu() MDI
                    
   DEFINE BUTTONBAR oBar SIZE 70, 70 OF oWnd 2010
                    
   DEFINE BUTTON OF oBar PROMPT "New" ;
      TOOLTIP "New" NOBORDER RESOURCE "New"
                    
   DEFINE BUTTON OF oBar PROMPT "Open" ;
      TOOLTIP "Open" NOBORDER RESOURCE "Open" ;
      ACTION OpenDataFile()
                    
   DEFINE BUTTON oBtnSave OF oBar PROMPT "Save" ;
      TOOLTIP "Save" NOBORDER RESOURCE "Save" ACTION Save()
      
   oBtnSave:Disable()   

   DEFINE BUTTON OF oBar GROUP PROMPT "Exit" ;
      TOOLTIP "Exit" NOBORDER RESOURCE "Exit" ACTION oWnd:End()

   oImageList = TImageList():New()

   oImageList:Add( TBitmap():Define( "folder",,  oWnd ),;
                   TBitmap():Define( "fldmask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "dialog",,  oWnd ),;
                   TBitmap():Define( "dlgmask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "icon",,    oWnd ),;
                   TBitmap():Define( "icomask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "bitmap",,  oWnd ),;
                   TBitmap():Define( "bmpmask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "includes",, oWnd ),;
                   TBitmap():Define( "incmask",, oWnd ) )

   DEFINE MSGBAR OF oWnd PROMPT "Personal Information Manager (c) FiveTech Software 2020" DATE KEYBOARD 2010

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON PAINT DrawTiled( hDC, oWnd, oBmpTiled )
      // VALID MsgYesNo( "Want to end ?" )

   oBmpTiled:End()
   oImageList:End()
  
return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu

   MENU oMenu 2007
      MENUITEM "&File"
      MENU
         MENUITEM "&New"  RESOURCE "new2"
         MENUITEM "&Open" RESOURCE "Open2" ;
            ACTION OpenDataFile()

         MENUITEM "&Save as..."
         SEPARATOR
    
         MENUITEM "Recent files"
         MENU
            MRU oMruRCs ;
               FILENAME ".\re.ini" ;    // .INI to manipulate. '\.' for local
               SECTION  "Recent RC files" ; // The name of the INI section
               ACTION   OpenDataFile( cMruItem ) ;   // cMruItem is automatically provided
               MESSAGE  "Open this file" ;   // The message for all of them
               SIZE     10
         ENDMENU
         
         SEPARATOR
         
         MENUITEM "&Exit..." ACTION oWnd:End() RESOURCE "Exit2"
      ENDMENU
      MENUITEM "&Edit"
      oMenu:AddMDI()
      oMenu:AddHelp( "FiveWin Resources Editor", "FiveTech 1993-2018" )
   ENDMENU

return oMenu

//----------------------------------------------------------------------------//

function Save()

   local oTreeView := oWnd:oWndActive:aControls[ 1 ]
   local cText := "", cFileName := oWnd:oWndActive:GetText()
   
   oTreeView:Scan( { | oItem | BuildXML( oItem, @cText ) } )
   
   if File( cFileName )
      if MsgYesNo( "Do you want to overwrite " + cFileName + " ?",;
                   cFileName + " already exists" )
         // MemoWrit( cFileName, cText )
         MsgInfo( cText )
         oBtnSave:Disable()
      endif   
   else
      MemoWrit( cFileName, cText )
      oBtnSave:Disable()
   endif 
   
return nil   

//----------------------------------------------------------------------------//

function BuildXML( oItem, cText )

   if oItem:oParent != nil
      cText += CRLF
   endif
   
   cText += "<" + oItem:cPrompt + ">"

   if ! Empty( oItem:Cargo )
      cText += oItem:Cargo
   endif    
   
   if Len( oItem:aItems ) == 0 
      cText += "</" + oItem:cPrompt + ">"
   endif      

   if oItem:oParent != nil
      if oItem == ATail( oItem:oParent:aItems )
         cText += CRLF + "</" + oItem:oParent:cPrompt + ">"
      endif
   endif   

return .F.  // so it iterates the entire tree

//----------------------------------------------------------------------------//

function OpenDataFile( cFileName )

   local oWndData, oTree, oMemo, oSplit
   local cTxtFile, cLine, nFrom := 1, cItemText := "", cText
   local oItem, oIncItem, oDefItem, oBmpItem, oDlgItem, oIcoItem
   local oMnuItem, oMnuString

   DEFAULT cFileName := cGetFile( "XML files (*.xml) |*.xml| JSON files (*.json)", "Select a data file" )

   if Empty( cFileName )
      return nil
   endif   

   oMruRCs:Save( cFileName )
   oBtnSave:Disable()

   DEFINE WINDOW oWndData TITLE cFileName MDICHILD

   oTree = TTreeView():New( 2, 0, oWndData )
   oTree:bChanged = { | oItem | oItem := oTree:GetSelected(),;
                      If( oItem != nil, oMemo:SetText( If( ! Empty( oItem:Cargo ), oItem:Cargo, "" ) ),) }
   // oTree:bLDblClick = { || ShowItem( oTree:GetSelected() ) }                   
   oTree:bRClicked = { | nRow, nCol | EditTree( nRow, nCol, oWndData, oTree ) }

   oTree:SetImageList( oImageList )
   oTree:nWidth += 48

   @ 0, 25.7 GET oMemo VAR cItemText MEMO OF oWndData SIZE 300, 100 ;
      ON CHANGE ( oBtnSave:Enable(), oMemo:Cargo := .T.,;
                  oTree:GetSelected():Cargo := cItemText )
                  
   oMemo:Cargo = .F. // it has not changed               

   @ 0, 200 SPLITTER oSplit ;
      VERTICAL ;
      PREVIOUS CONTROLS oTree ;
      HINDS CONTROLS oMemo ; 
      SIZE 4, 200 PIXEL ;
      OF oWndData
      
   oSplit:AdjClient()   

   if ! Empty( cFileName )
      cTxtFile = MemoRead( cFileName )
      
      do case
         case Upper( cFileExt( cFileName ) ) == "XML"
            OpenXML( cFileName, oTree )
            
         case Upper( cFileExt( cFileName ) ) == "JSON"
            OpenJSON( cFileName, oTree )
      endcase
   endif   

   ACTIVATE WINDOW oWndData ;
      ON RESIZE oSplit:AdjClient()
      
   oWndData:bGotFocus = { || If( oMemo:Cargo, oBtnSave:Enable(), oBtnSave:Disable() ) }   
      
return nil

//----------------------------------------------------------------------------//

function OpenXML( cFileName, oTree )

   local aRoots := {}, hFile, oXmlDoc, oXmlIter, oTagLast, oTagActual

   hFile    = FOpen( cFileName )
   oXmlDoc  = TXmlDocument():New( hFile )
   oXmlIter = TXmlIterator():New( oXmlDoc:oRoot )

   AAdd( aRoots, oTree )

   while ( oTagActual := oXmlIter:Next() ) != nil
      if oTagLast != nil
         if oTagLast:Depth() < oTagActual:Depth()
            ASize( aRoots, Len( aRoots ) + 1 )
            aRoots[ oTagActual:Depth() + 1 ] = aRoots[ oTagActual:Depth() ]:Add( oTagActual:cName )
            aRoots[ oTagActual:Depth() + 1 ]:Cargo = oTagActual:cData
         endif

         if oTagLast:Depth() > oTagActual:Depth()
            aRoots[ oTagActual:depth() + 1 ] = aRoots[ oTagActual:Depth() ]:Add( oTagActual:cName )
            aRoots[ oTagActual:depth() + 1 ]:Cargo = oTagActual:cData
         endif

         if oTagLast:Depth() == oTagActual:Depth()
            aRoots[ Max( oTagLast:Depth(), 1 ) ]:Add( oTagActual:cName ):Cargo = oTagActual:cData 
         endif
      else
         AAdd( aRoots, oTree:Add( oTagActual:cName ) )
         ATail( aRoots ):Cargo = oTagActual:cData
      endif
      oTagLast = oTagActual
   end

   FClose( hFile )

return nil     

//----------------------------------------------------------------------------//

function OpenJSON( cFileName )

return nil     

//----------------------------------------------------------------------------//

function ShowImage( cBmp )

   local oDlg, oBmp
   
   DEFINE DIALOG oDlg TITLE cBmp

   if Lower( Right( cBmp, 3 ) ) == "bmp"
      @ 0, 0 BITMAP oBmp FILENAME cBmp OF oDlg NOBORDER
   elseif Lower( Right( cBmp, 3 ) ) == "ico"
      @ 0, 0 ICON oBmp FILENAME cBmp OF oDlg
   endif     
   
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oDlg:SetSize( Max( 300, oBmp:nWidth + 20 ),;
                              Max( 300, oBmp:nHeight + 20 ) ),;
                oBmp:Center( oDlg ), oDlg:Center() )              
   
return nil   

//----------------------------------------------------------------------------//

function EditTree( nRow, nCol, oWndData, oTree )

   local oPopup
   
   MENU oPopup POPUP
      MENUITEM "Add"       ACTION If( oTree:GetSelected() != nil, ( oTree:GetSelected():oParent:Add( "new" ), oTree:Refresh() ),)
      MENUITEM "Add child" ACTION If( oTree:GetSelected() != nil, ( oTree:GetSelected():Add( "new" ), oTree:Refresh() ),)
      MENUITEM "Edit"
      MENUITEM "Delete"    
   ENDMENU   

   ACTIVATE POPUP oPopup WINDOW oWndData AT nRow, nCol

return nil

//----------------------------------------------------------------------------//

static function GenDblClickBlock( oCtrl )

return { || MsgInfo( oCtrl:nId ) }

//----------------------------------------------------------------------------//
pim.rc

Code: Select all

#ifndef __64__
  1 24 "WinXP/WindowsXP.Manifest" 
#endif

background BITMAP .\..\bitmaps\backgrnd\iosbg.bmp

New      BITMAP "../bitmaps/32x32/new.bmp"
New2     BITMAP "../bitmaps/16x16/new.bmp"
Dialog   BITMAP "../bitmaps/16x16/form.bmp"
DlgMask  BITMAP "../bitmaps/16x16/frmmask.bmp"
Open     BITMAP "../bitmaps/32x32/open.bmp"
Open2    BITMAP "../bitmaps/16x16/open.bmp"
Save     BITMAP "../bitmaps/32x32/floppy.bmp"
Run      BITMAP "../bitmaps/32x32/run.bmp"
Prg      BITMAP "../bitmaps/32x32/source.bmp"
Exit     BITMAP "../bitmaps/32x32/exit.bmp"
Exit2    BITMAP "../bitmaps/16x16/exit2.bmp"
includes BITMAP "../bitmaps/16x16/next.bmp"
incmask  BITMAP "../bitmaps/16x16/nxtmask.bmp"
bitmap   BITMAP "../bitmaps/16x16/bitmap.bmp"
bmpmask  BITMAP "../bitmaps/16x16/bmpmask.bmp"
icon     BITMAP "../bitmaps/16x16/icon.bmp"
icomask  BITMAP "../bitmaps/16x16/icomask.bmp"
folder   BITMAP "../bitmaps/16x16/folder.bmp"
fldmask  BITMAP "../bitmaps/16x16/fldmask.bmp"

Re: Are there any Treeview samples with associated edit boxes?

Posted: Tue Nov 24, 2020 1:15 pm
by FWExplorer
Ah, so you guys are working on something like this?

Ok thanks, I'll hold off and I'll check back periodically, and stay subscribed to FTDN.

Btw, do you send out notifications when our FTDN has to be renewed?

Re: Are there any Treeview samples with associated edit boxes?

Posted: Tue Nov 24, 2020 6:12 pm
by Antonio Linares
D.

> Ah, so you guys are working on something like this?

We have used another FWH example to adapt it. We always wanted to have a tool like this one, too :-)

> Ok thanks, I'll hold off and I'll check back periodically, and stay subscribed to FTDN.

We have included this pim.prg new example in FWH examples for next FWH build. many thanks

> Btw, do you send out notifications when our FTDN has to be renewed?

Sometimes :-)

Re: Are there any Treeview samples with associated edit boxes?

Posted: Thu Nov 26, 2020 1:38 pm
by Antonio Linares
Enhanced version:

EXE and full source code (it requires FWH 20.10)
https://github.com/FiveTechSoft/FWH_too ... er/pim.zip

pim.prg

Code: Select all

// FiveWin PIM (personal information manager)

#include "FiveWin.ch"
#include "Splitter.ch"
#include "xbrowse.ch"

static oWnd, oBtnSave, oImageList, oMruRCs
           
//----------------------------------------------------------------------------//
                    
function Main()     
                    
   local oBar, oMenuNew
   local oBmpTiled
    
   DEFINE BITMAP oBmpTiled RESOURCE "background"

   DEFINE WINDOW oWnd FROM 3, 6 TO 20, 70 ;
      TITLE FWVERSION + " PIM" ;
      MENU BuildMenu() MDI
                    
   DEFINE BUTTONBAR oBar SIZE 70, 70 OF oWnd 2010
                    
   DEFINE BUTTON OF oBar PROMPT "New" ;
      TOOLTIP "New" NOBORDER RESOURCE "New" ;
      ACTION NewDataFile()
                    
   DEFINE BUTTON OF oBar PROMPT "Open" ;
      TOOLTIP "Open" NOBORDER RESOURCE "Open" ;
      ACTION OpenDataFile()
                    
   DEFINE BUTTON oBtnSave OF oBar PROMPT "Save" ;
      TOOLTIP "Save" NOBORDER RESOURCE "Save" ACTION Save()
      
   oBtnSave:Disable()   

   DEFINE BUTTON OF oBar GROUP PROMPT "Exit" ;
      TOOLTIP "Exit" NOBORDER RESOURCE "Exit" ACTION oWnd:End()

   oImageList = TImageList():New()

   oImageList:Add( TBitmap():Define( "folder",,  oWnd ),;
                   TBitmap():Define( "fldmask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "dialog",,  oWnd ),;
                   TBitmap():Define( "dlgmask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "icon",,    oWnd ),;
                   TBitmap():Define( "icomask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "bitmap",,  oWnd ),;
                   TBitmap():Define( "bmpmask",, oWnd ) )
   oImageList:Add( TBitmap():Define( "includes",, oWnd ),;
                   TBitmap():Define( "incmask",, oWnd ) )

   DEFINE MSGBAR OF oWnd PROMPT "Personal Information Manager (c) FiveTech Software 2020" DATE KEYBOARD 2010

   ACTIVATE WINDOW oWnd MAXIMIZED ;
      ON PAINT DrawTiled( hDC, oWnd, oBmpTiled )
      // VALID MsgYesNo( "Want to end ?" )

   oBmpTiled:End()
   oImageList:End()
  
return nil

//----------------------------------------------------------------------------//

function BuildMenu()

   local oMenu

   MENU oMenu 2007
      MENUITEM "&File"
      MENU
         MENUITEM "&New"  RESOURCE "new2"
         MENUITEM "&Open" RESOURCE "Open2" ;
            ACTION OpenDataFile()

         MENUITEM "&Save as..."
         SEPARATOR
    
         MENUITEM "Recent files"
         MENU
            MRU oMruRCs ;
               FILENAME ".\re.ini" ;    // .INI to manipulate. '\.' for local
               SECTION  "Recent RC files" ; // The name of the INI section
               ACTION   OpenDataFile( cMruItem ) ;   // cMruItem is automatically provided
               MESSAGE  "Open this file" ;   // The message for all of them
               SIZE     10
         ENDMENU
         
         SEPARATOR
         
         MENUITEM "&Exit..." ACTION oWnd:End() RESOURCE "Exit2"
      ENDMENU
      MENUITEM "&Edit"
      oMenu:AddMDI()
      oMenu:AddHelp( "FiveWin Resources Editor", "FiveTech 1993-2018" )
   ENDMENU

return oMenu

//----------------------------------------------------------------------------//

function Save()

   local oTreeView := oWnd:oWndActive:aControls[ 1 ]
   local cText := "", cFileName := oWnd:oWndActive:GetText()
   
   oTreeView:Scan( { | oItem, nItem | BuildXML( oItem, @cText, nItem ) } )
   
   if File( cFileName )
      if MsgYesNo( "Do you want to overwrite " + cFileName + " ?",;
                   cFileName + " already exists" )
         hb_MemoWrit( cFileName, cText, .F. )
         MsgInfo( cText )
      endif   
   else
      hb_MemoWrit( cFileName, cText,.F. )
   endif 
   oBtnSave:Disable()
   
return nil   

//----------------------------------------------------------------------------//

function BuildXML( oItem, cText, nItem )

   if oItem:oParent != nil
      cText += CRLF
   endif
   
   if oItem:oParent == nil .and. nItem == 1 
      if oItem:cPrompt != "xml"
         oItem:Cargo = oItem:cPrompt
         oItem:cPrompt = "xml"
         cText += "<" + oItem:Cargo + ">"
      endif
   endif      

   if " " $ oItem:cPrompt
      oItem:cPrompt = StrTran( oItem:cPrompt, " ", "_" )
   endif   

   cText += "<" + If( ! Empty( oItem:cPrompt ), oItem:cPrompt, "" ) + ">"

   if ! Empty( oItem:Cargo )
      cText += oItem:Cargo
   endif    
   
   if Len( oItem:aItems ) == 0 
      cText += "</" + If( ! Empty( oItem:cPrompt ), oItem:cPrompt, "" ) + ">"
   endif      

   if oItem:oParent != nil .and. oItem:cPrompt != "xml"
      if oItem == ATail( oItem:oParent:aItems )
         cText += CRLF + "</" + oItem:oParent:cPrompt + ">"
      endif
   endif   

return .F.  // so it iterates the entire tree

//----------------------------------------------------------------------------//

function NewDataFile( cFileName )

   local oWndData, oTree, oMemo, cItemText, oSplit

   DEFAULT cFileName := cNewFileName( "new", "xml" )

   DEFINE WINDOW oWndData TITLE cFileName MDICHILD

   oTree = TTreeView():New( 2, 0, oWndData )
   oTree:bChanged = { | oItem | oItem := oTree:GetSelected(),;
                      If( oItem != nil, oMemo:SetText( If( ! Empty( oItem:Cargo ), oItem:Cargo, "" ) ),) }
   // oTree:bLDblClick = { || ShowItem( oTree:GetSelected() ) }                   
   oTree:bRClicked = { | nRow, nCol | EditTree( nRow, nCol, oWndData, oTree ) }

   oTree:SetImageList( oImageList )
   oTree:nWidth += 48

   if ! File( cFileName )
      hb_MemoWrit( cFileName, '<xml>version="1.0"<new></new></xml>', .F. )
      OpenXml( cFileName, oTree )
   endif   

   @ 0, 25.7 GET oMemo VAR cItemText MEMO OF oWndData SIZE 300, 100 ;
      ON CHANGE ( oBtnSave:Enable(), oMemo:Cargo := .T.,;
                  oTree:GetSelected():Cargo := cItemText )
                  
   oMemo:Cargo = .F. // it has not changed               

   @ 0, 200 SPLITTER oSplit ;
      VERTICAL ;
      PREVIOUS CONTROLS oTree ;
      HINDS CONTROLS oMemo ; 
      SIZE 4, 200 PIXEL ;
      OF oWndData
      
   oSplit:AdjClient()   

   ACTIVATE WINDOW oWndData ;
      ON RESIZE oSplit:AdjClient()
      
   oWndData:bGotFocus = { || If( oMemo:Cargo, oBtnSave:Enable(), oBtnSave:Disable() ) }   

return nil

//----------------------------------------------------------------------------//

function OpenDataFile( cFileName )

   local cTxtFile, oTree

   DEFAULT cFileName := cGetFile( "XML files (*.xml) |*.xml| JSON files (*.json)", "Select a data file" )

   if Empty( cFileName )
      return nil
   endif   

   oMruRCs:Save( cFileName )
   oBtnSave:Disable()

   NewDataFile( cFileName )
   oTree = oWnd:oWndActive:aControls[ 1 ]

   if ! Empty( cFileName )         
      do case
         case Upper( cFileExt( cFileName ) ) == "XML"
            OpenXML( cFileName, oTree )
            
         case Upper( cFileExt( cFileName ) ) == "JSON"
            OpenJSON( cFileName, oTree )
      endcase
   endif   
      
return nil

//----------------------------------------------------------------------------//

function OpenXML( cFileName, oTree )

   local aRoots := {}, hFile, oXmlDoc, oXmlIter, oTagLast, oTagActual

   hFile    = FOpen( cFileName )
   oXmlDoc  = TXmlDocument():New( hFile )
   oXmlIter = TXmlIterator():New( oXmlDoc:oRoot )

   AAdd( aRoots, oTree )

   while ( oTagActual := oXmlIter:Next() ) != nil
      if oTagLast != nil
         if oTagLast:Depth() < oTagActual:Depth()
            ASize( aRoots, Len( aRoots ) + 1 )
            aRoots[ oTagActual:Depth() + 1 ] = aRoots[ oTagActual:Depth() ]:Add( oTagActual:cName )
            aRoots[ oTagActual:Depth() + 1 ]:Cargo = oTagActual:cData
         endif

         if oTagLast:Depth() > oTagActual:Depth()
            aRoots[ oTagActual:depth() + 1 ] = aRoots[ oTagActual:Depth() ]:Add( oTagActual:cName )
            aRoots[ oTagActual:depth() + 1 ]:Cargo = oTagActual:cData
         endif

         if oTagLast:Depth() == oTagActual:Depth()
            aRoots[ Max( oTagLast:Depth(), 1 ) ]:Add( oTagActual:cName ):Cargo = oTagActual:cData 
         endif
      else
         AAdd( aRoots, oTree:Add( oTagActual:cName ) )
         ATail( aRoots ):Cargo = oTagActual:cData
      endif
      oTagLast = oTagActual
   end

   FClose( hFile )

return nil     

//----------------------------------------------------------------------------//

function OpenJSON( cFileName )

return nil     

//----------------------------------------------------------------------------//

function ShowImage( cBmp )

   local oDlg, oBmp
   
   DEFINE DIALOG oDlg TITLE cBmp

   if Lower( Right( cBmp, 3 ) ) == "bmp"
      @ 0, 0 BITMAP oBmp FILENAME cBmp OF oDlg NOBORDER
   elseif Lower( Right( cBmp, 3 ) ) == "ico"
      @ 0, 0 ICON oBmp FILENAME cBmp OF oDlg
   endif     
   
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oDlg:SetSize( Max( 300, oBmp:nWidth + 20 ),;
                              Max( 300, oBmp:nHeight + 20 ) ),;
                oBmp:Center( oDlg ), oDlg:Center() )              
   
return nil   

//----------------------------------------------------------------------------//

function EditTree( nRow, nCol, oWndData, oTree )

   local oPopup, cPrompt
   
   MENU oPopup POPUP
      MENUITEM "Add"       ACTION If( oTree:GetSelected() != nil,;
                                  ( oTree:GetSelected():oParent:Add( "new" ), oTree:Refresh() ),;
                                  ( oTree:Add( "new" ), oTree:Refresh(), oBtnSave:Enable() ) )
      MENUITEM "Add child" ACTION If( oTree:GetSelected() != nil,;
                                  ( oTree:GetSelected():Add( "new" ), oTree:Refresh(), oBtnSave:Enable() ),)
      MENUITEM "Edit"      ACTION ( cPrompt := PadR( oTree:GetSelected():cPrompt, 30 ),;
                                  If( MsgGet( "Edit", "item prompt", @cPrompt ),;
                                  ( oTree:GetSelected():cPrompt := AllTrim( cPrompt ), oBtnSave:Enable() ),) )   
      MENUITEM "Delete"    ACTION If( oTree:GetSelected() != nil,;
                                  ( oTree:GetSelected():End(), oTree:Refresh(), oBtnSave:Enable() ),)    
   ENDMENU   

   ACTIVATE POPUP oPopup WINDOW oWndData AT nRow, nCol

return nil

//----------------------------------------------------------------------------//

static function GenDblClickBlock( oCtrl )

return { || MsgInfo( oCtrl:nId ) }

//----------------------------------------------------------------------------//

Re: Are there any Treeview samples with associated edit boxes?

Posted: Fri Nov 27, 2020 11:52 am
by Silvio.Falconi
When I load a file created not read good
Please try it

Code: Select all

 
< ?xml version = "1.0" encoding = "ISO-8859-1" ? > 
<ROOT RPT="ripara" DESCRIPCION="scheda">
<Modulo>
   <Structure>
      <Field>
         <Field_name>REPORTNUM</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>         3</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>MODELLO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        25</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>DESC</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        60</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>FORMATO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        15</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>LARGHEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ALTEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ORIZONTALE</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>OFFSETX</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>OFFSETY</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>BODYINIT</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ENDBODY</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>INTERLINEA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>RIGHE</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         2</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>COLONNE</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         2</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>GUTTER</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINSUP</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGININF</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINSIN</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINDES</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>IMGFRONTE</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        60</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>IMGRETRO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        60</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINFRO</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINGRET</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
   </Structure>
   <Data>
      <Record>
         <REPORTNUM>001</REPORTNUM>
         <MODELLO>Scheda di riparazione
</MODELLO>
         <DESC>Scheda di riparazione
</DESC>
         <FORMATO>A4</FORMATO>
         <LARGHEZZA>21.00</LARGHEZZA>
         <ALTEZZA>29.70</ALTEZZA>
         <ORIZONTALE>False</ORIZONTALE>
         <OFFSETX>0.00</OFFSETX>
         <OFFSETY>0.00</OFFSETY>
         <BODYINIT>0.00</BODYINIT>
         <ENDBODY>0.00</ENDBODY>
         <INTERLINEA>0.00</INTERLINEA>
         <RIGHE>0</RIGHE>
         <COLONNE>0</COLONNE>
         <GUTTER>0.00</GUTTER>
         <MARGINSUP>0.00</MARGINSUP>
         <MARGININF>0.00</MARGININF>
         <MARGINSIN>0.00</MARGINSIN>
         <MARGINDES>0.00</MARGINDES>
         <IMGFRONTE>.\images\Chrysanthemum.jpg</IMGFRONTE>
         <IMGRETRO>.\images\Lighthouse.jpg</IMGRETRO>
         <MARGINFRO>4.00</MARGINFRO>
         <MARGINGRET>7.00</MARGINGRET>
      </Record>
   </Data>
</Modulo>
<RigheModulo>
   <Structure>
      <Field>
         <Field_name>TIPO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>TESTO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        40</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>CAMPO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>RIGA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>COLONNA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>LARGHEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ALTEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>BORDO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>COLORBORDO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>TIPOBORDO</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>ANGLBORDER</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>BACKBORDO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>CARATTERE</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>SIZEFONT</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         2</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>ALLINEA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>POSIZIONE</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>GRASSETTO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>CORSIVO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>BARRATO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>SOTTOLINE</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>COLORFONT</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>SPOSTARIGA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>SPOSTACOLO</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>REPORTNUM</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>         3</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
   </Structure>
   <Data>
      <Record>
         <TIPO>T</TIPO>
         <TESTO></TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.00</RIGA>
         <COLONNA>11.00</COLONNA>
         <LARGHEZZA>20.00</LARGHEZZA>
         <ALTEZZA>0.01</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO></BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>1</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT></COLORFONT>
         <SPOSTARIGA>0.04</SPOSTARIGA>
         <SPOSTACOLO>0.03</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>T</TIPO>
         <TESTO>Intestatario</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.00</RIGA>
         <COLONNA>11.00</COLONNA>
         <LARGHEZZA>13.00</LARGHEZZA>
         <ALTEZZA>0.40</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>black</BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>3</POSIZIONE>
         <GRASSETTO>True</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT>white</COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>T</TIPO>
         <TESTO>Tipo Documento</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>5.50</RIGA>
         <COLONNA>1.00</COLONNA>
         <LARGHEZZA>5.50</LARGHEZZA>
         <ALTEZZA>0.80</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>1</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT>white</COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>T</TIPO>
         <TESTO>Numero Documento</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>5.50</RIGA>
         <COLONNA>5.50</COLONNA>
         <LARGHEZZA>7.80</LARGHEZZA>
         <ALTEZZA>0.80</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>1</POSIZIONE>
         <GRASSETTO>True</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT>white</COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>I</TIPO>
         <TESTO>fondo.jpg</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.00</RIGA>
         <COLONNA>1.00</COLONNA>
         <LARGHEZZA>20.00</LARGHEZZA>
         <ALTEZZA>29.00</ALTEZZA>
         <BORDO>False</BORDO>
         <COLORBORDO></COLORBORDO>
         <TIPOBORDO>0</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE></CARATTERE>
         <SIZEFONT>0</SIZEFONT>
         <ALLINEA>0</ALLINEA>
         <POSIZIONE>0</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT></COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>I</TIPO>
         <TESTO>logoditta.bmp</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.15</RIGA>
         <COLONNA>1.10</COLONNA>
         <LARGHEZZA>8.00</LARGHEZZA>
         <ALTEZZA>2.00</ALTEZZA>
         <BORDO>False</BORDO>
         <COLORBORDO></COLORBORDO>
         <TIPOBORDO>0</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE></CARATTERE>
         <SIZEFONT>0</SIZEFONT>
         <ALLINEA>0</ALLINEA>
         <POSIZIONE>0</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT></COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
   </Data>
</RigheModulo>
</ROOT>
 

Re: Are there any Treeview samples with associated edit boxes?

Posted: Fri Nov 27, 2020 2:38 pm
by Otto
C:\_DEL ohne Rückfrage\xmltestz.xml (2:2) Critical Ein Name darf nicht mit dem Zeichen ' ', hexadezimaler Wert 0x20, beginnen. Zeile 2, Position 2.
Silvio, please delete the space in this line.
<?xml version = "1.0" encoding = "ISO-8859-1" ?>

Best regards,
Otto

Re: Are there any Treeview samples with associated edit boxes?

Posted: Fri Nov 27, 2020 6:32 pm
by Silvio.Falconi
Otto wrote:C:\_DEL ohne Rückfrage\xmltestz.xml (2:2) Critical Ein Name darf nicht mit dem Zeichen ' ', hexadezimaler Wert 0x20, beginnen. Zeile 2, Position 2.
Silvio, please delete the space in this line.
<?xml version = "1.0" encoding = "ISO-8859-1" ?>

Best regards,
Otto
thanks
Otto my report system save on Rpt file ( xml) , now I must make the decoding into

Re: Are there any Treeview samples with associated edit boxes?

Posted: Fri Nov 27, 2020 7:05 pm
by Otto
Hello Silvio,
mavbe this code is of any help.

Code: Select all


#include "FiveWin.ch"
#include "fileio.ch"
#include "hbxml.ch"
#INCLUDE "FILEIO.CH"

function xml2dbf( nActual, cXMLFile )

    local oXmlDoc  := TXmlDocument():New( cXMLFile  )
   local oXmlIter := TXmlIterator():New( oXmlDoc:oRoot ), oTagActual
   local nDepth
   local cStart     := ""
   local cEnde      := ""
   *----------------------------------------------------------
    
    ferase("xml2.log")
   while .T.
      
      oTagActual = oXmlIter:Next()
      
      if oTagActual != nil 
       
         nDepth = oTagActual:Depth()
          
            if oTagActual:cName = "RoomType"      .and. .not. oTagActual:cName = "RoomTypes" 
                select onlinestand
                APPEND_BLANK() 
              rlok()
                HEval( oTagActual:aAttributes, { | cKey, cValue | logfile( "xml2.log", { ,cKey, cValue } ),;
                         iif( cKey = "RoomID", ( onlinestand->RoomType := cValue ) , ),;
                         iif( cKey = "NumberOfUnits", (onlinestand->Units := cValue ) , ),;
                         iif( cKey = "Quantity", (onlinestand->Quantity := cValue ) , )       } )
                unlok()
         
            endif
  
            if oTagActual:cName = "TimeSpan"     
                rlok()
                HEval( oTagActual:aAttributes, { | cKey, cValue | logfile( "xml2.log", { ,cKey, cValue } ),;
                iif( cKey = "Start", ( onlinestand->Start := cValue ) , ),;
                    iif( cKey = "End", ( onlinestand->End := cValue ) , ) } )
               
            endif
            unlok()
      else
         exit
      endif
   end
   *----------------------------------------------------------
return nil

//----------------------------------------------------------------------------//

 
Best regards,
Otto

Re: Are there any Treeview samples with associated edit boxes?

Posted: Fri Nov 27, 2020 11:16 pm
by FWExplorer
Antonio,

Thanks, I didn't realize that anyone replied today. My email notification must be disabled.

Taking a look, now.

Happy birthday, enjoy.


T & R,



Antonio Linares wrote:D.

> Ah, so you guys are working on something like this?

We have used another FWH example to adapt it. We always wanted to have a tool like this one, too :-)

> Ok thanks, I'll hold off and I'll check back periodically, and stay subscribed to FTDN.

We have included this pim.prg new example in FWH examples for next FWH build. many thanks

> Btw, do you send out notifications when our FTDN has to be renewed?

Sometimes :-)

Re: Are there any Treeview samples with associated edit boxes?

Posted: Sat Nov 28, 2020 10:55 am
by Antonio Linares
There were a few bugs that have been solved. Please try pim.exe first with the included xml files in pim.zip. Open them from pim.exe.
They should read fine.

* We have noticed that Harbour Class TXmlIterator seems to fails when numbers are used instead of chars, i.e.:
<1></1>. This is something to be confirmed, fixed and reported to the Harbour dev. team

* Saving is failing when new1.xml (included in pim.zip) is saved. </one> is missing. This is our new bug to find and fix. Help is appreciated.

* We need to find a way to report an error when a XML is not properly processed and try to provide some feedback
to the user about where the error in the XML file is located. Help is appreciated.

* function OpenXML() had a bug that was inherited from the code in xmltree.prg. FWH/samples/xmltree.prg has been fixed also:
xmltree.prg

Code: Select all

#include "FiveWin.ch"
#include "Splitter.ch"

static oSplit1, oSplit2, oLbxDatas, oLbxMethods

//----------------------------------------------------------------------------/

function Test()

   local oWnd

   DEFINE WINDOW oWnd TITLE "XML viewer" ;
      MENU BuildMenu()

   ACTIVATE WINDOW oWnd ;
      ON INIT BuildTree( oWnd ) ;
      ON RESIZE ( If( oSplit1 != nil, oSplit1:AdjLeft(),),;
                  If( oSplit2 != nil, oSplit2:AdjRight(),) )

return nil

//----------------------------------------------------------------------------/


function BuildMenu()

   local oMenu

   MENU oMenu
      MENUITEM "About" ACTION MsgAbout( "XML Viewer", "(c) FiveTech Software 2013" )
   ENDMENU

return oMenu

//----------------------------------------------------------------------------/


function BuildTree( oWnd )

   local oTree := TTreeView():New( 0, 0, oWnd )
   local oClass, cData, cMethod
   local hFile, oXmlDoc, oXmlIter, oTagActual
   local oTagLast, aRoots := {}

   oTree:nWidth = 180
   // oTree:SetImageList( oImageList )

   oTree:Expand()

   @ 0, 186 LISTBOX oLbxDatas VAR cData ITEMS {} ;
      SIZE 200, 200 PIXEL OF oWnd

   @ 0, 391 LISTBOX oLbxMethods VAR cMethod ITEMS {} ;
      SIZE 200, 200 PIXEL OF oWnd

   @ 0, 181 SPLITTER oSplit1 ;
      VERTICAL ;
      PREVIOUS CONTROLS oTree ;
      HINDS CONTROLS oLbxDatas ;
      LEFT MARGIN 150 ;
      RIGHT MARGIN oSplit2:nLast + 100 ;
      SIZE 4, 300  PIXEL ;
      OF oWnd STYLE

   @ 0, 386 SPLITTER oSplit2 ;
      VERTICAL ;
      PREVIOUS CONTROLS oLbxDatas ;
      HINDS CONTROLS oLbxMethods ;
      LEFT MARGIN oSplit1:nFirst + 120 ;
      RIGHT MARGIN 80 ;
      SIZE 4, 300 PIXEL ;
      OF oWnd STYLE

   hFile    = FOpen( "test.xml" )
   oXmlDoc  = TXmlDocument():New( hFile )
   oXmlIter = TXmlIterator():New( oXmlDoc:oRoot )

   AAdd( aRoots, oTree )

   while ( oTagActual := oXmlIter:Next() ) != nil
      if oTagLast != nil
         if oTagLast:Depth() < oTagActual:Depth()
            ASize( aRoots, Len( aRoots ) + 1 )
            aRoots[ oTagActual:Depth() + 1 ] = aRoots[ oTagActual:Depth() ]:Add( oTagActual:cName )
            aRoots[ oTagActual:Depth() + 1 ]:Cargo = oTagActual
         endif

         if oTagLast:Depth() > oTagActual:Depth()
            aRoots[ oTagActual:Depth() + 1 ] = aRoots[ oTagActual:Depth() ]:Add( oTagActual:cName )
            aRoots[ oTagActual:Depth() + 1 ]:Cargo = oTagActual
         endif

         if oTagLast:Depth() == oTagActual:Depth()
            aRoots[ oTagActual:Depth() + 1 ] = aRoots[ Max( oTagLast:Depth(), 1 ) ]:Add( oTagActual:cName )
            aRoots[ oTagActual:Depth() + 1 ]:Cargo = oTagActual  
         endif
      else
         AAdd( aRoots, oTree:Add( oTagActual:cName ) )
         ATail( aRoots ):Cargo = oTagActual
      endif
      oTagLast = oTagActual
   end

   FClose( hFile )

   oTree:bChanged = { | oItem | ChangeItem( oItem ) }

return nil

//----------------------------------------------------------------------------//

function ChangeItem( oItem )
 
   if ! Empty( oItem:GetSelected():Cargo )
      oLbxDatas:SetItems( { oItem:GetSelected():Cargo:cData } )
   endif   
   oLbxMethods:Reset()
   if ! Empty( oItem:GetSelected():Cargo:aAttributes )
      HEval( oItem:GetSelected():Cargo:aAttributes,;
      { | cKey, cData | oLbxMethods:Add( cKey + " : " + cData ) } )
   endif
   
return nil    

//----------------------------------------------------------------------------//
Please download pim.zip again from:
https://github.com/FiveTechSoft/FWH_too ... er/pim.zip

many thanks for your feedback and help.

Silvio I am going to try your XML file but meanwhile we don't have a XML file format error reporting system, we should try with small and simple XML files as the XML files included in pim.zip. Thanks

Re: Are there any Treeview samples with associated edit boxes?

Posted: Sat Nov 28, 2020 11:03 am
by Antonio Linares
Silvio,

As I have explained in the previous post we need to implement a way to detect if there is an error in the XML file or check if it is a Harbour (Class TXmlIterator) bug.
Silvio.Falconi wrote:When I load a file created not read good
Please try it

Code: Select all

 
< ?xml version = "1.0" encoding = "ISO-8859-1" ? > 
<ROOT RPT="ripara" DESCRIPCION="scheda">
<Modulo>
   <Structure>
      <Field>
         <Field_name>REPORTNUM</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>         3</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>MODELLO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        25</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>DESC</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        60</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>FORMATO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        15</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>LARGHEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ALTEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ORIZONTALE</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>OFFSETX</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>OFFSETY</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>BODYINIT</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ENDBODY</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>INTERLINEA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>RIGHE</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         2</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>COLONNE</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         2</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>GUTTER</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINSUP</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGININF</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINSIN</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINDES</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>IMGFRONTE</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        60</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>IMGRETRO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        60</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINFRO</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>MARGINGRET</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
   </Structure>
   <Data>
      <Record>
         <REPORTNUM>001</REPORTNUM>
         <MODELLO>Scheda di riparazione
</MODELLO>
         <DESC>Scheda di riparazione
</DESC>
         <FORMATO>A4</FORMATO>
         <LARGHEZZA>21.00</LARGHEZZA>
         <ALTEZZA>29.70</ALTEZZA>
         <ORIZONTALE>False</ORIZONTALE>
         <OFFSETX>0.00</OFFSETX>
         <OFFSETY>0.00</OFFSETY>
         <BODYINIT>0.00</BODYINIT>
         <ENDBODY>0.00</ENDBODY>
         <INTERLINEA>0.00</INTERLINEA>
         <RIGHE>0</RIGHE>
         <COLONNE>0</COLONNE>
         <GUTTER>0.00</GUTTER>
         <MARGINSUP>0.00</MARGINSUP>
         <MARGININF>0.00</MARGININF>
         <MARGINSIN>0.00</MARGINSIN>
         <MARGINDES>0.00</MARGINDES>
         <IMGFRONTE>.\images\Chrysanthemum.jpg</IMGFRONTE>
         <IMGRETRO>.\images\Lighthouse.jpg</IMGRETRO>
         <MARGINFRO>4.00</MARGINFRO>
         <MARGINGRET>7.00</MARGINGRET>
      </Record>
   </Data>
</Modulo>
<RigheModulo>
   <Structure>
      <Field>
         <Field_name>TIPO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>TESTO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        40</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>CAMPO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>RIGA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>COLONNA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>LARGHEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>ALTEZZA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>BORDO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>COLORBORDO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>TIPOBORDO</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>ANGLBORDER</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>BACKBORDO</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>CARATTERE</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>SIZEFONT</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         2</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>ALLINEA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>POSIZIONE</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         1</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>GRASSETTO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>CORSIVO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>BARRATO</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>SOTTOLINE</Field_name>
         <Field_type>Logical</Field_type>
      </Field>
      <Field>
         <Field_name>COLORFONT</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>        20</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
      <Field>
         <Field_name>SPOSTARIGA</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>SPOSTACOLO</Field_name>
         <Field_type>Numeric</Field_type>
         <Field_length>         5</Field_length>
         <Field_decimals>         2</Field_decimals>
      </Field>
      <Field>
         <Field_name>REPORTNUM</Field_name>
         <Field_type>Character</Field_type>
         <Field_length>         3</Field_length>
         <Field_decimals>         0</Field_decimals>
      </Field>
   </Structure>
   <Data>
      <Record>
         <TIPO>T</TIPO>
         <TESTO></TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.00</RIGA>
         <COLONNA>11.00</COLONNA>
         <LARGHEZZA>20.00</LARGHEZZA>
         <ALTEZZA>0.01</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO></BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>1</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT></COLORFONT>
         <SPOSTARIGA>0.04</SPOSTARIGA>
         <SPOSTACOLO>0.03</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>T</TIPO>
         <TESTO>Intestatario</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.00</RIGA>
         <COLONNA>11.00</COLONNA>
         <LARGHEZZA>13.00</LARGHEZZA>
         <ALTEZZA>0.40</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>black</BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>3</POSIZIONE>
         <GRASSETTO>True</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT>white</COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>T</TIPO>
         <TESTO>Tipo Documento</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>5.50</RIGA>
         <COLONNA>1.00</COLONNA>
         <LARGHEZZA>5.50</LARGHEZZA>
         <ALTEZZA>0.80</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>1</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT>white</COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>T</TIPO>
         <TESTO>Numero Documento</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>5.50</RIGA>
         <COLONNA>5.50</COLONNA>
         <LARGHEZZA>7.80</LARGHEZZA>
         <ALTEZZA>0.80</ALTEZZA>
         <BORDO>True</BORDO>
         <COLORBORDO>black</COLORBORDO>
         <TIPOBORDO>1</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE>Arial</CARATTERE>
         <SIZEFONT>6</SIZEFONT>
         <ALLINEA>1</ALLINEA>
         <POSIZIONE>1</POSIZIONE>
         <GRASSETTO>True</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT>white</COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>I</TIPO>
         <TESTO>fondo.jpg</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.00</RIGA>
         <COLONNA>1.00</COLONNA>
         <LARGHEZZA>20.00</LARGHEZZA>
         <ALTEZZA>29.00</ALTEZZA>
         <BORDO>False</BORDO>
         <COLORBORDO></COLORBORDO>
         <TIPOBORDO>0</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE></CARATTERE>
         <SIZEFONT>0</SIZEFONT>
         <ALLINEA>0</ALLINEA>
         <POSIZIONE>0</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT></COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
      <Record>
         <TIPO>I</TIPO>
         <TESTO>logoditta.bmp</TESTO>
         <CAMPO>False</CAMPO>
         <RIGA>1.15</RIGA>
         <COLONNA>1.10</COLONNA>
         <LARGHEZZA>8.00</LARGHEZZA>
         <ALTEZZA>2.00</ALTEZZA>
         <BORDO>False</BORDO>
         <COLORBORDO></COLORBORDO>
         <TIPOBORDO>0</TIPOBORDO>
         <ANGLBORDER>False</ANGLBORDER>
         <BACKBORDO>gray</BACKBORDO>
         <CARATTERE></CARATTERE>
         <SIZEFONT>0</SIZEFONT>
         <ALLINEA>0</ALLINEA>
         <POSIZIONE>0</POSIZIONE>
         <GRASSETTO>False</GRASSETTO>
         <CORSIVO>False</CORSIVO>
         <BARRATO>False</BARRATO>
         <SOTTOLINE>False</SOTTOLINE>
         <COLORFONT></COLORFONT>
         <SPOSTARIGA>0.00</SPOSTARIGA>
         <SPOSTACOLO>0.00</SPOSTACOLO>
         <REPORTNUM>001</REPORTNUM>
      </Record>
   </Data>
</RigheModulo>
</ROOT>
 

Re: Are there any Treeview samples with associated edit boxes?

Posted: Sat Nov 28, 2020 1:14 pm
by Antonio Linares
Class TXmlDocument() provides XML error detection support, so we have already included it:
https://github.com/FiveTechSoft/FWH_too ... er/pim.zip

Silvio, now you can check the error in your XML file! Anyhow, we get the error description but no idea what the error is yet :-)

Re: Are there any Treeview samples with associated edit boxes?

Posted: Sat Nov 28, 2020 1:54 pm
by FWExplorer
Very nice. This is a good template. I'll play with it, after getting the environment issues resolved.

I think some hotkeys will need to be added, like Ins or <Alt>Ins to add a child. Also, immediately after adding a child, it should go right into Edit mode, with "New" highlighted.

I'll play with some Export/Save As routines, as this proceeds.

This is has some real potential, Antonio.


Antonio Linares wrote:Class TXmlDocument() provides XML error detection support, so we have already included it:
https://github.com/FiveTechSoft/FWH_too ... er/pim.zip

Silvio, now you can check the error in your XML file! Anyhow, we get the error description but no idea what the error is yet :-)

Re: Are there any Treeview samples with associated edit boxes?

Posted: Sat Nov 28, 2020 4:07 pm
by Antonio Linares
Enhanced version:
https://github.com/FiveTechSoft/FWH_too ... er/pim.zip

> * Saving is failing when new1.xml (included in pim.zip) is saved. </one> is missing. This is our new bug to find and fix. Help is appreciated.

fixed

> I think some hotkeys will need to be added, like Ins or <Alt>Ins to add a child. Also, immediately after adding a child, it should go right into Edit mode, with "New" highlighted

Implemented: you may press "+" on the numeric keyboard to add an item and start editing