XBROWSE Change FOOTER PCITURE

XBROWSE Change FOOTER PCITURE

Postby avista » Thu May 22, 2014 1:47 pm

Hi all,

Please how can i change picture of the footer
Example

ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
SIZE 50 ;
PICTURE "99999" ;
EDITABLE
oCol:lTotal := .t.
oCol:nTotal := 0

I dont want total values like "3.0E5"

// oCol:cFooterPicture := ("9999999999")
// This is not possible

AND i dont want to change cEditPicture

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE Change FOOTER PCITURE

Postby carlos vargas » Thu May 22, 2014 6:20 pm

oBrw:oCols[01]:cFooterPicture := "@999,999,999.99"

Code: Select all  Expand view

...
   EXTEND CLASS TXBRWCOLUMN WITH DATA   cFooterPicture
   OVERRIDE METHOD FOOTERSTR  IN CLASS TXBRWCOLUMN WITH KFOOTERSTR
...
/*-------------------------------------------------------------------------------------------------*/

 


Code: Select all  Expand view

FUNCTION KFooterStr()
   LOCAL Self    := HB_QSelf()
   LOCAL cFooter := ""
   LOCAL cType

   IF !HB_IsNil( ::bFooter )
      cFooter := Eval( ::bFooter, Self )
      DEFAULT cFooter := ""
   ELSEIF !HB_IsNil( ::nTotal ) .or. !Empty( ::nFooterType )
      DEFAULT ::nFooterType := AGGR_SUM, ;
              ::nTotal      := 0.0
      IF ::nFooterType >= AGGR_STD
         IF ::nCount > 0
            cFooter  := ::nTotalSq - ( ::nTotal * ::nTotal / ::nCount )
            cFooter  /= ::nCount - IIf( ::nFooterType == AGGR_STDEVP, 0, 1 )
            cFooter  ^= 0.5
         ELSE
            cFooter  := 0
         ENDIF
      ELSEIF ::nFooterType == AGGR_AVG
         cFooter := IIf( ::nCount > 0, ::nTotal / ::nCount, 0 )
      ELSEIF ::nFooterType == AGGR_COUNT
         cFooter := ::nCount
      ELSE
         cFooter := ::nTotal
      ENDIF
   ELSEIF !HB_IsNil( ::cFooter )
      cFooter := ::cFooter
   ENDIF

   cType := ValType( cFooter )

   IF cType != "C"
      IF cType == ::cDataType .and. !HB_IsNil( ::cEditPicture )
         cFooter := cValToStr( cFooter, IIf( ::cFooterPicture==NIL, ::cEditPicture, ::cFooterPicture ),, ;
                     IfNil( ::lDisplayZeros, ::oBrw:lDisplayZeros ) )
      ELSE
         cFooter := cValToChar( cFooter )
      ENDIF
   ENDIF

RETURN cFooter
 


uso
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: XBROWSE Change FOOTER PCITURE

Postby nageswaragunupudi » Fri May 23, 2014 12:30 am

When the picture clause can not accommodate the number the default behavior of (x)Harbour is to display stars, like "****". Instead, xbrowse displays the number in scientific format within the same width, so that the user gets some idea about the magnitude of the number instead of just seeing stars. When no picture is specified, the number is displayed fully without formatting.

If a picture is specified for the column's data, xbrowse uses the same picture for display of totals also in the footer. So when we "need" to specify picture and use totals, we need to specify picture that can accommodate totals also.

Instead of
Code: Select all  Expand view
ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
SIZE 50 ;
PICTURE "99999" ;
EDITABLE
oCol:lTotal := .t.
oCol:nTotal := 0

Try
Code: Select all  Expand view
ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
PICTURE "999999999" ;
EDITABLE TOTAL 0
 


#1) Let the picture specified for the column be adequate for the totals also.
#2) Let xbrowse calculate the column width.
#3) We may use Clause "TOTAL 0", instead of oCol:nTotal := 0, oCol:lTotal := .t.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Change FOOTER PCITURE

Postby avista » Fri May 23, 2014 9:23 am

Carlos, Rao
Thanks for reply,

Rao,
It is not logical picture specified for the column to be adequate for the totals also
Normally that the total value will be higher than maximal column value on 1000 or more rows,
In this case i need valuse maximum 99999
If i change column picture i need to use valid in hundreds places in the program

Is it possible some other solution to control footer picture ? If yes please tell me.
Is it possible to use TRANSFORM() function ?

I dont like to use modified classes i will probably try carlos sugestion.

Best regards,
Last edited by avista on Fri May 23, 2014 2:00 pm, edited 1 time in total.
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE Change FOOTER PCITURE

Postby nageswaragunupudi » Fri May 23, 2014 11:47 am

After defining the COLUMN as indicated above with TOTAL 0 clause, please add this line also:
Code: Select all  Expand view
oCol:bFooter := { || Transform( oCol:nTotal, "99999999" ) }
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Change FOOTER PCITURE

Postby avista » Fri May 23, 2014 1:35 pm

Rao,
Thanks for reply

