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>
24 //===========================================================================
25 #else // USE_WXWIDGETS
26 // define wxWindow as void hence wxWindow* are void*
27 typedef void wxWindow;
28 #endif // EO USE_WXWIDGETS
29 //===========================================================================
31 //===========================================================================
36 // How to have a Console and wxWidgets
37 // http://www.wxwidgets.org/wiki/index.php/MSVC_Setup_Guide
38 // In Visual C++ 6 (7 should be similar), to create an application that is both a console application
39 // (cout's to the console are visible) and has a wxWidgets GUI,
40 // you need to use the linker option "/subsystem:console" and the following code:
42 #define CREA_WXMAIN_WITH_CONSOLE \
43 int main(int argc, char* argv[]) \
45 return WinMain(::GetModuleHandle(NULL), NULL, \
46 ::GetCommandLine(), SW_SHOWNORMAL); \
49 #else // defined(_WIN32)
51 #define CREA_WXMAIN_WITH_CONSOLE
53 #endif // defined(_WIN32)
59 //==================================================================
60 /// Conversion std::string to wxString
61 inline wxString std2wx(const std::string& s) {
63 const char* my_string=s.c_str();
64 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
65 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
67 // test if conversion works of not. In case it fails convert from Ascii
69 wx=wxString(wxString::FromAscii(s.c_str()));
72 //==================================================================
74 //==================================================================
75 /// Conversion wxString to std::string
76 inline std::string wx2std(const wxString& s){
78 if(s.wxString::IsAscii()) {
79 s2=s.wxString::ToAscii();
81 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
82 const char *tmp_str = (const char*) tmp_buf;
83 s2=std::string(tmp_str, strlen(tmp_str));
87 //==================================================================
90 #endif // EO USE_WXWIDGETS