TreeView Xojo plugin

TreeViewCustomNode Class



TreeViewCustomNode is a class to make custom rendered TreeView nodes and possibly with custom functionality.

Note:
You can inherit from the TreeViewCustomNode and add your own data properties to it. In fact the way to make your custom rendered node is to inherit from the TreeViewCustomNode class and hook your custom code into its events.

Warning:
A TreeViewCustomNode can not be reused in any way. This means that a node may not be put in two different TreeView controls or twice in the same unless if the node has first been removed from the TreeView that it was in.

TreeViewNode
   TreeViewCustomNode

class TreeViewCustomNode

Constructors

TreeViewCustomNodeA constructor that takes a text.
TreeViewCustomNodeA constructor that takes a text and a image.
TreeViewCustomNodeA constructor that takes text, image and high resolution image for Retina mode.

Properties

FontBold (Inherited) Set this property to true to let the node text be drawn bold faced.
FontItalic (Inherited) Set this property to true to let the node text be drawn italic faced.
FontUnderline (Inherited) Set this property to true to let the node text be drawn with text underline style.
HasExpander (Inherited) Use this property to force a node to have a expander even if it has no child nodes.
HighResImage (Inherited) High resolution image for Retina mode on Retina displays running on Cocoa
Image (Inherited) Sets or gets the node image.
ItemData (Inherited) A property to store custom data on the node.
Text (Inherited) Sets or gets the text of a node.
TextColor (Inherited) Sets the text color of a node.

Methods

AddSubItem (Inherited) Adds text to additional columns of the node.
AppendNode (Inherited) Appends a child node to the current node.
Depth (Inherited) Returns the depth of the node in the tree.
Expanded (Inherited) Returns true if the node is expanded.
Index (Inherited) Returns the Screen Index of the node.
IndexOf (Inherited) Finds a index of a child node relative to the parent.
InsertNode (Inherited) Inserts a child node at a given index to the current node.
ItemText (Inherited) Sets or gets the text for a specific column.
Node (Inherited) Returns a child node at a given index.
NodeCount (Inherited) Returns the count of child nodes.
RemoveChild (Inherited) Removes a child node.
RemoveChildAt (Inherited) Removes a child node at a index that is relative to the parent node.
Selected (Inherited) Returns true if the node is currently selected.
SetExpanded (Inherited) Expands or collapses the node.
Swap (Inherited) Swaps child nodes of the given node instance.

Events

DrawBackgroundDraws the background of a node.
DrawForegroundDraws the foreground of a node.
MouseDownThis Event is fired when mouse goes down in the custom node.
MouseDragThis Event is fired when mouse is dragged over the custom node after mouse has gone down there and true was returned from the mouse down event.
MouseUpThis Event is fired when mouse buttons goes up in the custom node after mouse has gone down there and true was returned from the mouse down event.

Example

Sub DrawForeground(g as Graphics,ByRef textYOffset as Integer, offset as Integer,owner as TreeView)
    Dim img as Picture
    Dim img2 as Picture
   
    if State = 0 then
       img = SuccessImage
    else
       img = FailImage
    end if
   
    if IsDown then
       img2 = NewPicture(img.Width,img.Height,32)
       img2.Graphics.DrawPicture(img,0,0)
       img2.Mask.Graphics.DrawPicture(SuccessMaskImageFaded,0,0)
      
       g.DrawPicture img2,g.Width - 18,1
    else
       g.DrawPicture img,g.Width - 18,1
    end if
   
    ButtonStart = g.Width - 18
   
End Sub


Function MouseDown(x as Integer,y as Integer,owner as TreeView) As Boolean
    if x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18 then
       IsDown = true
       return true
    end if
   
    return false
End Function


Function MouseDrag(x as Integer,y as Integer,owner as TreeView) As Boolean
   
   
    if x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18 and IsDown = false then
       IsDown = true
       return true
    elseif not (x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18) and IsDown = true then
       IsDown = false
       return true
    end if
   
    return false
End Function


Function MouseUp(x as Integer,y as Integer,ByRef triggerAction as Boolean,owner as TreeView) As Boolean
    IsDown = false
   
    if x > ButtonStart and x < ButtonStart + 15 and y > 2 and y < 18 then
       triggerAction = true
      
       if State = 0 then
          State = 1
       else
          State = 0
       end if
    end if
   
    return true
End Function

Supported Platforms:

  • MacOS X Carbon
  • MacOS X Cocoa 32 bit
  • MacOS X Cocoa 64 bit
  • Windows 32 bit
  • Windows 64 bit
  • Linux 32 bit
  • Linux 64 bit
  • Linux ARM