X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/9fdd83842f5ead4ef45852b9943df36c38b4d7d7..b3031762e87338b20e682af9278731aec1d123c6:/utils/serialize/serctrl.cpp diff --git a/utils/serialize/serctrl.cpp b/utils/serialize/serctrl.cpp index 59aabe8f7f..13e5451721 100644 --- a/utils/serialize/serctrl.cpp +++ b/utils/serialize/serctrl.cpp @@ -1,3 +1,14 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: serctrl.cpp +// Purpose: Serialization: control classes +// Author: Guilhem Lavaux +// Modified by: +// Created: July 1998 +// RCS-ID: $Id$ +// Copyright: (c) 1998 Guilhem Lavaux +// Licence: wxWindows license +///////////////////////////////////////////////////////////////////////////// + #ifdef __GNUG__ #pragma implementation "serctrl.h" #endif @@ -12,8 +23,11 @@ #include #include #include +#include #include +#include #include +#include #include #include #include @@ -29,9 +43,12 @@ IMPLEMENT_SERIAL_CLASS(wxGauge, wxControl) IMPLEMENT_SERIAL_CLASS(wxListBox, wxControl) IMPLEMENT_SERIAL_CLASS(wxNotebook, wxControl) IMPLEMENT_SERIAL_CLASS(wxRadioBox, wxControl) - +IMPLEMENT_SERIAL_CLASS(wxRadioButton, wxControl) IMPLEMENT_SERIAL_CLASS(wxButton, wxControl) IMPLEMENT_SERIAL_CLASS(wxStaticText, wxControl) +IMPLEMENT_SERIAL_CLASS(wxStaticBox, wxControl) + +//----------------------------------------------------------------------------- void WXSERIAL(wxButton)::StoreObject(wxObjectOutputStream& s) { @@ -46,9 +63,11 @@ void WXSERIAL(wxButton)::LoadObject(wxObjectInputStream& s) printf("label = %s\n", WXSTRINGCAST m_label); button->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y), wxSize(m_w, m_h), - m_style, m_name); + m_style, *m_validator, m_name); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxCheckBox)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -68,11 +87,13 @@ void WXSERIAL(wxCheckBox)::LoadObject(wxObjectInputStream& s) wxCheckBox *chkbox = (wxCheckBox *)Object(); chkbox->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y), wxSize(m_w, m_h), - m_style, m_name); + m_style, *m_validator, m_name); chkbox->SetValue(data_s.Read8()); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxSlider)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -107,7 +128,7 @@ void WXSERIAL(wxSlider)::LoadObject(wxObjectInputStream& s) value = data_s.Read32(); slider->Create(m_parent, m_id, value, min, max, wxPoint(m_x, m_y), - wxSize(m_w, m_h), m_style, m_name); + wxSize(m_w, m_h), m_style, *m_validator, m_name); slider->SetTickFreq( 0, data_s.Read32() ); slider->SetPageSize( data_s.Read32() ); @@ -118,6 +139,8 @@ void WXSERIAL(wxSlider)::LoadObject(wxObjectInputStream& s) slider->SetThumbLength( data_s.Read32() ); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxGauge)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -144,13 +167,15 @@ void WXSERIAL(wxGauge)::LoadObject(wxObjectInputStream& s) range = data_s.Read32(); gauge->Create(m_parent, m_id, range, wxPoint(m_x, m_y), wxSize(m_w, m_h), - m_style, m_name); + m_style, *m_validator, m_name); gauge->SetShadowWidth( data_s.Read8() ); gauge->SetBezelFace( data_s.Read8() ); gauge->SetValue( data_s.Read32() ); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxChoice)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -176,12 +201,14 @@ void WXSERIAL(wxChoice)::LoadObject(wxObjectInputStream& s) int i,num = data_s.Read32(); choice->Create(m_parent, m_id, wxPoint(m_x, m_y), wxSize(m_w, m_h), 0, NULL, - m_style, m_name); + m_style, *m_validator, m_name); for (i=0;iAppend( data_s.ReadString() ); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxListBox)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -210,21 +237,24 @@ void WXSERIAL(wxListBox)::LoadObject(wxObjectInputStream& s) listbox->Append( data_s.ReadString() ); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxNotebook)::StoreObject(wxObjectOutputStream& s) { wxNotebook *notebook = (wxNotebook *)Object(); + wxImageList *imaglist = notebook->GetImageList(); int i, pcount = notebook->GetPageCount(); WXSERIAL(wxControl)::StoreObject(s); - if (s.FirstStage()) { - // Don't know how to retrieve images from wxImageList (copy to a DC ?) + s.AddChild(imaglist); return; } wxDataOutputStream data_s(s); data_s.Write8( pcount ); + for (i=0;iGetPageText(i) ); } @@ -232,20 +262,32 @@ void WXSERIAL(wxNotebook)::StoreObject(wxObjectOutputStream& s) void WXSERIAL(wxNotebook)::LoadObject(wxObjectInputStream& s) { wxNotebook *notebook = (wxNotebook *)Object(); - int i, pcount; + int i; + wxImageList *imaglist; + + if (s.SecondCall()) { + for (i=0;iAddPage( (wxWindow *)s.GetChild(), m_stringlist[i] ); + return; + } WXSERIAL(wxControl)::LoadObject(s); + imaglist = (wxImageList *)s.GetChild(); + notebook->Create(m_parent, m_id, wxPoint(m_x, m_y), wxSize(m_w, m_h), m_style, m_name); wxDataInputStream data_s(s); - pcount = data_s.Read8(); - for (i=0;iSetPageText(i, data_s.ReadString() ); + m_pcount = data_s.Read8(); + for (i=0;iCreate(m_parent, m_id, m_title, wxPoint(m_x, m_y), wxSize(m_w, m_h), - n_items, items, 0, m_style, m_name); + n_items, items, 0, m_style, *m_validator, m_name); } +//----------------------------------------------------------------------------- + +void WXSERIAL(wxRadioButton)::StoreObject(wxObjectOutputStream& s) +{ + WXSERIAL(wxControl)::StoreObject(s); + + if (s.FirstStage()) + return; + + wxDataOutputStream data_s(s); + data_s.Write8( (char) ((wxRadioButton *)Object())->GetValue() ); +} + +void WXSERIAL(wxRadioButton)::LoadObject(wxObjectInputStream& s) +{ + wxDataInputStream data_s(s); + + WXSERIAL(wxControl)::LoadObject(s); + ((wxRadioButton *)Object())->SetValue( (bool)data_s.Read8() ); +} + +//----------------------------------------------------------------------------- + void WXSERIAL(wxComboBox)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -315,7 +380,7 @@ void WXSERIAL(wxComboBox)::LoadObject(wxObjectInputStream& s) int i, num, selection; box->Create(m_parent, m_id, wxEmptyString, wxPoint(m_x, m_y), wxSize(m_w, m_h), - 0, NULL, m_style, m_name); + 0, NULL, m_style, *m_validator, m_name); num = data_s.Read8(); selection = data_s.Read8(); @@ -327,6 +392,8 @@ void WXSERIAL(wxComboBox)::LoadObject(wxObjectInputStream& s) box->SetValue( data_s.ReadString() ); } +//----------------------------------------------------------------------------- + void WXSERIAL(wxStaticText)::StoreObject(wxObjectOutputStream& s) { WXSERIAL(wxControl)::StoreObject(s); @@ -339,3 +406,18 @@ void WXSERIAL(wxStaticText)::LoadObject(wxObjectInputStream& s) ((wxStaticText *)Object())->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y), wxSize(m_w, m_h), m_style, m_name); } + +//----------------------------------------------------------------------------- + +void WXSERIAL(wxStaticBox)::StoreObject(wxObjectOutputStream& s) +{ + WXSERIAL(wxControl)::StoreObject(s); +} + +void WXSERIAL(wxStaticBox)::LoadObject(wxObjectInputStream& s) +{ + WXSERIAL(wxControl)::LoadObject(s); + + ((wxStaticBox *)Object())->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y), + wxSize(m_w, m_h), m_style, m_name); +}