Page 1 of 1

wxControls placement

Posted: Sat Aug 10, 2013 11:03 am
by Massimo Manca
Probably will seem a stupid question but I am not able to place freely the controls as I want. For instance I want to have 2 vertical check box arrays inside 2 panels but I am able only to put the 1st one because the 2nd will be put under the 1st instead then on its right. I would like to understand how I can freely put controls on a dialog just moving them with the mouse. Is it possible?

Re: wxControls placement

Posted: Sat Aug 10, 2013 11:22 am
by eranif
wxCrafter offers controls placement using sizers. This is the wxWidgets way.

To place 2 checkboxes next to each other, you need to have this hirerchy:

Code: Select all

wxPanel 
   ->  wxBoxSizer (orientation set to horizontal) 
        -> checkbox 
        -> checkbox 
You should read some about wxWidgets sizers, there is tutorial here:
http://hosannahighertech.co.tz/forums/s ... php?tid=74

But in general, try playing around with sizers in wxCrafter and see the result
Basically, controls are placed inside wxSizers and never directly inside a parent

Eran

Re: wxControls placement

Posted: Sun Aug 11, 2013 12:29 pm
by Massimo Manca
I am able to do this. What I am not able to do is to have 2 separate panels one with 16 check boxes vertically oriented and another panel with 8 spin controls always vertically oriented. The 1st panel should be at the left of the second side by side.

The panels should be side by side so the 1st should be on left of the 2nd.

When I place more then 1 panel or more then 1 sizer the 2nd always is under the 1st (so it is vertically ordered) and not on the side.

Actually my hierarchy is this:

MainDialog
+---mainSizer
+---spacer
+---panelLeft
+---boxSizer
+---chkBox1
+---chkBox2
...
+---chkBox8
+---panelRight
+---boxSizer
+---spinBox1
+---spinBox2
...
+---spinBox8
+---staticLine
+---boxSizer
+---btnOk
+---btnCancel

Re: wxControls placement

Posted: Sun Aug 11, 2013 2:31 pm
by eranif
Maybe I am missing it, but:
- The only children of the mainSizer should be panelLeft and panelRight
- mainSizer should have orientation of "wxHORIZONTAL"

Look at the below screenshot to see how it should look like. Notice the orientation of the sizer is set to wxHORIZONTAL:
wxc1.png
Eran

Re: wxControls placement

Posted: Mon Aug 12, 2013 12:59 pm
by Massimo Manca
Yes, it is what I want. I am not used with sizers, I think it is my main difficulty. I am more used with C++ Builder and Qt.
Thanks, I will correct my project as you described.