]> git.saurik.com Git - wxWidgets.git/commitdiff
* Added wxSerial DLL support for Borland 32
authorGuilhem Lavaux <lavaux@easynet.fr>
Thu, 17 Sep 1998 17:30:13 +0000 (17:30 +0000)
committerGuilhem Lavaux <lavaux@easynet.fr>
Thu, 17 Sep 1998 17:30:13 +0000 (17:30 +0000)
* zstream.h doesn't anymore include zlib.h
* updated static data
* made wxClassInfo::GetFirst() static
* added user/password support in the URL parser
* fixed bugs

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@746 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

19 files changed:
include/wx/dynlib.h
include/wx/object.h
include/wx/url.h
include/wx/zstream.h
samples/wxsocket/client.cpp
src/common/dynlib.cpp
src/common/objstrm.cpp
src/common/url.cpp
src/common/zstream.cpp
src/gtk/data.cpp
src/gtk1/data.cpp
src/msw/data.cpp
utils/serialize/makefile.b32 [new file with mode: 0644]
utils/serialize/serctrl.cpp
utils/serialize/serctrl.h
utils/serialize/sergdi.cpp
utils/serialize/sergdi.h
utils/serialize/serwnd.cpp
utils/serialize/serwnd.h

index 39db5aa6adc5863850ac377b2c610bce8c9a8d36..ceecce4a5842bcea2940498ff5fac51c2175a981 100644 (file)
@@ -39,7 +39,7 @@ class wxLibrary: public wxObject {
   void MergeWithSystem();
 
  protected:
-  void PrepareClasses(wxClassInfo **first);
+  void PrepareClasses(wxClassInfo *first);
 };
 
 // ---------------------------------------------------------------------------
@@ -65,9 +65,9 @@ extern wxLibraries wxTheLibraries;
 // Interesting defines
 
 #define WXDLL_ENTRY_FUNCTION() \
