2 #ifndef __creaWx_h__INCLUDED__
3 #define __creaWx_h__INCLUDED__
5 //===========================================================================
8 // For compilers that support precompilation, includes "wx/wx.h".
10 #include <wx/datetime.h>
25 //===========================================================================
26 #else // USE_WXWIDGETS
27 // define wxWindow as void hence wxWindow* are void*
28 typedef void wxWindow;
29 #endif // EO USE_WXWIDGETS
30 //===========================================================================
37 //===========================================================================
43 // How to have a Console and wxWidgets
44 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
45 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
46 // (cout's to the console are visible) and has a wxWidgets GUI,
47 // you need to use the linker option "/subsystem:console" and the following code:
48 #define CREA_WXMAIN_WITH_CONSOLE \
49 int main(int argc, char* argv[]) \
51 return WinMain(::GetModuleHandle(NULL), NULL, \
52 ::GetCommandLine(), SW_SHOWNORMAL); \
54 #else // defined(_WIN32)
55 #define CREA_WXMAIN_WITH_CONSOLE
56 #endif // defined(_WIN32)
63 //==================================================================
64 /// Conversion std::string to wxString
65 inline wxString std2wx(const std::string& s){
67 const char* my_string=s.c_str();
68 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
69 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
71 // test if conversion works of not. In case it fails convert from Ascii
73 wx=wxString(wxString::FromAscii(s.c_str()));
76 //==================================================================
78 //==================================================================
79 /// Conversion wxString to std::string
80 inline std::string wx2std(const wxString& s){
82 if(s.wxString::IsAscii()) {
83 s2=s.wxString::ToAscii();
85 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
86 const char *tmp_str = (const char*) tmp_buf;
87 s2=std::string(tmp_str, strlen(tmp_str));
91 //==================================================================
96 #endif // EO USE_WXWIDGETS