I have problem aligning 2 buttons, 1 on the left side and the other on the right side. Alignment doesn't seem to take effect with the code below. Basically, I want to lay out the sizers as the following: ------------------------------------------------------------------------ | Left Button | <------Whatever the size is -------> | Right Button | ------------------------------------------------------------------------
#include "wx/wxprec.h"
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
class cFrame: public wxFrame
{
public:
cFrame(const wxString sTitle, int iWidth, int iHeight)
:wxFrame((wxFrame *) NULL, -1, sTitle, wxPoint(-1, -1), wxSize(iWidth, iHeight))
{
wxBoxSizer *pFrameVSizer = new wxBoxSizer(wxVERTICAL);
wxBoxSizer *pBodyFrameVSizer = new wxBoxSizer(wxHORIZONTAL);
pFrameVSizer->Add(pBodyFrameVSizer, 1, wxEXPAND);
pBodyFrameVSizer->Add(new wxButton(this, -1, "LEFT", wxPoint(-1, -1)) , 0, wxALIGN_LEFT);
pBodyFrameVSizer->Add(new wxButton(this, -1, "RIGHT", wxPoint(-1, -1)) , 0, wxALIGN_RIGHT);
SetSizer(pFrameVSizer);
SetAutoLayout(TRUE);
Layout();
};
};
class cSizerLayout: public wxApp
{
public:
virtual bool OnInit();
};
DECLARE_APP(cSizerLayout)
IMPLEMENT_APP(cSizerLayout)
bool cSizerLayout::OnInit()
{
cFrame *pFrame = new cFrame("Sizer Testing", 600, 400);
SetTopWindow(pFrame);
pFrame->Show(TRUE);
return true;
}
|