* Added wxSerial DLL support for Borland 32

* 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
This commit is contained in:
Guilhem Lavaux 1998-09-17 17:30:13 +00:00
parent 46ccb5107f
commit 856d2e527d
19 changed files with 345 additions and 95 deletions

View 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

View 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;

View 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);

View 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

View 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;
}
}

View 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;
}

View 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

View 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;

View 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;
}

View 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"

View 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"

View 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)

View File

@ -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

View File

@ -35,11 +35,16 @@
#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);

View File

@ -21,11 +21,16 @@
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)

View File

@ -25,12 +25,13 @@
#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);

View 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)

View 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);
}

View 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)