* wxMemoryStreams updates
* Various fixes about wxGTK and Unicode * Various fixes in wxStreams git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@3010 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -34,7 +34,7 @@ class wxBitmapButton;
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxButtonNameStr;
|
||||
extern const wxChar *wxButtonNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBitmapButton
|
||||
|
@@ -30,7 +30,7 @@ class wxButton;
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxButtonNameStr;
|
||||
extern const wxChar *wxButtonNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxButton
|
||||
|
@@ -30,7 +30,7 @@ class wxStaticText;
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxStaticTextNameStr;
|
||||
extern const wxChar *wxStaticTextNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxStaticText
|
||||
|
@@ -34,7 +34,7 @@ class wxBitmapButton;
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxButtonNameStr;
|
||||
extern const wxChar *wxButtonNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxBitmapButton
|
||||
|
@@ -30,7 +30,7 @@ class wxButton;
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxButtonNameStr;
|
||||
extern const wxChar *wxButtonNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxButton
|
||||
|
@@ -30,7 +30,7 @@ class wxStaticText;
|
||||
// global data
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
extern const char *wxStaticTextNameStr;
|
||||
extern const wxChar *wxStaticTextNameStr;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// wxStaticText
|
||||
|
@@ -25,12 +25,28 @@ class wxMemoryInputStream: public wxInputStream {
|
||||
virtual size_t StreamSize() const { return m_length; }
|
||||
|
||||
char Peek();
|
||||
|
||||
protected:
|
||||
wxStreamBuffer *m_i_streambuf;
|
||||
|
||||
protected:
|
||||
size_t OnSysRead(void *buffer, size_t nbytes);
|
||||
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
};
|
||||
|
||||
class wxMemoryOutputStream: public wxOutputStream {
|
||||
public:
|
||||
wxMemoryOutputStream(char *data = NULL, size_t length = 0);
|
||||
virtual ~wxMemoryOutputStream();
|
||||
|
||||
protected:
|
||||
wxStreamBuffer *m_o_streambuf;
|
||||
|
||||
protected:
|
||||
size_t OnSysWrite(const void *buffer, size_t nbytes);
|
||||
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
||||
off_t OnSysTell() const;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@@ -105,7 +105,7 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
wxTextCtrl& textCtrl = * GetTextCtrl();
|
||||
|
||||
textCtrl.Clear();
|
||||
textCtrl << "\nTest fstream vs. wxFileStream:\n\n";
|
||||
textCtrl << _T("\nTest fstream vs. wxFileStream:\n\n");
|
||||
|
||||
textCtrl.WriteText( "Writing to ofstream and wxFileOutputStream:\n" );
|
||||
|
||||
@@ -116,31 +116,31 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
|
||||
wxString tmp;
|
||||
signed int si = 0xFFFFFFFF;
|
||||
tmp.Printf( "Signed int: %d\n", si );
|
||||
tmp.Printf( _T("Signed int: %d\n"), si );
|
||||
textCtrl.WriteText( tmp );
|
||||
text_output << si << "\n";
|
||||
std_file_output << si << "\n";
|
||||
|
||||
unsigned int ui = 0xFFFFFFFF;
|
||||
tmp.Printf( "Unsigned int: %u\n", ui );
|
||||
tmp.Printf( _T("Unsigned int: %u\n"), ui );
|
||||
textCtrl.WriteText( tmp );
|
||||
text_output << ui << "\n";
|
||||
std_file_output << ui << "\n";
|
||||
|
||||
double d = 2.01234567890123456789;
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
tmp.Printf( _T("Double: %f\n"), d );
|
||||
textCtrl.WriteText( tmp );
|
||||
text_output << d << "\n";
|
||||
std_file_output << d << "\n";
|
||||
|
||||
float f = 0.00001;
|
||||
tmp.Printf( "Float: %f\n", f );
|
||||
tmp.Printf( _T("Float: %f\n"), f );
|
||||
textCtrl.WriteText( tmp );
|
||||
text_output << f << "\n";
|
||||
std_file_output << f << "\n";
|
||||
|
||||
wxString str( "Hello!" );
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
wxString str( _T("Hello!") );
|
||||
tmp.Printf( _T("String: %s\n"), str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
text_output << str << "\n";
|
||||
std_file_output << str.c_str() << "\n";
|
||||
@@ -150,23 +150,23 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
ifstream std_file_input( "test_std.dat" );
|
||||
|
||||
std_file_input >> si;
|
||||
tmp.Printf( "Signed int: %d\n", si );
|
||||
tmp.Printf( _T("Signed int: %d\n"), si );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
std_file_input >> ui;
|
||||
tmp.Printf( "Unsigned int: %u\n", ui );
|
||||
tmp.Printf( _T("Unsigned int: %u\n"), ui );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
std_file_input >> d;
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
tmp.Printf( _T("Double: %f\n"), d );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
std_file_input >> f;
|
||||
tmp.Printf( "Float: %f\n", f );
|
||||
tmp.Printf( _T("Float: %f\n"), f );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
std_file_input >> str;
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
tmp.Printf( _T("String: %s\n"), str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
textCtrl.WriteText( "\nReading from wxFileInputStream:\n" );
|
||||
@@ -178,23 +178,23 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
wxTextInputStream text_input( buf_input );
|
||||
|
||||
text_input >> si;
|
||||
tmp.Printf( "Signed int: %d\n", si );
|
||||
tmp.Printf( _T("Signed int: %d\n"), si );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
text_input >> ui;
|
||||
tmp.Printf( "Unsigned int: %u\n", ui );
|
||||
tmp.Printf( _T("Unsigned int: %u\n"), ui );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
text_input >> d;
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
tmp.Printf( _T("Double: %f\n"), d );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
text_input >> f;
|
||||
tmp.Printf( "Float: %f\n", f );
|
||||
tmp.Printf( _T("Float: %f\n"), f );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
text_input >> str;
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
tmp.Printf( _T("String: %s\n"), str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
|
||||
@@ -206,22 +206,22 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
wxDataOutputStream data_output( buf_output );
|
||||
|
||||
wxInt16 i16 = 0xFFFF;
|
||||
tmp.Printf( "Signed int16: %d\n", (int)i16 );
|
||||
tmp.Printf( _T("Signed int16: %d\n"), (int)i16 );
|
||||
textCtrl.WriteText( tmp );
|
||||
data_output.Write16( i16 );
|
||||
|
||||
wxUint16 ui16 = 0xFFFF;
|
||||
tmp.Printf( "Unsigned int16: %u\n", (unsigned int) ui16 );
|
||||
tmp.Printf( _T("Unsigned int16: %u\n"), (unsigned int) ui16 );
|
||||
textCtrl.WriteText( tmp );
|
||||
data_output.Write16( ui16 );
|
||||
|
||||
d = 2.01234567890123456789;
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
tmp.Printf( _T("Double: %f\n"), d );
|
||||
textCtrl.WriteText( tmp );
|
||||
data_output.WriteDouble( d );
|
||||
|
||||
str = "Hello!";
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
tmp.Printf( _T("String: %s\n"), str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
data_output.WriteString( str );
|
||||
|
||||
@@ -233,19 +233,19 @@ void MyApp::DoStreamDemo(wxCommandEvent& WXUNUSED(event))
|
||||
wxDataInputStream data_input( buf_input );
|
||||
|
||||
i16 = data_input.Read16();
|
||||
tmp.Printf( "Signed int16: %d\n", (int)i16 );
|
||||
tmp.Printf( _T("Signed int16: %d\n"), (int)i16 );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
ui16 = data_input.Read16();
|
||||
tmp.Printf( "Unsigned int16: %u\n", (unsigned int) ui16 );
|
||||
tmp.Printf( _T("Unsigned int16: %u\n"), (unsigned int) ui16 );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
d = data_input.ReadDouble();
|
||||
tmp.Printf( "Double: %f\n", d );
|
||||
tmp.Printf( _T("Double: %f\n"), d );
|
||||
textCtrl.WriteText( tmp );
|
||||
|
||||
str = data_input.ReadString();
|
||||
tmp.Printf( "String: %s\n", str.c_str() );
|
||||
tmp.Printf( _T("String: %s\n"), str.c_str() );
|
||||
textCtrl.WriteText( tmp );
|
||||
}
|
||||
|
||||
|
@@ -194,8 +194,9 @@ void wxDataOutputStream::Write8(wxUint8 i)
|
||||
|
||||
void wxDataOutputStream::WriteString(const wxString& string)
|
||||
{
|
||||
const wxWX2MBbuf buf = string.mb_str();
|
||||
Write32(string.Length());
|
||||
m_output->Write((const wxChar *) string, string.Length()*sizeof(wxChar));
|
||||
m_output->Write(buf, string.Len());
|
||||
}
|
||||
|
||||
// Must be at global scope for VC++ 5
|
||||
|
@@ -1297,7 +1297,7 @@ wxDocTemplate *wxDocManager::SelectDocumentType(wxDocTemplate **templates,
|
||||
}
|
||||
|
||||
wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document template"), _("Templates"), n,
|
||||
strings, data);
|
||||
strings, (char **)data);
|
||||
delete[] strings;
|
||||
delete[] data;
|
||||
return theTemplate;
|
||||
@@ -1320,7 +1320,7 @@ wxDocTemplate *wxDocManager::SelectViewType(wxDocTemplate **templates,
|
||||
}
|
||||
}
|
||||
wxDocTemplate *theTemplate = (wxDocTemplate *)wxGetSingleChoiceData(_("Select a document view"), _("Views"), n,
|
||||
strings, data);
|
||||
strings, (char **)data);
|
||||
delete[] strings;
|
||||
delete[] data;
|
||||
return theTemplate;
|
||||
|
@@ -181,7 +181,7 @@ bool wxHTTP::BuildRequest(const wxString& path, wxHTTP_Req req)
|
||||
{
|
||||
wxChar *tmp_buf;
|
||||
wxChar buf[200];
|
||||
const wxWX2MBbuf pathbuf;
|
||||
wxWX2MBbuf pathbuf(200);
|
||||
wxString tmp_str;
|
||||
|
||||
switch (req) {
|
||||
|
@@ -33,24 +33,37 @@
|
||||
wxMemoryInputStream::wxMemoryInputStream(const char *data, size_t len)
|
||||
: wxInputStream()
|
||||
{
|
||||
/*
|
||||
m_i_streambuf = new wxStreamBuffer(wxStreamBuffer::read);
|
||||
m_i_streambuf->SetBufferIO((char*) data, (char*) (data+len));
|
||||
m_i_streambuf->SetIntPosition(0); // seek to start pos
|
||||
m_i_streambuf->Fixed(TRUE);
|
||||
*/
|
||||
|
||||
m_length = len;
|
||||
}
|
||||
|
||||
wxMemoryInputStream::~wxMemoryInputStream()
|
||||
{
|
||||
delete m_i_streambuf;
|
||||
}
|
||||
|
||||
char wxMemoryInputStream::Peek()
|
||||
{
|
||||
/*
|
||||
return m_i_streambuf->GetBufferStart()[m_i_streambuf->GetIntPosition()];
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t wxMemoryInputStream::OnSysRead(void *buffer, size_t nbytes)
|
||||
{
|
||||
return m_i_streambuf->Read(buffer, nbytes);
|
||||
}
|
||||
|
||||
off_t wxMemoryInputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_i_streambuf->Seek(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxMemoryInputStream::OnSysTell() const
|
||||
{
|
||||
return m_i_streambuf->Tell();
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@@ -60,15 +73,31 @@ char wxMemoryInputStream::Peek()
|
||||
wxMemoryOutputStream::wxMemoryOutputStream(char *data, size_t len)
|
||||
: wxOutputStream()
|
||||
{
|
||||
/*
|
||||
m_o_streambuf = new wxStreamBuffer(wxStreamBuffer::write);
|
||||
if (data)
|
||||
m_o_streambuf->SetBufferIO(data, data+len);
|
||||
m_o_streambuf->Fixed(TRUE);
|
||||
*/
|
||||
}
|
||||
|
||||
wxMemoryOutputStream::~wxMemoryOutputStream()
|
||||
{
|
||||
delete m_o_streambuf;
|
||||
}
|
||||
|
||||
size_t wxMemoryOutputStream::OnSysWrite(const void *buffer, size_t nbytes)
|
||||
{
|
||||
return m_o_streambuf->Write(buffer, nbytes);
|
||||
}
|
||||
|
||||
off_t wxMemoryOutputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
||||
{
|
||||
return m_o_streambuf->Seek(pos, mode);
|
||||
}
|
||||
|
||||
off_t wxMemoryOutputStream::OnSysTell() const
|
||||
{
|
||||
return m_o_streambuf->Tell();
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
@@ -23,6 +23,7 @@
|
||||
#if wxUSE_STREAMS
|
||||
|
||||
#include "wx/txtstrm.h"
|
||||
#include <ctype.h>
|
||||
|
||||
wxTextInputStream::wxTextInputStream(wxInputStream& s)
|
||||
: m_input(&s)
|
||||
@@ -300,7 +301,7 @@ wxTextOutputStream& wxTextOutputStream::operator<<(const wxString& string)
|
||||
wxTextOutputStream& wxTextOutputStream::operator<<(wxChar c)
|
||||
{
|
||||
wxString tmp_str;
|
||||
tmp_str.Printf("%c", c);
|
||||
tmp_str.Printf(_T("%c"), c);
|
||||
WriteString(tmp_str);
|
||||
return *this;
|
||||
}
|
||||
|
@@ -231,17 +231,17 @@ wxProgressDialog::Update(int value, const wxString& newmsg)
|
||||
|
||||
if (m_elapsed)
|
||||
{
|
||||
s.Printf("%i:%02i:%02i", diff.GetHour(), diff.GetMinute(), diff.GetSecond());
|
||||
s.Printf(_T("%i:%02i:%02i"), diff.GetHour(), diff.GetMinute(), diff.GetSecond());
|
||||
if (s != m_elapsed->GetLabel()) m_elapsed->SetLabel(s);
|
||||
}
|
||||
if (m_estimated)
|
||||
{
|
||||
s.Printf("%i:%02i:%02i", estim / (60 * 60), (estim / 60) % 60, estim % 60);
|
||||
s.Printf(_T("%i:%02i:%02i"), estim / (60 * 60), (estim / 60) % 60, estim % 60);
|
||||
if (s != m_estimated->GetLabel()) m_estimated->SetLabel(s);
|
||||
}
|
||||
if (m_remaining)
|
||||
{
|
||||
s.Printf("%i:%02i:%02i", remai / (60 * 60), (remai / 60) % 60, remai % 60);
|
||||
s.Printf(_T("%i:%02i:%02i"), remai / (60 * 60), (remai / 60) % 60, remai % 60);
|
||||
if (s != m_remaining->GetLabel()) m_remaining->SetLabel(s);
|
||||
}
|
||||
}
|
||||
|
@@ -138,7 +138,7 @@ wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption,
|
||||
{
|
||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
|
||||
if ( dialog.ShowModal() == wxID_OK )
|
||||
return dialog.GetSelectionClientData();
|
||||
return (wxChar *)dialog.GetSelectionClientData();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -212,10 +212,13 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title )
|
||||
|
||||
/* local buffer in multibyte form */
|
||||
wxString buf;
|
||||
buf << '/' << str.mb_str();
|
||||
buf << _T('/') << str.c_str();
|
||||
|
||||
char *cbuf = new char[buf.Length()];
|
||||
strcpy(cbuf, buf.mbc_str());
|
||||
|
||||
GtkItemFactoryEntry entry;
|
||||
entry.path = (gchar *)buf.c_str(); // const_cast
|
||||
entry.path = (gchar *)cbuf; // const_cast
|
||||
entry.accelerator = (gchar*) NULL;
|
||||
entry.callback = (GtkItemFactoryCallback) NULL;
|
||||
entry.callback_action = 0;
|
||||
|
@@ -390,7 +390,7 @@ void wxTextCtrl::AppendText( const wxString &text )
|
||||
m_font.GetInternalFont(),
|
||||
m_foregroundColour.GetColor(),
|
||||
m_backgroundColour.GetColor(),
|
||||
text, text.length());
|
||||
text.mbc_str(), text.length());
|
||||
|
||||
}
|
||||
else
|
||||
|
@@ -138,7 +138,7 @@ wxChar *wxGetSingleChoiceData( const wxString& message, const wxString& caption,
|
||||
{
|
||||
wxSingleChoiceDialog dialog(parent, message, caption, n, choices, client_data);
|
||||
if ( dialog.ShowModal() == wxID_OK )
|
||||
return dialog.GetSelectionClientData();
|
||||
return (wxChar *)dialog.GetSelectionClientData();
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
@@ -212,10 +212,13 @@ void wxMenuBar::Append( wxMenu *menu, const wxString &title )
|
||||
|
||||
/* local buffer in multibyte form */
|
||||
wxString buf;
|
||||
buf << '/' << str.mb_str();
|
||||
buf << _T('/') << str.c_str();
|
||||
|
||||
char *cbuf = new char[buf.Length()];
|
||||
strcpy(cbuf, buf.mbc_str());
|
||||
|
||||
GtkItemFactoryEntry entry;
|
||||
entry.path = (gchar *)buf.c_str(); // const_cast
|
||||
entry.path = (gchar *)cbuf; // const_cast
|
||||
entry.accelerator = (gchar*) NULL;
|
||||
entry.callback = (GtkItemFactoryCallback) NULL;
|
||||
entry.callback_action = 0;
|
||||
|
@@ -390,7 +390,7 @@ void wxTextCtrl::AppendText( const wxString &text )
|
||||
m_font.GetInternalFont(),
|
||||
m_foregroundColour.GetColor(),
|
||||
m_backgroundColour.GetColor(),
|
||||
text, text.length());
|
||||
text.mbc_str(), text.length());
|
||||
|
||||
}
|
||||
else
|
||||
|
Reference in New Issue
Block a user