I need to show a frame where there are two boxes. A box must contain lists, where one of the list is for months and the other is to contain a range of years. The other box must show a graph made with opengl and for that I use the wxglcanvas function.
I can show the graph in the frame, but this happens if I do not include the list in the first box. If I include the list in that case it shows me only the list but not the graph.
How can I insert the list in a box and the graph in another box?
Code: Select all
#include "wx/wxprec.h"
#ifdef __BORLANDC__
#pragma hdrstop
#endif
#ifndef WX_PRECOMP
#include "wx/wx.h"
#endif
#if !wxUSE_GLCANVAS
#error "OpenGL required: set wxUSE_GLCANVAS to 1 and rebuild the library"
#endif
#ifdef __WXMAC__
#include <GLUT/glut.h>
#else
#include <GL/glut.h>
#endif
//#include "../../sample.xpm"
#ifndef __WXMSW__ // for StopWatch, see remark below
#if defined(__WXMAC__) && !defined(__DARWIN__)
#include <utime.h>
#include <unistd.h>
#else
#include <sys/time.h>
#include <sys/unistd.h>
#endif
#else
#include <sys/timeb.h>
#endif
#define ID_NEW_WINDOW 10000
BEGIN_EVENT_TABLE(TestGLCanvas, wxGLCanvas)
EVT_SIZE(TestGLCanvas::OnSize)
EVT_PAINT(TestGLCanvas::OnPaint)
END_EVENT_TABLE()
TestGLCanvas::TestGLCanvas(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
: wxGLCanvas(parent, (wxGLCanvas*) NULL, id, pos, size, style|wxFULL_REPAINT_ON_RESIZE , name )
{
m_init = false;
//m_gllist = 0;
//wxMessageBox("hola");
}
TestGLCanvas::TestGLCanvas(wxWindow *parent, const TestGLCanvas *other,
wxWindowID id, const wxPoint& pos, const wxSize& size, long style,
const wxString& name )
: wxGLCanvas(parent, other->GetContext(), id, pos, size, style|wxFULL_REPAINT_ON_RESIZE , name)
{
m_init = false;
//m_gllist = other->m_gllist; // share display list
}
TestGLCanvas::~TestGLCanvas()
{
}
//GLubyte ubImage[65536];
GLint point1[1000][2];
void TestGLCanvas::Render() ///vendria siendo el void display_cb()
{
wxPaintDC dc(this);
/*#ifndef __WXMOTIF__
if (!GetContext()) return;
#endif*/
SetCurrent();
// Init OpenGL once, but after SetCurrent
if (!m_init)
{
InitGL();
m_init = true;
}
glClearColor(1.f,1.f,1.f,1.f);
glClear(GL_COLOR_BUFFER_BIT);
/**
graphics code----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
glFlush();
SwapBuffers();
}
void TestGLCanvas::OnPaint( wxPaintEvent& WXUNUSED(event) )
{
Render();
}
void TestGLCanvas::OnSize(wxSizeEvent& event) ///Para redimensionar la grafica
{
// this is also necessary to update the context on some platforms
wxGLCanvas::OnSize(event);
// set GL viewport (not called by wxGLCanvas::OnSize on all platforms...)
int w, h;
GetClientSize(&w, &h);
#ifndef __WXMOTIF__
if (GetContext())
#endif
{
SetCurrent();
glViewport(0, 0, (GLint) w, (GLint) h);
}
}
void TestGLCanvas::InitGL() ///vendria siendo el void reshape_cb (int w, int h)
{
//SetCurrent();
glMatrixMode(GL_PROJECTION);
glLoadIdentity ();
gluOrtho2D(0,700,0,250);
///glMatrixMode(GL_MODELVIEW);
//glLoadIdentity();
//glScalef(1.25, 1.25,0);
//glOrtho(-1, 200, -1, 200, -1, 200);
///
//glPolygonMode(GL_FRONT, GL_FILL);
}
BEGIN_EVENT_TABLE(MyFrame, wxFrame)
END_EVENT_TABLE()
// My frame constructor
MyFrame::MyFrame(wxWindow *parent, const wxString& title, const wxPoint& pos,
const wxSize& size, long style)
: wxFrame(parent, wxID_ANY, title, pos, size, style)
{
m_canvas = NULL;
}
/*static*/ MyFrame *MyFrame::Create(MyFrame *parentFrame, bool isCloneWindow)
{
wxString str = wxT("Grafica");
if (isCloneWindow) str += wxT(" - Clone");
MyFrame *frame = new MyFrame(parentFrame, str, wxDefaultPosition, wxSize(400, 300));
if (parentFrame)
{
frame->m_canvas = new TestGLCanvas(frame, parentFrame->m_canvas,
wxID_ANY, wxDefaultPosition, wxDefaultSize );
}
else
{
frame->m_canvas = new TestGLCanvas(frame, wxID_ANY,
wxDefaultPosition, wxDefaultSize);
}
wxBoxSizer* bSizer28;
bSizer28 = new wxBoxSizer( wxVERTICAL );
wxArrayString m_choice2Choices;
wxChoice *m_choice2 = new wxChoice( frame, wxID_ANY, wxDefaultPosition, wxDefaultSize, m_choice2Choices, 0 );
m_choice2->SetSelection( 0 );
bSizer28->Add( m_choice2, 0, wxALL, 5 );
bSizer28->Add( frame, 1, wxALL|wxEXPAND, 5 );
frame->Show(true);
return frame;
}
void VPrincipal::ClickGrafica(wxCommandEvent& event){
(void) MyFrame::Create(NULL);
}
wxDefaultPosition, wxDefaultSize), so that it generates the graph and then I pass the instruction so that the list is generated in the frame: bSizer28-> Add (m_choice2, 0, wxALL, 5), but this does it above the graph, I think there the problem arises.
How do I do for this type of case?