diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index 8c68f743c7..3c390b1b08 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 @@ -5672,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 { @@ -5713,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 @@ -5760,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 f7ca8e70c6..d4f4f54d4e 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} @@ -7423,54 +7346,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); - //@} @@ -7591,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. @@ -7724,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 @@ -7736,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. @@ -7924,6 +7799,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)} @@ -8044,6 +7923,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. @@ -8059,7 +7959,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. @@ -8536,7 +8437,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; @@ -8684,6 +8586,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 */ @@ -8937,3 +8840,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 c9fdfe9ee8..4c71d284a5 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 @@ -2328,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); @@ -2349,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), @@ -2356,9 +2393,10 @@ 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) + m_useDefaultCurrentTextColour(true), + m_listType(NULL), m_posStart(NULL), m_startLen(NULL) { ComputeColours(); } @@ -2557,6 +2595,28 @@ 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 @@ -2587,11 +2647,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); @@ -2646,6 +2708,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 +2822,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 +2870,37 @@ 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 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); + + if ( stc ) + { + wxStyledTextEvent evt(wxEVT_STC_AUTOCOMP_SELECTION_CHANGE,stc->GetId()); + evt.SetEventObject(stc); + evt.SetListType(m_visualData->GetListType()); + + evt.SetPosition(m_visualData->GetPosStart() - + m_visualData->GetStartLen()); + + 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 +2931,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 ) @@ -3163,16 +3263,9 @@ 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) +void ListBoxImpl::SetListInfo(int* listType, int* posStart, int* startLen) { - m_visualData->SetColours(background, text, hiliBg, hiliText); -} - -void ListBoxImpl::UseListCtrlStyle(bool useListCtrl, const wxColour& currentBg, - const wxColour& currentText) -{ - m_visualData->UseListCtrlStyle(useListCtrl, currentBg, currentText); + m_visualData->SetSciListData(listType,posStart,startLen); } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 8449c870d2..714f5e4180 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -49,9 +49,7 @@ 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&); + void SetListInfo(int*, int*, int*); }; @@ -80,12 +78,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 diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 9dcd59814c..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)); } @@ -1399,24 +1402,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..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) @@ -5046,22 +5047,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..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) @@ -573,22 +574,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..679c0e16e0 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 @@ -789,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 { @@ -830,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 @@ -877,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 a3c0334908..5e7e1b9a5d 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} @@ -363,54 +286,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); - //@} @@ -531,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. @@ -664,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 @@ -676,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. @@ -864,6 +739,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)} @@ -984,6 +863,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. @@ -999,7 +899,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. @@ -1476,7 +1377,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; @@ -1624,6 +1526,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 */ @@ -1877,3 +1780,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;