2 # ---------------------------------------------------------------------
4 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
6 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
7 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
8 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
10 # This software is governed by the CeCILL-B license under French law and
11 # abiding by the rules of distribution of free software. You can use,
12 # modify and/ or redistribute the software under the terms of the CeCILL-B
13 # license as circulated by CEA, CNRS and INRIA at the following URL
14 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
15 # or in the file LICENSE.txt.
17 # As a counterpart to the access to the source code and rights to copy,
18 # modify and redistribute granted by the license, users are provided only
19 # with a limited warranty and the software's author, the holder of the
20 # economic rights, and the successive licensors have only limited
23 # The fact that you are presently reading this means that you have had
24 # knowledge of the CeCILL-B license and that you accept its terms.
25 # ------------------------------------------------------------------------
29 #ifndef __creaWx_h__INCLUDED__
30 #define __creaWx_h__INCLUDED__
32 //===========================================================================
35 // For compilers that support precompilation, includes "wx/wx.h".
36 #include "wx/wxprec.h"
37 #include <wx/datetime.h>
51 //===========================================================================
52 #else // USE_WXWIDGETS
53 // define wxWindow as void hence wxWindow* are void*
54 typedef void wxWindow;
55 #endif // EO USE_WXWIDGETS
56 //===========================================================================
58 //===========================================================================
63 // How to have a Console and wxWidgets
64 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
65 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
66 // (cout's to the console are visible) and has a wxWidgets GUI,
67 // you need to use the linker option "/subsystem:console" and the following code:
69 #define CREA_WXMAIN_WITH_CONSOLE \
70 int main(int argc, char* argv[]) \
72 return WinMain(::GetModuleHandle(NULL), NULL, \
73 ::GetCommandLine(), SW_SHOWNORMAL); \
76 #else // defined(_WIN32)
78 #define CREA_WXMAIN_WITH_CONSOLE
80 #endif // defined(_WIN32)
86 //==================================================================
87 /// Conversion std::string to wxString
88 inline wxString std2wx(const std::string& s) {
90 const char* my_string=s.c_str();
91 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
92 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
94 // test if conversion works of not. In case it fails convert from Ascii
96 wx=wxString(wxString::FromAscii(s.c_str()));
99 //==================================================================
101 //==================================================================
102 /// Conversion wxString to std::string
103 inline std::string wx2std(const wxString& s){
105 if(s.wxString::IsAscii()) {
106 s2=s.wxString::ToAscii();
108 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
109 const char *tmp_str = (const char*) tmp_buf;
110 s2=std::string(tmp_str, strlen(tmp_str));
114 //==================================================================
117 #endif // EO USE_WXWIDGETS