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
This commit is contained in:
J. Russell Smyth
1999-04-05 23:55:42 +00:00
parent c4b10e41c7
commit 21677c36c9
19 changed files with 44 additions and 3783 deletions

View File

@@ -43,7 +43,6 @@
#include "barhintspl.h" #include "barhintspl.h"
#include "hintanimpl.h" #include "hintanimpl.h"
#include "controlarea.h" #include "controlarea.h"
#include "objstore.h"
#include "dyntbar.h" #include "dyntbar.h"
#include "dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar #include "dyntbarhnd.h" // fl-dimension-handler for dynamic toolbar
@@ -99,8 +98,6 @@ bool MyApp::OnInit(void)
wxMenu *file_menu = new wxMenu; wxMenu *file_menu = new wxMenu;
wxMenu *active_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->AppendSeparator();
file_menu->Append( ID_AUTOSAVE, "&Auto Save Layouts", "save layouts on exit", TRUE ); 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_QUIT, MyFrame::OnQuit )
EVT_MENU( MINIMAL_ABOUT, MyFrame::OnAbout ) 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_SETTINGS, MyFrame::OnSettings )
EVT_MENU( ID_REMOVE, MyFrame::OnRemove ) EVT_MENU( ID_REMOVE, MyFrame::OnRemove )
EVT_MENU( ID_REMOVEALL, MyFrame::OnRemoveAll ) 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 idx1 = mImageList.Add( bmp1 );
int idx2 = mImageList.Add( bmp2 ); int idx2 = mImageList.Add( bmp2 );
// load configuation if present InitAboutBox();
if ( wxFileExists( "layouts_for_demo.dat" ) ) // create multiple layouts
{
wxCommandEvent evt;
this->OnLoad( evt );
}
else
{
InitAboutBox();
// 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 // hide others
mLayouts[i]->HideBarWindows(); 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 ***/ /*** event handlers ***/
@@ -366,65 +350,11 @@ bool MyFrame::OnClose(void)
this->Show(FALSE); this->Show(FALSE);
if ( (mAutoSave && mSavedAlready) || !mAutoSave );
else
{
wxCommandEvent evt;
this->OnStore(evt);
}
mAboutBox.Destroy(); mAboutBox.Destroy();
this->Destroy(); this->Destroy();
return TRUE; 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 );
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();
} }
void MyFrame::OnSettings( wxCommandEvent& event ) void MyFrame::OnSettings( wxCommandEvent& event )
@@ -499,14 +429,8 @@ void MyFrame::OnQuit( wxCommandEvent& event )
this->Show(FALSE); this->Show(FALSE);
if ( (mAutoSave && mSavedAlready) || !mAutoSave );
else
{
wxCommandEvent evt;
this->OnStore(evt);
}
Destroy(); Destroy();
} }
void set_dlg_font( wxWindow* pParent, wxFont& font ) void set_dlg_font( wxWindow* pParent, wxFont& font )
@@ -588,28 +512,21 @@ void MyFrame::OnChar( wxKeyEvent& event )
// "AI" :-) // "AI" :-)
wxMessageBox("There are only 3 layouts in this demo :-("); wxMessageBox("There are only 3 layouts in this demo :-(");
else else
if ( event.m_keyCode == WXK_TAB ) if ( event.m_keyCode == WXK_TAB )
{ {
// USEFUL TRICK:: avoids flickering of application's frame // USEFUL TRICK:: avoids flickering of application's frame
// when closing NN windows on exit: // when closing NN windows on exit:
this->Show(FALSE); this->Show(FALSE);
if ( (mAutoSave && mSavedAlready) || !mAutoSave ); Destroy();
else
{
wxCommandEvent evt;
this->OnStore(evt);
}
Destroy();
} }
else else
if ( event.m_keyCode == WXK_CONTROL ) if ( event.m_keyCode == WXK_CONTROL )
this->OnSettings( evt ); this->OnSettings( evt );
else else
event.Skip(); event.Skip();
} }
void MyFrame::OnSayItsOk( wxCommandEvent& event ) void MyFrame::OnSayItsOk( wxCommandEvent& event )
@@ -924,7 +841,6 @@ wxWindow* MyFrame::CreateDevLayout( wxFrameLayout& layout, wxWindow* pParent )
// functions from "wxinfo.h" // functions from "wxinfo.h"
::wxCreateClassInfoTree( pClassView, cinfId, 1 ); ::wxCreateClassInfoTree( pClassView, cinfId, 1 );
::wxCreateSerializerInfoTree( pClassView, serId, 1 );
#ifdef __WXMSW__ #ifdef __WXMSW__
// (default arg anyway) // (default arg anyway)
@@ -1217,32 +1133,6 @@ void MyFrame::ActivateLayout( int layoutNo )
SyncMenuBarItems(); 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__ #ifdef __HACK_MY_MSDEV40__
////////////// new 2.0-magic (linker errors...) //////////////// ////////////// new 2.0-magic (linker errors...) ////////////////

