Page 12 of 35

Posted: Sat Dec 24, 2005 11:16 am
by DoubleDutch
Perfect, very nice & fast again... Thanks :)

The code I posted is just a rip from the main code thats why it looks a bit wierd - its fine in the main code.

Thanks once again and Merry Christmas!

-Anthony

Posted: Wed Dec 28, 2005 8:28 pm
by TerryHough
Maybe I have overlooked something...

I'm using

Code: Select all

PureCOLOR_SetGadgetColor(EventGadget, -1, lcolor)
to change the color of a StringGadget.

But, I really don't want to change the Text color.

The -1 sets it to the system color (black). However, in some cases the
text color has been changed to a different color.

Is there anyway to leave the text color unchanged and change just the
background?

Or, query for the text color and use that in place of the -1 when the
command is issued?

Thanks,
Terry

Posted: Thu Dec 29, 2005 9:04 am
by gnozal
TerryHough wrote:The -1 sets it to the system color (black). However, in some cases the text color has been changed to a different color.
Could I have some code examples ?
TerryHough wrote:Is there anyway to leave the text color unchanged and change just the background?
Or, query for the text color and use that in place of the -1 when the
command is issued?
Theoritically, when TextColor = #PureCOLOR_SystemColor (-1), TextColor is replaced by GetSysColor_(#COLOR_XXX), where #COLOR_XXX is chosen accordingly to the gadget class.
I could have made some mistakes when chosing #COLOR_XXX, or there are some others bugs (for this I need some code).
You can query for the default text color using the GetSysColor_(nIndex) and providing the correct nIndex (please refer to Win32.hlp with keyword GetSysColor).

Posted: Sat Dec 31, 2005 3:22 pm
by TerryHough
Modified one of your examples to exhibit what I am trying to do.

Code: Select all

; Set Callback
Procedure.l WindowCallBack(WindowId.l, Message.l, wParam.l, lParam.l)
  ReturnValue = #PB_ProcessPureBasicEvents 
  ;
  ReturnValue = PureCOLOR_CallBack(WindowId, Message, wParam, lParam, ReturnValue)
  ;
  ProcedureReturn ReturnValue 
