am new to wxWidgets so... yea :>
I kind of started of with this video for seizers
https://youtu.be/kPB5Y6ef9dw?t=135
Around this timestamp it is said, that the "this" on creating a panel like
wxPanel* p1 = new wxPanel(this, wxID_ANY, wxDefaultPosition, wxSize(20 , 20));
transfers ownership to the framework.
Where am not sure about is, what happens with seizers, since they don´t have a parent argument.
What I´m trying is, to crate an own class deriving from wxPanel which puts two panels in a horizontal seizer which trough a loop in the constructor
get´s put in a vertical seizer to create an arrangement like
What I have is, that the last created panel is displayed in left upepr corner. I already read, it´s probably a parenting issue, but I can´t figure it.
Plus I don´t know if this attempt of mine even works.
best regards,
Justus
.h
Code: Select all
#ifndef STCRT_MENU_BASE_H
#define STCRT_MENU_BASE_H
#include <wx/panel.h>
#include <wx/sizer.h>
#include <wx/stattext.h>
class Strct_Menu_Base_Ui : public wxPanel
{
public:
Strct_Menu_Base_Ui(wxWindow* parent);
protected:
private:
};
#endif
Code: Select all
#include "Strct_Menu_Base_Ui.h"
#define AMT_OF_MENU_ITEMS 3
Strct_Menu_Base_Ui::Strct_Menu_Base_Ui(wxWindow* parent) : wxPanel(parent, wxID_ANY, wxDefaultPosition, wxSize(100 , 100))
{
wxBoxSizer* seizerV = new wxBoxSizer(wxVERTICAL);
for(int i=0; i<AMT_OF_MENU_ITEMS; i++)
{
wxBoxSizer* sizerHor = new wxBoxSizer(wxHORIZONTAL);
seizerV->Add(sizerHor, 1, wxEXPAND | wxALL );
std::unique_ptr<wxBoxSizer> sizerHor = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
seizerV->Add(sizerHor.get(), 1, wxEXPAND | wxALL);
seizHorVec.emplace_back(std::move(sizerHor));
std::unique_ptr<wxPanel> p1 = std::make_unique<wxPanel>(this, wxID_ANY, wxDefaultPosition, wxSize(20 , 20));
p1->SetBackgroundColour(wxColour(255, 0, 0));
sizerHor->Add(p1.get(), 1, wxEXPAND | wxALL);
}
}