View File

@@ -41,7 +41,6 @@
#define THIRD_LAYOUT 2 #define THIRD_LAYOUT 2
class wxFrameLayout; class wxFrameLayout;
class wxObjectStorage;
// FOR NOW:: // FOR NOW::
typedef wxPanel MyTestPanel; typedef wxPanel MyTestPanel;
@@ -50,15 +49,15 @@ typedef wxPanel MyTestPanel;
class MyApp: public wxApp class MyApp: public wxApp
{ {
public: public:
bool OnInit(void); bool OnInit(void);
}; };
// Define a new frame type // Define a new frame type
class MyFrame: public wxFrame class MyFrame: public wxFrame
{ {
protected: protected:
wxFrameLayout* mLayouts[MAX_LAYOUTS]; wxFrameLayout* mLayouts[MAX_LAYOUTS];
@@ -100,7 +99,6 @@ protected:
void ActivateLayout( int layoutNo ); void ActivateLayout( int layoutNo );
void SerializeMe( wxObjectStorage& store );
public: /* public */ public: /* public */
@@ -115,9 +113,6 @@ public: /* public */
bool OnClose(void); bool OnClose(void);
void OnLoad( wxCommandEvent& event );
void OnStore( wxCommandEvent& event );
void OnAutoSave( wxCommandEvent& event );
void OnQuit(wxCommandEvent& event); void OnQuit(wxCommandEvent& event);
void OnAbout(wxCommandEvent& event); void OnAbout(wxCommandEvent& event);
void OnSettings( wxCommandEvent& event ); void OnSettings( wxCommandEvent& event );

View File

@@ -135,25 +135,4 @@ void wxCreateClassInfoTree( wxTreeCtrl* pTree,
} while( nHanged != 0 ); } 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;
}
}

View File

@@ -15,7 +15,6 @@
#include "wx/object.h" #include "wx/object.h"
#include "wx/treectrl.h" #include "wx/treectrl.h"
#include "objstore.h"
/* /*
* creates tree with hierarchically cauptured * creates tree with hierarchically cauptured
@@ -33,9 +32,4 @@ void wxCreateClassInfoTree( wxTreeCtrl* pTree,
* NOTE:: "objstore.cpp" should be compiled in * NOTE:: "objstore.cpp" should be compiled in
*/ */
void wxCreateSerializerInfoTree( wxTreeCtrl* pTree, // existing tree control
wxTreeItemId parentBranchId,
long classImageNo = -1 // (-1) - text only
);
#endif #endif

View File

