WX Aui and floating pane

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

WX Aui and floating pane

Post by gabre » Sat Mar 02, 2013 10:15 am

I would like to do the following: I d like to have "windows inside a window", I mean that I need (with Wx terminology) frames inside a frame. These smaller frames need to be floating but they cant get out of the borders of their parent frame. (look at this pic and window titled "output": http://i.msdn.microsoft.com/dynimg/IC86451.gif )
Is this possible in Wx? Do I have to write my own code (derived from wxAUI) or is there a way to do this "by default"? I m using wxErlang (Wx Erlang binding), so it is not so easy to write my own derived classes and use inheritance etc.

User avatar
doublemax
Moderator
Moderator
Posts: 14874
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WX Aui and floating pane

Post by doublemax » Sat Mar 02, 2013 12:09 pm

I don't think you need to derive your own classes for this. With wxAUI, floatable, but not dockable panes should work. Or you could use the classical "MDI" classes like wxMDIParentFrame / wxMDIChildFrame
http://docs.wxwidgets.org/stable/wx_wxm ... frame.html

Check the "mdi" sample that comes with wxWidgets.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: WX Aui and floating pane

Post by gabre » Sun Mar 10, 2013 2:41 pm

Hello,
Thank your for your answer, I have checked the Wx example "MDI", tried out MDI frame in my code and experimented some. I have found that there is no way (really?) in wxGTK to make floating frames inside another frame because MDI child frames are displayed as "notebook tabs" on GTK. If I used AUI I could have those floating frames but my problem is that they can be moved out of their parent frame's area (by the user).
What I would like to do exactly is that I want to have small boxes with code/text and these small boxes should be connected by lines/arrows. It will be kind of code investigation tool, but in wxErlang my opportunities are exiguous. (for e.g. I cant use other libraries based on wx)

User avatar
doublemax
Moderator
Moderator
Posts: 14874
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WX Aui and floating pane

Post by doublemax » Sun Mar 10, 2013 3:16 pm

In C++ you could use one of the libs mentioned here:
http://wiki.wxwidgets.org/WxFAQ#How_can ... d_nodes.3F

If that's not an option, the easiest way may to be to write the functionality yourself. Just put some wxPanels on a parent panel and handle moving them around yourself.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: WX Aui and floating pane

Post by gabre » Mon Mar 11, 2013 9:17 am

Thank you for your response, I managed to implement my own "floating, movable panel with a smaller styledtextcontrol (code browser) on it". The next problem is that I would like to connect my floating panels (code bubbles) with lines. I use getPosition and getSize from wxPanel to calculate the center point of my panels and then draw lines between them. This is done in every paint event. When I use GraphicsContext and add 7 (only 7!!) movable floating panels it gets very slow. (by the way I have i5 CPU and 4GB RAM, HD5470 1GB) When I use wxBufferedPaintDC then it is not slow but looks like an old software from 1990 :)
There is a function in wxErlang, wx:batch/1 which is useful (and has to be used) when running a sequence of more than one wx commands. I also use this, but I dont know, why it is extremely slow with that small value of lines to be drawn. (7 panels => 7 points, 7 lines)

User avatar
doublemax
Moderator
Moderator
Posts: 14874
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: WX Aui and floating pane

Post by doublemax » Mon Mar 11, 2013 9:42 am

Just for clarification: You have a big panel as parent for all the floating panels. The floating panels derive from wxPanel and contain some wx controls?

And the only thing you draw in the paint event handler of the background panel are the connecting lines?

That would be very strange. For just a few lines the performance difference between using wxGraphicsContext and wxPaintDC should be almost unmeasurable. Are you sure you're not performing any other operations unnecessarily in the paint event handler?
When I use wxBufferedPaintDC then it is not slow but looks like an old software from 1990
I assume you're referring to the missing antialiasing when the line is drawn? There should be no other visible difference.
Use the source, Luke!

gabre
Knows some wx things
Knows some wx things
Posts: 29
Joined: Sat Mar 02, 2013 9:45 am

Re: WX Aui and floating pane

Post by gabre » Fri Mar 15, 2013 1:48 pm

Just for clarification: You have a big panel as parent for all the floating panels. The floating panels derive from wxPanel and contain some wx controls?
There is no way to derive anything in Erlang (as it is not an OO language). I just wrote a module where I use a Parent coming from outside (like the parent parameter of a constructor in C++), and this Parent is that "big panel" as you mentioned. In my module I create a smaller panel as the child of this big one, and define event handler functions for the following events (of it): mouse motion, left mouse button down and up, and I use the move procedure of wxPanel to move the panel as the user drags it.
It behaves like I had a derived class "FloatingPanel" as you said.
And the only thing you draw in the paint event handler of the background panel are the connecting lines?
That would be very strange. For just a few lines the performance difference between using wxGraphicsContext and wxPaintDC should be almost unmeasurable. Are you sure you're not performing any other operations unnecessarily in the paint event handler?
The things I do in my event handler:
1, I compute the positions of the lines (start and end point) with wxPanel:getPosition(FloatingPanel) and wxPanel:getSize(FloatingPanel)
2, I connect these points with lines using a Path (wxGraphicsPath) and draw it
I assume you're referring to the missing antialiasing when the line is drawn? There should be no other visible difference.
You are right, I meant the missing antialiasing. The other difference is that when I use wxDC I cant have a transparent background. (I did not manage to have one)

Post Reply