Second phase of OOR completed. (Original python object return for

wxEvtHandler and derived classes.


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@11962 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn
2001-10-12 23:26:38 +00:00
parent 8754feb848
commit 0122b7e3fc
112 changed files with 3422 additions and 870 deletions

View File

@@ -15,12 +15,7 @@
%{
#include "export.h"
#ifdef __WXMSW__
#include "myglcanvas.h"
#else
#include <wx/glcanvas.h>
#endif
%}
//---------------------------------------------------------------------------
@@ -54,7 +49,8 @@ class wxGLCanvas;
class wxGLContext : public wxObject {
public:
wxGLContext(bool isRGB, wxGLCanvas *win, const wxPalette& palette = wxNullPalette);
wxGLContext(bool isRGB, wxGLCanvas *win,
const wxPalette& palette = wxNullPalette);
~wxGLContext();
void SetCurrent();
@@ -102,13 +98,34 @@ public:
int *attribList = NULL,
const wxPalette& palette = wxNullPalette);
%pragma(python) addtomethod = "__init__:#wx._StdWindowCallbacks(self)"
%name(wxGLCanvasWithContext)
wxGLCanvas( wxWindow *parent,
const wxGLContext *shared = NULL,
wxWindowID id = -1,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = 0,
const char* name = "GLCanvas",
int *attribList = NULL,
const wxPalette& palette = wxNullPalette );
bool Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name);
%pragma(python) addtomethod = "__init__:self._setOORInfo(self)"
%pragma(python) addtomethod = "wxGLCanvasWithContext:val._setOORInfo(self)"
void SetCurrent();
void SetColour(const char *colour);
void SwapBuffers();
wxGLContext* GetContext();
void SetupPixelFormat(int *attribList = NULL);
void SetupPalette(const wxPalette& palette);
wxPalette CreateDefaultPalette();
wxPalette* GetPalette();
};

View File

