Developer forums (C::B DEVELOPMENT STRICTLY!) > Development

wxSmith - wxGLCanvas - patch

(1/1)

seb_seb0:
Hello,

I ran into a problem while using wxSmith + wxGLCanvas (in"advanced" group of widgets).
The constructor code provided by wxSmith is not wxWidgets 2.9.0 compatible (order of parameters are different)

Here is the patch (against SVN 6181)

file <CODE::BLOCKS DIR>\src\plugins\contrib\wxSmith\wxwidgets\defitems\wxsglcanvas.cpp
replace line 211.
- (old line)
--- Code: ---Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.wx_str());
--- End code ---

+ (new line)
--- Code: ---Codef(_T("%C(%W, %I, %v, %P, %S, %T, %N);\n"),aname.wx_str());
--- End code ---

notice the change of the %v parameter.

This is all ! Now it works for me !

Best regards,

Seb

killerbot:
you say for wx 2.9, can I conclude the old version of that line should reamin as it is for wx 2.8 ?
So actually we need then an #ifdef construct ?

seb_seb0:
Yes, there are differences between constructors.

wxWidgets 2.8.10:

--- Code: ---void wxGLCanvas(wxWindow* parent,
                        wxWindowID id = -1,     
                        const wxPoint& pos = wxDefaultPosition,
                        const wxSize& size = wxDefaultSize,
                        long style=0,
                        const wxString& name="GLCanvas",
                        int* attribList = 0,
                        const wxPalette& palette = wxNullPalette)

--- End code ---

wxWidgets 2.9:

--- Code: ---wxGLCanvas (wxWindow *parent,
                   wxWindowID id=wxID_ANY,
                   const int *attribList=NULL,
                   const wxPoint &pos=wxDefaultPosition,
                   const wxSize &size=wxDefaultSize,
                   long style=0,
                   const wxString &name="GLCanvas",
                   const wxPalette &palette=wxNullPalette)

--- End code ---

The attribList parameter shifts from last to third position between the 2 wxWidgets versions - and it gives a compiler mistakes.

It is true that the patch will break the 2.8.10 constructor (not a so good solution).
Therefore I propose the following change:

ORIGINAL CODE:

--- Code: ---            #if wxCHECK_VERSION(2, 9, 0)
            Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.wx_str());
            #else
            Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.c_str());
            #endif
--- End code ---

NEW CODE:
           
--- Code: ---#if wxCHECK_VERSION(2, 9, 0)
            Codef(_T("#if wxCHECK_VERSION(2, 9, 0)\n"),aname.wx_str());
            Codef(_T("%C(%W, %I, %v, %P, %S, %T, %N);\n"),aname.wx_str());
            Codef(_T("#else\n"),aname.wx_str());
            Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.wx_str());
            Codef(_T("#endif\n"),aname.wx_str());
            #else
            Codef(_T("#if wxCHECK_VERSION(2, 9, 0)\n"),aname.c_str());
            Codef(_T("%C(%W, %I, %v, %P, %S, %T, %N);\n"),aname.c_str());
            Codef(_T("#else\n"),aname.c_str());
            Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.c_str());
            Codef(_T("#endif\n"),aname.c_str());
            #endif
--- End code ---

That will put a wxCHECK_VERSION directive in the user code - therefore wxSmith will adapt itself directly to the user choice.
I have tested it this morning - here is the result code generated by wxSmith:


--- Code: ---         int GLCanvasAttributes_1[] = {
WX_GL_RGBA,
WX_GL_DOUBLEBUFFER,
WX_GL_DEPTH_SIZE,      16,
WX_GL_STENCIL_SIZE,    0,
0, 0 };
#if wxCHECK_VERSION(2, 9, 0)
GLCanvas1 = new wxGLCanvas(this, ID_GLCANVAS1, GLCanvasAttributes_1, wxDefaultPosition, wxSize(60,180), 0, _T("ID_GLCANVAS1"));
#else
GLCanvas1 = new wxGLCanvas(this, ID_GLCANVAS1, wxDefaultPosition, wxSize(60,180), 0, _T("ID_GLCANVAS1"), GLCanvasAttributes_1);
#endif
--- End code ---

and it compiles perfectly well on my computer.
I attach also a patch (done against trunk this morning):



[attachment deleted by admin]

rcoll:

The patch looks good, but you can get rid of those "aname.wx_str*()" and "aname.c_str()"  where they are not needed:

NEW CODE:
            #if wxCHECK_VERSION(2, 9, 0)
            Codef(_T("#if wxCHECK_VERSION(2, 9, 0)\n"),aname.wx_str());
            Codef(_T("%C(%W, %I, %v, %P, %S, %T, %N);\n"),aname.wx_str());
            Codef(_T("#else\n"),aname.wx_str());
            Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.wx_str());
            Codef(_T("#endif\n"),aname.wx_str());
            #else
            Codef(_T("#if wxCHECK_VERSION(2, 9, 0)\n"),aname.c_str());
            Codef(_T("%C(%W, %I, %v, %P, %S, %T, %N);\n"),aname.c_str());
            Codef(_T("#else\n"),aname.c_str());
            Codef(_T("%C(%W, %I, %P, %S, %T, %N, %v);\n"),aname.c_str());
            Codef(_T("#endif\n"),aname.c_str());
            #endif

That "aname" value is only needed where you have a "%v" somewhere in the print format.

Ringo

Navigation

[0] Message Index

Go to full version