From caaebf43bc4c1bf57bde2c58d46a77e07f086353 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Tue, 25 Jun 2019 15:51:58 -0500 Subject: [PATCH 1/7] Remove wxSTC methods for configuring autocomp popup The wxSTC methods AutoCompSetColours and AutoCompUseListCtrl were added in fe7b332b7be1f958676f5eccab7459ab3a171403 to allow some configuration of the autocompletion popup window. Based on subsequent discussion, it was decided that a better method of configuring the popup and getting information about the configuration is needed. For now, simply remove the current methods while the better solution is created. In addition, since the configuration options are being removed, set the popup to have the appearance of a list control since that was the appearance before any configuration options were added. --- include/wx/stc/stc.h | 10 -------- interface/wx/stc/stc.h | 48 -------------------------------------- src/stc/PlatWX.cpp | 14 +---------- src/stc/PlatWX.h | 3 --- src/stc/ScintillaWX.cpp | 18 -------------- src/stc/ScintillaWX.h | 3 --- src/stc/stc.cpp | 16 ------------- src/stc/stc.cpp.in | 16 ------------- src/stc/stc.h.in | 10 -------- src/stc/stc.interface.h.in | 48 -------------------------------------- 10 files changed, 1 insertion(+), 185 deletions(-) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 8c68f743c7..53c6ab6032 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -5187,16 +5187,6 @@ public: // Register an image for use in autocompletion lists. void RegisterImage(int type, const wxBitmap& bmp); - // Set the colours used to display the items in an autocompletion list. - void AutoCompSetColours(const wxColour& background, const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText); - - // Use a wxListCtrl to display autocompletion lists. - void AutoCompUseListCtrl(bool useListCtrl = true, - const wxColour& currentBgColour = wxNullColour, - const wxColour& currentTextColour = wxNullColour); - // The following methods are nearly equivalent to their similarly named diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index f7ca8e70c6..21a3a4cac4 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -7423,54 +7423,6 @@ public: */ void RegisterImage(int type, const wxBitmap& bmp); - /** - Set the colours used to display the items in an autocompletion list. - - This method can be used if the default colours make the list hard to - read or if specific colours are desired for whatever reason. - @param background - The colour used for the background of the list. - @param text - The colour used for all text except for the selected item. - @param highlight - The colour used to highlight the selected item in the list. - @param highlightText - The colour used for the text of the selected item. - @remarks - To reset one or more of the colours to its default, - call this method with wxNullColour for the colour or colours - to be reset. - - @since 3.1.3 - */ - void AutoCompSetColours(const wxColour& background, const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText); - - /** - Use a wxListCtrl to display autocompletion and user lists. - - By default lists will be displayed in a wxListBox. Use this method to - display them in a wxListCtrl instead. The primary difference is that - wxListCtrl has hot tracking to highlight the item under the mouse cursor. - @param useListCtrl - Set this to true to use a wxListCtrl and to false to use a - wxListBox. - @param currentBgColour - The colour used to highlight the item under the mouse cursor. - @param currentTextColour - The colour used for the text of the item under the mouse cursor. - @remarks - To reset one or more of the colours to its default, - call this method with wxNullColour for the colour or colours - to be reset. - - @since 3.1.3 - */ - void AutoCompUseListCtrl(bool useListCtrl = true, - const wxColour& currentBgColour = wxNullColour, - const wxColour& currentTextColour = wxNullColour); - //@} diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index c9fdfe9ee8..0a1289e5c6 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2356,7 +2356,7 @@ wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), m_useDefaultTextColour(true), m_useDefaultHighlightBgColour(true), m_useDefaultHighlightTextColour(true), - m_hasListCtrlAppearance(false), + m_hasListCtrlAppearance(true), m_useDefaultCurrentBgColour(true), m_useDefaultCurrentTextColour(true) { @@ -3163,18 +3163,6 @@ void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) { m_listBox->SetDoubleClickAction(action, data); } -void ListBoxImpl::SetColours(const wxColour& background, const wxColour& text, - const wxColour& hiliBg, const wxColour& hiliText) -{ - m_visualData->SetColours(background, text, hiliBg, hiliText); -} - -void ListBoxImpl::UseListCtrlStyle(bool useListCtrl, const wxColour& currentBg, - const wxColour& currentText) -{ - m_visualData->UseListCtrlStyle(useListCtrl, currentBg, currentText); -} - ListBox::ListBox() { } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 8449c870d2..52c7eb92c9 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -49,9 +49,6 @@ public: virtual void ClearRegisteredImages() wxOVERRIDE; virtual void SetDoubleClickAction(CallBackAction, void *) wxOVERRIDE; virtual void SetList(const char* list, char separator, char typesep) wxOVERRIDE; - void SetColours(const wxColour&, const wxColour&, - const wxColour&, const wxColour&); - void UseListCtrlStyle(bool, const wxColour&, const wxColour&); }; diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 9dcd59814c..3796bf9f9f 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1399,24 +1399,6 @@ void ScintillaWX::DoRegisterImage(int type, const wxBitmap& bmp) { static_cast(ac.lb)->RegisterImageHelper(type, bmp); } -void ScintillaWX::SetListBoxColours(const wxColour& background, - const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText) -{ - static_cast(ac.lb)->SetColours(background, text, - highlight, highlightText); -} - -void ScintillaWX::UseListCtrlStyleForLists(bool useListCtrl, - const wxColour& currentBgColour, - const wxColour& currentTextColour) -{ - static_cast(ac.lb)->UseListCtrlStyle(useListCtrl, - currentBgColour, - currentTextColour); -} - sptr_t ScintillaWX::DirectFunction( ScintillaWX* swx, unsigned int iMessage, uptr_t wParam, sptr_t lParam) { return swx->WndProc(iMessage, wParam, lParam); diff --git a/src/stc/ScintillaWX.h b/src/stc/ScintillaWX.h index 5bbe6179c3..92079170e3 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -201,9 +201,6 @@ public: void SetPaintAbandoned(){paintState = paintAbandoned;} void DoMarkerDefineBitmap(int markerNumber, const wxBitmap& bmp); void DoRegisterImage(int type, const wxBitmap& bmp); - void SetListBoxColours(const wxColour&, const wxColour&, - const wxColour&, const wxColour&); - void UseListCtrlStyleForLists(bool, const wxColour&, const wxColour&); private: bool capturedMouse; diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index 54695d5466..b01802915c 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -5046,22 +5046,6 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) m_swx->DoRegisterImage(type, bmp); } -void wxStyledTextCtrl::AutoCompSetColours(const wxColour& background, - const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText) -{ - m_swx->SetListBoxColours(background, text, highlight, highlightText); -} - -void wxStyledTextCtrl::AutoCompUseListCtrl(bool useListCtrl, - const wxColour& currentBgColour, - const wxColour& currentTextColour) -{ - m_swx->UseListCtrlStyleForLists(useListCtrl, currentBgColour, - currentTextColour); -} - diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index 91807cf3f9..fb44624ab7 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -573,22 +573,6 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) m_swx->DoRegisterImage(type, bmp); } -void wxStyledTextCtrl::AutoCompSetColours(const wxColour& background, - const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText) -{ - m_swx->SetListBoxColours(background, text, highlight, highlightText); -} - -void wxStyledTextCtrl::AutoCompUseListCtrl(bool useListCtrl, - const wxColour& currentBgColour, - const wxColour& currentTextColour) -{ - m_swx->UseListCtrlStyleForLists(useListCtrl, currentBgColour, - currentTextColour); -} - diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 593b5dce88..503f127c25 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -304,16 +304,6 @@ public: // Register an image for use in autocompletion lists. void RegisterImage(int type, const wxBitmap& bmp); - // Set the colours used to display the items in an autocompletion list. - void AutoCompSetColours(const wxColour& background, const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText); - - // Use a wxListCtrl to display autocompletion lists. - void AutoCompUseListCtrl(bool useListCtrl = true, - const wxColour& currentBgColour = wxNullColour, - const wxColour& currentTextColour = wxNullColour); - // The following methods are nearly equivalent to their similarly named diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index a3c0334908..f2ac38130b 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -363,54 +363,6 @@ public: */ void RegisterImage(int type, const wxBitmap& bmp); - /** - Set the colours used to display the items in an autocompletion list. - - This method can be used if the default colours make the list hard to - read or if specific colours are desired for whatever reason. - @param background - The colour used for the background of the list. - @param text - The colour used for all text except for the selected item. - @param highlight - The colour used to highlight the selected item in the list. - @param highlightText - The colour used for the text of the selected item. - @remarks - To reset one or more of the colours to its default, - call this method with wxNullColour for the colour or colours - to be reset. - - @since 3.1.3 - */ - void AutoCompSetColours(const wxColour& background, const wxColour& text, - const wxColour& highlight, - const wxColour& highlightText); - - /** - Use a wxListCtrl to display autocompletion and user lists. - - By default lists will be displayed in a wxListBox. Use this method to - display them in a wxListCtrl instead. The primary difference is that - wxListCtrl has hot tracking to highlight the item under the mouse cursor. - @param useListCtrl - Set this to true to use a wxListCtrl and to false to use a - wxListBox. - @param currentBgColour - The colour used to highlight the item under the mouse cursor. - @param currentTextColour - The colour used for the text of the item under the mouse cursor. - @remarks - To reset one or more of the colours to its default, - call this method with wxNullColour for the colour or colours - to be reset. - - @since 3.1.3 - */ - void AutoCompUseListCtrl(bool useListCtrl = true, - const wxColour& currentBgColour = wxNullColour, - const wxColour& currentTextColour = wxNullColour); - //@} From d24f58cc5527e863770d01308741b9aaddfdf8a6 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 13 Jul 2019 12:23:06 -0500 Subject: [PATCH 2/7] Add AUTOCOMP_SELECTION_CHANGE event for wxSTC The SCN_AUTOCSELECTIONCHANGE notification was added in Scintilla 4.0 to notify an application when a new item is selected in an autocompletion or user list. However the version of Scintilla currently used is 3.7.2, so this potentially useful notification is not available. These changes allow an event corresponding to this notification to be generated completely in the wxWidgets portion of wxSTC. If the Scintilla library is ever updated to 4.0 or later, only one method should need to be modified let Scintilla generate the event instead. --- include/wx/stc/stc.h | 6 ++-- interface/wx/stc/stc.h | 30 +++++++++++++++- src/stc/PlatWX.cpp | 74 +++++++++++++++++++++++++++++++++----- src/stc/PlatWX.h | 4 +++ src/stc/ScintillaWX.cpp | 3 ++ src/stc/stc.cpp | 1 + src/stc/stc.cpp.in | 1 + src/stc/stc.h.in | 6 ++-- src/stc/stc.interface.h.in | 30 +++++++++++++++- 9 files changed, 141 insertions(+), 14 deletions(-) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 53c6ab6032..3c390b1b08 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -5662,6 +5662,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CLIPBOARD_COPY, wxStyledTex wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CLIPBOARD_PASTE, wxStyledTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_COMPLETED, wxStyledTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyledTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, wxStyledTextEvent ); #else enum { @@ -5703,7 +5704,8 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyle wxEVT_STC_CLIPBOARD_COPY, wxEVT_STC_CLIPBOARD_PASTE, wxEVT_STC_AUTOCOMP_COMPLETED, - wxEVT_STC_MARGIN_RIGHT_CLICK + wxEVT_STC_MARGIN_RIGHT_CLICK, + wxEVT_STC_AUTOCOMP_SELECTION_CHANGE }; #endif @@ -5750,7 +5752,7 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_CLIPBOARD_PASTE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CLIPBOARD_PASTE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #define EVT_STC_AUTOCOMP_COMPLETED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_COMPLETED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #define EVT_STC_MARGIN_RIGHT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGIN_RIGHT_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), - +#define EVT_STC_AUTOCOMP_SELECTION_CHANGE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #endif #endif // wxUSE_STC diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index 21a3a4cac4..02030c40ad 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -7876,6 +7876,10 @@ public: @event{EVT_STC_AUTOCOMP_SELECTION(id, fn)} Process a @c wxEVT_STC_AUTOCOMP_SELECTION event. + @event{EVT_STC_AUTOCOMP_SELECTION_CHANGE(id, fn)} + Process a @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE event. + @since 3.1.3 + @event{EVT_STC_CALLTIP_CLICK(id, fn)} Process a @c wxEVT_STC_CALLTIP_CLICK event. @event{EVT_STC_CHANGE(id, fn)} @@ -7996,6 +8000,27 @@ public: @link wxStyledTextEvent::GetString GetString@endlink, @link wxStyledTextEvent::GetListCompletionMethod GetListCompletionMethod@endlink. + @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE + + - Generated when items are highlighted in an autocompletion or user list. + + - @link wxStyledTextEvent::GetPosition GetPosition@endlink will return the + position at which the list is being shown. + + - For a user list, @link wxStyledTextEvent::GetListType GetListType@endlink + will return the list type. The list type is a value input in to the + @link wxStyledTextCtrl::UserListShow wxStyledTextCtrl::UserListShow@endlink + method when a user list is created. + + - For an autocompletion list, + @link wxStyledTextEvent::GetListType GetListType@endlink will always return + zero. + + - Valid event functions: + @link wxStyledTextEvent::GetListType GetListType@endlink, + @link wxStyledTextEvent::GetPosition GetPosition@endlink, + @link wxStyledTextEvent::GetString GetString@endlink. + @c wxEVT_STC_CALLTIP_CLICK - Generated when a calltip has been clicked. @@ -8488,7 +8513,8 @@ public: wxStyledTextCtrl::UserListShow @endlink method and can be used to distinguish lists if more than one is used. - This method is valid for @c wxEVT_STC_USERLISTSELECTION events. + This method is valid for @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE and + @c wxEVT_STC_USERLISTSELECTION events. */ int GetListType() const; @@ -8636,6 +8662,7 @@ public: - @c wxEVT_STC_INDICATOR_RELEASE - @c wxEVT_STC_CALLTIP_CLICK - @c wxEVT_STC_AUTOCOMP_SELECTION + - @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE - @c wxEVT_STC_AUTOCOMP_COMPLETED - @c wxEVT_STC_MARGIN_RIGHT_CLICK */ @@ -8889,3 +8916,4 @@ const wxEventType wxEVT_STC_CLIPBOARD_COPY; const wxEventType wxEVT_STC_CLIPBOARD_PASTE; const wxEventType wxEVT_STC_AUTOCOMP_COMPLETED; const wxEventType wxEVT_STC_MARGIN_RIGHT_CLICK; +const wxEventType wxEVT_STC_AUTOCOMP_SELECTION_CHANGE; diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 0a1289e5c6..cb51295f68 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2562,7 +2562,7 @@ const wxColour& wxSTCListBoxVisualData::GetCurrentTextColour() const class wxSTCListBox : public wxSystemThemedControl { public: - wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int); + wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int, int, int*, int*); // wxWindow overrides virtual bool AcceptsFocus() const wxOVERRIDE; @@ -2587,11 +2587,13 @@ public: protected: // Helpers void AppendHelper(const wxString& text, int type); + void SelectHelper(int i); void AccountForBitmap(int type, bool recalculateItemHeight); void RecalculateItemHeight(); int TextBoxFromClientEdge() const; // Event handlers + void OnSelection(wxCommandEvent&); void OnDClick(wxCommandEvent&); void OnSysColourChanged(wxSysColourChangedEvent& event); void OnMouseMotion(wxMouseEvent& event); @@ -2614,6 +2616,9 @@ private: CallBackAction m_doubleClickAction; void* m_doubleClickActionData; int m_aveCharWidth; + int m_listType; + int* m_posStart; + int* m_startLen; // These drawing parameters are computed or set externally. int m_borderSize; @@ -2630,12 +2635,14 @@ private: int m_textExtraVerticalPadding; }; -wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) +wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, + int ht, int listType, int* posStart, int* startLen) :wxSystemThemedControl(), m_visualData(v), m_maxStrWidth(0), m_currentRow(wxNOT_FOUND), m_doubleClickAction(NULL), m_doubleClickActionData(NULL), m_aveCharWidth(8), m_textHeight(ht), m_itemHeight(ht), - m_textTopGap(0), m_imageAreaWidth(0), m_imageAreaHeight(0) + m_textTopGap(0), m_imageAreaWidth(0), m_imageAreaHeight(0), + m_listType(listType), m_posStart(posStart), m_startLen(startLen) { wxVListBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); @@ -2646,6 +2653,7 @@ wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) SetBackgroundColour(m_visualData->GetBgColour()); + Bind(wxEVT_LISTBOX, &wxSTCListBox::OnSelection, this); Bind(wxEVT_LISTBOX_DCLICK, &wxSTCListBox::OnDClick, this); Bind(wxEVT_SYS_COLOUR_CHANGED, &wxSTCListBox::OnSysColourChanged, this); @@ -2759,6 +2767,7 @@ int wxSTCListBox::Length() const void wxSTCListBox::Select(int n) { SetSelection(n); + SelectHelper(n); } void wxSTCListBox::GetValue(int n, char *value, int len) const @@ -2806,6 +2815,39 @@ void wxSTCListBox::AppendHelper(const wxString& text, int type) SetItemCount(m_labels.size()); } +void wxSTCListBox::SelectHelper(int i) +{ + // This method is used to trigger the wxEVT_STC_AUTOCOMP_SELECTION_CHANGE + // event. This event is generated directly here since the version of + // Scintilla currently used does not support it. + + //If the Scintilla component is updated, it should be sufficient to: + // 1) change this method to use a callback to let Scintilla generate the + // event. + // 2) remove the member variables m_listType, m_posStart, and m_startLen + // from this and the ListBoxImpl class since they will no longer be + // needed. The SetListInfo method can also be removed from ListBoxImpl. + + wxStyledTextCtrl* stc = wxDynamicCast(GetGrandParent(), wxStyledTextCtrl); + + if ( stc ) + { + wxStyledTextEvent evt(wxEVT_STC_AUTOCOMP_SELECTION_CHANGE,stc->GetId()); + evt.SetEventObject(stc); + evt.SetListType(m_listType); + + if ( m_posStart != NULL && m_startLen != NULL ) + evt.SetPosition(*m_posStart - *m_startLen); + else + evt.SetPosition(stc->AutoCompPosStart()); + + if ( 0 <= i && i < static_cast(m_labels.size()) ) + evt.SetString(m_labels[i]); + + stc->ProcessWindowEvent(evt); + } +} + void wxSTCListBox::AccountForBitmap(int type, bool recalculateItemHeight) { const int oldHeight = m_imageAreaHeight; @@ -2836,6 +2878,11 @@ int wxSTCListBox::TextBoxFromClientEdge() const return (m_imageAreaWidth == 0 ? 0 : m_imageAreaWidth + 2 * m_imagePadding); } +void wxSTCListBox::OnSelection(wxCommandEvent& event) +{ + SelectHelper(event.GetSelection()); +} + void wxSTCListBox::OnDClick(wxCommandEvent& WXUNUSED(event)) { if ( m_doubleClickAction ) @@ -3002,7 +3049,8 @@ void wxSTCListBox::OnDrawBackground(wxDC &dc, const wxRect &rect,size_t n) const class wxSTCListBoxWin : public wxSTCPopupWindow { public: - wxSTCListBoxWin(wxWindow*, wxSTCListBox**, wxSTCListBoxVisualData*, int); + wxSTCListBoxWin(wxWindow*, wxSTCListBox**, wxSTCListBoxVisualData*, + int, int, int*, int*); protected: void OnPaint(wxPaintEvent&); @@ -3012,10 +3060,11 @@ private: }; wxSTCListBoxWin::wxSTCListBoxWin(wxWindow* parent, wxSTCListBox** lb, - wxSTCListBoxVisualData* v, int h) + wxSTCListBoxVisualData* v, int h, + int t, int* p, int* l) :wxSTCPopupWindow(parent) { - *lb = new wxSTCListBox(this, v, h); + *lb = new wxSTCListBox(this, v, h, t, p, l); // Use the background of this window to form a frame around the listbox // except on macos where the native Scintilla popup has no frame. @@ -3049,7 +3098,8 @@ void wxSTCListBoxWin::OnPaint(wxPaintEvent& WXUNUSED(evt)) //---------------------------------------------------------------------- ListBoxImpl::ListBoxImpl() - :m_listBox(NULL), m_visualData(new wxSTCListBoxVisualData(5)) + :m_listBox(NULL), m_visualData(new wxSTCListBoxVisualData(5)), + m_listType(NULL), m_posStart(NULL), m_startLen(NULL) { } @@ -3068,7 +3118,8 @@ void ListBoxImpl::Create(Window &parent, int WXUNUSED(ctrlID), bool WXUNUSED(unicodeMode_), int WXUNUSED(technology_)) { wid = new wxSTCListBoxWin(GETWIN(parent.GetID()), &m_listBox, m_visualData, - lineHeight_); + lineHeight_, (m_listType?*m_listType:0), + m_posStart, m_startLen); } @@ -3163,6 +3214,13 @@ void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) { m_listBox->SetDoubleClickAction(action, data); } +void ListBoxImpl::SetListInfo(int* listType, int* posStart, int* startLen) +{ + m_listType = listType; + m_posStart = posStart; + m_startLen = startLen; +} + ListBox::ListBox() { } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 52c7eb92c9..c24bd4f50e 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -22,6 +22,9 @@ class ListBoxImpl : public ListBox { private: wxSTCListBox* m_listBox; wxSTCListBoxVisualData* m_visualData; + int* m_listType; + int* m_posStart; + int* m_startLen; public: ListBoxImpl(); @@ -49,6 +52,7 @@ public: virtual void ClearRegisteredImages() wxOVERRIDE; virtual void SetDoubleClickAction(CallBackAction, void *) wxOVERRIDE; virtual void SetList(const char* list, char separator, char typesep) wxOVERRIDE; + void SetListInfo(int*, int*, int*); }; diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 3796bf9f9f..74c57f50ff 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -293,6 +293,9 @@ void ScintillaWX::Initialise() { kmap.AssignCmdKey(SCK_UP, SCI_CTRL, SCI_DOCUMENTSTART); kmap.AssignCmdKey(SCK_DOWN, SCI_CTRL, SCI_DOCUMENTEND); #endif // __WXMAC__ + + static_cast(ac.lb)->SetListInfo(&listType, &(ac.posStart), + &(ac.startLen)); } diff --git a/src/stc/stc.cpp b/src/stc/stc.cpp index b01802915c..789b44caf7 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -136,6 +136,7 @@ wxDEFINE_EVENT( wxEVT_STC_CLIPBOARD_COPY, wxStyledTextEvent ); wxDEFINE_EVENT( wxEVT_STC_CLIPBOARD_PASTE, wxStyledTextEvent ); wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_COMPLETED, wxStyledTextEvent ); wxDEFINE_EVENT( wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, wxStyledTextEvent ); wxBEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index fb44624ab7..833b8c9a33 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -136,6 +136,7 @@ wxDEFINE_EVENT( wxEVT_STC_CLIPBOARD_COPY, wxStyledTextEvent ); wxDEFINE_EVENT( wxEVT_STC_CLIPBOARD_PASTE, wxStyledTextEvent ); wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_COMPLETED, wxStyledTextEvent ); wxDEFINE_EVENT( wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyledTextEvent ); +wxDEFINE_EVENT( wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, wxStyledTextEvent ); wxBEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index 503f127c25..679c0e16e0 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -779,6 +779,7 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CLIPBOARD_COPY, wxStyledTex wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_CLIPBOARD_PASTE, wxStyledTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_COMPLETED, wxStyledTextEvent ); wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyledTextEvent ); +wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, wxStyledTextEvent ); #else enum { @@ -820,7 +821,8 @@ wxDECLARE_EXPORTED_EVENT( WXDLLIMPEXP_STC, wxEVT_STC_MARGIN_RIGHT_CLICK, wxStyle wxEVT_STC_CLIPBOARD_COPY, wxEVT_STC_CLIPBOARD_PASTE, wxEVT_STC_AUTOCOMP_COMPLETED, - wxEVT_STC_MARGIN_RIGHT_CLICK + wxEVT_STC_MARGIN_RIGHT_CLICK, + wxEVT_STC_AUTOCOMP_SELECTION_CHANGE }; #endif @@ -867,7 +869,7 @@ typedef void (wxEvtHandler::*wxStyledTextEventFunction)(wxStyledTextEvent&); #define EVT_STC_CLIPBOARD_PASTE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_CLIPBOARD_PASTE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #define EVT_STC_AUTOCOMP_COMPLETED(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_COMPLETED, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #define EVT_STC_MARGIN_RIGHT_CLICK(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_MARGIN_RIGHT_CLICK, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), - +#define EVT_STC_AUTOCOMP_SELECTION_CHANGE(id, fn) wxDECLARE_EVENT_TABLE_ENTRY( wxEVT_STC_AUTOCOMP_SELECTION_CHANGE, id, wxID_ANY, wxStyledTextEventHandler( fn ), (wxObject *) NULL ), #endif #endif // wxUSE_STC diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index f2ac38130b..992fb32fb7 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -816,6 +816,10 @@ public: @event{EVT_STC_AUTOCOMP_SELECTION(id, fn)} Process a @c wxEVT_STC_AUTOCOMP_SELECTION event. + @event{EVT_STC_AUTOCOMP_SELECTION_CHANGE(id, fn)} + Process a @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE event. + @since 3.1.3 + @event{EVT_STC_CALLTIP_CLICK(id, fn)} Process a @c wxEVT_STC_CALLTIP_CLICK event. @event{EVT_STC_CHANGE(id, fn)} @@ -936,6 +940,27 @@ public: @link wxStyledTextEvent::GetString GetString@endlink, @link wxStyledTextEvent::GetListCompletionMethod GetListCompletionMethod@endlink. + @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE + + - Generated when items are highlighted in an autocompletion or user list. + + - @link wxStyledTextEvent::GetPosition GetPosition@endlink will return the + position at which the list is being shown. + + - For a user list, @link wxStyledTextEvent::GetListType GetListType@endlink + will return the list type. The list type is a value input in to the + @link wxStyledTextCtrl::UserListShow wxStyledTextCtrl::UserListShow@endlink + method when a user list is created. + + - For an autocompletion list, + @link wxStyledTextEvent::GetListType GetListType@endlink will always return + zero. + + - Valid event functions: + @link wxStyledTextEvent::GetListType GetListType@endlink, + @link wxStyledTextEvent::GetPosition GetPosition@endlink, + @link wxStyledTextEvent::GetString GetString@endlink. + @c wxEVT_STC_CALLTIP_CLICK - Generated when a calltip has been clicked. @@ -1428,7 +1453,8 @@ public: wxStyledTextCtrl::UserListShow @endlink method and can be used to distinguish lists if more than one is used. - This method is valid for @c wxEVT_STC_USERLISTSELECTION events. + This method is valid for @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE and + @c wxEVT_STC_USERLISTSELECTION events. */ int GetListType() const; @@ -1576,6 +1602,7 @@ public: - @c wxEVT_STC_INDICATOR_RELEASE - @c wxEVT_STC_CALLTIP_CLICK - @c wxEVT_STC_AUTOCOMP_SELECTION + - @c wxEVT_STC_AUTOCOMP_SELECTION_CHANGE - @c wxEVT_STC_AUTOCOMP_COMPLETED - @c wxEVT_STC_MARGIN_RIGHT_CLICK */ @@ -1829,3 +1856,4 @@ const wxEventType wxEVT_STC_CLIPBOARD_COPY; const wxEventType wxEVT_STC_CLIPBOARD_PASTE; const wxEventType wxEVT_STC_AUTOCOMP_COMPLETED; const wxEventType wxEVT_STC_MARGIN_RIGHT_CLICK; +const wxEventType wxEVT_STC_AUTOCOMP_SELECTION_CHANGE; From 61d4dbc66b855331836ea0083ade6f342ca95cf1 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 13 Jul 2019 12:40:27 -0500 Subject: [PATCH 3/7] Fix crash with wxSTC autocomp on macOS On macOS, the autocompletion popup maintains a pointer to its parent control since it sometimes needs to set a cursor on the control. However when the control is destroyed while the popup is active, the control is destroyed before the popup because of the delayed destruction used by the popup. This leaves the popup with a dangling pointer and can lead to crashes. To prevent this, let the popup handle the window destroy event for the control. Reset the pointer to NULL in that handler so that the popup will no longer try to access its parent control after it is deleted. --- src/stc/PlatWX.cpp | 33 ++++++++++++++++++++++++++++++--- src/stc/PlatWX.h | 4 ++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index cb51295f68..8fb73b8d7b 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2010,9 +2010,14 @@ PRectangle Window::GetMonitorRect(Point pt) { wxNonOwnedWindow::Create(parent, m_nativeWin); m_stc = wxDynamicCast(parent, wxStyledTextCtrl); m_isShown = false; + m_cursorSetByPopup = false; + m_prevCursor = wxSTC_CURSORNORMAL; Bind(wxEVT_ENTER_WINDOW, &wxSTCPopupBase::OnMouseEnter, this); Bind(wxEVT_LEAVE_WINDOW, &wxSTCPopupBase::OnMouseLeave, this); + + if ( m_stc ) + m_stc->Bind(wxEVT_DESTROY, &wxSTCPopupBase::OnParentDestroy, this); } wxSTCPopupBase::~wxSTCPopupBase() @@ -2020,7 +2025,11 @@ PRectangle Window::GetMonitorRect(Point pt) { UnsubclassWin(); CloseFloatingWindow(m_nativeWin); - SetSTCCursor(wxSTC_CURSORNORMAL); + if ( m_stc ) + { + m_stc->Unbind(wxEVT_DESTROY, &wxSTCPopupBase::OnParentDestroy,this); + RestoreSTCCursor(); + } } bool wxSTCPopupBase::Show(bool show) @@ -2038,7 +2047,7 @@ PRectangle Window::GetMonitorRect(Point pt) { else { HideFloatingWindow(m_nativeWin); - SetSTCCursor(wxSTC_CURSORNORMAL); + RestoreSTCCursor(); } return true; @@ -2056,7 +2065,20 @@ PRectangle Window::GetMonitorRect(Point pt) { void wxSTCPopupBase::SetSTCCursor(int cursor) { if ( m_stc ) + { + m_cursorSetByPopup = true; + m_prevCursor = m_stc->GetSTCCursor(); m_stc->SetSTCCursor(cursor); + } + } + + void wxSTCPopupBase::RestoreSTCCursor() + { + if ( m_stc != NULL && m_cursorSetByPopup ) + m_stc->SetSTCCursor(m_prevCursor); + + m_cursorSetByPopup = false; + m_prevCursor = wxSTC_CURSORNORMAL; } void wxSTCPopupBase::OnMouseEnter(wxMouseEvent& WXUNUSED(event)) @@ -2066,7 +2088,12 @@ PRectangle Window::GetMonitorRect(Point pt) { void wxSTCPopupBase::OnMouseLeave(wxMouseEvent& WXUNUSED(event)) { - SetSTCCursor(wxSTC_CURSORNORMAL); + RestoreSTCCursor(); + } + + void wxSTCPopupBase::OnParentDestroy(wxWindowDestroyEvent& WXUNUSED(event)) + { + m_stc = NULL; } #elif wxUSE_POPUPWIN diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index c24bd4f50e..8d1a73e63f 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -81,12 +81,16 @@ public: protected: virtual void DoSetSize(int, int, int, int, int) wxOVERRIDE; void SetSTCCursor(int); + void RestoreSTCCursor(); void OnMouseEnter(wxMouseEvent&); void OnMouseLeave(wxMouseEvent&); + void OnParentDestroy(wxWindowDestroyEvent& event); private: WX_NSWindow m_nativeWin; wxStyledTextCtrl* m_stc; + bool m_cursorSetByPopup; + int m_prevCursor; }; #elif wxUSE_POPUPWIN From 67825e42f722841cf58a7ee569d4544c42acc6bd Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Fri, 12 Jul 2019 16:28:51 -0500 Subject: [PATCH 4/7] Update wxEVT_STC_CHANGE documentation --- interface/wx/stc/stc.h | 3 ++- src/stc/stc.interface.h.in | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index 02030c40ad..e2ce16e9a9 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -8036,7 +8036,8 @@ public: - Generated when the text of the document has changed. - - This an older style event and should probably not be used in new code. + - This an older style event and should probably not be used in new code. Use + @c wxEVT_STC_MODIFIED instead. - Valid event functions: none. diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index 992fb32fb7..17f95c5375 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -976,7 +976,8 @@ public: - Generated when the text of the document has changed. - - This an older style event and should probably not be used in new code. + - This an older style event and should probably not be used in new code. Use + @c wxEVT_STC_MODIFIED instead. - Valid event functions: none. From 3ce4a89c067cee2d3be53b7ddea24ef80fa2f3e1 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 13 Jul 2019 12:56:21 -0500 Subject: [PATCH 5/7] Refer wxSTC documnentation to wxStyledTextEvent page The current wxSTC documentation page currently has a bare listing of the event types defined for wxStyledTextEvent. These event types are completely documented on the wxStyledTextEvent page. However the bare listing on the wxSTC page can lead to the conclusion that there is no documentation for the event types. Remove the bare listing from the wxSTC page and replace it with a referral to the wxStyledTextEvent page. This is consistent with other large classes such as wxGrid and wxRichTextCtrl that separate the documentation for their methods and events. --- interface/wx/stc/stc.h | 83 ++------------------------------------ src/stc/stc.interface.h.in | 83 ++------------------------------------ 2 files changed, 6 insertions(+), 160 deletions(-) diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index e2ce16e9a9..9797ad24c7 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -2777,6 +2777,9 @@ wxStyledTextCtrl is a 1 to 1 mapping of "raw" scintilla interface, whose documentation can be found in the Scintilla website (http://www.scintilla.org/). + Please see wxStyledTextEvent for the documentation of all event types you + can use with wxStyledTextCtrl. + @section stc_index Index of the member groups @@ -2830,86 +2833,6 @@ - @ref_member_group{text_entry, Text entry methods} - @ref_member_group{text_area, Text area methods} - - @section event_list Events - - @beginEventEmissionTable{wxStyledTextEvent} - @event{EVT_STC_AUTOCOMP_CANCELLED(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_CANCELLED event. - @event{EVT_STC_AUTOCOMP_CHAR_DELETED(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_CHAR_DELETED event. - @event{EVT_STC_AUTOCOMP_COMPLETED(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_COMPLETED event. - @since 3.1.1 - - @event{EVT_STC_AUTOCOMP_SELECTION(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_SELECTION event. - @event{EVT_STC_CALLTIP_CLICK(id, fn)} - Process a @c wxEVT_STC_CALLTIP_CLICK event. - @event{EVT_STC_CHANGE(id, fn)} - Process a @c wxEVT_STC_CHANGE event. - @event{EVT_STC_CHARADDED(id, fn)} - Process a @c wxEVT_STC_CHARADDED event. - @event{EVT_STC_CLIPBOARD_COPY(id, fn)} - Process a @c wxEVT_STC_CLIPBOARD_COPY event. - @since 3.1.0 - - @event{EVT_STC_CLIPBOARD_PASTE(id, fn)} - Process a @c wxEVT_STC_CLIPBOARD_PASTE event. - @since 3.1.0 - - @event{EVT_STC_DO_DROP(id, fn)} - Process a @c wxEVT_STC_DO_DROP event. - @event{EVT_STC_DOUBLECLICK(id, fn)} - Process a @c wxEVT_STC_DOUBLECLICK event. - @event{EVT_STC_DRAG_OVER(id, fn)} - Process a @c wxEVT_STC_DRAG_OVER event. - @event{EVT_STC_DWELLEND(id, fn)} - Process a @c wxEVT_STC_DWELLEND event. - @event{EVT_STC_DWELLSTART(id, fn)} - Process a @c wxEVT_STC_DWELLSTART event. - @event{EVT_STC_HOTSPOT_CLICK(id, fn)} - Process a @c wxEVT_STC_HOTSPOT_CLICK event. - @event{EVT_STC_HOTSPOT_DCLICK(id, fn)} - Process a @c wxEVT_STC_HOTSPOT_DCLICK event. - @event{EVT_STC_HOTSPOT_RELEASE_CLICK(id, fn)} - Process a @c wxEVT_STC_HOTSPOT_RELEASE_CLICK event. - @event{EVT_STC_INDICATOR_CLICK(id, fn)} - Process a @c wxEVT_STC_INDICATOR_CLICK event. - @event{EVT_STC_INDICATOR_RELEASE(id, fn)} - Process a @c wxEVT_STC_INDICATOR_RELEASE event. - @event{EVT_STC_MACRORECORD(id, fn)} - Process a @c wxEVT_STC_MACRORECORD event. - @event{EVT_STC_MARGIN_RIGHT_CLICK(id, fn)} - Process a @c wxEVT_STC_MARGIN_RIGHT_CLICK event. - @since 3.1.1 - - @event{EVT_STC_MARGINCLICK(id, fn)} - Process a @c wxEVT_STC_MARGINCLICK event. - @event{EVT_STC_MODIFIED(id, fn)} - Process a @c wxEVT_STC_MODIFIED event. - @event{EVT_STC_NEEDSHOWN(id, fn)} - Process a @c wxEVT_STC_NEEDSHOWN event. - @event{EVT_STC_PAINTED(id, fn)} - Process a @c wxEVT_STC_PAINTED event. - @event{EVT_STC_ROMODIFYATTEMPT(id, fn)} - Process a @c wxEVT_STC_ROMODIFYATTEMPT event. - @event{EVT_STC_SAVEPOINTLEFT(id, fn)} - Process a @c wxEVT_STC_SAVEPOINTLEFT event. - @event{EVT_STC_SAVEPOINTREACHED(id, fn)} - Process a @c wxEVT_STC_SAVEPOINTREACHED event. - @event{EVT_STC_START_DRAG(id, fn)} - Process a @c wxEVT_STC_START_DRAG event. - @event{EVT_STC_STYLENEEDED(id, fn)} - Process a @c wxEVT_STC_STYLENEEDED event. - @event{EVT_STC_UPDATEUI(id, fn)} - Process a @c wxEVT_STC_UPDATEUI event. - @event{EVT_STC_USERLISTSELECTION(id, fn)} - Process a @c wxEVT_STC_USERLISTSELECTION event. - @event{EVT_STC_ZOOM(id, fn)} - Process a @c wxEVT_STC_ZOOM event. - @endEventTable - @library{wxstc} @category{stc} diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index 17f95c5375..5b6881008c 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -61,6 +61,9 @@ wxStyledTextCtrl is a 1 to 1 mapping of "raw" scintilla interface, whose documentation can be found in the Scintilla website (http://www.scintilla.org/). + Please see wxStyledTextEvent for the documentation of all event types you + can use with wxStyledTextCtrl. + @section stc_index Index of the member groups @@ -72,86 +75,6 @@ - @ref_member_group{text_entry, Text entry methods} - @ref_member_group{text_area, Text area methods} - - @section event_list Events - - @beginEventEmissionTable{wxStyledTextEvent} - @event{EVT_STC_AUTOCOMP_CANCELLED(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_CANCELLED event. - @event{EVT_STC_AUTOCOMP_CHAR_DELETED(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_CHAR_DELETED event. - @event{EVT_STC_AUTOCOMP_COMPLETED(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_COMPLETED event. - @since 3.1.1 - - @event{EVT_STC_AUTOCOMP_SELECTION(id, fn)} - Process a @c wxEVT_STC_AUTOCOMP_SELECTION event. - @event{EVT_STC_CALLTIP_CLICK(id, fn)} - Process a @c wxEVT_STC_CALLTIP_CLICK event. - @event{EVT_STC_CHANGE(id, fn)} - Process a @c wxEVT_STC_CHANGE event. - @event{EVT_STC_CHARADDED(id, fn)} - Process a @c wxEVT_STC_CHARADDED event. - @event{EVT_STC_CLIPBOARD_COPY(id, fn)} - Process a @c wxEVT_STC_CLIPBOARD_COPY event. - @since 3.1.0 - - @event{EVT_STC_CLIPBOARD_PASTE(id, fn)} - Process a @c wxEVT_STC_CLIPBOARD_PASTE event. - @since 3.1.0 - - @event{EVT_STC_DO_DROP(id, fn)} - Process a @c wxEVT_STC_DO_DROP event. - @event{EVT_STC_DOUBLECLICK(id, fn)} - Process a @c wxEVT_STC_DOUBLECLICK event. - @event{EVT_STC_DRAG_OVER(id, fn)} - Process a @c wxEVT_STC_DRAG_OVER event. - @event{EVT_STC_DWELLEND(id, fn)} - Process a @c wxEVT_STC_DWELLEND event. - @event{EVT_STC_DWELLSTART(id, fn)} - Process a @c wxEVT_STC_DWELLSTART event. - @event{EVT_STC_HOTSPOT_CLICK(id, fn)} - Process a @c wxEVT_STC_HOTSPOT_CLICK event. - @event{EVT_STC_HOTSPOT_DCLICK(id, fn)} - Process a @c wxEVT_STC_HOTSPOT_DCLICK event. - @event{EVT_STC_HOTSPOT_RELEASE_CLICK(id, fn)} - Process a @c wxEVT_STC_HOTSPOT_RELEASE_CLICK event. - @event{EVT_STC_INDICATOR_CLICK(id, fn)} - Process a @c wxEVT_STC_INDICATOR_CLICK event. - @event{EVT_STC_INDICATOR_RELEASE(id, fn)} - Process a @c wxEVT_STC_INDICATOR_RELEASE event. - @event{EVT_STC_MACRORECORD(id, fn)} - Process a @c wxEVT_STC_MACRORECORD event. - @event{EVT_STC_MARGIN_RIGHT_CLICK(id, fn)} - Process a @c wxEVT_STC_MARGIN_RIGHT_CLICK event. - @since 3.1.1 - - @event{EVT_STC_MARGINCLICK(id, fn)} - Process a @c wxEVT_STC_MARGINCLICK event. - @event{EVT_STC_MODIFIED(id, fn)} - Process a @c wxEVT_STC_MODIFIED event. - @event{EVT_STC_NEEDSHOWN(id, fn)} - Process a @c wxEVT_STC_NEEDSHOWN event. - @event{EVT_STC_PAINTED(id, fn)} - Process a @c wxEVT_STC_PAINTED event. - @event{EVT_STC_ROMODIFYATTEMPT(id, fn)} - Process a @c wxEVT_STC_ROMODIFYATTEMPT event. - @event{EVT_STC_SAVEPOINTLEFT(id, fn)} - Process a @c wxEVT_STC_SAVEPOINTLEFT event. - @event{EVT_STC_SAVEPOINTREACHED(id, fn)} - Process a @c wxEVT_STC_SAVEPOINTREACHED event. - @event{EVT_STC_START_DRAG(id, fn)} - Process a @c wxEVT_STC_START_DRAG event. - @event{EVT_STC_STYLENEEDED(id, fn)} - Process a @c wxEVT_STC_STYLENEEDED event. - @event{EVT_STC_UPDATEUI(id, fn)} - Process a @c wxEVT_STC_UPDATEUI event. - @event{EVT_STC_USERLISTSELECTION(id, fn)} - Process a @c wxEVT_STC_USERLISTSELECTION event. - @event{EVT_STC_ZOOM(id, fn)} - Process a @c wxEVT_STC_ZOOM event. - @endEventTable - @library{wxstc} @category{stc} From 3ccb912e629f8f9ecd24f7ef3a41f1b607de91c7 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 13 Jul 2019 15:53:33 -0500 Subject: [PATCH 6/7] Store SELECTION_CHANGE data in wxSTCListBoxVisualData MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The first attempt to add the wxEVT_STC_AUTOCOMP_SELECTION_CHANGE event to wxSTC passed the data needed for the event through the constructor for the wxSTCListBox class. Instead of mdifying the constructor for wxSTCListBox, it’s better to store the data in the wxSTCListBoxVisualData class with accessors for setting and retrieving the data. --- src/stc/PlatWX.cpp | 80 +++++++++++++++++++++++++++++----------------- src/stc/PlatWX.h | 3 -- 2 files changed, 50 insertions(+), 33 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 8fb73b8d7b..4c71d284a5 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2355,6 +2355,12 @@ public: const wxColour& GetCurrentBgColour() const; const wxColour& GetCurrentTextColour() const; + // Data needed for SELECTION_CHANGE event + void SetSciListData(int*, int*, int*); + int GetListType() const; + int GetPosStart() const; + int GetStartLen() const; + private: WX_DECLARE_HASH_MAP(int, wxBitmap, wxIntegerHash, wxIntegerEqual, ImgList); @@ -2376,6 +2382,10 @@ private: wxColour m_currentTextColour; bool m_useDefaultCurrentBgColour; bool m_useDefaultCurrentTextColour; + + int* m_listType; + int* m_posStart; + int* m_startLen; }; wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), @@ -2385,7 +2395,8 @@ wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), m_useDefaultHighlightTextColour(true), m_hasListCtrlAppearance(true), m_useDefaultCurrentBgColour(true), - m_useDefaultCurrentTextColour(true) + m_useDefaultCurrentTextColour(true), + m_listType(NULL), m_posStart(NULL), m_startLen(NULL) { ComputeColours(); } @@ -2584,12 +2595,34 @@ const wxColour& wxSTCListBoxVisualData::GetCurrentTextColour() const return m_currentTextColour; } +void wxSTCListBoxVisualData::SetSciListData(int* type, int* pos, int* len) +{ + m_listType = type; + m_posStart = pos; + m_startLen = len; +} + +int wxSTCListBoxVisualData::GetListType() const +{ + return (m_listType?*m_listType:0); +} + +int wxSTCListBoxVisualData::GetPosStart() const +{ + return (m_posStart?*m_posStart:0); +} + +int wxSTCListBoxVisualData::GetStartLen() const +{ + return (m_startLen?*m_startLen:0); +} + // The class is intended to look like a standard listbox (with an optional // icon). However, it needs to look like it has focus even when it doesn't. class wxSTCListBox : public wxSystemThemedControl { public: - wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int, int, int*, int*); + wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int); // wxWindow overrides virtual bool AcceptsFocus() const wxOVERRIDE; @@ -2643,9 +2676,6 @@ private: CallBackAction m_doubleClickAction; void* m_doubleClickActionData; int m_aveCharWidth; - int m_listType; - int* m_posStart; - int* m_startLen; // These drawing parameters are computed or set externally. int m_borderSize; @@ -2662,14 +2692,12 @@ private: int m_textExtraVerticalPadding; }; -wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, - int ht, int listType, int* posStart, int* startLen) +wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) :wxSystemThemedControl(), m_visualData(v), m_maxStrWidth(0), m_currentRow(wxNOT_FOUND), m_doubleClickAction(NULL), m_doubleClickActionData(NULL), m_aveCharWidth(8), m_textHeight(ht), m_itemHeight(ht), - m_textTopGap(0), m_imageAreaWidth(0), m_imageAreaHeight(0), - m_listType(listType), m_posStart(posStart), m_startLen(startLen) + m_textTopGap(0), m_imageAreaWidth(0), m_imageAreaHeight(0) { wxVListBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE); @@ -2849,11 +2877,11 @@ void wxSTCListBox::SelectHelper(int i) // Scintilla currently used does not support it. //If the Scintilla component is updated, it should be sufficient to: - // 1) change this method to use a callback to let Scintilla generate the + // 1) Change this method to use a callback to let Scintilla generate the // event. - // 2) remove the member variables m_listType, m_posStart, and m_startLen - // from this and the ListBoxImpl class since they will no longer be - // needed. The SetListInfo method can also be removed from ListBoxImpl. + // 2) Remove the SELECTION_CHANGE event data from the wxSTCListBoxVisualData + // class and the SetListInfo method from the ListBoxImpl class since they + // will no longer be needed. wxStyledTextCtrl* stc = wxDynamicCast(GetGrandParent(), wxStyledTextCtrl); @@ -2861,12 +2889,10 @@ void wxSTCListBox::SelectHelper(int i) { wxStyledTextEvent evt(wxEVT_STC_AUTOCOMP_SELECTION_CHANGE,stc->GetId()); evt.SetEventObject(stc); - evt.SetListType(m_listType); + evt.SetListType(m_visualData->GetListType()); - if ( m_posStart != NULL && m_startLen != NULL ) - evt.SetPosition(*m_posStart - *m_startLen); - else - evt.SetPosition(stc->AutoCompPosStart()); + evt.SetPosition(m_visualData->GetPosStart() - + m_visualData->GetStartLen()); if ( 0 <= i && i < static_cast(m_labels.size()) ) evt.SetString(m_labels[i]); @@ -3076,8 +3102,7 @@ void wxSTCListBox::OnDrawBackground(wxDC &dc, const wxRect &rect,size_t n) const class wxSTCListBoxWin : public wxSTCPopupWindow { public: - wxSTCListBoxWin(wxWindow*, wxSTCListBox**, wxSTCListBoxVisualData*, - int, int, int*, int*); + wxSTCListBoxWin(wxWindow*, wxSTCListBox**, wxSTCListBoxVisualData*, int); protected: void OnPaint(wxPaintEvent&); @@ -3087,11 +3112,10 @@ private: }; wxSTCListBoxWin::wxSTCListBoxWin(wxWindow* parent, wxSTCListBox** lb, - wxSTCListBoxVisualData* v, int h, - int t, int* p, int* l) + wxSTCListBoxVisualData* v, int h) :wxSTCPopupWindow(parent) { - *lb = new wxSTCListBox(this, v, h, t, p, l); + *lb = new wxSTCListBox(this, v, h); // Use the background of this window to form a frame around the listbox // except on macos where the native Scintilla popup has no frame. @@ -3125,8 +3149,7 @@ void wxSTCListBoxWin::OnPaint(wxPaintEvent& WXUNUSED(evt)) //---------------------------------------------------------------------- ListBoxImpl::ListBoxImpl() - :m_listBox(NULL), m_visualData(new wxSTCListBoxVisualData(5)), - m_listType(NULL), m_posStart(NULL), m_startLen(NULL) + :m_listBox(NULL), m_visualData(new wxSTCListBoxVisualData(5)) { } @@ -3145,8 +3168,7 @@ void ListBoxImpl::Create(Window &parent, int WXUNUSED(ctrlID), bool WXUNUSED(unicodeMode_), int WXUNUSED(technology_)) { wid = new wxSTCListBoxWin(GETWIN(parent.GetID()), &m_listBox, m_visualData, - lineHeight_, (m_listType?*m_listType:0), - m_posStart, m_startLen); + lineHeight_); } @@ -3243,9 +3265,7 @@ void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) { void ListBoxImpl::SetListInfo(int* listType, int* posStart, int* startLen) { - m_listType = listType; - m_posStart = posStart; - m_startLen = startLen; + m_visualData->SetSciListData(listType,posStart,startLen); } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 8d1a73e63f..714f5e4180 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -22,9 +22,6 @@ class ListBoxImpl : public ListBox { private: wxSTCListBox* m_listBox; wxSTCListBoxVisualData* m_visualData; - int* m_listType; - int* m_posStart; - int* m_startLen; public: ListBoxImpl(); From f18699c0af6c142871563030d5c895fd0c6156d4 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 14 Jul 2019 12:53:29 -0500 Subject: [PATCH 7/7] Fix invalid parameter names in wxSTC docs --- interface/wx/stc/stc.h | 6 +++--- src/stc/stc.interface.h.in | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/wx/stc/stc.h b/interface/wx/stc/stc.h index 9797ad24c7..d4f4f54d4e 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -7466,7 +7466,7 @@ public: @param value The value to replace the existing text with. */ - virtual void Replace(long from, long to, const wxString& text); + virtual void Replace(long from, long to, const wxString& value); /** Sets the insertion point at the given position. @@ -7599,7 +7599,7 @@ public: @return The length of the line, or -1 if @a lineNo was invalid. */ - virtual int GetLineLength(long n) const; + virtual int GetLineLength(long lineNo) const; /** Returns the contents of a given line in the text control, not including @@ -7611,7 +7611,7 @@ public: @return The contents of the line. */ - virtual wxString GetLineText(long n) const; + virtual wxString GetLineText(long lineNo) const; /** Returns the number of lines in the text control buffer. diff --git a/src/stc/stc.interface.h.in b/src/stc/stc.interface.h.in index 5b6881008c..5e7e1b9a5d 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -406,7 +406,7 @@ public: @param value The value to replace the existing text with. */ - virtual void Replace(long from, long to, const wxString& text); + virtual void Replace(long from, long to, const wxString& value); /** Sets the insertion point at the given position. @@ -539,7 +539,7 @@ public: @return The length of the line, or -1 if @a lineNo was invalid. */ - virtual int GetLineLength(long n) const; + virtual int GetLineLength(long lineNo) const; /** Returns the contents of a given line in the text control, not including @@ -551,7 +551,7 @@ public: @return The contents of the line. */ - virtual wxString GetLineText(long n) const; + virtual wxString GetLineText(long lineNo) const; /** Returns the number of lines in the text control buffer.