wxGLCanvas & sizers are driving me nuts. Can anyone help

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
ross
Experienced Solver
Experienced Solver
Posts: 74
Joined: Tue Sep 14, 2004 12:09 am
Location: Australia

wxGLCanvas & sizers are driving me nuts. Can anyone help

Post by ross » Thu Jan 06, 2005 8:16 am

Hi All,

Can anyone put me out of my misery. I'm trying to display and opengl graphic in a defined portion of a window. It seems this cant be done by putting the canvas in a panel (for example) so you need to use sizers.

Sizers are driving me nuts! After looking at some sample code from Dialog blocks its still not clear to me how one positions a control with sizers. Clearly I'm missing something. More worrying though is trying to put my canvas in a sizer (so to speak) and then positioning that sizer within another sizer that is the window.

I admit I'm lost. can anyone help

Cheers
Ross

upCASE
Site Admin
Site Admin
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Post by upCASE » Thu Jan 06, 2005 8:27 am

Hi!
I admit I'm lost. can anyone help
I'm sure someone can :D What exactly do you want to do? How should the window be layouted?
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda

ross
Experienced Solver
Experienced Solver
Posts: 74
Joined: Tue Sep 14, 2004 12:09 am
Location: Australia

Post by ross » Thu Jan 06, 2005 10:51 pm

What I'm trying to do is have a Opengl graphic displayed in the top right hand corner of a window. The final size I'm not sure of yet but roughly a quarter of the whole window client area.

Some controls will be on the left hand side and some room is left at the bottom of the window for ant aditional controls that may or may not be needed. I figured if I can do this then I should know enough to define the layout anyway I like.

My first approach was to have a panel filling the whole window then a second panel in the top right corner and then display the GL graphic in this panel. However all I get is a small (1cm square) graphic in the top right coner of the second panel. There seems to be no way to make the wxGLCanvas fill this panel?

So I thought I might try sizers. I have the following:

newProgramFrame::newProgramFrame( wxWindow *parent, wxWindowID id, const wxString &title, const wxPoint &position, const wxSize& size, long style )
: wxFrame( parent, id, title, position, size, style)
{
CreateGUIControls();
GetSizer()->Fit(this);

}

newProgramFrame::~newProgramFrame()
{

}

void newProgramFrame::CreateGUIControls(void)
{
wxBoxSizer* WxBoxSizer1 = new wxBoxSizer(wxHORIZONTAL);
this->SetSizer(WxBoxSizer1);
WxBoxSizer1->Add(new wxPanel(this, -1, wxPoint(0,0),wxSize(273,236) ), 1, wxEXPAND|wxALL, 5);

wxBoxSizer* WxBoxSizer2 = new wxBoxSizer(wxHORIZONTAL);
WxBoxSizer2->Add(new wxPanel(this, -1, wxPoint(42,62),wxSize(212,162) ), 1, wxFIXED_MINSIZE , 5);
m_pGLCanvas = new wxGLViewCanvas(this);
WxBoxSizer2->Add(m_pGLCanvas, 1, wxEXPAND|wxALL, 5);
WxBoxSizer1->Add(WxBoxSizer2, 0, wxFIXED_MINSIZE, 5);


////GUI Items Creation Start

this->SetSize(8,8,281,263);
this->SetTitle(_("newProgramFrame"));
this->Center();
this->SetIcon(wxNullIcon);

////GUI Items Creation End
}


However I cant seem to get wxBoxSizer1 to be the same size as the window along with alot of other things. :cry:

Is this the right approach or am I barking up the wrong tree completely? :shock:

Cheers
Ross

ross
Experienced Solver
Experienced Solver
Posts: 74
Joined: Tue Sep 14, 2004 12:09 am
Location: Australia

Post by ross » Sun Jan 23, 2005 11:11 pm

Ok I've reverted to type, ie given up on using sizers. I managed to get what i wanted working with a panel afterall. :D

Post Reply