X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2fcce89663e88cd41896ef62762660c1c1bbbc3a..8a094d7ba9913333b49f8561d97b8309d0023663:/src/stc/stc.cpp diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index c6438a351e..a9ca85c5c1 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -136,11 +136,24 @@ wxStyledTextCtrl::wxStyledTextCtrl(wxWindow *parent, const wxPoint& pos, const wxSize& size, long style, - const wxString& name) : - wxControl(parent, id, pos, size, - style | wxVSCROLL | wxHSCROLL | wxWANTS_CHARS | wxCLIP_CHILDREN, - wxDefaultValidator, name) + const wxString& name) { + m_swx = NULL; + Create(parent, id, pos, size, style, name); +} + + +void wxStyledTextCtrl::Create(wxWindow *parent, + wxWindowID id, + const wxPoint& pos, + const wxSize& size, + long style, + const wxString& name) +{ + wxControl::Create(parent, id, pos, size, + style | wxWANTS_CHARS | wxCLIP_CHILDREN, + wxDefaultValidator, name); + #ifdef LINK_LEXERS Scintilla_LinkLexers(); #endif @@ -2131,20 +2144,16 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (file.IsOpened()) { wxString contents; -#if wxUSE_UNICODE - wxMemoryBuffer buffer; -#else - wxString buffer; -#endif off_t len = file.Length(); if (len > 0) { - void *bufptr = buffer.GetWriteBuf(len); - success = (file.Read(bufptr, len) == len); - buffer.UngetWriteBuf(len); #if wxUSE_UNICODE + wxMemoryBuffer buffer(len); + success = (file.Read(buffer.GetData(), len) == len); contents = wxString(buffer, *wxConvCurrent); #else + wxString buffer; + success = (file.Read(wxStringBuffer(buffer, len), len) == len); contents = buffer; #endif } @@ -2201,8 +2210,10 @@ void wxStyledTextCtrl::OnScroll(wxScrollEvent& evt) { } void wxStyledTextCtrl::OnSize(wxSizeEvent& WXUNUSED(evt)) { - wxSize sz = GetClientSize(); - m_swx->DoSize(sz.x, sz.y); + if (m_swx) { + wxSize sz = GetClientSize(); + m_swx->DoSize(sz.x, sz.y); + } } void wxStyledTextCtrl::OnMouseLeftDown(wxMouseEvent& evt) {