From a9c7cf15bdbdbc2dba83a2a0b395916394fd5cbf Mon Sep 17 00:00:00 2001 From: Eduardo DAVILA Date: Wed, 20 Sep 2017 16:54:40 +0200 Subject: [PATCH] #3127 BBTK Feature New Normal - branch changeWx28to30 compilation with wxWidgets3 --- kernel/appli/bbStudio/bbStudio.cxx | 25 ++++++--- kernel/appli/bbi/bbi.cxx | 51 ++++++++++++++----- kernel/src/bbtkWxGUICommand.cxx | 6 +++ kernel/src/bbtkWxGUITextEditor.cxx | 16 ++++++ packages/wx/src/bbwxFileSelector.cxx | 16 ++++-- .../wxvtk/src/wxVTKRenderWindowInteractor.cxx | 49 ++++++++++++------ 6 files changed, 124 insertions(+), 39 deletions(-) diff --git a/kernel/appli/bbStudio/bbStudio.cxx b/kernel/appli/bbStudio/bbStudio.cxx index 4a00d22..25e4612 100644 --- a/kernel/appli/bbStudio/bbStudio.cxx +++ b/kernel/appli/bbStudio/bbStudio.cxx @@ -35,14 +35,25 @@ #include #include +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_PARAM, NULL, NULL, _T("file1 [file2 [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") }, + { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") }, + { wxCMD_LINE_NONE } + }; +#else + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_PARAM, NULL, NULL, "file1 [file2 [...]]", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, + { wxCMD_LINE_SWITCH, "h", "help", "Prints this help" }, + { wxCMD_LINE_SWITCH, "d", "debug", "Message all 9" }, + { wxCMD_LINE_NONE } + }; +#endif -static const wxCmdLineEntryDesc cmdLineDesc[] = -{ - { wxCMD_LINE_PARAM, NULL, NULL, _T("file1 [file2 [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL }, - { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("Prints this help") }, - { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("Message all 9") }, - { wxCMD_LINE_NONE } -}; diff --git a/kernel/appli/bbi/bbi.cxx b/kernel/appli/bbi/bbi.cxx index 89a3daa..ea8dd6c 100644 --- a/kernel/appli/bbi/bbi.cxx +++ b/kernel/appli/bbi/bbi.cxx @@ -40,20 +40,43 @@ #include //========================================================================== -// Command line options definition -static const wxCmdLineEntryDesc cmdLineDesc[] = -{ - { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("print this help or help on the application defined in input bbs file if any") }, - { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"), _T("prompt the input parameter values using graphical dialog") }, - { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"), _T("prompt the input parameter values in text mode") }, - { wxCMD_LINE_SWITCH, _T("c"), _T("console"), _T("open bbi console") }, - { wxCMD_LINE_SWITCH, _T("N"), _T("no-console"), _T("never open bbi console even on error") }, - { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet (='message max 0')") }, - { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("turn all messages on (='message all 9')") }, - { wxCMD_LINE_SWITCH, _T("D"), _T("Debug"), _T("memory debug on exit (='debug -D')") }, - { wxCMD_LINE_PARAM, NULL, NULL, _T("file [file [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, - { wxCMD_LINE_NONE } -}; + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + // Command line options definition + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_SWITCH, _T("h"), _T("help"), _T("print this help or help on the application defined in input bbs file if any") }, + { wxCMD_LINE_SWITCH, _T("g"), _T("graphical-dialog"), _T("prompt the input parameter values using graphical dialog") }, + { wxCMD_LINE_SWITCH, _T("t"), _T("text-dialog"), _T("prompt the input parameter values in text mode") }, + { wxCMD_LINE_SWITCH, _T("c"), _T("console"), _T("open bbi console") }, + { wxCMD_LINE_SWITCH, _T("N"), _T("no-console"), _T("never open bbi console even on error") }, + { wxCMD_LINE_SWITCH, _T("q"), _T("quiet"), _T("be quiet (='message max 0')") }, + { wxCMD_LINE_SWITCH, _T("d"), _T("debug"), _T("turn all messages on (='message all 9')") }, + { wxCMD_LINE_SWITCH, _T("D"), _T("Debug"), _T("memory debug on exit (='debug -D')") }, + { wxCMD_LINE_PARAM, NULL, NULL, _T("file [file [...]]"), wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, + { wxCMD_LINE_NONE } + }; +#else + // Command line options definition + static const wxCmdLineEntryDesc cmdLineDesc[] = + { + { wxCMD_LINE_SWITCH, "h", "help", "print this help or help on the application defined in input bbs file if any" }, + { wxCMD_LINE_SWITCH, "g", "graphical-dialog", "prompt the input parameter values using graphical dialog" }, + { wxCMD_LINE_SWITCH, "t", "text-dialog", "prompt the input parameter values in text mode" }, + { wxCMD_LINE_SWITCH, "c", "console", "open bbi console" }, + { wxCMD_LINE_SWITCH, "N", "no-console", "never open bbi console even on error" }, + { wxCMD_LINE_SWITCH, "q", "quiet", "be quiet (='message max 0')" }, + { wxCMD_LINE_SWITCH, "d", "debug", "turn all messages on (='message all 9')" }, + { wxCMD_LINE_SWITCH, "D", "Debug", "memory debug on exit (='debug -D')" }, + { wxCMD_LINE_PARAM, NULL, NULL, "file [file [...]]", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL | wxCMD_LINE_PARAM_MULTIPLE }, + { wxCMD_LINE_NONE } + }; +#endif + + + + //========================================================================== //========================================================================== diff --git a/kernel/src/bbtkWxGUICommand.cxx b/kernel/src/bbtkWxGUICommand.cxx index 2e37ec4..c9fc382 100644 --- a/kernel/src/bbtkWxGUICommand.cxx +++ b/kernel/src/bbtkWxGUICommand.cxx @@ -164,7 +164,13 @@ namespace bbtk std::string stdDir = default_doc_dir+"/share/bbtk/bbs"; wxString defaultDir(stdDir.c_str(), wxConvUTF8); +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 wxFileDialog dialog(this, _T("Include file"),defaultDir, _T(""), _T("*.bbs"), wxOPEN ); +#else + wxFileDialog dialog(this, _T("Include file"),defaultDir, _T(""), _T("*.bbs"), wxFD_OPEN ); +#endif + if (dialog.ShowModal() == wxID_OK) { // std::string command(_T("include ")); diff --git a/kernel/src/bbtkWxGUITextEditor.cxx b/kernel/src/bbtkWxGUITextEditor.cxx index 5f3aea8..3ab49d0 100644 --- a/kernel/src/bbtkWxGUITextEditor.cxx +++ b/kernel/src/bbtkWxGUITextEditor.cxx @@ -227,9 +227,18 @@ namespace bbtk // std::cout << "-------------- SAVE ---------------"<ShowModal(); // This line is need it by windows // EED @@ -530,9 +539,16 @@ namespace bbtk { // std::cout << "-------------- OPEN ---------------"<ShowModal(); // This line is need it by windows //EED diff --git a/packages/wx/src/bbwxFileSelector.cxx b/packages/wx/src/bbwxFileSelector.cxx index 4757485..c216cdd 100644 --- a/packages/wx/src/bbwxFileSelector.cxx +++ b/packages/wx/src/bbwxFileSelector.cxx @@ -80,11 +80,21 @@ namespace bbwx long style; if (bbGetInputOpenSave()=="Save") { +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 style = wxSAVE | wxOVERWRITE_PROMPT; - } - else - { +#else + style = wxFD_SAVE | wxFD_OVERWRITE_PROMPT; +#endif + } else { + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 style = wxOPEN | wxFILE_MUST_EXIST; +#else + style = wxFD_OPEN | wxFD_FILE_MUST_EXIST; +#endif + } std::string wc(bbGetInputWildcard()); diff --git a/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx b/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx index ea44bbb..7668c98 100644 --- a/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx +++ b/packages/wxvtk/src/wxVTKRenderWindowInteractor.cxx @@ -85,23 +85,34 @@ wxWindow* wxGetTopLevelParent(wxWindow *win) #endif //VTK_USE_COCOA #endif //__WXCOCOA__ -#ifdef __WXGTK__ -# include // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0 -# include "gdk/gdkprivate.h" -#if wxCHECK_VERSION(2, 8, 0) -#ifdef __WXGTK20__ -#include -#else -#include -#endif + +//EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 +#if wxMAJOR_VERSION <= 2 + #ifdef __WXGTK__ + #include // GDK_WINDOW_XWINDOW is found here in wxWidgets 2.8.0 + #include "gdk/gdkprivate.h" + #if wxCHECK_VERSION(2, 8, 0) + #ifdef __WXGTK20__ + #include + #else + #include + #endif + #else + #include + #endif + #define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \ + GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \ + GDK_WINDOW_XWINDOW((wxwin)->m_widget->window) + #endif #else -#include -#endif -#define GetXWindow(wxwin) (wxwin)->m_wxwindow ? \ - GDK_WINDOW_XWINDOW(GTK_PIZZA((wxwin)->m_wxwindow)->bin_window) : \ - GDK_WINDOW_XWINDOW((wxwin)->m_widget->window) + #ifdef __WXGTK__ + #include + #include + #endif #endif + + #ifdef __WXX11__ #include "wx/x11/privx.h" #define GetXWindow(wxwin) ((Window)(wxwin)->GetHandle()) @@ -374,7 +385,15 @@ long wxVTKRenderWindowInteractor::GetHandleHack() // Find and return the actual X-Window. #if defined(__WXGTK__) || defined(__WXX11__) - return (long)GetXWindow(this); + + //EED 2017-09-16 Migration wxWidgets 2.8 to 3.0 + #if wxMAJOR_VERSION <= 2 + return (long)GetXWindow(this); + #else + GdkWindow* Win = gtk_widget_get_window( (GtkWidget *) GetHandle() ); + return (long int)GDK_WINDOW_XDISPLAY(Win); + #endif + #endif //#ifdef __WXMOTIF__ -- 2.47.1