Kirix Support Forums

How To Use My Own Sizers

Please post all general questions, comments, bug reports, and any other wxAUI feedback here.

How To Use My Own Sizers

Postby HzD_Byte on Sun Feb 12, 2006 1:18 am

I'm need to create a pane with two controls: a text control and a button. Then, i want to resize them automatically with sizer.

I've use code (in wxFrame's constructor):

// ------------------------
wxSizer *sizerInput = new wxBoxSizer(wxHORIZONTAL);
wxPanel *inputPanel = new wxPanel(this, wxID_ANY);
input = new wxTextCtrl(inputPanel, ID_INPUT, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER);
inputOk = new wxButton(inputPanel, ID_INPUTOK, wxT("OK"));
sizerInput->Add(input, 1, wxALL, 1);
sizerInput->Add(inputOk, 0, wxALL, 1);
manager.AddPane(inputPanel, wxBOTTOM, wxT("Input panel"));
inputPanel->SetAutoLayout(true);
inputPanel->SetSizer(sizerInput);
sizerInput->Fit(inputPanel);
sizerInput->SetSizeHints(inputPanel);
sizerInput->Layout();
// ------------------------

And it doesn't properly resize itself automatically :( What's wrong?

More exactly, i think that it's because parent sizer in the pane's frame must add this "control" as: sizerMain->Add(sizerBottom, 0, wxGROW, 0);
but not as sizerMain->Add(sizerBottom, 1, wxGROW, 0);

Is there a known solution?
HzD_Byte
Registered User
 
Posts: 15
Joined: Sun Feb 12, 2006 1:03 am

Re: How To Use My Own Sizers

Postby abligh on Sun Feb 12, 2006 6:40 am

HzD_Byte wrote:I'm need to create a pane with two controls: a text control and a button. Then, i want to resize them automatically with sizer.

More exactly, i think that it's because parent sizer in the pane's frame must add this "control" as: sizerMain->Add(sizerBottom, 0, wxGROW, 0);
but not as sizerMain->Add(sizerBottom, 1, wxGROW, 0);

Is there a known solution?


Well I'd do the AddPane at the end, but you definitely also need to call manager.Update() after it.

Whenever I've had a bug, I've pasted the code I wanted to test into the sample application and seen if it misbehaves there too. This is in general a good way of finding there is no wxAUI bug at all :-)

Alex
abligh
Registered User
 
Posts: 59
Joined: Sun Jan 01, 2006 2:31 pm

Postby HzD_Byte on Sun Feb 12, 2006 8:53 am

"but you definitely also need to call manager.Update() after it."

:) of course, i call it... problem with constant height of my pane...
HzD_Byte
Registered User
 
Posts: 15
Joined: Sun Feb 12, 2006 1:03 am

Re: How To Use My Own Sizers

Postby EhLtUd on Sat Sep 12, 2009 8:53 am

Hi,
I have same problem.

[wxWidgets 2.8.10]
Create a panel:
Code: Select all
wxBoxSizer* bSizer10;
    bSizer10 = new wxBoxSizer( wxHORIZONTAL );

    wxTextCtrl* m_textCtrl2 = new wxTextCtrl( panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
    bSizer10->Add( m_textCtrl2, 0, wxALL, 5 );

    wxButton* m_button2 = new wxButton( panel, wxID_ANY, wxT("MyButton"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT );
    bSizer10->Add( m_button2, 0, wxALIGN_CENTER_VERTICAL, 5 );

    panel->SetSizer( bSizer10);
    panel->Layout();
    return panel;


Add to AUI:
Code: Select all
m_UI.AddPane(TopCenterPanel(), wxAuiPaneInfo().
        Name(wxT("TCP_ID")).
        CenterPane().
        PaneBorder(false).
        Resizable(false)
        );


Small window size:
Image
Large window size:
Image

And, PaneBorder(false) not works if panel not CenterPane(). I need a layout has a top panel with no PaneBorder and no CenterPane. But, I cannot remove PaneBorder by PaneBorder(false).
Image
Thanks so much.
EhLtUd
Registered User
 
Posts: 4
Joined: Fri Sep 11, 2009 3:24 am

Re: How To Use My Own Sizers

Postby Ben on Sat Sep 12, 2009 2:33 pm

Hi there,

Just as an FYI, CenterPane() doesn't mean "center this pane," but rather "be the center pane in the layout".

Did you try this?
Code: Select all
m_UI.AddPane(TopCenterPanel(), wxAuiPaneInfo().
        Name(wxT("TCP_ID")).
        Top().
        PaneBorder(false).
        Resizable(false)
        );

Also, did you make sure to call this?
Code: Select all
m_UI.Update()


All the best,
Ben
Ben Williams
Kirix Support Team
User avatar
Ben
Kirix Support Team
 
Posts: 525
Joined: Mon Dec 19, 2005 6:29 am

Re: How To Use My Own Sizers

Postby EhLtUd on Sun Sep 13, 2009 10:44 am

Is it?
Code: Select all
m_UI.AddPane(...);
m_UI.Update();
m_UI.AddPane(...);
m_UI.Update();
m_UI.AddPane(...);
m_UI.Update();
m_UI.AddPane(...);
m_UI.Update();
m_UI.AddPane(...);
m_UI.Update();
m_UI.AddPane(...);
...
m_UI.Update(); // <== END


I have only "m_UI.Update(); // <== END"

How about panel size? I try EVT_SIZE and m_UI.Update(), but it not works.
Regards
EhLtUd
Registered User
 
Posts: 4
Joined: Fri Sep 11, 2009 3:24 am

Return to wxAUI Questions, Thoughts & Feedback