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 »

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
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Post by vdell »

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 »

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 »

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 »

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 »

The tree should be something like
Attachments
sampletree.JPG
sampletree.JPG (11.26 KiB) Viewed 3822 times
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE »

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 117 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 »

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