EndProcedure
; Create Window
OpenWindow(0, 100, 300, 400, 400, #PB_Window_ScreenCentered|#PB_Window_SystemMenu, "PureCOLOR test") 
SetWindowCallback(@WindowCallBack()) 
If CreateGadgetList(WindowID()) 
  StringGadget(1, 10, 10, 90, 20, "StringGadget 1")
  ListIconGadget(2, 10, 40, 150, 100, "", 146, #PB_ListIcon_GridLines)
  AddGadgetItem(2, -1, "ListIconGadget 2-1")
  AddGadgetItem(2, -1, "ListIconGadget 2-2")
  AddGadgetItem(2, -1, "ListIconGadget 2-3")
  AddGadgetItem(2, -1, "ListIconGadget 2-4")
  AddGadgetItem(2, -1, "ListIconGadget 2-5")
  TextGadget(3, 10, 160, 300, 200, "TextGadget 3")
  ButtonGadget(4, 200, 10, 80, 20, "Button 4")
  ComboBoxGadget(5, 295, 10, 100, 100)
  AddGadgetItem(5, -1, "ComboBox 5-1")
  AddGadgetItem(5, -1, "ComboBox 5-2")
  SetGadgetState(5, 0)
  CheckBoxGadget(6, 110, 10, 80, 20, "CheckBox 6")
  ListViewGadget(7, 160, 40, 150, 100, #PB_ListIcon_GridLines)
  AddGadgetItem(7, -1, "ListViewGadget 7-1")
  AddGadgetItem(7, -1, "ListViewGadget 7-2")
  AddGadgetItem(7, -1, "ListViewGadget 7-3")
EndIf
; Adding colors
Msg$ = "The StringGadget gets the text changed to Red, system Default background "
Msg$ + "But after a 10 second delay, let's change its background color without changing "
Msg$ + "its text color.  However, lets assume we don't know its current text color.  We " 
Msg$ + "want to change the background without knowing or affecting the text color. "
PureCOLOR_SetGadgetColor(1, RGB(255,0,0), -1)
SetGadgetText(3,Msg$)
; -----------------------------------------------------------------------------------
; PureCOLOR_SetGadgetColor(2, RGB(0,255,0), -1)
; PureCOLOR_SetGadgetColorEx(2, RGB(0,0,0), RGB(255, 255, 255), RGB(255, 255, 223), #PureCOLOR_LV_AlternateColors)
; PureCOLOR_SetGadgetColor(3, RGB(255,0,0), RGB(0,0,0))
; PureCOLOR_SetButtonColor(4, RGB(255,0,0), RGB(0,255,0))
; PureCOLOR_SetGadgetColor(5, RGB(255,0,0), RGB(255,255,0))
; PureCOLOR_SetGadgetColor(6, RGB(255,255,0), -1)
; PureCOLOR_SetGadgetColor(7, RGB(255,0,0), RGB(100,100,0))
; PureCOLOR_ClearGadgetColor(2)
;
Msg$ = "OK. let's wait 10 seconds so we can see how it looks to begin with." 
Msg$ + "and then change the StringGadget's background color only."
SetGadgetText(3,Msg$)
While WindowEvent(): Wend
Delay(10000)
PureCOLOR_SetGadgetColor(1, -1, RGB(150,150, 255))
Msg$ = "Nope, that didn't work.  The text was changed to black (System default). "
Msg$ + " So, lets set it back to the original and try again."
SetGadgetText(3,Msg$)
While WindowEvent(): Wend
Delay(10000)
PureCOLOR_SetGadgetColor(1, RGB(255,0,0), -1)
While WindowEvent(): Wend
Delay(1000)
PureCOLOR_SetGadgetColor(1, 0, RGB(150,150, 255))
While WindowEvent(): Wend
Msg$ = "Nope, that didn't work.  The text was changed to black (System default) again. "
Msg$ + "So, lets set it back to the original and try again.  This time lets see if we can "
Msg$ + "find out its current color and just reset to that."
SetGadgetText(3,Msg$)
PureCOLOR_SetGadgetColor(1, RGB(255,0,0), -1)
While WindowEvent(): Wend
Delay(1000)
ActivateGadget(1)
TextColor = GetSysColor_(#COLOR_WINDOWTEXT) 
PureCOLOR_SetGadgetColor(1, TextColor, RGB(150,150, 255))
Msg$ = "Nope, that didn't work.  The text was changed to black (System default) again. "
Msg$ + "But, obviously, I don't know how to use the WinAPI to get the current text color."
SetGadgetText(3,Msg$)
While WindowEvent(): Wend

Repeat 
Until WaitWindowEvent() = #PB_EventCloseWindow 
End
I want to change the background color of the gadget and leave the
text color alone, no matter what the current color is.

The -1 parameter is great to return to the System Default color, and I
use it. Is it possible to have another value that leaves the existing color
as is when the PureCOLOR_SetGadgetColor() command is executed.

Terry

Posted: Sun Jan 01, 2006 12:19 pm
by gnozal
Let's see if I understand : you want a special value (let's say #PureCOLOR_LastDefinedValue) that doesn't change the current color ?
For example :

Code: Select all

PureCOLOR_SetGadgetColor(#Gadget, #Red, #White) ; --> Text = Red : Background = White
; You have to define the colors a first time before using #PureCOLOR_LastDefinedValue
PureCOLOR_SetGadgetColor(#Gadget, #PureCOLOR_LastDefinedValue, #Green) ; --> Text = Red : Background = Green
PureCOLOR_SetGadgetColor(#Gadget, #Blue, #PureCOLOR_LastDefinedValue) ; --> Text = Blue : Background = Green
Am I correct ?

Posted: Sun Jan 01, 2006 4:57 pm
by TerryHough
Yes!

PureCOLOR library : coloring gadgets (and much more)

Posted: Mon Jan 02, 2006 12:57 pm
by gnozal
Update

Changes :
- New special value #PureCOLOR_UseLastColor for SetGadgetColor() and SetButtonColor() => color is the last color set (don't change current color)
- GetCellColor() function was missing : fixed.

Posted: Mon Jan 02, 2006 3:05 pm
by TerryHough
Works great! At least for the text portion.

But, I am getting a white background when using
#PureCOLOR_UseLastColor for the background sometimes. I will work
with it a bit more to make sure I haven't used it incorrectly.

It seems to work in my example, but not in the main program. :(

Thanks,
Terry

Re: PureCOLOR library : coloring gadgets (and much more)

Posted: Fri Jan 13, 2006 4:49 pm
by rlumley
gnozal wrote:PureCOLOR library V12.04 (Jan 02nd 2006)

Purpose

Code: Select all

Coloring gadgets as simply as possible, and some other nice coloring functions
Functions

Code: Select all

* PureCOLOR_SetGadgetColor(GadgetNumber.l, TextColor.l, BackColor.l) 

Set gadget colors (any gadget except a ButtonGadget).

For buttons, use PureCOLOR_SetButtonColor().

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color
  #PureCOLOR_UseLastColor => TextColor is the last color set (don't change current color)

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color
  #PureCOLOR_DontSetBackColor => BackColor is parent window color (simulates transparency)
  #PureCOLOR_UseLastColor => BackColor is the last color set (don't change current color)

* PureCOLOR_SetGadgetColorEx(GadgetNumber.l, TextColor.l, BackColor.l, Param.l, Flag.l) 

Extended version of PureCOLOR_SetGadgetColor()

PureCOLOR_SetGadgetColorEx(GadgetNumber.l, TextColor.l, BackColor.l, 0, #PureCOLOR_LV_Standard) is equivalent to PureCOLOR_SetGadgetColor(GadgetNumber.l, TextColor.l, BackColor.l)

Colors :

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color
  #PureCOLOR_DontSetBackColor => BackColor is parent window color (simulates transparency)

Flags : * LISTICON GADGET

           - #PureCOLOR_LV_AlternateColors  [Param is a long (Param.l)]
  
            Alternate ListIconView row colors :BackColor  -> Even row color
                         Param.l      -> Odd row color

           - #PureCOLOR_LV_AlternateColors2  [Param is a long (Param.l)]
  
            Alternate ListIconView column colors :BackColor  -> Even column color
                         Param.l      -> Odd column color
            
           - #PureCOLOR_LV_GreaterThan      [Param is a structure address (@Param.PureCOLOR_ParamStructure)]
          
            Value dependant cell colors       :Param\SpecialTextColor -> text color
                                                                Param\SpecialBackColor -> back color
                                                               Param\SpecialTestValue -> test value
            
            Gadget cell color is (Param\SpecialTextColor, Param\SpecialBackColor) if the cell value is > Param\SpecialTestValue
            If Param\SpecialBackColor = #PureCOLOR_DontSetBackColor, there is no background color change                        
            [WORKS WITH NUMERIC CELL VALUES ONLY]
            
           - #PureCOLOR_LV_LesserThan       [Param is a structure address (@Param.PureCOLOR_ParamStructure)]
          
            Value dependant cell colors       :Param\SpecialTextColor -> text color
                                                Param\SpecialBackColor -> back color
                                                Param\SpecialTestValue -> test value
            
            Gadget cell color is (Param\SpecialTextColor, Param\SpecialBackColor) if the cell value is < Param\SpecialTestValue
            If Param\SpecialBackColor = #PureCOLOR_DontSetBackColor, there is no background color change                        
            [WORKS WITH NUMERIC CELL VALUES ONLY]
           
          * TREE GADGET
         
           - #PureCOLOR_TV_NodeLevel1  [Param is a long (Param.l)]
           
            Set colors for node level 1 (and TreeGadget background color) : TextColor.l, BackColor.l
            If Param = #PureCOLOR_DontSetBackColor, there is no background color change
         
           - #PureCOLOR_TV_NodeLevel2  [Param = 0]
           
            Set colors for node level 2 (and TreeGadget background color) : TextColor.l, BackColor.l

           - #PureCOLOR_TV_NodeLevel3  [Param = 0]
           
            Set colors for node level 3 (and TreeGadget background color) : TextColor.l, BackColor.l

           - #PureCOLOR_TV_NodeLevel4  [Param = 0]
           
            Set colors for node level 4 (and TreeGadget background color) : TextColor.l, BackColor.l
            
           The node levels > 4 are colored like node 1
           
          * TREE OR LISTICON GADGETS
         
           - #PureCOLOR_LTV_SelectedItem  [Param = 0]
           
            Set colors for the selected item (selection bar) : TextColor.l, BackColor.l

          * MISCELLANOUS GADGETS

           - #PureCOLOR_BackgroundImage        [Param is a long (Param.l)]

             Set a 'transparent' backcolor for the gadget (backcolor = image color)
             Param is the image output id.

* PureCOLOR_SetButtonColor(GadgetNumber.l, TextColor.l, BackColor.l, [TextColorPushed.l, [BackColorPushed.l]]) 

Set button colors.

All colors are are RGB values.

Optional parameters :

TextColorPushed :text color when button is pushed (and toggle text color)
BackColorPushed :back color when button is pushed (and toggle back color)

Special values :

#PureCOLOR_SystemColor => color is system color
#PureCOLOR_UseLastColor => color is the last color set (don't change current color)


* PureCOLOR_ClearGadgetColor(GadgetNumber.l) 

Clear gadget color set with PureCOLOR_SetGadgetColor(), PureCOLOR_SetGadgetColorEx() or PureCOLOR_SetButtonColor().

* PureCOLOR_SetCellColor(ListIconNumber.l, Row.l, Column.l, TextColor.l, BackColor.l) 

Set listicon cell color.

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color

Note : the listicon cell / row / column coloring functions use dynamic coordinates, e.g. the colorized cells / rows / columns coordinates are changed in realtime when the listicon [Add|Remove]Gadget[Item|Column]() functions are used.
For example : if cell (1,1) is colorized and a column is added at position 1, the cell coordinates are changed to (1,2) : the cell remains colorized (the new cell (1,1) is not).
The coloring priority is Cells > Columns > Rows.

* PureCOLOR_SetCellColorCallback(*ProcedureAddress) 

Declare a ListIcon coloring callback.

The callback is a procedure called for each cell in a ListIconGadget. It allows the user to modify the cell colors according to its content.

* PureCOLOR_GetCellColor(ListIconNumber.l, Row.l, Column.l, WhatColor.l) 

Get the listicon cell color, set with the PureCOLOR SetCellColor() / SetColumnColor() / SetRowColor() functions.

Returned values
- Cell TextColor if WhatColor = 1
- Cell BackColor if WhatColor = 2
- #CLR_DEFAULT if no color is set for the cell or the cell don't exist

TextColor and BackColor are RGB values.

* PureCOLOR_ClearCellColor(ListIconNumber.l, Row.l, Column.l) 

Clear listicon cell color.

* PureCOLOR_SetColumnColor(ListIconNumber.l, Column.l, TextColor.l, BackColor.l) 

Set listicon column color.

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color

Note : the listicon cell / row / column coloring functions use dynamic coordinates, e.g. the colorized cells / rows / columns coordinates are changed in realtime when the listicon [Add|Remove]Gadget[Item|Column]() functions are used.
For example : if cell (1,1) is colorized and a column is added at position 1, the cell coordinates are changed to (1,2) : the cell remains colorized (the new cell (1,1) is not).
The coloring priority is Cells > Columns > Rows.

* PureCOLOR_ClearColumnColor(ListIconNumber.l, Column.l) 

Clear listicon column color.

* PureCOLOR_SetRowColor(ListIconNumber.l, Row.l, TextColor.l, BackColor.l) 

Set listicon row color.

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color

Note : the listicon cell / row / column coloring functions use dynamic coordinates, e.g. the colorized cells / rows / columns coordinates are changed in realtime when the listicon [Add|Remove]Gadget[Item|Column]() functions are used.
For example : if cell (1,1) is colorized and a column is added at position 1, the cell coordinates are changed to (1,2) : the cell remains colorized (the new cell (1,1) is not).
The coloring priority is Cells > Columns > Rows.

* PureCOLOR_ClearRowColor(ListIconNumber.l, Row.l) 

Clear listicon row color.

* PureCOLOR_SetTreeItemColor(TreeNumber.l, ItemNumber.l, TextColor.l, BackColor.l) 

Set tree item color.

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color

* PureCOLOR_ClearTreeItemColor(TreeNumber.l, ItemNumber.l) 

Clear tree item color.

* PureCOLOR_SetColumnHeaderColor(ListIconNumber.l, Column.l, TextColor.l, BackColor.l) 

Set listicon column header color.

TextColor and BackColor are RGB values.

Special values :

- TextColor :
  #PureCOLOR_SystemColor => TextColor is system color

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color

Note : this function uses dynamic coordinates, e.g. the colorized columns coordinates are changed in realtime when the listicon [Add|Remove]GadgetColumn() functions are used.

* PureCOLOR_ClearColumnHeaderColor(ListIconNumber.l, Column.l) 

Clear listicon column header color.

* PureCOLOR_ClearAllColorsForGadget(GadgetNumber.l) 

Clear all colors for the specified gadget.

Usefull for complex gadgets like ListIcon or TreeView (clears cells colors, row colors, column colors, etc...).

* PureCOLOR_ClearAllGadgetColors() 

Clear all gadget colors.

* PureCOLOR_SetWindowColor(WindowNumber.l, BackColor.l) 

Set window back color.

BackColor is a RGB value.

Special values :

- BackColor :
  #PureCOLOR_SystemColor => BackColor is system color

* PureCOLOR_ClearWindowColor(WindowNumber.l) 

Clear window color.

* PureCOLOR_SetMenuColors(MenuNumber.l , TextColor.l, BackColor.l, TextColorSelected.l, BackColorSelected.l) 

Set menu text and back colors [may not work with WinNT4].
Up to 3 menu levels are supported.

Colors :

All colors are RGB values.
TextColorSelected and BackColorSelected are the colors of a selected or hotlighted menu item.

Special values :

#PureCOLOR_SystemColor => color is system color

* PureCOLOR_SetMenuItemColors(MenuNumber.l, MenuItemID.l, TextColor.l, BackColor.l, TextColorSelected.l, BackColorSelected.l) 

Set menu item colors for an existing ownerdrawn menu [may not work with WinNT4]
Up to 3 menu levels are supported.

Colors :

All colors are RGB values.
TextColorSelected and BackColorSelected are the colors of a selected or hotlighted menu item.

Special values :

#PureCOLOR_SystemColor => color is system color

* PureCOLOR_SetPopupMenuBackColor(MenuNumber.l, BackColor.l) 

Set menu backcolor [may not work with WinNT4].

* PureCOLOR_RedrawGadgetAfterColor(TrueOrFalse.l) 

Set gadget redraw mode after color is set or cleared.

Values :

#TRUE :the gadget is redrawn [WinAPI RedrawWindow()] after color is set or cleared [Default];
#FALSE :the gadget is not redrawn after color is set or cleared.
Example

Code: Select all

; Create Window
OpenWindow(0, 100, 300, 400, 200, #PB_Window_SystemMenu, "PureCOLOR test") 
If CreateGadgetList(WindowID()) 
  StringGadget(1, 10, 10, 90, 20, "StringGadget 1")
  ListIconGadget(2, 10, 40, 150, 100, "", 146, #PB_ListIcon_GridLines)
  AddGadgetItem(2, -1, "ListIconGadget 2-1")
  AddGadgetItem(2, -1, "ListIconGadget 2-2")
  AddGadgetItem(2, -1, "ListIconGadget 2-3")
  AddGadgetItem(2, -1, "ListIconGadget 2-4")
  AddGadgetItem(2, -1, "ListIconGadget 2-5")
  TextGadget(3, 10, 160, 300, 30, "TextGadget 3", #PB_Text_Center)
  ButtonGadget(4, 200, 10, 80, 20, "Button 4")
  ComboBoxGadget(5, 295, 10, 100, 100)
  AddGadgetItem(5, -1, "ComboBox 5-1")
  AddGadgetItem(5, -1, "ComboBox 5-2")
  SetGadgetState(5, 0)
  CheckBoxGadget(6, 110, 10, 80, 20, "CheckBox 6")
  ListViewGadget(7, 160, 40, 150, 100, #PB_ListIcon_GridLines)
  AddGadgetItem(7, -1, "ListViewGadget 7-1")
  AddGadgetItem(7, -1, "ListViewGadget 7-2")
  AddGadgetItem(7, -1, "ListViewGadget 7-3")
EndIf
; Adding colors
PureCOLOR_SetGadgetColor(1, RGB(255,0,0), -1)
;PureCOLOR_SetGadgetColor(2, RGB(0,255,0), -1)
PureCOLOR_SetGadgetColorEx(2, RGB(0,0,0), RGB(255, 255, 255), RGB(255, 255, 223), #PureCOLOR_LV_AlternateColors)
PureCOLOR_SetGadgetColor(3, RGB(255,0,0), RGB(0,0,0))
PureCOLOR_SetButtonColor(4, RGB(255,0,0), RGB(0,255,0))
PureCOLOR_SetGadgetColor(5, RGB(255,0,0), RGB(255,255,0))
PureCOLOR_SetGadgetColor(6, RGB(255,255,0), -1)
PureCOLOR_SetGadgetColor(7, RGB(255,0,0), RGB(100,100,0))
;PureCOLOR_ClearGadgetColor(2)
;
Repeat 
Until WaitWindowEvent() = #PB_EventCloseWindow 
;
End

Download
http://people.freenet.de/gnozal/PureCOLOR.zip

Image
Image

Other libs and tools at http://people.freenet.de/gnozal

Posted: Sat Jan 14, 2006 8:53 am
by gnozal
TerryHough wrote:Works great! At least for the text portion.

But, I am getting a white background when using
#PureCOLOR_UseLastColor for the background sometimes. I will work
with it a bit more to make sure I haven't used it incorrectly.

It seems to work in my example, but not in the main program. :(

Thanks,
Terry
Should be fixed now.

Posted: Sat Jan 14, 2006 10:11 am
by gnozal
Update

Changes :
- Fixed a bug when BackColor = #PureCOLOR_UseLastColor for some gadgets

Posted: Sun Jan 15, 2006 3:30 pm
by wcardoso
sorry if I repeat someone request, but, can you add coloring statusbar items ?. Both fore & back one. :wink:
thanks

Posted: Mon Jan 16, 2006 8:48 am
by gnozal
wcardoso wrote:sorry if I repeat someone request, but, can you add coloring statusbar items ?. Both fore & back one. :wink:
thanks
Maybe :wink:

Posted: Wed Jan 25, 2006 10:49 am
by Flype
hello gnozal,

when i use coloring for values in a listicongadget, for example, all positives values in GREEN, and all negatives values in RED. It's Ok, it's works. BUT, can i specify only a specific column and let the others unchanged which is important for my soft ?

With earlier version of your lib, i did this thanks the function PureCOLOR_SetColumnColor() before or after. But now adding this function make the PureCOLOR_SetGadgetColorEx not working.

Can you have a look at it, please.

Code: Select all

  PureCOLORParam.PureCOLOR_ParamStructure
  PureCOLORParam\SpecialTextColor = $0000FF
  PureCOLORParam\SpecialBackColor = #PureCOLOR_DontSetBackColor
  PureCOLORParam\SpecialTestValue = 0
  PureCOLOR_SetGadgetColorEx(#gListe,0,0,@PureCOLORParam,#PureCOLOR_LV_LesserThan)
  
  PureCOLORParam.PureCOLOR_ParamStructure
  PureCOLORParam\SpecialTextColor = $00AA00
  PureCOLORParam\SpecialBackColor = #PureCOLOR_DontSetBackColor
  PureCOLORParam\SpecialTestValue = 0
  PureCOLOR_SetGadgetColorEx(#gListe,0,0,@PureCOLORParam,#PureCOLOR_LV_GreaterThan)
so i would be pleased to see in this piece of code a new line :
PureCOLORParam\SpecialTestColumn = 5 ; a specifc column
PureCOLORParam\SpecialTestColumn = -1 ; all columns

Best regards.

Posted: Wed Jan 25, 2006 11:23 am
by gnozal
Flype wrote:hello gnozal,
when i use coloring for values in a listicongadget, for example, all positives values in GREEN, and all negatives values in RED. It's Ok, it's works. BUT, can i specify only a specific column and let the others unchanged which is important for my soft ?
What about the new PureCOLOR_SetCellColorCallback() function ?
Maybe it can do the job for you ?

Code: Select all

Procedure MyCellColorCallback(GadgetNumber.l, CellRow.l, CellColumn.l, *TextColor, *BackColor)
  If GadgetNumber = 1 And CellColumn = 1 ; <----- Example modified to color only column 1
    CellText.s = GetGadgetItemText(GadgetNumber, CellRow, CellColumn)
    Debug Str(CellRow) + ":" + Str(CellColumn) + ">" + CellText
    Select CellText
      Case "Red"
        PokeL(*TextColor, #Red)
        Debug "-> Red"
      Case "Blue"
        PokeL(*BackColor, #Blue)
        PokeL(*TextColor, #White)
        Debug "-> Blue"
      Case "Green"
        PokeL(*TextColor, #Green)
        Debug "-> Green"
    EndSelect
  EndIf
EndProcedure
; Create Window
OpenWindow(0, 100, 300, 400, 200, #PB_Window_SystemMenu, "PureCOLOR test : cell callback demo")
If CreateGadgetList(WindowID())
  ListIconGadget(1, 1, 1, 300, 160, "0", 100, #PB_ListIcon_GridLines | #PB_ListIcon_FullRowSelect)
  ;
  AddGadgetColumn(1, 1, "1", 100)
  AddGadgetColumn(1, 2, "2", 100)
  AddGadgetItem(1, -1, "0:0" + Chr(10) + "0:1" + Chr(10) + "Red")
  AddGadgetItem(1, -1, "1:0" + Chr(10) + "1:1" + Chr(10) + "1:2")
  AddGadgetItem(1, -1, "Blue" + Chr(10) + "Green" + Chr(10) + "2:2")
  AddGadgetItem(1, -1, "3:0" + Chr(10) + "Red" + Chr(10) + "3:2")
  AddGadgetItem(1, -1, "Red" + Chr(10) + "4:1" + Chr(10) + "Red")
  AddGadgetItem(1, -1, "Green" + Chr(10) + "Blue" + Chr(10) + "5:2")
  AddGadgetItem(1, -1, "6:0" + Chr(10) + "6:1" + Chr(10) + "6:2")
  AddGadgetItem(1, -1, "Red" + Chr(10) + "Blue" + Chr(10) + "7:2")
EndIf
PureCOLOR_SetCellColorCallback(0, @MyCellColorCallback())
Repeat
  EventID.l = WaitWindowEvent()
  If EventID = #PB_EventCloseWindow
    Break
  EndIf
ForEver
;
End