]>
git.saurik.com Git - wxWidgets.git/blob - utils/serialize/sergdi.cpp
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>
25 IMPLEMENT_SERIAL_CLASS(wxBitmap
, wxObject
)
26 IMPLEMENT_SERIAL_CLASS(wxGDIObject
, wxObject
)
27 IMPLEMENT_SERIAL_CLASS(wxColour
, wxGDIObject
)
28 IMPLEMENT_SERIAL_CLASS(wxFont
, wxGDIObject
)
29 IMPLEMENT_SERIAL_CLASS(wxPen
, wxGDIObject
)
30 IMPLEMENT_SERIAL_CLASS(wxBrush
, wxGDIObject
)
32 IMPLEMENT_ALIAS_SERIAL_CLASS(wxPenList
, wxList
)
33 IMPLEMENT_ALIAS_SERIAL_CLASS(wxBrushList
, wxList
)
34 IMPLEMENT_ALIAS_SERIAL_CLASS(wxFontList
, wxList
)
35 IMPLEMENT_ALIAS_SERIAL_CLASS(wxColourDatabase
, wxList
)
36 IMPLEMENT_ALIAS_SERIAL_CLASS(wxBitmapList
, wxList
)
38 void WXSERIAL(wxBitmap
)::StoreObject(wxObjectOutputStream
& s
)
43 void WXSERIAL(wxBitmap
)::LoadObject(wxObjectInputStream
& s
)
48 void WXSERIAL(wxGDIObject
)::StoreObject(wxObjectOutputStream
& s
)
53 bool visible
= ((wxGDIObject
*)Object())->GetVisible();
55 wxDataOutputStream
data_s(s
);
56 data_s
.Write8(visible
);
59 void WXSERIAL(wxGDIObject
)::LoadObject(wxObjectInputStream
& s
)
61 wxDataInputStream
data_s(s
);
63 ((wxGDIObject
*)Object())->SetVisible( data_s
.Read8() );
66 void WXSERIAL(wxColour
)::StoreObject(wxObjectOutputStream
& s
)
68 WXSERIAL(wxGDIObject
)::StoreObject(s
);
73 wxDataOutputStream
data_s(s
);
74 wxColour
*colour
= (wxColour
*)Object();
76 data_s
.Write8(colour
->Red());
77 data_s
.Write8(colour
->Green());
78 data_s
.Write8(colour
->Blue());
81 void WXSERIAL(wxColour
)::LoadObject(wxObjectInputStream
& s
)
83 WXSERIAL(wxGDIObject
)::LoadObject(s
);
85 wxDataInputStream
data_s(s
);
86 wxColour
*colour
= (wxColour
*)Object();
96 void WXSERIAL(wxPen
)::StoreObject(wxObjectOutputStream
& s
)
98 wxPen
*pen
= (wxPen
*)Object();
99 WXSERIAL(wxGDIObject
)::StoreObject(s
);
101 if (s
.FirstStage()) {
102 s
.AddChild(& (pen
->GetColour()) );
106 wxDataOutputStream
data_s(s
);
108 data_s
.Write8( pen
->GetCap() );
109 data_s
.Write8( pen
->GetJoin() );
110 data_s
.Write8( pen
->GetStyle() );
111 data_s
.Write8( pen
->GetWidth() );
114 void WXSERIAL(wxPen
)::LoadObject(wxObjectInputStream
& s
)
116 wxPen
*pen
= (wxPen
*)Object();
117 wxColour
*col
= (wxColour
*) s
.GetChild(0);
121 WXSERIAL(wxGDIObject
)::LoadObject(s
);
123 wxDataInputStream
data_s(s
);
125 pen
->SetColour(*col
);
126 pen
->SetCap( data_s
.Read8() );
127 pen
->SetJoin( data_s
.Read8() );
128 pen
->SetStyle( data_s
.Read8() );
129 pen
->SetWidth( data_s
.Read8() );
132 void WXSERIAL(wxBrush
)::StoreObject(wxObjectOutputStream
& s
)
134 wxBrush
*brush
= (wxBrush
*)Object();
135 WXSERIAL(wxGDIObject
)::StoreObject(s
);
137 if (s
.FirstStage()) {
138 s
.AddChild( &(brush
->GetColour()) );
139 s
.AddChild( brush
->GetStipple() );
143 wxDataOutputStream
data_s(s
);
144 data_s
.Write8( brush
->GetStyle() );
147 void WXSERIAL(wxBrush
)::LoadObject(wxObjectInputStream
& s
)
149 wxBrush
*brush
= (wxBrush
*)Object();
150 wxColour
*col
= (wxColour
*)s
.GetChild(0);
151 wxBitmap
*bmap
= (wxBitmap
*)s
.GetChild(1);
155 WXSERIAL(wxGDIObject
)::LoadObject(s
);
157 wxDataInputStream
data_s(s
);
159 *brush
= wxBrush(*col
, data_s
.Read8());
161 *brush
= wxBrush(bmap
);
164 void WXSERIAL(wxFont
)::StoreObject(wxObjectOutputStream
& s
)
166 wxFont
*font
= (wxFont
*)Object();
168 WXSERIAL(wxGDIObject
)::StoreObject(s
);
173 wxDataOutputStream
data_s(s
);
175 data_s
.Write8( font
->GetPointSize() );
176 data_s
.WriteString( font
->GetFaceName() );
177 data_s
.Write8( font
->GetFamily() );
178 data_s
.Write8( font
->GetStyle() );
179 data_s
.Write8( font
->GetWeight() );
180 data_s
.Write8( font
->GetUnderlined() );
183 void WXSERIAL(wxFont
)::LoadObject(wxObjectInputStream
& s
)
185 wxFont
*font
= (wxFont
*)Object();
187 WXSERIAL(wxGDIObject
)::LoadObject(s
);
189 wxDataInputStream
data_s(s
);
190 int psize
, family
, style
, weight
;
194 psize
= data_s
.Read8();
195 face_name
= data_s
.ReadString();
196 family
= data_s
.Read8();
197 style
= data_s
.Read8();
198 weight
= data_s
.Read8();
199 underlined
= data_s
.Read8();
201 *font
= wxFont(psize
, face_name
, family
, style
, weight
, underlined
);