Page 1 of 1

[Solved] Weird TreeViewGadget coloring behaviour

Posted: Mon Nov 30, 2015 12:54 pm
by Kukulkan
Hello,

this code below behaves somehow weird:

1) I need that the selected entries staying selected even without focus in both Tree and List
2) In the current example, on Windows 7, the lower list showing selection in blue and the upper in some light grey if no focus
3) If I change the background color to a darker one (commented), the selection color in lower list changes back to some light grey if no focus
4) How to change the selection color in TreeView for no-focus (rg to blue)?
5) How to make it always the blue selection and not a light grey one? I found no API for this :-(

Code: Select all

CompilerIf #PB_Compiler_Unicode
  #XmlEncoding = #PB_UTF8
CompilerElse
  #XmlEncoding = #PB_Ascii
CompilerEndIf

#Dialog = 0
#Xml = 0
#Image = 0
#Background = $F0F0F0; BBGGRR -> brighter one
; #Background = $D0D0D0; BBGGRR -> darker one

XML$ = "<window id='#PB_Any' name='test' text='test' minwidth='400' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
       "  <vbox expand='item:2' spacing='0'>"+
       "    <tree name='tree' width='160' height='150' flags='#PB_Tree_AlwaysShowSelection'/>"+
       "    <listicon name='files' width='160' height='150' flags='#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect'/>"+
       "  </vbox>"+
       "</window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
    
    For x.i = 1 To 10
      AddGadgetItem(DialogGadget(#Dialog, "tree"), -1, "Tree entry " + Str(x.i))
      AddGadgetItem(DialogGadget(#Dialog, "files"), -1, "File entry " + Str(x.i))
    Next
    
    SetGadgetColor(DialogGadget(#Dialog, "tree"), #PB_Gadget_BackColor, #Background)
    SetGadgetColor(DialogGadget(#Dialog, "files"), #PB_Gadget_BackColor, #Background)
    
    Repeat
      Event = WaitWindowEvent()
    Until Event = #PB_Event_CloseWindow
   
  Else
    Debug "Error  -Dialog- : " + DialogError(#Dialog)
  EndIf
Else
  Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf
BTW, on Linux this is working perfect with always clear selection indication...

Kukulkan

Re: Weird TreeViewGadget coloring behaviour

Posted: Mon Nov 30, 2015 2:52 pm
by RASHAD
Hi
Quick code you should handle it in a proper way :)

Code: Select all

CompilerIf #PB_Compiler_Unicode
  #XmlEncoding = #PB_UTF8
CompilerElse
  #XmlEncoding = #PB_Ascii
CompilerEndIf

#Dialog = 0
#Xml = 0
#Image = 0
#Background = $F0F0F0; BBGGRR -> brighter one
; #Background = $D0D0D0; BBGGRR -> darker one

XML$ = "<window id='#PB_Any' name='test' text='test' minwidth='400' minheight='auto' flags='#PB_Window_ScreenCentered | #PB_Window_SystemMenu | #PB_Window_SizeGadget'>" +
       "  <vbox expand='item:2' spacing='0'>"+
       "    <tree name='tree' width='160' height='150' flags='#PB_Tree_AlwaysShowSelection'/>"+
       "    <listicon name='files' width='160' height='150' flags='#PB_ListIcon_AlwaysShowSelection|#PB_ListIcon_FullRowSelect'/>"+
       "  </vbox>"+
       "</window>"

If CatchXML(#Xml, @XML$, StringByteLength(XML$), 0, #XmlEncoding) And XMLStatus(#Xml) = #PB_XML_Success
 
  If CreateDialog(#Dialog) And OpenXMLDialog(#Dialog, #Xml, "test")
    
    For x.i = 1 To 10
      AddGadgetItem(DialogGadget(#Dialog, "tree"), -1, "Tree entry " + Str(x.i))
      AddGadgetItem(DialogGadget(#Dialog, "files"), -1, "File entry " + Str(x.i))
    Next
    
    SetGadgetColor(DialogGadget(#Dialog, "tree"), #PB_Gadget_BackColor, #Background)
    SetGadgetColor(DialogGadget(#Dialog, "files"), #PB_Gadget_BackColor, #Background)
    tID = DialogGadget(#Dialog, "tree")
    tHndl = GadgetID(DialogGadget(#Dialog, "tree"))
    Repeat
      Event = WaitWindowEvent()
      hndl =  GadgetItemID(tID, GetGadgetState(tID))
      TVItem.TV_ITEM
      TVItem\Mask = #TVIF_STATE
      TVItem\hItem = hndl
      TVItem\StateMask = #TVIS_DROPHILITED
      TVItem\State = #TVIS_DROPHILITED
      SendMessage_(tHndl, #TVM_SETITEM, 0, @TVItem)

    Until Event = #PB_Event_CloseWindow
   
  Else
    Debug "Error  -Dialog- : " + DialogError(#Dialog)
  EndIf
Else
  Debug "Error XML : " + XMLError(#Xml) + " (Line: " + XMLErrorLine(#Xml) + ")"
EndIf

Re: [Solved] Weird TreeViewGadget coloring behaviour

Posted: Mon Nov 30, 2015 6:07 pm
by Kukulkan
Thank you RASHAD, this is doing the trick! :D

Kukulkan