AW: Again, sorry...Sizer Problem *SIGH*
JT
jt at oss-gmbh.de
Wed Sep 13 01:57:24 PDT 2006
Hi Eran,
As requested...below please find the code snippet concerning the 3 sizers
and how the frame constructor will set them up. The Code is autogenerated by
wxDesigner in which i designed the GUI.
Any hints? Thanks again!
CU
Jörg Töllner
[code]
--------------------------
This are parts of the constructor of my Frame which sets up this and some
other sizers a.s.o.:
wscFrame::wscFrame(wxWindow* parent, wxWindowID id, const wxString& title,
const wxPoint& pos, const wxSize& size,
long style, const wxString& name)
: wxFrame(parent, id, title, pos, size, style, name)
{
// some irrelevant code (like menubar creation a.s.o.) stripped here
// Hauptpanel laden und and Frame heften
aktsiz = sizMain(this, TRUE, TRUE);
// Feste (Log, Left, Global) Mainsizers mit den richtigen Sizern
fuellen
// notwendige Controls im neu zu addierenden Sizer in
Membervariablen merken
// some irrelevant code stripped
// Phasenpanel an Leftsizer heften
tmpwin = FindWindowById(ID_PAN_LEFT, this);
aktsiz = sizPhasen(tmpwin, TRUE, TRUE);
// some irrelevant code stripped
// Andere (Wechsel)Sizer fuer rechtes Panel vorbereiten
// und wichtige Controls und Variablen merken
m_RightPan = (wxPanel *) FindWindowById(ID_PAN_RIGHT, this);
// some irrelevant code stripped
// Kampf Sizer
m_panKampf = (wxPanel *) new wxPanel(m_RightPan);
aktsiz = sizKampf(m_panKampf, TRUE, TRUE);
m_panKampf->Show(TRUE);
// Framegroesse und Position anpassen
SetSize(700, 550);
CenterOnScreen();
}
--------------------------
This is the Code for the "MainSizer" that sits directly in the wxFrame:
wxSizer *sizMain( wxWindow *parent, bool call_fit, bool set_sizer )
{
wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
wxBoxSizer *item1 = new wxBoxSizer( wxVERTICAL );
wxPanel *item2 = new wxPanel( parent, ID_PAN_TOP, wxDefaultPosition,
wxDefaultSize, 0 );
item1->Add( item2, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxBOTTOM, 5 );
wxBoxSizer *item3 = new wxBoxSizer( wxHORIZONTAL );
wxPanel *item4 = new wxPanel( parent, ID_PAN_LEFT, wxDefaultPosition,
wxDefaultSize, 0 );
item3->Add( item4, 1,
wxADJUST_MINSIZE|wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT, 5 );
wxPanel *item5 = new wxPanel( parent, ID_PAN_RIGHT, wxDefaultPosition,
wxDefaultSize, 0 );
item3->Add( item5, 5,
wxADJUST_MINSIZE|wxGROW|wxALIGN_CENTER_HORIZONTAL|wxBOTTOM, 5 );
item1->Add( item3, 0, wxADJUST_MINSIZE|wxGROW|wxALIGN_CENTER_VERTICAL, 5
);
wxPanel *item6 = new wxPanel( parent, ID_PAN_BOTTOM, wxDefaultPosition,
wxDefaultSize, 0 );
item1->Add( item6, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxTOP, 5 );
item0->Add( item1, 0,
wxADJUST_MINSIZE|wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
if (set_sizer)
{
parent->SetSizer( item0 );
if (call_fit)
item0->SetSizeHints( parent );
}
return item0;
}
--------------------------
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 = new wxBoxSizer( wxVERTICAL );
wxButton *item1 = new wxButton( parent, ID_BTN_PHAWIND, wxT("Wind"),
wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item1, 0, wxALIGN_CENTER, 5 );
wxButton *item2 = new wxButton( parent, ID_BTN_PHAUNFOUL,
wxT("Entwirren"), wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item2, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
wxButton *item3 = new wxButton( parent, ID_BTN_PHAZUG,
wxT("Zugnotation"), wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item3, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
wxButton *item4 = new wxButton( parent, ID_BTN_PHAFOUL,
wxT("Verhakeln"), wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item4, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
wxButton *item5 = new wxButton( parent, ID_BTN_PHAENTER, wxT("Entern"),
wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item5, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
wxButton *item6 = new wxButton( parent, ID_BTN_PHAKAMPF, wxT("Kampf"),
wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item6, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
wxButton *item7 = new wxButton( parent, ID_BTN_PHAMELEE,
wxT("Handgemenge"), wxDefaultPosition, wxSize(80,-1), 0 );
item0->Add( item7, 0, wxALIGN_CENTER|wxBOTTOM, 5 );
wxStaticText *item8 = new wxStaticText( parent, ID_TEXT, wxT("Laden"),
wxDefaultPosition, wxDefaultSize, 0 );
item0->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
wxStaticText *item9 = 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 = new wxBoxSizer( wxVERTICAL );
wxStaticBox *item2 = new wxStaticBox( parent, -1, wxT("Kampfberechnung")
);
wxStaticBoxSizer *item1 = new wxStaticBoxSizer( item2, wxVERTICAL );
wxBoxSizer *item3 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer *item4 = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer *item5 = new wxFlexGridSizer( 2, 0, 0 );
wxStaticText *item6 = new wxStaticText( parent, ID_TEXT, wxT("Anzahl
Kanonen"), wxDefaultPosition, wxDefaultSize, 0 );
item5->Add( item6, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxSpinCtrl *item7 = 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 = new wxStaticText( parent, ID_TEXT,
wxT("Entfernung"), wxDefaultPosition, wxDefaultSize, 0 );
item5->Add( item8, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5 );
wxSpinCtrl *item9 = 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 = new wxStaticText( parent, ID_TEXT,
wxT("Mannschaftsqualität"), wxDefaultPosition, wxDefaultSize, 0 );
item5->Add( item10, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxBOTTOM, 5 );
wxSpinCtrl *item11 = 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 = new wxStaticText( parent, ID_TEXT, wxT("Leere
Mannschaftssektionen"), wxDefaultPosition, wxDefaultSize, 0 );
item5->Add( item12, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
wxSpinCtrl *item13 = 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 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *item15 = new wxStaticText( parent, ID_TEXT,
wxT("Munitionstyp"), wxDefaultPosition, wxDefaultSize, 0 );
item14->Add( item15, 0, wxALIGN_CENTER|wxRIGHT, 5 );
wxString strs16[] =
{
wxT("Standard"),
wxT("Kettenschuss"),
wxT("Doppelschlag"),
wxT("Schrapnell")
};
wxChoice *item16 = 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 = new wxBoxSizer( wxVERTICAL );
wxString strs18[] =
{
wxT("Rumpf"),
wxT("Takelage")
};
wxRadioBox *item18 = 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 = new wxStaticBox( parent, -1,
wxT("Schussmodifikatoren") );
wxStaticBoxSizer *item19 = new wxStaticBoxSizer( item20, wxHORIZONTAL );
wxBoxSizer *item21 = new wxBoxSizer( wxVERTICAL );
wxString strs22[] =
{
wxT("Keine"),
wxT("Vorne"),
wxT("Hinten")
};
wxRadioBox *item22 = 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 = 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 = new wxBoxSizer( wxVERTICAL );
wxCheckBox *item25 = 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 = 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 = 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 = 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 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer *item30 = new wxBoxSizer( wxVERTICAL );
wxFlexGridSizer *item31 = new wxFlexGridSizer( 2, 0, 0 );
wxButton *item32 = 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 = 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 = new wxStaticBitmap( parent, ID_SBM_KAMSINK,
WuerfelBilder( 0 ), wxDefaultPosition, wxDefaultSize );
item31->Add( item34, 0, wxALIGN_RIGHT|wxTOP, 5 );
wxButton *item35 = 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 = 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 = new wxStaticBox( parent, -1, wxT("Ergebnisse") );
wxStaticBoxSizer *item37 = new wxStaticBoxSizer( item38, wxVERTICAL );
wxFlexGridSizer *item39 = new wxFlexGridSizer( 3, 0, 0 );
wxStaticText *item40 = new wxStaticText( parent, ID_TEXT,
wxT("Rumpfschaden"), wxDefaultPosition, wxDefaultSize, 0 );
item39->Add( item40, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxTextCtrl *item41 = 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 = new wxStaticText( parent, ID_TEXT,
wxT("Takelagenschaden"), wxDefaultPosition, wxDefaultSize, 0 );
item39->Add( item42, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxTextCtrl *item43 = 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 = new wxStaticText( parent, ID_TEXT, wxT("Schaden
Eigene-/Prisencrew"), wxDefaultPosition, wxDefaultSize, 0 );
item39->Add( item44, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxTextCtrl *item45 = new wxTextCtrl( parent, ID_TXT_KAMCREWEIG, wxT(""),
wxDefaultPosition, wxSize(80,-1), 0 );
item39->Add( item45, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxTextCtrl *item46 = new wxTextCtrl( parent, ID_TXT_KAMCREWHIGH,
wxT(""), wxDefaultPosition, wxSize(80,-1), 0 );
item39->Add( item46, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
wxStaticText *item47 = new wxStaticText( parent, ID_TEXT,
wxT("Crewschaden (Höhere Sektion)"), wxDefaultPosition, wxDefaultSize, 0 );
item39->Add( item47, 0, wxALIGN_CENTER_VERTICAL, 5 );
wxTextCtrl *item48 = 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 = new wxBoxSizer( wxHORIZONTAL );
wxStaticText *item50 = new wxStaticText( parent, ID_TEXT,
wxT("Bemerkung"), wxDefaultPosition, wxDefaultSize, 0 );
item49->Add( item50, 0, wxALIGN_CENTER_VERTICAL|wxLEFT, 5 );
wxTextCtrl *item51 = 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üngliche 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örg
> Töllner
>
>
> ---------------------------------------------------------------------
> 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
More information about the wx-users
mailing list