@@ -56,12 +56,7 @@ extern PyObject *SWIG_newvarlink(void);
#define SWIG_name "glcanvasc"
#include "export.h"
#ifdef __WXMSW__
#include "myglcanvas.h"
#else
#include <wx/glcanvas.h>
#endif
static PyObject* t_output_helper(PyObject* target, PyObject* o) {
@@ -93,7 +88,7 @@ static PyObject* t_output_helper(PyObject* target, PyObject* o) {
#if PYTHON_API_VERSION >= 1009
static char* wxStringErrorMsg = "String or Unicode type required";
#else
static char* wxStringErrorMsg = "string type is required for parameter";
static char* wxStringErrorMsg = "String type required";
#endif
#ifdef __cplusplus
extern "C" {
@@ -411,6 +406,176 @@ static PyObject *_wrap_new_wxGLCanvas(PyObject *self, PyObject *args, PyObject *
return _resultobj;
}
#define new_wxGLCanvasWithContext(_swigarg0,_swigarg1,_swigarg2,_swigarg3,_swigarg4,_swigarg5,_swigarg6,_swigarg7,_swigarg8) (new wxGLCanvas(_swigarg0,_swigarg1,_swigarg2,_swigarg3,_swigarg4,_swigarg5,_swigarg6,_swigarg7,_swigarg8))
static PyObject *_wrap_new_wxGLCanvasWithContext(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxGLCanvas * _result;
wxWindow * _arg0;
wxGLContext * _arg1 = (wxGLContext *) NULL;
wxWindowID _arg2 = (wxWindowID ) -1;
wxPoint * _arg3 = (wxPoint *) &wxDefaultPosition;
wxSize * _arg4 = (wxSize *) &wxDefaultSize;
long _arg5 = (long ) 0;
char * _arg6 = (char *) "GLCanvas";
int * _arg7 = (int *) NULL;
wxPalette * _arg8 = (wxPalette *) &wxNullPalette;
PyObject * _argo0 = 0;
PyObject * _argo1 = 0;
wxPoint temp;
PyObject * _obj3 = 0;
wxSize temp0;
PyObject * _obj4 = 0;
int * temp1;
PyObject * _obj7 = 0;
PyObject * _argo8 = 0;
char *_kwnames[] = { "parent","shared","id","pos","size","style","name","attribList","palette", NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|OiOOlsOO:new_wxGLCanvasWithContext",_kwnames,&_argo0,&_argo1,&_arg2,&_obj3,&_obj4,&_arg5,&_arg6,&_obj7,&_argo8))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxWindow_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of new_wxGLCanvasWithContext. Expected _wxWindow_p.");
return NULL;
}
}
if (_argo1) {
if (_argo1 == Py_None) { _arg1 = NULL; }
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxGLContext_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of new_wxGLCanvasWithContext. Expected _wxGLContext_p.");
return NULL;
}
}
if (_obj3)
{
_arg3 = &temp;
if (! wxPoint_helper(_obj3, &_arg3))
return NULL;
}
if (_obj4)
{
_arg4 = &temp0;
if (! wxSize_helper(_obj4, &_arg4))
return NULL;
}
if (_obj7)
{
int i;
if (PySequence_Check(_obj7)) {
int size = PyObject_Length(_obj7);
temp1 = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int));
for (i = 0; i < size; i++) {
temp1[i] = PyInt_AsLong(PySequence_GetItem(_obj7, i));
}
temp1[size] = 0;
_arg7 = temp1;
}
}
if (_argo8) {
if (_argo8 == Py_None) { _arg8 = NULL; }
else if (SWIG_GetPtrObj(_argo8,(void **) &_arg8,"_wxPalette_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 9 of new_wxGLCanvasWithContext. Expected _wxPalette_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxGLCanvas *)new_wxGLCanvasWithContext(_arg0,_arg1,_arg2,*_arg3,*_arg4,_arg5,_arg6,_arg7,*_arg8);
wxPy_END_ALLOW_THREADS;
} if (_result) {
SWIG_MakePtr(_ptemp, (char *) _result,"_wxGLCanvas_p");
_resultobj = Py_BuildValue("s",_ptemp);
} else {
Py_INCREF(Py_None);
_resultobj = Py_None;
}
{
delete [] _arg7;
}
return _resultobj;
}
#define wxGLCanvas_Create(_swigobj,_swigarg0,_swigarg1,_swigarg2,_swigarg3,_swigarg4,_swigarg5) (_swigobj->Create(_swigarg0,_swigarg1,_swigarg2,_swigarg3,_swigarg4,_swigarg5))
static PyObject *_wrap_wxGLCanvas_Create(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
bool _result;
wxGLCanvas * _arg0;
wxWindow * _arg1;
wxWindowID _arg2;
wxPoint * _arg3;
wxSize * _arg4;
long _arg5;
wxString * _arg6;
PyObject * _argo0 = 0;
PyObject * _argo1 = 0;
wxPoint temp;
PyObject * _obj3 = 0;
wxSize temp0;
PyObject * _obj4 = 0;
PyObject * _obj6 = 0;
char *_kwnames[] = { "self","parent","id","pos","size","style","name", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OOiOOlO:wxGLCanvas_Create",_kwnames,&_argo0,&_argo1,&_arg2,&_obj3,&_obj4,&_arg5,&_obj6))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxGLCanvas_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGLCanvas_Create. Expected _wxGLCanvas_p.");
return NULL;
}
}
if (_argo1) {
if (_argo1 == Py_None) { _arg1 = NULL; }
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxWindow_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxGLCanvas_Create. Expected _wxWindow_p.");
return NULL;
}
}
{
_arg3 = &temp;
if (! wxPoint_helper(_obj3, &_arg3))
return NULL;
}
{
_arg4 = &temp0;
if (! wxSize_helper(_obj4, &_arg4))
return NULL;
}
{
#if PYTHON_API_VERSION >= 1009
char* tmpPtr; int tmpSize;
if (!PyString_Check(_obj6) && !PyUnicode_Check(_obj6)) {
PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
return NULL;
}
if (PyString_AsStringAndSize(_obj6, &tmpPtr, &tmpSize) == -1)
return NULL;
_arg6 = new wxString(tmpPtr, tmpSize);
#else
if (!PyString_Check(_obj6)) {
PyErr_SetString(PyExc_TypeError, wxStringErrorMsg);
return NULL;
}
_arg6 = new wxString(PyString_AS_STRING(_obj6), PyString_GET_SIZE(_obj6));
#endif
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (bool )wxGLCanvas_Create(_arg0,_arg1,_arg2,*_arg3,*_arg4,_arg5,*_arg6);
wxPy_END_ALLOW_THREADS;
} _resultobj = Py_BuildValue("i",_result);
{
if (_obj6)
delete _arg6;
}
return _resultobj;
}
#define wxGLCanvas_SetCurrent(_swigobj) (_swigobj->SetCurrent())
static PyObject *_wrap_wxGLCanvas_SetCurrent(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
@@ -527,11 +692,162 @@ static PyObject *_wrap_wxGLCanvas_GetContext(PyObject *self, PyObject *args, PyO
return _resultobj;
}
#define wxGLCanvas_SetupPixelFormat(_swigobj,_swigarg0) (_swigobj->SetupPixelFormat(_swigarg0))
static PyObject *_wrap_wxGLCanvas_SetupPixelFormat(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxGLCanvas * _arg0;
int * _arg1 = (int *) NULL;
PyObject * _argo0 = 0;
int * temp;
PyObject * _obj1 = 0;
char *_kwnames[] = { "self","attribList", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O|O:wxGLCanvas_SetupPixelFormat",_kwnames,&_argo0,&_obj1))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxGLCanvas_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGLCanvas_SetupPixelFormat. Expected _wxGLCanvas_p.");
return NULL;
}
}
if (_obj1)
{
int i;
if (PySequence_Check(_obj1)) {
int size = PyObject_Length(_obj1);
temp = new int[size+1]; // (int*)malloc((size + 1) * sizeof(int));
for (i = 0; i < size; i++) {
temp[i] = PyInt_AsLong(PySequence_GetItem(_obj1, i));
}
temp[size] = 0;
_arg1 = temp;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
wxGLCanvas_SetupPixelFormat(_arg0,_arg1);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
{
delete [] _arg1;
}
return _resultobj;
}
#define wxGLCanvas_SetupPalette(_swigobj,_swigarg0) (_swigobj->SetupPalette(_swigarg0))
static PyObject *_wrap_wxGLCanvas_SetupPalette(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxGLCanvas * _arg0;
wxPalette * _arg1;
PyObject * _argo0 = 0;
PyObject * _argo1 = 0;
char *_kwnames[] = { "self","palette", NULL };
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"OO:wxGLCanvas_SetupPalette",_kwnames,&_argo0,&_argo1))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxGLCanvas_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGLCanvas_SetupPalette. Expected _wxGLCanvas_p.");
return NULL;
}
}
if (_argo1) {
if (_argo1 == Py_None) { _arg1 = NULL; }
else if (SWIG_GetPtrObj(_argo1,(void **) &_arg1,"_wxPalette_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 2 of wxGLCanvas_SetupPalette. Expected _wxPalette_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
wxGLCanvas_SetupPalette(_arg0,*_arg1);
wxPy_END_ALLOW_THREADS;
} Py_INCREF(Py_None);
_resultobj = Py_None;
return _resultobj;
}
#define wxGLCanvas_CreateDefaultPalette(_swigobj) (_swigobj->CreateDefaultPalette())
static PyObject *_wrap_wxGLCanvas_CreateDefaultPalette(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxPalette * _result;
wxGLCanvas * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxGLCanvas_CreateDefaultPalette",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxGLCanvas_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGLCanvas_CreateDefaultPalette. Expected _wxGLCanvas_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = new wxPalette (wxGLCanvas_CreateDefaultPalette(_arg0));
wxPy_END_ALLOW_THREADS;
} SWIG_MakePtr(_ptemp, (void *) _result,"_wxPalette_p");
_resultobj = Py_BuildValue("s",_ptemp);
return _resultobj;
}
#define wxGLCanvas_GetPalette(_swigobj) (_swigobj->GetPalette())
static PyObject *_wrap_wxGLCanvas_GetPalette(PyObject *self, PyObject *args, PyObject *kwargs) {
PyObject * _resultobj;
wxPalette * _result;
wxGLCanvas * _arg0;
PyObject * _argo0 = 0;
char *_kwnames[] = { "self", NULL };
char _ptemp[128];
self = self;
if(!PyArg_ParseTupleAndKeywords(args,kwargs,"O:wxGLCanvas_GetPalette",_kwnames,&_argo0))
return NULL;
if (_argo0) {
if (_argo0 == Py_None) { _arg0 = NULL; }
else if (SWIG_GetPtrObj(_argo0,(void **) &_arg0,"_wxGLCanvas_p")) {
PyErr_SetString(PyExc_TypeError,"Type error in argument 1 of wxGLCanvas_GetPalette. Expected _wxGLCanvas_p.");
return NULL;
}
}
{
wxPy_BEGIN_ALLOW_THREADS;
_result = (wxPalette *)wxGLCanvas_GetPalette(_arg0);
wxPy_END_ALLOW_THREADS;
} if (_result) {
SWIG_MakePtr(_ptemp, (char *) _result,"_wxPalette_p");
_resultobj = Py_BuildValue("s",_ptemp);
} else {
Py_INCREF(Py_None);
_resultobj = Py_None;
}
return _resultobj;
}
static PyMethodDef glcanvascMethods[] = {
{ "wxGLCanvas_GetPalette", (PyCFunction) _wrap_wxGLCanvas_GetPalette, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_CreateDefaultPalette", (PyCFunction) _wrap_wxGLCanvas_CreateDefaultPalette, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_SetupPalette", (PyCFunction) _wrap_wxGLCanvas_SetupPalette, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_SetupPixelFormat", (PyCFunction) _wrap_wxGLCanvas_SetupPixelFormat, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_GetContext", (PyCFunction) _wrap_wxGLCanvas_GetContext, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_SwapBuffers", (PyCFunction) _wrap_wxGLCanvas_SwapBuffers, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_SetColour", (PyCFunction) _wrap_wxGLCanvas_SetColour, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_SetCurrent", (PyCFunction) _wrap_wxGLCanvas_SetCurrent, METH_VARARGS | METH_KEYWORDS },
{ "wxGLCanvas_Create", (PyCFunction) _wrap_wxGLCanvas_Create, METH_VARARGS | METH_KEYWORDS },
{ "new_wxGLCanvasWithContext", (PyCFunction) _wrap_new_wxGLCanvasWithContext, METH_VARARGS | METH_KEYWORDS },
{ "new_wxGLCanvas", (PyCFunction) _wrap_new_wxGLCanvas, METH_VARARGS | METH_KEYWORDS },
{ "wxGLContext_GetWindow", (PyCFunction) _wrap_wxGLContext_GetWindow, METH_VARARGS | METH_KEYWORDS },
{ "wxGLContext_SwapBuffers", (PyCFunction) _wrap_wxGLContext_SwapBuffers, METH_VARARGS | METH_KEYWORDS },

View File

@@ -74,6 +74,9 @@ class wxGLCanvasPtr(wxScrolledWindowPtr):
def __init__(self,this):
self.this = this
self.thisown = 0
def Create(self, *_args, **_kwargs):
val = apply(glcanvasc.wxGLCanvas_Create,(self,) + _args, _kwargs)
return val
def SetCurrent(self, *_args, **_kwargs):
val = apply(glcanvasc.wxGLCanvas_SetCurrent,(self,) + _args, _kwargs)
return val
@@ -87,16 +90,36 @@ class wxGLCanvasPtr(wxScrolledWindowPtr):
val = apply(glcanvasc.wxGLCanvas_GetContext,(self,) + _args, _kwargs)
if val: val = wxGLContextPtr(val)
return val
def SetupPixelFormat(self, *_args, **_kwargs):
val = apply(glcanvasc.wxGLCanvas_SetupPixelFormat,(self,) + _args, _kwargs)
return val
def SetupPalette(self, *_args, **_kwargs):
val = apply(glcanvasc.wxGLCanvas_SetupPalette,(self,) + _args, _kwargs)
return val
def CreateDefaultPalette(self, *_args, **_kwargs):
val = apply(glcanvasc.wxGLCanvas_CreateDefaultPalette,(self,) + _args, _kwargs)
if val: val = wxPalettePtr(val) ; val.thisown = 1
return val
def GetPalette(self, *_args, **_kwargs):
val = apply(glcanvasc.wxGLCanvas_GetPalette,(self,) + _args, _kwargs)
if val: val = wxPalettePtr(val)
return val
def __repr__(self):
return "<C wxGLCanvas instance at %s>" % (self.this,)
class wxGLCanvas(wxGLCanvasPtr):
def __init__(self,*_args,**_kwargs):
self.this = apply(glcanvasc.new_wxGLCanvas,_args,_kwargs)
self.thisown = 1
#wx._StdWindowCallbacks(self)
self._setOORInfo(self)
def wxGLCanvasWithContext(*_args,**_kwargs):
val = wxGLCanvasPtr(apply(glcanvasc.new_wxGLCanvasWithContext,_args,_kwargs))
val.thisown = 1
val._setOORInfo(self)
return val

View File

@@ -6,7 +6,7 @@
// Created: 04/01/98
// RCS-ID: $Id$
// Copyright: (c) Julian Smart
// Licence: wxWindows licence
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
#ifdef __GNUG__
@@ -36,7 +36,8 @@
#include "myglcanvas.h"
wxChar wxGLCanvasClassName[] = wxT("wxGLCanvasClass");
static const wxChar *wxGLCanvasClassName = wxT("wxGLCanvasClass");
static const wxChar *wxGLCanvasClassNameNoRedraw = wxT("wxGLCanvasClassNR");
LRESULT WXDLLEXPORT APIENTRY _EXPORT wxWndProc(HWND hWnd, UINT message,
WPARAM wParam, LPARAM lParam);
@@ -216,25 +217,16 @@ wxGLCanvas::~wxGLCanvas()
::ReleaseDC((HWND) GetHWND(), (HDC) m_hDC);
}
// Replaces wxWindow::Create functionality, since we need to use a different window class
bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
const wxPoint& pos, const wxSize& size, long style, const wxString& name)
// Replaces wxWindow::Create functionality, since we need to use a different
// window class
bool wxGLCanvas::Create(wxWindow *parent,
wxWindowID id,
const wxPoint& pos,
const wxSize& size,
long style,
const wxString& name)
{
/*
Suggestion from Kelly Brock <kbrock@8cs.com> (not yet implemented):
OpenGL corruption fix is simple assuming it doesn't screw anything else
up. Add the following line to the top of the create function:
wxSize parentSize = GetClientSize();
All locations within the function that use 'size' are changed to
'parentSize'.
The above corrects the initial display corruption with the GeForce and
TNT2, not sure about other NVidia cards yet.
*/
static bool registeredGLCanvasClass = FALSE;
static bool s_registeredGLCanvasClass = FALSE;
// We have to register a special window class because we need
// the CS_OWNDC style for GLCanvas.
@@ -256,12 +248,10 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
only way to prevent this, the only reliable means, is to set CS_OWNDC."
*/
if (!registeredGLCanvasClass)
if (!s_registeredGLCanvasClass)
{
WNDCLASS wndclass;
static const long styleNormal = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
// the fields which are common to all classes
wndclass.lpfnWndProc = (WNDPROC)wxWndProc;
wndclass.cbClsExtra = 0;
@@ -274,15 +264,29 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
// Register the GLCanvas class name
wndclass.hbrBackground = (HBRUSH)NULL;
wndclass.lpszClassName = wxGLCanvasClassName;
wndclass.style = styleNormal;
wndclass.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_OWNDC;
if ( !RegisterClass(&wndclass) )
if ( !::RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(wxGLCanvasClass)"));
return FALSE;
}
registeredGLCanvasClass = TRUE;
// Register the GLCanvas class name for windows which don't do full repaint
// on resize
wndclass.lpszClassName = wxGLCanvasClassNameNoRedraw;
wndclass.style &= ~(CS_HREDRAW | CS_VREDRAW);
if ( !::RegisterClass(&wndclass) )
{
wxLogLastError(wxT("RegisterClass(wxGLCanvasClassNameNoRedraw)"));
::UnregisterClass(wxGLCanvasClassName, wxhInstance);
return FALSE;
}
s_registeredGLCanvasClass = TRUE;
}
wxCHECK_MSG( parent, FALSE, wxT("can't create wxWindow without parent") );
@@ -305,10 +309,7 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
books that contain the wgl function descriptions.
*/
msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS;
// if ( style & wxCLIP_CHILDREN )
// msflags |= WS_CLIPCHILDREN;
msflags |= WS_CLIPCHILDREN;
msflags |= WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN;
bool want3D;
WXDWORD exStyle = Determine3DEffects(WS_EX_CLIENTEDGE, &want3D);
@@ -329,38 +330,11 @@ bool wxGLCanvas::Create(wxWindow *parent, wxWindowID id,
DLGC_WANTTAB | DLGC_WANTMESSAGE;
}
MSWCreate(m_windowId, parent, wxGLCanvasClassName, this, NULL,
pos.x, pos.y,
WidthDefault(size.x), HeightDefault(size.y),
msflags, NULL, exStyle);
return TRUE;
return MSWCreate(wxGLCanvasClassName, NULL, pos, size, msflags, exStyle);
}
void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
static void AdjustPFDForAttributes(PIXELFORMATDESCRIPTOR& pfd, int *attribList)
{
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER, /* support double-buffering */
PFD_TYPE_RGBA, /* color type */
16, /* prefered color depth */
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
0, /* no alpha buffer */
0, /* alpha bits (ignored) */
0, /* no accumulation buffer */
0, 0, 0, 0, /* accum bits (ignored) */
16, /* depth buffer */
0, /* no stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0, 0, 0, /* no layer, visible, damage masks */
};
if (attribList) {
pfd.dwFlags &= ~PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_COLORINDEX;
@@ -433,17 +407,42 @@ void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
}
}
}
}
void wxGLCanvas::SetupPixelFormat(int *attribList) // (HDC hDC)
{
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER, /* support double-buffering */
PFD_TYPE_RGBA, /* color type */
16, /* prefered color depth */
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
0, /* no alpha buffer */
0, /* alpha bits (ignored) */
0, /* no accumulation buffer */
0, 0, 0, 0, /* accum bits (ignored) */
16, /* depth buffer */
0, /* no stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0, 0, 0, /* no layer, visible, damage masks */
};
AdjustPFDForAttributes(pfd, attribList);
pixelFormat = ChoosePixelFormat((HDC) m_hDC, &pfd);
if (pixelFormat == 0) {
MessageBox(WindowFromDC((HDC) m_hDC), wxT("ChoosePixelFormat failed."), wxT("Error"),
MB_ICONERROR | MB_OK);
exit(1);
wxLogWarning(_("ChoosePixelFormat failed."));
}
if (SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) != TRUE) {
MessageBox(WindowFromDC((HDC) m_hDC), wxT("SetPixelFormat failed."), wxT("Error"),
MB_ICONERROR | MB_OK);
exit(1);
else {
if (SetPixelFormat((HDC) m_hDC, pixelFormat, &pfd) != TRUE) {
wxLogWarning(_("SetPixelFormat failed."));
}
}
}
@@ -459,7 +458,7 @@ void wxGLCanvas::SetupPalette(const wxPalette& palette)
}
else
{
return;
return;
}
m_palette = palette;
@@ -493,20 +492,20 @@ wxPalette wxGLCanvas::CreateDefaultPalette()
/* build a simple RGB color palette */
{
int redMask = (1 << pfd.cRedBits) - 1;
int greenMask = (1 << pfd.cGreenBits) - 1;
int blueMask = (1 << pfd.cBlueBits) - 1;
int i;
int redMask = (1 << pfd.cRedBits) - 1;
int greenMask = (1 << pfd.cGreenBits) - 1;
int blueMask = (1 << pfd.cBlueBits) - 1;
int i;
for (i=0; i<paletteSize; ++i) {
pPal->palPalEntry[i].peRed =
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
pPal->palPalEntry[i].peGreen =
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
pPal->palPalEntry[i].peBlue =
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
pPal->palPalEntry[i].peFlags = 0;
}
for (i=0; i<paletteSize; ++i) {
pPal->palPalEntry[i].peRed =
(((i >> pfd.cRedShift) & redMask) * 255) / redMask;
pPal->palPalEntry[i].peGreen =
(((i >> pfd.cGreenShift) & greenMask) * 255) / greenMask;
pPal->palPalEntry[i].peBlue =
(((i >> pfd.cBlueShift) & blueMask) * 255) / blueMask;
pPal->palPalEntry[i].peFlags = 0;
}
}
HPALETTE hPalette = CreatePalette(pPal);
@@ -716,5 +715,53 @@ void glAddSwapHintRectWin(GLint x, GLint y, GLsizei width, GLsizei height)
{
}
//---------------------------------------------------------------------------
// wxGLApp
//---------------------------------------------------------------------------
IMPLEMENT_CLASS(wxGLApp, wxApp)
bool wxGLApp::InitGLVisual(int *attribList)
{
int pixelFormat;
PIXELFORMATDESCRIPTOR pfd = {
sizeof(PIXELFORMATDESCRIPTOR), /* size */
1, /* version */
PFD_SUPPORT_OPENGL |
PFD_DRAW_TO_WINDOW |
PFD_DOUBLEBUFFER, /* support double-buffering */
PFD_TYPE_RGBA, /* color type */
16, /* prefered color depth */
0, 0, 0, 0, 0, 0, /* color bits (ignored) */
0, /* no alpha buffer */
0, /* alpha bits (ignored) */
0, /* no accumulation buffer */
0, 0, 0, 0, /* accum bits (ignored) */
16, /* depth buffer */
0, /* no stencil buffer */
0, /* no auxiliary buffers */
PFD_MAIN_PLANE, /* main layer */
0, /* reserved */
0, 0, 0, /* no layer, visible, damage masks */
};
AdjustPFDForAttributes(pfd, attribList);
// use DC for whole (root) screen, since no windows have yet been created
pixelFormat = ChoosePixelFormat((HDC) ::GetDC(NULL), &pfd);
if (pixelFormat == 0) {
wxLogError(_("Failed to initialize OpenGL"));
return FALSE;
}
return TRUE;
}
wxGLApp::~wxGLApp()
{
}
#endif
// wxUSE_GLCANVAS

View File

@@ -17,8 +17,6 @@
#define _WX_GLCANVAS_H_
#include <wx/setup.h>
#undef wxUSE_GLCANVAS
#define wxUSE_GLCANVAS 1
#if wxUSE_GLCANVAS
@@ -131,9 +129,29 @@ protected:
wxPalette m_palette;
WXHDC m_hDC;
DECLARE_EVENT_TABLE()
DECLARE_EVENT_TABLE()
};
class wxGLApp : public wxApp
{
public:
wxGLApp() : wxApp() { }
virtual ~wxGLApp();
// use this in the constructor of the user-derived wxGLApp class to
// determine if an OpenGL rendering context with these attributes
// is available - returns TRUE if so, FALSE if not.
bool InitGLVisual(int *attribList);
private:
DECLARE_DYNAMIC_CLASS(wxGLApp)
};
#endif
// wxUSE_GLCANVAS
#endif