Application layout 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
leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Application layout

Post by leiradella » Tue May 12, 2009 1:42 pm

Hi All,

I have an existing wxWidgets application. The main frame has a wxTreeCtrl, a wxPropertyGrid and a wxNotebook separated by wxSplitterWindows. The wxNotebook has two tabs, one is a wxTextCtrl, and the other, a custom control derived from wxScrolledWindow.

The custom control is used to draw a graph with many nodes and edges connecting them. Nodes and edges are drawn directly on a wxDC, but I'd like to turn the nodes into MDI child windows.

I know MDI is deprecated, so how can I add child windows to an existing container? Please notice that I don't want to add child windows to the main frame, and want to add them to some control added as a child of wxNotebook with it's own vertical and horizontal scroll bars to navigate the graph.

Also, any advice on how I can draw the edges connecting the child windows will be appreciated.

The attached image depicts what I want to achieve inside a tab of the wxNotebook.

Thanks in advance,

Andre
Attachments
image002.jpg

ilovasz
Earned a small fee
Earned a small fee
Posts: 21
Joined: Tue Jul 10, 2007 6:56 pm

Post by ilovasz » Tue May 12, 2009 9:03 pm

Hi leiradella,

if I'm not mistaken You might want to check out these addons/libraries:

wxArt2D http://www.wxart2d.org
wxShapeFramework http://sourceforge.net/projects/wxsf/
wxworkspaceview http://code.google.com/p/wxworkspaceview/

LI

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Wed May 13, 2009 12:53 am

Hi LI,

I already have something in the same line, but orders of magnitude simpler, as wxArt2D implemented. I already draw nodes, edges, handle connections etc.

I would like to take the tool to a higher level by making each node a window with all of its properties inside it instead of using a separate wxPropertyGrid for them, just like the picture attached to the first post.

But thanks for the links, I'll study them a bit more and see if they suit my needs.

Cheers,

Andre

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

Re: Application layout

Post by Auria » Wed May 13, 2009 1:06 am

leiradella wrote: I know MDI is deprecated, so how can I add child windows to an existing container? Please notice that I don't want to add child windows to the main frame, and want to add them to some control added as a child of wxNotebook with it's own vertical and horizontal scroll bars to navigate the graph.
The answer will depend what you mean by "window". If you mean a window with title bar, close button, etc. then MDI is the only way to do it "native" (at least on windows). If you just mean panes, wxPanel will do fine. In either case, you might want to take a look at wxAUI, which provides something between both (and powerful)
leiradella wrote: Also, any advice on how I can draw the edges connecting the child windows will be appreciated.

The attached image depicts what I want to achieve inside a tab of the wxNotebook.
In addition to the mentionned libs, if you want to keep dependencies low or remain minimal, take a look at wxDC (there are very useful small samples on the wiki to get started)
"Keyboard not detected. Press F1 to continue"
-- Windows

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Wed May 13, 2009 1:30 am

Hi Auria,

I meant windows with title bar and everything, but I think wxPanels could do what I want since I can add controls to it. I'd have to make some custom draw to finish the panel layout though. But I'd like something that would handle the window dragging for me.

I've already taken a look at wxAUI, and it seems it needs to be the main frame of the application at a first glance. If that's so, how could I have the wxTreeCtrl, wxPropertyGrid, wxNotebook and, as one page of the wxNotebook, the floating windows?

Regarding wxDC, the custom control I currently use to draw the graph is totally drawn by custom code using a wxDC. It handles panning and zoom automatically, one has only to provide a OnPaint method and draw to the wxDC passed as the only argument.

I guess a better description of what I want is:

1. Have a control I can add to a wxNotebook and to which I can add other controls;
2. This control must handle all drawing, panning, zooming and child control dragging for me;
3. This control must accept custom drawing code in addition to its own drawing method so I can draw the edges connecting the nodes; and
4. The children must be containers themselves, to which I can add other controls such as wxTextCtrl.

This is much like MS Access used to present the tables and their connections. Each table was a MDI window which could be dragged around, and lines were drawn connecting primary keys in one table to foreign keys in another table to show the relations between tables.

I think the picture summarizes very well what I need, if you assume it represents a control to which I can add all the floating windows, be them real windows or not.

I first thought of MDI windows because I thought the dragging would be handled for me by their parent control.

Thanks for the tips,

Andre

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

Post by Auria » Thu May 14, 2009 12:49 am

For "nodes" like this I wouldn't use MDI; I'd just draw them using a DC and catch mouse events on them. (you mentionned you already use wxDC; what's missing?)

As was pointed previously, check wxArt2D, it contains features to do very similar stuff
"Keyboard not detected. Press F1 to continue"
-- Windows

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Thu May 14, 2009 1:30 am

> I'd just draw them using a DC

Yeah, that's what I'm doing right now. I just wanted to add controls to the nodes and not implement my own drag & drop code...

> As was pointed previously, check wxArt2D

I'm taking a look at wxShapeFramework first as it looks more tuned for my needs.

Thanks again,

Andre

leiradella
I live to help wx-kind
I live to help wx-kind
Posts: 172
Joined: Sun Sep 07, 2008 9:49 pm
Location: Rio de Janeiro, Brazil

Post by leiradella » Fri May 15, 2009 1:58 am

Well, just for the records, I'm using wxShapeFramework to do the job. It seems suitable for the task.

Cheers,

Andre

Post Reply