How to creates complex color conditions

Requirement: bBrowser 1.4

 

Sometimes the color condition is too complex and cannot be defined in a simple condition. In these cases a method can be called in the condition, that returns a logical value. For this in the 2. argument of the method bColorCondition:Init() the object must be passed on, in that the method is defined. For example such an object can be the window of the bBrowser.

The following code fragment demonstrates the proceeding:

METHOD PostInit() CLASS myDataWindow

  LOCAL odbsCUSTOMER     AS bDBServer

  LOCAL oColorCondition  AS bColorCondition

 

  odbsCUSTOMER := bDBServer{"CUSTOMER.DBF"}

  IF odbsCUSTOMER:Used

    self:oDCBrowser:Use(odbsCUSTOMER)

 

    oColorCondition := bColorCondition{"Server:CheckCondition()",;

                                       self,;

                                       Color{COLORYELLOW},;

                                       Brush{Color{COLORRED}}}

    self:oDCBrowser:ColorCondition:Add(oColorCondition)

 

    self:oDCBrowser:Refresh()

    self:oDCBrowser:Redraw()

  ENDIF

 

METHOD CheckCondition() CLASS myDataWindow

  LOCAL odbsCUSTOMER  AS OBJECT

  LOCAL iAge          AS INT

 

  odbsCUSTOMER := self:oDCBrowser:Server

 

  iAge := Year(Today())-Year(odbsCUSTOMER:BIRTHDAY)

  IF iAge>=40

    RETURN TRUE

  ELSE

    RETURN FALSE

  ENDIF