-extern "C" wxClassInfo **wxGetClassFirst(); \
-wxClassInfo **wxGetClassFirst() { \
-  return &wxClassInfo::first; \
+extern "C" wxClassInfo *wxGetClassFirst(); \
+wxClassInfo *wxGetClassFirst() { \
+  return wxClassInfo::GetFirst(); \
 }
 
 #endif
index 319022cdfe519ee4bfc10290a94838de7725ed9a..16f2aebe352d8f06d1c8b58c9822745911f48e15 100644 (file)
@@ -57,7 +57,7 @@ class WXDLLEXPORT wxClassInfo
    inline wxClassInfo* GetBaseClass2() const { return m_baseInfo2; }
    inline int GetSize(void) const { return m_objectSize; }
    inline wxObjectConstructorFn GetConstructor() const { return m_objectConstructor; }
-   inline wxClassInfo* GetFirst() const { return sm_first; }
+   static inline wxClassInfo* GetFirst() { return sm_first; }
    inline wxClassInfo* GetNext() const { return m_next; }
    bool IsKindOf(wxClassInfo *info) const;
 
index dae1c6ec308b1fdaea6bb31e93d60080d4d8d456..22741e9295804a5ed8b3b03a383dd89000ae23f5 100644 (file)
@@ -42,6 +42,7 @@ protected:
   wxHTTP m_proxy;
   wxURLError m_error;
   wxString m_protoname, m_hostname, m_servname, m_path, m_url;
+  wxString m_user, m_password;
 
   bool PrepProto(wxString& url);
   bool PrepHost(wxString& url);
index 3f2de88380246b3ff09104e2f14a2f5b56bed3b5..65fa71c6153f530096de238dd913c57c8691f0cd 100644 (file)
@@ -16,7 +16,6 @@
 #endif
 
 #include <wx/stream.h>
-#include "../zlib/zlib.h"   // don't change this, Robert
 
 class wxZlibInputStream: public wxFilterInputStream {
  public:
@@ -33,7 +32,7 @@ class wxZlibInputStream: public wxFilterInputStream {
  protected:
   size_t m_z_size;
   unsigned char *m_z_buffer;
-  struct z_stream_s m_inflate;
+  struct z_stream_s *m_inflate;
 };
 
 class wxZlibOutputStream: public wxFilterOutputStream {
@@ -53,7 +52,7 @@ class wxZlibOutputStream: public wxFilterOutputStream {
  protected:
   size_t m_z_size;
   unsigned char *m_z_buffer;
-  struct z_stream_s m_deflate;
+  struct z_stream_s *m_deflate;
 };
 
 #endif
index e2bfdf6201b442f6b8d9e474fcf64b6c26a26b5c..9eec661f2f69c72c0fdb072e3a7a29be0abc72c3 100644 (file)
@@ -106,7 +106,6 @@ bool MyApp::OnInit(void)
   socket_menu->Append(SKDEMO_CONNECT, "Open session");
   socket_menu->AppendSeparator();
   socket_menu->Append(SKDEMO_TEST1, "Start test 1");
-  socket_menu->Append(SKDEMO_TEST2, "Start test 2");
   socket_menu->AppendSeparator();
   socket_menu->Append(SKDEMO_CLOSE, "Close session");
   socket_menu->AppendSeparator();
@@ -117,7 +116,7 @@ bool MyApp::OnInit(void)
   frame->SetMenuBar(menu_bar);
 
   // Make a panel with a message
-  (void)new wxPanel(frame, 0, 0, 300, 100);
+  txtctrl = new wxTextCtrl(this);
 
   // Show the frame
   frame->Show(TRUE);
@@ -266,8 +265,8 @@ void MyFrame::OnExecTest1(wxCommandEvent& WXUNUSED(evt))
 
 void MyFrame::OnExecUrlTest(wxCommandEvent& WXUNUSED(evt))
 {
-  wxString urlname = wxGetTextFromUser("Enter the address of the wxSocket Sample Server",
-                                     "Connect ...", "localhost");
+  wxString urlname = wxGetTextFromUser("Enter an URL to get",
+                                     "URL:", "http://localhost");
 
   wxURL url(urlname);
   wxInputStream *datas = url.GetInputStream();
@@ -275,7 +274,8 @@ void MyFrame::OnExecUrlTest(wxCommandEvent& WXUNUSED(evt))
   if (!datas)
     wxMessageBox("Error in getting data from the URL.", "Alert !");
   else {
-    wxMessageBox("Success !!", "OK !");
+    wxMessageBox("Success !! Click on OK to see the text.", "OK");
+    wxMessageBox(
     delete datas;
   }
 }
index 2fd32ddd586b3d5cade90e041a3e677898061baa..6fcdf2cd631e03d6659e637b2f442cc1cb73d49c 100644 (file)
@@ -55,7 +55,7 @@ wxLibraries wxTheLibraries;
 
 wxLibrary::wxLibrary(void *handle)
 {
-  typedef wxClassInfo **(*t_get_first)(void);
+  typedef wxClassInfo *(*t_get_first)(void);
   t_get_first get_first;
 
   m_handle = handle;
@@ -90,19 +90,19 @@ wxObject *wxLibrary::CreateObject(const wxString& name)
   return info->CreateObject();
 }
 
-void wxLibrary::PrepareClasses(wxClassInfo **first)
+void wxLibrary::PrepareClasses(wxClassInfo *first)
 {
   // Index all class infos by their class name
-  wxClassInfo *info = *first;
+  wxClassInfo *info = first;
   while (info)
   {
     if (info->m_className)
       classTable.Put(info->m_className, (wxObject *)info);
-    info = info->m_next;
+    info = info->GetNext();
   }
 
   // Set base pointers for each wxClassInfo
-  info = *first;
+  info = first;
   while (info)
   {
     if (info->GetBaseClassName1())
@@ -111,7 +111,6 @@ void wxLibrary::PrepareClasses(wxClassInfo **first)
       info->m_baseInfo2 = (wxClassInfo *)classTable.Get(info->GetBaseClassName2());
     info = info->m_next;
   }
-  *first = NULL;
 }
 
 void *wxLibrary::GetSymbol(const wxString& symbname)
@@ -150,10 +149,15 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
   wxString lib_name = name;
   wxNode *node;
   wxLibrary *lib;
+  wxClassInfo *old_sm_first;
 
   if ( (node = m_loaded.Find(name.GetData())) )
     return ((wxLibrary *)node->Data());
 
+  // If DLL shares data, this is necessary.
+  old_sm_first = wxClassInfo::sm_first;
+  wxClassInfo::sm_first = NULL;
+
 #if defined(__UNIX__)
   lib_name.Prepend("./lib");
   lib_name += ".so";
@@ -162,6 +166,8 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
 
   void *handle = dlopen(WXSTRINGCAST lib_name, RTLD_LAZY);
 
+  printf("error = %s\n", dlerror());
+
   if (!handle)
     return NULL;
 #elif defined(__WINDOWS__)
@@ -180,6 +186,8 @@ wxLibrary *wxLibraries::LoadLibrary(const wxString& name)
 
   lib = new wxLibrary((void *)handle);
 
+  wxClassInfo::sm_first = old_sm_first;
+
   m_loaded.Append(name.GetData(), lib);
   return lib;
 }
index b7beef3b716b1d101ba1330d4636794a8ca5b366..ca069bdb68b6f7b80cdb0231faab623e3c9694ed 100644 (file)
@@ -177,6 +177,7 @@ bool wxObjectOutputStream::SaveObject(wxObject& obj)
 wxObjectInputStream::wxObjectInputStream(wxInputStream& s)
   : wxFilterInputStream(s)
 {
+  m_secondcall = FALSE;
 }
 
 wxObject *wxObjectInputStream::SolveName(const wxString& name) const
index b9a8993e3f5e0fb35b86a4c2df0d43b0918da933..0489da90d90d7942af73d1037c82812064bbd102 100644 (file)
@@ -138,6 +138,7 @@ bool wxURL::PrepProto(wxString& url)
 
 bool wxURL::PrepHost(wxString& url)
 {
+  wxString temp_url;
   int pos, pos2;
 
   if ((url.GetChar(0) != '/') || (url.GetChar(1) != '/'))
@@ -149,17 +150,41 @@ bool wxURL::PrepHost(wxString& url)
   if (pos == -1)
     pos = url.Length();
 
-  pos2 = url.Find(':');
+  if (pos == 0)
+    return FALSE;
+
+  temp_url = url(0, pos);
+  url = url(url.Find('/'), url.Length());
+
+  // Retrieve service number
+  pos2 = temp_url.Find(':', TRUE);
   if (pos2 != -1 && pos2 < pos) {
     m_servname = url(pos2, pos);
     if (!m_servname.IsNumber())
       return FALSE;
     pos2 = pos;
+    temp_url = temp_url(0, pos2);
   }
 
-  m_hostname = url(0, pos);
+  // Retrieve user and password.
+  pos2 = temp_url.Find('@');
+  // Even if pos2 equals -1, this code is right.
+  m_hostname = temp_url(pos2+1, temp_url.Length());
 
-  url = url(url.Find('/'), url.Length());
+  m_user = "";
+  m_password = "";
+
+  if (pos2 == -1)
+    return TRUE;
+
+  temp_url = temp_url(0, pos2);
+  pos2 = temp_url.Find(':');
+
+  if (pos2 == -1)
+    return FALSE;
+
+  m_user = temp_url(0, pos2);
+  m_password = temp_url(pos2+1, url.Length());
 
   return TRUE;
 }
@@ -212,6 +237,11 @@ wxInputStream *wxURL::GetInputStream(void)
   }
 
   m_error = wxURL_NOERR;
+  if (m_user != "") {
+    m_protocol->SetUser(m_user);
+    m_protocol->SetPassword(m_password);
+  }
+
   if (m_protoinfo->m_needhost) {
     if (!addr.Hostname(m_hostname)) {
       m_error = wxURL_NOHOST;
index d2b33bc0e046e10f4f19933ac616c62d13726091..fd1dc1062f655601376f3b85db6191d29dc34d8f 100644 (file)
@@ -38,52 +38,55 @@ wxZlibInputStream::wxZlibInputStream(wxInputStream& stream)
   // I need a private stream buffer.
   m_i_streambuf = new wxStreamBuffer(*this);
   m_i_destroybuf = TRUE;
+  m_inflate = new z_stream_s;
 
-  m_inflate.zalloc = (alloc_func)0;
-  m_inflate.zfree = (free_func)0;
-  m_inflate.opaque = (void*)0;
+  m_inflate->zalloc = (alloc_func)0;
+  m_inflate->zfree = (free_func)0;
+  m_inflate->opaque = (voidpf)0;
 
-  err = inflateInit(&m_inflate);
+  err = inflateInit(m_inflate);
   if (err != Z_OK) {
-    inflateEnd(&m_inflate);
+    inflateEnd(m_inflate);
+    delete m_inflate;
     return;
   }
 
   m_z_buffer = new unsigned char[ZSTREAM_BUFFER_SIZE];
   m_z_size = ZSTREAM_BUFFER_SIZE;
 
-  m_inflate.avail_in = 0;
-  m_inflate.next_in = NULL;
+  m_inflate->avail_in = 0;
+  m_inflate->next_in = NULL;
 }
 
 wxZlibInputStream::~wxZlibInputStream()
 {
-  inflateEnd(&m_inflate);
+  inflateEnd(m_inflate);
+  delete m_inflate;
 }
 
 size_t wxZlibInputStream::DoRead(void *buffer, size_t size)
 {
   int err;
 
-  m_inflate.next_out = (unsigned char *)buffer;
-  m_inflate.avail_out = size;
+  m_inflate->next_out = (unsigned char *)buffer;
+  m_inflate->avail_out = size;
 
-  while (m_inflate.avail_out > 0) {
-    if (m_inflate.avail_in == 0) {
+  while (m_inflate->avail_out > 0) {
+    if (m_inflate->avail_in == 0) {
 
       m_parent_i_stream->Read(m_z_buffer, m_z_size);
-      m_inflate.next_in = m_z_buffer;
-      m_inflate.avail_in = m_parent_i_stream->LastRead();
+      m_inflate->next_in = m_z_buffer;
+      m_inflate->avail_in = m_parent_i_stream->LastRead();
 
       if (m_parent_i_stream->Eof())
-        return (size - m_inflate.avail_in);
+        return (size - m_inflate->avail_in);
     }
-    err = inflate(&m_inflate, Z_FINISH);
+    err = inflate(m_inflate, Z_FINISH);
     if (err == Z_STREAM_END)
-      return (size - m_inflate.avail_in);
+      return (size - m_inflate->avail_in);
   }
 
-  return size-m_inflate.avail_in;
+  return size-m_inflate->avail_in;
 }
 
 bool wxZlibInputStream::Eof() const
@@ -104,23 +107,24 @@ wxZlibOutputStream::wxZlibOutputStream(wxOutputStream& stream)
 
   m_o_streambuf = new wxStreamBuffer(*this);
   m_o_destroybuf = TRUE;
+  m_deflate = new z_stream_s;
 
-  m_deflate.zalloc = (alloc_func)0;
-  m_deflate.zfree = (free_func)0;
-  m_deflate.opaque = (void*)0;
+  m_deflate->zalloc = (alloc_func)0;
+  m_deflate->zfree = (free_func)0;
+  m_deflate->opaque = (voidpf)0;
 
-  err = deflateInit(&m_deflate, Z_DEFAULT_COMPRESSION);
+  err = deflateInit(m_deflate, Z_DEFAULT_COMPRESSION);
   if (err != Z_OK) {
-    deflateEnd(&m_deflate);
+    deflateEnd(m_deflate);
     return;
   }
 
   m_z_buffer = new unsigned char[ZSTREAM_BUFFER_SIZE];
   m_z_size = ZSTREAM_BUFFER_SIZE;
 
-  m_deflate.avail_in = 0;
-  m_deflate.next_out = m_z_buffer;
-  m_deflate.avail_out = m_z_size;
+  m_deflate->avail_in = 0;
+  m_deflate->next_out = m_z_buffer;
+  m_deflate->avail_out = m_z_size;
 }
 
 wxZlibOutputStream::~wxZlibOutputStream()
@@ -129,14 +133,14 @@ wxZlibOutputStream::~wxZlibOutputStream()
 
   Sync();
 
-  err = deflate(&m_deflate, Z_FINISH);
+  err = deflate(m_deflate, Z_FINISH);
   if (err != Z_STREAM_END) {
     wxDebugMsg(_("wxZlibOutputStream: an error occured while we was closing "
                "the stream.\n"));
     return;
   }
 
-  deflateEnd(&m_deflate);
+  deflateEnd(m_deflate);
 
   delete[] m_z_buffer;
 }
@@ -145,42 +149,42 @@ void wxZlibOutputStream::Sync()
 {
   int err;
 
-  m_parent_o_stream->Write(m_z_buffer, m_z_size-m_deflate.avail_out);
-  m_deflate.next_out  = m_z_buffer;
-  m_deflate.avail_out = m_z_size;
+  m_parent_o_stream->Write(m_z_buffer, m_z_size-m_deflate->avail_out);
+  m_deflate->next_out  = m_z_buffer;
+  m_deflate->avail_out = m_z_size;
 
-  err = deflate(&m_deflate, Z_FULL_FLUSH);
+  err = deflate(m_deflate, Z_FULL_FLUSH);
   if (err != Z_OK) {
     m_bad = TRUE;
     return;
   }
 
-  m_parent_o_stream->Write(m_z_buffer, m_z_size-m_deflate.avail_out);
-  m_deflate.next_out  = m_z_buffer;
-  m_deflate.avail_out = m_z_size;
+  m_parent_o_stream->Write(m_z_buffer, m_z_size-m_deflate->avail_out);
+  m_deflate->next_out  = m_z_buffer;
+  m_deflate->avail_out = m_z_size;
 }
 
 size_t wxZlibOutputStream::DoWrite(const void *buffer, size_t size)
 {
   int err;
 
-  m_deflate.next_in = (unsigned char *)buffer;
-  m_deflate.avail_in = size;
+  m_deflate->next_in = (unsigned char *)buffer;
+  m_deflate->avail_in = size;
 
-  while (m_deflate.avail_in > 0) {
+  while (m_deflate->avail_in > 0) {
 
-    if (m_deflate.avail_out == 0) {
+    if (m_deflate->avail_out == 0) {
       m_parent_o_stream->Write(m_z_buffer, m_z_size);
       if (m_parent_o_stream->Bad())
-        return (size - m_deflate.avail_in);
+        return (size - m_deflate->avail_in);
 
-      m_deflate.next_out = m_z_buffer;
-      m_deflate.avail_out = m_z_size;
+      m_deflate->next_out = m_z_buffer;
+      m_deflate->avail_out = m_z_size;
     }
 
-    err = deflate(&m_deflate, Z_NO_FLUSH);
+    err = deflate(m_deflate, Z_NO_FLUSH);
     if (err != Z_OK)
-      return (size - m_deflate.avail_in);
+      return (size - m_deflate->avail_in);
   }
   return size;
 }
index a0ab3cea95018e2a238dddd6e745aed734a7ed4e..a03c6f6f1f06a8e196446c34e274bb32068ab81e 100644 (file)
@@ -431,7 +431,7 @@ IMPLEMENT_PROTOCOL(wxHTTP, "http", "80", TRUE)
 #include "wx/protocol/ftp.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxFTP, wxProtocol)
-IMPLEMENT_PROTOCOL(wxFTP, "ftp", "ftp", TRUE)
+IMPLEMENT_PROTOCOL(wxFTP, "ftp", "21", TRUE)
 
 #include "wx/protocol/sckfile.h"
 
index a0ab3cea95018e2a238dddd6e745aed734a7ed4e..a03c6f6f1f06a8e196446c34e274bb32068ab81e 100644 (file)
@@ -431,7 +431,7 @@ IMPLEMENT_PROTOCOL(wxHTTP, "http", "80", TRUE)
 #include "wx/protocol/ftp.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxFTP, wxProtocol)
-IMPLEMENT_PROTOCOL(wxFTP, "ftp", "ftp", TRUE)
+IMPLEMENT_PROTOCOL(wxFTP, "ftp", "21", TRUE)
 
 #include "wx/protocol/sckfile.h"
 
index 0b9cb427f98b173ab42a985d5a8dd29e7c7ad14a..d26dc0a4f6cf6451ad53b415b2212e3e87fb2d24 100644 (file)
@@ -409,6 +409,50 @@ IMPLEMENT_DYNAMIC_CLASS(wxToolBar95, wxToolBarBase)
 
 #endif
 
+#include "wx/sckaddr.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxIPV4address, wxSockAddress)
+#ifdef ENABLE_IPV6
+IMPLEMENT_DYNAMIC_CLASS(wxIPV6address, wxSockAddress)
+#endif
+#ifndef __UNIX__
+IMPLEMENT_DYNAMIC_CLASS(wxUNIXaddress, wxSockAddress)
+#endif
+
+#include "wx/socket.h"
+
+IMPLEMENT_CLASS(wxSocketBase, wxEvtHandler)
+IMPLEMENT_CLASS(wxSocketClient, wxSocketBase)
+IMPLEMENT_CLASS(wxSocketServer, wxSocketBase)
+IMPLEMENT_CLASS(wxSocketHandler, wxObject)
+IMPLEMENT_DYNAMIC_CLASS(wxSocketEvent, wxEvent)
+
+#include "wx/url.h"
+
+IMPLEMENT_CLASS(wxProtoInfo, wxObject)
+IMPLEMENT_CLASS(wxURL, wxObject)
+
+#include "wx/protocol/http.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxHTTP, wxProtocol)
+IMPLEMENT_PROTOCOL(wxHTTP, "http", "80", TRUE)
+
+#include "wx/protocol/ftp.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxFTP, wxProtocol)
+IMPLEMENT_PROTOCOL(wxFTP, "ftp", "21", TRUE)
+
+#include "wx/protocol/sckfile.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxFileProto, wxProtocol)
+IMPLEMENT_PROTOCOL(wxFileProto, "file", NULL, FALSE)
+
+#include "wx/sckipc.h"
+
+IMPLEMENT_DYNAMIC_CLASS(wxTCPServer, wxServerBase)
+IMPLEMENT_DYNAMIC_CLASS(wxTCPClient, wxClientBase)
+IMPLEMENT_DYNAMIC_CLASS(wxTCPConnection, wxConnectionBase)
+
 #include "wx/statusbr.h"
 
 IMPLEMENT_DYNAMIC_CLASS(wxStatusBar, wxWindow)
diff --git a/utils/serialize/makefile.b32 b/utils/serialize/makefile.b32
new file mode 100644 (file)
index 0000000..f082c1a
--- /dev/null
@@ -0,0 +1,57 @@
+#
+# File:                makefile.b32
+# Author:      Patrick Halke, modified by Guilhem Lavaux
+# Created:     1997
+# Updated:     
+# Copyright:   (c) 1993, AIAI, University of Edinburgh
+#
+# "%W% %G%"
+#
+# Makefile : Builds 32bit wxstring library for Windows 3.1
+# and Borland C++ 4.x
+
+WXDIR = $(WXWIN)
+
+DLL=1
+WXBUILDDLL=1
+WXUSINGDLL=1
+
+!include $(WXDIR)\src\makeb32.env
+
+WXLIBDIR = $(WXDIR)\lib
+LIBS=$(WXLIB) cw32 import32
+
+!ifndef DEBUG
+DEBUG=0
+!endif
+
+LIBTARGET= $(WXLIBDIR)\wxserial.dll
+CPPFLAGS= $(CPPFLAGS) -Od
+
+.c.obj:
+       bcc32 $(CPPFLAGS) -P- -c {$< }
+
+OBJECTS = sermain.obj sercore.obj serwnd.obj serctrl.obj sergdi.obj serext.obj
+
+all:    $(LIBTARGET)
+
+sermain.obj:    sermain.$(SRCSUFF)
+        bcc32 $(CPPFLAGS) -P- -u- -c sermain.$(SRCSUFF)
+
+$(LIBTARGET):  $(OBJECTS)
+       erase $(LIBTARGET)
+        tlink32 $(LINK_FLAGS) /v @&&!
+c0d32.obj $(OBJECTS)
+$(LIBTARGET)
+nul
+$(LIBS)
+serial
+!
+
+clean:
+        -erase *.obj
+        -erase $(LIBTARGET)
+        -erase *.exe
+        -erase *.res
+        -erase *.map
+        -erase *.rws
index 13e54517215e922b721b85f4ba313b9df68adcb0..e9e0d56af475dd468931da98b3305c193fda53d9 100644 (file)
 #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)
@@ -59,6 +64,9 @@ 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);
@@ -83,6 +91,9 @@ void WXSERIAL(wxCheckBox)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxControl)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
   wxCheckBox *chkbox = (wxCheckBox *)Object();
 
@@ -94,7 +105,11 @@ void WXSERIAL(wxCheckBox)::LoadObject(wxObjectInputStream& s)
 
 //-----------------------------------------------------------------------------
 
+#ifdef __WXMSW__
+void WXSERIAL(wxSlider95)::StoreObject(wxObjectOutputStream& s)
+#else
 void WXSERIAL(wxSlider)::StoreObject(wxObjectOutputStream& s)
+#endif
 {
   WXSERIAL(wxControl)::StoreObject(s);
 
@@ -115,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;
@@ -141,7 +163,11 @@ void WXSERIAL(wxSlider)::LoadObject(wxObjectInputStream& s)
 
 //-----------------------------------------------------------------------------
 
+#ifdef __WXMSW__
+void WXSERIAL(wxGauge95)::StoreObject(wxObjectOutputStream& s)
+#else
 void WXSERIAL(wxGauge)::StoreObject(wxObjectOutputStream& s)
+#endif
 {
   WXSERIAL(wxControl)::StoreObject(s);
 
@@ -157,10 +183,17 @@ 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;
@@ -196,6 +229,9 @@ 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();
@@ -229,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();
@@ -265,14 +304,14 @@ void WXSERIAL(wxNotebook)::LoadObject(wxObjectInputStream& s)
   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;
   }
 
-  WXSERIAL(wxControl)::LoadObject(s);
-
   imaglist = (wxImageList *)s.GetChild();
 
   notebook->Create(m_parent, m_id, wxPoint(m_x, m_y), wxSize(m_w, m_h),
@@ -312,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;
@@ -345,6 +387,10 @@ 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() );
 }
 
@@ -375,6 +421,9 @@ 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;
@@ -403,6 +452,9 @@ 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);
 }
@@ -417,6 +469,9 @@ void WXSERIAL(wxStaticBox)::StoreObject(wxObjectOutputStream& 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);
index a93a1b3c1aca3bbd04ef4ed7357bf196c4a5b75f..8d7e89a8ff9ce50de2de175d4f7f55c5e1dc7e62 100644 (file)
 
 DECLARE_ALIAS_SERIAL_CLASS(wxControl, wxWindow)
 DECLARE_SERIAL_CLASS(wxButton, wxControl)
+#ifdef __WINDOWS__
+DECLARE_SERIAL_CLASS(wxSlider95, wxControl)
+DECLARE_SERIAL_CLASS(wxGauge95, wxControl)
+#else
 DECLARE_SERIAL_CLASS(wxSlider, wxControl)
+DECLARE_SERIAL_CLASS(wxGauge, wxControl)
+#endif
 DECLARE_SERIAL_CLASS(wxCheckBox, wxControl)
 DECLARE_SERIAL_CLASS(wxChoice, wxControl)
 DECLARE_SERIAL_CLASS(wxComboBox, wxControl)
-DECLARE_SERIAL_CLASS(wxGauge, wxControl)
 DECLARE_SERIAL_CLASS(wxListBox, wxControl)
 DECLARE_SERIAL_CLASS(wxRadioBox, wxControl)
 DECLARE_SERIAL_CLASS(wxRadioButton, wxControl)
index 8ab44d782c7df4a1943fd4af607b61a32a526d57..f53ef6acc927aefe5880ce4c211e9f32a5a8cd80 100644 (file)
 #include <wx/colour.h>
 #include <wx/palette.h>
 #include <wx/dcmemory.h>
+#include <wx/log.h>
 #include "sergdi.h"
 
 IMPLEMENT_SERIAL_CLASS(wxBitmap, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxGDIObject, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxRegion, wxGDIObject)
-IMPLEMENT_SERIAL_CLASS(wxColour, wxGDIObject)
+IMPLEMENT_SERIAL_CLASS(wxColour, wxObject)
 IMPLEMENT_SERIAL_CLASS(wxFont, wxGDIObject)
 IMPLEMENT_SERIAL_CLASS(wxPen, wxGDIObject)
 IMPLEMENT_SERIAL_CLASS(wxBrush, wxGDIObject)
@@ -89,7 +90,11 @@ void WXSERIAL(wxBitmap)::LoadObject(wxObjectInputStream& s)
   w = data_s.Read16();
   h = data_s.Read16();
 
+#ifdef __WXGTK__
   bitmap->Resize(w, h);
+#else
+  bitmap->Create(w, h);
+#endif
   dc.SelectObject(*bitmap);
 
   for (y=0;y<h;y++)
@@ -161,14 +166,20 @@ void WXSERIAL(wxRegion)::LoadObject(wxObjectInputStream& s)
 
 void WXSERIAL(wxColour)::StoreObject(wxObjectOutputStream& s)
 {
-  WXSERIAL(wxGDIObject)::StoreObject(s);
-
   if (s.FirstStage())
     return;
 
   wxDataOutputStream data_s(s);
   wxColour *colour = (wxColour *)Object();
 
+  if (!colour->Ok()) {
+    data_s.Write8(0);
+    data_s.Write8(0);
+    data_s.Write8(0);
+    wxLogDebug("wxColour (0x%x) isn't ready.\n", colour);
+    return;
+  }
+
   data_s.Write8(colour->Red());
   data_s.Write8(colour->Green());
   data_s.Write8(colour->Blue());
@@ -176,8 +187,6 @@ void WXSERIAL(wxColour)::StoreObject(wxObjectOutputStream& s)
 
 void WXSERIAL(wxColour)::LoadObject(wxObjectInputStream& s)
 {
-  WXSERIAL(wxGDIObject)::LoadObject(s);
-  
   wxDataInputStream data_s(s);
   wxColour *colour = (wxColour *)Object();
   int r, g, b;
@@ -305,8 +314,10 @@ void WXSERIAL(wxImageList)::StoreObject(wxObjectOutputStream& s)
   int i;
 
   if (s.FirstStage()) {
+#ifdef __WXGTK__
     for (i=0;i<list->GetImageCount();i++)
       s.AddChild(list->GetBitmap(i));
+#endif
   }
 
   wxDataOutputStream data_s(s);
index 941586e077e2f1c9188a3fc970efecb8f099734e..3a8d3d4b58c907a4f4c08a21fb767d81880d33d4 100644 (file)
@@ -22,7 +22,7 @@
 DECLARE_SERIAL_CLASS(wxBitmap, wxObject)
 DECLARE_SERIAL_CLASS(wxGDIObject, wxObject)
 DECLARE_SERIAL_CLASS(wxRegion, wxGDIObject)
-DECLARE_SERIAL_CLASS(wxColour, wxGDIObject)
+DECLARE_SERIAL_CLASS(wxColour, wxObject)
 DECLARE_SERIAL_CLASS(wxFont, wxGDIObject)
 DECLARE_SERIAL_CLASS(wxPen, wxGDIObject)
 DECLARE_SERIAL_CLASS(wxBrush, wxGDIObject)
index a52ef3f893fd601768419f848f40f50fba9333a5..a7790942cc5bfa28c5348e11186c683339709f36 100644 (file)
@@ -58,8 +58,8 @@ void WXSERIAL(wxWindow)::StoreObject(wxObjectOutputStream& s)
     s.AddChild(win_object->GetValidator());
 
     // BAD HACK, but I don't have access to the internal variable of wxWindow.
-    m_bg_colour = win_object->GetDefaultBackgroundColour();
-    m_fg_colour = win_object->GetDefaultForegroundColour();
+    m_bg_colour = win_object->GetBackgroundColour();
+    m_fg_colour = win_object->GetForegroundColour();
     s.AddChild(&m_bg_colour);
     s.AddChild(&m_fg_colour);
     s.AddChild(win_object->GetFont());
@@ -98,7 +98,24 @@ void WXSERIAL(wxWindow)::LoadObject(wxObjectInputStream& s)
   wxWindow *win_object = (wxWindow *)Object();
   wxColour *colour;
   wxFont *font;
-  int number;
+
+  if (s.SecondCall()) {
+    /* I assume we will never create raw wxWindow object */
+    (void)s.GetChild(); // We pass wxLayoutConstraints.
+    (void)s.GetChild(); // We pass wxValidator.
+
+    colour = (wxColour *)s.GetChild();
+    if (colour)
+      win_object->SetBackgroundColour(*colour);
+    colour = (wxColour *)s.GetChild();
+    if (colour)
+      win_object->SetForegroundColour(*colour);
+    font = (wxFont *)s.GetChild();
+    if (font)
+      win_object->SetFont(*font);
+    s.RemoveChildren(m_number);
+    return;
+  }
 
   m_parent = (wxWindow *)s.GetParent();
 
@@ -110,31 +127,22 @@ void WXSERIAL(wxWindow)::LoadObject(wxObjectInputStream& s)
   m_shown       = data_s.Read8();
   m_style       = data_s.Read32();
   m_id          = data_s.Read32();
-  number        = data_s.Read8();
+  m_number      = data_s.Read8();
 
   m_x = data_s.Read16();
   m_y = data_s.Read16();
   m_w = data_s.Read16();
   m_h = data_s.Read16();
 
-  /* I assume we will never create raw wxWindow object */
   (void)s.GetChild(); // We pass wxLayoutConstraints.
+
   m_validator = (wxValidator *)s.GetChild();
   if (!m_validator)
     m_validator = (wxValidator *)&wxDefaultValidator;
 
-  colour = (wxColour *)s.GetChild();
-  if (colour)
-    win_object->SetDefaultBackgroundColour(*colour);
-  colour = (wxColour *)s.GetChild();
-  if (colour)
-    win_object->SetDefaultForegroundColour(*colour);
-  font = (wxFont *)s.GetChild();
-  if (font)
-    win_object->SetFont(*font);
+  s.RemoveChildren(m_number+3);
 
-  s.RemoveChildren(number);
+  s.Recall();
 
   return;
 }
@@ -262,12 +270,15 @@ void WXSERIAL(wxFrame)::LoadObject(wxObjectInputStream& s)
 
   WXSERIAL(wxWindow)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   wxDataInputStream data_s(s);
 
-  frame->SetMenuBar(mbar);
   if (frame->GetClassInfo() == CLASSINFO(wxFrame))
     frame->Create(m_parent, m_id, m_title, wxPoint(m_x, m_y),
                   wxSize(m_w, m_h), m_style, m_name);
+  frame->SetMenuBar(mbar);
 
   frame->CreateStatusBar(data_s.Read8());
 }
@@ -348,17 +359,21 @@ void WXSERIAL(wxMenuItem)::StoreObject(wxObjectOutputStream& s)
   wxMenuItem *item = (wxMenuItem *)Object();
 
   if (s.FirstStage()) {
+#ifdef __WXGTK__
     s.AddChild(item->GetSubMenu());
+#endif
     return;
   }
 
   wxDataOutputStream data_s(s);
 
+#ifdef __WXGTK__
   data_s.Write8( item->GetId() );
   data_s.WriteString( item->GetText() );
   data_s.Write8( item->IsCheckable() );
   data_s.Write8( item->IsEnabled() );
   data_s.Write8( item->IsChecked() );
+#endif
 }
 
 void WXSERIAL(wxMenuItem)::LoadObject(wxObjectInputStream& s)
