]> git.saurik.com Git - wxWidgets.git/blob - utils/serialize/serext.cpp
forgot to commit - no changes
[wxWidgets.git] / utils / serialize / serext.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: serext.cpp
3 // Purpose: Serialization: Other classes
4 // Author: Guilhem Lavaux
5 // Modified by:
6 // Created: July 1998
7 // RCS-ID: $Id$
8 // Copyright: (c) 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "serext.h"
14 #endif
15
16 #include "serext.h"
17 #include <wx/wx.h>
18 #include <wx/splitter.h>
19 #include <wx/grid.h>
20 #include <wx/objstrm.h>
21 #include <wx/datstrm.h>
22
23 IMPLEMENT_SERIAL_CLASS(wxSplitterWindow, wxWindow)
24 IMPLEMENT_SERIAL_CLASS(wxGridCell, wxObject)
25 IMPLEMENT_SERIAL_CLASS(wxGrid, wxPanel)
26
27 void WXSERIAL(wxSplitterWindow)::StoreObject(wxObjectOutputStream& s)
28 {
29 wxSplitterWindow *splitter = (wxSplitterWindow *)Object();
30 WXSERIAL(wxWindow)::StoreObject(s);
31
32 if (s.FirstStage()) {
33 s.AddChild( splitter->GetWindow1() );
34 s.AddChild( splitter->GetWindow2() );
35 return;
36 }
37
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() );
44 }
45
46 void WXSERIAL(wxSplitterWindow)::LoadObject(wxObjectInputStream& s)
47 {
48 wxSplitterWindow *splitter = (wxSplitterWindow *)Object();
49 WXSERIAL(wxWindow)::LoadObject(s);
50
51 wxDataInputStream data_s(s);
52 int split_mode, sash_size, border_size, sash_position, min_pane_size;
53
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();
59
60 splitter->Create(m_parent, m_id, wxPoint(m_x, m_y), wxSize(m_w, m_h), m_style,
61 m_name);
62
63 if (s.GetChild(1)) {
64 if (data_s.Read8() == wxSPLIT_VERTICAL)
65 splitter->SplitVertically((wxWindow *)s.GetChild(0),
66 (wxWindow *)s.GetChild(1), sash_position);
67 else
68 splitter->SplitHorizontally((wxWindow *)s.GetChild(0),
69 (wxWindow *)s.GetChild(1), sash_position);
70 }
71
72 splitter->SetSashSize(sash_size);
73 splitter->SetBorderSize(border_size);
74 splitter->SetMinimumPaneSize(min_pane_size);
75 }
76
77 void WXSERIAL(wxGridCell)::StoreObject(wxObjectOutputStream& s)
78 {
79 wxGridCell *cell = (wxGridCell *)Object();
80 wxDataOutputStream data_s(s);
81
82 if (s.FirstStage()) {
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()) );
88 return;
89 }
90
91 data_s.WriteString( cell->GetTextValue() );
92 data_s.Write16( cell->GetAlignment() );
93 }
94
95 void WXSERIAL(wxGridCell)::LoadObject(wxObjectInputStream& s)
96 {
97 wxGridCell *cell = (wxGridCell *)Object();
98 wxDataInputStream data_s(s);
99
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()) );
107 }
108
109 void WXSERIAL(wxGrid)::StoreObject(wxObjectOutputStream& s)
110 {
111 wxDataOutputStream data_s(s);
112 wxGrid *grid = (wxGrid *)Object();
113 int n_rows = grid->GetRows(), n_cols = grid->GetCols();
114 int r, c;
115
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) );
120
121 s.AddChild( grid->GetDividerPen() );
122 WXSERIAL(wxPanel)::StoreObject(s);
123 return;
124 }
125
126 data_s.Write16( n_rows );
127 data_s.Write16( n_cols );
128 data_s.Write16( grid->GetCursorRow() );
129 data_s.Write16( grid->GetCursorColumn() );
130
131 WXSERIAL(wxPanel)::StoreObject(s);
132 }
133
134 void WXSERIAL(wxGrid)::LoadObject(wxObjectInputStream& s)
135 {
136 WXSERIAL(wxPanel)::LoadObject(s);
137 }