]>
git.saurik.com Git - wxWidgets.git/blob - utils/serialize/serext.cpp
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Serialization: Other classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "serext.h"
18 #include <wx/splitter.h>
20 #include <wx/objstrm.h>
21 #include <wx/datstrm.h>
23 IMPLEMENT_SERIAL_CLASS(wxSplitterWindow
, wxWindow
)
24 IMPLEMENT_SERIAL_CLASS(wxGridCell
, wxObject
)
25 IMPLEMENT_SERIAL_CLASS(wxGrid
, wxPanel
)
27 void WXSERIAL(wxSplitterWindow
)::StoreObject(wxObjectOutputStream
& s
)
29 wxSplitterWindow
*splitter
= (wxSplitterWindow
*)Object();
30 WXSERIAL(wxWindow
)::StoreObject(s
);
33 s
.AddChild( splitter
->GetWindow1() );
34 s
.AddChild( splitter
->GetWindow2() );
38 wxDataOutputStream
data_s(s
);
39 data_s
.Write8( splitter
->GetSplitMode() );
40 data_s
.Write32( splitter
->GetSashSize() );
41 data_s
.Write8( splitter
->GetBorderSize() );
42 data_s
.Write32( splitter
->GetSashPosition() );
43 data_s
.Write32( splitter
->GetMinimumPaneSize() );
46 void WXSERIAL(wxSplitterWindow
)::LoadObject(wxObjectInputStream
& s
)
48 wxSplitterWindow
*splitter
= (wxSplitterWindow
*)Object();
49 WXSERIAL(wxWindow
)::LoadObject(s
);
51 wxDataInputStream
data_s(s
);
52 int split_mode
, sash_size
, border_size
, sash_position
, min_pane_size
;
54 split_mode
= data_s
.Read8();
55 sash_size
= data_s
.Read32();
56 border_size
= data_s
.Read8();
57 sash_position
= data_s
.Read32();
58 min_pane_size
= data_s
.Read32();
60 splitter
->Create(m_parent
, m_id
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
), m_style
,
64 if (data_s
.Read8() == wxSPLIT_VERTICAL
)
65 splitter
->SplitVertically((wxWindow
*)s
.GetChild(0),
66 (wxWindow
*)s
.GetChild(1), sash_position
);
68 splitter
->SplitHorizontally((wxWindow
*)s
.GetChild(0),
69 (wxWindow
*)s
.GetChild(1), sash_position
);
72 splitter
->SetSashSize(sash_size
);
73 splitter
->SetBorderSize(border_size
);
74 splitter
->SetMinimumPaneSize(min_pane_size
);
77 void WXSERIAL(wxGridCell
)::StoreObject(wxObjectOutputStream
& s
)
79 wxGridCell
*cell
= (wxGridCell
*)Object();
80 wxDataOutputStream
data_s(s
);
83 s
.AddChild( cell
->GetFont() );
84 s
.AddChild( cell
->GetBackgroundBrush() );
85 s
.AddChild( cell
->GetCellBitmap() );
86 s
.AddChild( &(cell
->GetTextColour()) );
87 s
.AddChild( &(cell
->GetBackgroundColour()) );
91 data_s
.WriteString( cell
->GetTextValue() );
92 data_s
.Write16( cell
->GetAlignment() );
95 void WXSERIAL(wxGridCell
)::LoadObject(wxObjectInputStream
& s
)
97 wxGridCell
*cell
= (wxGridCell
*)Object();
98 wxDataInputStream
data_s(s
);
100 cell
->SetTextValue( data_s
.ReadString() );
101 cell
->SetAlignment( data_s
.Read16() );
102 cell
->SetFont( (wxFont
*)s
.GetChild() );
103 cell
->SetBackgroundBrush( (wxBrush
*)s
.GetChild() );
104 cell
->SetCellBitmap( (wxBitmap
*)s
.GetChild() );
105 cell
->SetTextColour( *((wxColour
*)s
.GetChild()) );
106 cell
->SetBackgroundColour( *((wxColour
*)s
.GetChild()) );
109 void WXSERIAL(wxGrid
)::StoreObject(wxObjectOutputStream
& s
)
111 wxDataOutputStream
data_s(s
);
112 wxGrid
*grid
= (wxGrid
*)Object();
113 int n_rows
= grid
->GetRows(), n_cols
= grid
->GetCols();
116 if (s
.FirstStage()) {
117 for (r
=0;r
<n_rows
;r
++)
118 for (c
=0;c
<n_cols
;c
++)
119 s
.AddChild( grid
->GetCell(r
, c
) );
121 s
.AddChild( grid
->GetDividerPen() );
122 WXSERIAL(wxPanel
)::StoreObject(s
);
126 data_s
.Write16( n_rows
);
127 data_s
.Write16( n_cols
);
128 data_s
.Write16( grid
->GetCursorRow() );
129 data_s
.Write16( grid
->GetCursorColumn() );
131 WXSERIAL(wxPanel
)::StoreObject(s
);
134 void WXSERIAL(wxGrid
)::LoadObject(wxObjectInputStream
& s
)
136 WXSERIAL(wxPanel
)::LoadObject(s
);