Page 1 of 1

DCBROWSECOL .... FOOTER

Posted: Thu May 16, 2019 3:22 pm
by unixkd
Hi all

I discovered that DCBROWSECOL .... FOOTER cause IDC error.

Run the code below:

Code: Select all

FUNCTION XSample_19                                                            
                                                                               
/*  ARRAY BROWSER WITH COLORS                                                                                                                                 
 This example demonstrates how to control the color of cells in                
 an array browser using DCBROWSE.  In this example, the color of               
 the SIZE cells is dependent on the size of the file.  The                     
 function DC_GETCOLARRAY() is used as a pointer into the array                 
 being browsed.                                                                                                                                              
*/                                                                             
                                                                               
LOCAL GetList := {}, cDir, oFileName, aDirectory, i, ;                    
      nPointer, oDirectory, aColors, bColor, GetOptions, cFooter := TRANSFORM(0,"###,###,###")                        
                                                                               
cDir := Space(30)                                                         
                                                                               
@ 2,2 DCGET cDir GETSIZE 43  POPUP {|c|DC_PopDir(c)}                           
                                                                               
aDirectory := Directory()                                                      
FOR i := 1 TO Len(aDirectory)                                                  
  ASize(aDirectory[i],5)                                                       
  aDirectory[i,5] := .f.                                                       
NEXT                                                                           
ASort(aDirectory,,,{|a,b|a[1]<b[1]})                                           
                                                                               
@ 3.5,2 DCBROWSE oDirectory DATA aDirectory ;                                  
      SIZE 60,12 ;                                                             
      FONT '10.Helv Bold' ;                                                    
      PRESENTATION DC_BrowPres() ;                                             
      POINTER nPointer ;                                                       
      OPTIMIZE ;                                                               
      FIT ;                                                                    
      NOHSCROLL ;                                                              
      MARK 5 ;                                                                 
      MKCOLOR 5, GRA_CLR_WHITE, GRA_CLR_BLUE                                   
                                                                               
aColors := { {GRA_CLR_WHITE,GRA_CLR_DARKRED}, ;                                
             {GRA_CLR_WHITE,GRA_CLR_DARKBLUE}, ;                               
             {GRA_CLR_BLACK,GRA_CLR_DARKGREEN}, ;                              
             {GRA_CLR_BLACK,GRA_CLR_YELLOW} }                                  
                                                                               
bColor := {| nSize, nCase | nSize := DC_GetColArray(2,oDirectory),;            
              nCase := DC_PickCase(nSize,'>=',;                                
                          {1000000,100000,10000,0}, ;                          
                          {      1,     2,    3,4} ), aColors[nCase] }         
                                                                               
DCBROWSECOL ELEMENT 1 WIDTH 10 HEADER "Name" PARENT oDirectory                 
                                                                               
DCBROWSECOL ELEMENT 2 WIDTH 7 HEADER "Size" PARENT oDirectory ;                
  EVAL { |o|o:colorBlock := bColor } // FOOTER {|| cFooter }                                          
                                                                               
DCBROWSECOL ELEMENT 3 WIDTH 8 HEADER "Date" PARENT oDirectory                  
                                                                               
DCBROWSECOL ELEMENT 4 WIDTH 6 HEADER "Time" PARENT oDirectory                  
                                                                               
DCBROWSECOL ELEMENT 5 WIDTH 4 HEADER "Marked" PARENT oDirectory   

@ 2,50  DCPUSHBUTTON CAPTION "Display" SIZE 7,0.8 ;
        ACTION {|| _UpdateDirFooter(aDirectory, cDir, @cFooter, GetList, oDirectory)}             
                                                                               
DCGETOPTIONS NOMINBUTTON NOMAXBUTTON NORESIZE TABSTOP                          
                                                                               
DCREAD GUI ;                                                                   
   OPTIONS GetOptions ;                                                        
   FIT ;                                                                       
   MODAL ;                                                                     
   BUTTONS DCGUI_BUTTON_OK + DCGUI_BUTTON_CANCEL ;                             
   TITLE 'Array Browse of Directory'  
                                                                               
RETURN nil 
*
Static Function _UpdateDirFooter(aDir, cDir, cFooter, GetList, oDirectory)
Local nSize := 0, i
aDir := Directory(AllTrim(cDir)+"\*.*")
aEval(aDir, {|e| nSize += e[2]})
cFooter := TRANSFORM(nSize, "###,###,###")
FOR i := 1 TO Len(aDir)                                                  
  ASize(aDir[i],5)                                                       
  aDir[i,5] := .f.                                                       
NEXT
DC_GetBrowArray(oDirectory,aDir)                           
DC_GetRefresh(GetList)
Return nil                                                                    
                                                                               
* ------------    

Re: DCBROWSECOL .... FOOTER

Posted: Fri May 17, 2019 12:39 am
by unixkd
DCBrowseColFooter.png
DCBrowseColFooter.png (172.52 KiB) Viewed 10697 times

Re: DCBROWSECOL .... FOOTER

Posted: Fri May 17, 2019 1:06 am
by Tom
You need a footer in every column. Create empty footers for the other columns (... FOOTER "-").

Re: DCBROWSECOL .... FOOTER

Posted: Fri May 17, 2019 1:32 am
by unixkd
Thanks Tom

Worked now. Roger should mention it in the doc.

Re: DCBROWSECOL .... FOOTER

Posted: Fri May 17, 2019 3:16 am
by Tom
This is not Roger's mistake.

Anyway, look at your screenshot. Besides it doesn't work - it doesn't look very good, having footers at a position where column values are expected. ;)

Re: DCBROWSECOL .... FOOTER

Posted: Fri May 17, 2019 5:58 am
by rdonnay
Worked now. Roger should mention it in the doc.
I suppose I should have mentioned that, but it never occurred to me that someone would want footers only on some columns, and not others. Tom is right. That's a strange way to design a browse.

It will require much more work for me to modify my code to fill in the empty footers than it will for you to do as Tom suggested.

Each column object knows nothing about other column objects, so the only way to handle this is to add another clause to the DCBROWSE object that would set some kind of default. That's more changes to DCDIALOG.CH, DC_XbpBrowse() class and the documentation. If this issue had been brought up 15-20 years ago, when I first wrote the browse system, I may have thought that this was a major design flaw. But after this long, with no other complaints from eXpress++ users, I will leave well enough alone. I have some bigger fish that I am frying right now which adds major new features to the browse system.

Re: DCBROWSECOL .... FOOTER

Posted: Sat May 18, 2019 12:29 pm
by unixkd
Roger

I agree with you totally

Thanks