summaryrefslogtreecommitdiffstats
path: root/Project/ControlEditorDC.cpp
blob: 84e212d14231c1ab9968faa337cd62033e02b26f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "ControlEditorDC.h"
#include "Camera.h"

ControlEditorDC::ControlEditorDC(wxWindow* parent, int ioflags) : ControlEditor(parent, nullptr, ioflags)
{
    BuildControlElementPanel();
    m_camera = new Camera();
    m_selectionRect = wxRect2DDouble(0, 0, 0, 0);
    // m_camera->SetScale(1.2);
    m_ioFlags = ioflags;
    
    this->GetSizer()->Remove(this->GetSizer()->GetChildren()[0]->GetId()); // remove m_glCanvas object from sizer
    
    delete m_glCanvas; // Delete GLCanvas to allow drawing with wxDC
	m_glCanvas = nullptr;
	SetBackgroundColour(wxColour(255, 255, 255));
	SetBackgroundStyle(wxBG_STYLE_PAINT); // To allow wxBufferedPaintDC works properly.
	Redraw();
}

ControlEditorDC::~ControlEditorDC()
{
    // Recreate the GLCanvas. This is necessary to prevent WorkspaceBase destructor access nullpr.
	// Also avoid the code editing of WorkspaceBase, since is automatically generated by wxCrafter.
	// TODO(?): Find a better way to solve this problem.
	m_glCanvas = new wxGLCanvas(this);
}

void ControlEditorDC::OnPaint(wxPaintEvent& event)
{
}