@@ -26,7 +26,6 @@
#endif #endif
#include "controlbar.h" #include "controlbar.h"
#include "objstore.h"
// plugins used // plugins used
#include "barhintspl.h" #include "barhintspl.h"
@@ -58,7 +57,6 @@ protected:
wxWindow* mpClientWnd; wxWindow* mpClientWnd;
wxPanel* mpInternalFrm; wxPanel* mpInternalFrm;
void SerializeMe( wxObjectStorage& store );
wxTextCtrl* CreateTextCtrl( const wxString& value ); wxTextCtrl* CreateTextCtrl( const wxString& value );
@@ -67,8 +65,6 @@ public:
MyFrame( wxWindow* parent, char *title ); MyFrame( wxWindow* parent, char *title );
~MyFrame(); ~MyFrame();
void OnLoad( wxCommandEvent& event );
void OnStore( wxCommandEvent& event );
void OnQuit( wxCommandEvent& event ); void OnQuit( wxCommandEvent& event );
bool OnClose(void) { return TRUE; } bool OnClose(void) { return TRUE; }
@@ -112,8 +108,6 @@ bool MyApp::OnInit(void)
BEGIN_EVENT_TABLE(MyFrame, wxFrame) BEGIN_EVENT_TABLE(MyFrame, wxFrame)
EVT_MENU( ID_LOAD, MyFrame::OnLoad )
EVT_MENU( ID_STORE, MyFrame::OnStore )
EVT_MENU( ID_QUIT, MyFrame::OnQuit ) EVT_MENU( ID_QUIT, MyFrame::OnQuit )
END_EVENT_TABLE() END_EVENT_TABLE()
@@ -204,46 +198,6 @@ wxTextCtrl* MyFrame::CreateTextCtrl( const wxString& value )
return pCtrl; 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 ) void MyFrame::OnQuit( wxCommandEvent& event )
{ {
Show( FALSE ); // TRICK:: hide it, to avoid flickered destruction Show( FALSE ); // TRICK:: hide it, to avoid flickered destruction
@@ -251,21 +205,6 @@ void MyFrame::OnQuit( wxCommandEvent& event )
Close(TRUE); 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__ #ifdef __HACK_MY_MSDEV40__
////////////// new 2.0-magic (linker errors...) //////////////// ////////////// new 2.0-magic (linker errors...) ////////////////

View File

@@ -63,8 +63,6 @@ bool MyApp::OnInit(void)
wxMenu *file_menu = new wxMenu; 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" ); file_menu->Append( NEW_TEST_EXIT, "E&xit" );
wxMenuBar *menu_bar = new wxMenuBar; wxMenuBar *menu_bar = new wxMenuBar;
@@ -100,52 +98,10 @@ BEGIN_EVENT_TABLE( MyFrame, wxFrame )
// EVT_CHAR_HOOK(MyFrame::OnKeyDown) // EVT_CHAR_HOOK(MyFrame::OnKeyDown)
// EVT_PAINT( MyFrame::OnPaint ) // 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 ) EVT_MENU( NEW_TEST_EXIT, MyFrame::OnExit )
END_EVENT_TABLE() 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 ) void MyFrame::OnExit( wxCommandEvent& event )
{ {
Destroy(); Destroy();
@@ -180,9 +136,6 @@ MyFrame::MyFrame(wxFrame *frame)
mpClientWnd = CreateTextCtrl( "Client window" ); mpClientWnd = CreateTextCtrl( "Client window" );
mStore.AddInitialRef( this );
mStore.AddInitialRef( mpInternalFrm );
//mStore.AddInitialRef( mpClientWnd );
mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd ); mpLayout = new wxFrameLayout( mpInternalFrm, mpClientWnd );

View File

@@ -1,7 +1,6 @@
#ifndef __NEW_TEST_G__ #ifndef __NEW_TEST_G__
#define __NEW_TEST_G__ #define __NEW_TEST_G__
#include "objstore.h"
#include "wx/panel.h" #include "wx/panel.h"
// Define a new application type // Define a new application type
@@ -13,7 +12,6 @@ class MyApp: public wxApp
class MyFrame: public wxFrame class MyFrame: public wxFrame
{ {
public: public:
wxObjectStorage mStore;
wxFrameLayout* mpLayout; wxFrameLayout* mpLayout;
wxTextCtrl* mpClientWnd; wxTextCtrl* mpClientWnd;
@@ -27,15 +25,11 @@ public:
bool OnClose(void) { Show(FALSE); return TRUE; } bool OnClose(void) { Show(FALSE); return TRUE; }
void OnLoad( wxCommandEvent& event );
void OnSave( wxCommandEvent& event );
void OnExit( wxCommandEvent& event ); void OnExit( wxCommandEvent& event );
DECLARE_EVENT_TABLE() DECLARE_EVENT_TABLE()
}; };
#define NEW_TEST_SAVE 1101 #define NEW_TEST_EXIT 1101
#define NEW_TEST_LOAD 1102
#define NEW_TEST_EXIT 1103
#endif #endif

View File

@@ -28,17 +28,14 @@ antiflickpl.cpp \
bardragpl.cpp \ bardragpl.cpp \
barhintspl.cpp \ barhintspl.cpp \
cbcustom.cpp \ cbcustom.cpp \
cbstore.cpp \
controlarea.cpp \ controlarea.cpp \
controlbar.cpp \ controlbar.cpp \
dyntbar.cpp \ dyntbar.cpp \
dyntbarhnd.cpp \ dyntbarhnd.cpp \
frmview.cpp \
garbagec.cpp \ garbagec.cpp \
gcupdatesmgr.cpp \ gcupdatesmgr.cpp \
hintanimpl.cpp \ hintanimpl.cpp \
newbmpbtn.cpp \ newbmpbtn.cpp \
objstore.cpp \
panedrawpl.cpp \ panedrawpl.cpp \
rowdragpl.cpp \ rowdragpl.cpp \
rowlayoutpl.cpp \ rowlayoutpl.cpp \

View File

@@ -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 );
}

View File

@@ -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

View File

