]> git.saurik.com Git - wxWidgets.git/blobdiff - utils/serialize/serctrl.cpp
New way to grey out disabled toolbar icons.
[wxWidgets.git] / utils / serialize / serctrl.cpp
index 022f940d76d427acad2324b09e9710f95ffbb4bb..e9e0d56af475dd468931da98b3305c193fda53d9 100644 (file)
 #include <wx/listbox.h>
 #include <wx/notebook.h>
 #include <wx/radiobox.h>
+#include <wx/radiobut.h>
 #include <wx/stattext.h>
+#include <wx/statbox.h>
 #include <wx/combobox.h>
+#include <wx/imaglist.h>
 #include <wx/objstrm.h>
 #include <wx/datstrm.h>
 #include <wx/serbase.h>
 #include "serctrl.h"
 
 IMPLEMENT_ALIAS_SERIAL_CLASS(wxControl, wxWindow)
+#ifdef __WINDOWS__
+IMPLEMENT_SERIAL_CLASS(wxSlider95, wxControl)
+IMPLEMENT_SERIAL_CLASS(wxGauge95, wxControl)
+#else
 IMPLEMENT_SERIAL_CLASS(wxSlider, wxControl)
+IMPLEMENT_SERIAL_CLASS(wxGauge, wxControl)
+#endif
 IMPLEMENT_SERIAL_CLASS(wxCheckBox, wxControl)
 IMPLEMENT_SERIAL_CLASS(wxChoice, wxControl)
 IMPLEMENT_SERIAL_CLASS(wxComboBox, wxControl)
-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)
 {
@@ -53,13 +64,18 @@ void WXSERIAL(wxButton)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxButton *button = (wxButton *)Object();
 
   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);
@@ -75,16 +91,25 @@ void WXSERIAL(wxCheckBox)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(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());
 }
 
+//-----------------------------------------------------------------------------
+
+#ifdef __WXMSW__
+void WXSERIAL(wxSlider95)::StoreObject(wxObjectOutputStream& s)
+#else
 void WXSERIAL(wxSlider)::StoreObject(wxObjectOutputStream& s)
+#endif
 {
   WXSERIAL(wxControl)::StoreObject(s);
 
@@ -105,10 +130,17 @@ void WXSERIAL(wxSlider)::StoreObject(wxObjectOutputStream& s)
   data_s.Write32( slider->GetThumbLength() );
 }
 
+#ifdef __WXMSW__
+void WXSERIAL(wxSlider95)::LoadObject(wxObjectInputStream& s)
+#else
 void WXSERIAL(wxSlider)::LoadObject(wxObjectInputStream& s)
+#endif
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   wxSlider *slider = (wxSlider *)Object();
   int value, min, max;
@@ -118,7 +150,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() );
@@ -129,7 +161,13 @@ void WXSERIAL(wxSlider)::LoadObject(wxObjectInputStream& s)
   slider->SetThumbLength( data_s.Read32() );
 }
 
+//-----------------------------------------------------------------------------
+
+#ifdef __WXMSW__
+void WXSERIAL(wxGauge95)::StoreObject(wxObjectOutputStream& s)
+#else
 void WXSERIAL(wxGauge)::StoreObject(wxObjectOutputStream& s)
+#endif
 {
   WXSERIAL(wxControl)::StoreObject(s);
 
@@ -145,23 +183,32 @@ void WXSERIAL(wxGauge)::StoreObject(wxObjectOutputStream& s)
   data_s.Write32( gauge->GetValue() );
 }
 
+#ifdef __WXMSW__
+void WXSERIAL(wxGauge95)::LoadObject(wxObjectInputStream& s)
+#else
 void WXSERIAL(wxGauge)::LoadObject(wxObjectInputStream& s)
+#endif
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   wxGauge *gauge = (wxGauge *)Object();
   int range;
 
   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);
@@ -182,17 +229,22 @@ void WXSERIAL(wxChoice)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   wxChoice *choice = (wxChoice *)Object();
   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;i<num;i++)
     choice->Append( data_s.ReadString() );
 }
 
+//-----------------------------------------------------------------------------
+
 void WXSERIAL(wxListBox)::StoreObject(wxObjectOutputStream& s)
 {
   WXSERIAL(wxControl)::StoreObject(s);
@@ -213,6 +265,9 @@ void WXSERIAL(wxListBox)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxListBox)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   wxListBox *listbox = (wxListBox *)Object();
   int i, num = data_s.Read32();
@@ -221,21 +276,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;i<pcount;i++)
     data_s.WriteString( notebook->GetPageText(i) );
 }
@@ -243,20 +301,32 @@ void WXSERIAL(wxNotebook)::StoreObject(wxObjectOutputStream& s)
 void WXSERIAL(wxNotebook)::LoadObject(wxObjectInputStream& s)
 {
   wxNotebook *notebook = (wxNotebook *)Object();
-  int i, pcount;
+  int i;
+  wxImageList *imaglist;
 
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall()) {
+    for (i=0;i<m_pcount;i++)
+      notebook->AddPage( (wxWindow *)s.GetChild(), m_stringlist[i] );
+    return;
+  }
+
+  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;i<pcount;i++)
-    notebook->SetPageText(i, data_s.ReadString() );
+  m_pcount = data_s.Read8();
+  for (i=0;i<m_pcount;i++)
+    m_stringlist.Add(data_s.ReadString());
+  s.Recall();
 }
 
+//-----------------------------------------------------------------------------
+
 void WXSERIAL(wxRadioBox)::StoreObject(wxObjectOutputStream& s)
 {
   wxRadioBox *box = (wxRadioBox *)Object();
@@ -281,6 +351,9 @@ void WXSERIAL(wxRadioBox)::LoadObject(wxObjectInputStream& s)
 
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   int i, n_rows_cols, n_items;
   wxString *items;
@@ -293,9 +366,36 @@ void WXSERIAL(wxRadioBox)::LoadObject(wxObjectInputStream& s)
     items[i] = data_s.ReadString();
 
   box->Create(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);
+
+  if (s.SecondCall())
+    return;
+
+  ((wxRadioButton *)Object())->SetValue( (bool)data_s.Read8() );
+}
+
+//-----------------------------------------------------------------------------
+
 void WXSERIAL(wxComboBox)::StoreObject(wxObjectOutputStream& s)
 {
   WXSERIAL(wxControl)::StoreObject(s);
@@ -321,12 +421,15 @@ void WXSERIAL(wxComboBox)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   wxComboBox *box = (wxComboBox *)Object();
   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();
@@ -338,6 +441,8 @@ void WXSERIAL(wxComboBox)::LoadObject(wxObjectInputStream& s)
   box->SetValue( data_s.ReadString() );
 }
 
+//-----------------------------------------------------------------------------
+
 void WXSERIAL(wxStaticText)::StoreObject(wxObjectOutputStream& s)
 {
   WXSERIAL(wxControl)::StoreObject(s);
@@ -347,6 +452,27 @@ void WXSERIAL(wxStaticText)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   ((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);
+  if (s.SecondCall())
+    return;
+
+  ((wxStaticBox *)Object())->Create(m_parent, m_id, m_label, wxPoint(m_x, m_y),
+                                    wxSize(m_w, m_h), m_style, m_name);
+}