xBrowse Fillrect - How to color multiple rows by column

xBrowse Fillrect - How to color multiple rows by column

Postby Rick Lipkin » Wed May 22, 2013 7:13 pm

To All

I am writing a scheduler and would like to be able to put color to the appointment duration for a span of time.

I have looked at Daniel Gil's Calex calendar class to see how he filled in the rows ( must be transparent for the column text ) for a specific column without much success... see below.

I have created an xBrowse populated from an array what paints by a start time ( horizontal row) by Persons Name ( vertical column ).

If I have an appointment that spans multiple 30 minute increments I would like to fill those xy rows a specific color outlining the duration of the appointment... In the below screen shot .. third column from 9:00 to 10:00 am.

If anyone has any suggestions .. I would be most honored by your suggestions and help!

Thanks
Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Fillrect - How to color multiple rows by column

Postby nageswaragunupudi » Fri May 24, 2013 3:56 am

Your program knows the top and bottom rows for the appointment, say nTop and nBot:
Code: Select all  Expand view

oCol:bClrStd := { || { CLR_BLACK, If( oBrw:nArrayAt >= nTop .and. oBrw:nArrayAt <= nBot, CLR_YELLOW, CLR_WHITE ) } }
 


To color a rectangle:

Assume we have two Arrays as static vars.
aSelRows := { nTop, nBottom }
aSelCols := { nLeft, nRight }
Note: I am using two arrays instead one aRect, because this logic easily enables using oBrw:aSelected.

Code: Select all  Expand view

for each oCol in oBrw:aCols
   SetClrStd( oCol )
next
....
....
static function SetClrStd( oCol )

oCol:bClrStd := { || { CLR_BLACK, If( oCol:oBrw:BookMark >= aSelRows[ 1 ] .and. oCol:oBrw:BookMark <= aSelRows[ 2 ] .and. oCol:nPos >= aSelCols[ 1 ] .and. oCol:nPos <= aSelCols[ 2 ], CLR_YELLOW, CLR_WHITE ) } }

 
Regards

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

Re: xBrowse Fillrect - How to color multiple rows by column

Postby Rick Lipkin » Fri May 24, 2013 12:53 pm

Rao

Thank you for your reply ..

I am struggling to know how to identify the appointment blocks at run time since I have already created the array with the proper values .. all xbrowse does is display the array.

You mentioned bookmarks ... is it possible to create bookmarks at run-time based on the value of the underlying array data .. then use the bookmarks to identify the top and bottom cells to apply the color?

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Fillrect - How to color multiple rows by column

Postby nageswaragunupudi » Fri May 24, 2013 3:08 pm

Let us be clear about what oBrw:BookMark means.

