wxList children;
wxObjectStreamInfo *parent;
wxObject *object;
- bool duplicate;
+ bool duplicate, recall;
};
class wxObjectOutputStream : public wxFilterOutputStream {
public:
wxObjectInputStream(wxInputStream& s);
+ bool SecondCall() const { return m_secondcall; }
+ void Recall(bool on = TRUE) { m_current_info->recall = on; }
+
wxObject *GetChild(int no) const;
wxObject *GetChild();
int NumberOfChildren() const { return m_current_info->n_children; }
void ProcessObjectData(wxObjectStreamInfo *info);
protected:
+ bool m_secondcall;
wxObjectStreamInfo *m_current_info;
wxList m_solver;
};
AC_CHECK_LIB(pthread-0.7, pthread_create, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthread-0.7"
- AC_DEFINE(USE_THREADS)
],[
AC_CHECK_HEADER(sys/prctl.h, [
UNIX_THREAD="gtk/threadsgi.cpp"
- AC_DEFINE(USE_THREADS)
])
- AC_CHECK_LIB(pthread, pthread_create, [
+
+ dnl pthread_create is always available in pthread but it seems not to be
+ dnl the case for pthread_setcanceltype.
+
+ AC_CHECK_LIB(pthread, pthread_setcanceltype, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthread"
- AC_DEFINE(USE_THREADS)
])
])
- AC_CHECK_LIB(pthreads, pthread_create, [
+ AC_CHECK_LIB(pthreads, pthread_setcanceltype, [
UNIX_THREAD="gtk/threadpsx.cpp"
THREADS_LINK="-lpthreads"
- AC_DEFINE(USE_THREADS)
])
fi
+if test -z "$UNIX_THREAD"; then
+ USE_THREADS=0
+fi
+
AC_SUBST(UNIX_THREAD)
AC_SUBST(THREADS_LINK)
+AC_DEFINE(USE_THREADS)
dnl defines UNIX_THREAD it contains the source file to use for threads. (GL)
dnl defines THREADS_LINK it contains the thread library to link with. (GL)
return ((wxLibrary *)node->Data());
#ifdef __UNIX__
- lib_name.Prepend("lib");
+ lib_name.Prepend("./lib");
lib_name += ".so";
printf("lib_name = %s\n", WXSTRINGCAST lib_name);
{
wxString obj_name = wxString(GetClassInfo()->GetClassName()) + "_Serialize";
wxLibrary *lib = wxTheLibraries.LoadLibrary("wxserial");
- WXSERIAL(wxObject) *serial =
- (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
+ WXSERIAL(wxObject) *serial;
+
+ if (!lib) {
+ wxMessageBox("Can't load wxSerial dynamic library.", "Alert !");
+ return;
+ }
+ serial = (WXSERIAL(wxObject) *)lib->CreateObject( obj_name );
if (!serial) {
wxString message;
data_s.WriteString(info.object->GetClassInfo()->GetClassName());
} else {
data_s.WriteString(TAG_EMPTY_OBJECT);
+ return;
}
data_s.WriteString(GetObjectName(info.object));
info->duplicate = FALSE;
m_saved_objs.Append(obj);
}
+ if (!obj)
+ info->duplicate = FALSE;
+
info->n_children = 0;
info->object = obj;
info->parent = m_current_info; // Not useful here.
m_stage = 0;
info.object = &obj;
info.n_children = 0;
+ info.duplicate = FALSE;
ProcessObjectDef(&info);
m_stage = 1;
return m_current_info->parent->object;
}
+wxObject *wxObjectInputStream::GetChild()
+{
+ wxObject *obj = GetChild(0);
+
+ m_current_info->children_removed++;
+
+ return obj;
+}
+
wxObject *wxObjectInputStream::GetChild(int no) const
{
- wxNode *node = m_current_info->children.Nth(m_current_info->children_removed+no);
+ wxNode *node;
wxObjectStreamInfo *info;
+ if (m_current_info->children_removed >= m_current_info->n_children)
+ return NULL;
+
+ node = m_current_info->children.Nth(m_current_info->children_removed+no);
+
if (!node)
return (wxObject *) NULL;
return FALSE;
class_name = data_s.ReadString();
- info->object_name = data_s.ReadString();
info->children_removed = 0;
if (class_name == TAG_EMPTY_OBJECT)
info->object = (wxObject *) NULL;
else if (class_name == TAG_DUPLICATE_OBJECT) {
+ info->object_name = data_s.ReadString();
info->object = SolveName(info->object_name);
info->n_children = 0;
} else {
+ info->object_name = data_s.ReadString();
info->object = wxCreateDynamicObject( WXSTRINGCAST class_name);
- info->n_children = data_s.Read8();
+ info->n_children = data_s.Read32();
}
return TRUE;
}
ProcessObjectData((wxObjectStreamInfo *)node->Data());
node = node->Next();
}
+
+ m_current_info = info;
+
+ if (info->recall) {
+ m_secondcall = TRUE;
+ info->object->LoadObject(*this);
+ m_secondcall = FALSE;
+ }
}
wxObject *wxObjectInputStream::LoadObject()
IMPLEMENT_SERIAL_CLASS(wxRadioButton, wxControl)
IMPLEMENT_SERIAL_CLASS(wxButton, wxControl)
IMPLEMENT_SERIAL_CLASS(wxStaticText, wxControl)
+IMPLEMENT_SERIAL_CLASS(wxStaticBox, wxControl)
//-----------------------------------------------------------------------------
wxImageList *imaglist = notebook->GetImageList();
int i, pcount = notebook->GetPageCount();
+ WXSERIAL(wxControl)::StoreObject(s);
if (s.FirstStage()) {
s.AddChild(imaglist);
- WXSERIAL(wxControl)::StoreObject(s);
return;
}
wxDataOutputStream data_s(s);
data_s.Write8( pcount );
- WXSERIAL(wxControl)::StoreObject(s);
for (i=0;i<pcount;i++)
data_s.WriteString( notebook->GetPageText(i) );
-
}
void WXSERIAL(wxNotebook)::LoadObject(wxObjectInputStream& s)
{
wxNotebook *notebook = (wxNotebook *)Object();
- int i, pcount;
+ int i;
wxImageList *imaglist;
- imaglist = (wxImageList *)s.GetChild();
+ if (s.SecondCall()) {
+ for (i=0;i<m_pcount;i++)
+ notebook->AddPage( (wxWindow *)s.GetChild(), m_stringlist[i] );
+ return;
+ }
WXSERIAL(wxControl)::LoadObject(s);
+ imaglist = (wxImageList *)s.GetChild();
+
notebook->Create(m_parent, m_id, wxPoint(m_x, m_y), wxSize(m_w, m_h),
m_style, m_name);
wxDataInputStream data_s(s);
- pcount = data_s.Read8();
- for (i=0;i<pcount;i++)
- notebook->SetPageText(i, data_s.ReadString() );
+ m_pcount = data_s.Read8();
+ for (i=0;i<m_pcount;i++)
+ m_stringlist.Add(data_s.ReadString());
+ s.Recall();
}
//-----------------------------------------------------------------------------
DECLARE_SERIAL_CLASS(wxComboBox, wxControl)
DECLARE_SERIAL_CLASS(wxGauge, wxControl)
DECLARE_SERIAL_CLASS(wxListBox, wxControl)
-DECLARE_SERIAL_CLASS(wxNotebook, wxControl)
DECLARE_SERIAL_CLASS(wxRadioBox, wxControl)
DECLARE_SERIAL_CLASS(wxRadioButton, wxControl)
DECLARE_SERIAL_CLASS(wxStaticText, wxControl)
DECLARE_SERIAL_CLASS(wxStaticBox, wxControl)
+
+class WXSERIAL(wxNotebook) : public WXSERIAL(wxControl) {
+ DECLARE_DYNAMIC_CLASS( wxNotebook_Serialize )
+public:
+ void StoreObject(wxObjectOutputStream& s);
+ void LoadObject(wxObjectInputStream& s);
+
+protected:
+ int m_pcount;
+ wxArrayString m_stringlist;
+};
+
#endif
#include <wx/brush.h>
#include <wx/serbase.h>
#include <wx/imaglist.h>
+#include <wx/region.h>
+#include <wx/colour.h>
+#include <wx/palette.h>
+#include <wx/dcmemory.h>
#include "sergdi.h"
IMPLEMENT_SERIAL_CLASS(wxBitmap, wxObject)
IMPLEMENT_SERIAL_CLASS(wxGDIObject, wxObject)
+IMPLEMENT_SERIAL_CLASS(wxRegion, wxGDIObject)
IMPLEMENT_SERIAL_CLASS(wxColour, wxGDIObject)
IMPLEMENT_SERIAL_CLASS(wxFont, wxGDIObject)
IMPLEMENT_SERIAL_CLASS(wxPen, wxGDIObject)
IMPLEMENT_ALIAS_SERIAL_CLASS(wxColourDatabase, wxList)
IMPLEMENT_ALIAS_SERIAL_CLASS(wxBitmapList, wxList)
+// ----------------------------------------------------------------------------
+
void WXSERIAL(wxBitmap)::StoreObject(wxObjectOutputStream& s)
{
// TODO
+ // I implemented a basic image saving (maybe I'll need to improve wxWin API).
+
+ int x, y, w, h;
+ wxDataOutputStream data_s(s);
+ wxBitmap *bitmap = (wxBitmap *)Object();
+ wxColour col;
+ wxMemoryDC dc;
+
+ w = bitmap->GetWidth();
+ h = bitmap->GetHeight();
+
+ if (s.FirstStage()) {
+ s.AddChild(bitmap->GetMask());
+ }
+
+ dc.SelectObject(*bitmap);
+
+ data_s.Write16(w);
+ data_s.Write16(h);
+ for (y=0;y<h;y++)
+ for (x=0;x<w;x++) {
+ dc.GetPixel(x, y, &col);
+ data_s.Write8( col.Red() );
+ data_s.Write8( col.Green() );
+ data_s.Write8( col.Blue() );
+ }
}
void WXSERIAL(wxBitmap)::LoadObject(wxObjectInputStream& s)
{
// TODO
+ // I implemented a basic image loading (maybe I'll need to improve wxWin API).
+ wxDataInputStream data_s(s);
+ wxBitmap *bitmap = (wxBitmap *)Object();
+ wxMemoryDC dc;
+ wxPen pen;
+ int x, y, w, h;
+ int r, g, b;
+
+ w = data_s.Read16();
+ h = data_s.Read16();
+
+ bitmap->Resize(w, h);
+ dc.SelectObject(*bitmap);
+
+ for (y=0;y<h;y++)
+ for (x=0;x<w;x++) {
+ r = data_s.Read8();
+ g = data_s.Read8();
+ b = data_s.Read8();
+ pen.SetColour(r, g, b);
+ dc.SetPen(pen);
+ dc.DrawPoint(x,y);
+ }
}
+// ----------------------------------------------------------------------------
+
void WXSERIAL(wxGDIObject)::StoreObject(wxObjectOutputStream& s)
{
if (s.FirstStage())
((wxGDIObject *)Object())->SetVisible( data_s.Read8() );
}
+// ----------------------------------------------------------------------------
+
+void WXSERIAL(wxRegion)::StoreObject(wxObjectOutputStream& s)
+{
+ WXSERIAL(wxGDIObject)::StoreObject(s);
+
+ if (s.FirstStage())
+ return;
+
+ wxDataOutputStream data_s(s);
+ wxRect rect = ((wxRegion *)Object())->GetBox();
+
+ data_s.Write16( rect.GetX() );
+ data_s.Write16( rect.GetY() );
+ data_s.Write16( rect.GetWidth() );
+ data_s.Write16( rect.GetHeight() );
+}
+
+void WXSERIAL(wxRegion)::LoadObject(wxObjectInputStream& s)
+{
+ WXSERIAL(wxGDIObject)::LoadObject(s);
+
+ wxDataInputStream data_s(s);
+ wxRegion *region = (wxRegion *)Object();
+ wxRect rect;
+
+ rect.SetX( data_s.Read16() );
+ rect.SetY( data_s.Read16() );
+ rect.SetWidth( data_s.Read16() );
+ rect.SetHeight( data_s.Read16() );
+
+ *region = wxRegion(rect);
+}
+
+// ----------------------------------------------------------------------------
+
void WXSERIAL(wxColour)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxGDIObject)::StoreObject(s);
colour->Set(r, g, b);
}
+// ----------------------------------------------------------------------------
+
void WXSERIAL(wxPen)::StoreObject(wxObjectOutputStream& s)
{
wxPen *pen = (wxPen *)Object();
pen->SetWidth( data_s.Read8() );
}
+// ----------------------------------------------------------------------------
void WXSERIAL(wxBrush)::StoreObject(wxObjectOutputStream& s)
{
wxBrush *brush = (wxBrush *)Object();
*brush = wxBrush(bmap);
}
+// ----------------------------------------------------------------------------
void WXSERIAL(wxFont)::StoreObject(wxObjectOutputStream& s)
{
wxFont *font = (wxFont *)Object();
*font = wxFont(psize, face_name, family, style, weight, underlined);
}
+// ----------------------------------------------------------------------------
+
void WXSERIAL(wxImageList)::StoreObject(wxObjectOutputStream& s)
{
wxImageList *list = (wxImageList *)Object();
DECLARE_SERIAL_CLASS(wxBitmap, wxObject)
DECLARE_SERIAL_CLASS(wxGDIObject, wxObject)
+DECLARE_SERIAL_CLASS(wxRegion, wxGDIObject)
DECLARE_SERIAL_CLASS(wxColour, wxGDIObject)
DECLARE_SERIAL_CLASS(wxFont, wxGDIObject)
DECLARE_SERIAL_CLASS(wxPen, wxGDIObject)
DECLARE_SERIAL_CLASS(wxBrush, wxGDIObject)
DECLARE_SERIAL_CLASS(wxImageList, wxObject)
-//DECLARE_SERIAL_CLASS(wxSize, wxObject)
-//DECLARE_SERIAL_CLASS(wxRealPoint, wxObject)
-//DECLARE_SERIAL_CLASS(wxRect, wxObject)
-
DECLARE_ALIAS_SERIAL_CLASS(wxPenList, wxList)
DECLARE_ALIAS_SERIAL_CLASS(wxBrushList, wxList)
DECLARE_ALIAS_SERIAL_CLASS(wxFontList, wxList)
#include "serwnd.h"
#include "sergdi.h"
#include "serctrl.h"
+#include "serext.h"
IMPLEMENT_DYNAMIC_CLASS(wxObject_Serialize, wxObject)
REGISTER_CLASS(wxMenu);
REGISTER_CLASS(wxMenuItem);
REGISTER_CLASS(wxMenuBar);
+ REGISTER_CLASS(wxMDIParentFrame);
+ REGISTER_CLASS(wxMDIChildFrame);
+ REGISTER_CLASS(wxMDIClientWindow);
REGISTER_CLASS(wxGDIObject);
REGISTER_CLASS(wxBitmap);
+ REGISTER_CLASS(wxRegion);
REGISTER_CLASS(wxColour);
REGISTER_CLASS(wxFont);
REGISTER_CLASS(wxPen);
REGISTER_CLASS(wxFontList);
REGISTER_CLASS(wxColourDatabase);
REGISTER_CLASS(wxBitmapList);
+ REGISTER_CLASS(wxImageList);
REGISTER_CLASS(wxControl);
REGISTER_CLASS(wxSlider);
REGISTER_CLASS(wxListBox);
REGISTER_CLASS(wxButton);
REGISTER_CLASS(wxStaticText);
+ REGISTER_CLASS(wxStaticBox);
REGISTER_CLASS(wxRadioBox);
REGISTER_CLASS(wxComboBox);
REGISTER_CLASS(wxNotebook);
+ REGISTER_CLASS(wxSplitterWindow);
+ REGISTER_CLASS(wxGrid);
+ REGISTER_CLASS(wxGridCell);
+
return lib;
}
#include <wx/serbase.h>
#include <wx/statusbr.h>
#include <wx/mdi.h>
+#include "wx/log.h"
#include "serwnd.h"
void WXSERIAL(wxWindow)::StoreObject(wxObjectOutputStream& s)
{
wxWindow *win_object = (wxWindow *)Object();
- wxNode *node = win_object->GetChildren()->First();
if (s.FirstStage()) {
+ wxNode *node = win_object->GetChildren()->First();
+
s.AddChild(win_object->GetConstraints());
s.AddChild(win_object->GetValidator());
wxDataOutputStream data(s);
int x,y,w,h;
- data.WriteString(win_object->GetName());
- data.WriteString(win_object->GetLabel());
- data.WriteString(win_object->GetTitle());
+ data.WriteString( win_object->GetName() );
+ data.WriteString( win_object->GetLabel() );
+ data.WriteString( win_object->GetTitle() );
- data.Write8(win_object->GetAutoLayout());
- data.Write8(win_object->IsShown());
+ data.Write8( win_object->GetAutoLayout() );
+ data.Write8( win_object->IsShown() );
data.Write32( win_object->GetWindowStyleFlag() );
- data.Write32(win_object->GetId());
+ data.Write32( win_object->GetId() );
+ wxLogDebug( "Number = %d", win_object->GetChildren()->Number() );
+ data.Write8( win_object->GetChildren()->Number() );
win_object->GetSize(&w, &h);
win_object->GetPosition(&x, &y);
{
wxDataInputStream data_s(s);
wxWindow *win_object = (wxWindow *)Object();
+ wxColour *colour;
+ wxFont *font;
+ int number;
m_parent = (wxWindow *)s.GetParent();
m_shown = data_s.Read8();
m_style = data_s.Read32();
m_id = data_s.Read32();
+ number = data_s.Read8();
m_x = data_s.Read16();
m_y = data_s.Read16();
m_h = data_s.Read16();
/* I assume we will never create raw wxWindow object */
-
+ (void)s.GetChild(); // We pass wxLayoutConstraints.
+
m_validator = (wxValidator *)s.GetChild();
- win_object->SetDefaultBackgroundColour(*((wxColour *)s.GetChild()));
- win_object->SetDefaultForegroundColour(*((wxColour *)s.GetChild()));
- win_object->SetFont(*((wxFont *)s.GetChild()));
+ if (!m_validator)
+ m_validator = (wxValidator *)&wxDefaultValidator;
+
+ colour = (wxColour *)s.GetChild();
+ if (colour)
+ win_object->SetDefaultBackgroundColour(*colour);
+ colour = (wxColour *)s.GetChild();
+ if (colour)
+ win_object->SetDefaultForegroundColour(*colour);
+ font = (wxFont *)s.GetChild();
+ if (font)
+ win_object->SetFont(*font);
+
+ s.RemoveChildren(number);
return;
}