]>
git.saurik.com Git - wxWidgets.git/blob - utils/serialize/sergdi.cpp
85072dbaba7f923d4b5ffa0c95293ee403853bb7
1 /////////////////////////////////////////////////////////////////////////////
3 // Purpose: Serialization: GDI classes
4 // Author: Guilhem Lavaux
8 // Copyright: (c) 1998 Guilhem Lavaux
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #pragma implementation "sergdi.h"
15 #include <wx/objstrm.h>
16 #include <wx/datstrm.h>
17 #include <wx/gdicmn.h>
18 #include <wx/bitmap.h>
22 #include <wx/serbase.h>
23 #include <wx/imaglist.h>
26 IMPLEMENT_SERIAL_CLASS(wxBitmap
, wxObject
)
27 IMPLEMENT_SERIAL_CLASS(wxGDIObject
, wxObject
)
28 IMPLEMENT_SERIAL_CLASS(wxColour
, wxGDIObject
)
29 IMPLEMENT_SERIAL_CLASS(wxFont
, wxGDIObject
)
30 IMPLEMENT_SERIAL_CLASS(wxPen
, wxGDIObject
)
31 IMPLEMENT_SERIAL_CLASS(wxBrush
, wxGDIObject
)
32 IMPLEMENT_SERIAL_CLASS(wxImageList
, wxObject
)
34 IMPLEMENT_ALIAS_SERIAL_CLASS(wxPenList
, wxList
)
35 IMPLEMENT_ALIAS_SERIAL_CLASS(wxBrushList
, wxList
)
36 IMPLEMENT_ALIAS_SERIAL_CLASS(wxFontList
, wxList
)
37 IMPLEMENT_ALIAS_SERIAL_CLASS(wxColourDatabase
, wxList
)
38 IMPLEMENT_ALIAS_SERIAL_CLASS(wxBitmapList
, wxList
)
40 void WXSERIAL(wxBitmap
)::StoreObject(wxObjectOutputStream
& s
)
45 void WXSERIAL(wxBitmap
)::LoadObject(wxObjectInputStream
& s
)
50 void WXSERIAL(wxGDIObject
)::StoreObject(wxObjectOutputStream
& s
)
55 bool visible
= ((wxGDIObject
*)Object())->GetVisible();
57 wxDataOutputStream
data_s(s
);
58 data_s
.Write8(visible
);
61 void WXSERIAL(wxGDIObject
)::LoadObject(wxObjectInputStream
& s
)
63 wxDataInputStream
data_s(s
);
65 ((wxGDIObject
*)Object())->SetVisible( data_s
.Read8() );
68 void WXSERIAL(wxColour
)::StoreObject(wxObjectOutputStream
& s
)
70 WXSERIAL(wxGDIObject
)::StoreObject(s
);
75 wxDataOutputStream
data_s(s
);
76 wxColour
*colour
= (wxColour
*)Object();
78 data_s
.Write8(colour
->Red());
79 data_s
.Write8(colour
->Green());
80 data_s
.Write8(colour
->Blue());
83 void WXSERIAL(wxColour
)::LoadObject(wxObjectInputStream
& s
)
85 WXSERIAL(wxGDIObject
)::LoadObject(s
);
87 wxDataInputStream
data_s(s
);
88 wxColour
*colour
= (wxColour
*)Object();
98 void WXSERIAL(wxPen
)::StoreObject(wxObjectOutputStream
& s
)
100 wxPen
*pen
= (wxPen
*)Object();
101 WXSERIAL(wxGDIObject
)::StoreObject(s
);
103 if (s
.FirstStage()) {
104 s
.AddChild(& (pen
->GetColour()) );
108 wxDataOutputStream
data_s(s
);
110 data_s
.Write8( pen
->GetCap() );
111 data_s
.Write8( pen
->GetJoin() );
112 data_s
.Write8( pen
->GetStyle() );
113 data_s
.Write8( pen
->GetWidth() );
116 void WXSERIAL(wxPen
)::LoadObject(wxObjectInputStream
& s
)
118 wxPen
*pen
= (wxPen
*)Object();
119 wxColour
*col
= (wxColour
*) s
.GetChild(0);
123 WXSERIAL(wxGDIObject
)::LoadObject(s
);
125 wxDataInputStream
data_s(s
);
127 pen
->SetColour(*col
);
128 pen
->SetCap( data_s
.Read8() );
129 pen
->SetJoin( data_s
.Read8() );
130 pen
->SetStyle( data_s
.Read8() );
131 pen
->SetWidth( data_s
.Read8() );
134 void WXSERIAL(wxBrush
)::StoreObject(wxObjectOutputStream
& s
)
136 wxBrush
*brush
= (wxBrush
*)Object();
137 WXSERIAL(wxGDIObject
)::StoreObject(s
);
139 if (s
.FirstStage()) {
140 s
.AddChild( &(brush
->GetColour()) );
141 s
.AddChild( brush
->GetStipple() );
145 wxDataOutputStream
data_s(s
);
146 data_s
.Write8( brush
->GetStyle() );
149 void WXSERIAL(wxBrush
)::LoadObject(wxObjectInputStream
& s
)
151 wxBrush
*brush
= (wxBrush
*)Object();
152 wxColour
*col
= (wxColour
*)s
.GetChild(0);
153 wxBitmap
*bmap
= (wxBitmap
*)s
.GetChild(1);
157 WXSERIAL(wxGDIObject
)::LoadObject(s
);
159 wxDataInputStream
data_s(s
);
161 *brush
= wxBrush(*col
, data_s
.Read8());
163 *brush
= wxBrush(bmap
);
166 void WXSERIAL(wxFont
)::StoreObject(wxObjectOutputStream
& s
)
168 wxFont
*font
= (wxFont
*)Object();
170 WXSERIAL(wxGDIObject
)::StoreObject(s
);
175 wxDataOutputStream
data_s(s
);
177 data_s
.Write8( font
->GetPointSize() );
178 data_s
.WriteString( font
->GetFaceName() );
179 data_s
.Write8( font
->GetFamily() );
180 data_s
.Write8( font
->GetStyle() );
181 data_s
.Write8( font
->GetWeight() );
182 data_s
.Write8( font
->GetUnderlined() );
185 void WXSERIAL(wxFont
)::LoadObject(wxObjectInputStream
& s
)
187 wxFont
*font
= (wxFont
*)Object();
189 WXSERIAL(wxGDIObject
)::LoadObject(s
);
191 wxDataInputStream
data_s(s
);
192 int psize
, family
, style
, weight
;
196 psize
= data_s
.Read8();
197 face_name
= data_s
.ReadString();
198 family
= data_s
.Read8();
199 style
= data_s
.Read8();
200 weight
= data_s
.Read8();
201 underlined
= data_s
.Read8();
203 *font
= wxFont(psize
, face_name
, family
, style
, weight
, underlined
);
206 void WXSERIAL(wxImageList
)::StoreObject(wxObjectOutputStream
& s
)
208 wxImageList
*list
= (wxImageList
*)Object();
211 if (s
.FirstStage()) {
212 for (i
=0;i
<list
->GetImageCount();i
++)
213 s
.AddChild(list
->GetBitmap(i
));
216 wxDataOutputStream
data_s(s
);
218 data_s
.Write32(list
->GetImageCount());
221 void WXSERIAL(wxImageList
)::LoadObject(wxObjectInputStream
& s
)
224 wxImageList
*list
= (wxImageList
*)Object();
225 wxDataInputStream
data_s(s
);
227 count
= data_s
.Read32();
228 for (i
=0;i
<count
;i
++)
229 list
->Add(*((wxBitmap
*)s
.GetChild(i
)));