Minor changes to wxTreeCtrl's horiz size,
Text stream now can write Mac/Unix/Dos EOL on resp. other platforms, Fixed return value of wxBufferedOutputStream::GetSize() and ::TellO() git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@5036 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -44,13 +44,22 @@ WXDLLEXPORT wxOutputStream& wxEndL(wxOutputStream& o_stream);
|
|||||||
#define wxStream_READ_ERR wxSTREAM_READ_ERROR
|
#define wxStream_READ_ERR wxSTREAM_READ_ERROR
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
wxStream_NOERROR = 0,
|
wxSTREAM_NO_ERROR = 0,
|
||||||
wxStream_EOF,
|
wxSTREAM_NO_ERR = wxSTREAM_NO_ERROR,
|
||||||
wxStream_WRITE_ERR,
|
wxSTREAM_NOERROR = wxSTREAM_NO_ERROR,
|
||||||
wxStream_READ_ERR
|
|
||||||
|
wxSTREAM_EOF,
|
||||||
|
|
||||||
|
wxSTREAM_WRITE_ERROR,
|
||||||
|
wxSTREAM_WRITE_ERR = wxSTREAM_WRITE_ERROR,
|
||||||
|
|
||||||
|
wxSTREAM_READ_ERROR,
|
||||||
|
wxSTREAM_READ_ERR = wxSTREAM_READ_ERROR,
|
||||||
|
|
||||||
} wxStreamError;
|
} wxStreamError;
|
||||||
|
|
||||||
class WXDLLEXPORT wxStreamBase {
|
class WXDLLEXPORT wxStreamBase
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxStreamBase();
|
wxStreamBase();
|
||||||
virtual ~wxStreamBase();
|
virtual ~wxStreamBase();
|
||||||
@@ -61,20 +70,19 @@ class WXDLLEXPORT wxStreamBase {
|
|||||||
size_t StreamSize() const { return GetSize(); }
|
size_t StreamSize() const { return GetSize(); }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
virtual size_t OnSysRead(void *buffer, size_t bufsize);
|
||||||
virtual size_t OnSysWrite(const void *buffer, size_t bufsize);
|
virtual size_t OnSysWrite(const void *buffer, size_t bufsize);
|
||||||
virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
virtual off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||||
virtual off_t OnSysTell() const;
|
virtual off_t OnSysTell() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class wxStreamBuffer;
|
friend class wxStreamBuffer;
|
||||||
|
|
||||||
size_t m_lastcount;
|
size_t m_lastcount;
|
||||||
wxStreamError m_lasterror;
|
wxStreamError m_lasterror;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxInputStream: public wxStreamBase {
|
class WXDLLEXPORT wxInputStream: public wxStreamBase
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxInputStream();
|
wxInputStream();
|
||||||
virtual ~wxInputStream();
|
virtual ~wxInputStream();
|
||||||
@@ -111,10 +119,10 @@ class WXDLLEXPORT wxInputStream: public wxStreamBase {
|
|||||||
|
|
||||||
char *AllocSpaceWBack(size_t needed_size);
|
char *AllocSpaceWBack(size_t needed_size);
|
||||||
size_t GetWBack(char *buf, size_t bsize);
|
size_t GetWBack(char *buf, size_t bsize);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxOutputStream: public wxStreamBase {
|
class WXDLLEXPORT wxOutputStream: public wxStreamBase
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxOutputStream();
|
wxOutputStream();
|
||||||
virtual ~wxOutputStream();
|
virtual ~wxOutputStream();
|
||||||
@@ -141,7 +149,8 @@ class WXDLLEXPORT wxOutputStream: public wxStreamBase {
|
|||||||
// A stream for measuring streamed output
|
// A stream for measuring streamed output
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxCountingOutputStream: public wxOutputStream {
|
class wxCountingOutputStream: public wxOutputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxCountingOutputStream();
|
wxCountingOutputStream();
|
||||||
|
|
||||||
@@ -149,12 +158,10 @@ class wxCountingOutputStream: public wxOutputStream {
|
|||||||
bool Ok() const { return TRUE; }
|
bool Ok() const { return TRUE; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
size_t OnSysWrite(const void *buffer, size_t size);
|
size_t OnSysWrite(const void *buffer, size_t size);
|
||||||
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
off_t OnSysSeek(off_t pos, wxSeekMode mode);
|
||||||
off_t OnSysTell() const;
|
off_t OnSysTell() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
size_t m_currentPos;
|
size_t m_currentPos;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -163,7 +170,8 @@ class wxCountingOutputStream: public wxOutputStream {
|
|||||||
// "Filter" streams
|
// "Filter" streams
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxFilterInputStream: public wxInputStream {
|
class WXDLLEXPORT wxFilterInputStream: public wxInputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxFilterInputStream();
|
wxFilterInputStream();
|
||||||
wxFilterInputStream(wxInputStream& stream);
|
wxFilterInputStream(wxInputStream& stream);
|
||||||
@@ -177,7 +185,8 @@ class WXDLLEXPORT wxFilterInputStream: public wxInputStream {
|
|||||||
wxInputStream *m_parent_i_stream;
|
wxInputStream *m_parent_i_stream;
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream {
|
class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxFilterOutputStream();
|
wxFilterOutputStream();
|
||||||
wxFilterOutputStream(wxOutputStream& stream);
|
wxFilterOutputStream(wxOutputStream& stream);
|
||||||
@@ -193,23 +202,19 @@ class WXDLLEXPORT wxFilterOutputStream: public wxOutputStream {
|
|||||||
// Stream buffer
|
// Stream buffer
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxStreamBuffer {
|
class WXDLLEXPORT wxStreamBuffer
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
typedef enum {
|
typedef enum {
|
||||||
read = 0, write, read_write
|
read = 0, write, read_write
|
||||||
} BufMode;
|
} BufMode;
|
||||||
|
|
||||||
// -----------
|
|
||||||
// ctor & dtor
|
|
||||||
// -----------
|
|
||||||
wxStreamBuffer(wxStreamBase& stream, BufMode mode);
|
wxStreamBuffer(wxStreamBase& stream, BufMode mode);
|
||||||
wxStreamBuffer(BufMode mode);
|
wxStreamBuffer(BufMode mode);
|
||||||
wxStreamBuffer(const wxStreamBuffer& buf);
|
wxStreamBuffer(const wxStreamBuffer& buf);
|
||||||
~wxStreamBuffer();
|
~wxStreamBuffer();
|
||||||
|
|
||||||
// -----------
|
|
||||||
// Filtered IO
|
// Filtered IO
|
||||||
// -----------
|
|
||||||
size_t Read(void *buffer, size_t size);
|
size_t Read(void *buffer, size_t size);
|
||||||
size_t Read(wxStreamBuffer *buf);
|
size_t Read(wxStreamBuffer *buf);
|
||||||
size_t Write(const void *buffer, size_t size);
|
size_t Write(const void *buffer, size_t size);
|
||||||
@@ -221,9 +226,7 @@ class WXDLLEXPORT wxStreamBuffer {
|
|||||||
off_t Tell() const;
|
off_t Tell() const;
|
||||||
off_t Seek(off_t pos, wxSeekMode mode);
|
off_t Seek(off_t pos, wxSeekMode mode);
|
||||||
|
|
||||||
// --------------
|
|
||||||
// Buffer control
|
// Buffer control
|
||||||
// --------------
|
|
||||||
void ResetBuffer();
|
void ResetBuffer();
|
||||||
void SetBufferIO(char *buffer_start, char *buffer_end);
|
void SetBufferIO(char *buffer_start, char *buffer_end);
|
||||||
void SetBufferIO(size_t bufsize);
|
void SetBufferIO(size_t bufsize);
|
||||||
@@ -241,16 +244,13 @@ class WXDLLEXPORT wxStreamBuffer {
|
|||||||
bool FillBuffer();
|
bool FillBuffer();
|
||||||
size_t GetDataLeft();
|
size_t GetDataLeft();
|
||||||
|
|
||||||
// --------------
|
// Misc.
|
||||||
// Administration
|
|
||||||
// --------------
|
|
||||||
wxStreamBase *Stream() { return m_stream; }
|
wxStreamBase *Stream() { return m_stream; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void GetFromBuffer(void *buffer, size_t size);
|
void GetFromBuffer(void *buffer, size_t size);
|
||||||
void PutToBuffer(const void *buffer, size_t size);
|
void PutToBuffer(const void *buffer, size_t size);
|
||||||
|
|
||||||
protected:
|
|
||||||
char *m_buffer_start, *m_buffer_end, *m_buffer_pos;
|
char *m_buffer_start, *m_buffer_end, *m_buffer_pos;
|
||||||
size_t m_buffer_size;
|
size_t m_buffer_size;
|
||||||
|
|
||||||
@@ -265,7 +265,8 @@ class WXDLLEXPORT wxStreamBuffer {
|
|||||||
// wxBufferedStreams
|
// wxBufferedStreams
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
class wxBufferedInputStream: public wxFilterInputStream {
|
class wxBufferedInputStream: public wxFilterInputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxBufferedInputStream(wxInputStream& stream);
|
wxBufferedInputStream(wxInputStream& stream);
|
||||||
~wxBufferedInputStream();
|
~wxBufferedInputStream();
|
||||||
@@ -284,11 +285,11 @@ class wxBufferedInputStream: public wxFilterInputStream {
|
|||||||
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||||
off_t OnSysTell() const;
|
off_t OnSysTell() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
wxStreamBuffer *m_i_streambuf;
|
wxStreamBuffer *m_i_streambuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
class wxBufferedOutputStream: public wxFilterOutputStream {
|
class wxBufferedOutputStream: public wxFilterOutputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxBufferedOutputStream(wxOutputStream& stream);
|
wxBufferedOutputStream(wxOutputStream& stream);
|
||||||
~wxBufferedOutputStream();
|
~wxBufferedOutputStream();
|
||||||
@@ -301,6 +302,8 @@ class wxBufferedOutputStream: public wxFilterOutputStream {
|
|||||||
|
|
||||||
void Sync();
|
void Sync();
|
||||||
|
|
||||||
|
size_t GetSize() const;
|
||||||
|
|
||||||
wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; }
|
wxStreamBuffer *OutputStreamBuffer() const { return m_o_streambuf; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -308,7 +311,6 @@ class wxBufferedOutputStream: public wxFilterOutputStream {
|
|||||||
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
off_t OnSysSeek(off_t seek, wxSeekMode mode);
|
||||||
off_t OnSysTell() const;
|
off_t OnSysTell() const;
|
||||||
|
|
||||||
protected:
|
|
||||||
wxStreamBuffer *m_o_streambuf;
|
wxStreamBuffer *m_o_streambuf;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -28,7 +28,8 @@ typedef wxTextOutputStream& (*__wxTextOutputManip)(wxTextOutputStream&);
|
|||||||
|
|
||||||
WXDLLEXPORT wxTextOutputStream &endl( wxTextOutputStream &stream );
|
WXDLLEXPORT wxTextOutputStream &endl( wxTextOutputStream &stream );
|
||||||
|
|
||||||
class WXDLLEXPORT wxTextInputStream {
|
class WXDLLEXPORT wxTextInputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t") );
|
wxTextInputStream(wxInputStream& s, const wxString &sep=wxT(" \t") );
|
||||||
~wxTextInputStream();
|
~wxTextInputStream();
|
||||||
@@ -65,16 +66,27 @@ public:
|
|||||||
void SkipIfEndOfLine( wxChar c );
|
void SkipIfEndOfLine( wxChar c );
|
||||||
};
|
};
|
||||||
|
|
||||||
class WXDLLEXPORT wxTextOutputStream {
|
typedef enum {
|
||||||
|
wxEOL_NATIVE,
|
||||||
|
wxEOL_UNIX,
|
||||||
|
wxEOL_MAC,
|
||||||
|
wxEOL_DOS,
|
||||||
|
} wxEOL;
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxTextOutputStream
|
||||||
|
{
|
||||||
public:
|
public:
|
||||||
wxTextOutputStream(wxOutputStream& s);
|
wxTextOutputStream( wxOutputStream& s, wxEOL mode = wxEOL_NATIVE );
|
||||||
~wxTextOutputStream();
|
virtual ~wxTextOutputStream();
|
||||||
|
|
||||||
|
void SetMode( wxEOL mode = wxEOL_NATIVE );
|
||||||
|
wxEOL GetMode() { return m_mode; }
|
||||||
|
|
||||||
void Write32(wxUint32 i);
|
void Write32(wxUint32 i);
|
||||||
void Write16(wxUint16 i);
|
void Write16(wxUint16 i);
|
||||||
void Write8(wxUint8 i);
|
void Write8(wxUint8 i);
|
||||||
void WriteDouble(double d);
|
virtual void WriteDouble(double d);
|
||||||
void WriteString(const wxString& string);
|
virtual void WriteString(const wxString& string);
|
||||||
|
|
||||||
wxTextOutputStream& operator<<(const wxChar *string);
|
wxTextOutputStream& operator<<(const wxChar *string);
|
||||||
wxTextOutputStream& operator<<(const wxString& string);
|
wxTextOutputStream& operator<<(const wxString& string);
|
||||||
@@ -90,6 +102,7 @@ class WXDLLEXPORT wxTextOutputStream {
|
|||||||
|
|
||||||
protected:
|
protected:
|
||||||
wxOutputStream &m_output;
|
wxOutputStream &m_output;
|
||||||
|
wxEOL m_mode;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -469,7 +469,7 @@ void wxBoxSizer::RecalcSizes()
|
|||||||
wxSize wxBoxSizer::CalcMin()
|
wxSize wxBoxSizer::CalcMin()
|
||||||
{
|
{
|
||||||
if (m_children.GetCount() == 0)
|
if (m_children.GetCount() == 0)
|
||||||
return wxSize(2,2);
|
return wxSize(10,10);
|
||||||
|
|
||||||
m_stretchable = 0;
|
m_stretchable = 0;
|
||||||
m_minWidth = 0;
|
m_minWidth = 0;
|
||||||
|
@@ -423,21 +423,24 @@ off_t wxStreamBuffer::Seek(off_t pos, wxSeekMode mode)
|
|||||||
|
|
||||||
off_t wxStreamBuffer::Tell() const
|
off_t wxStreamBuffer::Tell() const
|
||||||
{
|
{
|
||||||
off_t pos;
|
off_t pos = m_stream->OnSysTell();
|
||||||
|
|
||||||
if (m_flushable) {
|
|
||||||
pos = m_stream->OnSysTell();
|
|
||||||
if (pos == wxInvalidOffset)
|
if (pos == wxInvalidOffset)
|
||||||
return wxInvalidOffset;
|
return wxInvalidOffset;
|
||||||
return pos - GetLastAccess() + GetIntPosition();
|
|
||||||
} else
|
pos += GetIntPosition();
|
||||||
return GetIntPosition();
|
|
||||||
|
if (m_mode == read && m_flushable)
|
||||||
|
pos -= GetLastAccess();
|
||||||
|
|
||||||
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t wxStreamBuffer::GetDataLeft()
|
size_t wxStreamBuffer::GetDataLeft()
|
||||||
{
|
{
|
||||||
|
/* Why is this done? RR. */
|
||||||
if (m_buffer_end == m_buffer_pos && m_flushable)
|
if (m_buffer_end == m_buffer_pos && m_flushable)
|
||||||
FillBuffer();
|
FillBuffer();
|
||||||
|
|
||||||
return m_buffer_end-m_buffer_pos;
|
return m_buffer_end-m_buffer_pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -493,14 +496,11 @@ wxInputStream::~wxInputStream()
|
|||||||
|
|
||||||
char *wxInputStream::AllocSpaceWBack(size_t needed_size)
|
char *wxInputStream::AllocSpaceWBack(size_t needed_size)
|
||||||
{
|
{
|
||||||
char *temp_b;
|
|
||||||
size_t toget;
|
|
||||||
|
|
||||||
/* get number of bytes left from previous wback buffer */
|
/* get number of bytes left from previous wback buffer */
|
||||||
toget = m_wbacksize - m_wbackcur;
|
size_t toget = m_wbacksize - m_wbackcur;
|
||||||
|
|
||||||
/* allocate a buffer large enough to hold prev + new data */
|
/* allocate a buffer large enough to hold prev + new data */
|
||||||
temp_b = (char *) malloc(needed_size + toget);
|
char *temp_b = (char *) malloc(needed_size + toget);
|
||||||
|
|
||||||
if (!temp_b)
|
if (!temp_b)
|
||||||
return NULL;
|
return NULL;
|
||||||
@@ -533,7 +533,8 @@ size_t wxInputStream::GetWBack(char *buf, size_t bsize)
|
|||||||
memcpy(buf, (m_wback+m_wbackcur), s_toget);
|
memcpy(buf, (m_wback+m_wbackcur), s_toget);
|
||||||
|
|
||||||
m_wbackcur += s_toget;
|
m_wbackcur += s_toget;
|
||||||
if (m_wbackcur == m_wbacksize) {
|
if (m_wbackcur == m_wbacksize)
|
||||||
|
{
|
||||||
free(m_wback);
|
free(m_wback);
|
||||||
m_wback = (char *)NULL;
|
m_wback = (char *)NULL;
|
||||||
m_wbacksize = 0;
|
m_wbacksize = 0;
|
||||||
@@ -545,9 +546,7 @@ size_t wxInputStream::GetWBack(char *buf, size_t bsize)
|
|||||||
|
|
||||||
size_t wxInputStream::Ungetch(const void *buf, size_t bufsize)
|
size_t wxInputStream::Ungetch(const void *buf, size_t bufsize)
|
||||||
{
|
{
|
||||||
char *ptrback;
|
char *ptrback = AllocSpaceWBack(bufsize);
|
||||||
|
|
||||||
ptrback = AllocSpaceWBack(bufsize);
|
|
||||||
if (!ptrback)
|
if (!ptrback)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -557,9 +556,7 @@ size_t wxInputStream::Ungetch(const void *buf, size_t bufsize)
|
|||||||
|
|
||||||
bool wxInputStream::Ungetch(char c)
|
bool wxInputStream::Ungetch(char c)
|
||||||
{
|
{
|
||||||
char *ptrback;
|
char * ptrback = AllocSpaceWBack(1);
|
||||||
|
|
||||||
ptrback = AllocSpaceWBack(1);
|
|
||||||
if (!ptrback)
|
if (!ptrback)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
@@ -576,11 +573,11 @@ char wxInputStream::GetC()
|
|||||||
|
|
||||||
wxInputStream& wxInputStream::Read(void *buffer, size_t size)
|
wxInputStream& wxInputStream::Read(void *buffer, size_t size)
|
||||||
{
|
{
|
||||||
size_t retsize;
|
|
||||||
char *buf = (char *)buffer;
|
char *buf = (char *)buffer;
|
||||||
|
|
||||||
retsize = GetWBack(buf, size);
|
size_t retsize = GetWBack(buf, size);
|
||||||
if (retsize == size) {
|
if (retsize == size)
|
||||||
|
{
|
||||||
m_lastcount = size;
|
m_lastcount = size;
|
||||||
m_lasterror = wxStream_NOERROR;
|
m_lasterror = wxStream_NOERROR;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -595,12 +592,13 @@ wxInputStream& wxInputStream::Read(void *buffer, size_t size)
|
|||||||
char wxInputStream::Peek()
|
char wxInputStream::Peek()
|
||||||
{
|
{
|
||||||
char c;
|
char c;
|
||||||
|
|
||||||
Read(&c, 1);
|
Read(&c, 1);
|
||||||
if (m_lasterror == wxStream_NOERROR) {
|
if (m_lasterror == wxStream_NOERROR)
|
||||||
|
{
|
||||||
Ungetch(c);
|
Ungetch(c);
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -609,7 +607,8 @@ wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
|||||||
char buf[BUF_TEMP_SIZE];
|
char buf[BUF_TEMP_SIZE];
|
||||||
size_t bytes_read = BUF_TEMP_SIZE;
|
size_t bytes_read = BUF_TEMP_SIZE;
|
||||||
|
|
||||||
while (bytes_read == BUF_TEMP_SIZE) {
|
while (bytes_read == BUF_TEMP_SIZE)
|
||||||
|
{
|
||||||
bytes_read = Read(buf, bytes_read).LastRead();
|
bytes_read = Read(buf, bytes_read).LastRead();
|
||||||
bytes_read = stream_out.Write(buf, bytes_read).LastWrite();
|
bytes_read = stream_out.Write(buf, bytes_read).LastWrite();
|
||||||
}
|
}
|
||||||
@@ -618,16 +617,17 @@ wxInputStream& wxInputStream::Read(wxOutputStream& stream_out)
|
|||||||
|
|
||||||
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
|
off_t wxInputStream::SeekI(off_t pos, wxSeekMode mode)
|
||||||
{
|
{
|
||||||
// Should be check and improve, just to remove a slight bug !
|
/* Should be check and improve, just to remove a slight bug !
|
||||||
// I don't know whether it should be put as well in wxFileInputStream::OnSysSeek ?
|
I don't know whether it should be put as well in wxFileInputStream::OnSysSeek ? */
|
||||||
if (m_lasterror==wxSTREAM_EOF)
|
if (m_lasterror==wxSTREAM_EOF)
|
||||||
m_lasterror=wxSTREAM_NOERROR;
|
m_lasterror=wxSTREAM_NOERROR;
|
||||||
|
|
||||||
// A call to SeekI() will automatically invalidate any previous call
|
/* A call to SeekI() will automatically invalidate any previous call
|
||||||
// to Ungetch(), otherwise it would be possible to SeeI() to one
|
to Ungetch(), otherwise it would be possible to SeekI() to one
|
||||||
// one position, unread some bytes there, SeekI() to another position
|
one position, unread some bytes there, SeekI() to another position
|
||||||
// and the data would be corrupted.
|
and the data would be corrupted. */
|
||||||
if (m_wback) {
|
if (m_wback)
|
||||||
|
{
|
||||||
free(m_wback);
|
free(m_wback);
|
||||||
m_wback = (char*) NULL;
|
m_wback = (char*) NULL;
|
||||||
m_wbacksize = 0;
|
m_wbacksize = 0;
|
||||||
@@ -733,25 +733,20 @@ size_t wxCountingOutputStream::OnSysWrite(const void *WXUNUSED(buffer), size_t s
|
|||||||
off_t wxCountingOutputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
off_t wxCountingOutputStream::OnSysSeek(off_t pos, wxSeekMode mode)
|
||||||
{
|
{
|
||||||
if (mode == wxFromStart)
|
if (mode == wxFromStart)
|
||||||
{
|
|
||||||
m_currentPos = pos;
|
m_currentPos = pos;
|
||||||
}
|
|
||||||
if (mode == wxFromEnd)
|
if (mode == wxFromEnd)
|
||||||
{
|
|
||||||
m_currentPos = m_lastcount + pos;
|
m_currentPos = m_lastcount + pos;
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
m_currentPos += pos;
|
m_currentPos += pos;
|
||||||
}
|
|
||||||
if (m_currentPos > m_lastcount) m_lastcount = m_currentPos;
|
if (m_currentPos > m_lastcount) m_lastcount = m_currentPos;
|
||||||
|
|
||||||
return m_currentPos; // ?
|
return m_currentPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
off_t wxCountingOutputStream::OnSysTell() const
|
off_t wxCountingOutputStream::OnSysTell() const
|
||||||
{
|
{
|
||||||
return m_currentPos; // ?
|
return m_currentPos;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -821,7 +816,8 @@ wxInputStream& wxBufferedInputStream::Read(void *buffer, size_t size)
|
|||||||
|
|
||||||
retsize = GetWBack(buf, size);
|
retsize = GetWBack(buf, size);
|
||||||
m_lastcount = retsize;
|
m_lastcount = retsize;
|
||||||
if (retsize == size) {
|
if (retsize == size)
|
||||||
|
{
|
||||||
m_lasterror = wxStream_NOERROR;
|
m_lasterror = wxStream_NOERROR;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
@@ -858,6 +854,7 @@ off_t wxBufferedInputStream::OnSysTell() const
|
|||||||
return m_parent_i_stream->TellI();
|
return m_parent_i_stream->TellI();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// wxBufferedOutputStream
|
// wxBufferedOutputStream
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -914,6 +911,11 @@ off_t wxBufferedOutputStream::OnSysTell() const
|
|||||||
return m_parent_o_stream->TellO();
|
return m_parent_o_stream->TellO();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t wxBufferedOutputStream::GetSize() const
|
||||||
|
{
|
||||||
|
return m_parent_o_stream->GetSize() + m_o_streambuf->GetIntPosition();
|
||||||
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Some IOManip function
|
// Some IOManip function
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@@ -323,15 +323,41 @@ wxTextInputStream& wxTextInputStream::operator>>(float& f)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextOutputStream::wxTextOutputStream(wxOutputStream& s)
|
wxTextOutputStream::wxTextOutputStream(wxOutputStream& s, wxEOL mode)
|
||||||
: m_output(s)
|
: m_output(s)
|
||||||
{
|
{
|
||||||
|
m_mode = mode;
|
||||||
|
if (m_mode == wxEOL_NATIVE)
|
||||||
|
{
|
||||||
|
#if defined(__WXMSW__) || defined(__WXPM__)
|
||||||
|
m_mode = wxEOL_DOS;
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
m_mode = wxEOL_MAC;
|
||||||
|
#else
|
||||||
|
m_mode = wxEOL_UNIX;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxTextOutputStream::~wxTextOutputStream()
|
wxTextOutputStream::~wxTextOutputStream()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxTextOutputStream::SetMode( wxEOL mode = wxEOL_NATIVE )
|
||||||
|
{
|
||||||
|
m_mode = mode;
|
||||||
|
if (m_mode == wxEOL_NATIVE)
|
||||||
|
{
|
||||||
|
#if defined(__WXMSW__) || defined(__WXPM__)
|
||||||
|
m_mode = wxEOL_DOS;
|
||||||
|
#elif defined(__WXMAC__)
|
||||||
|
m_mode = wxEOL_MAC;
|
||||||
|
#else
|
||||||
|
m_mode = wxEOL_UNIX;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void wxTextOutputStream::Write32(wxUint32 i)
|
void wxTextOutputStream::Write32(wxUint32 i)
|
||||||
{
|
{
|
||||||
wxString str;
|
wxString str;
|
||||||
@@ -371,25 +397,22 @@ void wxTextOutputStream::WriteString(const wxString& string)
|
|||||||
wxChar c = string[i];
|
wxChar c = string[i];
|
||||||
if (c == wxT('\n'))
|
if (c == wxT('\n'))
|
||||||
{
|
{
|
||||||
#if defined(__WINDOWS__)
|
if (m_mode == wxEOL_DOS)
|
||||||
|
{
|
||||||
c = wxT('\r');
|
c = wxT('\r');
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
||||||
c = wxT('\n');
|
c = wxT('\n');
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
||||||
#elif defined(__UNIX__)
|
} else
|
||||||
c = wxT('\n');
|
if (m_mode == wxEOL_MAC)
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
{
|
||||||
#elif defined(__WXMAC__)
|
|
||||||
c = wxT('\r');
|
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
|
||||||
#elif defined(__OS2__)
|
|
||||||
c = wxT('\r');
|
c = wxT('\r');
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
||||||
|
} else
|
||||||
|
{
|
||||||
c = wxT('\n');
|
c = wxT('\n');
|
||||||
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
m_output.Write( (const void*)(&c), sizeof(wxChar) );
|
||||||
#else
|
}
|
||||||
#error "wxTextOutputStream: unsupported platform."
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@@ -298,11 +298,8 @@ wxGenericTreeItem::wxGenericTreeItem(wxGenericTreeItem *parent,
|
|||||||
|
|
||||||
m_attr = (wxTreeItemAttr *)NULL;
|
m_attr = (wxTreeItemAttr *)NULL;
|
||||||
|
|
||||||
dc.GetTextExtent( m_text, &m_width, &m_height );
|
m_width = 0;
|
||||||
// TODO : Add the width of the image
|
m_height = 0;
|
||||||
// PB : We don't know which image is shown (image, selImage)
|
|
||||||
// We don't even know imageList from the treectrl this item belongs to !!!
|
|
||||||
// At this point m_width doesn't mean much, this can be remove !
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxGenericTreeItem::~wxGenericTreeItem()
|
wxGenericTreeItem::~wxGenericTreeItem()
|
||||||
@@ -1327,6 +1324,7 @@ void wxTreeCtrl::ScrollTo(const wxTreeItemId &item)
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
m_anchor->GetSize( x, y, this );
|
m_anchor->GetSize( x, y, this );
|
||||||
y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
||||||
|
x += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
||||||
int x_pos = GetScrollPos( wxHORIZONTAL );
|
int x_pos = GetScrollPos( wxHORIZONTAL );
|
||||||
// Item should appear at top
|
// Item should appear at top
|
||||||
SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, item_y/PIXELS_PER_UNIT );
|
SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, item_y/PIXELS_PER_UNIT );
|
||||||
@@ -1338,6 +1336,7 @@ void wxTreeCtrl::ScrollTo(const wxTreeItemId &item)
|
|||||||
int y = 0;
|
int y = 0;
|
||||||
m_anchor->GetSize( x, y, this );
|
m_anchor->GetSize( x, y, this );
|
||||||
y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
||||||
|
x += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
||||||
item_y += PIXELS_PER_UNIT+2;
|
item_y += PIXELS_PER_UNIT+2;
|
||||||
int x_pos = GetScrollPos( wxHORIZONTAL );
|
int x_pos = GetScrollPos( wxHORIZONTAL );
|
||||||
// Item should appear at bottom
|
// Item should appear at bottom
|
||||||
@@ -1435,8 +1434,8 @@ void wxTreeCtrl::AdjustMyScrollbars()
|
|||||||
int x = 0;
|
int x = 0;
|
||||||
int y = 0;
|
int y = 0;
|
||||||
m_anchor->GetSize( x, y, this );
|
m_anchor->GetSize( x, y, this );
|
||||||
//y += GetLineHeight(m_anchor);
|
|
||||||
y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
y += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
||||||
|
x += PIXELS_PER_UNIT+2; // one more scrollbar unit + 2 pixels
|
||||||
int x_pos = GetScrollPos( wxHORIZONTAL );
|
int x_pos = GetScrollPos( wxHORIZONTAL );
|
||||||
int y_pos = GetScrollPos( wxVERTICAL );
|
int y_pos = GetScrollPos( wxVERTICAL );
|
||||||
SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, y_pos );
|
SetScrollbars( PIXELS_PER_UNIT, PIXELS_PER_UNIT, x/PIXELS_PER_UNIT, y/PIXELS_PER_UNIT, x_pos, y_pos );
|
||||||
|
Reference in New Issue
Block a user