]> Creatis software - bbtk.git/blob - kernel/src/bbtkWx.h
Initial revision
[bbtk.git] / kernel / src / bbtkWx.h
1 #ifndef __bbtkWx_h_INCLUDED__
2 #define __bbtkWx_h_INCLUDED__
3
4
5 /*
6 #ifdef wxUSE_STD_IOSTREAM
7 #undef wxUSE_STD_IOSTREAM
8 #endif
9 #define wxUSE_STD_IOSTREAM 0
10 */
11
12 // Wx headers
13 #ifdef _USE_WXWIDGETS_
14 // For compilers that support precompilation, includes "wx/wx.h".
15 #include "wx/wxprec.h"
16 #include <wx/datetime.h>
17
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include <wx/wx.h>
25 #endif
26
27 #ifdef __WXGTK__
28 # include <locale.h>
29 #endif //__WXGTK__
30 // EO Wx headers
31
32 #include "bbtkSystem.h"
33
34 namespace bbtk
35 {
36   //==================================================================
37   /// Global wx handlers (cursor...)
38
39   struct BBTK_EXPORT wx
40    {      public:
41                           static void ResetCursor();
42                           static void BeginBusyCursor(); 
43                           static void EndBusyCursor();
44                           static int mBeginBusyCallsCount;
45                 }; // struct wx
46 //==================================================================
47
48
49   //==================================================================
50   /// Conversion std::string to wxString 
51   inline wxString std2wx(const std::string& s){
52     wxString wx;
53     const char* my_string=s.c_str();
54     wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
55     wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
56     delete wxconv;
57     // test if conversion works of not. In case it fails convert from Ascii
58     if(wx.length()==0)
59       wx=wxString(wxString::FromAscii(s.c_str()));
60     return wx;
61   }
62   //==================================================================
63
64   //==================================================================
65   /// Conversion wxString to std::string
66   inline std::string wx2std(const wxString& s){
67     std::string s2;
68     if(s.wxString::IsAscii()) {
69       s2=s.wxString::ToAscii();
70     } else {
71       const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
72       const char *tmp_str = (const char*) tmp_buf;
73       s2=std::string(tmp_str, strlen(tmp_str));
74     }
75     return s2;
76   }
77   //==================================================================
78
79
80   
81 } // namespace bbtk
82   
83
84
85 #else // _USE_WXWIDGETS
86
87
88 namespace bbtk
89 {
90
91    struct BBTK_EXPORT wx
92         {
93                 static void ResetCursor() {}
94                 static void BeginBusyCursor() {}
95                 static void EndBusyCursor() {}
96         }; // struct wx
97
98 } // namespace bbtk
99   
100
101
102 #endif // EO _USE_WXWIDGETS
103 #endif // EO __bbtkWx_h_INCLUDED__