@@ -366,12 +381,14 @@ void WXSERIAL(wxMenuItem)::LoadObject(wxObjectInputStream& s)
   wxMenuItem *item = (wxMenuItem *)Object();
   wxDataInputStream data_s(s);
 
+#ifdef __WXGTK__
   item->SetId( data_s.Read8() );
   item->SetText( data_s.ReadString() );
   item->SetCheckable( data_s.Read8() );
   item->Enable( data_s.Read8() );
   item->Check( data_s.Read8() );
   item->SetSubMenu( (wxMenu *)s.GetChild() );
+#endif
 }
 
 /////////////////////////////////////////////////////////////////////////////
@@ -385,6 +402,9 @@ void WXSERIAL(wxPanel)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxWindow)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   ((wxPanel *)Object())->Create(m_parent, m_id, wxPoint(m_x, m_y),
                                 wxSize(m_w, m_h), m_style, m_name);
 }
@@ -400,6 +420,9 @@ void WXSERIAL(wxDialog)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxWindow)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   ((wxDialog *)Object())->Create(m_parent, m_id, m_title, wxPoint(m_x, m_y),
                                  wxSize(m_w, m_h), m_style, m_name);
 }
@@ -424,6 +447,11 @@ void WXSERIAL(wxMDIParentFrame)::LoadObject(wxObjectInputStream& s)
   wxMDIParentFrame *frame = (wxMDIParentFrame *)Object();
   wxMDIClientWindow *client;
 
