Conditionally Color Rows of a Browse Template List

Using Clarion 10. I’ve had zero success in changing a Row’s Color, based on a variable in the Row. Is this possible? Or does it have to be done on a column by column basis.

Thank you.

Jim

In addition to using addon templates and/or classes, you could also use the wonderful world of Disney :slight_smile:

JSColorQ              QUEUE,TYPE
ColorDesc1              STRING(30)
TextColor1              LONG
BackColor1              LONG
TextSelColor1           LONG,OVER(TextColor1)
BackSelColor1           LONG,OVER(BackColor1)
ColorDesc2              STRING(30)
TextColor2              LONG
BackColor2              LONG
TextSelColor2           LONG,OVER(TextColor2)
BackSelColor2           LONG,OVER(BackColor2)
ColorDesc3              STRING(30)
TextColor3              LONG
BackColor3              LONG
TextSelColor3           LONG,OVER(TextColor3)
BackSelColor3           LONG,OVER(BackColor3)
ColorDesc4              STRING(30)
TextColor4              LONG
BackColor4              LONG
TextSelColor4           LONG,OVER(TextColor4)
BackSelColor4           LONG,OVER(BackColor4)
ColorDesc5              STRING(30)
TextColor5              LONG
BackColor5              LONG
TextSelColor5           LONG,OVER(TextColor5)
BackSelColor5           LONG,OVER(BackColor5)
ColorDesc6              STRING(30)
TextColor6              LONG
BackColor6              LONG
TextSelColor6           LONG,OVER(TextColor6)
BackSelColor6           LONG,OVER(BackColor6)
                      END

Thanks Jeff. Pardon my ignorance, but how should this be called? I tried a number of things in the SetQueueRecord Embed but not much joy.

You can conditionally change a cell colour, if you want to conditionally change a row color you would have to configure every field in the row to be conditionally colored

I have a template at A Clarion Template to Change Browse Colors which might help? It has a C10 demo app that you can play with.

Edit: The template probably won’t help since it is designed to change the entire table. Use conditional colors for every field in the table. You set that up in the table formatter - enable colors and then in Actions for the table, choose the colors tab and enter your condition for each field.

Thanks Geoff. I will grab your template anyway. I’m sure it will teach me something.

BTW: Is this a C10 issue that gets resolved in 11 or 12?

There are 2 approaches for coloring Cells. But there are no approaches that change the color of a row. This isn’t an “issue” - it’s just the way the list boxes / queues work.

The one approach is, as Jeff showed, is to set each cell to have the color option on. This allows for direct colors to be used on a cell by cell basis. If you are coloring based on a field in the row, then this is certainly an approach to go. It uses 4 LONG values per field in the queue., so you have infine control over foreground and background.

The second approach is to create “styles” for the control. Then each cell can be assigned to a style. This uses fewer fields in the Queue (1 LONG per column), but since it requires a pre-defined style, it doesn’t give the endless range the colors do. Use this approach when you have a limited palette to choose from.

A browse will generate the appropriate fields into the Queue if the column on the list box has the COLOR or STYLE property turned on (set on a column by column basis.) Then you set the values in the Browse Extension template. If you want to override the template embed into the SETQUEUERECORD method.

If you’re learning this from scratch, consider Bruce’s suggestion = Styles, these can deliver a more visually attractive result (eg: bold, italic, different font) into an individual cell that colour alone can’t achieve.

Thank you Bruce. Very helpful. It’s making sense now!

The Browse Template has a feature “Create Greenbar Effect” that colors entire rows alternating two colors e.g White and Green.

That still has to color individual cells using either 4 Colors/Field or 1 Style. I cannot recall which it uses.

You may be able to override that code to get the effect you want.

Thanks Carl and to all who responded.

My problem was that I was only getting one column to reflect the color changes because I thought that the Browse just needed to have “has color” turned on for one column. When all columns in the Browse were set to “Has Color”, they all showed up in the embed and it was actually simple to add the Color codes to what I wanted. After spending way too much time on it yesterday, victory was sweet when it all came together today.

Clarion has an awesome community. I’m always impressed by that.

You can learn to edit the FORMAT string directly. This is made much easier with a tool that splits (parses) the FORMAT into one Column per Line. I made one and Mark wrote an IDE plug-in.

