2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
8 # This software is governed by the CeCILL-B license under French law and
9 # abiding by the rules of distribution of free software. You can use,
10 # modify and/ or redistribute the software under the terms of the CeCILL-B
11 # license as circulated by CEA, CNRS and INRIA at the following URL
12 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
13 # or in the file LICENSE.txt.
15 # As a counterpart to the access to the source code and rights to copy,
16 # modify and redistribute granted by the license, users are provided only
17 # with a limited warranty and the software's author, the holder of the
18 # economic rights, and the successive licensors have only limited
21 # The fact that you are presently reading this means that you have had
22 # knowledge of the CeCILL-B license and that you accept its terms.
23 # ------------------------------------------------------------------------ */
26 #ifndef __creaWx_h__INCLUDED__
27 #define __creaWx_h__INCLUDED__
29 //===========================================================================
32 // For compilers that support precompilation, includes "wx/wx.h".
33 #include "wx/wxprec.h"
34 #include <wx/datetime.h>
48 //===========================================================================
49 #else // USE_WXWIDGETS
50 // define wxWindow as void hence wxWindow* are void*
51 typedef void wxWindow;
52 #endif // EO USE_WXWIDGETS
53 //===========================================================================
55 //===========================================================================
60 // How to have a Console and wxWidgets
61 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
62 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
63 // (cout's to the console are visible) and has a wxWidgets GUI,
64 // you need to use the linker option "/subsystem:console" and the following code:
66 #define CREA_WXMAIN_WITH_CONSOLE \
67 int main(int argc, char* argv[]) \
69 return WinMain(::GetModuleHandle(NULL), NULL, \
70 ::GetCommandLine(), SW_SHOWNORMAL); \
73 #else // defined(_WIN32)
75 #define CREA_WXMAIN_WITH_CONSOLE
77 #endif // defined(_WIN32)
83 //==================================================================
84 /// Conversion std::string to wxString
85 inline wxString std2wx(const std::string& s) {
87 const char* my_string=s.c_str();
88 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
89 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
91 // test if conversion works of not. In case it fails convert from Ascii
93 wx=wxString(wxString::FromAscii(s.c_str()));
96 //==================================================================
98 //==================================================================
99 /// Conversion wxString to std::string
100 inline std::string wx2std(const wxString& s){
102 if(s.wxString::IsAscii()) {
103 s2=s.wxString::ToAscii();
105 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
106 const char *tmp_str = (const char*) tmp_buf;
107 s2=std::string(tmp_str, strlen(tmp_str));
111 //==================================================================
114 #endif // EO USE_WXWIDGETS