X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2fcce89663e88cd41896ef62762660c1c1bbbc3a..395b914eae60df47b2adf35ef895cce14dfe120d:/src/stc/stc.cpp.in diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 2b531a6f54..a859ec1a47 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -136,11 +136,27 @@ 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) +{ +#ifdef __WXMAC__ + style |= wxVSCROLL | wxHSCROLL; +#endif + wxControl::Create(parent, id, pos, size, + style | wxWANTS_CHARS | wxCLIP_CHILDREN, + wxDefaultValidator, name); + #ifdef LINK_LEXERS Scintilla_LinkLexers(); #endif @@ -336,20 +352,19 @@ 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 - contents = wxString(buffer, *wxConvCurrent); + wxMemoryBuffer buffer(len+1); + success = (file.Read(buffer.GetData(), len) == len); + if (success) { + ((char*)buffer.GetData())[len] = 0; + contents = wxString(buffer, *wxConvCurrent, len); + } #else + wxString buffer; + success = (file.Read(wxStringBuffer(buffer, len), len) == len); contents = buffer; #endif } @@ -380,6 +395,14 @@ bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) { #endif +void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) { + m_swx->SetUseAntiAliasing(useAA); +} + +bool wxStyledTextCtrl::GetUseAntiAliasing() { + return m_swx->GetUseAntiAliasing(); +} + //---------------------------------------------------------------------- // Event handlers @@ -406,8 +429,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) { @@ -443,6 +468,14 @@ void wxStyledTextCtrl::OnMouseMiddleUp(wxMouseEvent& evt) { void wxStyledTextCtrl::OnContextMenu(wxContextMenuEvent& evt) { wxPoint pt = evt.GetPosition(); ScreenToClient(&pt.x, &pt.y); + /* + Show context menu at event point if it's within the window, + or at caret location if not + */ + wxHitTest ht = this->HitTest(pt); + if (ht != wxHT_WINDOW_INSIDE) { + pt = this->PointFromPosition(this->GetCurrentPos()); + } m_swx->DoContextMenu(Point(pt.x, pt.y)); } @@ -470,7 +503,7 @@ void wxStyledTextCtrl::OnChar(wxKeyEvent& evt) { // printf("OnChar key:%%d consumed:%%d ctrl:%%d alt:%%d skip:%%d\n", // key, m_lastKeyDownConsumed, ctrl, alt, skip); - if ( (key <= WXK_START || key > WXK_NUMPAD_DIVIDE) && + if ( (key <= WXK_START || key > WXK_COMMAND) && !m_lastKeyDownConsumed && !skip) { m_swx->DoAddChar(key); return; @@ -496,13 +529,15 @@ void wxStyledTextCtrl::OnKeyDown(wxKeyEvent& evt) { } -void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& WXUNUSED(evt)) { +void wxStyledTextCtrl::OnLoseFocus(wxFocusEvent& evt) { m_swx->DoLoseFocus(); + evt.Skip(); } -void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& WXUNUSED(evt)) { +void wxStyledTextCtrl::OnGainFocus(wxFocusEvent& evt) { m_swx->DoGainFocus(); + evt.Skip(); } @@ -527,6 +562,11 @@ void wxStyledTextCtrl::OnListBox(wxCommandEvent& WXUNUSED(evt)) { } +void wxStyledTextCtrl::OnIdle(wxIdleEvent& evt) { + m_swx->DoOnIdle(evt); +} + + //---------------------------------------------------------------------- // Turn notifications from Scintilla into events