1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Contrib. demo
4 // Author: Aleksandras Gluchovas
8 // Copyright: (c) Aleksandras Gluchovas
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "cbstore.h"
17 // For compilers that support precompilation, includes "wx.h".
18 #include "wx/wxprec.h"
30 /***** Implementation for class wxFrameLayoutSerializer *****/
32 IMPLEMENT_SERIALIZER_CLASS( wxFrameLayout
,
33 wxFrameLayoutSerializer
,
34 wxFrameLayoutSerializer::Serialize
,
35 wxFrameLayoutSerializer::Initialize
)
37 void wxFrameLayoutSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
39 // wxFrameLayout is a "kind of" wxEvtHandler - perform
40 // serialization of the base class first
42 info
.SerializeInherited( pObj
, store
);
44 wxFrameLayout
* pLayout
= (wxFrameLayout
*)pObj
;
46 store
.XchgObjPtr( (wxObject
**) &pLayout
->mpFrame
);
47 store
.XchgObjPtr( (wxObject
**) &pLayout
->mpFrameClient
);
49 for( int i
= 0; i
!= MAX_PANES
; ++i
)
51 store
.XchgObjPtr( (wxObject
**) &(pLayout
->mPanes
[i
]) );
53 // plugins are serialized _after_ panes
55 store
.XchgObjPtr( (wxObject
**) &(pLayout
->mpTopPlugin
) );
57 // and the rest will follow...
59 store
.XchgObjArray( pLayout
->mAllBars
);
61 store
.XchgObjList( pLayout
->mBarSpyList
);
63 store
.XchgObjList( pLayout
->mFloatedFrames
);
65 store
.XchgObjPtr( (wxObject
**) &(pLayout
->mpUpdatesMgr
) );
67 store
.XchgBool( pLayout
->mFloatingOn
);
69 store
.XchgWxPoint( pLayout
->mNextFloatedWndPos
);
71 store
.XchgWxSize( pLayout
->mFloatingPosStep
);
73 store
.XchgObj( (wxObject
*) &pLayout
->mDarkPen
);
74 store
.XchgObj( (wxObject
*) &pLayout
->mLightPen
);
75 store
.XchgObj( (wxObject
*) &pLayout
->mGrayPen
);
76 store
.XchgObj( (wxObject
*) &pLayout
->mBlackPen
);
77 store
.XchgObj( (wxObject
*) &pLayout
->mBorderPen
);
80 void wxFrameLayoutSerializer::Initialize( wxObject
* pObj
)
82 wxFrameLayout
* pLayout
= (wxFrameLayout
*)pObj
;
84 // wxFrameLayout is a "kind of" wxEvtHandler - perform
85 // wxEvtHandler-specific initialization first
87 info
.InitializeInherited( pObj
);
89 //pLayout->RecalcLayout( TRUE );
92 /***** Implementation for class wxFrameLayoutSerializer *****/
94 IMPLEMENT_SERIALIZER_CLASS( cbBarSpy
,
96 cbBarSpySerializer::Serialize
,
97 cbBarSpySerializer::Initialize
)
99 void cbBarSpySerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
101 // cbBarSpy is a "kind of" wxEvtHandler - perform
102 // serialization of the base class first
104 info
.SerializeInherited( pObj
, store
);
106 cbBarSpy
* pSpy
= (cbBarSpy
*)pObj
;
108 store
.XchgObjPtr( (wxObject
**) &(pSpy
->mpLayout
) );
109 store
.XchgObjPtr( (wxObject
**) &(pSpy
->mpBarWnd
) );
112 void cbBarSpySerializer::Initialize( wxObject
* pObj
)
114 // cbBarSpySerializer is a "kind of" wxEvtHandler - perform
115 // wxEvtHandler-specific initialization first
117 info
.InitializeInherited( pObj
);
119 cbBarSpy
* pSpy
= (cbBarSpy
*)pObj
;
121 // is done by wxEventHandler's serializer already!
123 //pSpy->mpBarWnd->PushEventHandler( pSpy );
126 /***** Implementation for class cbBarDimHandlerBaseSerializer *****/
128 IMPLEMENT_SERIALIZER_CLASS( cbBarDimHandlerBase
,
129 cbBarDimHandlerBaseSerializer
,
130 cbBarDimHandlerBaseSerializer::Serialize
,
133 void cbBarDimHandlerBaseSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
135 cbBarDimHandlerBase
* pHandler
= (cbBarDimHandlerBase
*)pObj
;
137 store
.XchgInt( pHandler
->mRefCount
);
140 /***** Implementation for class cbDimInfoSerializer *****/
142 IMPLEMENT_SERIALIZER_CLASS( cbDimInfo
,
144 cbDimInfoSerializer::Serialize
,
147 void cbDimInfoSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
149 cbDimInfo
* pInfo
= (cbDimInfo
*)pObj
;
153 for( i
= 0; i
!= MAX_BAR_STATES
; ++i
)
155 store
.XchgWxSize( pInfo
->mSizes
[i
] );
157 for( i
= 0; i
!= MAX_BAR_STATES
; ++i
)
159 store
.XchgWxRect( pInfo
->mBounds
[i
] );
161 store
.XchgInt ( pInfo
->mLRUPane
);
162 store
.XchgInt ( pInfo
->mHorizGap
);
163 store
.XchgInt ( pInfo
->mVertGap
);
165 store
.XchgBool ( pInfo
->mIsFixed
);
166 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpHandler
) );
169 /***** Implementation for class cbRowInfoSerializer *****/
171 IMPLEMENT_SERIALIZER_CLASS( cbRowInfo
,
173 cbRowInfoSerializer::Serialize
,
176 void cbRowInfoSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
178 cbRowInfo
* pInfo
= (cbRowInfo
*)pObj
;
180 store
.XchgObjArray( pInfo
->mBars
);
182 store
.XchgLongArray( pInfo
->mSavedRatios
);
184 store
.XchgObjPtr( (wxObject
**) &pInfo
->mpNext
);
185 store
.XchgObjPtr( (wxObject
**) &pInfo
->mpPrev
);
186 store
.XchgObjPtr( (wxObject
**) &pInfo
->mpExpandedBar
);
188 store
.XchgBool ( pInfo
->mHasUpperHandle
);
189 store
.XchgBool ( pInfo
->mHasLowerHandle
);
190 store
.XchgBool ( pInfo
->mHasOnlyFixedBars
);
191 store
.XchgInt ( pInfo
->mNotFixedBarsCnt
);
193 // other properties of the row are transient, since
194 // they are reclaculated each time the frame is resized/activated
197 /***** Implementation for class cbBarInfoSerializer *****/
199 IMPLEMENT_SERIALIZER_CLASS( cbBarInfo
,
201 cbBarInfoSerializer::Serialize
,
204 void cbBarInfoSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
206 cbBarInfo
* pInfo
= (cbBarInfo
*)pObj
;
208 store
.XchgWxStr ( pInfo
->mName
);
210 store
.XchgWxRect( pInfo
->mBounds
);
212 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpRow
) );
214 store
.XchgBool ( pInfo
->mHasLeftHandle
);
215 store
.XchgBool ( pInfo
->mHasRightHandle
);
217 store
.XchgObj ( (wxObject
*) &(pInfo
->mDimInfo
) );
219 store
.XchgInt ( pInfo
->mState
);
220 store
.XchgInt ( pInfo
->mAlignment
);
221 store
.XchgInt ( pInfo
->mRowNo
);
223 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpBarWnd
) );
225 store
.XchgDouble( pInfo
->mLenRatio
);
227 store
.XchgWxPoint( pInfo
->mPosIfFloated
);
229 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpNext
) );
230 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpPrev
) );
232 // other properties of the bar are transient, since
233 // they are reclaculated each time the frame is resized/activated
236 /***** Implementation for class cbCommonPanePropertiesSerializer *****/
238 IMPLEMENT_SERIALIZER_CLASS( cbCommonPaneProperties
,
239 cbCommonPanePropertiesSerializer
,
240 cbCommonPanePropertiesSerializer::Serialize
,
243 void cbCommonPanePropertiesSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
245 cbCommonPaneProperties
* pProps
= (cbCommonPaneProperties
*)pObj
;
247 store
.XchgBool ( pProps
->mRealTimeUpdatesOn
);
248 store
.XchgBool ( pProps
->mOutOfPaneDragOn
);
249 store
.XchgBool ( pProps
->mExactDockPredictionOn
);
250 store
.XchgBool ( pProps
->mNonDestructFirctionOn
);
252 store
.XchgBool ( pProps
->mShow3DPaneBorderOn
);
254 store
.XchgBool ( pProps
->mBarFloatingOn
);
255 store
.XchgBool ( pProps
->mRowProportionsOn
);
256 store
.XchgBool ( pProps
->mColProportionsOn
);
257 store
.XchgBool ( pProps
->mBarCollapseIconsOn
);
258 store
.XchgBool ( pProps
->mBarDragHintsOn
);
260 store
.XchgWxSize( pProps
->mMinCBarDim
);
262 store
.XchgInt( pProps
->mResizeHandleSize
);
265 /***** Implementation for class *****/
267 IMPLEMENT_SERIALIZER_CLASS( cbDockPane
,
268 cbDockPaneSerializer
,
269 cbDockPaneSerializer::Serialize
,
272 void cbDockPaneSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
274 cbDockPane
* pPane
= (cbDockPane
*)pObj
;
276 store
.XchgObj( (wxObject
*) &(pPane
->mProps
) );
278 store
.XchgInt( pPane
->mLeftMargin
);
279 store
.XchgInt( pPane
->mRightMargin
);
280 store
.XchgInt( pPane
->mTopMargin
);
281 store
.XchgInt( pPane
->mBottomMargin
);
283 store
.XchgInt( pPane
->mAlignment
);
285 store
.XchgObjArray( pPane
->mRows
);
286 store
.XchgObjPtr ( (wxObject
**) &(pPane
->mpLayout
) );
289 /***** Implementation for class cbUpdatesManagerBaseSerializer *****/
291 IMPLEMENT_SERIALIZER_CLASS( cbUpdatesManagerBase
,
292 cbUpdatesManagerBaseSerializer
,
293 cbUpdatesManagerBaseSerializer::Serialize
,
296 void cbUpdatesManagerBaseSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
298 cbUpdatesManagerBase
* pMgr
= (cbUpdatesManagerBase
*)pObj
;
300 // only back-reference to layout "engine"
301 store
.XchgObjPtr( (wxObject
**) &(pMgr
->mpLayout
) );
304 /***** Implementation for class cbPluginBaseSerializer *****/
306 IMPLEMENT_SERIALIZER_CLASS( cbPluginBase
,
307 cbPluginBaseSerializer
,
308 cbPluginBaseSerializer::Serialize
,
309 cbPluginBaseSerializer::Initialize
)
311 void cbPluginBaseSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
313 // plugin is "a kind" of wxEvtHandler - perform
314 // serialization of the base class first
316 info
.SerializeInherited( pObj
, store
);
318 cbPluginBase
* pPlugin
= (cbPluginBase
*)pObj
;
320 store
.XchgObjPtr( (wxObject
**) &(pPlugin
->mpLayout
) );
322 store
.XchgInt( pPlugin
->mPaneMask
);
325 void cbPluginBaseSerializer::Initialize( wxObject
* pObj
)
327 // plugins need extra-initialization, after they are
328 // attached to the frame-layout and pane mask is set
330 ( (cbPluginBase
*)pObj
)->OnInitPlugin();
333 /***** Implementation for class cbRowDragPluginSerializer *****/
335 IMPLEMENT_SERIALIZER_CLASS( cbRowDragPlugin
,
336 cbRowDragPluginSerializer
,
337 cbRowDragPluginSerializer::Serialize
,
338 cbRowDragPluginSerializer::Initialize
)
340 void cbRowDragPluginSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
342 // plugin is "a kind" of cbPluginBaseSerializer - perform
343 // serialization of the base class first
345 info
.SerializeInherited( pObj
, store
);
347 cbRowDragPlugin
* pPlugin
= (cbRowDragPlugin
*)pObj
;
349 store
.XchgInt( pPlugin
->mSvTopMargin
);
350 store
.XchgInt( pPlugin
->mSvBottomMargin
);
351 store
.XchgInt( pPlugin
->mSvLeftMargin
);
352 store
.XchgInt( pPlugin
->mSvRightMargin
);
354 store
.XchgObjList( pPlugin
->mHiddenBars
);
357 void cbRowDragPluginSerializer::Initialize( wxObject
* pObj
)
359 // plugins need extra-initialization, after they are
360 // attached to the frame-layout and pane mask is set
362 ( (cbPluginBase
*)pObj
)->OnInitPlugin();
365 /***** Implementation for class cbHiddenBarInfoSerializer *****/
367 IMPLEMENT_SERIALIZER_CLASS( cbHiddenBarInfo
,
368 cbHiddenBarInfoSerializer
,
369 cbHiddenBarInfoSerializer::Serialize
,
372 void cbHiddenBarInfoSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
374 cbHiddenBarInfo
* pInfo
= (cbHiddenBarInfo
*)pObj
;
376 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpBar
) );
377 store
.XchgInt( pInfo
->mRowNo
);
378 store
.XchgInt( pInfo
->mIconNo
);
379 store
.XchgInt( pInfo
->mAlignment
);
382 /***** Implementation for class cbFloatedBarWindowSerializer *****/
384 IMPLEMENT_SERIALIZER_CLASS( cbFloatedBarWindow
,
385 cbFloatedBarWindowSerializer
,
386 cbFloatedBarWindowSerializer::Serialize
,
387 cbFloatedBarWindowSerializer::Initialize
)
389 static wxString __gTmpFrameTitle
;
391 void cbFloatedBarWindowSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
393 cbFloatedBarWindow
* pWnd
= (cbFloatedBarWindow
*)pObj
;
395 if ( store
.IsLoading() == FALSE
)
397 __gTmpFrameTitle
= pWnd
->GetTitle();
399 store
.XchgWxStr( __gTmpFrameTitle
);
401 // cbFloatedBarWindow is "a kind" of wxWindow - perform
402 // serialization of the base class first
404 wxWindowSerializer::DoSerialize( pObj
, store
,
405 (wndCreationFn
)cbFloatedBarWindowSerializer::CreateFloatedBarWindowFn
);
407 store
.XchgObjPtr( (wxObject
**) &(pWnd
->mpBar
) );
408 store
.XchgObjPtr( (wxObject
**) &(pWnd
->mpLayout
) );
409 store
.XchgObjPtr( (wxObject
**) &(pWnd
->mpClientWnd
) );
412 void cbFloatedBarWindowSerializer::CreateFloatedBarWindowFn( cbFloatedBarWindow
* fbar
, wxWindow
* parent
, const wxWindowID id
,
413 const wxPoint
& pos
, const wxSize
& size
, long style
,
414 const wxString
& name
)
416 fbar
->Create( parent
, id
, __gTmpFrameTitle
, pos
, size
, style
);
419 void cbFloatedBarWindowSerializer::Initialize( wxObject
* pObj
)
424 /***** Implementation for class wxNewBitmapButtonSerializer *****/
426 IMPLEMENT_SERIALIZER_CLASS( wxNewBitmapButton
,
427 wxNewBitmapButtonSerializer
,
428 wxNewBitmapButtonSerializer::Serialize
,
429 wxNewBitmapButtonSerializer::Initialize
)
431 void wxNewBitmapButtonSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
433 wxNewBitmapButton
* pBtn
= (wxNewBitmapButton
*)pObj
;
435 store
.XchgInt ( pBtn
->mTextToLabelGap
);
436 store
.XchgInt ( pBtn
->mMarginX
);
437 store
.XchgInt ( pBtn
->mMarginY
);
438 store
.XchgInt ( pBtn
->mTextAlignment
);
439 store
.XchgBool( pBtn
->mIsFlat
);
440 store
.XchgBool( pBtn
->mIsSticky
);
442 store
.XchgWxStr( pBtn
->mLabelText
);
443 store
.XchgWxStr( pBtn
->mImageFileName
);
444 store
.XchgInt ( pBtn
->mImageFileType
);
446 store
.XchgInt( pBtn
->mFiredEventType
);
448 // cbFloatedBarWindow is "a kind" of wxWindow - perform
449 // serialization of the base class
451 wxWindowSerializer::DoSerialize( pObj
, store
,
452 (wndCreationFn
)wxNewBitmapButtonSerializer::CreateNewBmpBtnWindowFn
);
455 void wxNewBitmapButtonSerializer::CreateNewBmpBtnWindowFn( wxNewBitmapButton
* btn
, wxWindow
* parent
, const wxWindowID id
,
456 const wxPoint
& pos
, const wxSize
& size
, long style
,
457 const wxString
& name
)
459 btn
->Create( parent
, id
, pos
, size
, style
, name
);
462 btn
->mIsCreated
= FALSE
;
466 void wxNewBitmapButtonSerializer::Initialize( wxObject
* pObj
)
469 wxNewBitmapButton
* pBtn
= (wxNewBitmapButton
*)pObj
;
474 /***** Implementation for class wxDynamicToolBarSerializer *****/
476 IMPLEMENT_SERIALIZER_CLASS( wxDynamicToolBar
,
477 wxDynamicToolBarSerializer
,
478 wxDynamicToolBarSerializer::Serialize
,
479 wxDynamicToolBarSerializer::Initialize
)
481 void wxDynamicToolBarSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
483 // cbFloatedBarWindow is "a kind" of wxWindow - perform
484 // serialization of the base class first
486 wxWindowSerializer::DoSerialize( pObj
, store
,
487 (wndCreationFn
)wxDynamicToolBarSerializer::CreateDynTBarWindowFn
);
489 wxDynamicToolBar
* pTBar
= (wxDynamicToolBar
*)pObj
;
491 store
.XchgObjArray( pTBar
->mTools
);
494 void wxDynamicToolBarSerializer::CreateDynTBarWindowFn( wxDynamicToolBar
* tbar
, wxWindow
* parent
, const wxWindowID id
,
495 const wxPoint
& pos
, const wxSize
& size
, long style
,
496 const wxString
& name
)
498 tbar
->Create( parent
, id
, pos
, size
, style
);
501 void wxDynamicToolBarSerializer::Initialize( wxObject
* pObj
)
506 /***** Implementation for class wxDynToolInfoSerializer *****/
508 IMPLEMENT_SERIALIZER_CLASS( wxDynToolInfo
,
509 wxDynToolInfoSerializer
,
510 wxDynToolInfoSerializer::Serialize
,
513 void wxDynToolInfoSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
515 // cbFloatedBarWindow is "a kind" of wxWindow - perform
516 // serialization of the base class first
518 wxDynToolInfo
* pInfo
= (wxDynToolInfo
*)pObj
;
520 store
.XchgWxRect( pInfo
->mRect
);
521 store
.XchgBool ( pInfo
->mIsSeparator
);
523 store
.XchgObjPtr( (wxObject
**) &pInfo
->mpToolWnd
);
524 store
.XchgInt ( pInfo
->mIndex
);
525 store
.XchgWxSize( pInfo
->mRealSize
);
528 #include "objstore.h" // tabbed window is serialiable
530 /***** Implementation for class wxTabbedWindowSerializer ****/
532 IMPLEMENT_SERIALIZER_CLASS( wxTabbedWindow
,
533 wxTabbedWindowSerializer
,
534 wxTabbedWindowSerializer::Serialize
,
535 wxTabbedWindowSerializer::Initialize
)
537 void wxTabbedWindowSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
539 wxTabbedWindow
* pWnd
= (wxTabbedWindow
*)pObj
;
541 // we're kind of window - serialize it first
543 if ( store
.IsLoading() )
545 // FOR NOW::workaround for the mistery
547 pWnd
->mpTabScroll
= (wxScrollBar
*)(-1);
549 wxWindowSerializer::DoSerialize( pObj
, store
,
550 (wndCreationFn
)wxWindowSerializer::CreateWindowFn
,
553 store
.XchgObjList( pWnd
->mTabs
);
555 store
.XchgInt( pWnd
->mActiveTab
);
556 store
.XchgInt( pWnd
->mTitleHeight
);
557 store
.XchgInt( pWnd
->mLayoutType
);
558 store
.XchgInt( pWnd
->mTitleHeight
);
560 store
.XchgObj( (wxObject
*) &(pWnd
->mWhitePen
) );
561 store
.XchgObj( (wxObject
*) &(pWnd
->mGrayPen
) );
562 store
.XchgObj( (wxObject
*) &(pWnd
->mDarkPen
) );
563 store
.XchgObj( (wxObject
*) &(pWnd
->mBlackPen
) );
565 store
.XchgObjPtr( (wxObject
**) &(pWnd
->mpTabScroll
) );
566 store
.XchgObjPtr( (wxObject
**) &(pWnd
->mpHorizScroll
) );
567 store
.XchgObjPtr( (wxObject
**) &(pWnd
->mpVertScroll
) );
569 store
.XchgInt( pWnd
->mVertGap
);
570 store
.XchgInt( pWnd
->mHorizGap
);
571 store
.XchgInt( pWnd
->mTitleVertGap
);
572 store
.XchgInt( pWnd
->mTitleHorizGap
);
573 store
.XchgInt( pWnd
->mImageTextGap
);
574 store
.XchgInt( pWnd
->mFirstTitleGap
);
575 store
.XchgInt( pWnd
->mBorderOnlyWidth
);
578 void wxTabbedWindowSerializer::Initialize( wxObject
* pObj
)
580 wxTabbedWindow
* pWnd
= (wxTabbedWindow
*)pObj
;
582 pWnd
->RecalcLayout(TRUE
);
585 /***** Implementation for class twTabInfoSerializer ****/
587 IMPLEMENT_SERIALIZER_CLASS( twTabInfo
,
589 twTabInfoSerializer::Serialize
,
592 void twTabInfoSerializer::Serialize( wxObject
* pObj
, wxObjectStorage
& store
)
594 twTabInfo
* pInfo
= (twTabInfo
*)pObj
;
596 store
.XchgObjPtr( (wxObject
**) &(pInfo
->mpContent
) );
598 // NOTE:: wxSize is NOT a dynamic class unfortunately ...
600 store
.XchgWxSize( pInfo
->mDims
);
602 store
.XchgWxStr ( pInfo
->mText
);
603 store
.XchgWxStr( pInfo
->mImageFile
);
605 store
.XchgLong( pInfo
->mImageType
);
607 if ( store
.IsLoading() && wxFileExists( pInfo
->mImageFile
) )
609 pInfo
->mBitMap
.LoadFile( pInfo
->mImageFile
, pInfo
->mImageType
);