Streching components 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.
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 »

http://www.mediamax.com/flyingisfun1217 ... MS-Lib.exe thats the program built already.

http://www.mediamax.com/flyingisfun1217 ... Lib.tar.gz theres the source for it.

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

Post by Auria »

You add the object to the panel, but the sizer to the frame - you will need to choose if you add things to the panel OR to the frame, not both at the same time!

second, you give the panel a fixed size, and no sizer controls the panel. Therefore it will never grow.

Third, you give the list a size during creation. Sizers will try to respect that size - if you just want it to grow with the window, don't specify any size.

try this: (i just removed the wxPanel - if you absolutely want it, you'll need to fix the issue another way)

Code: Select all

//---------------------------------------------------------------------------
//
// Name:        MUMSFrm.cpp
// Author:      FlyingIsFun1217
// Created:     1/27/2007 12:22:25 PM
// Description: MUMSFrm class implementation
//
//---------------------------------------------------------------------------

#include "MUMSFrm.h"
#include <wx/sizer.h>
//Do not add custom headers between
//Header Include Start and Header Include End
//wxDev-C++ designer will remove them
////Header Include Start
////Header Include End

//----------------------------------------------------------------------------
// MUMSFrm
//----------------------------------------------------------------------------
//Add Custom Events only in the appropriate block.
//Code added in other places will be removed by wxDev-C++
////Event Table Start
BEGIN_EVENT_TABLE(MUMSFrm,wxFrame)
	////Manual Code Start
	////Manual Code End

	EVT_CLOSE(MUMSFrm::OnClose)
	EVT_MENU(MenuFileNewUser, MUMSFrm::MenuFileNewUserClick)
	EVT_MENU(MenuEditSettings, MUMSFrm::MenuEditSettingsClick)
	EVT_MENU(MenuHelpHelp, MUMSFrm::MenuHelpHelpClick)
	EVT_MENU(MenuHelpAbout, MUMSFrm::MenuHelpAboutClick)
END_EVENT_TABLE()
////Event Table End

MUMSFrm::MUMSFrm(wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style)
: wxFrame(parent, id, title, position, size, style)
{
	CreateGUIControls();
}

MUMSFrm::~MUMSFrm()
{
}

void MUMSFrm::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

	WxListCtrl1 = new wxListCtrl(this, ID_WXLISTCTRL1, wxPoint(10,10), wxDefaultSize, wxLC_REPORT);

	WxMenuBar1 = new wxMenuBar();
	wxMenu *MenuFile_Mnu_Obj = new wxMenu(0);

	wxMenu *MenuFileNew_Mnu_Obj = new wxMenu(0);
	MenuFileNew_Mnu_Obj->Append(MenuFileNewUser, wxT("MUMS User"), wxT("Create a new MUMS user"), wxITEM_NORMAL);
	MenuFile_Mnu_Obj->Append(MenuFileNew, wxT("New..."), MenuFileNew_Mnu_Obj);
	WxMenuBar1->Append(MenuFile_Mnu_Obj, wxT("File"));

	wxMenu *MenuEdit_Mnu_Obj = new wxMenu(0);
	MenuEdit_Mnu_Obj->Append(MenuEditSettings, wxT("Settings"), wxT("Edit MUMS settings"), wxITEM_NORMAL);
	WxMenuBar1->Append(MenuEdit_Mnu_Obj, wxT("Edit"));

	wxMenu *MenuTools_Mnu_Obj = new wxMenu(0);
	WxMenuBar1->Append(MenuTools_Mnu_Obj, wxT("Tools"));
	wxMenu *MenuHelp_Mnu_Obj = new wxMenu(0);
	MenuHelp_Mnu_Obj->Append(MenuHelpHelp, wxT("Help"), wxT("Help for MUMS"), wxITEM_NORMAL);
	MenuHelp_Mnu_Obj->AppendSeparator();
	MenuHelp_Mnu_Obj->Append(MenuHelpAbout, wxT("About"), wxT("About MUMS"), wxITEM_NORMAL);
	WxMenuBar1->Append(MenuHelp_Mnu_Obj, wxT("Help"));
	SetMenuBar(WxMenuBar1);

	SetTitle(wxT("MUMS"));
	SetIcon(wxNullIcon);
	SetSize(8,8,610,595);
	Center();

    wxFlexGridSizer *DisplaySizer = new wxFlexGridSizer(2,1,0,0);
   // DisplaySizer->SetFlexibleDirection(wxHORIZONTAL);
    DisplaySizer->AddGrowableRow(0);
	DisplaySizer->AddGrowableCol(0);
    DisplaySizer->Add(WxListCtrl1, 0, wxALL|wxEXPAND, 0);

    this->SetSizer(DisplaySizer);
    this->Layout();
	this->SetAutoLayout(true);
	/*WxListCtrl->Layout();
	WxListCtrl->Update();*/

	////GUI Items Creation End
}

void MUMSFrm::OnClose(wxCloseEvent& event)
{
	Destroy();
}

/*
 * MenuFileNewUserClick
 */
void MUMSFrm::MenuFileNewUserClick(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * MenuEditSettingsClick
 */
void MUMSFrm::MenuEditSettingsClick(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * MenuHelpHelpClick
 */
void MUMSFrm::MenuHelpHelpClick(wxCommandEvent& event)
{
	// insert your code here
}

/*
 * MenuHelpAboutClick
 */
void MUMSFrm::MenuHelpAboutClick(wxCommandEvent& event)
{
	// insert your code here
}

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

Post by FlyingIsFun1217 »

Aha! Works great!

So I cannot have a Panel at all? The only reason I say this is because I will eventually need space between the components in the frame, and I would like a uniform color that matches the systems colors, instead of the default gray.

Thanks for your help!
FlyingIsFun1217
Auria
Site Admin
Site Admin
Posts: 6695
Joined: Thu Sep 28, 2006 12:23 am
Contact:

Post by Auria »

you can have a panel, you'll just need to set the sizers accordingly (i.e. a first sizer in the frame to make the panel extend to the dimensions of the frame, and a second sizer inside the panel to make its child components stretch with it - just add the sizers to the right component, don't mix things up. A sizer added to a panel will only size the children of panel)

The genral idea of how sizers works:

You create sizer_of_X with component X as parent.
Create a few wxWindows with X as parent too.
Add these wxWindows to sizer_of_X.
Do X->SetSizer(sizer_of_X);

Yo ucan also do SetAutoLayout() to make it auto-updated, sizer_of_X->SetSizeHints(X) to make X the best fitting size, et.c other options

Hope it's clearer now :wink: wxWidgets sizers are not that easy to use compared to those of other toolkits
FlyingIsFun1217
Super wx Problem Solver
Super wx Problem Solver
Posts: 497
Joined: Mon Nov 06, 2006 9:58 pm

Post by FlyingIsFun1217 »

Got that right, very difficult to what I've worked with in the past.

I'll try experimenting with them until I get what I need, and post some results/problems if needed.

Thanks again!
FlyingIsFun1217
Post Reply