inline wxColour& GetBackgroundColour(void) { return backgroundColour; }
void SetBackgroundColour(const wxColour& colour);
inline wxBrush *GetBackgroundBrush(void) { return backgroundBrush; }
+ inline void SetBackgroundBrush(wxBrush *brush) { backgroundBrush = brush; }
inline int GetAlignment(void) { return alignment; }
inline void SetAlignment(int align) { alignment = align; }
inline wxBitmap *GetCellBitmap(void) { return cellBitmap; }
wxList children;
wxObjectStreamInfo *parent;
wxObject *object;
+ bool duplicate;
};
class wxObjectOutputStream : public wxFilterOutputStream {
int m_stage;
bool m_saving;
wxObjectStreamInfo *m_current_info;
+ wxList m_saved_objs;
};
class wxObjectInputStream : public wxFilterInputStream {
wxObjectInputStream(wxInputStream& s);
wxObject *GetChild(int no) const;
+ wxObject *GetChild();
int NumberOfChildren() const { return m_current_info->n_children; }
void RemoveChildren(int nb);
wxObject *GetParent() const;
#define WXOBJ_BEG_LEN 6
#define TAG_EMPTY_OBJECT "NULL"
+#define TAG_DUPLICATE_OBJECT "DUPLIC"
// ----------------------------------------------------------------------------
// wxObjectOutputStream
Write(WXOBJ_BEGIN, WXOBJ_BEG_LEN);
+ if (info.duplicate) {
+ data_s.WriteString(TAG_DUPLICATE_OBJECT);
+ data_s.WriteString(GetObjectName(info.object));
+ return;
+ }
+
if (info.object) {
data_s.WriteString(info.object->GetClassInfo()->GetClassName());
} else {
data_s.WriteString(GetObjectName(info.object));
// I assume an object will not have millions of children
- data_s.Write8(info.children.Number());
+ // Hmmm ... it could have (for example wxGrid)
+ data_s.Write32(info.children.Number());
}
void wxObjectOutputStream::AddChild(wxObject *obj)
return;
info = new wxObjectStreamInfo;
+
+ if (m_saved_objs.Member(obj) != NULL) {
+ info->duplicate = TRUE;
+ } else {
+ info->duplicate = FALSE;
+ m_saved_objs.Append(obj);
+ }
info->n_children = 0;
info->object = obj;
info->parent = m_current_info; // Not useful here.
m_current_info = info;
// First stage: get children of obj
- if (info->object)
+ if (info->object && !info->duplicate)
info->object->StoreObject(*this);
// Prepare and write the sub-entry about the child obj.
m_current_info = info;
- if (info->object)
+ if (info->object && !info->duplicate)
info->object->StoreObject(*this);
while (node) {
ProcessObjectData(&info);
info.children.Clear();
+ m_saved_objs.Clear();
m_saving = FALSE;
return FALSE;
class_name = data_s.ReadString();
- printf("class_name = %s\n", WXSTRINGCAST class_name);
- if (class_name == TAG_EMPTY_OBJECT)
- info->object = NULL;
- else
- info->object = wxCreateDynamicObject( WXSTRINGCAST class_name);
info->object_name = data_s.ReadString();
- printf("object_name = %s\n", WXSTRINGCAST info->object_name);
- info->n_children = data_s.Read8();
info->children_removed = 0;
- printf("n_children = %d\n", info->n_children);
+ if (class_name == TAG_EMPTY_OBJECT)
+ info->object = NULL;
+ else if (class_name == TAG_DUPLICATE_OBJECT) {
+ info->object = SolveName(info->object_name);
+ info->n_children = 0;
+ } else {
+ info->object = wxCreateDynamicObject( WXSTRINGCAST class_name);
+ info->n_children = data_s.Read8();
+ }
return TRUE;
}
void wxObjectInputStream::ProcessObjectData(wxObjectStreamInfo *info)
{
wxNode *node = info->children.First();
- wxObjectStreamInfo *c_info;
m_current_info = info;
#endif
#include <wx/objstrm.h>
#include <wx/datstrm.h>
+#include <wx/list.h>
+#include <wx/hash.h>
#include "sercore.h"
-IMPLEMENT_SERIAL_CLASS(wxList,wxObject)
+IMPLEMENT_SERIAL_CLASS(wxList, wxObject)
+IMPLEMENT_SERIAL_CLASS(wxHashTable, wxObject)
void WXSERIAL(wxList)::StoreObject(wxObjectOutputStream& s)
{
if (list->key_type == wxKEY_INTEGER) {
for (i=0;i<number;i++)
- list->Append( data_s.Read32(), s.GetChild(i) );
+ list->Append( data_s.Read32(), s.GetChild() );
} else {
for (i=0;i<number;i++)
- list->Append( data_s.ReadString(), s.GetChild(i) );
+ list->Append( data_s.ReadString(), s.GetChild() );
}
}
+
+// ----------------------------------------------------------------------------
+
+void WXSERIAL(wxHashTable)::StoreObject(wxObjectOutputStream& s)
+{
+ wxHashTable *table = (wxHashTable *)Object();
+ int i;
+
+ if (s.FirstStage()) {
+ for (i=0;i<table->n;i++)
+ s.AddChild(table->hash_table[i]);
+ return;
+ }
+
+ wxDataOutputStream data_s(s);
+
+ data_s.Write8(table->key_type);
+ data_s.Write32(table->n);
+}
+
+void WXSERIAL(wxHashTable)::LoadObject(wxObjectInputStream& s)
+{
+ wxHashTable *table = (wxHashTable *)Object();
+ wxDataInputStream data_s(s);
+ int i, key, n;
+
+ key = data_s.Read8();
+ n = data_s.Read32();
+
+ table->Create(key, n);
+
+ for (i=0;i<n;i++)
+ table->hash_table[i] = (wxList *)s.GetChild();
+}
#include <wx/serbase.h>
-DECLARE_SERIAL_CLASS(wxList,wxObject)
+DECLARE_SERIAL_CLASS(wxList, wxObject)
+DECLARE_SERIAL_CLASS(wxHashTable, wxObject)
#endif
#include <wx/listbox.h>
#include <wx/notebook.h>
#include <wx/radiobox.h>
+#include <wx/radiobut.h>
#include <wx/stattext.h>
+#include <wx/statbox.h>
#include <wx/combobox.h>
#include <wx/imaglist.h>
#include <wx/objstrm.h>
IMPLEMENT_SERIAL_CLASS(wxListBox, wxControl)
IMPLEMENT_SERIAL_CLASS(wxNotebook, wxControl)
IMPLEMENT_SERIAL_CLASS(wxRadioBox, wxControl)
-
+IMPLEMENT_SERIAL_CLASS(wxRadioButton, wxControl)
IMPLEMENT_SERIAL_CLASS(wxButton, wxControl)
IMPLEMENT_SERIAL_CLASS(wxStaticText, wxControl)
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxButton)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
m_style, *m_validator, m_name);
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxCheckBox)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
chkbox->SetValue(data_s.Read8());
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxSlider)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
slider->SetThumbLength( data_s.Read32() );
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxGauge)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
gauge->SetValue( data_s.Read32() );
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxChoice)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
choice->Append( data_s.ReadString() );
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxListBox)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
listbox->Append( data_s.ReadString() );
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxNotebook)::StoreObject(wxObjectOutputStream& s)
{
wxNotebook *notebook = (wxNotebook *)Object();
int i, pcount;
wxImageList *imaglist;
- imaglist = (wxImageList *)s.GetChild(0);
- s.RemoveChildren(1);
+ imaglist = (wxImageList *)s.GetChild();
WXSERIAL(wxControl)::LoadObject(s);
notebook->SetPageText(i, data_s.ReadString() );
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxRadioBox)::StoreObject(wxObjectOutputStream& s)
{
wxRadioBox *box = (wxRadioBox *)Object();
n_items, items, 0, m_style, *m_validator, m_name);
}
+//-----------------------------------------------------------------------------
+
+void WXSERIAL(wxRadioButton)::StoreObject(wxObjectOutputStream& s)
+{
+ WXSERIAL(wxControl)::StoreObject(s);
+
+ if (s.FirstStage())
+ return;
+
+ wxDataOutputStream data_s(s);
+ data_s.Write8( (char) ((wxRadioButton *)Object())->GetValue() );
+}
+
+void WXSERIAL(wxRadioButton)::LoadObject(wxObjectInputStream& s)
+{
+ wxDataInputStream data_s(s);
+
+ WXSERIAL(wxControl)::LoadObject(s);
+ ((wxRadioButton *)Object())->SetValue( (bool)data_s.Read8() );
+}
+
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxComboBox)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
box->SetValue( data_s.ReadString() );
}
+//-----------------------------------------------------------------------------
+
void WXSERIAL(wxStaticText)::StoreObject(wxObjectOutputStream& s)
{
WXSERIAL(wxControl)::StoreObject(s);
((wxStaticText *)Object())->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y),
wxSize(m_w, m_h), m_style, m_name);
}
+
+//-----------------------------------------------------------------------------
+
+void WXSERIAL(wxStaticBox)::StoreObject(wxObjectOutputStream& s)
+{
+ WXSERIAL(wxControl)::StoreObject(s);
+}
+
+void WXSERIAL(wxStaticBox)::LoadObject(wxObjectInputStream& s)
+{
+ WXSERIAL(wxControl)::LoadObject(s);
+
+ ((wxStaticBox *)Object())->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y),
+ wxSize(m_w, m_h), m_style, m_name);
+}
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)
#endif
#pragma implementation "serext.h"
#endif
+#include "serext.h"
+#include <wx/wx.h>
#include <wx/splitter.h>
+#include <wx/grid.h>
#include <wx/objstrm.h>
#include <wx/datstrm.h>
-#include "serext.h"
IMPLEMENT_SERIAL_CLASS(wxSplitterWindow, wxWindow)
+IMPLEMENT_SERIAL_CLASS(wxGridCell, wxObject)
+IMPLEMENT_SERIAL_CLASS(wxGrid, wxPanel)
void WXSERIAL(wxSplitterWindow)::StoreObject(wxObjectOutputStream& s)
{
splitter->SetBorderSize(border_size);
splitter->SetMinimumPaneSize(min_pane_size);
}
+
+void WXSERIAL(wxGridCell)::StoreObject(wxObjectOutputStream& s)
+{
+ wxGridCell *cell = (wxGridCell *)Object();
+ wxDataOutputStream data_s(s);
+
+ if (s.FirstStage()) {
+ s.AddChild( cell->GetFont() );
+ s.AddChild( cell->GetBackgroundBrush() );
+ s.AddChild( cell->GetCellBitmap() );
+ s.AddChild( &(cell->GetTextColour()) );
+ s.AddChild( &(cell->GetBackgroundColour()) );
+ return;
+ }
+
+ data_s.WriteString( cell->GetTextValue() );
+ data_s.Write16( cell->GetAlignment() );
+}
+
+void WXSERIAL(wxGridCell)::LoadObject(wxObjectInputStream& s)
+{
+ wxGridCell *cell = (wxGridCell *)Object();
+ wxDataInputStream data_s(s);
+
+ cell->SetTextValue( data_s.ReadString() );
+ cell->SetAlignment( data_s.Read16() );
+ cell->SetFont( (wxFont *)s.GetChild() );
+ cell->SetBackgroundBrush( (wxBrush *)s.GetChild() );
+ cell->SetCellBitmap( (wxBitmap *)s.GetChild() );
+ cell->SetTextColour( *((wxColour *)s.GetChild()) );
+ cell->SetBackgroundColour( *((wxColour *)s.GetChild()) );
+}
+
+void WXSERIAL(wxGrid)::StoreObject(wxObjectOutputStream& s)
+{
+ wxDataOutputStream data_s(s);
+ wxGrid *grid = (wxGrid *)Object();
+ int n_rows = grid->GetRows(), n_cols = grid->GetCols();
+ int r, c;
+
+ if (s.FirstStage()) {
+ for (r=0;r<n_rows;r++)
+ for (c=0;c<n_cols;c++)
+ s.AddChild( grid->GetCell(r, c) );
+
+ s.AddChild( grid->GetDividerPen() );
+ WXSERIAL(wxPanel)::StoreObject(s);
+ return;
+ }
+
+ data_s.Write16( n_rows );
+ data_s.Write16( n_cols );
+ data_s.Write16( grid->GetCursorRow() );
+ data_s.Write16( grid->GetCursorColumn() );
+
+ WXSERIAL(wxPanel)::StoreObject(s);
+}
+
+void WXSERIAL(wxGrid)::LoadObject(wxObjectInputStream& s)
+{
+ WXSERIAL(wxPanel)::LoadObject(s);
+}
#include "serwnd.h"
DECLARE_SERIAL_CLASS(wxSplitterWindow, wxWindow)
+DECLARE_SERIAL_CLASS(wxGrid, wxPanel)
+DECLARE_SERIAL_CLASS(wxGridCell, wxObject)
#endif
void WXSERIAL(wxPen)::LoadObject(wxObjectInputStream& s)
{
wxPen *pen = (wxPen *)Object();
- wxColour *col = (wxColour *) s.GetChild(0);
-
- s.RemoveChildren(1);
+ wxColour *col = (wxColour *) s.GetChild();
WXSERIAL(wxGDIObject)::LoadObject(s);
void WXSERIAL(wxBrush)::LoadObject(wxObjectInputStream& s)
{
wxBrush *brush = (wxBrush *)Object();
- wxColour *col = (wxColour *)s.GetChild(0);
- wxBitmap *bmap = (wxBitmap *)s.GetChild(1);
-
- s.RemoveChildren(2);
+ wxColour *col = (wxColour *)s.GetChild();
+ wxBitmap *bmap = (wxBitmap *)s.GetChild();
WXSERIAL(wxGDIObject)::LoadObject(s);
count = data_s.Read32();
for (i=0;i<count;i++)
- list->Add(*((wxBitmap *)s.GetChild(i)));
+ list->Add(*((wxBitmap *)s.GetChild()));
}
REGISTER_CLASS(wxIndividualLayoutConstraint);
REGISTER_CLASS(wxLayoutConstraints);
REGISTER_CLASS(wxFrame);
-// REGISTER_CLASS(wxPanel);
-// REGISTER_CLASS(wxDialog);
+ REGISTER_CLASS(wxPanel);
+ REGISTER_CLASS(wxDialog);
REGISTER_CLASS(wxMenu);
REGISTER_CLASS(wxMenuItem);
REGISTER_CLASS(wxMenuBar);
REGISTER_CLASS(wxFont);
REGISTER_CLASS(wxPen);
REGISTER_CLASS(wxBrush);
+ REGISTER_CLASS(wxImageList);
REGISTER_CLASS(wxPenList);
REGISTER_CLASS(wxBrushList);
REGISTER_CLASS(wxFontList);
IMPLEMENT_SERIAL_CLASS(wxMenuItem, wxObject)
IMPLEMENT_SERIAL_CLASS(wxMenu, wxObject)
+IMPLEMENT_SERIAL_CLASS(wxMDIParentFrame, wxFrame)
+IMPLEMENT_SERIAL_CLASS(wxMDIChildFrame, wxFrame)
+IMPLEMENT_SERIAL_CLASS(wxMDIClientWindow, wxWindow)
+
/////////////////////////////////////////////////////////////////////////////
void WXSERIAL(wxWindow)::StoreObject(wxObjectOutputStream& s)
/* I assume we will never create raw wxWindow object */
- m_validator = (wxValidator *)s.GetChild(1);
- win_object->SetDefaultBackgroundColour(*((wxColour *)s.GetChild(2)));
- win_object->SetDefaultForegroundColour(*((wxColour *)s.GetChild(3)));
- win_object->SetFont(*((wxFont *)s.GetChild(4)));
+ m_validator = (wxValidator *)s.GetChild();
+ win_object->SetDefaultBackgroundColour(*((wxColour *)s.GetChild()));
+ win_object->SetDefaultForegroundColour(*((wxColour *)s.GetChild()));
+ win_object->SetFont(*((wxFont *)s.GetChild()));
return;
}
wxDataOutputStream data_s(s);
wxStatusBar *statbar = frame->GetStatusBar();
+
+ // AAARGH !! I absolutely need to be able to modify internal fields of
+ // wxFrame (wxToolBar and wxStatusBar)
if (statbar)
data_s.Write8(statbar->GetFieldsCount());
void WXSERIAL(wxFrame)::LoadObject(wxObjectInputStream& s)
{
wxFrame *frame = (wxFrame *)Object();
- wxMenuBar *mbar = (wxMenuBar *)s.GetChild(0);
+ wxMenuBar *mbar = (wxMenuBar *)s.GetChild();
- s.RemoveChildren(1);
WXSERIAL(wxWindow)::LoadObject(s);
wxDataInputStream data_s(s);
mcount = data_s.Read8();
for (i=0;i<mcount;i++) {
- wxMenu *menu = (wxMenu *)s.GetChild(0);
+ wxMenu *menu = (wxMenu *)s.GetChild();
mbar->Append( menu, menu->GetTitle() );
}
void WXSERIAL(wxMenu)::LoadObject(wxObjectInputStream& s)
{
wxMenu *menu = (wxMenu *)Object();
- wxList *items = (wxList *)s.GetChild(0);
+ wxList *items = (wxList *)s.GetChild();
wxNode *node = items->First();
wxDataInputStream data_s(s);
-// menu->SetTitle( data_s.ReadString() );
+ menu->SetTitle( data_s.ReadString() );
while (node) {
// NOT IMPLEMENTED in wxGTK
item->SetCheckable( data_s.Read8() );
item->Enable( data_s.Read8() );
item->Check( data_s.Read8() );
- item->SetSubMenu( (wxMenu *)s.GetChild(0) );
+ item->SetSubMenu( (wxMenu *)s.GetChild() );
}
/////////////////////////////////////////////////////////////////////////////
wxMDIParentFrame *frame = (wxMDIParentFrame *)Object();
wxMDIClientWindow *client;
- client = (wxMDIClientWindow *) s.GetChild(0);
- s.RemoveChildren(1);
+ client = (wxMDIClientWindow *) s.GetChild();
frame->Create(m_parent, m_id, m_title, wxPoint(m_x, m_y),
wxSize(m_w, m_h), m_style, m_name);
-// client->CreateClient(this, style_client);
WXSERIAL(wxFrame)::LoadObject(s);
}
+
+/////////////////////////////////////////////////////////////////////////////
+
+void WXSERIAL(wxMDIChildFrame)::StoreObject(wxObjectOutputStream& s)
+{
+ WXSERIAL(wxFrame)::StoreObject(s);
+}
+
+void WXSERIAL(wxMDIChildFrame)::LoadObject(wxObjectInputStream& s)
+{
+ WXSERIAL(wxFrame)::LoadObject(s);
+
+ ((wxMDIChildFrame *)Object())->Create((wxMDIParentFrame *)m_parent,
+ m_id, m_title,
+ wxPoint(m_x, m_y), wxSize(m_w, m_h),
+ m_style, m_name);
+}
+
+/////////////////////////////////////////////////////////////////////////////
+
+void WXSERIAL(wxMDIClientWindow)::StoreObject(wxObjectOutputStream& s)
+{
+ WXSERIAL(wxWindow)::StoreObject(s);
+}
+
+void WXSERIAL(wxMDIClientWindow)::LoadObject(wxObjectInputStream& s)
+{
+ WXSERIAL(wxWindow)::LoadObject(s);
+
+ ((wxMDIClientWindow *)Object())->CreateClient((wxMDIParentFrame *)m_parent, m_style);
+}
DECLARE_SERIAL_CLASS(wxMenuItem, wxObject)
DECLARE_SERIAL_CLASS(wxMenu, wxObject)
DECLARE_SERIAL_CLASS(wxMDIParentFrame, wxFrame)
+DECLARE_SERIAL_CLASS(wxMDIChildFrame, wxFrame)
+DECLARE_SERIAL_CLASS(wxMDIClientWindow, wxFrame)
#endif