@@ -12,10 +12,10 @@ WXDIR = $(WXWIN)
LIBTARGET=$(WXDIR)\lib\fl.lib LIBTARGET=$(WXDIR)\lib\fl.lib
OBJECTS = antiflickpl.obj bardragpl.obj barhintspl.obj cbcustom.obj\ 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\ garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\
objstore.obj panedrawpl.obj pf_sample.obj rowdragpl.obj rowlayoutpl.obj\ panedrawpl.obj rowdragpl.obj rowlayoutpl.obj\
settingsdlg.obj toolwnd.obj updatesmgr.obj wxinfo.obj toolwnd.obj updatesmgr.obj
!include $(WXDIR)\src\makelib.b32 !include $(WXDIR)\src\makelib.b32

View File

@@ -12,9 +12,9 @@ WXDIR = ../../..
LIBTARGET=$(WXDIR)/lib/libfl.a LIBTARGET=$(WXDIR)/lib/libfl.a
OBJECTS = antiflickpl.o bardragpl.o barhintspl.o cbcustom.o\ OBJECTS = antiflickpl.o bardragpl.o barhintspl.o cbcustom.o\
cbstore.o controlarea.o controlbar.o dyntbar.o dyntbarhnd.o\ controlarea.o controlbar.o dyntbar.o dyntbarhnd.o\
frmview.o garbagec.o gcupdatesmgr.o hintanimpl.o newbmpbtn.o\ garbagec.o gcupdatesmgr.o hintanimpl.o newbmpbtn.o\
objstore.o panedrawpl.o rowdragpl.o rowlayoutpl.o\ panedrawpl.o rowdragpl.o rowlayoutpl.o\
toolwnd.o updatesmgr.o toolwnd.o updatesmgr.o
include $(WXDIR)/src/makelib.g95 include $(WXDIR)/src/makelib.g95

View File

@@ -17,25 +17,19 @@ antiflickpl.cpp \
bardragpl.cpp \ bardragpl.cpp \
barhintspl.cpp \ barhintspl.cpp \
cbcustom.cpp \ cbcustom.cpp \
cbstore.cpp \
controlarea.cpp \ controlarea.cpp \
controlbar.cpp \ controlbar.cpp \
dyntbar.cpp \ dyntbar.cpp \
dyntbarhnd.cpp \ dyntbarhnd.cpp \
frmview.cpp \
garbagec.cpp \ garbagec.cpp \
gcupdatesmgr.cpp \ gcupdatesmgr.cpp \
hintanimpl.cpp \ hintanimpl.cpp \
newbmpbtn.cpp \ newbmpbtn.cpp \
objstore.cpp \
panedrawpl.cpp \ panedrawpl.cpp \
pf_sample.cpp \
rowdragpl.cpp \ rowdragpl.cpp \
rowlayoutpl.cpp \ rowlayoutpl.cpp \
settingsdlg.cpp \
toolwnd.cpp \ toolwnd.cpp \
updatesmgr.cpp \ updatesmgr.cpp \
wxinfo.cpp
all: $(FLLIB) all: $(FLLIB)

View File

@@ -19,9 +19,9 @@ THISDIR = $(FLDIR)\src
LIBTARGET=$(WXDIR)\lib\fl.lib LIBTARGET=$(WXDIR)\lib\fl.lib
OBJECTS = antiflickpl.obj bardragpl.obj barhintspl.obj cbcustom.obj\ 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\ garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\
objstore.obj panedrawpl.obj pf_sample.obj rowdragpl.obj rowlayoutpl.obj\ panedrawpl.obj rowdragpl.obj rowlayoutpl.obj\
toolwnd.obj updatesmgr.obj toolwnd.obj updatesmgr.obj
!include $(WXDIR)\src\makelib.vc !include $(WXDIR)\src\makelib.vc

View File

@@ -15,10 +15,10 @@ LNK = $(name).lnk
IFLAGS = -i=$(WXINC) -i=$(WXBASEINC) -i=..\..\mfutils\src -i=..\..\prologio\src IFLAGS = -i=$(WXINC) -i=$(WXBASEINC) -i=..\..\mfutils\src -i=..\..\prologio\src
OBJECTS = antiflickpl.obj bardragpl.obj barhintspl.obj cbcustom.obj\ 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\ frmview.obj garbagec.obj gcupdatesmgr.obj hintanimpl.obj newbmpbtn.obj\
objstore.obj panedrawpl.obj pf_sample.obj rowdragpl.obj rowlayoutpl.obj\ panedrawpl.obj rowdragpl.obj rowlayoutpl.obj\
settingsdlg.obj toolwnd.obj updatesmgr.obj wxinfo.obj toolwnd.obj updatesmgr.obj
all: $(OBJECTSLIB) all: $(OBJECTSLIB)

File diff suppressed because it is too large Load Diff

View File

@@ -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

View File

@@ -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();
}

View File

@@ -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