X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/254847461268bbc10cb90ca91d5feff411a16bc6..822e690b221486b63895b5f14a7fbee2bc966fe5:/contrib/src/stc/stc.cpp diff --git a/contrib/src/stc/stc.cpp b/contrib/src/stc/stc.cpp index d3e43c21a7..8ab07a92ab 100644 --- a/contrib/src/stc/stc.cpp +++ b/contrib/src/stc/stc.cpp @@ -1,6 +1,6 @@ //////////////////////////////////////////////////////////////////////////// // Name: stc.cpp -// Purpose: A wxWindows implementation of Scintilla. This class is the +// Purpose: A wxWidgets implementation of Scintilla. This class is the // one meant to be used directly by wx applications. It does not // derive directly from the Scintilla classes, but instead // delegates most things to the real Scintilla class. @@ -76,7 +76,6 @@ DEFINE_EVENT_TYPE( wxEVT_STC_MODIFIED ) DEFINE_EVENT_TYPE( wxEVT_STC_MACRORECORD ) DEFINE_EVENT_TYPE( wxEVT_STC_MARGINCLICK ) DEFINE_EVENT_TYPE( wxEVT_STC_NEEDSHOWN ) -DEFINE_EVENT_TYPE( wxEVT_STC_POSCHANGED ) DEFINE_EVENT_TYPE( wxEVT_STC_PAINTED ) DEFINE_EVENT_TYPE( wxEVT_STC_USERLISTSELECTION ) DEFINE_EVENT_TYPE( wxEVT_STC_URIDROPPED ) @@ -169,6 +168,8 @@ void wxStyledTextCtrl::Create(wxWindow *parent, // Put Scintilla into unicode (UTF-8) mode SetCodePage(wxSTC_CP_UTF8); #endif + + SetBestFittingSize(size); } @@ -2547,9 +2548,12 @@ bool wxStyledTextCtrl::LoadFile(const wxString& filename) if (len > 0) { #if wxUSE_UNICODE - wxMemoryBuffer buffer(len); + wxMemoryBuffer buffer(len+1); success = (file.Read(buffer.GetData(), len) == len); - contents = wxString(buffer, *wxConvCurrent); + if (success) { + ((char*)buffer.GetData())[len] = 0; + contents = wxString(buffer, *wxConvCurrent, len); + } #else wxString buffer; success = (file.Read(wxStringBuffer(buffer, len), len) == len); @@ -2755,6 +2759,14 @@ void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { } +wxSize wxStyledTextCtrl::DoGetBestSize() const +{ + // What would be the best size for a wxSTC? + // Just give a reasonable minimum until something else can be figured out. + return wxSize(200,100); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events