resizable Panel

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

resizable Panel

Post by gabre » Thu May 02, 2013 7:35 am

In my program I have a feature where it is possible to investigate your Erlang code. This needs a tree structure drawn on the screen the nodes of which are boxes with styled text controls showing code for the user. I made a custom control for this with wxPanel, there are some buttons on it, etc, it works the way I want, but I dont know if it is possible to make this box (panel) resizable for the user. How could I manage to do this?

Manolo
Can't get richer than this
Can't get richer than this
Posts: 709
Joined: Mon Apr 30, 2012 11:07 pm

Re: resizable Panel

Post by Manolo » Thu May 02, 2013 11:51 am

The OS allows a window to be resizable using its border.
A control can't be resizable by the user, just using the mouse.

But if you put your control inside a window so it fulfill the whole window (using a wxsizer), you can achieve it.

Another hard approach is to follow mouse coordinates and resizing the control on your own when mouse is on a border...

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

Re: resizable Panel

Post by gabre » Sat May 04, 2013 7:29 pm

Manolo wrote:The OS allows a window to be resizable using its border.
A control can't be resizable by the user, just using the mouse.

But if you put your control inside a window so it fulfill the whole window (using a wxsizer), you can achieve it.

Another hard approach is to follow mouse coordinates and resizing the control on your own when mouse is on a border...
Thank you for your reply!
As you said, if I put my control into a window... but I guess (or I am sure), in that case the user will be able to move (the window and) the control inside of it out of the bigger window and the area (workspace) where these box-like controls are kept. And this would be very bad.

The another approach, following mouse coordinates and calculating borders etc would need too much calculations, am I right? What if I placed some kind of "small hook" (wxButton or something) to the bottom right corner of my box? How could I detect when the user is dragging that "hook" and how could I resize the panel to the proper size?

Manolo
Can't get richer than this
Can't get richer than this
Posts: 709
Joined: Mon Apr 30, 2012 11:07 pm

Re: resizable Panel

Post by Manolo » Sun May 05, 2013 7:51 pm

If you want that some or all of the controls belonging to a window to change their size when the window changes its size, use [several] wxSizer. I think this is your case. You can call Layout() in response to some user action, and the sizers will do the job.

If you want a window (with controls) to be resizable and movable without going out of its parent window, use MDI (just for MSW) or wxAUI.

If you want a control to be resizable by mouse, but you don't want it to have a border, nor move it, you must handle mouse on your own. What if the user resizes it out of its parent window limits?

Post Reply