oBrw:bBookmark is defined as { |n| If( n == nil, RecNo(), DbGoTo( n ) } for RDD and { |u| If( u == nil, oRs:BookMark, oRs:BookMark := u ) } for RecordSet.

oBrw:BookMark is the same as RecNo() for DBF and oRs:BookMark for RecordSet.

oBrw:BookMark := n means DbGoTo( n ) for DBF and oRs:BookMark := n for RecordSet.

Bookmark does not change when the DBF or RecordSet is sorted in different orders.

oBrw:Bookmark is not something we create to flag (or mark) a row.

For Arrays oBrw:Bookmark is the same as oBrw:nArrayAt.
Regards

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

Re: xBrowse Fillrect - How to color multiple rows by column

Postby nageswaragunupudi » Fri May 24, 2013 4:40 pm

I am struggling to know how to identify the appointment blocks at run time since I have already created the array with the proper values .. all xbrowse does is display the array.


Please have a look at the following sample:
Code: Select all  Expand view
#include "fivewin.ch"
#include "xbrowse.ch"

function main()

   local oDlg, oBrw, oFont
   local aData := { ;
   { 1, ''  , 'AA', 'BB', ''   }, ;
   { 2, ''  , ''  , 'BB', ''   }, ;
   { 3, 'AA', 'AA', 'CC', 'DD' }, ;
   { 4, 'CC', 'AA', 'DD', 'EE' }, ;
   { 5, 'CC', 'AA', 'CC', 'EE' }, ;
   { 6, ''  , 'CC', ''  , 'AA' }  }

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 400,240 PIXEL FONT oFont
   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE aData AUTOCOLS ;
      CELL LINES NOBORDER

   AEval( oBrw:aCols, { |o| o:bClrStd := SetStdColor( o ) }, 2 )

   WITH OBJECT oBrw
      :nWidths       := 60
      :nDataStrAlignS:= AL_CENTER
      //
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED
   RELEASE FONT oFont

return nil

static function SetStdColor( oCol )
return { || CellColor( oCol ) }

static function CellColor( oCol )

   local aColor   := { CLR_BLACK, CLR_WHITE }
   local oBrw     := oCol:oBrw
   local nRow     := oBrw:nArrayAt
   local nCol     := oCol:nCreationOrder
   local cVal     := oCol:Value

   if ! Empty( cVal )
      if nRow > 1 .and. cVal == oBrw:aArrayData[ nRow - 1, nCol ]
         aColor   := { CLR_WHITE, CLR_GREEN }
      elseif nRow < oBrw:nLen .and. cVal == oBrw:aArrayData[ nRow + 1, nCol ]
         aColor   := { CLR_WHITE, CLR_GREEN }
      endif
   endif

return aColor
 


result:
Image

Now can you build the array in a similar way and use similar logic for coloring?
Regards

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

Re: xBrowse Fillrect - How to color multiple rows by column

Postby Rick Lipkin » Fri May 24, 2013 4:57 pm

Rao

I thought about labeling each cell as I create the array .. and I may have to do that. I was trying not to add text to each cell .. only color the ones starting from the beginning cell and count down the number of cells in the appointment.

I am trying to re-create an appointment screen like this ..

Rick Lipkin

Image
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Fillrect - How to color multiple rows by column

Postby nageswaragunupudi » Fri May 24, 2013 6:07 pm

You can also use oCol:lMergeVert := .t.

Image
Regards

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

Re: xBrowse Fillrect - How to color multiple rows by column

Postby Rick Lipkin » Fri May 24, 2013 6:13 pm

Rao

I did think about that and looked at how xBrowse.prg was painting the like cells .. Good food for thought..

I will see how that idea works .. would be nice if you could specify the color of the merged data 8)

Appreciate your help and advice!
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Fillrect - How to color multiple rows by column

Postby nageswaragunupudi » Fri May 24, 2013 8:47 pm

I will see how that idea works .. would be nice if you could specify the color of the merged data

Sorry, while working on this I noticed that there is a little bug in painting if we specify a different colour.
Let us keep thinking.
Regards

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

Re: xBrowse Fillrect - How to color multiple rows by column

Postby Rick Lipkin » Fri May 24, 2013 10:23 pm

Rao

I am re-working the code to build the array .. turning into a nightmare.. hopefully sometime Saturday I will have the re-write on the array and then see if I can do the merge.

I think this will work..

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: xBrowse Fillrect - How to color multiple rows by column

Postby nageswaragunupudi » Fri May 24, 2013 10:56 pm

nd then see if I can do the merge.

Please do not consider this option. I thought about it and with the present xbrowse code, you will get stuck up.

Just prepare the array like this. Prepare another array of same size with duration in the corresponding cell of the second array. Keep the duration as number of half-hours ( that gives the number of rows )

Example:
If aData[ 3, 4 ] contains an appointment, aDurn[ 3, 4 ] contains its duration. If the duration is less than 1/2 hour the value is 1. If more than 1/2 hour and less than 1 hour the value is 2. etc.

Then we can draw the cells on our own. Thats a lot better. First please make the two arrays.

I am also assuming that all the rows of the browse will fit into one screen. Right? Or not?
Regards

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

Re: xBrowse Fillrect - How to color multiple rows by column

Postby Rick Lipkin » Sat May 25, 2013 1:59 pm

Rao

Just curious what problems did you encounter with the vertical merge ? I have not yet got too deep into the array re-write.

Let me study your second array option .. the original xBrowse array creates each row starting with the time .. then loops thru a separate employee array used to build the header columns.. so I really do not store the start date to the array.. each row is created in time increments and each column looks for the matching person's name which places the array data in the correct xy coordinates displayed in the browse.

I am a bit fuzzy on how you can use the second array as a guide to paint the blocks on the browse :?:

As far as fitting on one screen .. depending on the screen resolution .. 1024 x 768 will not allow all the vertical rows to paint without scrolling and the horizontal is based on the number of employees.

I sent you the Schedule.prg via your private e-mail .. please feel free to review the code and make any suggestions...

Thanks
Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2664
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 46 guests