Page 5 of 35

Posted: Thu Mar 31, 2005 12:39 pm
by gnozal
HeX0R wrote:

Code: Select all

#PureCOLOR_LV_LesserThan
Hmm... wasn't it
-little
-less
-least
I am not english, but it seems correct to me.
http://66.102.9.104/search?q=cache:eJ9m ... Than&hl=en

Posted: Thu Mar 31, 2005 2:11 pm
by HeX0R
k, then i go and shoot my english-teacher (if she is still alive :o )

Posted: Fri Apr 01, 2005 11:18 am
by gnozal
Library update
- new feature : TreeGadget() now also works

Code: Select all

Procedure MyWindowCallback(WindowID,Message,wParam,lParam) 
  Result = #PB_ProcessPureBasicEvents 
  Result = PureCOLOR_CallBack(WindowID,Message,wParam,lParam, Result)
  ProcedureReturn Result 
EndProcedure 
;
Enumeration 
  #MainWindow 
  #TreeGadget 
EndEnumeration 
If OpenWindow(#MainWindow,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"PureCOLOR TreeGadget example") 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") 
    OpenTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1") 
    OpenTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1") 
    OpenTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-1") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-2") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-3") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-4") 
    CloseTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-2") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-3") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-4") 
    CloseTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-2") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-3") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-4") 
    CloseTreeGadgetNode(#TreeGadget) 
    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 
  ; PureCOLOR_SetGadgetColor(#TreeGadget, $FF00FF, $00FFFF)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $00FFFF, #PureCOLOR_DontSetBackColor, #PureCOLOR_TV_NodeLevel1)
  ; PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $00FFFF, 0, #_PureCOLOR_TV_NodeLevel1)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $00FF00, 0, #PureCOLOR_TV_NodeLevel2)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $0000FF, $FFFF00, 0, #PureCOLOR_TV_NodeLevel3)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $00FFFF, $FFFF00, 0, #PureCOLOR_TV_NodeLevel4)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $FFFF00, 0, #PureCOLOR_LTV_SelectedItem)
  SetWindowCallback(@MyWindowCallback()) 
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf 
- new flags for PureCOLOR_SetGadgetColorEx()

Code: Select all

          * 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 : TextColor.l, BackColor.l

Posted: Fri Apr 01, 2005 9:31 pm
by DoubleDutch
nice update, thanks! :)

Posted: Fri Apr 01, 2005 9:43 pm
by DoubleDutch
is there a way of colouring a particular item in the tree gadget with the library? This overiding the depth colour settings...

eg:

Code: Select all

PureCOLOR_SetTreeItemColor(gadget.l,item.l,backcolour.l,textcolour.l)
(with the background colour setting being optional as before?)

-Anthony

Posted: Sat Apr 02, 2005 7:42 am
by gnozal
DoubleDutch wrote:is there a way of colouring a particular item in the tree gadget with the library? This overiding the depth colour settings...

eg:

Code: Select all

PureCOLOR_SetTreeItemColor(gadget.l,item.l,backcolour.l,textcolour.l)
(with the background colour setting being optional as before?)

-Anthony
Like PureCOLOR_SetCellColor() for ListIcon, no. Not yet ? :wink:

Posted: Sat Apr 02, 2005 9:55 am
by gnozal
Yet another update :shock:
- new function : PureCOLOR_SetTreeItemColor()
- new function : PureCOLOR_ClearTreeItemColor()

Example

Code: Select all

Procedure MyWindowCallback(WindowID,Message,wParam,lParam) 
  Result = #PB_ProcessPureBasicEvents 
  Result = PureCOLOR_CallBack(WindowID,Message,wParam,lParam, Result)
  ProcedureReturn Result 
EndProcedure 
;
Enumeration 
  #MainWindow 
  #TreeGadget 
EndEnumeration 
If OpenWindow(#MainWindow,0,0,355,180,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"PureCOLOR TreeGadget example") 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") 
    OpenTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1") 
    OpenTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1") 
    OpenTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-1") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-2") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-3") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-1-4") 
    CloseTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-2") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-3") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-1-4") 
    CloseTreeGadgetNode(#TreeGadget) 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-2") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-3") 
    AddGadgetItem(#TreeGadget,-1,"Sub-Item 1-4") 
    CloseTreeGadgetNode(#TreeGadget) 
    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 
  ; PureCOLOR_SetGadgetColor(#TreeGadget, $FF00FF, $00FFFF)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $00FFFF, #PureCOLOR_DontSetBackColor, #PureCOLOR_TV_NodeLevel1)
  ; PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $00FFFF, 0, #_PureCOLOR_TV_NodeLevel1)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $00FF00, 0, #PureCOLOR_TV_NodeLevel2)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $0000FF, $FFFF00, 0, #PureCOLOR_TV_NodeLevel3)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $00FFFF, $FFFF00, 0, #PureCOLOR_TV_NodeLevel4)
  PureCOLOR_SetGadgetColorEx(#TreeGadget, $FF00FF, $FFFF00, 0, #PureCOLOR_LTV_SelectedItem)
  PureCOLOR_SetTreeItemColor(#TreeGadget, 2, $AA00AA, $AAFFAA)
  PureCOLOR_SetTreeItemColor(#TreeGadget, 20, $AA00AA, $AAFFAA)
  SetWindowCallback(@MyWindowCallback()) 
  Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow 
EndIf
I hope DoubleDutch is happy now :wink:

Posted: Sat Apr 02, 2005 11:00 am
by Blade
This userlib should be really included with the other official libs !!!
(but shold be done without using callbacks, they alway looks like some sort of hack)

Posted: Sat Apr 02, 2005 11:07 am
by gnozal
Blade wrote:but should be done without using callbacks, they alway looks like some sort of hack)
You can't do it without callbacks and some subclassing (although you can hide them), it's the way Windows works.

Posted: Sat Apr 02, 2005 1:20 pm
by DoubleDutch
I'm happy! :)

You know what would be REALLY good....

Being able to have type of control sequence to colour individual text items a different colour within a cell or tree...

eg:

Code: Select all

PureCOLOR_VirtualColorReg(1,rgb(255,0,0))  ; set virtual colour reg 1 to red

AddGadgetItem(#TreeGadget,-1,"Sub-~01Item~~ 1")  ; add an item with default text colour for "Sub-" and then red for "Item" and back to default for " 1"
I know its a bit of a hack and may need you to go a level deeper in the drawing process, but it would make it look even better...

What do you reckon?
This userlib should be really included with the other official libs !!!
Fred, are you reading this... I'm sure that a compatible set of commands would be possible in Linux and OSX???

-Anthony

Posted: Sat Apr 02, 2005 1:52 pm
by Blade
gnozal wrote:You can't do it without callbacks and some subclassing (although you can hide them), it's the way Windows works.
Yes, I can imagine this. Anyway, "official" PB comands do not require callbacks, I suppose that those callbacks are simply hidden to the user...

Posted: Mon Apr 04, 2005 7:45 am
by gnozal
DoubleDutch wrote:I'm happy!
Finally :wink: !
DoubleDutch wrote:Being able to have type of control sequence to colour individual text items a different colour within a cell or tree...

Code: Select all

PureCOLOR_VirtualColorReg(1,rgb(255,0,0))  ; set virtual colour reg 1 to red
AddGadgetItem(#TreeGadget,-1,"Sub-~01Item~~ 1")  ; add an item with default text colour for "Sub-" and then red for "Item" and back to default for " 1"
Seems a bit complicated ... Isn't it possible with the existing functions ?
This userlib should be really included with the other official libs !!!
Well, althought I am not against it, I am not sure it is a good idea : it is not a 'developper' library written in ASM, it's a 'user' library compiled with Tailbite.

Posted: Tue Apr 05, 2005 4:11 pm
by DoubleDutch
It may not have been clear, but in some circumstances I just want to be able to colour part of the text in a tree.

eg
users
anthony
joseph
the account is overdue, click here to send a reminder...
joshua

I would colour the "overdue" in say red, but the "here" in blue, the rest in black...

Can this be done already, or will the colouring have to be done at a lower level?

Posted: Wed Apr 06, 2005 7:37 am
by gnozal
DoubleDutch wrote:It may not have been clear, but in some circumstances I just want to be able to colour part of the text in a tree.

eg
users
anthony
joseph
the account is overdue, click here to send a reminder...
joshua

I would colour the "overdue" in say red, but the "here" in blue, the rest in black...

Can this be done already, or will the colouring have to be done at a lower level?
Now I understand ; you mean having different colors in the same (sub)item ?
I am not sure how to do this :oops: Is it possible ?

Posted: Wed Apr 06, 2005 12:27 pm
by DoubleDutch
This code should demonstrate the drawing...

Code: Select all

Enumeration
  #MainWindow
  #MainGadget
EndEnumeration

#LVM_GETSUBITEMRECT = #LVM_FIRST + 56 

#CDIS_CHECKED = 8 
#CDIS_DEFAULT = $20 
#CDIS_DISABLED = 4 
#CDIS_FOCUS = $10 
#CDIS_GRAYED = 2 
#CDIS_HOT = $40 
#CDIS_INDETERMINATE = $100 
#CDIS_MARKED = $80 
#CDIS_SELECTED = 1 
#CDIS_SHOWKEYBOARDCUES = $200 

#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

#DT_WORD_ELLIPSIS = $40000 
#DT_END_ELLIPSIS = $8000 
#DT_PATH_ELLIPSIS = $4000 
#DT_MODIFYSTRING = $10000 

Procedure MyWindowCallback(WindowID,Message,wParam,lParam) 
  Result=#PB_ProcessPureBasicEvents
  Select Message
    Case  #WM_NOTIFY
      *lvCD.NMLVCUSTOMDRAW=lparam
      If *lvCD\nmcd\hdr\hwndFrom=GadgetID(#MainGadget) And *lvCD\nmcd\hdr\code=#NM_CUSTOMDRAW    
        Select *LVCD\nmcd\dwDrawStage
          Case #CDDS_PREPAINT:ProcedureReturn(#CDRF_NOTIFYITEMDRAW) 
          Case #CDDS_ITEMPREPAINT:ProcedureReturn(#CDRF_NOTIFYSUBITEMDRAW) 
          Case #CDDS_ITEMPREPAINT|#CDDS_SUBITEM
            thisItem=*lvCD\nmcd\dwItemSpec 
            column=*lvCD\iSubItem ; possibly used in your routines?
            subItemRect.RECT\left=#LVIR_LABEL 
            subItemRect.RECT\top=*lvCD\iSubItem 
            SendMessage_(GadgetID(#MainGadget),#LVM_GETSUBITEMRECT,thisItem,@subItemRect) 
            subItemText$=GetGadgetItemText(#MainGadget,*lvCD\nmcd\dwItemSpec,*lvCD\iSubItem)
            sitLen=Len(subItemText$) 
            lvFlags=#DT_END_ELLIPSIS|#DT_WORDBREAK|#DT_VCENTER
            If GetGadgetState(#MainGadget)=thisItem 
               BackgroundColour=RGB(255,0,128)
            Else
               BackgroundColour=RGB(Random(255),Random(255),Random(255))
            EndIf
            MyBrush=CreateSolidBrush_(BackgroundColour)
            If MyBrush
              FillRect_(*lvCD\nmcd\hDC,subItemRect,MyBrush)
              DeleteObject_(MyBrush)
            EndIf
            If sitLen
              For n=1 To sitLen
                SetTextColor_(*lvCD\nmcd\hDC,RGB(Random(255),Random(255),Random(255)))  
                SetBkColor_(*lvCD\nmcd\hDC,RGB(0,0,0))        ; this appears to be ignored - so thats why there is a draw above
                DrawText_(*lvCD\nmcd\hDC,Mid(subItemText$,n,1),1,subItemRect,lvFlags)
                subItemRect.RECT\left+8       ; I don't know how to find the draw width of the character - maybe someone does???
              Next 
            EndIf  
            ProcedureReturn(#CDRF_SKIPDEFAULT)
        EndSelect
      EndIf
  EndSelect
  ProcedureReturn Result 
EndProcedure     
      
  If OpenWindow(#MainWindow,0,0,640,300,#PB_Window_SystemMenu|#PB_Window_ScreenCentered,"ListIconGadgets") And CreateGadgetList(WindowID(0))
    ; left column
    ListIconGadget(#MainGadget, 10, 25, 600, 270, "Column 1",100)
    
    For b=2 To 4          ; add 3 more columns to each listicon
      AddGadgetColumn(#MainGadget,b,"Column "+Str(b),65)
    Next
    
    For b=0 To 2          ; add 4 items to each line of the listicons
      AddGadgetItem(#MainGadget,b,"Item 1"+Chr(10)+"Item 2"+Chr(10)+"Item 3"+Chr(10)+"Item 4")
    Next
    
    SetWindowCallback(@MyWindowCallback())   
 
    Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
  EndIf
It should draw the text in random background colours for the whole cell and random colours for each letter. The background for the selected row is pink!

I couldn't find the api routine to find the drawn width of a string, maybe you can, I fixed it at 8?

I don't know why the background colour for drawing text is ignored, maybe I have a bug in my code??? Thats why it is drawn beforehand with a filled rectangle...

-Anthony