]>
git.saurik.com Git - wxWidgets.git/blob - utils/serialize/serctrl.cpp
2 #pragma implementation "serctrl.h"
6 #include <wx/control.h>
8 #include <wx/checkbox.h>
11 #include <wx/choice.h>
12 #include <wx/listbox.h>
13 #include <wx/notebook.h>
14 #include <wx/radiobox.h>
15 #include <wx/stattext.h>
16 #include <wx/combobox.h>
17 #include <wx/objstrm.h>
18 #include <wx/datstrm.h>
19 #include <wx/serbase.h>
23 IMPLEMENT_ALIAS_SERIAL_CLASS(wxControl
, wxWindow
)
24 IMPLEMENT_SERIAL_CLASS(wxSlider
, wxControl
)
25 IMPLEMENT_SERIAL_CLASS(wxCheckBox
, wxControl
)
26 IMPLEMENT_SERIAL_CLASS(wxChoice
, wxControl
)
27 IMPLEMENT_SERIAL_CLASS(wxComboBox
, wxControl
)
28 IMPLEMENT_SERIAL_CLASS(wxGauge
, wxControl
)
29 IMPLEMENT_SERIAL_CLASS(wxListBox
, wxControl
)
30 IMPLEMENT_SERIAL_CLASS(wxNotebook
, wxControl
)
31 IMPLEMENT_SERIAL_CLASS(wxRadioBox
, wxControl
)
33 IMPLEMENT_SERIAL_CLASS(wxButton
, wxControl
)
34 IMPLEMENT_SERIAL_CLASS(wxStaticText
, wxControl
)
36 void WXSERIAL(wxButton
)::StoreObject(wxObjectOutputStream
& s
)
38 WXSERIAL(wxControl
)::StoreObject(s
);
41 void WXSERIAL(wxButton
)::LoadObject(wxObjectInputStream
& s
)
43 WXSERIAL(wxControl
)::LoadObject(s
);
45 wxButton
*button
= (wxButton
*)Object();
47 printf("label = %s\n", WXSTRINGCAST m_label
);
48 button
->Create(m_parent
, m_id
, m_label
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
),
52 void WXSERIAL(wxCheckBox
)::StoreObject(wxObjectOutputStream
& s
)
54 WXSERIAL(wxControl
)::StoreObject(s
);
59 wxDataOutputStream
data_s(s
);
60 data_s
.Write8( ((wxCheckBox
*)Object())->GetValue() );
63 void WXSERIAL(wxCheckBox
)::LoadObject(wxObjectInputStream
& s
)
65 WXSERIAL(wxControl
)::LoadObject(s
);
67 wxDataInputStream
data_s(s
);
68 wxCheckBox
*chkbox
= (wxCheckBox
*)Object();
70 chkbox
->Create(m_parent
, m_id
, m_label
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
),
73 chkbox
->SetValue(data_s
.Read8());
76 void WXSERIAL(wxSlider
)::StoreObject(wxObjectOutputStream
& s
)
78 WXSERIAL(wxControl
)::StoreObject(s
);
83 wxDataOutputStream
data_s(s
);
84 wxSlider
*slider
= (wxSlider
*)Object();
86 data_s
.Write32( slider
->GetMin() );
87 data_s
.Write32( slider
->GetMax() );
88 data_s
.Write32( slider
->GetValue() );
89 data_s
.Write32( slider
->GetTickFreq() );
90 data_s
.Write32( slider
->GetPageSize() );
91 data_s
.Write32( slider
->GetLineSize() );
92 data_s
.Write32( slider
->GetSelStart() );
93 data_s
.Write32( slider
->GetSelEnd() );
94 data_s
.Write32( slider
->GetThumbLength() );
97 void WXSERIAL(wxSlider
)::LoadObject(wxObjectInputStream
& s
)
99 WXSERIAL(wxControl
)::LoadObject(s
);
101 wxDataInputStream
data_s(s
);
102 wxSlider
*slider
= (wxSlider
*)Object();
105 min
= data_s
.Read32();
106 max
= data_s
.Read32();
107 value
= data_s
.Read32();
109 slider
->Create(m_parent
, m_id
, value
, min
, max
, wxPoint(m_x
, m_y
),
110 wxSize(m_w
, m_h
), m_style
, m_name
);
112 slider
->SetTickFreq( 0, data_s
.Read32() );
113 slider
->SetPageSize( data_s
.Read32() );
114 slider
->SetLineSize( data_s
.Read32() );
115 min
= data_s
.Read32();
116 max
= data_s
.Read32();
117 slider
->SetSelection(min
, max
);
118 slider
->SetThumbLength( data_s
.Read32() );
121 void WXSERIAL(wxGauge
)::StoreObject(wxObjectOutputStream
& s
)
123 WXSERIAL(wxControl
)::StoreObject(s
);
128 wxDataOutputStream
data_s(s
);
129 wxGauge
*gauge
= (wxGauge
*)Object();
131 data_s
.Write32( gauge
->GetRange() );
132 data_s
.Write8( gauge
->GetShadowWidth() );
133 data_s
.Write8( gauge
->GetBezelFace() );
134 data_s
.Write32( gauge
->GetValue() );
137 void WXSERIAL(wxGauge
)::LoadObject(wxObjectInputStream
& s
)
139 WXSERIAL(wxControl
)::LoadObject(s
);
141 wxDataInputStream
data_s(s
);
142 wxGauge
*gauge
= (wxGauge
*)Object();
145 range
= data_s
.Read32();
146 gauge
->Create(m_parent
, m_id
, range
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
),
149 gauge
->SetShadowWidth( data_s
.Read8() );
150 gauge
->SetBezelFace( data_s
.Read8() );
151 gauge
->SetValue( data_s
.Read32() );
154 void WXSERIAL(wxChoice
)::StoreObject(wxObjectOutputStream
& s
)
156 WXSERIAL(wxControl
)::StoreObject(s
);
161 wxDataOutputStream
data_s(s
);
162 wxChoice
*choice
= (wxChoice
*)Object();
163 int i
, num
= choice
->Number();
167 data_s
.WriteString( choice
->GetString(i
) );
170 void WXSERIAL(wxChoice
)::LoadObject(wxObjectInputStream
& s
)
172 WXSERIAL(wxControl
)::LoadObject(s
);
174 wxDataInputStream
data_s(s
);
175 wxChoice
*choice
= (wxChoice
*)Object();
176 int i
,num
= data_s
.Read32();
178 choice
->Create(m_parent
, m_id
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
), 0, NULL
,
182 choice
->Append( data_s
.ReadString() );
185 void WXSERIAL(wxListBox
)::StoreObject(wxObjectOutputStream
& s
)
187 WXSERIAL(wxControl
)::StoreObject(s
);
192 wxDataOutputStream
data_s(s
);
193 wxListBox
*listbox
= (wxListBox
*)Object();
194 int i
, num
= listbox
->Number();
198 data_s
.WriteString( listbox
->GetString(i
) );
201 void WXSERIAL(wxListBox
)::LoadObject(wxObjectInputStream
& s
)
203 WXSERIAL(wxListBox
)::LoadObject(s
);
205 wxDataInputStream
data_s(s
);
206 wxListBox
*listbox
= (wxListBox
*)Object();
207 int i
, num
= data_s
.Read32();
210 listbox
->Append( data_s
.ReadString() );
213 void WXSERIAL(wxNotebook
)::StoreObject(wxObjectOutputStream
& s
)
215 wxNotebook
*notebook
= (wxNotebook
*)Object();
216 int i
, pcount
= notebook
->GetPageCount();
218 WXSERIAL(wxControl
)::StoreObject(s
);
220 if (s
.FirstStage()) {
221 // Don't know how to retrieve images from wxImageList (copy to a DC ?)
225 wxDataOutputStream
data_s(s
);
227 data_s
.Write8( pcount
);
228 for (i
=0;i
<pcount
;i
++)
229 data_s
.WriteString( notebook
->GetPageText(i
) );
232 void WXSERIAL(wxNotebook
)::LoadObject(wxObjectInputStream
& s
)
234 wxNotebook
*notebook
= (wxNotebook
*)Object();
237 WXSERIAL(wxControl
)::LoadObject(s
);
239 notebook
->Create(m_parent
, m_id
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
),
242 wxDataInputStream
data_s(s
);
244 pcount
= data_s
.Read8();
245 for (i
=0;i
<pcount
;i
++)
246 notebook
->SetPageText(i
, data_s
.ReadString() );
249 void WXSERIAL(wxRadioBox
)::StoreObject(wxObjectOutputStream
& s
)
251 wxRadioBox
*box
= (wxRadioBox
*)Object();
252 WXSERIAL(wxControl
)::StoreObject(s
);
257 wxDataOutputStream
data_s(s
);
258 int i
, n_items
= box
->Number();
260 data_s
.Write8( n_items
);
261 data_s
.Write8( box
->GetNumberOfRowsOrCols() );
263 for (i
=0;i
<n_items
;i
++)
264 data_s
.WriteString( box
->GetString(i
) );
267 void WXSERIAL(wxRadioBox
)::LoadObject(wxObjectInputStream
& s
)
269 wxRadioBox
*box
= (wxRadioBox
*)Object();
271 WXSERIAL(wxControl
)::LoadObject(s
);
273 wxDataInputStream
data_s(s
);
274 int i
, n_rows_cols
, n_items
;
277 n_items
= data_s
.Read8();
278 n_rows_cols
= data_s
.Read8();
280 items
= new wxString
[n_items
];
281 for (i
=0;i
<n_items
;i
++)
282 items
[i
] = data_s
.ReadString();
284 box
->Create(m_parent
, m_id
, m_title
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
),
285 n_items
, items
, 0, m_style
, m_name
);
288 void WXSERIAL(wxComboBox
)::StoreObject(wxObjectOutputStream
& s
)
290 WXSERIAL(wxControl
)::StoreObject(s
);
295 wxDataOutputStream
data_s(s
);
296 wxComboBox
*box
= (wxComboBox
*)Object();
297 int i
, num
= box
->Number();
299 data_s
.Write8( num
);
300 data_s
.Write8( box
->GetSelection() );
302 data_s
.WriteString( box
->GetString(i
) );
304 data_s
.WriteString( box
->GetValue() );
306 // TODO: Editable flag
309 void WXSERIAL(wxComboBox
)::LoadObject(wxObjectInputStream
& s
)
311 WXSERIAL(wxControl
)::LoadObject(s
);
313 wxDataInputStream
data_s(s
);
314 wxComboBox
*box
= (wxComboBox
*)Object();
315 int i
, num
, selection
;
317 box
->Create(m_parent
, m_id
, wxEmptyString
, wxPoint(m_x
, m_y
), wxSize(m_w
, m_h
),
318 0, NULL
, m_style
, m_name
);
320 num
= data_s
.Read8();
321 selection
= data_s
.Read8();
324 box
->Append( data_s
.ReadString() );
326 box
->SetSelection( selection
);
327 box
->SetValue( data_s
.ReadString() );
330 void WXSERIAL(wxStaticText
)::StoreObject(wxObjectOutputStream
& s
)
332 WXSERIAL(wxControl
)::StoreObject(s
);
335 void WXSERIAL(wxStaticText
)::LoadObject(wxObjectInputStream
& s
)
337 WXSERIAL(wxControl
)::LoadObject(s
);
339 ((wxStaticText
*)Object())->Create(m_parent
, m_id
, m_label
, wxPoint(m_x
, m_y
),
340 wxSize(m_w
, m_h
), m_style
, m_name
);