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