AW: AW: Again, sorry...Sizer Problem *SIGH*
Joerg Toellner
toellner at oss-gmbh.de
Wed Sep 13 06:19:19 PDT 2006
Hi Thomas,
=
thank you very, very much. I'll study your notes closely and try your code.
Cant say how i appreciate that you have spent so much time for going through
my code.
=
Greetings
Joerg
=
=
_____ =
Von: Thomas Zehbe [mailto:tz at ingenion.de] =
Gesendet: Mittwoch, 13. September 2006 13:07
An: wx-users at lists.wxwidgets.org
Betreff: Re: AW: Again, sorry...Sizer Problem *SIGH*
Hi,
I think you are creating too much panels, which are of no use. And you don't
add the vBoxSizer to the hBoxSizer. Instead you add . I'll ry to strip some
of your code.
If you don't want your controls being a child of a special panel, you can
ommit the panels, create the controls with the top level panel as the parent
and add them to the sizers they belong to.
Thomas
Am Mittwoch, 13. September 2006 10:57 schrieb JT:
> // Hauptpanel laden und and Frame heften
> aktsiz =3D sizMain(this, TRUE, TRUE);
...
> wxSizer *sizMain( wxWindow *parent, bool call_fit, bool set_sizer )
> {
> wxBoxSizer *item0 =3D new wxBoxSizer( wxVERTICAL );
>
> wxBoxSizer *item1 =3D new wxBoxSizer( wxVERTICAL );
>
> wxBoxSizer *item3 =3D new wxBoxSizer( wxHORIZONTAL );
//adding the sizers
item3->Add(item0, 1, wxGROW|wxALL, 5);
item3->Add(item1, 1, wxGROW|wxALL, 5);
//creating panels and add them
wxPanel *item4 =3D new wxPanel( parent, ID_PAN_LEFT, wxDefaultPosition,
wxDefaultSize, 0 );
item0->Add( item4, 1,
wxADJUST_MINSIZE|wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
wxPanel *item5 =3D new wxPanel( parent, ID_PAN_LEFT, wxDefaultPosition,
wxDefaultSize, 0 );
item1->Add( item5, 1,
wxADJUST_MINSIZE|wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
This should be sufficient.
> This is the code for setting up the Controls in the left vsizer (the
> smaller one):
>
> wxSizer *sizPhasen( wxWindow *parent, bool call_fit, bool set_sizer )
> {
> wxBoxSizer *item0 =3D new wxBoxSizer( wxVERTICAL );
>
> wxButton *item1 =3D new wxButton( parent, ID_BTN_PHAWIND, wxT("Wind"),
> wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item1, 0, wxALIGN_CENTER, 5 );
>
> wxButton *item2 =3D new wxButton( parent, ID_BTN_PHAUNFOUL,
> wxT("Entwirren"), wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item2, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
>
> wxButton *item3 =3D new wxButton( parent, ID_BTN_PHAZUG,
> wxT("Zugnotation"), wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item3, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
>
> wxButton *item4 =3D new wxButton( parent, ID_BTN_PHAFOUL,
> wxT("Verhakeln"), wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item4, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
>
> wxButton *item5 =3D new wxButton( parent, ID_BTN_PHAENTER, wxT("Entern"),
> wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item5, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
>
> wxButton *item6 =3D new wxButton( parent, ID_BTN_PHAKAMPF, wxT("Kampf"),
> wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item6, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
>
> wxButton *item7 =3D new wxButton( parent, ID_BTN_PHAMELEE,
> wxT("Handgemenge"), wxDefaultPosition, wxSize(80,-1), 0 );
> item0->Add( item7, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
>
> wxStaticText *item8 =3D new wxStaticText( parent, ID_TEXT, wxT("Laden"),
> wxDefaultPosition, wxDefaultSize, 0 );
> item0->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
>
> wxStaticText *item9 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Segelwechsel"), wxDefaultPosition, wxDefaultSize, 0 );
> item0->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
>
> item0->Add( 20, 45, 0, wxALIGN_CENTER|wxALL, 5 );
>
> if (set_sizer)
> {
> parent->SetSizer( item0 );
> if (call_fit)
> item0->SetSizeHints( parent );
> }
>
> return item0;
> }
> --------------------------
> This is the code for setting up the bigger right vsizer:
>
> wxSizer *sizKampf( wxWindow *parent, bool call_fit, bool set_sizer )
> {
> wxBoxSizer *item0 =3D new wxBoxSizer( wxVERTICAL );
>
> wxStaticBox *item2 =3D new wxStaticBox( parent, -1,
> wxT("Kampfberechnung") );
> wxStaticBoxSizer *item1 =3D new wxStaticBoxSizer( item2, wxVERTICAL );
>
> wxBoxSizer *item3 =3D new wxBoxSizer( wxHORIZONTAL );
>
> wxBoxSizer *item4 =3D new wxBoxSizer( wxVERTICAL );
>
> wxFlexGridSizer *item5 =3D new wxFlexGridSizer( 2, 0, 0 );
>
> wxStaticText *item6 =3D new wxStaticText( parent, ID_TEXT, wxT("Anzahl
> Kanonen"), wxDefaultPosition, wxDefaultSize, 0 );
> item5->Add( item6, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxSpinCtrl *item7 =3D new wxSpinCtrl( parent, ID_SPI_KAMANZKAN, wxT("0"),
> wxDefaultPosition, wxSize(50,-1), 0, 0, 100, 0 );
> item5->Add( item7, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5
> );
>
> wxStaticText *item8 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Entfernung"), wxDefaultPosition, wxDefaultSize, 0 );
> item5->Add( item8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5 );
>
> wxSpinCtrl *item9 =3D new wxSpinCtrl( parent, ID_SPI_KAMDIST, wxT("0"),
> wxDefaultPosition, wxSize(50,-1), 0, 0, 100, 0 );
> item5->Add( item9, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5
> );
>
> wxStaticText *item10 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Mannschaftsqualit=E4t"), wxDefaultPosition, wxDefaultSize, 0 );
> item5->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5 );
>
> wxSpinCtrl *item11 =3D new wxSpinCtrl( parent, ID_SPI_KAMQUAL, wxT("0"),
> wxDefaultPosition, wxSize(50,-1), 0, 0, 100, 0 );
> item5->Add( item11, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL|wxBOTTOM,
> 5 );
>
> wxStaticText *item12 =3D new wxStaticText( parent, ID_TEXT, wxT("Leere
> Mannschaftssektionen"), wxDefaultPosition, wxDefaultSize, 0 );
> item5->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
>
> wxSpinCtrl *item13 =3D new wxSpinCtrl( parent, ID_SPI_KAMSEKTLEER,
> wxT("0"), wxDefaultPosition, wxSize(50,-1), 0, 0, 100, 0 );
> item5->Add( item13, 0, wxALIGN_RIGHT|wxALIGN_CENTER_VERTICAL, 5 );
>
> item4->Add( item5, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxBoxSizer *item14 =3D new wxBoxSizer( wxHORIZONTAL );
>
> wxStaticText *item15 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Munitionstyp"), wxDefaultPosition, wxDefaultSize, 0 );
> item14->Add( item15, 0, wxALIGN_CENTER|wxRIGHT, 5 );
>
> wxString strs16[] =3D
> {
> wxT("Standard"),
> wxT("Kettenschuss"),
> wxT("Doppelschlag"),
> wxT("Schrapnell")
> };
> wxChoice *item16 =3D new wxChoice( parent, ID_CHO_KAMSART,
> wxDefaultPosition, wxSize(130,-1), 4, strs16, 0 );
> item14->Add( item16, 0, wxALIGN_CENTER, 5 );
>
> item4->Add( item14, 0, wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
>
> item3->Add( item4, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
>
> wxBoxSizer *item17 =3D new wxBoxSizer( wxVERTICAL );
>
> wxString strs18[] =3D
> {
> wxT("Rumpf"),
> wxT("Takelage")
> };
> wxRadioBox *item18 =3D new wxRadioBox( parent, ID_RAD_KAMZIEL,
> wxT("Schussziel"), wxDefaultPosition, wxDefaultSize, 2, strs18, 1,
> wxRA_SPECIFY_ROWS );
> item17->Add( item18, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxStaticBox *item20 =3D new wxStaticBox( parent, -1,
> wxT("Schussmodifikatoren") );
> wxStaticBoxSizer *item19 =3D new wxStaticBoxSizer( item20, wxHORIZONTAL
> );
>
> wxBoxSizer *item21 =3D new wxBoxSizer( wxVERTICAL );
>
> wxString strs22[] =3D
> {
> wxT("Keine"),
> wxT("Vorne"),
> wxT("Hinten")
> };
> wxRadioBox *item22 =3D new wxRadioBox( parent, ID_RBX_KAMBREIT,
> wxT("Volle Breitseite"), wxDefaultPosition, wxDefaultSize, 3, strs22, 1,
> wxRA_SPECIFY_ROWS );
> item21->Add( item22, 0, wxBOTTOM, 5 );
>
> wxCheckBox *item23 =3D new wxCheckBox( parent, ID_CHK_KAMINIT,
> wxT("Initialschuss"), wxDefaultPosition, wxDefaultSize, 0 );
> item21->Add( item23, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
>
> item19->Add( item21, 0, wxALIGN_CENTER, 5 );
>
> wxBoxSizer *item24 =3D new wxBoxSizer( wxVERTICAL );
>
> wxCheckBox *item25 =3D new wxCheckBox( parent, ID_CHK_KAMPRISE, wxT("Ziel
> ist unter Fremdkommando"), wxDefaultPosition, wxDefaultSize, 0 );
> item24->Add( item25, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
>
> wxCheckBox *item26 =3D new wxCheckBox( parent, ID_CHK_KAMKAPER,
> wxT("Schuss von fremden Schiff"), wxDefaultPosition, wxDefaultSize, 0 );
> item24->Add( item26, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
>
> wxCheckBox *item27 =3D new wxCheckBox( parent, ID_CHK_KAMANKER,
> wxT("Schuss-Schiff liegt vor Anker"), wxDefaultPosition, wxDefaultSize, 0
> ); item24->Add( item27, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
>
> wxCheckBox *item28 =3D new wxCheckBox( parent, ID_CHK_KAMENTER,
> wxT("Zielschiff hat Enterkommando"), wxDefaultPosition, wxDefaultSize, 0
);
> item24->Add( item28, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
>
> item19->Add( item24, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT, 5 );
>
> item17->Add( item19, 0, wxALIGN_CENTER, 5 );
>
> item3->Add( item17, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT, 5 );
>
> item1->Add( item3, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxBoxSizer *item29 =3D new wxBoxSizer( wxHORIZONTAL );
>
> wxBoxSizer *item30 =3D new wxBoxSizer( wxVERTICAL );
>
> wxFlexGridSizer *item31 =3D new wxFlexGridSizer( 2, 0, 0 );
>
> wxButton *item32 =3D new wxButton( parent, ID_BTN_KAMCALC,
> wxT("Berechnen"), wxDefaultPosition, wxDefaultSize, 0 );
> item31->Add( item32, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
>
> item31->Add( 20, 10, 0, wxALIGN_CENTER|wxALL, 5 );
>
> item31->Add( 20, 40, 0, wxALIGN_CENTER|wxALL, 5 );
>
> item31->Add( 20, 10, 0, wxALIGN_CENTER|wxALL, 5 );
>
> wxButton *item33 =3D new wxButton( parent, ID_BTN_KAMSINK,
> wxT("Sinkt/Explodiert?"), wxDefaultPosition, wxSize(-1,19), 0 );
> item31->Add( item33, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5 );
>
> wxStaticBitmap *item34 =3D new wxStaticBitmap( parent, ID_SBM_KAMSINK,
> WuerfelBilder( 0 ), wxDefaultPosition, wxDefaultSize );
> item31->Add( item34, 0, wxALIGN_RIGHT|wxTOP, 5 );
>
> wxButton *item35 =3D new wxButton( parent, ID_BTN_KAMEXPL,
> wxT("Explosionsschaden?"), wxDefaultPosition, wxSize(-1,19), 0 );
> item31->Add( item35, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxTOP, 5 );
>
> wxStaticBitmap *item36 =3D new wxStaticBitmap( parent, ID_SBM_KAMEXPL,
> WuerfelBilder( 0 ), wxDefaultPosition, wxDefaultSize );
> item31->Add( item36, 0, wxALIGN_RIGHT|wxTOP, 5 );
>
> item30->Add( item31, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
>
> item29->Add( item30, 0, wxGROW|wxALIGN_CENTER_HORIZONTAL|wxTOP, 5 );
>
> wxStaticBox *item38 =3D new wxStaticBox( parent, -1, wxT("Ergebnisse") );
> wxStaticBoxSizer *item37 =3D new wxStaticBoxSizer( item38, wxVERTICAL );
>
> wxFlexGridSizer *item39 =3D new wxFlexGridSizer( 3, 0, 0 );
>
> wxStaticText *item40 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Rumpfschaden"), wxDefaultPosition, wxDefaultSize, 0 );
> item39->Add( item40, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxTextCtrl *item41 =3D new wxTextCtrl( parent, ID_TXT_KAMRUMPF, wxT(""),
> wxDefaultPosition, wxSize(80,-1), 0 );
> item39->Add( item41, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> item39->Add( 20, 20, 0, wxALIGN_CENTER, 5 );
>
> wxStaticText *item42 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Takelagenschaden"), wxDefaultPosition, wxDefaultSize, 0 );
> item39->Add( item42, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxTextCtrl *item43 =3D new wxTextCtrl( parent, ID_TXT_KAMTAKEL, wxT(""),
> wxDefaultPosition, wxSize(80,-1), 0 );
> item39->Add( item43, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> item39->Add( 20, 20, 0, wxALIGN_CENTER, 5 );
>
> wxStaticText *item44 =3D new wxStaticText( parent, ID_TEXT, wxT("Schaden
> Eigene-/Prisencrew"), wxDefaultPosition, wxDefaultSize, 0 );
> item39->Add( item44, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxTextCtrl *item45 =3D new wxTextCtrl( parent, ID_TXT_KAMCREWEIG,
> wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
> item39->Add( item45, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxTextCtrl *item46 =3D new wxTextCtrl( parent, ID_TXT_KAMCREWHIGH,
> wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
> item39->Add( item46, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
>
> wxStaticText *item47 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Crewschaden (H=F6here Sektion)"), wxDefaultPosition, wxDefaultSize, 0
);
> item39->Add( item47, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> wxTextCtrl *item48 =3D new wxTextCtrl( parent, ID_TXT_KAMCREWHIGH,
> wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
> item39->Add( item48, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> item39->Add( 20, 20, 0, wxALIGN_CENTER, 5 );
>
> item37->Add( item39, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
>
> wxBoxSizer *item49 =3D new wxBoxSizer( wxHORIZONTAL );
>
> wxStaticText *item50 =3D new wxStaticText( parent, ID_TEXT,
> wxT("Bemerkung"), wxDefaultPosition, wxDefaultSize, 0 );
> item49->Add( item50, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
>
> wxTextCtrl *item51 =3D new wxTextCtrl( parent, ID_TXT_KAMBEM, wxT(""),
> wxDefaultPosition, wxSize(320,-1), 0 );
> item49->Add( item51, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
>
> item37->Add( item49, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> item29->Add( item37, 0, wxALIGN_CENTER|wxLEFT, 5 );
>
> item1->Add( item29, 0, wxALIGN_CENTER_VERTICAL, 5 );
>
> item0->Add( item1, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
>
> if (set_sizer)
> {
> parent->SetSizer( item0 );
> if (call_fit)
> item0->SetSizeHints( parent );
> }
>
> return item0;
> }
> --------------------------
> [/code]
>
>
> -----Urspr=FCngliche Nachricht-----
> Von: Eran Ifrah [mailto:eran.ifrah at gmail.com]
> Gesendet: Montag, 13. November 2006 09:55
> An: wx-users at lists.wxwidgets.org
> Betreff: Re: Again, sorry...Sizer Problem *SIGH*
>
> Joerg Toellner wrote:
> > Dear Group,
> >
> > Env: wxMSW 2.7, MSVC 2003, Windows XP
> >
> > I have a sizer problem again. Even after testing 2 days now and
> > reading the manual, sizer overview and the sizer-howto cant find a
> > solution. Somehow i cant get this sizer stuff into my head, dunno why.
> >
> > I have a wxFrame with some sizers and controls in it. The Layout also
> > includes (as a middle part of other sizers and panels that work
> > correctly
> > already) the following:
> >
> > +------------HBoxSizer-------------+
> >
> > | +---VBoxSizer--+ +--VBoxSizer--+ +
> > |
> > | | Button | | Control1 | |
> > | | Button | | Control2 | |
> > | | Button | | Control3 | |
> > |
> > | +--------------+ | Control4 | |
> > |
> > | | Control5 | |
> > | | Control6 | |
> > | | ... | |
> > |
> > | +-------------+ |
> >
> > +----------------------------------+
> >
> > You see, i have a left vsizer and a right vsizer in the hsizer. The
> > left vsizer is smaller in height (has less controls in vertical
> > direction) as the right one. The problem is, that the surrounding
> > HBoxSizer gets always the vertical size of the smaller left vsizer,
> > clipping some controls from the right sizer (not visible or
> > overlapping some controls that are located in another HBoxSizer which is
>
> beyond the a.m. HBoxSizer).
>
> > If i add a Spacer to the left vsizer with some height, the Hboxsizer
> > grows vertically to fit the, now higher, left vsizer. Then all the
> > controls from the right sizer will fit too and are visible.
> >
> > But i have to calc and try and error to get the correct height of the
> > spacer to make all fit in and dont waste too much space. This i have
> > to do any time, when i change sth. on the controls of the right sizer
> > that changes the right sizer height.
> >
> > I wonder if there is an automatic way to get the HBoxSizer using the
> > correct height of the vertically largest vsizer in it, leaving space
> > automatically at the bottom of the smaller sizer? Indifferent if the
> > higher sizer is the left or right one? Or must i really calculate how
> > much pixel the additional spacer must have to get a good fitting size
for
>
> the HBoxSizer?
>
> > Do i anything wrong or is the spacer idea the suggested and only way
> > to go and there will be no automtic solution for my problem?
> >
> > Any help really appreciated. Thanks very much in advance Yours J=F6rg
> > T=F6llner
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> > For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
> Can you post some snippet of your code?
>
> It will really help
> Eran
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
-- =
Dipl.-Ing. Thomas Zehbe
INGENION GmbH
Kuhweide 6
31552 Apelern
Fon: 05043 / 40 57 90 4
Fax: 05043 / 40 57 90 7
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20060913/7b3=
b2fcf/attachment.htm
More information about the wx-users
mailing list