Add to the interface after shown Topic is solved

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.
Post Reply
rrcn
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Nov 17, 2008 4:57 pm

Add to the interface after shown

Post by rrcn » Sun Nov 30, 2008 1:54 pm

My problem is the inverse of Notepad or Emacs.
Instead of a available (scratch) work area when I call the application, I want that the user explicitly opens a new work area so it can be displayed.

In my case, I have a menu bar, and a tool bar that I want to be displayed when I run the application.
And I have a tab bar (wxNotebook) with a panel for each tab.
each panel have a list view.

The problem that I have is that when I construct everything and show it all (like on notepad) it works. But if I show first only the menu bar and the tool bar, and the tab bar only when the user requests it, it doesn't works! It only appears a small box bellow the toolbar instead of the tab bar.

TrV
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 630
Joined: Wed Jul 04, 2007 1:12 pm

Post by TrV » Sun Nov 30, 2008 4:10 pm

That's a common problem (which i've never really dealt with, so i can't give you a relevant solution).

Try to have a look at Update(), Refresh(), Fit(), SetClientSize(), etc. from wxWindow class.

frank_frl
Earned some good credits
Earned some good credits
Posts: 139
Joined: Sat Feb 18, 2006 1:41 pm
Location: Germany

Post by frank_frl » Sun Nov 30, 2008 4:59 pm

Try to call GetSizer()->Layout() after adding a tab.

Frank
WinXp SP3, OS X10.5.5; CodeLite, Dialog::Blocks, wxWidgets 2.8.10

rrcn
Earned a small fee
Earned a small fee
Posts: 14
Joined: Mon Nov 17, 2008 4:57 pm

Only Fit helps a little

Post by rrcn » Mon Dec 01, 2008 12:45 pm

I tried everything you told but only Fit on the tab bar does something. The problem is that doesn't fill the all area.
I'll post some code.

First it sizes the toolbar and the panel where the tab bar will sit and shows it:

Code: Select all

...
resourcepanel = new wxPanel(this, wxID_ANY);
vbox->Add(resourcepanel, 1, wxEXPAND);
SetSizer(vbox);

Centre();
Show(true);

Then, at user request fills the work area:

Code: Select all

nb = new wxNotebook(resourcepanel, wxID_ANY);
wxPanel *lpanel = new wxPanel(nb,wxID_ANY);
wxPanel *mpanel = new wxPanel(nb,wxID_ANY);
wxPanel *spanel = new wxPanel(nb,wxID_ANY);

lv1 = new wxListView(lpanel,ID_LISTVIEW1,wxDefaultPosition,wxDefaultSize,wxLC_REPORT);
  
lv2 = new wxListView(mpanel,ID_LISTVIEW2,wxDefaultPosition,wxDefaultSize,wxLC_REPORT);
  
lv3 = new wxListView(spanel,ID_LISTVIEW3,wxDefaultPosition,wxDefaultSize,wxLC_REPORT); 

nb->AddPage(lpanel,wxT("L"));
nb->AddPage(mpanel,wxT("M"));
nb->AddPage(spanel,wxT("S"));


wxBoxSizer *vbox2 = new wxBoxSizer(wxHORIZONTAL);
vbox2->Add(nb,1, wxEXPAND);
resourcepanel->SetSizer(vbox2);

wxBoxSizer *vboxl = new wxBoxSizer(wxVERTICAL);
vboxl->Add(lv1,1, wxEXPAND);
lpanel->SetSizer(vboxl);

wxBoxSizer *vboxm = new wxBoxSizer(wxVERTICAL);
vboxm->Add(lv2,1, wxEXPAND);
mpanel->SetSizer(vboxm);

wxBoxSizer *vboxs = new wxBoxSizer(wxVERTICAL);
vboxs->Add(lv3,1, wxEXPAND);
spanel->SetSizer(vboxs);

//With fit I see the contents of the tab bar but it doesn't occupy all available area

nb->Fit();

radcapricorn
Experienced Solver
Experienced Solver
Posts: 70
Joined: Fri Nov 07, 2008 4:25 pm
Location: Saint-Petersburg, Russia

Post by radcapricorn » Mon Dec 01, 2008 2:04 pm

First of all, you shouldn't call Fit() at all, as it fits notebook to its contents, not contents to notebook.

Now, why not use resourcepanel->GetClientSize()?

Try this:

Code: Select all


		wxBoxSizer *vbox2 = new wxBoxSizer(wxVERTICAL);
		resourcepanel->SetSizer(vbox2);	

		wxNotebook* nb = new wxNotebook(resourcepanel, wxID_ANY, wxDefaultPosition, resourcepanel->GetClientSize());
		vbox2->Add(nb,1, wxEXPAND);

		wxPanel *lpanel = new wxPanel(nb,wxID_ANY);
		wxBoxSizer *vboxl = new wxBoxSizer(wxVERTICAL);
		lpanel->SetSizer(vboxl);

		wxPanel *mpanel = new wxPanel(nb,wxID_ANY);
		wxBoxSizer *vboxm = new wxBoxSizer(wxVERTICAL);
		mpanel->SetSizer(vboxm);

		wxPanel *spanel = new wxPanel(nb,wxID_ANY);
		wxBoxSizer *vboxs = new wxBoxSizer(wxVERTICAL);
		spanel->SetSizer(vboxs);

		wxListView* lv1 = new wxListView(lpanel,ID_LISTVIEW1,wxDefaultPosition,wxDefaultSize,wxLC_REPORT);
		wxListView* lv2 = new wxListView(mpanel,ID_LISTVIEW2,wxDefaultPosition,wxDefaultSize,wxLC_REPORT);
		wxListView* lv3 = new wxListView(spanel,ID_LISTVIEW3,wxDefaultPosition,wxDefaultSize,wxLC_REPORT);

		vboxl->Add(lv1,1, wxEXPAND);
		vboxm->Add(lv2,1, wxEXPAND);
		vboxs->Add(lv3,1, wxEXPAND);

		nb->AddPage(lpanel,wxT("L"));
		nb->AddPage(mpanel,wxT("M"));
		nb->AddPage(spanel,wxT("S"));


win xp pro sp3/VS Express 2008/MinGW;
win Vista Ultimate/VS 2005;
Debian Lenny/gcc/cegcc-mingw32ce;
wxWidgets-2.8.9 w/wxWinCE;

Post Reply