Toolbox like Gimp

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.
tkd
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Mar 23, 2010 10:57 am

Toolbox like Gimp

Post by tkd »

Hi,

I'm looking for a way to create a toolbox like gimp : a table of button, and a second part for action linked to the pressed button.

I created a panel with wxgridsizer or wxflexgridsizer, but the problem is when I resize this panel, the buttons table alignement does not changes.

I would like to know how doing a floating button table in a panel, as gimp do, to obtain this :
- the original buttons table is a matrix of 3x4 buttons
- after growing the panel, the matrix can become just a matrix of 1x1 or 1x2, it depends of the new size of the panel
- reversly, if the size go down, the matrix have to become 10x1 for example.

I tried many things, but right now, I have no more idea :evil: :cry:

If someone have an idea, thanks in advance !

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

Post by doublemax »

If you're using wxWidgets 2.9.x you can use wxWrapSizer:
http://docs.wxwidgets.org/trunk/classwx_wrap_sizer.html

If you want to stay with wx 2.8.x you'd have to implement that behavior yourself.
Use the source, Luke!
tkd
In need of some credit
In need of some credit
Posts: 2
Joined: Tue Mar 23, 2010 10:57 am

Toolbox like Gimp

Post by tkd »

doublemax wrote:If you're using wxWidgets 2.9.x you can use wxWrapSizer:
http://docs.wxwidgets.org/trunk/classwx_wrap_sizer.html

If you want to stay with wx 2.8.x you'd have to implement that behavior yourself.


Hi,

unfortunatly, I have to stay with wx 2.8.
I can implement it by myself, but I don't understand exactly how to start. Do you have an indication to help me pl ?

Thanks in advance

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

Post by doublemax »

In pseudo code:

create vertical sizer
loop:
-Create horizontal boxsizer
-add items until the maximum width is reached or no more items available
-add horizontal sizer to vertical sizer
end loop:
Use the source, Luke!
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am

Post by Auria »

Or it could just be a grid sizer. You'd just need to calculate the best size to fit all tools
"Keyboard not detected. Press F1 to continue"
-- Windows
User avatar
doublemax
Moderator
Moderator
Posts: 19163
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Post by doublemax »

Yeah. Important thing that i forgot to mention: You have to do this whenever the control gets resized, either recreating the whole sizer layout, or dynamically detaching/attaching the buttons to the different sizers. Not really a trivial task.

So maybe you should consider switching to 2.9.x ;)
Use the source, Luke!
eranif
Moderator
Moderator
Posts: 610
Joined: Tue Nov 29, 2005 7:10 pm
Location: Israel

Post by eranif »

So maybe you should consider switching to 2.9.x
or copy the wxWrapSizer (wrapsizer.cpp/h) source files into your project and use it

Eran
IDE: CodeLite + wxCrafter
OS: All
https://wxcrafter.codelite.org
https://codelite.org