Page 1 of 1

xBrowse with „Meter“

Posted: Sun Jun 08, 2008 9:08 am
by Otto
Call:
send in bStrData block:

„#“ shows it is a meter +
10 characters for the maximum + the value as string

oCol:bStrData := { || "#"+"50000 "+ALLTRIM(str(field->test))}



Change the METHOD PaintData as follows:

Code: Select all

METHOD PaintData( nRow, nCol, nHeight, lHighLite, lSelected, nOrder ) CLASS TXBrwColumn
local nPerc :=  0
local hBrushgruen  := CreateSolidBrush(RGB(0,159,80))
local nMax:=0
local lMeter:=.f.

...
   if ::bStrData != nil
      cData := Eval( ::bStrData )
      IF left(cData,1)="#"
         lMeter:=.t.
      endif
...
   if ! lTransparent
      IF lMeter=.t.
         nMax := VAL(substr(cData,2,10))
         nPerc := ( nRectWidth  ) *  VAL ( substr(cData,12))/nMax
         FillRect( hDC, {nRow, nRectCol, nRectHeight, Min( nRectCol + nRectWidth, ::oBrw:BrwWidth() - 4 ) }, hBrush )
         FillRect( hDC, {nRow+5, nRectCol, nRectHeight-5, nRectCol+ nPerc  },  hBrushgruen)
      else
         FillRect( hDC, {nRow, nRectCol, nRectHeight, Min( nRectCol + nRectWidth, ::oBrw:BrwWidth() - 4 ) }, hBrush )
      endif
   endif


...

    if !Empty( cData )
       IF lMeter=.t.



       else

      oFont:Activate( hDC )
      SetTextColor( hDC, aColors[ 1 ] )

     endif







Image

Meter and xBrowse

Posted: Sun Jun 08, 2008 12:10 pm
by ukoenig
Hello Otto,

it'a a good idea.

A customer of mine is selling software for schools.
There are different prices in relation to schoolsize ( schoolchilden ).

In the moment i have a val-field, that shows just a number.
I can change the field with a gradient-background :
start with green and change to red for the highest value.

Image

I will try out your solution.

Best regards

Uwe :lol:

Re: xBrowse with „Meter“

Posted: Mon Jun 09, 2008 11:47 am
by Patrick Mast
Otto wrote:„#“ shows it is a meter +
10 characters for the maximum + the value as string
Nice idea Otto!
Antonio, should we not have someting standard in xBrowse? Is it possible to have a REAL meter per cell?

Patrick

Posted: Mon Jun 09, 2008 12:12 pm
by Antonio Linares
Patrick,

Its a better solution to paint a meter, as Otto has done, instead of using real meter controls, as we may need to manage lots of them, scroll them (change their coordinates), hide them, etc.