TreeView Control

While it seems there has been some interesting discussion about why a custom control of this type would be created when you can “roll your own” using the built in Listbox, I am going to present this in any case. If you have an interest, that is great, if you don’t see or have a need thats ok too.

Available at this link [ www.rdS.com/treeview_demo.zip ] is a ZIP file containing a DEMO app (see image above) for both OSX and Windows. There are still a few places where some polish is required.

If this generates any interest, when fully complete, I will most likely offer it as an encrypted control and full source code versions (need to find a decent price point)

Here is the “developer” side code required to create the tree shown above

  Me.AutoUpdate=False
  
  Me.add("E","A","Hummer",hummer)
  Me.add("E","C","Cadillac",cadillac)
  Me.add("E","S","Saab",saab)
  Me.add("G","F","F")
  Me.add("D","E","GM",gm)
  Me.Add("G","H","H")
  Me.add("D","G","G")
  Me.add("A","B","HumVee",hummer)
  
  Me.add("","D","Daves TreeView")
  //
  Me.add("D","X","Microsoft",microsoft)
  Me.add("X","Y","MSDN",msdn)
  Me.add("X","Z","Z")
  me.add("Z","1","1")
  me.add("1","2","2")
  me.add("2","3","3")
  Me.AutoUpdate=True

AutoUpdate locks the refresh of the control until all transactions have occured

ADD(parent, child, description,picture)

Looks very nice. But where is the download?

Not sure what happened to the file… it WAS there :slight_smile:
and it is there now… sorry

www.rdS.com/treeview_demo.zip

Looks better now :wink:

Hey, that’s only an app and not a Xojo project :frowning:

  1. An animation would make opening and closing of the rows look smoother.
  2. The alpha of the triangle looks off.
  3. Is it possible to change the indent? This is called Offset in the Treeview so question is answered.
  4. What about checkboxes?
    5: What is the price for the source code?

PS: The memories… I loved going to Saab. It was always so relaxing.

  1. pseudo animation can be achieved by NOT setting AUTOUPDATE to false. AutoUpdate suspends the redraw until all the controls are re-aligned
  2. Let me play with that
  3. Yes :), as I guess you figured out
  4. An idea I’d thought about, and I guess I’ll go ahead an implement it

Yes, this was just an app showing the control with the ability to alter its appearance , (also all the COLORS can be controlled, I just didn’t expose that on the demo screen)

I realized this morning that I’d left 2 important features out, the ability to clear the tree, and the ability to remove an existing branch or leaf.

I was thinking $49.00USD for an encrypted class, and $99.00 for full documented source code (it will be a few more days before those are ready, need to add more comments to the code, and write up a bit of a users manual)
Also any code I release (encrypted or not), there is no “free updates for a year” type deal. Thats too much to keep track of, so any updates I do are available to anyone that purchased from me, for as long as I maintain the code :slight_smile: [I do ask, that if you buy the source code, and find ways to speed things up, add new features etc, that you provide that as feedback to make the product better as time goes on)

I am adding Tristate Checkboxes as an option, and hope to have it operational in the next couple of days…

In the meantime, if there is anyone with more artistic ability that me, and would be interested in a free copy of the encyrpted class (or appropriate discount on the source code), and would be able to come up with nicer graphics for the Expand/Collapse icons, and checkbox images… here is the file I have created. The only requirement is that the size and placement within the image remain as-is. There are 3 sizes of Icons (16/24/32), with 3 styles (Osx/Win/Std), and one size of Checkbox, in 3 styles (OSX/Win/Yosemite)

Looks like a great piece of work Dave.
I found the sample code above a bit confusing, as I expected ‘cant add a child until the parent exists’, but the code doesn’t seem to add the ‘Daves Treeview’ item until half way down.

So the control maintains a linked list in memory?
And you can add parentage (shift everything to the right) as simply as adding children?
(I would have thought that would mean having to redraw all the nodes if they were open…)

Ive just had a look at this, and I like it a lot. Its the kind of control I’d be happy to pay for.

There are other things I would like to see with it, but its a solid start.

:slight_smile:

[quote=176032:@Jeff Tullin]Looks like a great piece of work Dave.
I found the sample code above a bit confusing, as I expected ‘cant add a child until the parent exists’, but the code doesn’t seem to add the ‘Daves Treeview’ item until half way down.

So the control maintains a linked list in memory?
And you can add parentage (shift everything to the right) as simply as adding children?
(I would have thought that would mean having to redraw all the nodes if they were open…)[/quote]

Yes it maintains a Linked List… And the order in the demo was just to see if I could confuse it :). The only requirement is that the ROOT node (the one with “” as a parent) exist, BEFORE AutoUpdate is released, otherwise it won’t draw anything…

Adding Children automatically updates the treeview, as does removing them. The next version also is going to allow changing the text and icon after the node is initially established

[quote=176043:@Stephen Thomas]Ive just had a look at this, and I like it a lot. Its the kind of control I’d be happy to pay for.

There are other things I would like to see with it, but its a solid start.

:)[/quote]

Other things? such as?

Dave, that is beautiful. Great job! I’m going to buy it when you are ready to sell it.

Henry

[quote=176030:@Dave S]The only requirement is that the size and placement within the image remain as-is. There are 3 sizes of Icons (16/24/32), with 3 styles (Osx/Win/Std), and one size of Checkbox, in 3 styles (OSX/Win/Yosemite)
[/quote]
To support OS X they should probably be 16, 32 and 48 (1x, 2x, 3x) - although I dont think we’re at 3x on Desktops yet

When it gets to that point, it would be easiest to have 3 versions of the PNG (@1x @2x and @3x)

Ah so this image is 3 sizes at 1x then ?

yes

so you can display the same tree with small, medium or large expanders

unless you can give me another idea how how best to handle that

Ah no slicing an image up makes sense BUT at 2x the # of pixels will be 2x and so one so slicing it up would have to take that into account. And similarly for 3x.
But that’s another bridge for another day :slight_smile:

[quote=176120:@Norman Palardy]Ah no slicing an image up makes sense BUT at 2x the # of pixels will be 2x and so one so slicing it up would have to take that into account. And similarly for 3x.
But that’s another bridge for another day :)[/quote]
It is :slight_smile:
and just a matter of a little multiplication is all,

Question is when will XOJO be able to support Retina without 3rd party solutions?
(I know… it will when it does :slight_smile: )

Let me find the company line for that one :stuck_out_tongue:

Umm … “It will happen when it happens”
Sounds about right ?

[quote=176058:@Dave S]Yes it maintains a Linked List… And the order in the demo was just to see if I could confuse it :). The only requirement is that the ROOT node (the one with “” as a parent) exist, BEFORE AutoUpdate is released, otherwise it won’t draw anything…

Adding Children automatically updates the treeview, as does removing them. The next version also is going to allow changing the text and icon after the node is initially established

Other things? such as?[/quote]

I was going to say custom icons but then realised you can prob do that anyway.

Other thing was an optional number count to the right of the column for categories/sub-categories.

[quote=176217:@Stephen Thomas]I was going to say custom icons but then realised you can prob do that anyway.

Other thing was an optional number count to the right of the column for categories/sub-categories.[/quote]
Yup custom icons are part of it (see the example above)

Do you mean like if a node is collapsed it shows how many “children” are not visible?