]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/object.cpp
several fixes
[wxWidgets.git] / src / common / object.cpp
index 272e88a21f514df935fe6b40190accfe416371b9..ed1c78b1a7ac5981ca36148e5a05aebe60a6f9ef 100644 (file)
@@ -221,12 +221,57 @@ wxObject *wxCreateDynamicObject(char *name)
 
 #ifdef USE_STORABLE_CLASSES
 
+#include "wx/serbase.h"
+#include "wx/dynlib.h"
+#include "wx/msgdlg.h"
+
 wxObject* wxCreateStoredObject( wxInputStream &stream )
 {
   wxObjectInputStream obj_s(stream);
   return obj_s.LoadObject();
 };
 
+void wxObject::StoreObject( wxObjectOutputStream& stream )
+{
+  wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
+  wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
+  WXSERIAL(wxObject) *serial =
+                           (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
+
+  if (!serial) {
+    wxString message;
+
+    message.Printf("Can't find the serialization object (%s) for the object %s",
+                   WXSTRINGCAST obj_name,                                                          WXSTRINGCAST GetClassInfo()->GetClassName());
+    wxMessageBox(message, "Alert !");
+    return;
+  }
+
+  serial->SetObject(this);
+  serial->StoreObject(stream);
+}
+
+void wxObject::LoadObject( wxObjectInputStream& stream )
+{
+  wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
+  wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
+  WXSERIAL(wxObject) *serial =
+                           (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
+
+  if (!serial) {
+    wxString message;
+
+    message.Printf("Can't find the serialization object (%s) for the object %s",
+                   WXSTRINGCAST obj_name,
+                   WXSTRINGCAST GetClassInfo()->GetClassName());
+    wxMessageBox(message, "Alert !");
+    return;
+  }
+
+  serial->SetObject(this);
+  serial->LoadObject(stream);
+}
+
 #endif
 
 /*