]> Creatis software - bbtk.git/blob - kernel/src/bbtkWx.h
*** empty log message ***
[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   {     
41   public:
42     static void ResetCursor();
43     static void BeginBusyCursor(); 
44     static void EndBusyCursor();
45     static int mBeginBusyCallsCount;
46
47     static void CreateInvisibleTopWindow(wxWindow* parent=0);
48     /// Returns the global parent of all bbtk windows
49     static wxWindow* GetTopWindow();
50     /// Sets the global parent of all bbtk windows
51     static void SetTopWindow(wxWindow*);
52     
53     static void IncNbWindowsAlive();
54     static void DecNbWindowsAlive();
55     static int  GetNbWindowsAlive();
56     static bool IsSomeWindowAlive();
57     
58     static void IncNbWindowsShown();
59     static void DecNbWindowsShown();
60     static int  GetNbWindowsShown();
61     static bool IsSomeWindowShown();
62     
63 /*EED
64   private:
65     static wxWindow* mgTopWindow;
66     static int mgNbWindowsAlive;
67     static int mgNbWindowsShown;
68 */
69   }; // struct Wx
70   //==================================================================
71   
72
73
74   //==================================================================
75   /// Conversion std::string to wxString 
76   inline wxString std2wx(const std::string& s){
77     wxString wx;
78     const char* my_string=s.c_str();
79     wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
80     wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
81     delete wxconv;
82     // test if conversion works of not. In case it fails convert from Ascii
83     if(wx.length()==0)
84       wx=wxString(wxString::FromAscii(s.c_str()));
85     return wx;
86   }
87   //==================================================================
88
89   //==================================================================
90   /// Conversion wxString to std::string
91   inline std::string wx2std(const wxString& s){
92     std::string s2;
93     if(s.wxString::IsAscii()) {
94       s2=s.wxString::ToAscii();
95     } else {
96       const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
97       const char *tmp_str = (const char*) tmp_buf;
98       s2=std::string(tmp_str, strlen(tmp_str));
99     }
100     return s2;
101   }
102   //==================================================================
103
104
105   
106 } // namespace bbtk
107   
108
109
110 #else // _USE_WXWIDGETS
111
112
113 namespace bbtk
114 {
115
116   struct BBTK_EXPORT Wx
117   {
118     static void ResetCursor() {}
119     static void BeginBusyCursor() {}
120     static void EndBusyCursor() {}
121     static void CreateInvisibleTopWindow() {}
122     static wxWindow* GetTopWindow() { return 0; }
123     static void SetTopWindow(wxWindow*) {}
124     static void IncNbWindowsAlive() {}
125     static void DecNbWindowsAlive() {}
126     static int  GetNbWindowsAlive() { return 0; }
127     static bool IsSomeWindowAlive() { return false; }
128     
129     static void IncNbWindowsShown() {}
130     static void DecNbWindowsShown() {}
131     static int  GetNbWindowsShown() { return 0; }
132     static bool IsSomeWindowShown() { return false; }
133   }; // struct Wx
134
135 } // namespace bbtk
136   
137
138
139 #endif // EO _USE_WXWIDGETS
140 #endif // EO __bbtkWx_h_INCLUDED__