wxSizer to expand a window

272 views
Skip to first unread message

abir...@gmail.com

unread,
Aug 16, 2006, 7:20:45 AM8/16/06
to wx-u...@lists.wxwidgets.org

Hi,
I have a wxBoxSizer for wxFrame. A wxSplitterWindow is attached to
wxBoxSizer. I wan't to fill the wxFrame with the wxSplitterWindow when
the frame is resizing. How to do it using wxSizerFlags ?


Iulian-Nicu Serbanoiu

unread,
Aug 16, 2006, 2:00:22 PM8/16/06
to wx-u...@lists.wxwidgets.org
Add( your_splitter_window, 1, wxGROW ) when you add it to the sizer ?

more details here:
http://www.wxwindows.org/manuals/2.6.3/wx_wxsizer.html#wxsizeradd

or in your local chm help file ( or any other help format you downloaded )

HTH,

Iulian

> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-u...@lists.wxwidgets.org
> For additional commands, e-mail: wx-use...@lists.wxwidgets.org
>
>

abir...@gmail.com

unread,
Aug 17, 2006, 1:02:49 AM8/17/06
to wx-u...@lists.wxwidgets.org

"Iulian-Nicu Serbanoiu" wrote:
> Add( your_splitter_window, 1, wxGROW ) when you add it to the sizer ?
>
> more details here:
> http://www.wxwindows.org/manuals/2.6.3/wx_wxsizer.html#wxsizeradd
>
> or in your local chm help file ( or any other help format you downloaded )

My code looks like,
InkControl* inkControl = new InkControl(this);
wxBoxSizer* inkSizer = new wxBoxSizer(wxHORIZONTAL);
inkSizer->Add(inkControl,wxSizerFlags(1).Expand().Centre());
this->SetSizer(inkSizer);

The code is inside a Frame, which is derived from wxFrame.
InkControl is a control derived from wxControl. Irrespective of
InkControl's size ( which is set to wxDefaultSize here) , I want it to
occupy the full parent window. But it resides at the top left corner,
with it's default size.
even inkSizer->Add(inkControl,1,wxGROW); also have same effect
changing InkControl to a wxButton neither helps.
also wxGROW is not mentioned in document or the link.

Moreover when I use wxSashLayoutWindow, also same kind of problem
happens.
now if I add this->DoLayout(); then it gets filled by the control,
however on resizing it do not stretch it anymore (I am not having a
resize event, as I think sizer will resize it automatically, otherwise
one need to add resize event to every resizable window!)

One more problem,
Any example for using thread in a gui for time consuming work? like
I want a function to be called when the user presses a button, but in s
seperate thread, otherwise the GUI will be non-responsive.

Iulian-Nicu Serbanoiu

unread,
Aug 17, 2006, 1:14:23 PM8/17/06
to wx-u...@lists.wxwidgets.org
wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
// Create text ctrl with minimal size 100x60
topSizer->Add(
new wxButton( this, wxID_OK, wxT("tada") ),
1,wxGROW);

SetSizer( topSizer ); // use the sizer for layout

This code put in a wxFrame based object works fine here.

Regards,

Iulian

abir...@gmail.com

unread,
Aug 18, 2006, 1:30:51 AM8/18/06
to wx-u...@lists.wxwidgets.org

"Iulian-Nicu Serbanoiu" wrote:
> wxBoxSizer *topSizer = new wxBoxSizer( wxVERTICAL );
> // Create text ctrl with minimal size 100x60
> topSizer->Add(
> new wxButton( this, wxID_OK, wxT("tada") ),
> 1,wxGROW);
>
> SetSizer( topSizer ); // use the sizer for layout
>
> This code put in a wxFrame based object works fine here.

I had used EVT_SIZE for the wxFrame, which doing nothing, and layout
mechanism was not working. Removing the event works fine. However I
want to do something OnSize for the frame. Will I call frame->OnSize()
first on the event handler first, before my custom code?
Thanks for reply.
abir

Iulian-Nicu Serbanoiu

unread,
Aug 18, 2006, 3:14:30 AM8/18/06
to wx-u...@lists.wxwidgets.org
If you are using the EVT_SIZE event you should call also the default
handler for this event. This can be done by calling Skip(true);

MyFrame::OnSize(wxSizeEvent& event)
{
// your code before the default event

event.Skip(true);

// your code after the default event
}

HTH,

Iulian

Robin Dunn

unread,
Aug 18, 2006, 10:50:33 AM8/18/06
to wx-u...@lists.wxwidgets.org
Iulian-Nicu Serbanoiu wrote:
> If you are using the EVT_SIZE event you should call also the default
> handler for this event. This can be done by calling Skip(true);
>
> MyFrame::OnSize(wxSizeEvent& event)
> {
> // your code before the default event
>
> event.Skip(true);
>
> // your code after the default event
> }
>

This is not true. Calling Skip only sets a flag that causes the event
system to continue looking for a handler *after* the current handler
returns. It does *not* cause the default handler to be called
immediately (during the call to Skip.)


--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


abir...@gmail.com

unread,
Aug 18, 2006, 3:43:51 AM8/18/06
to wx-u...@lists.wxwidgets.org

"Iulian-Nicu Serbanoiu" wrote:
> If you are using the EVT_SIZE event you should call also the default
> handler for this event. This can be done by calling Skip(true);
>
> MyFrame::OnSize(wxSizeEvent& event)
> {
> // your code before the default event
>
> event.Skip(true);
>
> // your code after the default event
> }

Thanks. This one is working.
But one more problem. Now I am adding a wxPanel to my wxFrame, and set
it to the sizer. I want to add wxSashLayoutWindow insize the panel. Now
This one is not working as expected.
here is the code inside wxFrame ctor
wxPanel* clientPanel = new wxPanel(this);
clientPanel->SetBackgroundColour(*wxBLUE);
wxBoxSizer* clientSizer = new wxBoxSizer(wxHORIZONTAL);
clientSizer->Add(clientPanel,wxSizerFlags(1).Expand());

wxSashLayoutWindow* _bottomSplitterWindow = new
wxSashLayoutWindow(clientPanel);
_bottomSplitterWindow->SetDefaultSize(wxSize(1000,200));
_bottomSplitterWindow->SetOrientation(wxLAYOUT_HORIZONTAL);
_bottomSplitterWindow->SetAlignment(wxLAYOUT_BOTTOM);
_bottomSplitterWindow->SetBackgroundColour(*wxGREEN);
_bottomSplitterWindow->SetSashVisible(wxSASH_TOP,true);
this->SetSizer(clientSizer);

clientPanel is expanded to the whole wxFrame, except statusbar, menubar
& toolbar as expected. But bottomSplitterWindow is not at the bottom of
the clientPanel, with a height of 200. (It appears at the top left
corner of the clientPanel) .
How to do it? I am new to wxWidgets , and not finding a way to do it.
sorry for disturbing.
abir

>
> HTH,
>
> Iulian
>
> On 17 Aug 2006 22:30:51 -0700, abir...@gmail.com <abir...@gmail.com> wrote:
> > I had used EVT_SIZE for the wxFrame, which doing nothing, and layout
> > mechanism was not working. Removing the event works fine. However I
> > want to do something OnSize for the frame. Will I call frame->OnSize()
> > first on the event handler first, before my custom code?
> > Thanks for reply.
> > abir
> > > Regards,
> > >
> > > Iulian
>

Reply all
Reply to author
Forward
0 new messages