oCol:bFooter := { || Transform( oCol:nTotal, "99999999" ) }


But this is not working
In start on 2 rows with values 105, 8
Total is showed as 9215466 and total is not changing more while changing data in xbrowse for that column

Please for solution

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE Change FOOTER PCITURE

Postby carlos vargas » Fri May 23, 2014 4:33 pm

Avista,

my code is a solution, its work.

salu2
carlos vargas
Salu2
Carlos Vargas
Desde Managua, Nicaragua (CA)
User avatar
carlos vargas
 
Posts: 1683
Joined: Tue Oct 11, 2005 5:01 pm
Location: Nicaragua

Re: XBROWSE Change FOOTER PCITURE

Postby nageswaragunupudi » Sat May 24, 2014 2:18 am

ALTERNATIVE-1
--------------------

Code: Select all  Expand view
ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
SIZE 80 ;
PICTURE "99999" ;
EDITABLE

oCol:nFooterType := AGGR_SUM
oCol:bFooter      := { |o,nNew,nOld| TRANSFORM( oCol:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }

 

Please also let me know the version you are using. The above code works unless the fwh version is too old.

ALTERNATIVE-2
-------------------
This is much simpler. We know the picture can be a codeblock also, When we specify a codeblock for oCol:cEditPicture, this codeblock is evaluated with the value to be formatted before use. Using this feature, your code can be:
Code: Select all  Expand view
ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
SIZE 50 ;
PICTURE { |n| If( n > "99999", "9999999999", "99999" } ;
EDITABLE

oCol:nFooterType := AGGR_SUM
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Change FOOTER PCITURE

Postby nageswaragunupudi » Sat May 24, 2014 2:27 am

By the way, while working on your posting, we noticed a bug in the ADD COLUMN command in xbrowse.ch.

If you like, you may correct.
in xbrowse.ch, line 196 is now
Code: Select all  Expand view

             <.lite.>, <nOrder>, <nAt>, <nBmpElem>, [\{ <aBmp> \}], <.hide.>,, ;
 

The two commas at the end of the line should be made as one comma only like this:
Code: Select all  Expand view

             <.lite.>, <nOrder>, <nAt>, <nBmpElem>, [\{ <aBmp> \}], <.hide.>, ;
 

With this correction, the above code can be written similar to this:
Code: Select all  Expand view

ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
SIZE 50 ;
PICTURE "99999" ;
EDITABLE TOTAL 0 ;
FOOTER { |o,nNew,nOld| TRANSFORM( oCol:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "999999" ) }
 

This fix is incorporated for the next build of FWH.

Alternatively, you can also use codeblock for the picture:
Code: Select all  Expand view
ADD oCol TO oBrwSumar DATA ARRAY ELEMENT 2 ;
HEADER a2m("Test") ;
SIZE 50 ;
PICTURE { |n| If( n > "99999", "9999999999", "99999" } ;
EDITABLE TOTAL 0
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Change FOOTER PCITURE

Postby avista » Sat May 24, 2014 5:26 pm

Rao,
Thanks for reply

I use version 13.01 & 13.02 for applications ....higher for testing

I have seen now BUG in the ADD COLUMN command in xbrowse.ch line 196
<.lite.>, <nOrder>, <nAt>, <nBmpElem>, [\{ <aBmp> \}], <.hide.>,, ;

and changed in to
<.lite.>, <nOrder>, <nAt>, <nBmpElem>, [\{ <aBmp> \}], <.hide.>, ;


sugested option
PICTURE { |n| If( n > "99999", "9999999999", "99999" } ;

Produce Syntax error

sugested option
Code: Select all  Expand view
FOOTER { |o,nNew,nOld| TRANSFORM( oCol:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "999999" )

Make wrong totals

Test this sample
Code: Select all  Expand view

#include "FiveWin.Ch"
#include "XBrowse.Ch"

#define CLR_PLAVO_POSVETLO nRGB( 203, 225, 252 )
#define CLR_PLAVO_POTEMNO  nRGB( 125, 165, 224 )

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

function Main()

   local oDlg, oBrw, oCol, oBtnReset

   aSumar := {{"  ",0,0,0}}

   DEFINE DIALOG oDlg SIZE 550,250 TITLE "Test"

   @   5,  5 XBROWSE oBrw OF oDlg ;
             SIZE 200,100 PIXEL ;
             ARRAY aSumar LINES FASTEDIT CELL FOOTERS

   ADD oCol  TO oBrw DATA ARRAY ELEMENT 1 ;
       HEADER "Col1" ;
       SIZE  30 ;
       PICTURE "XX" ;
       EDITABLE

   ADD oCol  TO oBrw DATA ARRAY ELEMENT 2 ;
       HEADER "Col2" ;
       SIZE  70 ;
       PICTURE "99999" ;
; //   PICTURE { |n| If( n > "99999", "9999999999", "99999" } ;
       EDITABLE TOTAL 0 ;
       FOOTER { |o,nNew,nOld| TRANSFORM( oCol:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }
; //   FOOTER { |o,nNew,nOld| TRANSFORM( o:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }
; //   FOOTER { |oCol,nNew,nOld| TRANSFORM( oCol:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }

   ADD oCol  TO oBrw DATA ARRAY ELEMENT 3 ;
       HEADER "Col3" ;
       SIZE 100 ;
       PICTURE "9999999999" ;
       EDITABLE TOTAL 0

   ADD oCol  TO oBrw DATA ARRAY ELEMENT 4 ;
       HEADER "Col4" ;
       SIZE 100 ;
       PICTURE "9999999999" ;
       EDITABLE TOTAL 0

   oBrw:l2007 := .t.               // 2007 Style
   oBrw:lAllowRowSizing     := .f.
   AEval( oBrw:aCols, { |o| o:lAllowSizing := .f. } )
   oBrw:lAllowColSwapping   := .f.
   oBrw:lAllowColHiding     := .f.
   oBrw:lColDividerComplete := .f.

   oBrw:nSizePen  := 1
   oBrw:nColorPen := CLR_PLAVO_POTEMNO

   oBrw:MakeTotals()
   oBrw:CreateFromCode()

   @  5,220 BUTTON oBtnReset PROMPT "ResetArray" SIZE 50,12 PIXEL ;
            ACTION ResetArray( oBrw )


   ACTIVATE DIALOG oDlg CENTERED


RETURN NIL

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


FUNCTION ResetArray( oBrw )

ASIZE( aSumar, 0 )

AADD( aSumar, {"01",10,100,1000} )
AADD( aSumar, {"02",20,200,2000} )

oBrw:Refresh()
oBrw:MakeTotals()

RETURN NIL
 


Using line 34 or 35 going good
; // FOOTER { |o,nNew,nOld| TRANSFORM( o:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }
; // FOOTER { |oCol,nNew,nOld| TRANSFORM( oCol:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }


However
i think Carlos option
oBrw:oCols[01]:cFooterPicture := "@999,999,999.99"
need to be part of xBrowse
(tested working good)

Best rehards
And thanks for the time
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE Change FOOTER PCITURE

Postby nageswaragunupudi » Sun May 25, 2014 3:24 pm

I readily have FWH1204 installed on my computer. I tested your sample and it is working fine. ( I declared aSummar as static variable at the top of the module and corrected xbrowse.ch )

We created ADD COLUMN command to make it easy for migration of legacy programs from TCBrowse to XBrowse.
We recommend using COLUMNS syntax while using XBROWSE command like this:
Code: Select all  Expand view
  @   5,  5 XBROWSE oBrw OF oDlg SIZE 200,100 PIXEL ;
             ARRAY aSumar ;
             COLUMNS 1, 2, 3, 4 ;
             HEADERS "Col1", "Col2", "Col3", "Col4" ;
             SIZES 30, 70, 100, 100 ;
             PICTURES nil, "99999", "9999999999", "9999999999" ;
             LINES FASTEDIT CELL FOOTERS NOBORDER

   AEval( oBrw:aCols, { |o| o:nFooterType := AGGR_SUM, o:nEditType   := EDIT_GET }, 2 )
   oBrw:aCols[ 2 ]:bFooter       := ;
      { |o,nNew,nOld| TRANSFORM( o:nTotal += ( IfNil( nNew, 0 ) - IfNil( nOld, 0 ) ), "99999999" ) }
 


However
i think Carlos option
oBrw:oCols[01]:cFooterPicture := "@999,999,999.99"
need to be part of xBrowse
(tested working good)

We are going to provide this in the next version.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Change FOOTER PCITURE

Postby avista » Tue May 27, 2014 9:09 pm

Rao, Carlos

Many thanks for sugestions.

BTW Rao,

By the way, while working on your posting, we noticed a bug in the ADD COLUMN command in xbrowse.ch.

If you like, you may correct.
in xbrowse.ch, line 196 is now
CODE: SELECT ALL EXPAND VIEW

<.lite.>, <nOrder>, <nAt>, <nBmpElem>, [\{ <aBmp> \}], <.hide.>,, ;


The two commas at the end of the line should be made as one comma only like this:
CODE: SELECT ALL EXPAND VIEW

<.lite.>, <nOrder>, <nAt>, <nBmpElem>, [\{ <aBmp> \}], <.hide.>, ;



I think THERE IS ONE MORE BUG in line 164
Code: Select all  Expand view
<.lite.>, <(cOrder)>, <nAt>, <{uBmpData}>, [\{ <aBmp> \}], <.hide.>,,;

and need to be fixed

Best regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia

Re: XBROWSE Change FOOTER PCITURE

Postby nageswaragunupudi » Wed May 28, 2014 2:20 am

I think THERE IS ONE MORE BUG in line 164

Please tell me what is the bug.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10248
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: XBROWSE Change FOOTER PCITURE

Postby avista » Wed May 28, 2014 7:24 am

Hi,

My bad
It is only one comma at the end of the line ... not two
Sorry

Regards,
User avatar
avista
 
Posts: 301
Joined: Fri Jun 01, 2007 9:07 am
Location: Macedonia


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests