Page 4 of 35

Posted: Thu Mar 24, 2005 11:42 pm
by DoubleDutch
Me again! :D

It would be a great feature if there was a #nochange colour value...

eg:

Code: Select all

PureCOLORParam.PureCOLOR_ParamStructure
PureCOLORParam\SpecialTextColor=RGB(255,255,255)
PureCOLORParam\SpecialBackColor=#NoChange
PureCOLORParam\SpecialTestValue=0
PureCOLOR_SetGadgetColorEx(#Customers,0,0,@PureCOLORParam,#PureCOLOR_LV_LesserThan)
This would make programs using the alternate colour bars look much better when displaying negative values...

-Anthony

Posted: Fri Mar 25, 2005 8:41 am
by gnozal
@DoubleDutch : much work, again :shock:
I will see what I can do ...

DoubleDutch, double requests :lol:

Posted: Fri Mar 25, 2005 8:48 am
by gnozal
DoubleDutch wrote:It would be a great feature if there was a #nochange colour value...
I don't have the source right now, but did you try #CLR_DEFAULT?

Posted: Fri Mar 25, 2005 2:26 pm
by DoubleDutch
Just tried that - it sets it to white.

Its mainly for use with the alternating colour rows... This way the correct alternating colour would show up with a new text colour. eg. RED if the figure is negative.

This would be a nice addition:

Code: Select all

Procedure PureCOLOR_SetListIconUnused(Gadget,Colour)
  result=SendMessage_(GadgetID(Gadget),#LVM_SETBKCOLOR,0,Colour)
  ProcedureReturn result
EndProcedure
It allows you to set the colour of the unused area (not the actual used area of the list) of the ListIcon gadget...

It looks really good when combined with your alternate colours...



-Anthony

Posted: Sat Mar 26, 2005 10:49 am
by gnozal
Library update
- fixed : PureCOLOR_SetGadgetColorEx() with #PureCOLOR_LV_AlternateColors flag did not colorize text
thanks DoubleDutch for the report
- new feature : the PureCOLOR_SetGadgetColor() and PureCOLOR_SetGadgetColorEx() functions will now colorize the unused background area of ListIconGadgets with BackColor
thanks (again) DoubleDutch for the idea
- new feature : PureCOLOR_SetGadgetColorEx() with #PureCOLOR_LV_[Lesser|Greater]Than flags ; if SpecialBackColor = #CLR_DEFAULT, there is no background color change.
thanks (double again) DoubleDutch for the idea

Posted: Sun Mar 27, 2005 12:24 am
by DoubleDutch
Wow, fast response and great new commands! :)

Thanks for the mention too! :D

-Anthony

Posted: Sun Mar 27, 2005 12:49 am
by DoubleDutch
Noticed that a slight bug has appeared into this version...

Code: Select all

PureCOLOR_SetGadgetColorEx(#Bank,0,0,@PureCOLORParam,#PureCOLOR_LV_LesserThan)
Will colour the text < the value specified great! - but it will also colour any text that shouldn't be affected by the condition to black!

If I put:

Code: Select all

PureCOLOR_SetGadgetColor(#Bank,NormalTextColour,BackgroundColour)
after the PureCOLOR_SetGadgetColorEx I can sort it out to be the same result as before, but I thought you may like to know about this bug.

Other than that, the library is greater than ever! :D

Much thanks for the modifications...

Now if only tree gadget was next.... ;)

-Anthony

Posted: Tue Mar 29, 2005 8:21 am
by gnozal
DoubleDutch wrote:Noticed that a slight bug has appeared into this version...

Code: Select all

PureCOLOR_SetGadgetColorEx(#Bank,0,0,@PureCOLORParam,#PureCOLOR_LV_LesserThan)
Will colour the text < the value specified great! - but it will also colour any text that shouldn't be affected by the condition to black!
Fixed (Library and resident updated)

Posted: Tue Mar 29, 2005 2:52 pm
by DoubleDutch
Hi Gnozal,

Thanks for all the additions and fixes... :D

I've done a routine to test colouring tree gadgets, you may like to include the method in PureCOLOR???

Code: Select all

Enumeration
  #MainWindow
  #TreeGadget
EndEnumeration

#CDIS_FOCUS = $10 
#CDIS_SELECTED = 1

#CDDS_ITEM = $10000 
#CDDS_MAPPART = 5 
#CDDS_POSTERASE = 4 
#CDDS_POSTPAINT = 2 
#CDDS_PREERASE = 3 
#CDDS_PREPAINT = 1 
#CDDS_ITEMPOSTERASE = #CDDS_ITEM | #CDDS_POSTERASE 
#CDDS_ITEMPOSTPAINT = #CDDS_ITEM | #CDDS_POSTPAINT 
#CDDS_ITEMPREERASE = #CDDS_ITEM | #CDDS_PREERASE 
#CDDS_ITEMPREPAINT = #CDDS_ITEM | #CDDS_PREPAINT 
#CDDS_SUBITEM = $20000 

#CDRF_DODEFAULT = 0 
#CDRF_NEWFONT = 2 
#CDRF_NOTIFYITEMDRAW = $20 
#CDRF_NOTIFYPOSTERASE = $40 
#CDRF_NOTIFYPOSTPAINT = $10 
#CDRF_NOTIFYSUBITEMDRAW = $20 
#CDRF_SKIPDEFAULT = 4

Procedure MyWindowCallback(WindowID,Message,wParam,lParam) 
  Result=#PB_ProcessPureBasicEvents
  Select Message
    Case  #WM_NOTIFY
      *tvCD.NMTVCUSTOMDRAW=lparam
      If *tvCD\nmcd\hdr\hwndFrom=GadgetID(#TreeGadget) And *tvCD\nmcd\hdr\code=#NM_CUSTOMDRAW    
        Select *tvCD\nmcd\dwDrawStage
          Case #CDDS_PREPAINT
            ProcedureReturn #CDRF_NOTIFYPOSTPAINT|#CDRF_NOTIFYITEMDRAW
          Case #CDDS_PREPAINT
            ProcedureReturn #CDRF_NOTIFYITEMDRAW
          Case #CDDS_ITEMPREPAINT
            Select *tvCD\iLevel
              Case 0
                If *tvCD\nmcd\uItemState=(#CDIS_FOCUS|#CDIS_SELECTED)
                  *tvCD\clrText=RGB(255,255,0) 
                  *tvCD\clrTextBk=RGB(0,0,255)
                Else        
                  *tvCD\clrText=RGB(255,255,0) 
                  *tvCD\clrTextBk=RGB(0,0,255)
                EndIf
              Default
                 If *tvCD\nmcd\uItemState=(#CDIS_FOCUS|#CDIS_SELECTED)
                  *tvCD\clrText=RGB(255,255,255) 
                  *tvCD\clrTextBk=RGB(128,0,128)
                Else        
                  *tvCD\clrText=RGB(0,255,0) 
                  *tvCD\clrTextBk=RGB(0,128,0)
                EndIf             
            EndSelect
            ProcedureReturn #CDRF_NEWFONT
        EndSelect
      EndIf
  EndSelect 
  ProcedureReturn Result 
EndProcedure 


If OpenWindow(#MainWindow,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"TreeGadget") And CreateGadgetList(WindowID(0))
  TreeGadget(#TreeGadget, 10,10,330,160)  
  For a=0 To 10
    AddGadgetItem (#TreeGadget,-1,"Normal Item "+Str(a)) 
    AddGadgetItem (#TreeGadget,-1,"Node "+Str(a))
    OpenTreeGadgetNode(#TreeGadget)
      AddGadgetItem(#TreeGadget,-1,"Sub-Item 1")
      AddGadgetItem(#TreeGadget,-1,"Sub-Item 2")
      AddGadgetItem(#TreeGadget,-1,"Sub-Item 3")
      AddGadgetItem(#TreeGadget,-1,"Sub-Item 4")
    CloseTreeGadgetNode(#TreeGadget)
    AddGadgetItem (#TreeGadget,-1,"File "+Str(a))
  Next
  SetWindowCallback(@MyWindowCallback()) 
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Notice that "nmcd\uItemState=(CDIS_FOCUS|CDIS_SELECTED)" is used to see if the item is currently focused/selected - maybe you could use this also with listview and other gadgets?

If you do add treegadgets then you could have a special case like:

Code: Select all

PureCOLOR_SetGadgetColorEx(GadgetNumber.l, TextColor.l, BackColor.l,Level.l, #PureCOLOR_TV_Level)
What do you think?

(I've edited the code above to include the bug fix mentioned below! :D )

Posted: Tue Mar 29, 2005 2:55 pm
by DoubleDutch
Fred: You should ask Gnozal if you can include PureCOLOR in purebasic as standard - its a great library.

Posted: Tue Mar 29, 2005 3:05 pm
by gnozal
DoubleDutch wrote:Hi Gnozal,
Thanks for all the additions and fixes... :D
:D
DoubleDutch wrote:I've done a routine to test colouring tree gadgets, you may like to include the method in PureCOLOR???
What do you think?
Good idea, thanks.
I will see how to include something like this in the library. The tree levels may be a problem (not compatible with the actual structure holding the gadget coloring information [same structure for all gadgets]).

Posted: Tue Mar 29, 2005 3:12 pm
by DoubleDutch
That would be great!

Thanks,

-Anthony

Posted: Wed Mar 30, 2005 12:41 am
by DoubleDutch
I noticed a bug in the code I posted, the text (appears twice):

Code: Select all

CDIS_FOCUS|CDIS_SELECTED
Should be:

Code: Select all

#CDIS_FOCUS|#CDIS_SELECTED
Also include this at the top:

Code: Select all

#CDIS_FOCUS = $10
#CDIS_SELECTED = 1 
Sorry for any confusion...

-Anthony

Posted: Thu Mar 31, 2005 9:48 am
by gnozal
Notice that "nmcd\uItemState=(CDIS_FOCUS|CDIS_SELECTED)" is used to see if the item is currently focused/selected - maybe you could use this also with listview and other gadgets?
It seems to work quite well with a TreeView but it does not seem to work with a ListIconView :

Code: Select all

Enumeration 
  #MainWindow 
  #TreeGadget 
EndEnumeration 

#CDIS_FOCUS = $10 
#CDIS_SELECTED = 1 

#CDDS_ITEM = $10000 
#CDDS_MAPPART = 5 
#CDDS_POSTERASE = 4 
#CDDS_POSTPAINT = 2 
#CDDS_PREERASE = 3 
#CDDS_PREPAINT = 1 
#CDDS_ITEMPOSTERASE = #CDDS_ITEM | #CDDS_POSTERASE 
#CDDS_ITEMPOSTPAINT = #CDDS_ITEM | #CDDS_POSTPAINT 
#CDDS_ITEMPREERASE = #CDDS_ITEM | #CDDS_PREERASE 
#CDDS_ITEMPREPAINT = #CDDS_ITEM | #CDDS_PREPAINT 
#CDDS_SUBITEM = $20000 

#CDRF_DODEFAULT = 0 
#CDRF_NEWFONT = 2 
#CDRF_NOTIFYITEMDRAW = $20 
#CDRF_NOTIFYPOSTERASE = $40 
#CDRF_NOTIFYPOSTPAINT = $10 
#CDRF_NOTIFYSUBITEMDRAW = $20 
#CDRF_SKIPDEFAULT = 4 

Procedure MyWindowCallback(WindowID,Message,wParam,lParam) 
  Result=#PB_ProcessPureBasicEvents 
  Select Message 
    Case  #WM_NOTIFY 
      *lvCD.NMLVCUSTOMDRAW = lParam 
      If *lvCD\nmcd\hdr\hwndFrom=GadgetID(#TreeGadget) And *lvCD\nmcd\hdr\code=#NM_CUSTOMDRAW    
        Select *lvCD\nmcd\dwDrawStage 
          Case #CDDS_PREPAINT 
            ProcedureReturn #CDRF_NOTIFYPOSTPAINT|#CDRF_NOTIFYITEMDRAW 
          Case #CDDS_PREPAINT 
            ProcedureReturn #CDRF_NOTIFYITEMDRAW 
          Case #CDDS_ITEMPREPAINT 
            If *lvCD\nmcd\uItemState & (#CDIS_FOCUS | #CDIS_SELECTED)
              Debug "Selected line " + Str(*lvCD\nmcd\dwItemSpec)
              *lvCD\clrText=RGB(0,255,0) 
              *lvCD\clrTextBk=RGB(0,0,255) 
              ; the selected line is not colorized
            Else        
              *lvCD\clrText=RGB(255,255,0) 
              *lvCD\clrTextBk=RGB(0,0,255) 
            EndIf 
            ProcedureReturn #CDRF_NEWFONT 
        EndSelect 
      EndIf 
  EndSelect 
  ProcedureReturn Result 
EndProcedure 


If OpenWindow(#MainWindow,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ListIconGadget") And CreateGadgetList(WindowID(0)) 
  ListIconGadget(#TreeGadget, 10,10,330,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) + "0:2")
  AddGadgetItem(1, -1, "1:0" + Chr(10) + "1:1" + Chr(10) + "1:2")
  AddGadgetItem(1, -1, "2:0" + Chr(10) + "2:1" + Chr(10) + "2:2")
  AddGadgetItem(1, -1, "3:0" + Chr(10) + "3:1" + Chr(10) + "3:2")
  AddGadgetItem(1, -1, "4:0" + Chr(10) + "4:1" + Chr(10) + "4:2")
  AddGadgetItem(1, -1, "5:0" + Chr(10) + "5:1" + Chr(10) + "5:2")
  AddGadgetItem(1, -1, "6:0" + Chr(10) + "6:1" + Chr(10) + "6:2")
  AddGadgetItem(1, -1, "7:0" + Chr(10) + "7:1" + Chr(10) + "7:2")
  
  SetWindowCallback(@MyWindowCallback()) 
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf
This is a bit tricky but seems to work with a ListIconView :

Code: Select all

Enumeration 
  #MainWindow 
  #TreeGadget 
EndEnumeration 

#CDIS_FOCUS = $10 
#CDIS_SELECTED = 1 

#CDDS_ITEM = $10000 
#CDDS_MAPPART = 5 
#CDDS_POSTERASE = 4 
#CDDS_POSTPAINT = 2 
#CDDS_PREERASE = 3 
#CDDS_PREPAINT = 1 
#CDDS_SUBITEM = $20000

#CDDS_ITEMPOSTERASE = #CDDS_ITEM | #CDDS_POSTERASE 
#CDDS_ITEMPOSTPAINT = #CDDS_ITEM | #CDDS_POSTPAINT 
#CDDS_ITEMPREERASE = #CDDS_ITEM | #CDDS_PREERASE 
#CDDS_ITEMPREPAINT = #CDDS_ITEM | #CDDS_PREPAINT 
#CDDS_SUBITEMPREPAINT = #CDDS_SUBITEM | #CDDS_ITEMPREPAINT
#CDDS_SUBITEM = $20000 

#CDRF_DODEFAULT = 0 
#CDRF_NEWFONT = 2 
#CDRF_NOTIFYITEMDRAW = $20 
#CDRF_NOTIFYPOSTERASE = $40 
#CDRF_NOTIFYPOSTPAINT = $10 
#CDRF_NOTIFYSUBITEMDRAW = $20 
#CDRF_SKIPDEFAULT = 4 

Procedure.l MyWindowCallback(WindowID,Message,wParam,lParam) 
  Result=#PB_ProcessPureBasicEvents 
  Select Message 
    Case  #WM_NOTIFY 
      *lvCD.NMLVCUSTOMDRAW = lParam 
      If *lvCD\nmcd\hdr\hwndFrom=GadgetID(#TreeGadget) And *lvCD\nmcd\hdr\code=#NM_CUSTOMDRAW    
        Select *lvCD\nmcd\dwDrawStage 
          Case #CDDS_PREPAINT 
            Result = #CDRF_NOTIFYITEMDRAW 
          Case #CDDS_ITEMPREPAINT
            Result = #CDRF_NOTIFYSUBITEMDRAW
          Case #CDDS_SUBITEMPREPAINT
            If *lvCD\nmcd\uItemState & #CDIS_SELECTED
              Debug "Selected line " + Str(*lvCD\nmcd\dwItemSpec) + " column " + Str(*lvCD\iSubItem)
              *lvCD\nmcd\uItemState = *lvCD\nmcd\uItemState &~#CDIS_SELECTED
              Result = #CDRF_DODEFAULT
            EndIf
            If *lvCD\nmcd\uItemState & #CDIS_FOCUS
              *lvCD\clrText=RGB(0,255,255) 
              *lvCD\clrTextBk=RGB(255,127,255) 
              Result = #CDRF_NEWFONT 
            Else        
              *lvCD\clrText=RGB(255,255,0) 
              *lvCD\clrTextBk=RGB(0,0,255) 
              Result = #CDRF_NEWFONT 
            EndIf 
        EndSelect 
      EndIf 
  EndSelect 
  ProcedureReturn Result 
EndProcedure 


If OpenWindow(#MainWindow,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ListIconGadget") And CreateGadgetList(WindowID(0)) 
  ListIconGadget(#TreeGadget, 10,10,330,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) + "0:2")
  AddGadgetItem(1, -1, "1:0" + Chr(10) + "1:1" + Chr(10) + "1:2")
  AddGadgetItem(1, -1, "2:0" + Chr(10) + "2:1" + Chr(10) + "2:2")
  AddGadgetItem(1, -1, "3:0" + Chr(10) + "3:1" + Chr(10) + "3:2")
  AddGadgetItem(1, -1, "4:0" + Chr(10) + "4:1" + Chr(10) + "4:2")
  AddGadgetItem(1, -1, "5:0" + Chr(10) + "5:1" + Chr(10) + "5:2")
  AddGadgetItem(1, -1, "6:0" + Chr(10) + "6:1" + Chr(10) + "6:2")
  AddGadgetItem(1, -1, "7:0" + Chr(10) + "7:1" + Chr(10) + "7:2")
  SetWindowCallback(@MyWindowCallback()) 
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf

Posted: Thu Mar 31, 2005 12:07 pm
by HeX0R

Code: Select all

#PureCOLOR_LV_LesserThan
Hmm... wasn't it
-little
-less
-least