Draw a tree Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
qarantena
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Jul 11, 2009 6:08 pm

Draw a tree

Post by qarantena » Sun Jul 12, 2009 11:00 am

Hello, I have a code in c++ which builds a tree structure (it is a forest in fact because the tree has several roots). I need to draw the tree ( using rectangles for each list with the number stored in the list placed in the middle of the rectangle + lines ). I dont know how to do it. Where to place a rectangle according to the data the c++ code has evaluated ( if it is a parent, child or sibling). How to put a number from the code in the middle of the rectangle. Could someone please help me?

vdell
Moderator
Moderator
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Post by vdell » Sun Jul 12, 2009 6:24 pm

Is this question wxWidgets specific?
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere

qarantena
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Jul 11, 2009 6:08 pm

Post by qarantena » Sun Jul 12, 2009 6:33 pm

vdell wrote:Is this question wxWidgets specific?
Sorry, I dont understand what you mean.

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Sun Jul 12, 2009 7:41 pm

qarantena: I don't understand what you mean, sorry. Maybe show a mockup?
"Keyboard not detected. Press F1 to continue"
-- Windows

ninja9578
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 236
Joined: Thu Jan 29, 2009 3:33 pm

Post by ninja9578 » Sun Jul 12, 2009 10:45 pm

He's saying that he wants a number inside the expansion box instead of the default +. I don't think this is possible because it's a native widget and isn't designed for that. You need to draw all of that yourself I think.

Like this right: Instead of

Code: Select all

+ root
  + stuff
    One
    Two
    Three
  + More Stuff
    One
You want:

Code: Select all

2 root
  3 stuff
    One
    Two
    Three
  1 More Stuff
    One

qarantena
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Jul 11, 2009 6:08 pm

Post by qarantena » Mon Jul 13, 2009 10:16 am

The tree should be something like
Attachments
sampletree.JPG
sampletree.JPG (11.26 KiB) Viewed 1304 times

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Mon Jul 13, 2009 12:44 pm

Hi!
There is no such class/control in wxWidgets.

However, in the 2.4 branch there used to be wxTreeLayout. I salvaged this class from the SVN repo and hacked a small application that basically does what you want. It sure looks ugly and only resembles the sample app for wxTreeLayout that came with 2.4, plus the drawing of the bounding boxes. But maybe this gives you an idea of how you might get it done. Again: This is VERY simple.

Have a look at http://sourceforge.net/projects/wxsf/. wxShapeFramework might be what you want.
Attachments
treelayout.tar.gz
wxTreeLayout from 2.4 branch + simple example
(3.94 KiB) Downloaded 45 times
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

qarantena
In need of some credit
In need of some credit
Posts: 7
Joined: Sat Jul 11, 2009 6:08 pm

Post by qarantena » Mon Jul 13, 2009 1:46 pm

upCASE wrote:Hi!
There is no such class/control in wxWidgets.

However, in the 2.4 branch there used to be wxTreeLayout. I salvaged this class from the SVN repo and hacked a small application that basically does what you want. It sure looks ugly and only resembles the sample app for wxTreeLayout that came with 2.4, plus the drawing of the bounding boxes. But maybe this gives you an idea of how you might get it done. Again: This is VERY simple.

Have a look at http://sourceforge.net/projects/wxsf/. wxShapeFramework might be what you want.
Thanks a lot.

Post Reply