X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/4261ba88cfaf12f02e91082e20c8d4044b6cde0d..822e690b221486b63895b5f14a7fbee2bc966fe5:/contrib/src/stc/PlatWX.cpp diff --git a/contrib/src/stc/PlatWX.cpp b/contrib/src/stc/PlatWX.cpp index 46d478e701..b20f68fa34 100644 --- a/contrib/src/stc/PlatWX.cpp +++ b/contrib/src/stc/PlatWX.cpp @@ -1,5 +1,5 @@ // Scintilla source code edit control -// PlatWX.cxx - implementation of platform facilities on wxWindows +// PlatWX.cxx - implementation of platform facilities on wxWidgets // Copyright 1998-1999 by Neil Hodgson // Robin Dunn // The License.txt file describes the conditions under which this software may be distributed. @@ -684,6 +684,7 @@ public: : wxListView(parent, id, pos, size, style) {} + void OnFocus(wxFocusEvent& event) { GetParent()->SetFocus(); event.Skip(); @@ -692,7 +693,24 @@ public: void OnKillFocus(wxFocusEvent& WXUNUSED(event)) { // Do nothing. Prevents base class from resetting the colors... } + +#ifdef __WXMAC__ + // For some reason I don't understand yet the focus doesn't really leave + // the listbox like it should, so if we get any events feed them back to + // the wxSTC + void OnKeyDown(wxKeyEvent& event) { + GetGrandParent()->GetEventHandler()->ProcessEvent(event); + } + void OnChar(wxKeyEvent& event) { + GetGrandParent()->GetEventHandler()->ProcessEvent(event); + } + // And we need to force the focus back when being destroyed + ~wxSTCListBox() { + GetGrandParent()->SetFocus(); + } +#endif + private: DECLARE_EVENT_TABLE() }; @@ -700,6 +718,10 @@ private: BEGIN_EVENT_TABLE(wxSTCListBox, wxListView) EVT_SET_FOCUS( wxSTCListBox::OnFocus) EVT_KILL_FOCUS(wxSTCListBox::OnKillFocus) +#ifdef __WXMAC__ + EVT_KEY_DOWN( wxSTCListBox::OnKeyDown) + EVT_CHAR( wxSTCListBox::OnChar) +#endif END_EVENT_TABLE() @@ -736,7 +758,7 @@ public: // immediately. bool Destroy() { #ifdef __WXMAC__ - // There bottom edge of this window is not getting properly + // The bottom edge of this window is not getting properly // refreshed upon deletion, so help it out... wxWindow* p = GetParent(); wxRect r(GetPosition(), GetSize()); @@ -1229,6 +1251,14 @@ double ElapsedTime::Duration(bool reset) { #if wxUSE_UNICODE wxString stc2wx(const char* str, size_t len) { + // note: we assume that str is of length len not including the terminating null. + + if (!len) + return wxEmptyString; + else if (str[len-1] == 0) + // It's already terminated correctly. + return wxString(str, wxConvUTF8, len); + char *buffer=new char[len+1]; strncpy(buffer, str, len); buffer[len]=0;