first. I created a Panel named DataViewPanel class into AGUIFrame class, i wanna use that Panel class in order to manage a part of GUI Frame.
file.h
class DataViewPanel : public wxPanel
{
public:
DataViewPanel(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
};
//DECLARE_EVENT_TABLE()
};
file.cpp
AGUIFrame::AGUIFrame(wxWindow* parent, int id, const wxString& title, const wxPoint& pos, const wxSize& size)
: wxFrame(parent, id, title, pos, size)
{
wxPanel* dataViewPanel = new DataViewPanel(this, -1, wxDefaultPosition, wxDefaultSize);
}
AGUIFrame::DataViewPanel::DataViewPanel(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size)
: wxPanel(parent, id, pos, size)
{
wxBoxSizer* topSizer = new wxBoxSizer(wxHORIZONTAL);
topSizer->Add(new wxButton(this, wxID_OK, "OK"),
0, // make horizontally unstretchable
wxALL, // make border all around (implicit top alignment)
10);
topSizer->Add(new wxButton(this, wxID_OK, "Button 1"), 0, wxALL, 10);
topSizer->Add(new wxButton(this, wxID_OK, "Button 2"), 0, wxALL, 10);
}
However, when i create 3 button into DataViewPanel, then compile to show just one Button.
help me to show 3 button of panel in Gui Frame
You need to associate your sizer with the panel, without SetSizer(topSizer)
call the sizer is not used and hence all buttons remain superposed on each other in their default location instead of being correctly placed by it.