FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Inserting a progress bar with xBrowse
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Inserting a progress bar with xBrowse
Posted: Mon Aug 06, 2012 05:21 PM
To All

I have reviewed the sample xBrprogb.prg and am trying to adapt a progress bar to xBrowse. I can not seem to adapt the object code for the new column:

Code (fw): Select all Collapse
WITH OBJECT oBrw:Age
       :cHeader    := 'Percent'
       :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
       :nDataStrAlign := AL_RIGHT

END


I want to be able to add a new column 10 using the syntax

Code (fw): Select all Collapse
 ADD oCol TO oBrw AT 10  ...


Also .. I do not seem to understand the SetProgBar( 100, 104 ... What do these values represent ?

The progress bar will actually be the value between a "Start Date", "End Date" and the percentage complete by Date()

Thanks
Rick Lipkin
Posts: 990
Joined: Thu Nov 17, 2005 05:49 PM
Re: Inserting a progress bar with xBrowse
Posted: Tue Aug 07, 2012 12:05 AM
Hi Rick;

From the source file: METHOD SetProgBar( nProgTotal, nWidth, bClrProg )

Here is how to use it:

Code (fw): Select all Collapse
      :Progress:nTotal          := 0
      :Progress:lTotal          := .t.
      :Progress:SetProgBar( 100.00, 0.00, oBrw:bClrStd )
      :Progress:nDataStrAlign := AL_RIGHT
      :Progress:cEditPicture    := "999.99%"


To see the progress bar grow, change 2nd parameter up to 100. It is that simple.



Reinaldo.
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Inserting a progress bar with xBrowse
Posted: Tue Aug 07, 2012 12:48 PM
Reinaldo

I have spent a good part of the day yesterday working on this ..

I just do not see how the method paints the progress bar and how it manipulates its values?? I am looking at incorporating this logic to create a percentage of completion for a project with a start date, projected end date with respect to today's date and then paint a progress bar in a column.

Rick Lipkin

Code (fw): Select all Collapse
ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Percent' RIGHT size 90


//------------------------
Static Func _CalcPercent( dStart, dEnd )

Local nPercent,nDiff,nElapsed

dStart   := TtoDate(dStart )
dEnd     := TtoDate( dEnd )
nPercent := 0

nDiff    := ( dEnd  - dStart )

If nDiff > 0
Else
   nPercent := 0
   Return( ltrim(str(nPercent))+" %" )
Endif

nElapsed := (Date() - dStart )
nPercent :=  nElapsed / nDiff
nPercent := round(nPercent * 100,0)

If nPercent > 100
   nPercent := 100
Endif

Return(ltrim(str(nPercent))+" %" )
Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Inserting a progress bar with xBrowse
Posted: Tue Aug 07, 2012 01:23 PM
You might try something like that:

Rick Lipkin wrote:
Code (fw): Select all Collapse
ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Percent' RIGHT size 90

oCol:SetProgBar( oRsProj:Fields("End_Date"):Value - oRsProj:Fields("Start_date"):Value, oRsProj:Fields("End_Date"):Value - date(), oBrw:bClrStd )
Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Inserting a progress bar with xBrowse
Posted: Tue Aug 07, 2012 01:24 PM
Reinaldo,André

This code now appears to be working to the point where I can see a progress bar based on the numeric value of the cell... I still have no clue why this works or how it paints :-)

Thanks for your Help !

Rick Lipkin

Code (fw): Select all Collapse
ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Percent' size 90

        WITH OBJECT oBrw:Percent
            :nTotal          := 0
            :lTotal          := .t.
            :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
            :nDataStrAlign := AL_RIGHT
        END


Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Inserting a progress bar with xBrowse
Posted: Tue Aug 07, 2012 01:43 PM

My sample is wrong. I think now I understood how it works. SetProgBar( Param1, Param2, Param3 )

Param1 is the maximum possible value of the data in the cell. In your case end date - begin date, the data of the cell should be the quantity of elapsed days from begin day.
Param2 is the width you want your column to be shown.

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Inserting a progress bar with xBrowse
Posted: Tue Aug 07, 2012 02:42 PM
André

YES .. you are correct. Apparently the first parameter is the Max value ( 100 % ) and the second is the width of the column and the value of the column is evaluated as a percentage of the max ( 100 ).

Code (fw): Select all Collapse
ADD oCol TO oBrw AT 10 DATA {|x| x :=  _CalcPercent( oRsProj:Fields("Start_date"):Value,;
                 oRsProj:Fields("End_Date"):Value )} HEADER 'Progress' size 90

        WITH OBJECT oBrw:Progress
          *  :nTotal          := 0
          *  :lTotal          := .t.
            :SetProgBar( 100, 104, { || { nProgClr, CLR_WHITE } } )
            :nDataStrAlign := AL_CENTER
        END


Also .. :nTotal and :lTotal are not needed ..

Thanks
Rick Lipkin

Continue the discussion