1 #ifndef __bbtkWx_h_INCLUDED__
2 #define __bbtkWx_h_INCLUDED__
6 #ifdef wxUSE_STD_IOSTREAM
7 #undef wxUSE_STD_IOSTREAM
9 #define wxUSE_STD_IOSTREAM 0
13 #ifdef _USE_WXWIDGETS_
14 // For compilers that support precompilation, includes "wx/wx.h".
15 #include "wx/wxprec.h"
16 #include <wx/datetime.h>
32 #include "bbtkSystem.h"
36 //==================================================================
37 /// Global wx handlers (cursor...)
42 static void ResetCursor();
43 static void BeginBusyCursor();
44 static void EndBusyCursor();
45 static int mBeginBusyCallsCount;
47 /// Returns the global parent of all bbtk windows
48 static wxWindow* GetTopWindow() { return mgTopWindow; }
49 /// Sets the global parent of all bbtk windows
50 static void SetTopWindow(wxWindow*);
52 static void IncNbWindowsAlive() { mgNbWindowsAlive++; }
53 static void DecNbWindowsAlive();
54 static int GetNbWindowsAlive() { return mgNbWindowsAlive; }
55 static bool IsSomeWindowAlive() { return (mgNbWindowsAlive>0);}
57 static void IncNbWindowsShown() { mgNbWindowsShown++; }
58 static void DecNbWindowsShown();
59 static int GetNbWindowsShown() { return mgNbWindowsShown; }
60 static bool IsSomeWindowShown() { return (mgNbWindowsShown>0);}
63 static wxWindow* mgTopWindow;
64 static int mgNbWindowsAlive;
65 static int mgNbWindowsShown;
68 //==================================================================
71 //==================================================================
72 /// Conversion std::string to wxString
73 inline wxString std2wx(const std::string& s){
75 const char* my_string=s.c_str();
76 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
77 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
79 // test if conversion works of not. In case it fails convert from Ascii
81 wx=wxString(wxString::FromAscii(s.c_str()));
84 //==================================================================
86 //==================================================================
87 /// Conversion wxString to std::string
88 inline std::string wx2std(const wxString& s){
90 if(s.wxString::IsAscii()) {
91 s2=s.wxString::ToAscii();
93 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
94 const char *tmp_str = (const char*) tmp_buf;
95 s2=std::string(tmp_str, strlen(tmp_str));
99 //==================================================================
107 #else // _USE_WXWIDGETS
113 struct BBTK_EXPORT Wx
115 static void ResetCursor() {}
116 static void BeginBusyCursor() {}
117 static void EndBusyCursor() {}
118 static wxWindow* GetTopWindow() { return 0; }
119 static void SetTopWindow(wxWindow*) {}
120 static void IncNbWindowsAlive() {}
121 static void DecNbWindowsAlive() {}
122 static int GetNbWindowsAlive() { return 0; }
123 static bool IsSomeWindowAlive() { return false; }
125 static void IncNbWindowsShown() {}
126 static void DecNbWindowsShown() {}
127 static int GetNbWindowsShown() { return 0; }
128 static bool IsSomeWindowShown() { return false; }
135 #endif // EO _USE_WXWIDGETS
136 #endif // EO __bbtkWx_h_INCLUDED__