E.g. you just have to add an ‘’ to each column for Color or a ‘Y’ for style. Seeing the Format split out makes it easy to see which columns are missing the '’ / ‘Y’.

 FORMAT('[' &|
          '27R(2)|M~Cust.~C(0)@n_6@'                         &|
          '41R(4)|M~Meter~C(0)@n_9@'                         &|
          '4C|M~Port~@n1@'                                   &|
                         '](85)|M~I.D. Numbers~'             &|
        '['                                                  &|
          '38R(2)|M~Previous~C(0)@d1@'                       &|
          '47R(2)|M~Current~C(0)@d1@'                        &|
                                    '](76)|M~Reading Dates~' &|
        '['                                                  &|
          '41R(2)|M~Current~C(0)@n_9@'                       &|
          '41R(2)|M~Prior~C(0)@n_9@'                         &|
          '39R(2)|M~Usage~C(0)@n-9@'                         &|
          '22C|M~Meter~@s1@'                                 &|
          '21C|M~Read~@s1@'                                  &|
          '4C|M~Final~@s1@'                                  &|
                          '](224)|M~Readings~'               ), |

That’s awesome! Thank you.

VLB+styles. But this way has no support from standard templates.

A LIST setup as a VLB (Virtual List Box) gets interesting when the FORMAT() has modifiers like Color (*), Style Column (Y), Icon (I,J), etc, because those are extra columns that make calls to the VLBProc(Row,Column). I.e. if List Column 1 is (*) Colored there will be VLBProc calls for Columns 2,3,4,5 to get the 4 Colors … then List Column 2 is VLBProc(Row,6).

The Window Designer generated Preview program creates a FROM(Queue) based on the FORMAT() that was so so. I created a Class that replaces the Queue with a VLB that can provide sample data for any List Format and all modifiers. It was fun.

I really like a VLB. They are not hard to code. In my StringTheory tools is a way to View the Split Queue Lines in a VLB to verify they contain what you thought source.


Note: With a normal Queue based List and Format modifiers like Color you face these List Column 1,2 versus From(Queue) Field 1,6 issues using the PROP’s. ?List{PROP:COLUMN} (also PROPLIST:MouseDownField) is the LIST Column clicked. The Queue Field number is from ?{PROPLIST:FieldNo, (?{PROP:COLUMN}) }

It’s useful to use the parser for the FORMAT string with VLB. Such parser can prepare information about matching nominal and real columns and about meaning of nominal columns (text, icon, style, colors, tree level).

I think what you mean is to use the PropList: properties to parse the Format for each column?

I have written a FORMAT Parser, but in this case I used PROPLIST: which if you have the actual LIST control is much easier.

     IF ListFEQ{PROPLIST:Color, ColX} THEN       !*Colors
        CLEAR(ColQ)
        ColQ:ModFld='*' ; ColMods[1]='*'
        ColQ:IsLong=1
        ColQ:DataLong=COLOR_C_FG  ; DO AddColumnQ  !Text color
        ColQ:DataLong=COLOR_C_BG  ; DO AddColumnQ  !Back color
        ColQ:DataLong=COLOR_C_SFG ; DO AddColumnQ  !Selected FG color
        ColQ:DataLong=COLOR_C_SBG ; DO AddColumnQ  !SBG
     END
     IF ListFEQ{PROPLIST:CellStyle, ColX} THEN   !Y Cell Style
        CLEAR(ColQ)
        ColQ:ModFld='Y' ; ColMods[4]='Y'
        ColQ:IsLong=1
        ColQ:DataLong=255    ; DO AddColumnQ
        ListFEQ{PROPSTYLE:TextColor,255}=COLOR_Y_FG   !Create List Style to Use
        ListFEQ{PROPSTYLE:BackColor,255}=COLOR_Y_BG
     END
     IF ListFEQ{PROPLIST:Icon, ColX} THEN        !Icon
    ...
     ELSIF ListFEQ{PROPLIST:IconTrn, ColX} THEN  !Tran Icon J
    ...
     END
     IF ListFEQ{PROPLIST:Tree, ColX} THEN        !Tree
    ...
     END
    ...

COLOR_C_FG  EQUATE(COLOR:Maroon) ! * Text Color like a Red Shirt washed in HOT Water
COLOR_C_BG  EQUATE(0FAFAFFH)     ! * Back Pinkish White
COLOR_C_SFG EQUATE(COLOR:None)   ! * Selected normal
COLOR_C_SBG EQUATE(COLOR:None)
COLOR_Z_FG  EQUATE(Color:Green)  !Z Col  Style Text 
COLOR_Z_BG  EQUATE(0E0FFFFH)     !Z Col  Style Back  Lt Yellow
COLOR_Y_FG  EQUATE(Color:Teal)   !Y Cell Style
COLOR_Y_BG  EQUATE(0E0FFFFH)     !Y Cell Style Back  Lt Yellow

No. I had in mind a function to parse the FORMAT string and build some structures to hold following information:

  • To translate a nominal column number to real column number
  • What value must be returned for particular nominal column: text, icon index, etc.

I do this before setting PROP:Format to LIST. This approach allows highly simplify work with VLB. If row number passed to the VLB procedure is positive, use these structures to find what kind of data must be returned.