+  if (s.SecondCall()) {
+    WXSERIAL(wxFrame)::LoadObject(s);
+    return;
+  }
+
   client = (wxMDIClientWindow *) s.GetChild();
 
   frame->Create(m_parent, m_id, m_title, wxPoint(m_x, m_y),
@@ -443,6 +471,9 @@ void WXSERIAL(wxMDIChildFrame)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxFrame)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   ((wxMDIChildFrame *)Object())->Create((wxMDIParentFrame *)m_parent,
                                         m_id, m_title,
                                         wxPoint(m_x, m_y), wxSize(m_w, m_h),
@@ -460,5 +491,8 @@ void WXSERIAL(wxMDIClientWindow)::LoadObject(wxObjectInputStream& s)
 {
   WXSERIAL(wxWindow)::LoadObject(s);
 
+  if (s.SecondCall())
+    return;
+
   ((wxMDIClientWindow *)Object())->CreateClient((wxMDIParentFrame *)m_parent, m_style);
 }
index 14c3423ff9d7628c9c0a7c0de667bfa8770de352..38cdb657c19e9669e278ec946f3704f0fbe5f0cc 100644 (file)
@@ -38,6 +38,7 @@ class WXSERIAL(wxWindow) : public WXSERIAL(wxObject)
   wxValidator *m_validator;
   wxColour m_bg_colour, m_fg_colour;
   long m_style;
+  int m_number;
 };
 
 DECLARE_SERIAL_CLASS(wxIndividualLayoutConstraint, wxObject)