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"
34 // SIGNAL/SLOT MECHANISM
35 // FOR bbtk WINDOWS CREATION/DESTRUCTION OBSERVATION
37 #include <boost/signal.hpp>
38 #include <boost/bind.hpp>
43 //==================================================================
44 /// Global wx handlers (cursor...)
47 #define bbtkAddWxSignalObserver(METHOD) \
48 Wx::AddSignalObserver(boost::bind(&METHOD, this))
55 typedef boost::signals::trackable SignalObserver;
56 typedef boost::signal<void ()> Signal_type;
57 typedef Signal_type::slot_function_type Slot_function_type;
60 static void ResetCursor();
61 static void BeginBusyCursor();
62 static void EndBusyCursor();
64 static void CreateTopWindow(wxWindow* parent=0, bool autodestroy=true);
65 /// Returns the creation time parent of all bbtk windows
66 /// (window can be reparented after creation)
67 static wxWindow* GetTopWindow();
68 static bool TopWindowExists();
70 static void AutoDestroyTopWindow(bool);
72 static void IncNbWindowsAlive();
73 static void DecNbWindowsAlive();
74 static int GetNbWindowsAlive();
75 static bool IsSomeWindowAlive();
77 static void IncNbWindowsShown();
78 static void DecNbWindowsShown();
79 static int GetNbWindowsShown();
80 static bool IsSomeWindowShown();
83 static void AddSignalObserver(Slot_function_type);
86 /// Sets the creation time parent of all bbtk windows
87 static void SetTopWindow(wxWindow*);
89 //==================================================================
93 //==================================================================
94 /// Conversion std::string to wxString
95 inline wxString std2wx(const std::string& s){
97 const char* my_string=s.c_str();
98 wxMBConvUTF8 *wxconv= new wxMBConvUTF8();
99 wx=wxString(wxconv->cMB2WC(my_string),wxConvUTF8);
101 // test if conversion works of not. In case it fails convert from Ascii
103 wx=wxString(wxString::FromAscii(s.c_str()));
106 //==================================================================
108 //==================================================================
109 /// Conversion wxString to std::string
110 inline std::string wx2std(const wxString& s){
112 if(s.wxString::IsAscii()) {
113 s2=s.wxString::ToAscii();
115 const wxWX2MBbuf tmp_buf = wxConvCurrent->cWX2MB(s);
116 const char *tmp_str = (const char*) tmp_buf;
117 s2=std::string(tmp_str, strlen(tmp_str));
121 //==================================================================
129 #else // _USE_WXWIDGETS
135 struct BBTK_EXPORT Wx
137 static void ResetCursor() {}
138 static void BeginBusyCursor() {}
139 static void EndBusyCursor() {}
140 static void CreateInvisibleTopWindow() {}
141 static wxWindow* GetTopWindow() { return 0; }
142 static void SetTopWindow(wxWindow*) {}
143 static void IncNbWindowsAlive() {}
144 static void DecNbWindowsAlive() {}
145 static int GetNbWindowsAlive() { return 0; }
146 static bool IsSomeWindowAlive() { return false; }
148 static void IncNbWindowsShown() {}
149 static void DecNbWindowsShown() {}
150 static int GetNbWindowsShown() { return 0; }
151 static bool IsSomeWindowShown() { return false; }
158 #endif // EO _USE_WXWIDGETS
159 #endif // EO __bbtkWx_h_INCLUDED__