3 SplitterWindow Creation? Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Idogftw
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jun 25, 2018 10:19 pm

3 SplitterWindow Creation?

Post by Idogftw »

Ok so I copied then modified the given 'Splitter.cpp' file in my own project and managed to get it to where there are two split vertical windows and a horizontal, but can't figure out how to achieve whats in the picture, the reason being is that if you try to split a window that is split it returns false, so I need an alternative, basically I just wanna achieve whats in the picture. The end goal is a map editor
2D window (left panel), 3D window (middle panel), Console area (bottom panel), and Editor for misc stuff (Right panel)
Image
Here is the code I am using:

Code: Select all

wxWindow *m_left, *m_right, *m_console, *m_info;

wxSplitterWindow* m_splitter, *m_splitter_b, *m_splitter_r;

wxBoxSizer *_topCont, *_mainCont; //Containers

_topCont = new wxBoxSizer(wxVERTICAL);
_mainCont = new wxBoxSizer(wxHORIZONTAL);
_topCont->Add(_mainCont, 1, wxEXPAND);

m_splitter = new MySplitterWindow(this);
m_splitter->SetMinimumPaneSize(1);

_topCont->Add(m_splitter, 1, wxEXPAND);

m_splitter_b = new wxSplitterWindow(m_splitter, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxSP_3D | wxSP_LIVE_UPDATE |
wxSP_NO_XP_THEME);
m_splitter_b->SetMinimumPaneSize(1);

m_splitter_r = new wxSplitterWindow(m_splitter, wxID_ANY,
wxDefaultPosition, wxDefaultSize,
wxSP_3D | wxSP_LIVE_UPDATE |
wxSP_NO_XP_THEME);
m_splitter_r->SetMinimumPaneSize(1);

m_splitter->SetSize(GetClientSize());
m_splitter->SetSashGravity(1.0);

m_left = new MyCanvas(m_splitter_b, false);
m_left->SetBackgroundColour(*wxRED);

m_right = new MyCanvas(m_splitter_b, false);
m_right->SetBackgroundColour(*wxLIGHT_GREY);

m_console = new MyCanvas(m_splitter, false);
m_console->SetBackgroundColour(*wxGREEN);

m_info = new MyCanvas(m_splitter, false);
m_info->SetBackgroundColour(*wxBLACK);

m_splitter_b->SplitVertically(m_left, m_right, 300);
m_splitter->SplitHorizontally(m_splitter_b, m_info, 400);
//m_splitter_r->SplitVertically(m_splitter_b, m_console, 500);
Which produces this:
Image
User avatar
doublemax
Moderator
Moderator
Posts: 19160
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: 3 SplitterWindow Creation?

Post by doublemax »

m_info = new MyCanvas(m_splitter, false);
If i understood the code correctly, this should have m_splitter_r as parent.
Use the source, Luke!
Idogftw
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jun 25, 2018 10:19 pm

Re: 3 SplitterWindow Creation?

Post by Idogftw »

Even with changing it, it does nothing, just still returns the

Code: Select all

m_splitter_r->SplitVertically
as false.
Idogftw
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jun 25, 2018 10:19 pm

Re: 3 SplitterWindow Creation?

Post by Idogftw »

Can anyone please help me, my code is 100% completely wrong, if need be I can change it, but I don't know how seeing as once you set a window, you can't set it again with another object that's already been split, i've tried many ways but they usually end in failure, I literally just want whats in that paint image. aka two windows at the top, one on the side, and a bottom
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4204
Joined: Sun Jan 03, 2010 5:45 pm

Re: 3 SplitterWindow Creation?

Post by PB »

Sorry, I did not read your code, I just created my simple test one based on your description and goal picture, seems to work as expected, but perhaps I am missing something?
splitter.png
splitter.png (2.6 KiB) Viewed 1116 times

Code: Select all

#include <wx/wx.h>
#include <wx/splitter.h>

class MyFrame : public wxFrame
{
public:
    MyFrame() : wxFrame(NULL, wxID_ANY, "Test", wxDefaultPosition, wxSize(600, 400))
    {
        wxSplitterWindow* splitterMain = new wxSplitterWindow(this);
        wxSplitterWindow* splitter2D3DConsole = new wxSplitterWindow(splitterMain);
        wxSplitterWindow* splitter2D3D = new wxSplitterWindow(splitter2D3DConsole);

        wxPanel* view2D = new wxPanel(splitter2D3D);
        view2D->SetBackgroundColour(*wxRED);

        wxPanel* view3D = new wxPanel(splitter2D3D);
        view3D->SetBackgroundColour(*wxGREEN);

        wxPanel* console = new wxPanel(splitter2D3DConsole);
        console->SetBackgroundColour(*wxBLACK);

        wxPanel* editor = new wxPanel(splitterMain);
        editor->SetBackgroundColour(*wxCYAN);

        splitterMain->SetSize(GetClientSize());
        splitterMain->SplitVertically(splitter2D3DConsole, editor, -150);

        splitter2D3DConsole->SplitHorizontally(splitter2D3D, console, -150);

        splitter2D3D->SplitVertically(view2D, view3D);
    }
};

class MyApp : public wxApp
{
public:
    bool OnInit()
    {
        (new MyFrame())->Show();
        return true;
    }
}; wxIMPLEMENT_APP(MyApp);
Idogftw
In need of some credit
In need of some credit
Posts: 4
Joined: Mon Jun 25, 2018 10:19 pm

Re: 3 SplitterWindow Creation?

Post by Idogftw »

Thank you very much man! :D I've been stuck on this since I posted it, been driving me up the wall.
Post Reply