C++ Вопрос WxWidgets help

Пользователь
Статус
Оффлайн
Регистрация
1 Дек 2019
Сообщения
262
Реакции[?]
31
Поинты[?]
14K
Как пофиксить вот єту фигню? Чекбокс на заголовке страницы
1678117826658.png
По сути первый день юзаю этот wxWidgets так что помогите, не вдупляюсь.


C++:
#include <wx/wx.h>
#include <wx/notebook.h>
#include <wx/checkbox.h>
#include <wx/slider.h>


class MyApp : public wxApp {
public:
    virtual bool OnInit() override;
};

class MyFrame : public wxFrame {
public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);

    void OnExit(wxCommandEvent& event);
};

class MyPanel : public wxPanel {
public:
    MyPanel(wxNotebook* parent);

    void OnCheckbox(wxCommandEvent& event);
    void OnSlider(wxCommandEvent& event);


private:
    wxCheckBox* m_checkbox;
    wxComboBox* m_comboBox;
    wxSlider* m_slider1;
    wxSlider* m_slider2;
    wxStaticText* m_staticText1;
    wxStaticText* m_staticText2;
    wxStaticText* m_staticText3;
};

wxIMPLEMENT_APP(MyApp);

bool MyApp::OnInit() {

    MyFrame* frame = new MyFrame("Val", wxPoint(50, 50), wxSize(600, 400));
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    : wxFrame(NULL, wxID_ANY, title, pos, size) {
    SetIcon(wxICON(sample));
    wxMenu* menuFile = new wxMenu;
    menuFile->Append(wxID_EXIT);
    wxMenuBar* menuBar = new wxMenuBar;
    menuBar->Append(menuFile, "&File");
    SetMenuBar(menuBar);

    wxNotebook* notebook = new wxNotebook(this, wxID_ANY);
  

    MyPanel* panel1 = new MyPanel(notebook);
    notebook->AddPage(panel1, "Rifles");
    panel1->SetBackgroundColour(wxColour(210, 210, 210, 255));

    MyPanel* panel2 = new MyPanel(notebook);
    notebook->AddPage(panel2, "SMG");

    MyPanel* panel3 = new MyPanel(notebook);
    notebook->AddPage(panel3, "Pistols");

    MyPanel* panel4 = new MyPanel(notebook);
    notebook->AddPage(panel4, "Snipers");

    MyPanel* panel5 = new MyPanel(notebook);
    notebook->AddPage(panel4, "Shotgun");

    notebook->SetPadding(wxSize(10, 3));
    wxBoxSizer* sizer = new wxBoxSizer(wxVERTICAL);
    //sizer->Add(notebook, 1, wxEXPAND);
    sizer->Add(notebook, wxSizerFlags(0).Expand().Border(wxALL, 10));
    SetSizer(sizer);

    Bind(wxEVT_MENU, &MyFrame::OnExit, this, wxID_EXIT);
}

void MyFrame::OnExit(wxCommandEvent& event) {
    Close(true);
}

MyPanel::MyPanel(wxNotebook* parent)
    : wxPanel(parent, wxID_ANY) {


    wxString choices[] = { "Head", "Body" };

    m_checkbox = new wxCheckBox(this, wxID_ANY, "Enable");
    m_comboBox = new wxComboBox(this, wxID_ANY, choices[0], wxDefaultPosition, wxSize(150, 0), WXSIZEOF(choices), choices, wxCB_DROPDOWN);
    m_slider1 = new wxSlider(this, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxSize(150, -1));
    m_slider2 = new wxSlider(this, wxID_ANY, 50, 0, 100, wxDefaultPosition, wxSize(150, -1));
    m_staticText1 = new wxStaticText(this, wxID_ANY, "Fov");
    m_staticText2 = new wxStaticText(this, wxID_ANY, "Speаd");
    m_staticText3 = new wxStaticText(this, wxID_ANY, "HitBox:", wxPoint(25, 55));



    auto staticBox = new wxStaticBox(this, wxID_ANY, "Aim");

    auto staticBoxSizer = new wxStaticBoxSizer(staticBox, wxVERTICAL);
    staticBoxSizer->Add(m_checkbox, 0, wxBOTTOM, 20);

    staticBoxSizer->Add(m_comboBox, 0, wxLEFT | wxTOP | wxBOTTOM, 15);
    staticBoxSizer->Add(m_staticText1, 0, wxLEFT | wxTOP, 15);
    staticBoxSizer->Add(m_slider1, 0,  wxLEFT | wxRIGHT | wxBOTTOM, 10);
    staticBoxSizer->Add(m_staticText2, 0, wxLEFT, 15);
    staticBoxSizer->Add(m_slider2, 0,  wxLEFT | wxRIGHT | wxBOTTOM, 10);
  




    auto sizer = new wxBoxSizer(wxVERTICAL);
    //sizer->Add(m_checkbox, 0, wxALL, 10);
    sizer->Add(staticBoxSizer, 0, wxALL, 10);

    SetSizer(sizer);

  

    Bind(wxEVT_CHECKBOX, &MyPanel::OnCheckbox, this, m_checkbox->GetId());
    Bind(wxEVT_SLIDER, &MyPanel::OnSlider, this, m_slider1->GetId());
    Bind(wxEVT_SLIDER, &MyPanel::OnSlider, this, m_slider2->GetId());


}

void MyPanel::OnCheckbox(wxCommandEvent& event) {
    bool checked = m_checkbox->GetValue();
    // do something with the checkbox state
}

void MyPanel::OnSlider(wxCommandEvent& event) {
  
    int value1 = m_slider1->GetValue();
    int value2 = m_slider2->GetValue();
    // do something with the slider values
}
 
Пользователь
Статус
Оффлайн
Регистрация
1 Дек 2019
Сообщения
262
Реакции[?]
31
Поинты[?]
14K
Сверху Снизу