From 21677c36c9ada889b2deadce126d3bad91e77029 Mon Sep 17 00:00:00 2001 From: "J. Russell Smyth" Date: Mon, 5 Apr 1999 23:55:42 +0000 Subject: [PATCH] Removed Persistance Framework code/files from FrameLayout Corrected makefiles to match git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@2046 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- utils/framelayout/samples/demo/fl_demo.cpp | 164 +- utils/framelayout/samples/demo/fl_demo.h | 11 +- utils/framelayout/samples/demo/wxinfo.cpp | 21 - utils/framelayout/samples/demo/wxinfo.h | 6 - .../framelayout/samples/sample/fl_sample.cpp | 61 - utils/framelayout/samples/test/fl_test.cpp | 47 - utils/framelayout/samples/test/fl_test.h | 8 +- utils/framelayout/src/Makefile.in | 3 - utils/framelayout/src/cbstore.cpp | 611 ------ utils/framelayout/src/cbstore.h | 181 -- utils/framelayout/src/makefile.b32 | 8 +- utils/framelayout/src/makefile.g95 | 6 +- utils/framelayout/src/makefile.unx | 6 - utils/framelayout/src/makefile.vc | 6 +- utils/framelayout/src/makefile.wat | 6 +- utils/framelayout/src/objstore.cpp | 1809 ----------------- utils/framelayout/src/objstore.h | 501 ----- utils/framelayout/src/pf_sample.cpp | 286 --- utils/framelayout/src/pf_sample.h | 86 - 19 files changed, 44 insertions(+), 3783 deletions(-) delete mode 100644 utils/framelayout/src/cbstore.cpp delete mode 100644 utils/framelayout/src/cbstore.h delete mode 100644 utils/framelayout/src/objstore.cpp delete mode 100644 utils/framelayout/src/objstore.h delete mode 100644 utils/framelayout/src/pf_sample.cpp delete mode 100644 utils/framelayout/src/pf_sample.h diff --git a/utils/framelayout/samples/demo/fl_demo.cpp b/utils/framelayout/samples/demo/fl_demo.cpp index f42044e9f7..ccea06bdc5 100644 --- a/utils/framelayout/samples/demo/fl_demo.cpp +++ b/utils/framelayout/samples/demo/fl_demo.cpp @@ -43,7 +43,6 @@ #include "barhintspl.h" #include "hintanimpl.h" #include "controlarea.h" -#include "objstore.h" #include "dyntbar.h" #include "dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar @@ -99,8 +98,6 @@ bool MyApp::OnInit(void) wxMenu *file_menu = new wxMenu; wxMenu *active_menu = new wxMenu; - file_menu->Append( ID_LOAD, "&Load layouts" ); - file_menu->Append( ID_STORE, "&Store layouts" ); file_menu->AppendSeparator(); file_menu->Append( ID_AUTOSAVE, "&Auto Save Layouts", "save layouts on exit", TRUE ); @@ -258,9 +255,6 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame) EVT_MENU( MINIMAL_QUIT, MyFrame::OnQuit ) EVT_MENU( MINIMAL_ABOUT, MyFrame::OnAbout ) - EVT_MENU( ID_LOAD, MyFrame::OnLoad ) - EVT_MENU( ID_STORE, MyFrame::OnStore ) - EVT_MENU( ID_AUTOSAVE, MyFrame::OnAutoSave ) EVT_MENU( ID_SETTINGS, MyFrame::OnSettings ) EVT_MENU( ID_REMOVE, MyFrame::OnRemove ) EVT_MENU( ID_REMOVEALL, MyFrame::OnRemoveAll ) @@ -322,38 +316,28 @@ MyFrame::MyFrame(wxFrame *frame, char *title, int x, int y, int w, int h) int idx1 = mImageList.Add( bmp1 ); int idx2 = mImageList.Add( bmp2 ); - // load configuation if present + InitAboutBox(); - if ( wxFileExists( "layouts_for_demo.dat" ) ) - { - wxCommandEvent evt; - this->OnLoad( evt ); - } - else - { - InitAboutBox(); + // create multiple layouts - // create multiple layouts + mpNestedLayout = 0; - mpNestedLayout = 0; + mpClntWindow = CreateTxtCtrl("client window"); - mpClntWindow = CreateTxtCtrl("client window"); + for( i = 0; i != MAX_LAYOUTS; ++i ) - for( i = 0; i != MAX_LAYOUTS; ++i ) - - CreateLayout( i ); + CreateLayout( i ); - for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i ) + for( i = SECOND_LAYOUT; i != MAX_LAYOUTS; ++i ) - // hide others - mLayouts[i]->HideBarWindows(); + // hide others + mLayouts[i]->HideBarWindows(); - // activate first one + // activate first one - mLayouts[FIRST_LAYOUT]->Activate(); + mLayouts[FIRST_LAYOUT]->Activate(); - mActiveLayoutNo = FIRST_LAYOUT; - } + mActiveLayoutNo = FIRST_LAYOUT; } /*** event handlers ***/ @@ -366,65 +350,11 @@ bool MyFrame::OnClose(void) this->Show(FALSE); - if ( (mAutoSave && mSavedAlready) || !mAutoSave ); - else - { - wxCommandEvent evt; - this->OnStore(evt); - } - - mAboutBox.Destroy(); - this->Destroy(); - - return TRUE; -} - -void MyFrame::OnLoad( wxCommandEvent& event ) -{ - if ( !wxFileExists( "layouts_for_demo.dat" ) ) - { - wxMessageBox( - -"File \"layouts_for_demo.dat\" was not found,\n select\ -(File|Store Layouts) menu item to store layout information first" - ); - return; - } - - DestroyEverything(); - - wxIOStreamWrapper stm; - stm.CreateForInput( "layouts_for_demo.dat" ); - wxObjectStorage store( stm ); + mAboutBox.Destroy(); + this->Destroy(); - SerializeMe( store ); - - if ( mLayouts[mActiveLayoutNo] ) - - mLayouts[mActiveLayoutNo]->Activate(); -} - -void MyFrame::OnStore( wxCommandEvent& event ) -{ - wxIOStreamWrapper stm; - stm.CreateForOutput( "layouts_for_demo.dat" ); - - wxObjectStorage store( stm ); - - SerializeMe( store ); - - mSavedAlready = TRUE; -} - -void MyFrame::OnAutoSave( wxCommandEvent& event ) -{ - mAutoSave = !mAutoSave; - - wxCommandEvent evt; - this->OnStore(evt); - - SyncMenuBarItems(); + return TRUE; } void MyFrame::OnSettings( wxCommandEvent& event ) @@ -499,14 +429,8 @@ void MyFrame::OnQuit( wxCommandEvent& event ) this->Show(FALSE); - if ( (mAutoSave && mSavedAlready) || !mAutoSave ); - else - { - wxCommandEvent evt; - this->OnStore(evt); - } - Destroy(); + Destroy(); } void set_dlg_font( wxWindow* pParent, wxFont& font ) @@ -588,28 +512,21 @@ void MyFrame::OnChar( wxKeyEvent& event ) // "AI" :-) wxMessageBox("There are only 3 layouts in this demo :-("); else - if ( event.m_keyCode == WXK_TAB ) + if ( event.m_keyCode == WXK_TAB ) { - // USEFUL TRICK:: avoids flickering of application's frame - // when closing NN windows on exit: + // USEFUL TRICK:: avoids flickering of application's frame + // when closing NN windows on exit: - this->Show(FALSE); + this->Show(FALSE); - if ( (mAutoSave && mSavedAlready) || !mAutoSave ); - else - { - wxCommandEvent evt; - this->OnStore(evt); - } - - Destroy(); + Destroy(); } - else - if ( event.m_keyCode == WXK_CONTROL ) - - this->OnSettings( evt ); - else - event.Skip(); + else + if ( event.m_keyCode == WXK_CONTROL ) + + this->OnSettings( evt ); + else + event.Skip(); } void MyFrame::OnSayItsOk( wxCommandEvent& event ) @@ -924,7 +841,6 @@ wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent ) // functions from "wxinfo.h" ::wxCreateClassInfoTree( pClassView, cinfId, 1 ); - ::wxCreateSerializerInfoTree( pClassView, serId, 1 ); #ifdef __WXMSW__ // (default arg anyway) @@ -1217,32 +1133,6 @@ void MyFrame::ActivateLayout( int layoutNo ) SyncMenuBarItems(); } -void MyFrame::SerializeMe( wxObjectStorage& store ) -{ - store.AddInitialRef( this ); - store.AddInitialRef( mpInternalFrm ); - store.AddInitialRef( &mAboutBox ); - store.AddInitialRef( &mImageList ); - - store.XchgInt ( mActiveLayoutNo ); - store.XchgBool( mAutoSave ); - - store.XchgObjPtr( (wxObject**) &mpClntWindow ); - - for( int i = 0; i != MAX_LAYOUTS; ++i ) - { - if ( i == THIRD_LAYOUT ) - - store.XchgObjPtr( (wxObject**) &(mpNestedLayout) ); - - store.XchgObjPtr( (wxObject**) &(mLayouts[i]) ); - } - - store.XchgObjPtr( (wxObject**) &(mpAboutBoxLayout) ); - - store.Finalize(); // finish serialization -} - #ifdef __HACK_MY_MSDEV40__ ////////////// new 2.0-magic (linker errors...) //////////////// diff --git a/utils/framelayout/samples/demo/fl_demo.h b/utils/framelayout/samples/demo/fl_demo.h index 6f2fd452b5..a6a5542bf0 100644 --- a/utils/framelayout/samples/demo/fl_demo.h +++ b/utils/framelayout/samples/demo/fl_demo.h @@ -41,7 +41,6 @@ #define THIRD_LAYOUT 2 class wxFrameLayout; -class wxObjectStorage; // FOR NOW:: typedef wxPanel MyTestPanel; @@ -50,15 +49,15 @@ typedef wxPanel MyTestPanel; class MyApp: public wxApp { -public: - bool OnInit(void); + public: + bool OnInit(void); }; // Define a new frame type class MyFrame: public wxFrame { -protected: + protected: wxFrameLayout* mLayouts[MAX_LAYOUTS]; @@ -100,7 +99,6 @@ protected: void ActivateLayout( int layoutNo ); - void SerializeMe( wxObjectStorage& store ); public: /* public */ @@ -115,9 +113,6 @@ public: /* public */ bool OnClose(void); - void OnLoad( wxCommandEvent& event ); - void OnStore( wxCommandEvent& event ); - void OnAutoSave( wxCommandEvent& event ); void OnQuit(wxCommandEvent& event); void OnAbout(wxCommandEvent& event); void OnSettings( wxCommandEvent& event ); diff --git a/utils/framelayout/samples/demo/wxinfo.cpp b/utils/framelayout/samples/demo/wxinfo.cpp index 5f4d3ab8cd..c7aa850891 100644 --- a/utils/framelayout/samples/demo/wxinfo.cpp +++ b/utils/framelayout/samples/demo/wxinfo.cpp @@ -135,25 +135,4 @@ void wxCreateClassInfoTree( wxTreeCtrl* pTree, } while( nHanged != 0 ); } -void wxCreateSerializerInfoTree( wxTreeCtrl* pTree, - wxTreeItemId parentBranchId, - long classImageNo - ) -{ - expand_item( pTree, parentBranchId ); - - wxSerializerInfo::InitializeSerializers(); - - // FOR NOW:: no hierarchy - one branch - - wxSerializerInfo* pCur = wxSerializerInfo::first; - - while( pCur ) - { - wxString fullName = pCur->className + wxString( "Serializer" ); - - pTree->AppendItem( parentBranchId, fullName, classImageNo ); - pCur = pCur->next; - } -} diff --git a/utils/framelayout/samples/demo/wxinfo.h b/utils/framelayout/samples/demo/wxinfo.h index 9e9d135ab4..5f8ddda160 100644 --- a/utils/framelayout/samples/demo/wxinfo.h +++ b/utils/framelayout/samples/demo/wxinfo.h @@ -15,7 +15,6 @@ #include "wx/object.h" #include "wx/treectrl.h" -#include "objstore.h" /* * creates tree with hierarchically cauptured @@ -33,9 +32,4 @@ void wxCreateClassInfoTree( wxTreeCtrl* pTree, * NOTE:: "objstore.cpp" should be compiled in */ -void wxCreateSerializerInfoTree( wxTreeCtrl* pTree, // existing tree control - wxTreeItemId parentBranchId, - long classImageNo = -1 // (-1) - text only - ); - #endif diff --git a/utils/framelayout/samples/sample/fl_sample.cpp b/utils/framelayout/samples/sample/fl_sample.cpp index 0c5abcad4c..147d7f0d03 100644 --- a/utils/framelayout/samples/sample/fl_sample.cpp +++ b/utils/framelayout/samples/sample/fl_sample.cpp @@ -26,7 +26,6 @@ #endif #include "controlbar.h" -#include "objstore.h" // plugins used #include "barhintspl.h" @@ -58,7 +57,6 @@ protected: wxWindow* mpClientWnd; wxPanel* mpInternalFrm; - void SerializeMe( wxObjectStorage& store ); wxTextCtrl* CreateTextCtrl( const wxString& value ); @@ -67,8 +65,6 @@ public: MyFrame( wxWindow* parent, char *title ); ~MyFrame(); - void OnLoad( wxCommandEvent& event ); - void OnStore( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event ); bool OnClose(void) { return TRUE; } @@ -112,8 +108,6 @@ bool MyApp::OnInit(void) BEGIN_EVENT_TABLE(MyFrame, wxFrame) - EVT_MENU( ID_LOAD, MyFrame::OnLoad ) - EVT_MENU( ID_STORE, MyFrame::OnStore ) EVT_MENU( ID_QUIT, MyFrame::OnQuit ) END_EVENT_TABLE() @@ -204,46 +198,6 @@ wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value ) return pCtrl; } -void MyFrame::OnLoad( wxCommandEvent& event ) -{ - if ( !wxFileExists( LAYOUT_FILE ) ) - { - wxMessageBox( "layout data file `layout.dat' not found\n\n store layout first" ); - - return; - } - - mpLayout->HideBarWindows(); // hide first, to avoid flickered destruction - mpLayout->DestroyBarWindows(); - - if ( mpClientWnd ) - { - mpClientWnd->Destroy(); - delete mpLayout; - - mpClientWnd = NULL; - } - - wxIOStreamWrapper stm; - stm.CreateForInput( LAYOUT_FILE ); // TRUE - create stream for input - - wxObjectStorage store( stm ); - - SerializeMe( store ); - - mpLayout->Activate(); -} - -void MyFrame::OnStore( wxCommandEvent& event ) -{ - wxIOStreamWrapper stm; - stm.CreateForOutput( LAYOUT_FILE ); // FALSE - create stream for output - - wxObjectStorage store( stm ); - - SerializeMe( store ); -} - void MyFrame::OnQuit( wxCommandEvent& event ) { Show( FALSE ); // TRICK:: hide it, to avoid flickered destruction @@ -251,21 +205,6 @@ void MyFrame::OnQuit( wxCommandEvent& event ) Close(TRUE); } -void MyFrame::SerializeMe( wxObjectStorage& store ) -{ - // mark contaienr-frames as not serializable - - store.AddInitialRef( mpInternalFrm ); - store.AddInitialRef( this ); - - // does all the rest for as - - store.XchgObjPtr( (wxObject**) &(mpLayout) ); - store.XchgObjPtr( (wxObject**) &(mpClientWnd) ); - - store.Finalize(); // finish serialization -} - #ifdef __HACK_MY_MSDEV40__ ////////////// new 2.0-magic (linker errors...) //////////////// diff --git a/utils/framelayout/samples/test/fl_test.cpp b/utils/framelayout/samples/test/fl_test.cpp index 83425e2713..8e32d9677e 100644 --- a/utils/framelayout/samples/test/fl_test.cpp +++ b/utils/framelayout/samples/test/fl_test.cpp @@ -63,8 +63,6 @@ bool MyApp::OnInit(void) wxMenu *file_menu = new wxMenu; - file_menu->Append( NEW_TEST_LOAD, "&Load layouts" ); - file_menu->Append( NEW_TEST_SAVE, "&Store layouts" ); file_menu->Append( NEW_TEST_EXIT, "E&xit" ); wxMenuBar *menu_bar = new wxMenuBar; @@ -100,52 +98,10 @@ BEGIN_EVENT_TABLE( MyFrame, wxFrame ) // EVT_CHAR_HOOK(MyFrame::OnKeyDown) // EVT_PAINT( MyFrame::OnPaint ) - EVT_MENU( NEW_TEST_SAVE, MyFrame::OnSave ) - EVT_MENU( NEW_TEST_LOAD, MyFrame::OnLoad ) EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit ) END_EVENT_TABLE() -void MyFrame::OnLoad( wxCommandEvent& event ) -{ - mpLayout->HideBarWindows(); - mpLayout->DestroyBarWindows(); - delete mpLayout; - - if ( mpClientWnd ) - { - mpClientWnd->Destroy(); - mpClientWnd = NULL; - } - - mpLayout = NULL; - - wxIOStreamWrapper& stm = *(new wxIOStreamWrapper()); - - stm.CreateForInput( "layouts1.dat" ); - - mStore.SetDataStream( stm ); - - mStore.XchgObjPtr( (wxObject**) &mpLayout ); - - mStore.Finalize(); // finish serialization - - mpLayout->Activate(); -} - -void MyFrame::OnSave( wxCommandEvent& event ) -{ - wxIOStreamWrapper& stm = *(new wxIOStreamWrapper()); - - stm.CreateForOutput( "layouts1.dat" ); - - mStore.SetDataStream( stm ); - - mStore.XchgObjPtr( (wxObject**) &mpLayout ); - - mStore.Finalize(); // finish serialization -} - void MyFrame::OnExit( wxCommandEvent& event ) { Destroy(); @@ -180,9 +136,6 @@ MyFrame::MyFrame(wxFrame *frame) mpClientWnd = CreateTextCtrl( "Client window" ); - mStore.AddInitialRef( this ); - mStore.AddInitialRef( mpInternalFrm ); - //mStore.AddInitialRef( mpClientWnd ); mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd ); diff --git a/utils/framelayout/samples/test/fl_test.h b/utils/framelayout/samples/test/fl_test.h index 38c4c303bc..e24755cc73 100644 --- a/utils/framelayout/samples/test/fl_test.h +++ b/utils/framelayout/samples/test/fl_test.h @@ -1,7 +1,6 @@ #ifndef __NEW_TEST_G__ #define __NEW_TEST_G__ -#include "objstore.h" #include "wx/panel.h" // Define a new application type @@ -13,7 +12,6 @@ class MyApp: public wxApp class MyFrame: public wxFrame { public: - wxObjectStorage mStore; wxFrameLayout* mpLayout; wxTextCtrl* mpClientWnd; @@ -27,15 +25,11 @@ public: bool OnClose(void) { Show(FALSE); return TRUE; } - void OnLoad( wxCommandEvent& event ); - void OnSave( wxCommandEvent& event ); void OnExit( wxCommandEvent& event ); DECLARE_EVENT_TABLE() }; -#define NEW_TEST_SAVE 1101 -#define NEW_TEST_LOAD 1102 -#define NEW_TEST_EXIT 1103 +#define NEW_TEST_EXIT 1101 #endif diff --git a/utils/framelayout/src/Makefile.in b/utils/framelayout/src/Makefile.in index dd44f2de11..244ee3be1e 100644 --- a/utils/framelayout/src/Makefile.in +++ b/utils/framelayout/src/Makefile.in @@ -28,17 +28,14 @@ antiflickpl.cpp \ bardragpl.cpp \ barhintspl.cpp \ cbcustom.cpp \ -cbstore.cpp \ controlarea.cpp \ controlbar.cpp \ dyntbar.cpp \ dyntbarhnd.cpp \ -frmview.cpp \ garbagec.cpp \ gcupdatesmgr.cpp \ hintanimpl.cpp \ newbmpbtn.cpp \ -objstore.cpp \ panedrawpl.cpp \ rowdragpl.cpp \ rowlayoutpl.cpp \ diff --git a/utils/framelayout/src/cbstore.cpp b/utils/framelayout/src/cbstore.cpp deleted file mode 100644 index 596f4c513a..0000000000 --- a/utils/framelayout/src/cbstore.cpp +++ /dev/null @@ -1,611 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo -// Author: Aleksandras Gluchovas -// Modified by: -// Created: 27/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "cbstore.h" -// #pragma interface -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#include "cbstore.h" - -/***** Implementation for class wxFrameLayoutSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxFrameLayout, - wxFrameLayoutSerializer, - wxFrameLayoutSerializer::Serialize, - wxFrameLayoutSerializer::Initialize ) - -void wxFrameLayoutSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // wxFrameLayout is a "kind of" wxEvtHandler - perform - // serialization of the base class first - - info.SerializeInherited( pObj, store ); - - wxFrameLayout* pLayout = (wxFrameLayout*)pObj; - - store.XchgObjPtr( (wxObject**) &pLayout->mpFrame ); - store.XchgObjPtr( (wxObject**) &pLayout->mpFrameClient ); - - for( int i = 0; i != MAX_PANES; ++i ) - - store.XchgObjPtr( (wxObject**) &(pLayout->mPanes[i]) ); - - // plugins are serialized _after_ panes - - store.XchgObjPtr( (wxObject**) &(pLayout->mpTopPlugin) ); - - // and the rest will follow... - - store.XchgObjArray( pLayout->mAllBars ); - - store.XchgObjList( pLayout->mBarSpyList ); - - store.XchgObjList( pLayout->mFloatedFrames ); - - store.XchgObjPtr( (wxObject**) &(pLayout->mpUpdatesMgr) ); - - store.XchgBool( pLayout->mFloatingOn ); - - store.XchgWxPoint( pLayout->mNextFloatedWndPos ); - - store.XchgWxSize( pLayout->mFloatingPosStep ); - - store.XchgObj( (wxObject*) &pLayout->mDarkPen ); - store.XchgObj( (wxObject*) &pLayout->mLightPen ); - store.XchgObj( (wxObject*) &pLayout->mGrayPen ); - store.XchgObj( (wxObject*) &pLayout->mBlackPen ); - store.XchgObj( (wxObject*) &pLayout->mBorderPen ); -} - -void wxFrameLayoutSerializer::Initialize( wxObject* pObj ) -{ - wxFrameLayout* pLayout = (wxFrameLayout*)pObj; - - // wxFrameLayout is a "kind of" wxEvtHandler - perform - // wxEvtHandler-specific initialization first - - info.InitializeInherited( pObj ); - - //pLayout->RecalcLayout( TRUE ); -} - -/***** Implementation for class wxFrameLayoutSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbBarSpy, - cbBarSpySerializer, - cbBarSpySerializer::Serialize, - cbBarSpySerializer::Initialize ) - -void cbBarSpySerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // cbBarSpy is a "kind of" wxEvtHandler - perform - // serialization of the base class first - - info.SerializeInherited( pObj, store ); - - cbBarSpy* pSpy = (cbBarSpy*)pObj; - - store.XchgObjPtr( (wxObject**) &(pSpy->mpLayout) ); - store.XchgObjPtr( (wxObject**) &(pSpy->mpBarWnd) ); -} - -void cbBarSpySerializer::Initialize( wxObject* pObj ) -{ - // cbBarSpySerializer is a "kind of" wxEvtHandler - perform - // wxEvtHandler-specific initialization first - - info.InitializeInherited( pObj ); - - cbBarSpy* pSpy = (cbBarSpy*)pObj; - - // is done by wxEventHandler's serializer already! - - //pSpy->mpBarWnd->PushEventHandler( pSpy ); -} - -/***** Implementation for class cbBarDimHandlerBaseSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbBarDimHandlerBase, - cbBarDimHandlerBaseSerializer, - cbBarDimHandlerBaseSerializer::Serialize, - NO_CLASS_INIT ) - -void cbBarDimHandlerBaseSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbBarDimHandlerBase* pHandler = (cbBarDimHandlerBase*)pObj; - - store.XchgInt( pHandler->mRefCount ); -} - -/***** Implementation for class cbDimInfoSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbDimInfo, - cbDimInfoSerializer, - cbDimInfoSerializer::Serialize, - NO_CLASS_INIT ) - -void cbDimInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbDimInfo* pInfo = (cbDimInfo*)pObj; - - int i = 0; - - for( i = 0; i != MAX_BAR_STATES; ++i ) - - store.XchgWxSize( pInfo->mSizes[i] ); - - for( i = 0; i != MAX_BAR_STATES; ++i ) - - store.XchgWxRect( pInfo->mBounds[i] ); - - store.XchgInt ( pInfo->mLRUPane ); - store.XchgInt ( pInfo->mHorizGap ); - store.XchgInt ( pInfo->mVertGap ); - - store.XchgBool ( pInfo->mIsFixed ); - store.XchgObjPtr( (wxObject**) &(pInfo->mpHandler) ); -} - -/***** Implementation for class cbRowInfoSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbRowInfo, - cbRowInfoSerializer, - cbRowInfoSerializer::Serialize, - NO_CLASS_INIT ) - -void cbRowInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbRowInfo* pInfo = (cbRowInfo*)pObj; - - store.XchgObjArray( pInfo->mBars ); - - store.XchgLongArray( pInfo->mSavedRatios ); - - store.XchgObjPtr( (wxObject**) &pInfo->mpNext ); - store.XchgObjPtr( (wxObject**) &pInfo->mpPrev ); - store.XchgObjPtr( (wxObject**) &pInfo->mpExpandedBar ); - - store.XchgBool ( pInfo->mHasUpperHandle ); - store.XchgBool ( pInfo->mHasLowerHandle ); - store.XchgBool ( pInfo->mHasOnlyFixedBars ); - store.XchgInt ( pInfo->mNotFixedBarsCnt ); - - // other properties of the row are transient, since - // they are reclaculated each time the frame is resized/activated -} - -/***** Implementation for class cbBarInfoSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbBarInfo, - cbBarInfoSerializer, - cbBarInfoSerializer::Serialize, - NO_CLASS_INIT ) - -void cbBarInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbBarInfo* pInfo = (cbBarInfo*)pObj; - - store.XchgWxStr ( pInfo->mName ); - - store.XchgWxRect( pInfo->mBounds ); - - store.XchgObjPtr( (wxObject**) &(pInfo->mpRow) ); - - store.XchgBool ( pInfo->mHasLeftHandle ); - store.XchgBool ( pInfo->mHasRightHandle ); - - store.XchgObj ( (wxObject*) &(pInfo->mDimInfo ) ); - - store.XchgInt ( pInfo->mState ); - store.XchgInt ( pInfo->mAlignment ); - store.XchgInt ( pInfo->mRowNo ); - - store.XchgObjPtr( (wxObject**) &(pInfo->mpBarWnd) ); - - store.XchgDouble( pInfo->mLenRatio ); - - store.XchgWxPoint( pInfo->mPosIfFloated ); - - store.XchgObjPtr( (wxObject**) &(pInfo->mpNext) ); - store.XchgObjPtr( (wxObject**) &(pInfo->mpPrev) ); - - // other properties of the bar are transient, since - // they are reclaculated each time the frame is resized/activated -} - -/***** Implementation for class cbCommonPanePropertiesSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbCommonPaneProperties, - cbCommonPanePropertiesSerializer, - cbCommonPanePropertiesSerializer::Serialize, - NO_CLASS_INIT ) - -void cbCommonPanePropertiesSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbCommonPaneProperties* pProps = (cbCommonPaneProperties*)pObj; - - store.XchgBool ( pProps->mRealTimeUpdatesOn ); - store.XchgBool ( pProps->mOutOfPaneDragOn ); - store.XchgBool ( pProps->mExactDockPredictionOn ); - store.XchgBool ( pProps->mNonDestructFirctionOn ); - - store.XchgBool ( pProps->mShow3DPaneBorderOn ); - - store.XchgBool ( pProps->mBarFloatingOn ); - store.XchgBool ( pProps->mRowProportionsOn ); - store.XchgBool ( pProps->mColProportionsOn ); - store.XchgBool ( pProps->mBarCollapseIconsOn ); - store.XchgBool ( pProps->mBarDragHintsOn ); - - store.XchgWxSize( pProps->mMinCBarDim ); - - store.XchgInt( pProps->mResizeHandleSize ); -} - -/***** Implementation for class *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbDockPane, - cbDockPaneSerializer, - cbDockPaneSerializer::Serialize, - NO_CLASS_INIT ) - -void cbDockPaneSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbDockPane* pPane = (cbDockPane*)pObj; - - store.XchgObj( (wxObject*) &(pPane->mProps) ); - - store.XchgInt( pPane->mLeftMargin ); - store.XchgInt( pPane->mRightMargin ); - store.XchgInt( pPane->mTopMargin ); - store.XchgInt( pPane->mBottomMargin ); - - store.XchgInt( pPane->mAlignment ); - - store.XchgObjArray( pPane->mRows ); - store.XchgObjPtr ( (wxObject**) &(pPane->mpLayout) ); -} - -/***** Implementation for class cbUpdatesManagerBaseSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbUpdatesManagerBase, - cbUpdatesManagerBaseSerializer, - cbUpdatesManagerBaseSerializer::Serialize, - NO_CLASS_INIT ) - -void cbUpdatesManagerBaseSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbUpdatesManagerBase* pMgr = (cbUpdatesManagerBase*)pObj; - - // only back-reference to layout "engine" - store.XchgObjPtr( (wxObject**) &(pMgr->mpLayout) ); -} - -/***** Implementation for class cbPluginBaseSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbPluginBase, - cbPluginBaseSerializer, - cbPluginBaseSerializer::Serialize, - cbPluginBaseSerializer::Initialize ) - -void cbPluginBaseSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // plugin is "a kind" of wxEvtHandler - perform - // serialization of the base class first - - info.SerializeInherited( pObj, store ); - - cbPluginBase* pPlugin = (cbPluginBase*)pObj; - - store.XchgObjPtr( (wxObject**) &(pPlugin->mpLayout) ); - - store.XchgInt( pPlugin->mPaneMask ); -} - -void cbPluginBaseSerializer::Initialize( wxObject* pObj ) -{ - // plugins need extra-initialization, after they are - // attached to the frame-layout and pane mask is set - - ( (cbPluginBase*)pObj )->OnInitPlugin(); -} - -/***** Implementation for class cbRowDragPluginSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbRowDragPlugin, - cbRowDragPluginSerializer, - cbRowDragPluginSerializer::Serialize, - cbRowDragPluginSerializer::Initialize ) - -void cbRowDragPluginSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // plugin is "a kind" of cbPluginBaseSerializer - perform - // serialization of the base class first - - info.SerializeInherited( pObj, store ); - - cbRowDragPlugin* pPlugin = (cbRowDragPlugin*)pObj; - - store.XchgInt( pPlugin->mSvTopMargin ); - store.XchgInt( pPlugin->mSvBottomMargin ); - store.XchgInt( pPlugin->mSvLeftMargin ); - store.XchgInt( pPlugin->mSvRightMargin ); - - store.XchgObjList( pPlugin->mHiddenBars ); -} - -void cbRowDragPluginSerializer::Initialize( wxObject* pObj ) -{ - // plugins need extra-initialization, after they are - // attached to the frame-layout and pane mask is set - - ( (cbPluginBase*)pObj )->OnInitPlugin(); -} - -/***** Implementation for class cbHiddenBarInfoSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbHiddenBarInfo, - cbHiddenBarInfoSerializer, - cbHiddenBarInfoSerializer::Serialize, - NO_CLASS_INIT ) - -void cbHiddenBarInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbHiddenBarInfo* pInfo = (cbHiddenBarInfo*)pObj; - - store.XchgObjPtr( (wxObject**) &(pInfo->mpBar) ); - store.XchgInt( pInfo->mRowNo ); - store.XchgInt( pInfo->mIconNo ); - store.XchgInt( pInfo->mAlignment ); -} - -/***** Implementation for class cbFloatedBarWindowSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( cbFloatedBarWindow, - cbFloatedBarWindowSerializer, - cbFloatedBarWindowSerializer::Serialize, - cbFloatedBarWindowSerializer::Initialize ) - -static wxString __gTmpFrameTitle; - -void cbFloatedBarWindowSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - cbFloatedBarWindow* pWnd = (cbFloatedBarWindow*)pObj; - - if ( store.IsLoading() == FALSE ) - - __gTmpFrameTitle = pWnd->GetTitle(); - - store.XchgWxStr( __gTmpFrameTitle ); - - // cbFloatedBarWindow is "a kind" of wxWindow - perform - // serialization of the base class first - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)cbFloatedBarWindowSerializer::CreateFloatedBarWindowFn ); - - store.XchgObjPtr( (wxObject**) &(pWnd->mpBar) ); - store.XchgObjPtr( (wxObject**) &(pWnd->mpLayout) ); - store.XchgObjPtr( (wxObject**) &(pWnd->mpClientWnd) ); -} - -void cbFloatedBarWindowSerializer::CreateFloatedBarWindowFn( cbFloatedBarWindow* fbar, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - fbar->Create( parent, id, __gTmpFrameTitle, pos, size, style ); -} - -void cbFloatedBarWindowSerializer::Initialize( wxObject* pObj ) -{ - // FOR NOW:: nothing -} - -/***** Implementation for class wxNewBitmapButtonSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxNewBitmapButton, - wxNewBitmapButtonSerializer, - wxNewBitmapButtonSerializer::Serialize, - wxNewBitmapButtonSerializer::Initialize ) - -void wxNewBitmapButtonSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxNewBitmapButton* pBtn = (wxNewBitmapButton*)pObj; - - store.XchgInt ( pBtn->mTextToLabelGap ); - store.XchgInt ( pBtn->mMarginX ); - store.XchgInt ( pBtn->mMarginY ); - store.XchgInt ( pBtn->mTextAlignment ); - store.XchgBool( pBtn->mIsFlat ); - store.XchgBool( pBtn->mIsSticky ); - - store.XchgWxStr( pBtn->mLabelText ); - store.XchgWxStr( pBtn->mImageFileName ); - store.XchgInt ( pBtn->mImageFileType ); - - store.XchgInt( pBtn->mFiredEventType ); - - // cbFloatedBarWindow is "a kind" of wxWindow - perform - // serialization of the base class - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxNewBitmapButtonSerializer::CreateNewBmpBtnWindowFn ); -} - -void wxNewBitmapButtonSerializer::CreateNewBmpBtnWindowFn( wxNewBitmapButton* btn, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - btn->Create( parent, id, pos, size, style, name ); - - //btn->Reshape(); - btn->mIsCreated = FALSE; - btn->Reshape(); -} - -void wxNewBitmapButtonSerializer::Initialize( wxObject* pObj ) -{ - // FOR NOW:: nothing - wxNewBitmapButton* pBtn = (wxNewBitmapButton*)pObj; - - //pBtn->Reshape(); -} - -/***** Implementation for class wxDynamicToolBarSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxDynamicToolBar, - wxDynamicToolBarSerializer, - wxDynamicToolBarSerializer::Serialize, - wxDynamicToolBarSerializer::Initialize ) - -void wxDynamicToolBarSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // cbFloatedBarWindow is "a kind" of wxWindow - perform - // serialization of the base class first - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxDynamicToolBarSerializer::CreateDynTBarWindowFn ); - - wxDynamicToolBar* pTBar = (wxDynamicToolBar*)pObj; - - store.XchgObjArray( pTBar->mTools ); -} - -void wxDynamicToolBarSerializer::CreateDynTBarWindowFn( wxDynamicToolBar* tbar, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - tbar->Create( parent, id, pos, size, style ); -} - -void wxDynamicToolBarSerializer::Initialize( wxObject* pObj ) -{ - // FOR NOW:: nothing -} - -/***** Implementation for class wxDynToolInfoSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxDynToolInfo, - wxDynToolInfoSerializer, - wxDynToolInfoSerializer::Serialize, - NO_CLASS_INIT ) - -void wxDynToolInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // cbFloatedBarWindow is "a kind" of wxWindow - perform - // serialization of the base class first - - wxDynToolInfo* pInfo = (wxDynToolInfo*)pObj; - - store.XchgWxRect( pInfo->mRect ); - store.XchgBool ( pInfo->mIsSeparator ); - - store.XchgObjPtr( (wxObject**) &pInfo->mpToolWnd ); - store.XchgInt ( pInfo->mIndex ); - store.XchgWxSize( pInfo->mRealSize ); -} - -#include "objstore.h" // tabbed window is serialiable - -/***** Implementation for class wxTabbedWindowSerializer ****/ - -IMPLEMENT_SERIALIZER_CLASS( wxTabbedWindow, - wxTabbedWindowSerializer, - wxTabbedWindowSerializer::Serialize, - wxTabbedWindowSerializer::Initialize) - -void wxTabbedWindowSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxTabbedWindow* pWnd = (wxTabbedWindow*)pObj; - - // we're kind of window - serialize it first - - if ( store.IsLoading() ) - - // FOR NOW::workaround for the mistery - - pWnd->mpTabScroll = (wxScrollBar*)(-1); - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxWindowSerializer::CreateWindowFn, - FALSE ); - - store.XchgObjList( pWnd->mTabs ); - - store.XchgInt( pWnd->mActiveTab ); - store.XchgInt( pWnd->mTitleHeight ); - store.XchgInt( pWnd->mLayoutType ); - store.XchgInt( pWnd->mTitleHeight ); - - store.XchgObj( (wxObject*) &(pWnd->mWhitePen) ); - store.XchgObj( (wxObject*) &(pWnd->mGrayPen) ); - store.XchgObj( (wxObject*) &(pWnd->mDarkPen) ); - store.XchgObj( (wxObject*) &(pWnd->mBlackPen) ); - - store.XchgObjPtr( (wxObject**) &(pWnd->mpTabScroll ) ); - store.XchgObjPtr( (wxObject**) &(pWnd->mpHorizScroll) ); - store.XchgObjPtr( (wxObject**) &(pWnd->mpVertScroll ) ); - - store.XchgInt( pWnd->mVertGap ); - store.XchgInt( pWnd->mHorizGap ); - store.XchgInt( pWnd->mTitleVertGap ); - store.XchgInt( pWnd->mTitleHorizGap ); - store.XchgInt( pWnd->mImageTextGap ); - store.XchgInt( pWnd->mFirstTitleGap ); - store.XchgInt( pWnd->mBorderOnlyWidth ); -} - -void wxTabbedWindowSerializer::Initialize( wxObject* pObj ) -{ - wxTabbedWindow* pWnd = (wxTabbedWindow*)pObj; - - pWnd->RecalcLayout(TRUE); -} - -/***** Implementation for class twTabInfoSerializer ****/ - -IMPLEMENT_SERIALIZER_CLASS( twTabInfo, - twTabInfoSerializer, - twTabInfoSerializer::Serialize, - NO_CLASS_INIT ) - -void twTabInfoSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - twTabInfo* pInfo = (twTabInfo*)pObj; - - store.XchgObjPtr( (wxObject**) &(pInfo->mpContent) ); - - // NOTE:: wxSize is NOT a dynamic class unfortunately ... - - store.XchgWxSize( pInfo->mDims ); - - store.XchgWxStr ( pInfo->mText ); - store.XchgWxStr( pInfo->mImageFile ); - - store.XchgLong( pInfo->mImageType ); - - if ( store.IsLoading() && wxFileExists( pInfo->mImageFile ) ) - - pInfo->mBitMap.LoadFile( pInfo->mImageFile, pInfo->mImageType ); -} - diff --git a/utils/framelayout/src/cbstore.h b/utils/framelayout/src/cbstore.h deleted file mode 100644 index 26c64ea501..0000000000 --- a/utils/framelayout/src/cbstore.h +++ /dev/null @@ -1,181 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo -// Author: Aleksandras Gluchovas -// Modified by: -// Created: ??/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef __CBSTORE_G__ -#define __CBSTORE_G__ - -#include "controlbar.h" -#include "objstore.h" // used for persistance of control-bars - -// serializers for some additional classes placed here -#include "rowdragpl.h" -#include "toolwnd.h" -#include "newbmpbtn.h" -#include "dyntbar.h" -#include "controlarea.h" - -// serialziers for common components of frame-layout engine - -class wxFrameLayoutSerializer : public wxEvtHandlerSerializer -{ - DECLARE_SERIALIZER_CLASS( wxFrameLayoutSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); -}; - -class cbBarSpySerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbBarSpySerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); -}; - -class cbBarDimHandlerBaseSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbBarDimHandlerBaseSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class cbDimInfoSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbDimInfoSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class cbRowInfoSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbRowInfoSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; -class cbBarInfoSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbBarInfoSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; -class cbCommonPanePropertiesSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbCommonPanePropertiesSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class cbDockPaneSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbDockPaneSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class cbUpdatesManagerBaseSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbUpdatesManagerBaseSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class cbPluginBaseSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbPluginBaseSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); -}; - -class cbRowDragPluginSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbRowDragPluginSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); -}; - -class cbHiddenBarInfoSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( cbHiddenBarInfoSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class cbFloatedBarWindowSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( cbFloatedBarWindowSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); - - static void CreateFloatedBarWindowFn( cbFloatedBarWindow* fbar, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, - const wxString& name ); -}; - -/*** serializers for some additional classes (FOR NOW:: also placed here) ***/ - -class wxNewBitmapButtonSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxNewBitmapButtonSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); - - static void CreateNewBmpBtnWindowFn( wxNewBitmapButton* btn, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, - const wxString& name ); -}; - -class wxDynamicToolBarSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxDynamicToolBarSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); - - static void CreateDynTBarWindowFn( wxDynamicToolBar* btn, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style, - const wxString& name ); -}; - -class wxDynToolInfoSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( wxDynToolInfoSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -class wxTabbedWindowSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxTabbedWindowSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); -}; - -class twTabInfoSerializer : wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( twTabInfoSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -#endif \ No newline at end of file diff --git a/utils/framelayout/src/makefile.b32 b/utils/framelayout/src/makefile.b32 index 7bc1588327..4bc96b2fc5 100644 --- a/utils/framelayout/src/makefile.b32 +++ b/utils/framelayout/src/makefile.b32 @@ -12,10 +12,10 @@ WXDIR = $(WXWIN) LIBTARGET=$(WXDIR)\lib\fl.lib OBJECTS = antiflickpl.obj bardragpl.obj barhintspl.obj cbcustom.obj\ - cbstore.obj controlarea.obj controlbar.obj dyntbar.obj dyntbarhnd.obj\ - frmview.obj garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\ - objstore.obj panedrawpl.obj pf_sample.obj rowdragpl.obj rowlayoutpl.obj\ - settingsdlg.obj toolwnd.obj updatesmgr.obj wxinfo.obj + controlarea.obj controlbar.obj dyntbar.obj dyntbarhnd.obj\ + garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\ + panedrawpl.obj rowdragpl.obj rowlayoutpl.obj\ + toolwnd.obj updatesmgr.obj !include $(WXDIR)\src\makelib.b32 diff --git a/utils/framelayout/src/makefile.g95 b/utils/framelayout/src/makefile.g95 index a08dd88498..92b653bea3 100644 --- a/utils/framelayout/src/makefile.g95 +++ b/utils/framelayout/src/makefile.g95 @@ -12,9 +12,9 @@ WXDIR = ../../.. LIBTARGET=$(WXDIR)/lib/libfl.a OBJECTS = antiflickpl.o bardragpl.o barhintspl.o cbcustom.o\ - cbstore.o controlarea.o controlbar.o dyntbar.o dyntbarhnd.o\ - frmview.o garbagec.o gcupdatesmgr.o hintanimpl.o newbmpbtn.o\ - objstore.o panedrawpl.o rowdragpl.o rowlayoutpl.o\ + controlarea.o controlbar.o dyntbar.o dyntbarhnd.o\ + garbagec.o gcupdatesmgr.o hintanimpl.o newbmpbtn.o\ + panedrawpl.o rowdragpl.o rowlayoutpl.o\ toolwnd.o updatesmgr.o include $(WXDIR)/src/makelib.g95 diff --git a/utils/framelayout/src/makefile.unx b/utils/framelayout/src/makefile.unx index b8b3060eb9..6e98b792a8 100644 --- a/utils/framelayout/src/makefile.unx +++ b/utils/framelayout/src/makefile.unx @@ -17,25 +17,19 @@ antiflickpl.cpp \ bardragpl.cpp \ barhintspl.cpp \ cbcustom.cpp \ -cbstore.cpp \ controlarea.cpp \ controlbar.cpp \ dyntbar.cpp \ dyntbarhnd.cpp \ -frmview.cpp \ garbagec.cpp \ gcupdatesmgr.cpp \ hintanimpl.cpp \ newbmpbtn.cpp \ -objstore.cpp \ panedrawpl.cpp \ -pf_sample.cpp \ rowdragpl.cpp \ rowlayoutpl.cpp \ -settingsdlg.cpp \ toolwnd.cpp \ updatesmgr.cpp \ -wxinfo.cpp all: $(FLLIB) diff --git a/utils/framelayout/src/makefile.vc b/utils/framelayout/src/makefile.vc index deb4cc5e04..dbbaf07bbd 100644 --- a/utils/framelayout/src/makefile.vc +++ b/utils/framelayout/src/makefile.vc @@ -19,9 +19,9 @@ THISDIR = $(FLDIR)\src LIBTARGET=$(WXDIR)\lib\fl.lib OBJECTS = antiflickpl.obj bardragpl.obj barhintspl.obj cbcustom.obj\ - cbstore.obj controlarea.obj controlbar.obj dyntbar.obj dyntbarhnd.obj\ - frmview.obj garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\ - objstore.obj panedrawpl.obj pf_sample.obj rowdragpl.obj rowlayoutpl.obj\ + controlarea.obj controlbar.obj dyntbar.obj dyntbarhnd.obj\ + garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\ + panedrawpl.obj rowdragpl.obj rowlayoutpl.obj\ toolwnd.obj updatesmgr.obj !include $(WXDIR)\src\makelib.vc diff --git a/utils/framelayout/src/makefile.wat b/utils/framelayout/src/makefile.wat index 8a6cba33c6..0e4971821f 100644 --- a/utils/framelayout/src/makefile.wat +++ b/utils/framelayout/src/makefile.wat @@ -15,10 +15,10 @@ LNK = $(name).lnk IFLAGS = -i=$(WXINC) -i=$(WXBASEINC) -i=..\..\mfutils\src -i=..\..\prologio\src OBJECTS = antiflickpl.obj bardragpl.obj barhintspl.obj cbcustom.obj\ - cbstore.obj controlarea.obj controlbar.obj dyntbar.obj dyntbarhnd.obj\ + controlarea.obj controlbar.obj dyntbar.obj dyntbarhnd.obj\ frmview.obj garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\ - objstore.obj panedrawpl.obj pf_sample.obj rowdragpl.obj rowlayoutpl.obj\ - settingsdlg.obj toolwnd.obj updatesmgr.obj wxinfo.obj + panedrawpl.obj rowdragpl.obj rowlayoutpl.obj\ + toolwnd.obj updatesmgr.obj all: $(OBJECTSLIB) diff --git a/utils/framelayout/src/objstore.cpp b/utils/framelayout/src/objstore.cpp deleted file mode 100644 index 6aec8f02bf..0000000000 --- a/utils/framelayout/src/objstore.cpp +++ /dev/null @@ -1,1809 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo -// Author: Aleksandras Gluchovas -// Modified by: -// Created: 26/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "objstore.h" -// #pragma interface -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#include -#include "objstore.h" -#include - -// FIXME:: -// BUG?:: somehow assertion statements with oritinal wxASSERT do not get compiled in - -//#undef wxASSERT -//#define wxASSERT(x) if ( !(x) ) throw; - -/***** Implementation for class wxSerializerInfo *****/ - -bool wxSerializerInfo::alreadyInitialized = FALSE; -wxSerializerInfo *wxSerializerInfo::first = NULL; -wxHashTable wxSerializerInfo::serInfoHash; - -wxSerializerInfo::wxSerializerInfo( char* theClassName, - wxObjectSerializationFn serializationFun, - wxObjectInitializationFn initializationFun, - char* classVersionName - ) - : classInfo ( NULL ), - next ( NULL ), - nextByVersion( NULL ), - className ( theClassName ), - serFn ( serializationFun ), - initFn ( initializationFun ), - classVersion ( classVersionName ) -{ - next = first; - - first = this; -} - -int serializer_ver_cmp_fun( const void* arg1, const void* arg2 ) -{ - // "no-version" is considered being the highest version - - if ( ((wxSerializerInfo*)arg1)->classVersion == NO_CLASS_VER ) - { - // DBG:: two serializers for the same version of the class should not be present! - wxASSERT( ((wxSerializerInfo*)arg1)->classVersion != NO_CLASS_VER ); - - return -1; // (inverted already) - } - - if ( ((wxSerializerInfo*)arg2)->classVersion == NO_CLASS_VER ) - { - // DBG:: two serializers for the same version of the class should not be present! - wxASSERT( ((wxSerializerInfo*)arg1)->classVersion != NO_CLASS_VER ); - - return 1; // (inverted already) - } - - // versions are compared lexicographically ignoring the char-case - - wxString v1( ((wxSerializerInfo*)arg1)->classVersion ); - wxString v2( ((wxSerializerInfo*)arg2)->classVersion ); - - bool result = v1.CompareTo( v2, wxString::ignoreCase ); - - // DBG:: two serializers for the same version of the class should not be present! - wxASSERT( result == FALSE ); - - // invert the sense of "greater than" for storting in decreasing order - - return ( result > 0 ) ? -1 : 1; -} - -void wxSerializerInfo::InitializeSerializers(void) -{ - if ( alreadyInitialized ) return; - - alreadyInitialized = TRUE; - - wxSerializerInfo* pCur = first; - - // first resolve references to class information structures - - while( pCur ) - { - pCur->classInfo = wxClassInfo::FindClass( pCur->className ); - - wxASSERT( pCur->classInfo ); // DBG:: class info should already be present somewhere! - - // check if serializer for the class is already present, - - wxSerializerInfo* pFound = (wxSerializerInfo*)serInfoHash.Get( (long)pCur->classInfo ); - - if ( pFound ) - { - // if present, then it must be serializer for the certain version of that class, - // put it at the end of the chain of versioned serializers for that class - - // go to the end of chain - - while( pFound->nextByVersion ) pFound = pFound->nextByVersion; - - // append it - - pFound->nextByVersion = pCur; - - pCur->next = (wxSerializerInfo*)(-1); // label it as member of local chain - // of "versioned" serializers - - pCur->nextByVersion = NULL; - } - else - { - // otherwise, serializer for the class found for the first time - - // hash it - - serInfoHash.Put( (long)pCur->classInfo, (wxObject*)pCur ); - - // and include it to the list of serializers for the highest-versions - pCur = pCur->next; - } - } - - // sort chains of "versioned" serializers in the order of decreasing version - // - // (since, when loading, the newest version of an object - // is expected first, rather then the older one) - - wxSerializerInfo* pPrev = NULL; - pCur = first; - - while ( pCur ) - { - // chain present? - - if ( pCur->nextByVersion ) - { - // sort it - - wxSerializerInfo* pStart = pCur; - wxSerializerInfo* pNext = pCur->next; - - // let wxList do the sorting, we're too lazy :) - - wxList sorted; - - while( pCur ) - { - sorted.Append( (wxObject*) pCur ); - - pCur = pCur->nextByVersion; - } - - sorted.Sort( serializer_ver_cmp_fun ); - - wxNode* pNode = sorted.First(); - - while( pNode ) - { - wxSerializerInfo* pInfo = (wxSerializerInfo*)pNode->Data(); - - if ( pNode == sorted.First() ) - { - // make node with the highest version, a member of the global - // list of serializers - - if ( pPrev ) pPrev->next = pInfo; - else first = pInfo; - - pInfo->next = pNext; - } - else - pInfo->next = (wxSerializerInfo*)(-1); // otherwise label it as a member of local - // chain of "versioned" serializers - - if ( pNode->Next() ) - { - pInfo->nextByVersion = (wxSerializerInfo*)( pNode->Next()->Data() ); - } - else - pInfo->nextByVersion = 0; - - pNode = pNode->Next(); - } - - } // end of if ( nextByVersion ) - - pPrev = pCur; - pCur = pCur->next; - - } // end of while(...) -} - -wxSerializerInfo* wxSerializerInfo::FindSerializer( char* className ) -{ - wxSerializerInfo::InitializeSerializers(); - - wxSerializerInfo* pInfo = (wxSerializerInfo*) - - serInfoHash.Get( (long)wxClassInfo::FindClass( className ) ); - - return pInfo; -} - -static void invoke_for_inherited( wxObject* pObj, wxClassInfo* pCInfo, wxObjectStorage* pStore, bool invokeSerFn ) -{ - wxSerializerInfo* pSrzInfo = (wxSerializerInfo*) - - wxSerializerInfo::serInfoHash.Get( (long)wxClassInfo::FindClass( pCInfo->GetClassName() ) ); - - if ( pSrzInfo ) - { - // if found, serialize/initialize and don't go "any higher" - - if ( invokeSerFn ) - - (*pSrzInfo->serFn) ( pObj, *pStore ); - else - (*pSrzInfo->initFn)( pObj ); - - } - else - { - // go up the hierarchy, if no serializer present for the current class - - if ( pCInfo->GetBaseClass1() ) - - invoke_for_inherited( pObj, pCInfo->GetBaseClass1(), pStore, invokeSerFn ); - - if ( pCInfo->GetBaseClass2() ) - - invoke_for_inherited( pObj, pCInfo->GetBaseClass2(), pStore, invokeSerFn ); - } -} - -void wxSerializerInfo::SerializeInherited( wxObject* pObj, wxObjectStorage& store ) -{ - // search recursivelly up the hierarchy for serializers of base - // classes, and invoke serialization function for the given object - - if ( classInfo->GetBaseClass1() ) - - invoke_for_inherited( pObj, classInfo->GetBaseClass1(), &store, TRUE ); - - if ( classInfo->GetBaseClass2() ) - - invoke_for_inherited( pObj, classInfo->GetBaseClass2(), &store, TRUE ); -} - -void wxSerializerInfo::InitializeInherited( wxObject* pObj ) -{ - // search recursivelly up the hierarchy for serializers of base - // classes, and invoke initialization function for the given object - - if ( classInfo->GetBaseClass1() ) - - invoke_for_inherited( pObj, classInfo->GetBaseClass1(), NULL, FALSE ); - - if ( classInfo->GetBaseClass2() ) - - invoke_for_inherited( pObj, classInfo->GetBaseClass2(), NULL, FALSE ); -} - -/***** Implementation for class wxDataStreamBase *****/ - -IMPLEMENT_ABSTRACT_CLASS( wxDataStreamBase, wxObject ) - -/***** Implementation for class wxObjectStorage *****/ - -// codes, used as tokens written/read from the stream - -enum STORED_OBJ_TYPES -{ - SOT_NULL_POINTER = 'N', - SOT_POINTER_TO_OBJ = 'P', - SOT_INITIAL_REF = 'I', - SOT_OBJ_DATA = 'D' -}; - -// veraion-encoding in object-name string fromat defaults: - -char wxObjectStorage::mVerSepartorCh = '#'; -char wxObjectStorage::mMinorMajorSepartorCh = '-'; - -IMPLEMENT_DYNAMIC_CLASS( wxObjectStorage, wxObject ) - -wxObjectStorage::wxObjectStorage() - : mpStm ( 0 ), - mIsLoading ( TRUE ), - mInitialRefsCnt ( 0 ), - mFinalizePending( FALSE ) -{} - -wxObjectStorage::wxObjectStorage( wxDataStreamBase& stm ) - : mpStm ( &stm ), - mIsLoading ( stm.IsForInput() ), - mInitialRefsCnt ( 0 ), - mFinalizePending( FALSE ) -{ - wxSerializerInfo::InitializeSerializers(); - - mFinalizePending = TRUE; // stream object was given - store/load is - // started -} - -wxObjectStorage::~wxObjectStorage() -{ - if ( mFinalizePending ) - - Finalize(); // <- do it now, if "user" forgot about it -} - -/*** protected members ***/ - -void wxObjectStorage::ClearHashesAndLists() -{ - mNewObjs.Clear(); - mSerializersForNewObjs.Clear(); - mRefHash.Clear(); -} - -/*** public members ***/ - -void wxObjectStorage::SetDataStream( wxDataStreamBase& stm ) -{ - if ( mFinalizePending ) - - Finalize(); - - wxSerializerInfo::InitializeSerializers(); - - ClearHashesAndLists(); - - mpStm = &stm; - - mIsLoading = stm.IsForInput(); - - mFinalizePending = TRUE; -} - -void wxObjectStorage::Finalize() -{ - wxASSERT( mpStm ); // DBG:: finalize should called be after loading/storing has proceeded - - mFinalizePending = FALSE; - - if ( mIsLoading ) - { - // initializaiton is performed after all objects successfully - // loaded, and references among them are established - - wxNode* pObjNode = mNewObjs.First(); - wxNode* pSrzNode = mSerializersForNewObjs.First(); - - while( pObjNode ) - { - wxSerializerInfo* pSrzInfo = (wxSerializerInfo*)(pSrzNode->Data()); - - if ( pSrzInfo->HasInitializer() ) - - (*pSrzInfo->initFn)( pObjNode->Data() ); - - pObjNode = pObjNode->Next(); - pSrzNode = pSrzNode->Next(); - } - } - else - // otherwise, nothing's need to be done after storing of objects is proceeded - mpStm->Flush(); -} - -// storage methods for basic types - -void wxObjectStorage::XchgChar( char& chObj ) -{ - if ( mIsLoading ) mpStm->LoadChar( &chObj ); - else mpStm->StoreChar( chObj ); -} - -void wxObjectStorage::XchgInt( int& intObj ) -{ - if ( mIsLoading ) mpStm->LoadInt( &intObj ); - else mpStm->StoreInt( intObj ); -} - -void wxObjectStorage::XchgSizeType( size_t& szObj ) -{ - int i = int(szObj); - - if ( mIsLoading ) - { - mpStm->LoadInt( &i ); - szObj = (size_t)i; - } - else - mpStm->StoreInt( i ); -} - -void wxObjectStorage::XchgLong( long& longObj ) -{ - if ( mIsLoading ) mpStm->LoadLong( &longObj ); - else mpStm->StoreLong( longObj ); -} - -void wxObjectStorage::XchgBool( bool& boolObj ) -{ - // bools are stored as ints - - if ( mIsLoading ) - { - int bVal = (int)boolObj; - mpStm->LoadInt( &bVal ); - boolObj = bVal; - } - else - mpStm->StoreInt( (int)boolObj ); -} - -void wxObjectStorage::XchgUInt ( unsigned int& uI ) -{ - if ( mIsLoading ) - { - int uiVal = (int)uI; - mpStm->LoadInt( &uiVal ); - uI = (unsigned int)uiVal; - } - else - mpStm->StoreInt( (int)uI ); -} - -void wxObjectStorage::XchgObjList( wxList& objList ) -{ - int count = 0; - - if ( mIsLoading ) - { - XchgInt( count ); - - if ( count == 0 ) return; - - objList.Clear(); - } - else - { - count = objList.GetCount(); - - XchgInt( count ); - } - - // work-around for assessing operator[] which is protected in wxArrayBase - - if ( mIsLoading ) - - for( int i = 0; i != count; ++i ) - { - wxObject* pObj = NULL; - - XchgObjPtr( &pObj ); - - objList.Append( pObj ); - } - else - { - wxNode* pNode = objList.First(); - - while( pNode ) - { - wxObject* pObj = pNode->Data(); - - XchgObjPtr( &pObj ); - - pNode = pNode->Next(); - } - } -} - -void wxObjectStorage::XchgObjArray ( wxBaseArray& objArr ) -{ - int count = 0; - - if ( mIsLoading ) - { - XchgInt( count ); - - if ( count == 0 ) return; - - objArr.Clear(); - objArr.Alloc( count ); - } - else - { - count = objArr.GetCount(); - - XchgInt( count ); - } - - // work-around for assessing operator[] which is protected in wxArrayBase - - wxArrayLong& longArr = *( (wxArrayLong*) (&objArr) ); - - if ( mIsLoading ) - - for( int i = 0; i != count; ++i ) - { - wxObject* pObj = NULL; - - XchgObjPtr( &pObj ); - - longArr.Add( (long) pObj ); - } - else - for( int i = 0; i != count; ++i ) - { - wxObject* pObj = (wxObject*)longArr[i]; - - XchgObjPtr( &pObj ); - } -} - -void wxObjectStorage::XchgLongArray( wxBaseArray& longArr ) -{ - int count = 0; - - if ( mIsLoading ) - { - XchgInt( count ); - - if ( count == 0 ) return; - - longArr.Clear(); - longArr.Alloc( count ); - } - else - { - count = longArr.GetCount(); - - XchgInt( count ); - } - - // work-around for assessing operator[] which is protected in wxArrayBase - - wxArrayLong& realLongArr = *( (wxArrayLong*) (&longArr) ); - - if ( mIsLoading ) - - for( int i = 0; i != count; ++i ) - { - long l = 0; - XchgLong( l ); - - realLongArr.Add( l ); - } - else - for( int i = 0; i != count; ++i ) - - XchgLong( realLongArr[i] ); -} - -void wxObjectStorage::XchgDouble( double& doubleObj ) -{ - if ( mIsLoading ) mpStm->LoadDouble( &doubleObj ); - else mpStm->StoreDouble( doubleObj ); -} - -void wxObjectStorage::XchgCStr( char* pCStrObj ) -{ - if ( mIsLoading ) - { - int len; - mpStm->LoadInt( &len ); - mpStm->LoadBytes( pCStrObj, len ); - } - else - { - int len = strlen( pCStrObj ) + 1; // include terminating zero - mpStm->StoreInt( len ); - mpStm->StoreBytes( pCStrObj, len ); - } -} - -wxSerializerInfo* wxObjectStorage::FindSrzInfoForClass( wxClassInfo* pInfo ) -{ - wxSerializerInfo* pSrz = (wxSerializerInfo*) - - wxSerializerInfo::serInfoHash.Get( (long)pInfo ); - - if ( !pSrz ) - { - // look up recursivelly for serializers for of the base classes - - if ( pInfo->GetBaseClass1() ) - - return FindSrzInfoForClass( pInfo->GetBaseClass1() ); - else - if ( pInfo->GetBaseClass2() ) - - return FindSrzInfoForClass( pInfo->GetBaseClass2() ); - else - { - wxASSERT(0); // DBG:: no serializers present for the given class, - // serialization cannot proceed - return 0; - } - } - else - return pSrz; -} - -bool wxObjectStorage::VersionsMatch( char* v1, char* v2 ) -{ - while( *v1 && *v2 ) - { - if ( *v1 == mMinorMajorSepartorCh || - *v2 == mMinorMajorSepartorCh ) - - // minor versions are ignored - - return TRUE; - - if ( toupper(*v1) != toupper(*v2) ) - - return FALSE; - - ++v1; ++v2; - } - - return ( *v1 == '\0' && *v2 == '\0' ); -} - -bool wxObjectStorage::ExchangeObjectInfo( wxClassInfo** ppCInfo, wxSerializerInfo** ppSrz ) -{ - char objInfoStr[512]; // FOR NOW:: fixed? - - if ( mIsLoading == FALSE ) - { - strcpy( objInfoStr, (*ppCInfo)->GetClassName() ); - - if ( (*ppSrz)->HasVersion() ) - { - char separator[2]; - separator[2] = mVerSepartorCh; - separator[1] = '\0'; - - strcat( objInfoStr, separator ); - - strcat( objInfoStr, (*ppSrz)->classVersion ); - } - - XchgCStr( objInfoStr ); - - return TRUE; - } - - // otherwise if loading... - - XchgCStr( objInfoStr ); // read string - - (*ppCInfo) = NULL; - (*ppSrz) = NULL; - - // formal description of objInfoStr format is following (if '#' and '-' are set - // as version and minor/major separators): - // - // object objInfoStr = { class_name_str , [version] } - // - // version = { '#', simple_version_str | major_and_minor_version_str } - // - // simple_version_str = any_literal - // - // major_and_minro_version_str = { major_version_str, '-', minro_version_str } - // - // major_version_str = any_literal - // - // inor_version_str = any_literal - // - // any_literal = "any string not containing '#' and '-' characters" - // - - char* cur = objInfoStr; - - while( *cur && *cur != mVerSepartorCh ) ++cur; - - char last = *cur; - - if ( last == mVerSepartorCh ) - - *cur = '\0'; - - (*ppCInfo) = wxClassInfo::FindClass( objInfoStr ); - - if ( !(*ppCInfo) ) return FALSE; - - // get the bigining of the chain of serializers for (*ppCInfo) - - wxSerializerInfo* pSrz = FindSrzInfoForClass( (*ppCInfo ) ); - - if ( last == mVerSepartorCh ) *cur = last; // restore from temprary "termination" - - // find serializer which matches the version, or the serializer - // with no version, if version is not attached to the objInfoStr - - if ( *cur == '\0' ) - { - // there's no version trailing, the "not-versioned" - // serializer can be present only at the begining of - // the chain - - if ( pSrz->HasVersion() == FALSE ) - { - (*ppSrz) = pSrz; - - return TRUE; - } - else - return FALSE; - } - - ++cur; // skip className<->version separator - - // version present, search for matching serializer down the chain - - if ( pSrz->HasVersion() == FALSE ) pSrz = pSrz->nextByVersion; - - while( pSrz ) - { - if ( VersionsMatch( pSrz->classVersion, cur ) ) - { - (*ppSrz) = pSrz; - - return TRUE; - } - - pSrz = pSrz->nextByVersion; - } - - return FALSE; // no serializers matching given version found -} - -wxSerializerInfo* wxObjectStorage::GetLatestSrzForObj( wxObject* pWxObj ) -{ - wxClassInfo* pCInfo = pWxObj->GetClassInfo(); - - wxASSERT( pCInfo ); // DBG:: object's class should be dynamic - - // find first serializer for (*pCInfo) in the chain - - wxSerializerInfo* pSrz = FindSrzInfoForClass( pCInfo ); - - wxASSERT( pSrz ); // DBG:: there should be at least one serializer of - // the object's class, at least for it's base classes - - // skip not-versioned serializer at the beginng of the chain if present - - if ( !pSrz->HasVersion() && pSrz->nextByVersion ) - - pSrz = pSrz->nextByVersion; // the reminding ones are "vesioned", - // starting from the highest version - - return pSrz; -} - -void wxObjectStorage::DoExchangeObject( wxObject* pInstance, wxSerializerInfo& srzInfo ) -{ - if ( mIsLoading ) - - // put info about already (partially) loaded object (stream-offset <=> object-ptr ) - - mRefHash.Put( (long)mpStm->GetStreamPos(), (wxObject*)pInstance ); - else - // put info about already (partially) stored object (object-ptr <=> stream-offset) - - mRefHash.Put( (long)(pInstance), (wxObject*)mpStm->GetStreamPos() ); - - if ( mIsLoading ) - { - mNewObjs.Append( pInstance ); - mSerializersForNewObjs.Append( (wxObject*)&srzInfo ); - } - - // now, perform actual serialization of the object - - (srzInfo.serFn)( pInstance, *this ); -} - -// storage methods for objects and object-references - -void wxObjectStorage::XchgObj( wxObject* pWxObj ) -{ - wxClassInfo* pCInfo = pWxObj->GetClassInfo(); - - wxASSERT( pCInfo ); // DBG:: if this fails, the object which is passed to - // XchgObj(..) has not it's class information - // i.e. is not a wxWindows dynamic class - - wxSerializerInfo* pSrz = ( mIsLoading == FALSE ) ? GetLatestSrzForObj( pWxObj ) - : NULL; - - bool success = ExchangeObjectInfo( &pCInfo, &pSrz ); - - wxASSERT( success ); // DBG:: all info about object should be present i.e. class - // info, serializer which matches the object's version - // (see source of ExchangeObjectInfo() for more info) - - DoExchangeObject( pWxObj, *pSrz ); -} - -void wxObjectStorage::XchgObjPtr( wxObject** ppWxObj ) -{ - if ( mIsLoading ) - { - char token; - mpStm->LoadChar( &token ); - - if ( token == (char)SOT_NULL_POINTER ) - - (*ppWxObj) = NULL; - else - if ( token == (char)SOT_POINTER_TO_OBJ ) - { - long ofs; // stream-offset - - mpStm->LoadLong( &ofs ); - - wxObject* pObj = (wxObject*) mRefHash.Get( ofs ); - - wxASSERT( pObj ); // DBG:: object (at the given stream-offset) - // must be already loaded - - (*ppWxObj) = pObj; - } - else - if ( token == (char)SOT_INITIAL_REF ) - { - long refNo; - - mpStm->LoadLong( &refNo ); - - wxASSERT( mInitialRefsCnt >= refNo ); // DBG:: inital refernce should be already added - - // refNo is 1-based - (*ppWxObj) = mInitialRefs.Nth( refNo-1 )->Data(); - } - else - { - wxASSERT( token == (char)SOT_OBJ_DATA );// DBG:: other types of tokens are - // bogous! If this happens you're - // probably trying to load the data - // which was stored by defferent. - // perhaps out-dated serializers - // - // Use versioning mechanizm to - // privide backwards compatiblity - // option, among different versions - // stored data-format - - - int stmPos = mpStm->GetStreamPos(); - - wxClassInfo* pCInfo = 0; - wxSerializerInfo* pSrz = 0; - - bool success = ExchangeObjectInfo( &pCInfo, &pSrz ); - - wxASSERT( success ); // DBG:: all info about object should be present - // i.e. class info, serializer which matches the object's - // version (see source of ExchangeObjectInfo() for more info) - - (*ppWxObj) = pCInfo->CreateObject(); - - DoExchangeObject( (*ppWxObj), *pSrz ); - } - } - else - { - // otherwise if storing the pointer to an object - - // first, check if it's an initial reference - - long refNo = (long)mInitialRefsHash.Get( (long)(*ppWxObj) ); - - if ( refNo != 0 ) - { - mpStm->StoreChar( (char)SOT_INITIAL_REF ); - mpStm->StoreLong( refNo ); - - return; - } - - long streamPos = (long) mRefHash.Get( (long)(*ppWxObj) ); - - // check if object is already stored - if ( streamPos != 0 ) - { - // store only reference to the object (in the form of stream-offset) - - mpStm->StoreChar( (char)SOT_POINTER_TO_OBJ ); - mpStm->StoreLong( streamPos ); - } - else - { - // otherwise store the entire referenced object - - if ( (*ppWxObj) == NULL ) - { - mpStm->StoreChar( (char)SOT_NULL_POINTER ); // token - return; - } - - mpStm->StoreChar( (char)SOT_OBJ_DATA ); // token - - // store object's info and data - XchgObj( *ppWxObj ); - } - } -} - -// storage methods for common wxWindows objects - -void wxObjectStorage::XchgWxStr( wxString& str ) -{ - if ( mIsLoading ) - { - long len = 0; - mpStm->LoadLong( &len ); - - str = ""; - str.Append( (char)1, len ); - - mpStm->LoadBytes( (char*)str.c_str(), len ); - } - else - XchgCStr( (char*)str.c_str() ); -} - -void wxObjectStorage::XchgWxSize( wxSize& size ) -{ - XchgLong( size.x ); - XchgLong( size.y ); -} - -void wxObjectStorage::XchgWxPoint( wxPoint& point ) -{ - XchgLong( point.x ); - XchgLong( point.y ); -} - -void wxObjectStorage::XchgWxRect( wxRect& rect ) -{ - XchgLong( rect.x ); - XchgLong( rect.y ); - XchgLong( rect.width ); - XchgLong( rect.height ); -} - -void wxObjectStorage::AddInitialRef( wxObject* pObjRef ) -{ - // duplicates are not accepted - - if ( mInitialRefsHash.Get( (long)pObjRef ) != NULL ) - - return; - - ++mInitialRefsCnt; - - // NOTE:: reference number is 1-based (zero is "reserved" by wxHashTable) - - mInitialRefs.Append( pObjRef ); - mInitialRefsHash.Put( (long)pObjRef, (wxObject*)mInitialRefsCnt ); -} - -void wxObjectStorage::ClearInitalRefs() -{ - mInitialRefsCnt = 0; - - mInitialRefsHash.Clear(); - mInitialRefsHash.Clear(); -} - -/***** Implementation for class wxColourSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxColour, - wxColourSerializer, - wxColourSerializer::Serialize, - NO_CLASS_INIT ) - -void wxColourSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxColour* pCol = (wxColour*)pObj; - - // slightly optimized - - if ( store.IsLoading() ) - { - long rgb; - store.XchgLong( rgb ); - - *pCol = wxColour( rgb & 0xFF, - ( rgb >> 8 ) & 0xFF, - ( rgb >> 16 ) & 0xFF ); - - } - else - { - long rgb = 0; - - unsigned char r = pCol->Red(),g = pCol->Green(), b = pCol->Blue(); - - rgb = ( long(r) & 0x0000FF ) | - ( ( long(g) << 8 ) & 0x00FF00 ) | - ( ( long(b) << 16 ) & 0xFF0000 ); - - store.XchgLong( rgb ); - } -} - -/***** Implementation for class wxPenSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxPen, - wxPenSerializer, - wxPenSerializer::Serialize, - NO_CLASS_INIT ) - -void wxPenSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxPen* pPen = (wxPen*)pObj; - - int cap; - wxColour col; - int join; - int style; - int width; - - if ( store.IsLoading() == FALSE ) - { - cap = pPen->GetCap(); - col = pPen->GetColour(); - join = pPen->GetJoin(); - style = pPen->GetStyle(); - width = pPen->GetWidth(); - } - - store.XchgInt( cap ); - store.XchgObj( (wxObject*) &col ); - store.XchgInt( join ); - store.XchgInt( style ); - store.XchgInt( width ); - - if ( store.IsLoading() ) - { - pPen->SetCap ( cap ); - pPen->SetColour( col ); - pPen->SetJoin ( join ); - pPen->SetStyle ( style ); - pPen->SetWidth ( width ); - } -} - -/***** Implementation for class wxBrushSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxBrush, - wxBrushSerializer, - wxBrushSerializer::Serialize, - NO_CLASS_INIT ) - -void wxBrushSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxBrush* pBrush = (wxBrush*)pObj; - - wxColour col; - int style; - - if ( store.IsLoading() == FALSE ) - { - col = pBrush->GetColour(); - style = pBrush->GetStyle(); - } - - store.XchgObj( (wxObject*) &col ); - store.XchgInt( style ); - - if ( store.IsLoading() ) - { - pBrush->SetColour( col ); - pBrush->SetStyle ( style ); - } -} - -/***** Implementation for class wxEvtHandlerSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxEvtHandler, - wxEvtHandlerSerializer, - wxEvtHandlerSerializer::Serialize, - wxEvtHandlerSerializer::Initialize ) - -void wxEvtHandlerSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxEvtHandler* pHnd = ( wxEvtHandler*) pObj; - - wxEvtHandler* pPrevHnd; - wxEvtHandler* pNextHnd; - - if ( store.IsLoading() == FALSE ) - { - // extract properties when storing - - pPrevHnd = pHnd->GetPreviousHandler(); - pNextHnd = pHnd->GetNextHandler(); - } - - // serialize properties - - store.XchgObjPtr( (wxObject**) &pPrevHnd ); - store.XchgObjPtr( (wxObject**) &pNextHnd ); - - if ( store.IsLoading() ) - { - // set properties when loading - - pHnd->SetPreviousHandler( pPrevHnd ); - pHnd->SetNextHandler ( pNextHnd ); - } -} - -void wxEvtHandlerSerializer::Initialize( wxObject* pObj ) -{ - wxEvtHandler* pHnd = ( wxEvtHandler*) pObj; - - // if we're on top - if ( pHnd->GetPreviousHandler() == NULL ) - { - // then check if we're in the chain which is - // attached to wxWindow object - - wxEvtHandler* pCur = pHnd->GetNextHandler(); - - while( pCur ) - { - if ( pCur->IsKindOf( CLASSINFO(wxWindow) ) ) - { - // since we are the the right-most event handler - // in the chain, then we must be the first - // receiver of events sent to the window obj. - - // therefore "make it happen": - - ((wxWindow*)pCur)->SetEventHandler( pHnd ); - - // but if wxWindow is persistant, then why - // we're setting "manually" the property - // which is serialized anyway? - // - // The *PROBLEM* is that, it's not always good idea - // to serialize a window (e.g. main frame), instead - // they could be referred by "inital-refernces". To - // handle the later case, we additionally make sure - // that serialized evt. handlers are "glued" to the - // window correctly,even if the window is transient - // itself - - return; - } - - // keep on searching for wxWindows down the chain - - pCur = pCur->GetNextHandler(); - } - } -} - -/***** Implementation for class wxWindowSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxWindow, - wxWindowSerializer, - wxWindowSerializer::Serialize, - NO_CLASS_INIT ) - -void wxWindowSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - DoSerialize( pObj, store, (wndCreationFn)wxWindowSerializer::CreateWindowFn ); -} - -void wxWindowSerializer::DoSerialize( wxObject* pObj, wxObjectStorage& store, - wndCreationFn creationFn, bool refreshNow ) -{ - // wxWindow is a kind of wxEvtHandler - peform serialization of - // the base class first - - info.SerializeInherited( pObj, store ); - - wxWindow* pWnd = (wxWindow*)pObj; - - long id; - long style; - wxString name; - wxPoint pos; - wxSize size; - wxColour bkCol; - wxWindow* pParent; - wxList* pCldLst; - wxEvtHandler* pEvtHandler; - - wxList tmpCldLst; - - if ( store.IsLoading() == FALSE ) - { - // extract properties from window object - - name = pWnd->GetName(); - id = pWnd->GetId(); - style = pWnd->GetWindowStyleFlag(); - - // workaround for long/int inconsitency of wxWin2.0a - int x,y,w,h; - pWnd->GetPosition( &x, &y ); - pWnd->GetSize ( &w, &h ); - bkCol = pWnd->GetBackgroundColour(); - - pos.x = x; pos.y = y; - size.x = w; size.y = h; - - pEvtHandler = pWnd->GetEventHandler(); - pParent = pWnd->GetParent(); - -#ifdef __HACK_MY_MSDEV40__ - pCldLst = pWnd->GetChildren(); -#else - pCldLst = &pWnd->GetChildren(); -#endif - - } - - // serialize properties - - store.XchgWxStr ( name ); - store.XchgLong ( id ); - store.XchgLong ( style ); - store.XchgLong ( pos.x ); - store.XchgLong ( pos.y ); - store.XchgLong ( size.x ); - store.XchgLong ( size.y ); - store.XchgObj ( (wxObject* ) &bkCol ); - store.XchgObjPtr( (wxObject**) &pParent ); - store.XchgObjPtr( (wxObject**) &pEvtHandler ); - - if ( store.IsLoading() ) - { - - // serialize to on-stack list object, since children will - // automatically add themselves to parent's list - - pCldLst = &tmpCldLst; - - // first create window (when loading), then serialize it's children - - (*creationFn)( pWnd, pParent, id, pos, size, style, name ); - - //pWnd->SetBackgroundColour( bkCol ); - - //pWnd->SetBackgroundColour( bkCol ); - - if ( refreshNow && 0 ) pWnd->Refresh(); - } - - store.XchgObjList( *pCldLst ); -} - -void wxWindowSerializer::CreateWindowFn( wxWindow* wnd, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - wnd->Create( parent, id, pos, size, style, name ); -} - -/***** Implementation for class wxTextCtrlSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxTextCtrl, - wxTextCtrlSerializer, - wxTextCtrlSerializer::Serialize, - NO_CLASS_INIT ) - -void wxTextCtrlSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxTextCtrl* pCtrl = (wxTextCtrl*)pObj; - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxTextCtrlSerializer::CreateTextCtrlWindowFn ); - - wxString text; - - if ( store.IsLoading() == FALSE ) - - text = pCtrl->GetValue(); - - store.XchgWxStr( text ); - - if ( store.IsLoading() ) - - pCtrl->SetValue( text ); -} - -void wxTextCtrlSerializer::CreateTextCtrlWindowFn( wxTextCtrl* wnd, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - wnd->Create( parent, id, "", pos, size, style ); - - // FIXME:: quick-hack - wnd->SetBackgroundColour( wxColour(255,255,255) ); -} - -/***** Implementation for class wxButtonSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxButton, - wxButtonSerializer, - wxButtonSerializer::Serialize, - NO_CLASS_INIT ) - -void wxButtonSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxButton* pBtn = (wxButton*)pObj; - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxButtonSerializer::CreateButtonWindowFn ); - - wxString label; - - if ( store.IsLoading() == FALSE ) - - label = pBtn->GetLabel(); - - store.XchgWxStr( label ); - - if ( store.IsLoading() ) - - pBtn->SetLabel( label ); -} - -void wxButtonSerializer::CreateButtonWindowFn( wxButton* btn, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - btn->Create( parent, id, "", pos, size, style ); -} - -/***** Implementation for class wxStaticTextSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxStaticText, - wxStaticTextSerializer, - wxStaticTextSerializer::Serialize, - NO_CLASS_INIT ) - -void wxStaticTextSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxStaticText* pSTxt = (wxStaticText*)pObj; - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxStaticTextSerializer::CreateSTextWindowFn ); - - wxString label; - - if ( store.IsLoading() == FALSE ) - - label = pSTxt->GetLabel(); - - store.XchgWxStr( label ); - - if ( store.IsLoading() ) - - pSTxt->SetLabel( label ); -} - -void wxStaticTextSerializer::CreateSTextWindowFn( wxStaticText* pSTxt, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - pSTxt->Create( parent, id, "", pos, size, style ); -} - -/***** Implementation for class wxScrollBarSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxScrollBar, - wxScrollBarSerializer, - wxScrollBarSerializer::Serialize, - NO_CLASS_INIT ) - -void wxScrollBarSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxScrollBarSerializer::CreateScollBarWindowFn ); -} - -void wxScrollBarSerializer::CreateScollBarWindowFn( wxScrollBar* sbar, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - sbar->Create( parent, id, pos, size, style ); -} - -// FIXME:: serialization of tree control causes bunch of assertions on wxGtk - -#if 0 - -/***** Implementation for class wxTreeCtrlSerializer *****/ - -IMPLEMENT_SERIALIZER_CLASS( wxTreeCtrl, - wxTreeCtrlSerializer, - wxTreeCtrlSerializer::Serialize, - NO_CLASS_INIT ) - -static bool get_child_count( wxTreeItemId itemId, wxTreeCtrl* pTree ) -{ - long cookie; - - if ( !pTree->ItemHasChildren( itemId ) ) return 0; - - wxTreeItemId curId = pTree->GetFirstChild( itemId, cookie ); - - int cnt = 0; - - do - { - ++cnt; - - curId = pTree->GetNextChild( itemId, cookie ); - - } while( curId ); - - return cnt; -} - -void wxTreeCtrlSerializer::SerializeBranch( wxTreeItemId parentId, wxTreeCtrl* pTree, - wxObjectStorage& store, wxTreeItemId nextVisId, - int depth ) -{ - wxString text; - int childCnt; - int img; - bool isExpanded; - bool isVisible; - - if ( store.IsLoading() ) - { - store.XchgWxStr( text ); - store.XchgInt ( childCnt ); - store.XchgInt ( img ); - store.XchgBool ( isExpanded ); - store.XchgBool ( isVisible ); - - wxTreeItemId subBranchId = - ( depth == 0 ) - ? pTree->AddRoot( text, img ) - : pTree->AppendItem( parentId, text, img); - - // check if the item was labeled as first-visible - - if ( isVisible ) - - nextVisId = subBranchId; - - while ( childCnt-- ) - - SerializeBranch( subBranchId, pTree, store, nextVisId, depth+1 ); - - if ( isExpanded ) pTree->Expand( subBranchId ); - else pTree->Collapse( subBranchId ); - - } - else - { - // otherwise storing children of the branch - - text = pTree->GetItemText( parentId ); - childCnt = get_child_count( parentId, pTree ); - img = pTree->GetItemImage( parentId ); - isExpanded = pTree->IsExpanded( parentId ); - - if ( parentId == nextVisId ) - - isVisible = TRUE; - else - isVisible = FALSE; - - store.XchgWxStr( text ); - store.XchgInt ( childCnt ); - store.XchgInt ( img ); - store.XchgBool ( isExpanded ); - store.XchgBool ( isVisible ); - - long cookie; - - wxTreeItemId curId = pTree->GetFirstChild( parentId, cookie ); - - while ( childCnt-- ) - { - SerializeBranch( curId, pTree, store, nextVisId, -1 ); - - curId = pTree->GetNextChild( parentId, cookie ); - } - } -} - -void wxTreeCtrlSerializer::Serialize( wxObject* pObj, wxObjectStorage& store ) -{ - // FOR NOW::image id's and image list are not serialized! - // it should be provided as a initial reference (IR) - // if it presents. Currently only normal image list - // for normal items-states is set up - - wxTreeCtrl* pTree = (wxTreeCtrl*)pObj; - - wxWindowSerializer::DoSerialize( pObj, store, - (wndCreationFn)wxTreeCtrlSerializer::CreateTreeCtrlWindowFn ); - - wxTreeItemId nextVisId = (long)0; - int indent = 0; - int childCnt; - wxImageList* pILst; - - if ( store.IsLoading() ) - { - store.XchgInt( indent ); - - store.XchgObjPtr( (wxObject**) &(pILst) ); - - if ( pILst ) - - pTree->SetImageList( pILst ); - - store.XchgInt( childCnt ); - - while ( childCnt-- ) - - SerializeBranch( pTree->GetRootItem() , pTree, store, nextVisId, 0 ); - - // FIXME:: somehow this is no longer inmplemented in latest wxWin-2.0 - // pTree->ScrollTo( nextVisId ); - - pTree->SetIndent( indent ); - } - else - { - indent = pTree->GetIndent(); - - // FIXME:: somehow this is no longer inmplemented in latest wxWin-2.0 - // nextVisId = pTree->GetFirstVisibleItem(); - - nextVisId = pTree->GetRootItem(); - - pILst = pTree->GetImageList(); - - store.XchgInt( indent ); - - store.XchgObjPtr( (wxObject**) &(pILst) ); - - // otherwise storing children of the branch - - childCnt = get_child_count( pTree->GetRootItem(), pTree ); - - store.XchgInt( childCnt ); - - long cookie; - wxTreeItemId parent = pTree->GetRootItem(); - wxTreeItemId curId = pTree->GetFirstChild( parent, cookie ); - - while ( childCnt-- ) - { - SerializeBranch( curId, pTree, store, nextVisId, -1 ); - - curId = pTree->GetNextChild( parent, cookie ); - } - } -} - -void wxTreeCtrlSerializer::CreateTreeCtrlWindowFn( wxTreeCtrl* tree, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ) -{ - tree->Create( parent, id, pos, size, style ); -} - -#endif - -/***** Implementation for class wxIOStreamWrapper *****/ - -IMPLEMENT_DYNAMIC_CLASS( wxIOStreamWrapper, wxDataStreamBase ) - -void wxIOStreamWrapper::Close() -{ - // close previous stream if any - if ( mpStm ) - { - mpStm->flush(); - - if ( mOwnsStmObject ) - - delete mpStm; - - mOwnsStmObject = FALSE; - - mpStm = NULL; - } - - mStreamPos = 0; -} - -wxIOStreamWrapper::wxIOStreamWrapper() - : mpStm( NULL ), - mOwnsStmObject( FALSE ), - mStreamPos(0) -{ - mIsForInput = TRUE; // just a defaul -} - -bool wxIOStreamWrapper::Create( const char* fileName, bool forInput ) -{ - Close(); - - // FIXME:: if using default value of the last arg, linking breaks complaining - // about duplicated symbols - -#ifdef __WXMSW__ - mpStm = new fstream( fileName, - ( ( forInput == FALSE ) ? ios::out : ios::in ) | ios::binary, - 0 - ); -#else - mpStm = new fstream( fileName, - ( ( forInput == FALSE ) ? ios::out : ios::in ) | ios::binary - ); -#endif - - //((fstream*)mpStm)->close(); - - //delete ((fstream*)mpStm); - - mOwnsStmObject = TRUE; - - if ( !Good() ) - { - Close(); - return FALSE; - } - - mIsForInput = forInput; - - return TRUE; -} - -wxIOStreamWrapper::wxIOStreamWrapper( iostream& stm, bool forInput ) - : mOwnsStmObject( FALSE ) -{ - mpStm = &stm; - - // FIXME:: what about actual stream postion of attached stream? - mStreamPos = 0; - - mIsForInput = forInput; -} - -void wxIOStreamWrapper::Attach( iostream& stm, bool forInput ) -{ - Close(); - - mOwnsStmObject = FALSE; - - mpStm = &stm; - - // FIXME:: what about actual stream postion of attached stream? - mStreamPos = 0; - - mIsForInput = forInput; -} - -wxIOStreamWrapper::~wxIOStreamWrapper() -{ - Close(); -} - -bool wxIOStreamWrapper::StoreChar( char ch ) -{ - mpStm->write( &ch, sizeof(char) ); - - mStreamPos += sizeof(char); - - return Good(); -} - -bool wxIOStreamWrapper::StoreInt( int i ) -{ - mpStm->write( (char*)&i, sizeof(int) ); - - mStreamPos += sizeof(int); - - return Good(); -} - -bool wxIOStreamWrapper::StoreLong( long l ) -{ - mpStm->write( (char*)&l, sizeof(long) ); - - mStreamPos += sizeof(long); - - return Good(); -} - -bool wxIOStreamWrapper::StoreDouble( double d ) -{ - mpStm->write( (char*)&d, sizeof(double) ); - - mStreamPos += sizeof(double); - - return Good(); -} - -bool wxIOStreamWrapper::StoreBytes( void* bytes, int count ) -{ - mpStm->write( (char*)bytes, count ); - - mStreamPos += count; - - return Good(); -} - -bool wxIOStreamWrapper::LoadChar( char* pCh ) -{ - mpStm->read( pCh, sizeof(char) ); - - mStreamPos += sizeof(char); - - return Good(); -} - -bool wxIOStreamWrapper::LoadInt( int* pI ) -{ - mpStm->read( (char*)pI, sizeof(int) ); - - mStreamPos += sizeof(int); - - return Good(); -} - -bool wxIOStreamWrapper::LoadLong( long* pL ) -{ - mpStm->read( (char*)pL, sizeof(long) ); - - mStreamPos += sizeof(long); - - return Good(); -} - -bool wxIOStreamWrapper::LoadDouble( double* pD ) -{ - mpStm->read( (char*)pD, sizeof(double) ); - - mStreamPos += sizeof(double); - - return Good(); -} - -bool wxIOStreamWrapper::LoadBytes ( void* pBytes, int count ) -{ - mpStm->read( (char*)pBytes, count ); - - mStreamPos += count; - - return Good(); -} - -bool wxIOStreamWrapper::Flush() -{ - mpStm->flush(); - - return Good(); -} - -long wxIOStreamWrapper::GetStreamPos() -{ - return mStreamPos; -} - -bool wxIOStreamWrapper::Good() -{ - // FIXME FIXME:: somehow, when using ios::good/ios::bad, linking breaks complaining - // about "ios::bad" already defined in this object file... - - return TRUE; -} diff --git a/utils/framelayout/src/objstore.h b/utils/framelayout/src/objstore.h deleted file mode 100644 index 86616bd9ac..0000000000 --- a/utils/framelayout/src/objstore.h +++ /dev/null @@ -1,501 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo -// Author: Aleksandras Gluchovas -// Modified by: -// Created: 26/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef __OBJSTORE_G__ -#define __OBJSTORE_G__ - -#include "wx/object.h" -#include "wx/string.h" -#include "wx/list.h" -#include "wx/hash.h" - -#include "wx/window.h" -#include "wx/button.h" -#include "wx/textctrl.h" -#include "wx/treectrl.h" -#include "wx/dynarray.h" - -// abstract classes declared - -class wxDataStreamBase; -class wxSerializerBase; -class wxObjectStorage; - -// classes which implement the above interfaces - -class wxPointSerializer; -class wxSizeSerializer; -class wxRectSerializer; -class wxPenSerializer; -class wxBrushSerializer; - -class wxObjectListSerializer; - -class wxEvtHandlerSerializer; -class wxWindowSerializer; -class wxButtonSerializer; -class wxScrollBarSerializer; -class wxChoiceSerializer; -class wxTextCtrlSerializer; -class wxTreeCtrlSerializer; - - -class wxIOStreamWrapper; - -// prototypes for serialzatoin/initialization functions - -typedef void (*wxObjectSerializationFn) (wxObject*, wxObjectStorage& ); -typedef void (*wxObjectInitializationFn)(wxObject*); - -#define NO_CLASS_VER NULL -#define NO_CLASS_INIT NULL - -/* - * class conceptually simiar to wxClassInfo, execpt that it's static - * instances hold information about class-serializers rather then - * about the classes themselves. - */ - -class wxSerializerInfo -{ -public: - char* className; - - wxClassInfo* classInfo; // link to corresponding class-info object, - // established upon invocation of InitializeSerializers() - - wxObjectSerializationFn serFn; - wxObjectInitializationFn initFn; - - char* classVersion; - - static bool alreadyInitialized; - static wxSerializerInfo* first; - static wxHashTable serInfoHash; // classInfo <=> serializerInfo - - wxSerializerInfo* next; - wxSerializerInfo* nextByVersion; - - wxSerializerInfo( char* theClassName, - wxObjectSerializationFn serializationFun, - wxObjectInitializationFn initializationFun, - char* classVersionName - ); - - // looks up for serializers of the base classes (base1 and base2) - // of the given object invokes them if present - - void SerializeInherited ( wxObject* pObj, wxObjectStorage& store ); - void InitializeInherited( wxObject* pObj ); - - bool HasVersion() { return classVersion != NO_CLASS_VER; } - - bool HasInitializer() { return initFn != NO_CLASS_INIT; } - - // static methods - - static void InitializeSerializers(void); - - static wxSerializerInfo* FindSerializer( char* className ); -}; - -/* - * formal base class for all serializers, implemented as - * classes with static serialization/initialization methods - */ - -class wxSerializerBase {}; - -// macros for declaring and implementing serializers both as -// classes and as a pair of (serialize/init) functions - -#define DECLARE_SERIALIZER_CLASS(serializerName) \ - public:\ - static wxSerializerInfo info;; - -#define IMPLEMENT_SERIALIZER_CLASS( name, serializerName, serFn, initFn) \ - wxSerializerInfo \ - serializerName::info( #name, serFn, initFn, NO_CLASS_VER ); - -#define IMPLEMENT_SERIALIZER_FUNCTIONS( name, serFn, initFn) \ - wxSerializerInfo \ - static __gSerFnInfoFor##name( #name, serFn, initFn, NO_CLASS_VER ); - -// for serializers, which are dedicated for specific versions of persistant classes -// (further referred as "versioned" serializers) - -#define IMPLEMENT_SERIALIZER_CLASS_FOR_VERSION( name, serializerName, serFn, initFn, versionName) \ - wxSerializerInfo \ - serializerName::info( #name, serFn, initFn, #versionName ); - -#define IMPLEMENT_SERIALIZER_FUNCTIONS_FOR_VERSION( name, serializerName, serFn, initFn, versionName) \ - wxSerializerInfo \ - static __gSerFnInfoFor##name( #name, serFn, initFn, #versionName ); - -/* - * defines abstract inferface for data-stream objects, - * can be implemented as a wrapper class for already - * existing stream classes - */ - -class wxDataStreamBase : public wxObject -{ - DECLARE_ABSTRACT_CLASS( wxDataStreamBase ) -protected: - bool mIsForInput; - -public: - virtual bool StoreChar ( char ch ) = 0; - virtual bool StoreInt ( int i ) = 0; - virtual bool StoreLong ( long l ) = 0; - virtual bool StoreDouble( double d ) = 0; - virtual bool StoreBytes ( void* bytes, int count ) = 0; - - virtual bool LoadChar ( char *pCh ) = 0; - virtual bool LoadInt ( int *pI ) = 0; - virtual bool LoadLong ( long *pL ) = 0; - virtual bool LoadDouble( double *pD ) = 0; - virtual bool LoadBytes ( void *pBytes, int count ) = 0; - - virtual bool Flush() = 0; - - virtual long GetStreamPos() = 0; - - bool IsForInput() { return mIsForInput; } -}; - -/* - * class provides stream-based persistance service for - * classes derivated from wxObject, which are declared - * as dynamic classes. Relies on the presence of appropriate - * serializers for objects, which are being stored/loaded. - */ - -class wxObjectStorage : public wxObject -{ - DECLARE_DYNAMIC_CLASS( wxObjectStorage ) -protected: - wxDataStreamBase* mpStm; - bool mIsLoading; - - wxHashTable mRefHash; - - wxList mInitialRefs; - wxHashTable mInitialRefsHash; - long mInitialRefsCnt; - - wxList mNewObjs; - wxList mSerializersForNewObjs; - - bool mFinalizePending; - -protected: - wxSerializerBase* FindSerializer( wxObject* pForObj ); - - void ClearHashesAndLists(); - - virtual bool VersionsMatch( char* v1, char* v2 ); - - virtual wxSerializerInfo* FindSrzInfoForClass( wxClassInfo* pInfo ); - - void DoExchangeObject( wxObject* pInstance, wxSerializerInfo& srzInfo ); - - bool ExchangeObjectInfo( wxClassInfo** ppCInfo, wxSerializerInfo** ppSrz ); - - wxSerializerInfo* GetLatestSrzForObj( wxObject* pWxObj ); - -public: - // can be changed (with countion!) - - static char mVerSepartorCh; // default: '#' - static char mMinorMajorSepartorCh; // default: '-' - -public: - - wxObjectStorage(); - - wxObjectStorage( wxDataStreamBase& stm ); - - virtual ~wxObjectStorage(); - - // adds initial reference, objects referred by such reference - // are not serialized when storing. When loading, pointers which - // refere to these "inital objects" are set up to refere to - // objects provided in by AddInitailRef() method. - // - // NOTE:: initial references should be added always in the - // same order, since the seq-# of the reference is used - // as an alias to the real object while storing/loading - - void AddInitialRef( wxObject* pObjRef ); - - void ClearInitalRefs(); - - // init/reinit of object-storage - - void SetDataStream( wxDataStreamBase& stm ); - - // performs linkng of in-memory references after loading, or - // links in-stream references after storing has proceeded - - void Finalize(); - - // storage methods for basic types - - void XchgChar ( char& chObj ); - void XchgInt ( int& intObj ); - void XchgLong ( long& longObj ); - void XchgBool ( bool& boolObj ); - void XchgDouble ( double& doubleObj ); - void XchgCStr ( char* pCStrObj ); - void XchgUInt ( unsigned int& uI ); - void XchgSizeType( size_t& szObj ); - - void XchgObjList ( wxList& objList ); - void XchgObjArray ( wxBaseArray& objArr ); - void XchgLongArray( wxBaseArray& longArr ); - - // storage methods for objects and pointers to objects - - void XchgObj ( wxObject* pWxObj ); - void XchgObjPtr( wxObject** ppWxObj ); - - bool IsLoading() { return mIsLoading; } - - // storage methods for common wxWindows classes, - // which may or may not be dymaic, therefor use the - // below methods instead of XchgObj(..) - - void XchgWxStr ( wxString& str ); - void XchgWxSize ( wxSize& size ); - void XchgWxPoint( wxPoint& point ); - void XchgWxRect ( wxRect& rect ); -}; - -/* - * The below classes provide "curde" serialization for most - * common wxWindows objects, i.e. they discard the information - * which may be contained in the subclassed versions of these classes - * However, more "fine-grainded" serializers could be written - * to match these subclasses exactly. - */ - -class wxColourSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( wxColourSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -// NOTE:: currently "stipple" and "dashes" properties of the pen -// are not serialized - -class wxPenSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( wxPenSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -// NOTE:: currently "stipple" property of the brush is not serialized - -class wxBrushSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( wxBrushSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -// serializer for wxList, assuming that the list -// holds derivatives of wxObject. - -class wxObjectListSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( wxObjectListSerializer ); - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); -}; - -// generic serializer for classes derived from wxEvtHandler handler, -// assuming that they do not add any new properties to wxEvtHandler -// or these properties are transient - -class wxEvtHandlerSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( wxEvtHandlerSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void Initialize( wxObject* pObj ); -}; - -// serializer for generic wxWindow. Serializes position, size, id, -// reference to parent, list of children, style flags and name string. -// Could be used for serializing wxWindow and generic wxPanel objects. -// Separate serializers have to be written for control classes. - -class wxWindowSerializer : public wxEvtHandlerSerializer -{ - DECLARE_SERIALIZER_CLASS( wxWindowSerializer ); -public: - - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - // helpers, to ease the creation of serializers for derivatives of wxWindow - - typedef (*wndCreationFn)(wxWindow*, wxWindow*, const wxWindowID, - const wxPoint&, const wxSize&, long, const wxString& ); - - - static void DoSerialize( wxObject* pObj, wxObjectStorage& store, - wndCreationFn creationFn, bool refreshNow = TRUE - ); - - - static void CreateWindowFn( wxWindow* wnd, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ); - -}; - -class wxTextCtrlSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxTextCtrlSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void CreateTextCtrlWindowFn( wxTextCtrl* wnd, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ); -}; - -class wxButtonSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxButtonSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void CreateButtonWindowFn( wxButton* btn, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ); -}; - -class wxStaticTextSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxStaticTextSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void CreateSTextWindowFn( wxStaticText* pSTxt, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ); -}; - - -class wxScrollBarSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxScrollBarSerializer ); -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void CreateScollBarWindowFn( wxScrollBar* sbar, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ); -}; - -class wxTreeCtrlSerializer : public wxWindowSerializer -{ - DECLARE_SERIALIZER_CLASS( wxTreeCtrlSerializer ); - -protected: - static void SerializeBranch( wxTreeItemId parentId, wxTreeCtrl* pTree, - wxObjectStorage& store, wxTreeItemId nextVisId, - int depth ); - -public: - static void Serialize( wxObject* pObj, wxObjectStorage& store ); - - static void CreateTreeCtrlWindowFn( wxTreeCtrl* tree, wxWindow* parent, const wxWindowID id, - const wxPoint& pos, const wxSize& size, long style , - const wxString& name ); -}; - -// default implementations of interfaces, used by wxObjectStorage class -// -// FOR NOW:: methods do not yet perform byte-swaps for outputting/reading words in -// machine-independent format. Better solution would be to write wrapper -// around the "promissed" protable-data-stream class of wxWindows - -class wxIOStreamWrapper : public wxDataStreamBase -{ - DECLARE_DYNAMIC_CLASS( wxIOStreamWrapper ) -protected: - iostream* mpStm; - bool mOwnsStmObject; - long mStreamPos; // precalcualted stream postion, - // assuming that the actual stream object is not - // capable of telling postion of current get/put pointer - // (e.g. socket-stream) - void Close(); - -public: - - // default constructor - wxIOStreamWrapper(); - - // attach this wrapper to already exiting iostream object - - wxIOStreamWrapper( iostream& stm, bool forInput = TRUE ); - - // creates "fstream" object with the given file name in binary mode, - // returns FALSE, if stream creation failed - // - // The created fstream object is "owned" by this wrapper, - // thus it is destored during destruction of this object - - bool Create( const char* fileName, bool forInput = TRUE ); - - inline bool CreateForInput( const char* fileName ) - - { return Create( fileName, TRUE ); } - - inline bool CreateForOutput( const char* fileName ) - - { return Create( fileName, FALSE ); } - - // the same as in the second constructor, previousely used - // stream object is flushed and destroyed (if owned). - // The attached stream is not "owned" by this wrapper object - - void Attach( iostream& stm, bool forInput = TRUE ); - - virtual ~wxIOStreamWrapper(); - - virtual bool StoreChar ( char ch ); - virtual bool StoreInt ( int i ); - virtual bool StoreLong ( long l ); - virtual bool StoreDouble( double d ); - virtual bool StoreBytes ( void* bytes, int count ); - - virtual bool LoadChar ( char* pCh ); - virtual bool LoadInt ( int* pI ); - virtual bool LoadLong ( long* pL ); - virtual bool LoadDouble( double* pD ); - virtual bool LoadBytes ( void* pBytes, int count ); - - virtual bool Flush(); - - virtual long GetStreamPos(); - - bool Good(); -}; - -#endif diff --git a/utils/framelayout/src/pf_sample.cpp b/utils/framelayout/src/pf_sample.cpp deleted file mode 100644 index e0dcf9ee5e..0000000000 --- a/utils/framelayout/src/pf_sample.cpp +++ /dev/null @@ -1,286 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo -// Author: Aleksandras Gluchovas -// Modified by: -// Created: 26/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifdef __GNUG__ -#pragma implementation "pf_sample.h" -// #pragma interface -#endif - -// For compilers that support precompilation, includes "wx.h". -#include "wx/wxprec.h" - -#ifdef __BORLANDC__ -#pragma hdrstop -#endif - -#ifndef WX_PRECOMP -#include "wx/wx.h" -#endif - -#include "pf_sample.h" - -IMPLEMENT_DYNAMIC_CLASS( classA, wxObject ) -IMPLEMENT_DYNAMIC_CLASS( classB, wxObject ) - -IMPLEMENT_SERIALIZER_CLASS( classA, - classASerializer, - classASerializer::Serialize, - NO_CLASS_INIT ) - -IMPLEMENT_SERIALIZER_CLASS( classB, - classBSerializer, - classBSerializer::Serialize, - NO_CLASS_INIT ) - -// somehow original wxASSERT(0) statements get not compiled in... - -#undef wxASSERT -#define wxASSERT(x) if ( !(x) ) throw; - -extern notStorableClass gNotStorable; - -typedef notStorableClass* BackRefType; - -void test_storing( const char* fname, wxObjectStorage& store ) -{ - // create objects - - classA* pA = new classA(); - pA->x = 1; - - classB* pB = new classB(); - - pB->y = 2; - - // put cross-references - - pB->mpAObj = pA; - - pA->mpBObj = pB; - - // put back-references to not-storable obj - - pA->mpBackRef = &gNotStorable; - pB->mpBackRef = &gNotStorable; - - // create stream object for output - - wxIOStreamWrapper outFile; - - bool success = outFile.Create( fname, FALSE ); - - wxASSERT( success ); - - store.SetDataStream( outFile ); - - // store everything starting from "pA" object - - store.XchgObjPtr( (wxObject**) &pA ); - - // flushes stream - store.Finalize(); -} - -void test_loading( const char* fname, wxObjectStorage& store ) -{ - classA* pA = 0; - - // create stream-object for input - - wxIOStreamWrapper inFile; - - bool success = inFile.Create( fname, TRUE ); - - wxASSERT( success ); - - store.SetDataStream( inFile ); - - // load everything - - store.XchgObjPtr( (wxObject**) &pA ); - - // calls initializing procedures for serializer - // which provide them - - store.Finalize(); - - // short-cut - - classB* pB = pA->mpBObj; - - // assertain correctness of class members - - wxASSERT( pA->x == 1 ); - wxASSERT( pB->y == 2 ); - - // assertain correctness of cross-references - - wxASSERT( pA->mpBObj == pB ); - wxASSERT( pB->mpAObj == pA ); - - // asssertain correctness of inital references - - wxASSERT( pA->mpBackRef == &gNotStorable ); - wxASSERT( pB->mpBackRef == &gNotStorable ); -} - -void setup_inital_refs( wxObjectStorage& store ) -{ - store.AddInitialRef( (wxObject*) &gNotStorable ); -} - -// global instance of the object, which we do not want to store/load for -// some reason, even though other stored/loaded objects have refernces to it - -notStorableClass gNotStorable; - -void test_storing_of_list( const char* fname, wxObjectStorage& store ); -void test_loading_of_list( const char* fname, wxObjectStorage& store ); - -/*---------------------------*/ -/* Main testing function */ -/*---------------------------*/ - -void test_obj_storage() -{ - // NOTE:: for brevity, the heap clean-ups are omitted in the tests - - wxObjectStorage store; - - setup_inital_refs( store ); - - test_storing( "testdata.dat", store ); - test_loading( "testdata.dat", store ); - - test_storing_of_list( "testdata.dat", store ); - test_loading_of_list( "testdata.dat", store ); -} - -void test_storing_of_list( const char* fname, wxObjectStorage& store ) -{ - // create objects - - classA* pA = new classA(); - pA->x = 1; - - classB* pB = new classB(); - - pB->y = 2; - - // put cross-references - - pB->mpAObj = pA; - - pA->mpBObj = pB; - - // create list object - - wxList* pLst = new wxList; - - // put objects to the list - - wxNode* pNode = pLst->Append( pA ); - - pA->mpBackRef = (BackRefType)pNode; - - pNode = pLst->Append( pB ); - - pB->mpBackRef = (BackRefType)pNode; - - // create stream object for output - - wxIOStreamWrapper outFile; - - bool success = outFile.Create( fname, FALSE ); - - wxASSERT( success ); - - store.SetDataStream( outFile ); - - // store everything starting from "pLst" object - - store.XchgObjPtr( (wxObject**) &pLst ); - - // flushes stream - store.Finalize(); -} - -void test_loading_of_list( const char* fname, wxObjectStorage& store ) -{ - // create stream-object for input - - wxIOStreamWrapper inFile; - - bool success = inFile.Create( fname, TRUE ); - - wxASSERT( success ); - - store.SetDataStream( inFile ); - - // load everything - - wxList* pLst; - - // (NOTE:: serializers for wxList/wxNode is file objstore.cpp) - - store.XchgObjPtr( (wxObject**) &pLst ); - - // assertain correctness of list and it's contents - - wxASSERT( pLst->Number() == 2 ); - - int n = 0; - wxNode* pNode = pLst->First(); - - while( pNode ) - { - if ( n == 0 ) - { - classA* pA = (classA*)pNode->Data(); - - // assertain correctness of class members - - wxASSERT( pA->x == 1 ); - - // assertain correctness of cross-references - - wxASSERT( pA->mpBObj == (classB*)pNode->Next()->Data() ); - - // asssertain correctness of inital references - - wxASSERT( (wxNode*)pA->mpBackRef == pNode ) - } - if ( n == 1 ) - { - classB* pB = (classB*)pNode->Data(); - - // assertain correctness of class members - - wxASSERT( pB->y == 2 ); - - // assertain correctness of cross-references - - wxASSERT( pB->mpAObj == (classA*)pNode->Previous()->Data() ); - - // asssertain correctness of inital references - - wxASSERT( (wxNode*)pB->mpBackRef == pNode ) - } - - pNode = pNode->Next(); - ++n; - } - - // calls initializing procedures for serializer - // which provide them - - store.Finalize(); -} diff --git a/utils/framelayout/src/pf_sample.h b/utils/framelayout/src/pf_sample.h deleted file mode 100644 index 12bec2e7d5..0000000000 --- a/utils/framelayout/src/pf_sample.h +++ /dev/null @@ -1,86 +0,0 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: No names yet. -// Purpose: Contrib. demo -// Author: Aleksandras Gluchovas -// Modified by: -// Created: 26/10/98 -// RCS-ID: $Id$ -// Copyright: (c) Aleksandras Gluchovas -// Licence: wxWindows license -///////////////////////////////////////////////////////////////////////////// - -#ifndef __PF_SAMPLE_G__ -#define __PF_SAMPLE_G__ - -#include "objstore.h" - -// forward decl. -class classA; -class classB; - -// sample classes - -class notStorableClass -{}; - -class classA : public wxObject -{ - DECLARE_DYNAMIC_CLASS( classA ) -public: - - int x; - classB* mpBObj; - notStorableClass* mpBackRef; -}; - -class classB : public wxObject -{ - DECLARE_DYNAMIC_CLASS( classB ) -public: - - int y; - classA* mpAObj; - notStorableClass* mpBackRef; -}; - -// serialization handlers for the above classes - -class classASerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( classASerializer ) - - static void Serialize( wxObject* pObj, wxObjectStorage& store ) - { - classA* pA = (classA*)pObj; // cast - - store.XchgInt ( pA->x ); - store.XchgObjPtr( (wxObject**) &(pA->mpBObj) ); - store.XchgObjPtr( (wxObject**) &(pA->mpBackRef) ); - } -}; - -class classBSerializer : public wxSerializerBase -{ - DECLARE_SERIALIZER_CLASS( classBSerializer ) - - static void Serialize( wxObject* pObj, wxObjectStorage& store ) - { - classB* pB = (classB*)pObj; // cast - - store.XchgInt ( pB->y ); - store.XchgObjPtr( (wxObject**) &(pB->mpAObj) ); - store.XchgObjPtr( (wxObject**) &(pB->mpBackRef) ); - } -}; - -/*---------------------------*/ -/* Main testing function */ -/*---------------------------*/ - -// include this header and .cpp file into any of your -// wxWindows projects, and invoke the below function -// to peform tests - -void test_obj_storage(); - -#endif \ No newline at end of file -- 2.47.2