wxSplitterWindow & resizing contents

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

wxSplitterWindow & resizing contents

Post by FlyingIsFun1217 » Mon Feb 05, 2007 1:19 am

Hey, me again...

I have started writing a quick app to store contact info, as I have not found one that is very well fit for a flash drive, etc.

Anyway, what I'm shooting for is a window which is split by wxSplitterWindow, one side being the "sidebar", where all of the contacts are displayed (I have chosen wxListBox, is this suitable?), and the other side being the side that displays the info for the contact selected in the "sidebar" (not sure how I will display it quite yet, getting there...). Here's my code:

Code: Select all

void ContactManagerFrm::CreateGUIControls()
{
	//Do not add custom code between
        //GUI Items Creation Start and GUI Items Creation End
	//wxDev-C++ designer will remove them.
	//Add the custom code before or after the blocks
	////GUI Items Creation Start

	WxSplitterWindow1 =new wxSplitterWindow(this, ID_WXSPLITTERWINDOW1, wxDefaultPosition, wxDefaultSize, wxSP_LIVE_UPDATE);

	wxWindow *ContactDetails = new wxWindow(WxSplitterWindow1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER);

    wxWindow *ContactList = new wxWindow(WxSplitterWindow1, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxSUNKEN_BORDER);

    WxSplitterWindow1->SplitVertically(ContactList, ContactDetails, 200);

    wxListBox *SampleSidebarListbox = new wxListBox(ContactList, wxID_ANY, wxDefaultPosition, wxSize(200,400));

	SetTitle(wxT("Simple Contact Manager"));
	SetIcon(wxNullIcon);
	SetSize(8,8,500,400);
	Center();

	////GUI Items Creation End
}
What I am not achieving with that though is resizing the wxListBox to fit the height of the window on a resize, and the disabling of changing the width of the splitter. Can anybody tell me what kind of things I must do to do this?

Thanks!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Re: wxSplitterWindow & resizing contents

Post by Auria » Mon Feb 05, 2007 1:40 am

FlyingIsFun1217 wrote: What I am not achieving with that though is resizing the wxListBox to fit the height of the window on a resize
Well you'll need to use a sizer for that... FlexGridSizer is usually good when you just want to make a component take all available space (check your previous thread) in this code there is no sizer, no surprise it doesn't work

EDIT: well i *assume* it is the case, since i've never used splitters
FlyingIsFun1217 wrote: and the disabling of changing the width of the splitter.
I'm not sure what you mean? You mean to make it impossible to change the position of the division bar? If then why use a splitter at all?
Last edited by Auria on Mon Feb 05, 2007 1:46 am, edited 1 time in total.

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 1:44 am

Yes, there is nothing for a splitter, as every time I tried using one, it did nothing to help me.

As far as 'disabling the width of the splitter', yes, I DO want to do this, as this is the most sensible thing for the application. All I really need to know is how to disable it from being resized.

Thanks again!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Feb 05, 2007 1:47 am

Look at this:
http://lists.wxwidgets.org/archive/wxPy ... 08286.html

basically catch events and invalidate them

found that with a google search in a few seconds :P google is your friend

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 1:58 am

Well, looking at the Splitter example, I could maybe do something like setting the min and max (can you set the max) at the same value, right? And if I did that, could I just remove the arrow cursor that shows over the splitter?

Thanks again!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Feb 05, 2007 2:04 am

FlyingIsFun1217 wrote:Well, looking at the Splitter example, I could maybe do something like setting the min and max (can you set the max) at the same value, right? And if I did that, could I just remove the arrow cursor that shows over the splitter?

Thanks again!
FlyingIsFun1217
I don't know why you want to use a Splitter so much if you,re going to remove everything that makes it a splitter? why not just use 2 panels?

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 2:07 am

Well, at first I thought it would be easier to resize things within splitters, but as I have found out, it isn't quite that easy.

I will see what it looks like with just panels.

FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Feb 05, 2007 2:10 am

About Splitter:

- I don't think you can remove the cursor.
- Setting min and max would be harder than just dismissing events, since you'll need to keep track of window size changes, and calculate and apply a new mix and max everyime it does

About Panels:

true it may not as nice though

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 2:26 am

Yes, the panel idea is much cleaner than the splitter.
Now I have a panel again for the 'sidebar', which should be 200 p in width, and then the other panel for the details. This is all set on top of a base panel for a total of 3 panels.

What would be the best way to set sizers for this so that the one on the left stays 200 p wide, but is resized to match the vertical length, and the one on the right takes up the remaining space?

Thanks!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Mon Feb 05, 2007 2:38 am

not an easy one ;)

FlexGridSizer with a vertically flexible area could be good

There must be many good ways to do it, have a look at the docs... though for a side bar like this i usually use wxBorderSizer, even though it's not part of the default distribution and has to be downloaded from wxCode / wxExtras / whatever - however there are probably other ways - flexgridsizer, namely

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 2:44 am

I think I'll try using a wxFlexGridSizer for the 'sidebar', and... maybe the same for the panel for the rest of the area.

Thanks, be back soon... :P
FlyingIsFun1217

DavidHart
Site Admin
Site Admin
Posts: 4008
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Post by DavidHart » Mon Feb 05, 2007 10:38 am

Hi,
What would be the best way to set sizers for this so that the one on the left stays 200 p wide, but is resized to match the vertical length, and the one on the right takes up the remaining space?
This is a standard situation to use a horizontal wxBoxSizer. Add the first panel to it with the wxEXPAND style flag so that it stretches vertically, but with a proportion of 0 so it won't grow horizontally. The second panel gets wxEXPAND and a proportion of 1, so it grows everywhere.

Regards,

David

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 5:22 pm

Ok, thank you for that, I will try it (can't right now, as I am at school).

Both being box sizers, I assume?

FlyingIsFun1217 :)

FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 » Mon Feb 05, 2007 11:50 pm

Tell me though, how can I set proportions of the panels (as DavidHart said 1 and 0)?

Thanks!
FlyingIsFun1217

Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria » Tue Feb 06, 2007 12:34 am

FlyingIsFun1217 wrote:Tell me though, how can I set proportions of the panels (as DavidHart said 1 and 0)?

Thanks!
FlyingIsFun1217
When you create a component, you give it a size... just use that, if you tell the sizer not to stretch the default size should be respected

Post Reply