From 518cdc57901a650b69d385b67f812a90a34fb5f4 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Mon, 11 Feb 2019 23:18:37 -0600 Subject: [PATCH 01/23] Demonstrate autocompletion in the stc sample This adds a demonstration of autocompletion for C preprocessor directives to the stc sample. It also shows how to register and use small images with the autocompletion popup. --- samples/stc/edit.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index e9aeac9990..335cbeccae 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -52,6 +52,22 @@ // The (uniform) style used for the annotations. const int ANNOTATION_STYLE = wxSTC_STYLE_LASTPREDEFINED + 1; +// A small image of a hashtag symbol used in the autocompletion window. +const char* hashtag_xpm[] = { +"10 10 2 1", +" c None", +". c #BD08F9", +" .. .. ", +" .. .. ", +"..........", +"..........", +" .. .. ", +" .. .. ", +"..........", +"..........", +" .. .. ", +" .. .. "}; + //============================================================================ // implementation //============================================================================ @@ -169,6 +185,10 @@ Edit::Edit (wxWindow *parent, wxWindowID id, // annotations AnnotationSetVisible(wxSTC_ANNOTATION_BOXED); + // autocompletion + wxBitmap bmp(hashtag_xpm); + RegisterImage(0, bmp); + // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, "_999999"); m_FoldingMargin = 16; @@ -481,6 +501,11 @@ void Edit::OnCharAdded (wxStyledTextEvent &event) { SetLineIndentation (currentLine, lineInd); GotoPos(PositionFromLine (currentLine) + lineInd); } + else if (chr == '#') { + wxString s = "define?0 elif?0 else?0 endif?0 error?0 if?0 ifdef?0 " + "ifndef?0 include?0 line?0 pragma?0 undef?0"; + AutoCompShow(0,s); + } } From 79e16c78bc9e7d42adc6f6a7df34a29df07f36fa Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 10 Mar 2019 19:08:13 -0500 Subject: [PATCH 02/23] Demonstrate call tip clicks in the stc sample This adds a demonstration of handling call tip clicks to the stc sample. Instead of showing a single call tip, 3 different call tips can be shown. The sample demonstrates how to move between the call tips depending on if the up or down button was clicked in the call tip window. --- samples/stc/edit.cpp | 47 +++++++++++++++++++++++++++++++++++++++----- samples/stc/edit.h | 7 +++++++ 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index 335cbeccae..bd2bfd6fb3 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -131,6 +131,7 @@ wxBEGIN_EVENT_TABLE (Edit, wxStyledTextCtrl) // stc EVT_STC_MARGINCLICK (wxID_ANY, Edit::OnMarginClick) EVT_STC_CHARADDED (wxID_ANY, Edit::OnCharAdded) + EVT_STC_CALLTIP_CLICK(wxID_ANY, Edit::OnCallTipClick) EVT_KEY_DOWN( Edit::OnKeyDown ) wxEND_EVENT_TABLE() @@ -189,6 +190,10 @@ Edit::Edit (wxWindow *parent, wxWindowID id, wxBitmap bmp(hashtag_xpm); RegisterImage(0, bmp); + //call tips + CallTipSetBackground(*wxYELLOW); + m_calltipNo = 1; + // miscellaneous m_LineNrMargin = TextWidth (wxSTC_STYLE_LINENUMBER, "_999999"); m_FoldingMargin = 16; @@ -231,11 +236,9 @@ void Edit::OnKeyDown (wxKeyEvent &event) CallTipCancel(); if (event.GetKeyCode() == WXK_SPACE && event.ControlDown() && event.ShiftDown()) { - int pos = GetCurrentPos(); - CallTipSetBackground(*wxYELLOW); - CallTipShow(pos, - "This is a CallTip with multiple lines.\n" - "It is meant to be a context sensitive popup helper for the user."); + // Show our first call tip at the current position of the caret. + m_calltipNo = 1; + ShowCallTipAt(GetCurrentPos()); return; } event.Skip(); @@ -508,9 +511,43 @@ void Edit::OnCharAdded (wxStyledTextEvent &event) { } } +void Edit::OnCallTipClick(wxStyledTextEvent &event) +{ + if ( event.GetPosition() == 1 ) { + // If position=1, the up arrow has been clicked. Show the next tip. + m_calltipNo = m_calltipNo==3?1:(m_calltipNo+1); + ShowCallTipAt(CallTipPosAtStart()); + } + else if ( event.GetPosition() == 2 ) { + // If position=2, the down arrow has been clicked. Show previous tip. + m_calltipNo = m_calltipNo==1?3:(m_calltipNo-1); + ShowCallTipAt(CallTipPosAtStart()); + } +} + //---------------------------------------------------------------------------- // private functions +void Edit::ShowCallTipAt(int position) +{ + // In a call tip string, the character '\001' will become a clickable + // up arrow and '\002' will become a clickable down arrow. + wxString ctString = wxString::Format("\001 %d of 3 \002 ", m_calltipNo); + if ( m_calltipNo == 1 ) + ctString += "This is a call tip. Try clicking the up or down buttons."; + else if ( m_calltipNo == 2 ) + ctString += "It is meant to be a context sensitive popup helper for " + "the user."; + else + ctString += "This is a call tip with multiple lines.\n" + "You can provide slightly longer help with " + "call tips like these."; + + if ( CallTipActive() ) + CallTipCancel(); + CallTipShow(position, ctString); +} + wxString Edit::DeterminePrefs (const wxString &filename) { LanguageInfo const* curInfo; diff --git a/samples/stc/edit.h b/samples/stc/edit.h index 703ebae395..09ca020847 100644 --- a/samples/stc/edit.h +++ b/samples/stc/edit.h @@ -105,9 +105,13 @@ public: // stc void OnMarginClick (wxStyledTextEvent &event); void OnCharAdded (wxStyledTextEvent &event); + void OnCallTipClick(wxStyledTextEvent &event); void OnKeyDown(wxKeyEvent &event); + // call tips + void ShowCallTipAt(int position); + //! language/lexer wxString DeterminePrefs (const wxString &filename); bool InitializePrefs (const wxString &filename); @@ -137,6 +141,9 @@ private: int m_FoldingMargin; int m_DividerID; + // call tip data + int m_calltipNo; + wxDECLARE_EVENT_TABLE(); }; From 75656067aeb6f94dbdc0d8da18b9bb80dd4b0e22 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Mon, 11 Mar 2019 13:27:35 -0500 Subject: [PATCH 03/23] Add wxSTCPopupWindow for wxSTC The wxSTCPopupWindow is intended to serve as a popup window for showing call tips and popup lists with wxSTC. This class is designed to show its content and respond to mouse clicks, but it should never take focus from its parent wxSTC. It is built with customizations for wxMSW, wxCocoa, and wxGTK+ to function in that way. --- src/stc/PlatWX.cpp | 207 +++++++++++++++++++++++++++++++++++++++++++++ src/stc/PlatWX.h | 83 ++++++++++++++++++ 2 files changed, 290 insertions(+) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 6ac1b876af..a907e4b955 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -32,6 +32,7 @@ #include "wx/tokenzr.h" #include "wx/dynlib.h" #include "wx/scopedarray.h" +#include "wx/toplevel.h" #ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" @@ -55,6 +56,12 @@ #include "wx/dcscreen.h" #endif +#if defined(__WXGTK__) && wxSTC_POPUP_IS_FRAME + #include "wx/gtk/private/wrapgtk.h" +#elif defined(__WXMSW__) + #include "wx/msw/wrapwin.h" +#endif + Point Point::FromLong(long lpoint) { return Point(lpoint & 0xFFFF, lpoint >> 16); } @@ -1983,6 +1990,206 @@ PRectangle Window::GetMonitorRect(Point pt) { return PRectangleFromwxRect(dpy.GetGeometry()); } + +//---------------------------------------------------------------------- +// wxSTCPopupBase and wxSTCPopupWindow + +#ifdef __WXOSX_COCOA__ + + wxSTCPopupBase::wxSTCPopupBase(wxWindow* parent):wxNonOwnedWindow() + { + } + + wxSTCPopupBase::~wxSTCPopupBase() + { + } + +#elif wxUSE_POPUPWIN + + wxSTCPopupBase::wxSTCPopupBase(wxWindow* parent) + :wxPopupWindow(parent, wxPU_CONTAINS_CONTROLS) + { + } + + #ifdef __WXGTK__ + + wxSTCPopupBase::~wxSTCPopupBase() + { + wxRect rect = GetRect(); + GetParent()->ScreenToClient(&(rect.x), &(rect.y)); + GetParent()->Refresh(false, &rect); + } + + #elif defined(__WXMSW__) + + // Do not activate the window when it is shown. + bool wxSTCPopupBase::Show(bool show) + { + if ( !wxWindowBase::Show(show) ) + return false; + + if ( show ) + { + HWND hWnd = reinterpret_cast(GetHandle()); + ::ShowWindow(hWnd, SW_SHOWNA ); + + ::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, + SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); + } + else + wxPopupWindow::Show(false); + + return true; + } + + // Do not activate in response to mouse clicks on this window. + bool wxSTCPopupBase::MSWHandleMessage(WXLRESULT *res, WXUINT msg, + WXWPARAM wParam, WXLPARAM lParam) + { + if ( msg == WM_MOUSEACTIVATE ) + { + *res = MA_NOACTIVATE; + return true; + } + else + return wxPopupWindow::MSWHandleMessage(res, msg, wParam,lParam); + } + + #endif // __WXGTK__ + +#else + + wxSTCPopupBase::wxSTCPopupBase(wxWindow* parent):wxFrame() + { + // Make sure the frame is initially hidden. However, GTK+ will hide the + // frame initially and doesn't like trying to hide it before it's + // created, so don't do it there. + #if !defined(__WXGTK__) + Hide(); + #endif + + wxFrame::Create(parent, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxFRAME_FLOAT_ON_PARENT | wxBORDER_NONE); + + #if defined(__WXGTK__) + gtk_window_set_accept_focus(GTK_WINDOW(this->GetHandle()), FALSE); + #endif + } + + #ifdef __WXMSW__ + + // Use ShowWithoutActivating instead of show. + bool wxSTCPopupBase::Show(bool show) + { + if ( show ) + { + if ( IsShown() ) + return false; + else + { + ShowWithoutActivating(); + return true; + } + } + else + return wxFrame::Show(false); + } + + // Do not activate in response to mouse clicks on this window. + bool wxSTCPopupBase::MSWHandleMessage(WXLRESULT *res, WXUINT msg, + WXWPARAM wParam, WXLPARAM lParam) + { + if ( msg == WM_MOUSEACTIVATE ) + { + *res = MA_NOACTIVATE; + return true; + } + else + return wxFrame::MSWHandleMessage(res, msg, wParam, lParam); + } + + #elif !wxSTC_POPUP_IS_CUSTOM + + void wxSTCPopupBase::ActivateParent() + { + // Although we're a frame, we always want the parent to be active, + // so raise it whenever we get shown, focused, etc. + wxTopLevelWindow *frame = wxDynamicCast( + wxGetTopLevelParent(GetParent()), wxTopLevelWindow); + if (frame) + frame->Raise(); + } + + bool wxSTCPopupBase::Show(bool show) + { + bool rv = wxFrame::Show(show); + if (rv && show) + ActivateParent(); + + #ifdef __WXMAC__ + GetParent()->Refresh(false); + #endif + } + + #endif + +#endif // __WXOSX_COCOA__ + +wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent):wxSTCPopupBase(parent) +{ + #if !wxSTC_POPUP_IS_CUSTOM + Bind(wxEVT_SET_FOCUS, &wxSTCPopupWindow::OnFocus, this); + #endif +} + +bool wxSTCPopupWindow::Destroy() +{ + #if defined(__WXMAC__) && wxSTC_POPUP_IS_FRAME && !wxSTC_POPUP_IS_CUSTOM + // The bottom edge of this window is not getting properly + // refreshed upon deletion, so help it out... + wxWindow* p = GetParent(); + wxRect r(GetPosition(), GetSize()); + r.SetHeight(r.GetHeight()+1); + p->Refresh(false, &r); + #endif + + if ( !wxPendingDelete.Member(this) ) + wxPendingDelete.Append(this); + + return true; +} + +bool wxSTCPopupWindow::AcceptsFocus() const +{ + return false; +} + +void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) +{ + // convert coords to screen coords since we're a top-level window + if (x != wxDefaultCoord) + GetParent()->ClientToScreen(&x, NULL); + + if (y != wxDefaultCoord) + GetParent()->ClientToScreen(NULL, &y); + + wxSTCPopupBase::DoSetSize(x, y, width, height, flags); +} + +#if !wxSTC_POPUP_IS_CUSTOM + void wxSTCPopupWindow::OnFocus(wxFocusEvent& event) + { + #if wxSTC_POPUP_IS_FRAME + ActivateParent(); + #endif + + GetParent()->SetFocus(); + event.Skip(); + } +#endif // !wxSTC_POPUP_IS_CUSTOM + + //---------------------------------------------------------------------- // Helper classes for ListBox diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index ce308b50a0..93dc33f380 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -54,6 +54,89 @@ public: virtual void SetList(const char* list, char separator, char typesep) wxOVERRIDE; }; + +//---------------------------------------------------------------------- +// wxSTCPopupWindow + +#if defined(__WXOSX_COCOA__) || defined(__WXMSW__) || defined(__WXGTK__) + #define wxSTC_POPUP_IS_CUSTOM 1 +#else + #define wxSTC_POPUP_IS_CUSTOM 0 +#endif + +// Define the base class used for wxSTCPopupWindow. +#ifdef __WXOSX_COCOA__ + + #include "wx/nonownedwnd.h" + #define wxSTC_POPUP_IS_FRAME 0 + + class wxSTCPopupBase:public wxNonOwnedWindow + { + public: + wxSTCPopupBase(wxWindow*); + virtual ~wxSTCPopupBase(); + }; + +#elif wxUSE_POPUPWIN + + #include "wx/popupwin.h" + #define wxSTC_POPUP_IS_FRAME 0 + + class wxSTCPopupBase:public wxPopupWindow + { + public: + wxSTCPopupBase(wxWindow*); + #ifdef __WXGTK__ + virtual ~wxSTCPopupBase(); + #elif defined(__WXMSW__) + virtual bool Show(bool show=true) wxOVERRIDE; + virtual bool MSWHandleMessage(WXLRESULT *result, WXUINT message, + WXWPARAM wParam, WXLPARAM lParam) + wxOVERRIDE; + #endif + }; + +#else + + #include "wx/frame.h" + #define wxSTC_POPUP_IS_FRAME 1 + + class wxSTCPopupBase:public wxFrame + { + public: + wxSTCPopupBase(wxWindow*); + #ifdef __WXMSW__ + virtual bool Show(bool show=true) wxOVERRIDE; + virtual bool MSWHandleMessage(WXLRESULT *result, WXUINT message, + WXWPARAM wParam, WXLPARAM lParam) + wxOVERRIDE; + #elif !wxSTC_POPUP_IS_CUSTOM + virtual bool Show(bool show=true) wxOVERRIDE; + void ActivateParent(); + #endif + }; + +#endif // __WXOSX_COCOA__ + +class wxSTCPopupWindow:public wxSTCPopupBase +{ +public: + wxSTCPopupWindow(wxWindow*); + virtual bool Destroy() wxOVERRIDE; + virtual bool AcceptsFocus() const wxOVERRIDE; + +protected: + virtual void DoSetSize(int x, int y, int width, int height, + int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; + #if !wxSTC_POPUP_IS_CUSTOM + void OnFocus(wxFocusEvent& event); + #endif +}; + + +//---------------------------------------------------------------------- +// SurfaceData + class SurfaceData { public: From 66d340ae150a391a8fdda455d1c3481e58007e7e Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Thu, 14 Mar 2019 20:00:35 -0500 Subject: [PATCH 04/23] Define the wxSTCPopupBase for wxCocoa With the cocoa port, wxSTCPopupBase is defined by creating a floating window using the cocoa api and then wrapping that window in a wxNonOwnedWindow for use with wxWidgets. --- src/stc/PlatWX.cpp | 59 ++++++++++++++++++ src/stc/PlatWX.h | 13 ++++ src/stc/PlatWXcocoa.h | 28 +++++++++ src/stc/PlatWXcocoa.mm | 132 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 232 insertions(+) create mode 100644 src/stc/PlatWXcocoa.h create mode 100644 src/stc/PlatWXcocoa.mm diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index a907e4b955..b78b8445b5 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -60,6 +60,8 @@ #include "wx/gtk/private/wrapgtk.h" #elif defined(__WXMSW__) #include "wx/msw/wrapwin.h" +#elif defined(__WXOSX_COCOA__) + #include "PlatWXcocoa.h" #endif Point Point::FromLong(long lpoint) { @@ -1998,10 +2000,67 @@ PRectangle Window::GetMonitorRect(Point pt) { wxSTCPopupBase::wxSTCPopupBase(wxWindow* parent):wxNonOwnedWindow() { + m_nativeWin = CreateFloatingWindow(this); + wxNonOwnedWindow::Create(parent, m_nativeWin); + m_stc = wxDynamicCast(parent, wxStyledTextCtrl); + m_isShown = false; + + Bind(wxEVT_ENTER_WINDOW, &wxSTCPopupBase::OnMouseEnter, this); + Bind(wxEVT_LEAVE_WINDOW, &wxSTCPopupBase::OnMouseLeave, this); } wxSTCPopupBase::~wxSTCPopupBase() { + UnsubclassWin(); + CloseFloatingWindow(m_nativeWin); + + SetSTCCursor(wxSTC_CURSORNORMAL); + } + + bool wxSTCPopupBase::Show(bool show) + { + if ( !wxWindowBase::Show(show) ) + return false; + + if ( show ) + { + ShowFloatingWindow(m_nativeWin); + + if ( GetRect().Contains(::wxMouseState().GetPosition()) ) + SetSTCCursor(wxSTC_CURSORARROW); + } + else + { + HideFloatingWindow(m_nativeWin); + SetSTCCursor(wxSTC_CURSORNORMAL); + } + + return true; + } + + void wxSTCPopupBase::DoSetSize(int x, int y, int width, int ht, int flags) + { + wxSize oldSize = GetSize(); + wxNonOwnedWindow::DoSetSize(x, y, width, ht, flags); + + if ( oldSize != GetSize() ) + SendSizeEvent(); + } + + void wxSTCPopupBase::SetSTCCursor(int cursor) + { + if ( m_stc ) + m_stc->SetSTCCursor(cursor); + } + + void wxSTCPopupBase::OnMouseEnter(wxMouseEvent& WXUNUSED(event)) + { + SetSTCCursor(wxSTC_CURSORARROW); + } + + void wxSTCPopupBase::OnMouseLeave(wxMouseEvent& WXUNUSED(event)) + { + SetSTCCursor(wxSTC_CURSORNORMAL); } #elif wxUSE_POPUPWIN diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 93dc33f380..edb5493161 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -8,6 +8,8 @@ #include "wx/imaglist.h" #include "Platform.h" +class wxStyledTextCtrl; + @@ -75,6 +77,17 @@ public: public: wxSTCPopupBase(wxWindow*); virtual ~wxSTCPopupBase(); + virtual bool Show(bool show=true) wxOVERRIDE; + + protected: + virtual void DoSetSize(int, int, int, int, int) wxOVERRIDE; + void SetSTCCursor(int); + void OnMouseEnter(wxMouseEvent&); + void OnMouseLeave(wxMouseEvent&); + + private: + WX_NSWindow m_nativeWin; + wxStyledTextCtrl* m_stc; }; #elif wxUSE_POPUPWIN diff --git a/src/stc/PlatWXcocoa.h b/src/stc/PlatWXcocoa.h new file mode 100644 index 0000000000..74c7f4856c --- /dev/null +++ b/src/stc/PlatWXcocoa.h @@ -0,0 +1,28 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/stc/PlatWXcocoa.h +// Purpose: Declaration of utility functions for wxSTC with cocoa +// Author: New Pagodi +// Created: 2019-03-10 +// Copyright: (c) 2019 wxWidgets development team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#ifndef _SRC_STC_PLATWXCOCOA_H_ +#define _SRC_STC_PLATWXCOCOA_H_ + +#include "wx/defs.h" + +#if wxUSE_STC + +// Functions used to create and manage popup windows. +WX_NSWindow CreateFloatingWindow(wxWindow*); +void CloseFloatingWindow(WX_NSWindow win); +void ShowFloatingWindow(WX_NSWindow win); +void HideFloatingWindow(WX_NSWindow win); + +// Function needed for list control colours. +wxColour GetListHighlightColour(); + +#endif // wxUSE_STC + +#endif // _SRC_STC_PLATWXCOCOA_H_ diff --git a/src/stc/PlatWXcocoa.mm b/src/stc/PlatWXcocoa.mm new file mode 100644 index 0000000000..0c8ce5ccd3 --- /dev/null +++ b/src/stc/PlatWXcocoa.mm @@ -0,0 +1,132 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: src/stc/PlatWXcocoa.mm +// Purpose: Implementation of utility functions for wxSTC with cocoa +// Author: New Pagodi +// Created: 2019-03-10 +// Copyright: (c) 2019 wxWidgets development team +// Licence: wxWindows licence +///////////////////////////////////////////////////////////////////////////// + +#include "wx/wxprec.h" + +#if wxUSE_STC + +#include "wx/osx/private.h" +#include "PlatWXcocoa.h" + +// A simple view used for popup windows. + +@interface wxSTCPopupBaseView : NSView +{ +@private + NSTrackingArea * m_trackingArea; + wxWindow* m_wxWin; +} + +- (id)initWithwxWin:(wxWindow*) wxwin; + +@end + +@implementation wxSTCPopupBaseView + +- (id)initWithwxWin:(wxWindow*) wxWin +{ + m_trackingArea = nil; + + self = [super init]; + if ( self ) + m_wxWin = wxWin; + + return self; +} + +- (void)updateTrackingAreas +{ + if( m_trackingArea != nil ) + { + [self removeTrackingArea:m_trackingArea]; + [m_trackingArea release]; + } + + int options = NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways; + m_trackingArea = [[NSTrackingArea alloc] initWithRect: [self bounds] + options: options + owner: self + userInfo: nil]; + [self addTrackingArea:m_trackingArea]; +} + +- (void)mouseEntered:(NSEvent *)evt +{ + wxMouseEvent wxevent(wxEVT_ENTER_WINDOW); + wxevent.SetEventObject(m_wxWin); + m_wxWin->ProcessWindowEvent(wxevent); +} + +- (void)mouseExited:(NSEvent *)evt +{ + wxMouseEvent wxevent(wxEVT_LEAVE_WINDOW); + wxevent.SetEventObject(m_wxWin); + m_wxWin->ProcessWindowEvent(wxevent); +} + +- (void)mouseDown:(NSEvent *)evt +{ + NSRect locationInWindow = NSZeroRect; + locationInWindow.origin = [evt locationInWindow]; + NSPoint locationInView = [self convertPoint: locationInWindow.origin + fromView: nil]; + wxPoint locationInViewWX = wxFromNSPoint(self, locationInView); + + wxMouseEvent wxevent(wxEVT_LEFT_DOWN); + wxevent.SetEventObject(m_wxWin); + wxevent.SetX(locationInViewWX.x); + wxevent.SetY(locationInViewWX.y); + m_wxWin->ProcessWindowEvent(wxevent); +} + +- (void)drawRect:(NSRect)dirtyRect +{ + static_cast(m_wxWin->GetPeer())-> + drawRect(&dirtyRect, self, NULL); +} + +@end + + +// Utility functions. + +WX_NSWindow CreateFloatingWindow(wxWindow* wxWin) +{ + NSWindow* w = [[NSWindow alloc] initWithContentRect: NSZeroRect + styleMask: NSBorderlessWindowMask + backing: NSBackingStoreBuffered + defer: NO]; + [w setLevel:NSFloatingWindowLevel]; + [w setHasShadow:YES]; + [w setContentView:[[wxSTCPopupBaseView alloc] initWithwxWin:wxWin]]; + + return w; +} + +void CloseFloatingWindow(WX_NSWindow nsWin) +{ + [nsWin close]; +} + +void ShowFloatingWindow(WX_NSWindow nsWin) +{ + [nsWin orderFront:NSApp]; +} + +void HideFloatingWindow(WX_NSWindow nsWin) +{ + [nsWin orderOut:NSApp]; +} + +wxColour GetListHighlightColour() +{ + return wxColour([NSColor alternateSelectedControlColor]); +} + +#endif // wxUSE_STC From f2e1aa46fe0806274e7e8a9193e87e4369519cc0 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Wed, 20 Mar 2019 00:12:41 -0500 Subject: [PATCH 05/23] Modify build system files to use PlatWXcocoa.mm A recent commit added the file src/stc/PlatWXcocoa.mm needed for wxSTC with the cocoa port. This commit modifies the build system files to use this new file when it is needed. --- build/bakefiles/files.bkl | 21 +++++++++++++++++++-- build/cmake/files.cmake | 11 +++++++++-- build/cmake/lib/stc/CMakeLists.txt | 6 +++++- build/files | 9 +++++++-- build/upmake | 2 +- build/upmake_script.pl | 2 +- 6 files changed, 42 insertions(+), 9 deletions(-) diff --git a/build/bakefiles/files.bkl b/build/bakefiles/files.bkl index b7cc9e1699..047134a61f 100644 --- a/build/bakefiles/files.bkl +++ b/build/bakefiles/files.bkl @@ -3459,16 +3459,23 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! - + src/stc/stc.cpp src/stc/PlatWX.cpp src/stc/ScintillaWX.cpp - + wx/stc/stc.h + + src/stc/PlatWXcocoa.mm + + + + + @@ -3650,6 +3657,16 @@ IMPORTANT: please read docs/tech/tn0016.txt before modifying this file! $(MEDIA_CMN_SRC) $(MEDIA_PLATFORM_SRC) $(MEDIA_CMN_HDR) $(MEDIA_PLATFORM_HDR) + + + $(STC_OSX_COCOA_SRC) + + + $(STC_OSX_COCOA_HDR) + + $(STC_CMN_SRC) $(STC_PLATFORM_SRC) + $(STC_CMN_HDR) $(STC_PLATFORM_HDR) + $(GUI_HDR) diff --git a/build/cmake/files.cmake b/build/cmake/files.cmake index 75cc4a916f..0e5f97b7f0 100644 --- a/build/cmake/files.cmake +++ b/build/cmake/files.cmake @@ -3196,13 +3196,20 @@ set(RICHTEXT_HDR wx/xrc/xh_richtext.h ) -set(STC_SRC +set(STC_CMN_SRC src/stc/stc.cpp src/stc/PlatWX.cpp src/stc/ScintillaWX.cpp ) -set(STC_HDR +set(STC_CMN_HDR wx/stc/stc.h ) +set(STC_OSX_COCOA_SRC + src/stc/PlatWXcocoa.mm +) + +set(STC_OSX_COCOA_HDR +) + diff --git a/build/cmake/lib/stc/CMakeLists.txt b/build/cmake/lib/stc/CMakeLists.txt index 82b79518fa..25bb80801e 100644 --- a/build/cmake/lib/stc/CMakeLists.txt +++ b/build/cmake/lib/stc/CMakeLists.txt @@ -9,7 +9,11 @@ include(../../source_groups.cmake) -wx_append_sources(STC_FILES STC) +wx_append_sources(STC_FILES STC_CMN) + +if(WXOSX_COCOA) + wx_append_sources(STC_FILES STC_OSX_COCOA) +endif() wx_add_builtin_library(wxscintilla src/stc/scintilla/lexers/LexA68k.cxx diff --git a/build/files b/build/files index 8df05a9460..08fcbfb6d4 100644 --- a/build/files +++ b/build/files @@ -3129,10 +3129,15 @@ RICHTEXT_HDR = # wxSTC -STC_SRC = +STC_CMN_SRC = src/stc/stc.cpp src/stc/PlatWX.cpp src/stc/ScintillaWX.cpp -STC_HDR = +STC_CMN_HDR = wx/stc/stc.h + +STC_OSX_COCOA_SRC = + src/stc/PlatWXcocoa.mm +STC_OSX_COCOA_HDR = + diff --git a/build/upmake b/build/upmake index 33b6d0c7fb..de8d1c80b4 100755 --- a/build/upmake +++ b/build/upmake @@ -1441,7 +1441,7 @@ if (!$only_bkl) { qa => [qw(QA)], ribbon => [qw(RIBBON)], richtext => [qw(RICHTEXT)], - stc => [qw(STC)], + stc => [qw(STC_CMN)], webview => [qw(WEBVIEW_CMN WEBVIEW_MSW)], xml => [qw(XML)], xrc => [qw(XRC)], diff --git a/build/upmake_script.pl b/build/upmake_script.pl index f11bbeaf72..594e553c74 100755 --- a/build/upmake_script.pl +++ b/build/upmake_script.pl @@ -82,7 +82,7 @@ if (!$only_bkl) { qa => [qw(QA)], ribbon => [qw(RIBBON)], richtext => [qw(RICHTEXT)], - stc => [qw(STC)], + stc => [qw(STC_CMN)], webview => [qw(WEBVIEW_CMN WEBVIEW_MSW)], xml => [qw(XML)], xrc => [qw(XRC)], From 10bbd4009a6e9a3fda23b29e83ab8bfe4713f9d5 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Wed, 20 Mar 2019 00:14:08 -0500 Subject: [PATCH 06/23] Regenerate build files after recent changes --- Makefile.in | 58 +++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 52 insertions(+), 6 deletions(-) diff --git a/Makefile.in b/Makefile.in index 4cd7651056..5b5e83a97f 100644 --- a/Makefile.in +++ b/Makefile.in @@ -2027,11 +2027,22 @@ STCDLL_CXXFLAGS = $(__stcdll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DNO_CXX11_REGEX \ -DLINK_LEXERS -DWXUSINGDLL -DWXMAKINGDLL_STC $(PIC_FLAG) $(CXXWARNINGS) \ $(CPPFLAGS) $(CXXFLAGS) +STCDLL_OBJCXXFLAGS = $(__stcdll_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \ + $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -DWXBUILDING $(__INC_TIFF_BUILD_p) \ + $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \ + $(__INC_REGEX_p) $(__INC_EXPAT_p) \ + -I$(top_srcdir)/src/stc/scintilla/include \ + -I$(top_srcdir)/src/stc/scintilla/lexlib \ + -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DNO_CXX11_REGEX \ + -DLINK_LEXERS -DWXUSINGDLL -DWXMAKINGDLL_STC $(PIC_FLAG) $(CPPFLAGS) \ + $(OBJCXXFLAGS) STCDLL_OBJECTS = \ $(__stcdll___win32rc) \ stcdll_stc.o \ stcdll_PlatWX.o \ - stcdll_ScintillaWX.o + stcdll_ScintillaWX.o \ + $(__STC_PLATFORM_SRC_OBJECTS_2) STCDLL_ODEP = $(_____pch_wxprec_stcdll_wx_wxprec_h_gch___depname) STCLIB_CXXFLAGS = $(__stclib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ @@ -2041,10 +2052,20 @@ STCLIB_CXXFLAGS = $(__stclib_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ -I$(top_srcdir)/src/stc/scintilla/lexlib \ -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DNO_CXX11_REGEX \ -DLINK_LEXERS $(CXXWARNINGS) $(CPPFLAGS) $(CXXFLAGS) +STCLIB_OBJCXXFLAGS = $(__stclib_PCH_INC) -D__WX$(TOOLKIT)__ \ + $(__WXUNIV_DEFINE_p) $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) \ + $(__RTTI_DEFINE_p) $(__THREAD_DEFINE_p) -DWXBUILDING $(__INC_TIFF_BUILD_p) \ + $(__INC_TIFF_p) $(__INC_JPEG_p) $(__INC_PNG_p) $(__INC_ZLIB_p) \ + $(__INC_REGEX_p) $(__INC_EXPAT_p) \ + -I$(top_srcdir)/src/stc/scintilla/include \ + -I$(top_srcdir)/src/stc/scintilla/lexlib \ + -I$(top_srcdir)/src/stc/scintilla/src -D__WX__ -DSCI_LEXER -DNO_CXX11_REGEX \ + -DLINK_LEXERS $(CPPFLAGS) $(OBJCXXFLAGS) STCLIB_OBJECTS = \ stclib_stc.o \ stclib_PlatWX.o \ - stclib_ScintillaWX.o + stclib_ScintillaWX.o \ + $(__STC_PLATFORM_SRC_OBJECTS_3) STCLIB_ODEP = $(_____pch_wxprec_stclib_wx_wxprec_h_gch___depname) GLDLL_CXXFLAGS = $(__gldll_PCH_INC) -D__WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p) \ $(__DEBUG_DEFINE_p) $(__EXCEPTIONS_DEFINE_p) $(__RTTI_DEFINE_p) \ @@ -6112,8 +6133,13 @@ COND_TOOLKIT_X11___LOWLEVEL_SRC_OBJECTS_1 = \ @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ = monodll_tabartgtk.o @COND_TOOLKIT_MSW@__AUI_PLATFORM_SRC_OBJECTS = \ @COND_TOOLKIT_MSW@ monodll_tabartmsw.o monodll_barartmsw.o -@COND_USE_STC_1@__MONOLIB_STC_SRC_OBJECTS = monodll_stc.o \ -@COND_USE_STC_1@ monodll_PlatWX.o monodll_ScintillaWX.o +COND_USE_STC_1___MONOLIB_STC_SRC_OBJECTS = \ + monodll_stc.o \ + monodll_PlatWX.o \ + monodll_ScintillaWX.o \ + $(__STC_PLATFORM_SRC_OBJECTS) +@COND_USE_STC_1@__MONOLIB_STC_SRC_OBJECTS = $(COND_USE_STC_1___MONOLIB_STC_SRC_OBJECTS) +@COND_TOOLKIT_OSX_COCOA@__STC_PLATFORM_SRC_OBJECTS = monodll_PlatWXcocoa.o @COND_PLATFORM_UNIX_1_USE_PLUGINS_0@__PLUGIN_SRC_OBJECTS \ @COND_PLATFORM_UNIX_1_USE_PLUGINS_0@ = monodll_sound_sdl.o @COND_PLATFORM_WIN32_1@__monodll___win32rc = monodll_version_rc.o @@ -8091,8 +8117,14 @@ COND_TOOLKIT_X11___LOWLEVEL_SRC_OBJECTS_3 = \ @COND_TOOLKIT_GTK_TOOLKIT_VERSION_2@ = monolib_tabartgtk.o @COND_TOOLKIT_MSW@__AUI_PLATFORM_SRC_OBJECTS_1 = \ @COND_TOOLKIT_MSW@ monolib_tabartmsw.o monolib_barartmsw.o -@COND_USE_STC_1@__MONOLIB_STC_SRC_OBJECTS_1 = monolib_stc.o \ -@COND_USE_STC_1@ monolib_PlatWX.o monolib_ScintillaWX.o +COND_USE_STC_1___MONOLIB_STC_SRC_OBJECTS_1 = \ + monolib_stc.o \ + monolib_PlatWX.o \ + monolib_ScintillaWX.o \ + $(__STC_PLATFORM_SRC_OBJECTS_1) +@COND_USE_STC_1@__MONOLIB_STC_SRC_OBJECTS_1 = $(COND_USE_STC_1___MONOLIB_STC_SRC_OBJECTS_1) +@COND_TOOLKIT_OSX_COCOA@__STC_PLATFORM_SRC_OBJECTS_1 \ +@COND_TOOLKIT_OSX_COCOA@ = monolib_PlatWXcocoa.o @COND_PLATFORM_UNIX_1_USE_PLUGINS_0@__PLUGIN_SRC_OBJECTS_1 \ @COND_PLATFORM_UNIX_1_USE_PLUGINS_0@ = monolib_sound_sdl.o COND_MONOLITHIC_0_SHARED_1___basedll___depname = \ @@ -12955,6 +12987,7 @@ COND_USE_SOVERSOLARIS_1___stcdll___so_symlinks_uninst_cmd = rm -f \ $(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc-$(WX_RELEASE)$(HOST_SUFFIX).$(DLLIMP_SUFFIX) @COND_USE_SOVERSOLARIS_1@__stcdll___so_symlinks_uninst_cmd = $(COND_USE_SOVERSOLARIS_1___stcdll___so_symlinks_uninst_cmd) @COND_PLATFORM_WIN32_1@__stcdll___win32rc = stcdll_version_rc.o +@COND_TOOLKIT_OSX_COCOA@__STC_PLATFORM_SRC_OBJECTS_2 = stcdll_PlatWXcocoa.o COND_MONOLITHIC_0_SHARED_0_USE_STC_1___stclib___depname = \ $(LIBDIRNAME)/$(LIBPREFIX)wx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc-$(WX_RELEASE)$(HOST_SUFFIX)$(LIBEXT) @COND_MONOLITHIC_0_SHARED_0_USE_STC_1@__stclib___depname = $(COND_MONOLITHIC_0_SHARED_0_USE_STC_1___stclib___depname) @@ -12967,6 +13000,7 @@ COND_MONOLITHIC_0_SHARED_0_USE_STC_1___stclib___depname = \ @COND_ICC_PCH_1@ ./.pch/wxprec_stclib/wx/wxprec.h.gch @COND_USE_PCH_1@_____pch_wxprec_stclib_wx_wxprec_h_gch___depname \ @COND_USE_PCH_1@ = ./.pch/wxprec_stclib/wx/wxprec.h.gch +@COND_TOOLKIT_OSX_COCOA@__STC_PLATFORM_SRC_OBJECTS_3 = stclib_PlatWXcocoa.o @COND_SHARED_1@____wxstc_namedll_DEP = $(__stcdll___depname) @COND_SHARED_0@____wxstc_namelib_DEP = $(__stclib___depname) COND_SHARED_1_USE_GUI_1_USE_OPENGL_1___gldll___depname = \ @@ -17416,6 +17450,9 @@ monodll_PlatWX.o: $(srcdir)/src/stc/PlatWX.cpp $(MONODLL_ODEP) monodll_ScintillaWX.o: $(srcdir)/src/stc/ScintillaWX.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/stc/ScintillaWX.cpp +monodll_PlatWXcocoa.o: $(srcdir)/src/stc/PlatWXcocoa.mm $(MONODLL_ODEP) + $(CXXC) -c -o $@ $(MONODLL_OBJCXXFLAGS) $(srcdir)/src/stc/PlatWXcocoa.mm + monodll_xml.o: $(srcdir)/src/xml/xml.cpp $(MONODLL_ODEP) $(CXXC) -c -o $@ $(MONODLL_CXXFLAGS) $(srcdir)/src/xml/xml.cpp @@ -22675,6 +22712,9 @@ monolib_PlatWX.o: $(srcdir)/src/stc/PlatWX.cpp $(MONOLIB_ODEP) monolib_ScintillaWX.o: $(srcdir)/src/stc/ScintillaWX.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/stc/ScintillaWX.cpp +monolib_PlatWXcocoa.o: $(srcdir)/src/stc/PlatWXcocoa.mm $(MONOLIB_ODEP) + $(CXXC) -c -o $@ $(MONOLIB_OBJCXXFLAGS) $(srcdir)/src/stc/PlatWXcocoa.mm + monolib_xml.o: $(srcdir)/src/xml/xml.cpp $(MONOLIB_ODEP) $(CXXC) -c -o $@ $(MONOLIB_CXXFLAGS) $(srcdir)/src/xml/xml.cpp @@ -36613,6 +36653,9 @@ stcdll_PlatWX.o: $(srcdir)/src/stc/PlatWX.cpp $(STCDLL_ODEP) stcdll_ScintillaWX.o: $(srcdir)/src/stc/ScintillaWX.cpp $(STCDLL_ODEP) $(CXXC) -c -o $@ $(STCDLL_CXXFLAGS) $(srcdir)/src/stc/ScintillaWX.cpp +stcdll_PlatWXcocoa.o: $(srcdir)/src/stc/PlatWXcocoa.mm $(STCDLL_ODEP) + $(CXXC) -c -o $@ $(STCDLL_OBJCXXFLAGS) $(srcdir)/src/stc/PlatWXcocoa.mm + stclib_stc.o: $(srcdir)/src/stc/stc.cpp $(STCLIB_ODEP) $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $(srcdir)/src/stc/stc.cpp @@ -36622,6 +36665,9 @@ stclib_PlatWX.o: $(srcdir)/src/stc/PlatWX.cpp $(STCLIB_ODEP) stclib_ScintillaWX.o: $(srcdir)/src/stc/ScintillaWX.cpp $(STCLIB_ODEP) $(CXXC) -c -o $@ $(STCLIB_CXXFLAGS) $(srcdir)/src/stc/ScintillaWX.cpp +stclib_PlatWXcocoa.o: $(srcdir)/src/stc/PlatWXcocoa.mm $(STCLIB_ODEP) + $(CXXC) -c -o $@ $(STCLIB_OBJCXXFLAGS) $(srcdir)/src/stc/PlatWXcocoa.mm + gldll_version_rc.o: $(srcdir)/src/msw/version.rc $(GLDLL_ODEP) $(WINDRES) -i$< -o$@ --define __WX$(TOOLKIT)__ $(__WXUNIV_DEFINE_p_67) $(__DEBUG_DEFINE_p_66) $(__EXCEPTIONS_DEFINE_p_65) $(__RTTI_DEFINE_p_65) $(__THREAD_DEFINE_p_65) --define WXBUILDING --define WXDLLNAME=$(WXDLLNAMEPREFIXGUI)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_gl$(WXCOMPILER)$(VENDORTAG)$(WXDLLVERSIONTAG) $(__RCDEFDIR_p) --include-dir $(top_srcdir)/include $(__INC_TIFF_BUILD_p_66) $(__INC_TIFF_p_66) $(__INC_JPEG_p_66) $(__INC_PNG_p_65) $(__INC_ZLIB_p_67) $(__INC_REGEX_p_65) $(__INC_EXPAT_p_65) --define WXUSINGDLL --define WXMAKINGDLL_GL From 06a7433e76b1e629655fec18a9583577839b85ef Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 10 Mar 2019 20:51:56 -0500 Subject: [PATCH 07/23] Modify xcode project to use PlatWXcocoa.mm --- build/osx/wxcocoa.xcodeproj/project.pbxproj | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/build/osx/wxcocoa.xcodeproj/project.pbxproj b/build/osx/wxcocoa.xcodeproj/project.pbxproj index a7b2275d59..cc7dd28bf3 100644 --- a/build/osx/wxcocoa.xcodeproj/project.pbxproj +++ b/build/osx/wxcocoa.xcodeproj/project.pbxproj @@ -962,6 +962,9 @@ 4CB3626391CE34D4B1F71AA0 /* jdatasrc.c in Sources */ = {isa = PBXBuildFile; fileRef = DECAF5DD80383A2CA76EB383 /* jdatasrc.c */; }; 4CB3626391CE34D4B1F71AA1 /* jdatasrc.c in Sources */ = {isa = PBXBuildFile; fileRef = DECAF5DD80383A2CA76EB383 /* jdatasrc.c */; }; 4CB3626391CE34D4B1F71AA2 /* jdatasrc.c in Sources */ = {isa = PBXBuildFile; fileRef = DECAF5DD80383A2CA76EB383 /* jdatasrc.c */; }; + 4CECCB6D2224FAD300FF250C /* PlatWXcocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4CECCB6C2224FAD300FF250C /* PlatWXcocoa.mm */; }; + 4CECCB6E2224FADB00FF250C /* PlatWXcocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4CECCB6C2224FAD300FF250C /* PlatWXcocoa.mm */; }; + 4CECCB6F2224FAE300FF250C /* PlatWXcocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4CECCB6C2224FAD300FF250C /* PlatWXcocoa.mm */; }; 4CF9BA40653C3153805D88AB /* arcfind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C513377E9E303F778BA9D7ED /* arcfind.cpp */; }; 4CF9BA40653C3153805D88AC /* arcfind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C513377E9E303F778BA9D7ED /* arcfind.cpp */; }; 4CF9BA40653C3153805D88AD /* arcfind.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C513377E9E303F778BA9D7ED /* arcfind.cpp */; }; @@ -4131,6 +4134,7 @@ 4BA819575B5136B09FA8FEB1 /* pen.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = pen.cpp; path = ../../src/osx/pen.cpp; sourceTree = ""; }; 4C4649974D8B3A109D1BF145 /* art_internal.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = art_internal.cpp; path = ../../src/ribbon/art_internal.cpp; sourceTree = ""; }; 4CB467F9898C3952A68D988B /* zutil.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = zutil.c; path = ../../src/zlib/zutil.c; sourceTree = ""; }; + 4CECCB6C2224FAD300FF250C /* PlatWXcocoa.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = PlatWXcocoa.mm; path = ../../src/stc/PlatWXcocoa.mm; sourceTree = ""; }; 4EB3B255D20F3AE5A95230F6 /* LexCSS.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = LexCSS.cxx; path = ../../src/stc/scintilla/lexers/LexCSS.cxx; sourceTree = ""; }; 4F58B88D42A93BD0B74ADF75 /* CallTip.cxx */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = CallTip.cxx; path = ../../src/stc/scintilla/src/CallTip.cxx; sourceTree = ""; }; 4F768B23D8B535CE8D0BD343 /* tif_jpeg_12.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = tif_jpeg_12.c; path = ../../src/tiff/libtiff/tif_jpeg_12.c; sourceTree = ""; }; @@ -6152,6 +6156,7 @@ D0B9C41A4D12345AAA764CAD /* stc.cpp */, 47FF6D792CA234C395692118 /* PlatWX.cpp */, 8E6F9D4319F639BE89E5A82F /* ScintillaWX.cpp */, + 4CECCB6C2224FAD300FF250C /* PlatWXcocoa.mm */, ); name = stc; sourceTree = ""; @@ -8066,6 +8071,7 @@ E3B3E4F75D503DB89B5C622F /* stc.cpp in Sources */, 908957F65B7E36F8BF3858DF /* PlatWX.cpp in Sources */, 3E6AA08E72A030D39D867D4D /* ScintillaWX.cpp in Sources */, + 4CECCB6F2224FAE300FF250C /* PlatWXcocoa.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -8916,6 +8922,7 @@ D4EC9DB5F8DF319EA0FD26A5 /* LexVB.cxx in Sources */, 3C5E1A45A57B3169A4C073DA /* LexVerilog.cxx in Sources */, 16021CFD78623B8CBD08FC20 /* LexVHDL.cxx in Sources */, + 4CECCB6E2224FADB00FF250C /* PlatWXcocoa.mm in Sources */, 9CC92BB4B0E233A0A7F8127A /* LexVisualProlog.cxx in Sources */, 159E4248CB1333AD841D9F04 /* LexYAML.cxx in Sources */, 91364FDD73053139BBAA313C /* Accessor.cxx in Sources */, @@ -10141,6 +10148,7 @@ D4EC9DB5F8DF319EA0FD26A4 /* LexVB.cxx in Sources */, 3C5E1A45A57B3169A4C073D9 /* LexVerilog.cxx in Sources */, 16021CFD78623B8CBD08FC1F /* LexVHDL.cxx in Sources */, + 4CECCB6D2224FAD300FF250C /* PlatWXcocoa.mm in Sources */, 9CC92BB4B0E233A0A7F81279 /* LexVisualProlog.cxx in Sources */, 159E4248CB1333AD841D9F03 /* LexYAML.cxx in Sources */, 91364FDD73053139BBAA313B /* Accessor.cxx in Sources */, From 891f541397b3b103798173814bcb2de08f5da9db Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Thu, 14 Mar 2019 20:01:56 -0500 Subject: [PATCH 08/23] Use wxSTCPopupWindow for showing autocompletion lists The newly defined wxSTCPopupWindow class has been built to have the behavior necessary for showing the popup windows used by wxSTC. This commit uses it as the base class of the window that shows autocompletion lists. --- src/stc/PlatWX.cpp | 198 +-------------------------------------------- 1 file changed, 2 insertions(+), 196 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index b78b8445b5..925cd14bc8 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2309,12 +2309,8 @@ wxBEGIN_EVENT_TABLE(wxSTCListBox, wxListView) wxEND_EVENT_TABLE() - -#if wxUSE_POPUPWIN //----------------------------------- -#include "wx/popupwin.h" - // A popup window to place the wxSTCListBox upon -class wxSTCListBoxWin : public wxPopupWindow +class wxSTCListBoxWin : public wxSTCPopupWindow { private: wxListView* lv; @@ -2322,7 +2318,7 @@ private: void* doubleClickActionData; public: wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : - wxPopupWindow(parent, wxBORDER_SIMPLE) + wxSTCPopupWindow(parent) { lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, @@ -2349,36 +2345,6 @@ public: } - // Set position in client coords - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO) wxOVERRIDE { - if (x != wxDefaultCoord) { - GetParent()->ClientToScreen(&x, NULL); - } - if (y != wxDefaultCoord) { - GetParent()->ClientToScreen(NULL, &y); - } - wxPopupWindow::DoSetSize(x, y, width, height, sizeFlags); - } - - // return position as if it were in client coords - virtual void DoGetPosition( int *x, int *y ) const wxOVERRIDE { - int sx, sy; - wxPopupWindow::DoGetPosition(&sx, &sy); - GetParent()->ScreenToClient(&sx, &sy); - if (x) *x = sx; - if (y) *y = sy; - } - - - bool Destroy() wxOVERRIDE { - if ( !wxPendingDelete.Member(this) ) - wxPendingDelete.Append(this); - return true; - } - - int IconWidth() { wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); if (il != NULL) { @@ -2396,11 +2362,6 @@ public: } - void OnFocus(wxFocusEvent& event) { - GetParent()->SetFocus(); - event.Skip(); - } - void OnSize(wxSizeEvent& event) { // resize the child to fill the popup wxSize sz = GetClientSize(); @@ -2434,166 +2395,11 @@ private: }; wxBEGIN_EVENT_TABLE(wxSTCListBoxWin, wxPopupWindow) - EVT_SET_FOCUS ( wxSTCListBoxWin::OnFocus) EVT_SIZE ( wxSTCListBoxWin::OnSize) EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) wxEND_EVENT_TABLE() - -#else // !wxUSE_POPUPWIN ----------------------------------- -#include "wx/frame.h" - -// A normal window to place the wxSTCListBox upon, but make it behave as much -// like a wxPopupWindow as possible -class wxSTCListBoxWin : public wxFrame { -private: - wxListView* lv; - CallBackAction doubleClickAction; - void* doubleClickActionData; -public: - wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point location) : - wxFrame(parent, id, wxEmptyString, wxPoint(location.x, location.y), wxSize(0,0), - wxFRAME_NO_TASKBAR - | wxFRAME_FLOAT_ON_PARENT -#ifdef __WXMAC__ - | wxPOPUP_WINDOW - | wxNO_BORDER -#else - | wxSIMPLE_BORDER -#endif - ) - { - - lv = new wxSTCListBox(this, id, wxDefaultPosition, wxDefaultSize, - wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxNO_BORDER); - lv->SetCursor(wxCursor(wxCURSOR_ARROW)); - lv->InsertColumn(0, wxEmptyString); - lv->InsertColumn(1, wxEmptyString); - - // Eventhough we immediately reset the focus to the parent, this helps - // things to look right... - lv->SetFocus(); - - Hide(); - } - - - // On OSX and (possibly others) there can still be pending - // messages/events for the list control when Scintilla wants to - // close it, so do a pending delete of it instead of destroying - // immediately. - bool Destroy() - { -#ifdef __WXMAC__ - // The bottom edge of this window is not getting properly - // refreshed upon deletion, so help it out... - wxWindow* p = GetParent(); - wxRect r(GetPosition(), GetSize()); - r.SetHeight(r.GetHeight()+1); - p->Refresh(false, &r); -#endif - if ( !wxPendingDelete.Member(this) ) - wxPendingDelete.Append(this); - return true; - } - - - int IconWidth() - { - wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); - if (il != NULL) { - int w, h; - il->GetSize(0, w, h); - return w; - } - return 0; - } - - - void SetDoubleClickAction(CallBackAction action, void *data) - { - doubleClickAction = action; - doubleClickActionData = data; - } - - - void OnFocus(wxFocusEvent& event) - { - ActivateParent(); - GetParent()->SetFocus(); - event.Skip(); - } - - void OnSize(wxSizeEvent& event) - { - // resize the child - wxSize sz = GetClientSize(); - lv->SetSize(sz); - // reset the column widths - lv->SetColumnWidth(0, IconWidth()+4); - lv->SetColumnWidth(1, sz.x - 2 - lv->GetColumnWidth(0) - - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X)); - event.Skip(); - } - - void ActivateParent() - { - // Although we're a frame, we always want the parent to be active, so - // raise it whenever we get shown, focused, etc. - wxTopLevelWindow *frame = wxDynamicCast( - wxGetTopLevelParent(GetParent()), wxTopLevelWindow); - if (frame) - frame->Raise(); - } - - - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO) - { - // convert coords to screen coords since we're a top-level window - if (x != wxDefaultCoord) { - GetParent()->ClientToScreen(&x, NULL); - } - if (y != wxDefaultCoord) { - GetParent()->ClientToScreen(NULL, &y); - } - wxFrame::DoSetSize(x, y, width, height, sizeFlags); - } - - virtual bool Show(bool show = true) - { - bool rv = wxFrame::Show(show); - if (rv && show) - ActivateParent(); -#ifdef __WXMAC__ - GetParent()->Refresh(false); -#endif - return rv; - } - - void OnActivate(wxListEvent& WXUNUSED(event)) - { - doubleClickAction(doubleClickActionData); - } - - wxListView* GetLB() { return lv; } - -private: - wxDECLARE_EVENT_TABLE(); -}; - - -wxBEGIN_EVENT_TABLE(wxSTCListBoxWin, wxWindow) - EVT_SET_FOCUS ( wxSTCListBoxWin::OnFocus) - EVT_SIZE ( wxSTCListBoxWin::OnSize) - EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) -wxEND_EVENT_TABLE() - -#endif // wxUSE_POPUPWIN ----------------------------------- - - inline wxSTCListBoxWin* GETLBW(WindowID win) { return ((wxSTCListBoxWin*)win); } From 59190ffc0618e1e62f0cec3bd66b36e91e0f8416 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 10 Mar 2019 21:29:53 -0500 Subject: [PATCH 09/23] Use wxSTCPopupWindow for call tips in wxSTC This class has been built to have the features needed for showing popups with wxSTC and so provides a much shorter implementation for calltips. --- src/stc/ScintillaWX.cpp | 112 ++++++---------------------------------- 1 file changed, 15 insertions(+), 97 deletions(-) diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index 20b155069f..a15161ffcc 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -35,6 +35,7 @@ #include "wx/dnd.h" #include "wx/image.h" #include "wx/scopedarray.h" +#include "wx/dcbuffer.h" #if !wxUSE_STD_CONTAINERS && !wxUSE_STD_IOSTREAM && !wxUSE_STD_STRING #include "wx/beforestd.h" @@ -92,47 +93,25 @@ void wxSTCDropTarget::OnLeave() { #endif // wxUSE_DRAG_AND_DROP -#if wxUSE_POPUPWIN -#include "wx/popupwin.h" -#define wxSTCCallTipBase wxPopupWindow -#else -#include "wx/frame.h" -#define wxSTCCallTipBase wxFrame -#endif - -#include "wx/dcbuffer.h" - -class wxSTCCallTip : public wxSTCCallTipBase { +class wxSTCCallTip : public wxSTCPopupWindow { public: wxSTCCallTip(wxWindow* parent, CallTip* ct, ScintillaWX* swx) : -#if wxUSE_POPUPWIN - wxSTCCallTipBase(parent, wxBORDER_NONE), -#else - wxSTCCallTipBase(parent, -1, wxEmptyString, wxDefaultPosition, wxDefaultSize, - wxFRAME_NO_TASKBAR - | wxFRAME_FLOAT_ON_PARENT - | wxBORDER_NONE -#ifdef __WXMAC__ - | wxPOPUP_WINDOW -#endif - ), -#endif - m_ct(ct), m_swx(swx), m_cx(wxDefaultCoord), m_cy(wxDefaultCoord) - { - SetBackgroundStyle(wxBG_STYLE_PAINT); - SetName("wxSTCCallTip"); - } + wxSTCPopupWindow(parent), m_ct(ct), m_swx(swx) + { + Bind(wxEVT_LEFT_DOWN, &wxSTCCallTip::OnLeftDown, this); + Bind(wxEVT_PAINT, &wxSTCCallTip::OnPaint, this); - ~wxSTCCallTip() { -#if wxUSE_POPUPWIN && defined(__WXGTK__) - wxRect rect = GetRect(); - rect.x = m_cx; - rect.y = m_cy; - GetParent()->Refresh(false, &rect); -#endif + SetBackgroundStyle(wxBG_STYLE_PAINT); + SetName("wxSTCCallTip"); } - bool AcceptsFocus() const wxOVERRIDE { return false; } + void OnLeftDown(wxMouseEvent& event) + { + wxPoint pt = event.GetPosition(); + Point p(pt.x, pt.y); + m_ct->MouseClick(p); + m_swx->CallTipClick(); + } void OnPaint(wxPaintEvent& WXUNUSED(evt)) { @@ -144,72 +123,11 @@ public: delete surfaceWindow; } - void OnFocus(wxFocusEvent& event) - { - GetParent()->SetFocus(); - event.Skip(); - } - - void OnLeftDown(wxMouseEvent& event) - { - wxPoint pt = event.GetPosition(); - Point p(pt.x, pt.y); - m_ct->MouseClick(p); - m_swx->CallTipClick(); - } - - virtual void DoSetSize(int x, int y, - int width, int height, - int sizeFlags = wxSIZE_AUTO) wxOVERRIDE - { - // convert coords to screen coords since we're a top-level window - if (x != wxDefaultCoord) { - m_cx = x; - GetParent()->ClientToScreen(&x, NULL); - } - if (y != wxDefaultCoord) { - m_cy = y; - GetParent()->ClientToScreen(NULL, &y); - } - wxSTCCallTipBase::DoSetSize(x, y, width, height, sizeFlags); - } - -#if wxUSE_POPUPWIN -#else - virtual bool Show( bool show = true ) - { - // Although we're a frame, we always want the parent to be active, so - // raise it whenever we get shown. - bool rv = wxSTCCallTipBase::Show(show); - if (rv && show) - { - wxTopLevelWindow *frame = wxDynamicCast( - wxGetTopLevelParent(GetParent()), wxTopLevelWindow); - if (frame) - frame->Raise(); - } - return rv; - } -#endif - - wxPoint GetMyPosition() - { - return wxPoint(m_cx, m_cy); - } - private: CallTip* m_ct; ScintillaWX* m_swx; - int m_cx, m_cy; - wxDECLARE_EVENT_TABLE(); }; -wxBEGIN_EVENT_TABLE(wxSTCCallTip, wxSTCCallTipBase) - EVT_PAINT(wxSTCCallTip::OnPaint) - EVT_SET_FOCUS(wxSTCCallTip::OnFocus) - EVT_LEFT_DOWN(wxSTCCallTip::OnLeftDown) -wxEND_EVENT_TABLE() - //---------------------------------------------------------------------- From de0992ea3d232212be217d0c179472af428aa609 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Mon, 18 Mar 2019 22:35:43 -0500 Subject: [PATCH 10/23] Implement wxSTCListBox using wxVListBox Previously wxSTCListBox was a class derived from wxListView and required several extra steps to make the control look correct when it lacked focus. This commit changes wxSTCListBox so that it is a wxVListBox and is built to always draw itself looking as though it has focus. In addition this splits the work previously done by ListBoxImpl class among wxSTCListBox and a newly defined wxSTCListBoxVisualData class. wxSTCListBox manages the work done by a specific list and wxSTCListBoxVisualData manages the data common to all lists. All ListBoxImpl methods now simply forward to a method of one of those 2 classes. --- src/stc/PlatWX.cpp | 961 +++++++++++++++++++++++++++++---------------- src/stc/PlatWX.h | 13 +- 2 files changed, 633 insertions(+), 341 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 925cd14bc8..84ac3c8adc 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -33,6 +33,10 @@ #include "wx/dynlib.h" #include "wx/scopedarray.h" #include "wx/toplevel.h" +#include "wx/vlbox.h" +#include "wx/sizer.h" +#include "wx/renderer.h" +#include "wx/hashset.h" #ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" @@ -2252,347 +2256,79 @@ void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) //---------------------------------------------------------------------- // Helper classes for ListBox - -// This is a simple subclass of wxListView that just resets focus to the -// parent when it gets it. -class wxSTCListBox : public wxListView { +// The class manages the colours, images, and other data needed for popup lists. +class wxSTCListBoxVisualData +{ public: - wxSTCListBox(wxWindow* parent, wxWindowID id, - const wxPoint& pos, const wxSize& size, - long style) - : wxListView() - { -#ifdef __WXMSW__ - Hide(); // don't flicker as we move it around... -#endif - Create(parent, id, pos, size, style); - } + wxSTCListBoxVisualData(int d); + virtual ~wxSTCListBoxVisualData(); + // ListBoxImpl implementation + void SetDesiredVisibleRows(int d); + int GetDesiredVisibleRows() const; + void RegisterImage(int type, const wxBitmap& bmp); + void RegisterImage(int, const char *); + void RegisterRGBAImage(int, int, int,const unsigned char *); + void ClearRegisteredImages(); - void OnFocus(wxFocusEvent& event) { - GetParent()->SetFocus(); - event.Skip(); - } + // Image data + const wxBitmap* GetImage(int i) const; - 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 + // Colour data + void ComputeColours(); + const wxColour& GetBorderColour() const; + const wxColour& GetBgColour() const; + const wxColour& GetTextColour() const; + const wxColour& GetHighlightBgColour() const; + const wxColour& GetHighlightTextColour() const; private: - wxDECLARE_EVENT_TABLE(); + WX_DECLARE_HASH_MAP(int, wxBitmap, wxIntegerHash, wxIntegerEqual, ImgList); + + int m_desiredVisibleRows; + ImgList m_imgList; + + wxColour m_borderColour; + wxColour m_bgColour; + wxColour m_textColour; + wxColour m_highlightBgColour; + wxColour m_highlightTextColour; }; -wxBEGIN_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 -wxEND_EVENT_TABLE() - - -// A popup window to place the wxSTCListBox upon -class wxSTCListBoxWin : public wxSTCPopupWindow +wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d) { -private: - wxListView* lv; - CallBackAction doubleClickAction; - void* doubleClickActionData; -public: - wxSTCListBoxWin(wxWindow* parent, wxWindowID id, Point WXUNUSED(location)) : - wxSTCPopupWindow(parent) - { - - lv = new wxSTCListBox(parent, id, wxPoint(-50,-50), wxDefaultSize, - wxLC_REPORT | wxLC_SINGLE_SEL | wxLC_NO_HEADER | wxBORDER_NONE); - lv->SetCursor(wxCursor(wxCURSOR_ARROW)); - lv->InsertColumn(0, wxEmptyString); - lv->InsertColumn(1, wxEmptyString); - - // NOTE: We need to fool the wxListView into thinking that it has the - // focus so it will use the normal selection colour and will look - // "right" to the user. But since the wxPopupWindow or its children - // can't receive focus then we have to pull a fast one and temporarily - // parent the listctrl on the STC window and then call SetFocus and - // then reparent it back to the popup. - lv->SetFocus(); - lv->Reparent(this); -#ifdef __WXMSW__ - lv->Show(); -#endif -#if defined(__WXOSX_COCOA__) || defined(__WXGTK__) - // This color will end up being our border - SetBackgroundColour(wxColour(0xC0, 0xC0, 0xC0)); -#endif - } - - - int IconWidth() { - wxImageList* il = lv->GetImageList(wxIMAGE_LIST_SMALL); - if (il != NULL) { - int w, h; - il->GetSize(0, w, h); - return w; - } - return 0; - } - - - void SetDoubleClickAction(CallBackAction action, void *data) { - doubleClickAction = action; - doubleClickActionData = data; - } - - - void OnSize(wxSizeEvent& event) { - // resize the child to fill the popup - wxSize sz = GetClientSize(); - int x, y, w, h; - x = y = 0; - w = sz.x; - h = sz.y; -#if defined(__WXOSX_COCOA__) || defined(__WXGTK__) - // make room for the parent's bg color to show, to act as a border - x = y = 1; - w -= 2; - h -= 2; -#endif - lv->SetSize(x, y, w, h); - // reset the column widths - lv->SetColumnWidth(0, IconWidth()+4); - lv->SetColumnWidth(1, w - 2 - lv->GetColumnWidth(0) - - wxSystemSettings::GetMetric(wxSYS_VSCROLL_X)); - event.Skip(); - } - - void OnActivate(wxListEvent& WXUNUSED(event)) { - doubleClickAction(doubleClickActionData); - } - - wxListView* GetLB() { return lv; } - -private: - wxDECLARE_EVENT_TABLE(); - -}; - -wxBEGIN_EVENT_TABLE(wxSTCListBoxWin, wxPopupWindow) - EVT_SIZE ( wxSTCListBoxWin::OnSize) - EVT_LIST_ITEM_ACTIVATED(wxID_ANY, wxSTCListBoxWin::OnActivate) -wxEND_EVENT_TABLE() - - -inline wxSTCListBoxWin* GETLBW(WindowID win) { - return ((wxSTCListBoxWin*)win); + ComputeColours(); } -inline wxListView* GETLB(WindowID win) { - return GETLBW(win)->GetLB(); -} - -//---------------------------------------------------------------------- - -ListBoxImpl::ListBoxImpl() - : lineHeight(10), unicodeMode(false), - desiredVisibleRows(5), aveCharWidth(8), maxStrWidth(0), - imgList(NULL), imgTypeMap(NULL) +wxSTCListBoxVisualData::~wxSTCListBoxVisualData() { + m_imgList.clear(); } -ListBoxImpl::~ListBoxImpl() { - wxDELETE(imgList); - wxDELETE(imgTypeMap); -} - - -void ListBoxImpl::SetFont(Font &font) { - GETLB(wid)->SetFont(*((wxFont*)font.GetID())); -} - - -void ListBoxImpl::Create(Window &parent, int ctrlID, Point location_, int lineHeight_, bool unicodeMode_, int WXUNUSED(technology_)) { - location = location_; - lineHeight = lineHeight_; - unicodeMode = unicodeMode_; - maxStrWidth = 0; - wid = new wxSTCListBoxWin(GETWIN(parent.GetID()), ctrlID, location); - if (imgList != NULL) - GETLB(wid)->SetImageList(imgList, wxIMAGE_LIST_SMALL); -} - - -void ListBoxImpl::SetAverageCharWidth(int width) { - aveCharWidth = width; -} - - -void ListBoxImpl::SetVisibleRows(int rows) { - desiredVisibleRows = rows; -} - - -int ListBoxImpl::GetVisibleRows() const { - return desiredVisibleRows; -} - -PRectangle ListBoxImpl::GetDesiredRect() { - // wxListCtrl doesn't have a DoGetBestSize, so instead we kept track of - // the max size in Append and calculate it here... - int maxw = maxStrWidth * aveCharWidth; - int maxh ; - - // give it a default if there are no lines, and/or add a bit more - if (maxw == 0) maxw = 100; - maxw += aveCharWidth * 3 + - GETLBW(wid)->IconWidth() + wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); - if (maxw > 350) - maxw = 350; - - // estimate a desired height - int count = GETLB(wid)->GetItemCount(); - if (count) { - wxRect rect; - GETLB(wid)->GetItemRect(0, rect); - maxh = count * rect.GetHeight(); - if (maxh > 140) // TODO: Use desiredVisibleRows?? - maxh = 140; - - // Try to make the size an exact multiple of some number of lines - int lines = maxh / rect.GetHeight(); - maxh = (lines + 1) * rect.GetHeight() + 2; - } - else - maxh = 100; - - PRectangle rc; - rc.top = 0; - rc.left = 0; - rc.right = maxw; - rc.bottom = maxh; - return rc; -} - - -int ListBoxImpl::CaretFromEdge() { - return 4 + GETLBW(wid)->IconWidth(); -} - - -void ListBoxImpl::Clear() { - GETLB(wid)->DeleteAllItems(); -} - - -void ListBoxImpl::Append(char *s, int type) { - Append(stc2wx(s), type); -} - -void ListBoxImpl::Append(const wxString& text, int type) { - long count = GETLB(wid)->GetItemCount(); - long itemID = GETLB(wid)->InsertItem(count, wxEmptyString); - long idx = -1; - GETLB(wid)->SetItem(itemID, 1, text); - maxStrWidth = wxMax(maxStrWidth, text.length()); - if (type != -1) { - wxCHECK_RET(imgTypeMap, wxT("Unexpected NULL imgTypeMap")); - idx = imgTypeMap->Item(type); - } - GETLB(wid)->SetItemImage(itemID, idx, idx); -} - -void ListBoxImpl::SetList(const char* list, char separator, char typesep) { - GETLB(wid)->Freeze(); - Clear(); - wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); - while ( tkzr.HasMoreTokens() ) { - wxString token = tkzr.GetNextToken(); - long type = -1; - int pos = token.Find(typesep); - if (pos != -1) { - token.Mid(pos+1).ToLong(&type); - token.Truncate(pos); - } - Append(token, (int)type); - } - GETLB(wid)->Thaw(); -} - - -int ListBoxImpl::Length() { - return GETLB(wid)->GetItemCount(); -} - - -void ListBoxImpl::Select(int n) { - bool select = true; - if (n == -1) { - n = 0; - select = false; - } - GETLB(wid)->EnsureVisible(n); - GETLB(wid)->Select(n, select); -} - - -int ListBoxImpl::GetSelection() { - return GETLB(wid)->GetFirstSelected(); -} - - -int ListBoxImpl::Find(const char *WXUNUSED(prefix)) { - // No longer used - return wxNOT_FOUND; -} - - -void ListBoxImpl::GetValue(int n, char *value, int len) { - wxListItem item; - item.SetId(n); - item.SetColumn(1); - item.SetMask(wxLIST_MASK_TEXT); - GETLB(wid)->GetItem(item); - strncpy(value, wx2stc(item.GetText()), len); - value[len-1] = '\0'; -} - -void ListBoxImpl::RegisterImageHelper(int type, const wxBitmap& bmp) +void wxSTCListBoxVisualData::SetDesiredVisibleRows(int d) { - if (! imgList) { - // assumes all images are the same size - imgList = new wxImageList(bmp.GetWidth(), bmp.GetHeight(), true); - imgTypeMap = new wxArrayInt; - } - - int idx = imgList->Add(bmp); - - // do we need to extend the mapping array? - wxArrayInt& itm = *imgTypeMap; - if ( itm.GetCount() < (size_t)type+1) - itm.Add(-1, type - itm.GetCount() + 1); - - // Add an item that maps type to the image index - itm[type] = idx; + m_desiredVisibleRows=d; } -void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { +int wxSTCListBoxVisualData::GetDesiredVisibleRows() const +{ + return m_desiredVisibleRows; +} + +void wxSTCListBoxVisualData::RegisterImage(int type, const wxBitmap& bmp) +{ + if ( !bmp.IsOk() ) + return; + + ImgList::iterator it=m_imgList.find(type); + if ( it != m_imgList.end() ) + m_imgList.erase(it); + + m_imgList[type] = bmp; +} + +void wxSTCListBoxVisualData::RegisterImage(int type, const char *xpm_data) +{ wxXPMDecoder dec; wxImage img; @@ -2609,28 +2345,589 @@ void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { img = dec.ReadData(reinterpret_cast(xpm_data)); wxBitmap bmp(img); - RegisterImageHelper(type, bmp); + RegisterImage(type, bmp); +} + +void wxSTCListBoxVisualData::RegisterRGBAImage(int type, int width, int height, + const unsigned char *pixelsImage) +{ + wxBitmap bmp = BitmapFromRGBAImage(width, height, pixelsImage); + RegisterImage(type, bmp); +} + +void wxSTCListBoxVisualData::ClearRegisteredImages() +{ + m_imgList.clear(); +} + +const wxBitmap* wxSTCListBoxVisualData::GetImage(int i) const +{ + ImgList::const_iterator it = m_imgList.find(i); + + if ( it != m_imgList.end() ) + return &(it->second); + else + return NULL; +} + +void wxSTCListBoxVisualData::ComputeColours() +{ + // wxSYS_COLOUR_BTNSHADOW seems to be the closest match with most themes. + m_borderColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW ); + + m_bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); + m_textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); + +#ifdef __WXOSX_COCOA__ + m_highlightBgColour = GetListHighlightColour(); +#else + m_highlightBgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); +#endif + + m_highlightTextColour = + wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); +} + +const wxColour& wxSTCListBoxVisualData::GetBorderColour() const +{ + return m_borderColour; +} + +const wxColour& wxSTCListBoxVisualData::GetBgColour() const +{ + return m_bgColour; +} + +const wxColour& wxSTCListBoxVisualData::GetTextColour() const +{ + return m_textColour; +} + +const wxColour& wxSTCListBoxVisualData::GetHighlightBgColour() const +{ + return m_highlightBgColour; +} + +const wxColour& wxSTCListBoxVisualData::GetHighlightTextColour() const +{ + return m_highlightTextColour; +} + + +// 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 wxVListBox +{ +public: + wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int); + virtual ~wxSTCListBox(); + + // wxWindow overrides + virtual bool AcceptsFocus() const wxOVERRIDE; + virtual void SetFocus() wxOVERRIDE; + + // Setters + void SetContainerBorderSize(int); + + // ListBoxImpl implementation + void SetListBoxFont(Font &font); + void SetAverageCharWidth(int width); + PRectangle GetDesiredRect() const; + int CaretFromEdge() const; + void Clear(); + void Append(char *s, int type = -1); + int Length() const; + void Select(int n); + void GetValue(int n, char *value, int len) const; + void SetDoubleClickAction(CallBackAction, void *); + void SetList(const char* list, char separator, char typesep); + +protected: + // Helpers + void AppendHelper(const wxString& text, int type); + void AccountForBitmap(int type, bool recalculateItemHeight); + void RecalculateItemHeight(); + int TextBoxFromClientEdge() const; + + // Event handlers + void OnDClick(wxCommandEvent&); + void OnSysColourChanged(wxSysColourChangedEvent& event); + + // wxVListBox overrides + virtual wxCoord OnMeasureItem(size_t) const wxOVERRIDE; + virtual void OnDrawItem(wxDC& , const wxRect &, size_t) const wxOVERRIDE; + virtual void OnDrawBackground(wxDC&, const wxRect&,size_t) const wxOVERRIDE; + +private: + WX_DECLARE_HASH_SET(int, wxIntegerHash, wxIntegerEqual, SetOfInts); + + wxSTCListBoxVisualData* m_visualData; + wxVector m_labels; + wxVector m_imageNos; + size_t m_maxStrWidth; + + CallBackAction m_doubleClickAction; + void* m_doubleClickActionData; + int m_aveCharWidth; + + // These drawing parameters are computed or set externally. + int m_borderSize; + int m_textHeight; + int m_itemHeight; + int m_textTopGap; + int m_imageAreaWidth; + int m_imageAreaHeight; + + // These drawing parameters are set internally and can be changed if needed + // to better match the appearance of a list box on a specific platform. + int m_imagePadding; + int m_textBoxToTextGap; + int m_textExtraVerticalPadding; +}; + +wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) + :wxVListBox(), m_visualData(v), m_maxStrWidth(0), + m_doubleClickAction(NULL), m_doubleClickActionData(NULL), + m_aveCharWidth(8), m_textHeight(ht), m_itemHeight(ht), + m_textTopGap(0), m_imageAreaWidth(0), m_imageAreaHeight(0) +{ + wxVListBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, + wxBORDER_NONE); + + m_imagePadding = FromDIP(1); + m_textBoxToTextGap = FromDIP(3); + m_textExtraVerticalPadding = FromDIP(1); + + SetBackgroundColour(m_visualData->GetBgColour()); + + Bind(wxEVT_LISTBOX_DCLICK, &wxSTCListBox::OnDClick, this); + Bind(wxEVT_SYS_COLOUR_CHANGED, &wxSTCListBox::OnSysColourChanged, this); +} + +wxSTCListBox::~wxSTCListBox() +{ + m_labels.clear(); + m_imageNos.clear(); +} + +bool wxSTCListBox::AcceptsFocus() const +{ + return false; +} + +// Do nothing in response to an attempt to set focus. +void wxSTCListBox::SetFocus() +{ +} + +void wxSTCListBox::SetContainerBorderSize(int s) +{ + m_borderSize = s; +} + +void wxSTCListBox::SetListBoxFont(Font &font) +{ + SetFont(*((wxFont*)font.GetID())); + int w; + GetTextExtent(EXTENT_TEST, &w, &m_textHeight); + RecalculateItemHeight(); +} + +void wxSTCListBox::SetAverageCharWidth(int width) +{ + m_aveCharWidth = width; +} + +PRectangle wxSTCListBox::GetDesiredRect() const +{ + int maxw = m_maxStrWidth * m_aveCharWidth; + int maxh ; + + // give it a default if there are no lines, and/or add a bit more + if (maxw == 0) maxw = 100; + maxw += TextBoxFromClientEdge() + m_textBoxToTextGap + m_aveCharWidth * 3; + if (maxw > 350) + maxw = 350; + + // estimate a desired height + const int count = Length(); + const int desiredVisibleRows = m_visualData->GetDesiredVisibleRows(); + if ( count ) + { + if ( count <= desiredVisibleRows ) + maxh = count * m_itemHeight; + else + maxh = desiredVisibleRows * m_itemHeight; + } + else + maxh = 100; + + // Add space for a scrollbar if needed. + if ( count > desiredVisibleRows ) + maxw += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X); + + // Add borders. + maxw += 2 * m_borderSize; + maxh += 2 * m_borderSize; + + PRectangle rc; + rc.top = 0; + rc.left = 0; + rc.right = maxw; + rc.bottom = maxh; + return rc; +} + +int wxSTCListBox::CaretFromEdge() const +{ + return m_borderSize + TextBoxFromClientEdge() + m_textBoxToTextGap; +} + +void wxSTCListBox::Clear() +{ + m_imageAreaWidth = 0; + m_imageAreaHeight = 0; + m_labels.clear(); + m_imageNos.clear(); +} + +void wxSTCListBox::Append(char *s, int type) +{ + AppendHelper(stc2wx(s), type); + AccountForBitmap(type, true); +} + +int wxSTCListBox::Length() const +{ + return GetItemCount(); +} + +void wxSTCListBox::Select(int n) +{ + SetSelection(n); +} + +void wxSTCListBox::GetValue(int n, char *value, int len) const +{ + strncpy(value, wx2stc(m_labels[n]), len); + value[len-1] = '\0'; +} + +void wxSTCListBox::SetDoubleClickAction(CallBackAction action, void *data) +{ + m_doubleClickAction = action; + m_doubleClickActionData = data; +} + +void wxSTCListBox::SetList(const char* list, char separator, char typesep) +{ + Freeze(); + Clear(); + SetOfInts bitmapNos; + wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); + while ( tkzr.HasMoreTokens() ) { + wxString token = tkzr.GetNextToken(); + long type = -1; + int pos = token.Find(typesep); + if (pos != -1) { + token.Mid(pos+1).ToLong(&type); + token.Truncate(pos); + } + AppendHelper(token, (int)type); + bitmapNos.insert(static_cast(type)); + } + + for ( SetOfInts::iterator it=bitmapNos.begin(); it!=bitmapNos.end(); ++it ) + AccountForBitmap(*it, false); + + if ( m_imageAreaHeight > 0 ) + RecalculateItemHeight(); + + Thaw(); +} + +void wxSTCListBox::AppendHelper(const wxString& text, int type) +{ + m_maxStrWidth = wxMax(m_maxStrWidth, text.length()); + m_labels.push_back(text); + m_imageNos.push_back(type); + SetItemCount(m_labels.size()); +} + +void wxSTCListBox::AccountForBitmap(int type, bool recalculateItemHeight) +{ + const int oldHeight = m_imageAreaHeight; + const wxBitmap* bmp = m_visualData->GetImage(type); + + if ( bmp ) + { + if ( bmp->GetWidth() > m_imageAreaWidth ) + m_imageAreaWidth = bmp->GetWidth(); + + if ( bmp->GetHeight() > m_imageAreaHeight ) + m_imageAreaHeight = bmp->GetHeight(); + } + + if ( recalculateItemHeight && m_imageAreaHeight != oldHeight ) + RecalculateItemHeight(); +} + +void wxSTCListBox::RecalculateItemHeight() +{ + m_itemHeight = wxMax(m_textHeight + 2 * m_textExtraVerticalPadding, + m_imageAreaHeight + 2 * m_imagePadding); + m_textTopGap = (m_itemHeight - m_textHeight)/2; +} + +int wxSTCListBox::TextBoxFromClientEdge() const +{ + return (m_imageAreaWidth == 0 ? 0 : m_imageAreaWidth + 2 * m_imagePadding); +} + +void wxSTCListBox::OnDClick(wxCommandEvent& WXUNUSED(event)) +{ + if ( m_doubleClickAction ) + m_doubleClickAction(m_doubleClickActionData); +} + +void wxSTCListBox::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) +{ + m_visualData->ComputeColours(); + SetBackgroundColour(m_visualData->GetBgColour()); + Refresh(); +} + +wxCoord wxSTCListBox::OnMeasureItem(size_t WXUNUSED(n)) const +{ + return static_cast(m_itemHeight); +} + +// This control will be drawn so that a typical row of pixels looks like: +// +// +++++++++++++++++++++++++ =====ITEM TEXT================ +// | | | | +// | m_imageAreaWidth | | +// | | | +// m_imagePadding | m_textBoxToTextGap +// | +// m_imagePadding +// +// +// m_imagePadding : Used to give a little extra space between the +// client edge and an item's bitmap. +// m_imageAreaWidth : Computed as the width of the largest registered +// bitmap. +// m_textBoxToTextGap : Used so that item text does not begin immediately +// at the edge of the highlight box. +// +// Images are drawn centered in the image area. +// If a selection rectangle is drawn, its left edge is at x=0 if there are +// no bitmaps. Otherwise +// x = m_imagePadding + m_imageAreaWidth + m_imagePadding. +// Text is drawn at x + m_textBoxToTextGap and centered vertically. + +void wxSTCListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const +{ + wxString label; + int imageNo = -1; + if ( n < m_labels.size() ) + { + label = m_labels[n]; + imageNo = m_imageNos[n]; + } + + int topGap = m_textTopGap; + int leftGap = TextBoxFromClientEdge() + m_textBoxToTextGap; + + wxDCTextColourChanger tcc(dc); + + if ( IsSelected(n) ) + tcc.Set(m_visualData->GetHighlightTextColour()); + else + tcc.Set(m_visualData->GetTextColour()); + + label = wxControl::Ellipsize(label, dc, wxELLIPSIZE_END, + rect.GetWidth() - leftGap); + dc.DrawText(label, rect.GetLeft() + leftGap, rect.GetTop() + topGap); + + const wxBitmap* b = m_visualData->GetImage(imageNo); + if ( b ) + { + topGap = (m_itemHeight - b->GetHeight())/2; + leftGap = m_imagePadding + (m_imageAreaWidth - b->GetWidth())/2; + dc.DrawBitmap(*b, rect.GetLeft()+leftGap, rect.GetTop()+topGap, true); + } +} + +void wxSTCListBox::OnDrawBackground(wxDC &dc, const wxRect &rect,size_t n) const +{ + if ( IsSelected(n) ) + { + wxRect selectionRect(rect); + const wxColour& highlightBgColour =m_visualData->GetHighlightBgColour(); + + #ifdef __WXMSW__ + // On windows the selection rectangle in Scintilla's + // autocompletion list only covers the text and not the icon. + const int textBoxFromClientEdge = TextBoxFromClientEdge(); + selectionRect.SetLeft(rect.GetLeft() + textBoxFromClientEdge); + selectionRect.SetWidth(rect.GetWidth() - textBoxFromClientEdge); + #endif // __WXMSW__ + + wxDCBrushChanger bc(dc, highlightBgColour); + wxDCPenChanger pc(dc, highlightBgColour); + dc.DrawRectangle(selectionRect); + + wxRendererNative::GetDefault().DrawFocusRect( + const_cast(this), dc, selectionRect); + } +} + + +// A popup window to place the wxSTCListBox upon +class wxSTCListBoxWin : public wxSTCPopupWindow +{ +public: + wxSTCListBoxWin(wxWindow*, wxSTCListBox**, wxSTCListBoxVisualData*, int); +}; + +wxSTCListBoxWin::wxSTCListBoxWin(wxWindow* parent, wxSTCListBox** lb, + wxSTCListBoxVisualData* v, int h) + :wxSTCPopupWindow(parent) +{ + *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. +#ifdef __WXOSX_COCOA__ + const int borderThickness = 0; +#else + const int borderThickness = FromDIP(1); +#endif + wxBoxSizer* bSizer = new wxBoxSizer(wxVERTICAL); + bSizer->Add(*lb, 1, wxEXPAND|wxALL, borderThickness); + SetSizer(bSizer); + + (*lb)->SetContainerBorderSize(borderThickness); + SetOwnBackgroundColour(v->GetBorderColour()); +} + + +//---------------------------------------------------------------------- + +ListBoxImpl::ListBoxImpl() + :m_listBox(NULL), m_visualData(new wxSTCListBoxVisualData(5)) +{ +} + +ListBoxImpl::~ListBoxImpl() { + delete m_visualData; +} + + +void ListBoxImpl::SetFont(Font &font) { + m_listBox->SetListBoxFont(font); +} + + +void ListBoxImpl::Create(Window &parent, int WXUNUSED(ctrlID), + Point WXUNUSED(location_), int lineHeight_, + bool WXUNUSED(unicodeMode_), + int WXUNUSED(technology_)) { + wid = new wxSTCListBoxWin(GETWIN(parent.GetID()), &m_listBox, m_visualData, + lineHeight_); +} + + +void ListBoxImpl::SetAverageCharWidth(int width) { + m_listBox->SetAverageCharWidth(width); +} + + +void ListBoxImpl::SetVisibleRows(int rows) { + m_visualData->SetDesiredVisibleRows(rows); +} + + +int ListBoxImpl::GetVisibleRows() const { + return m_visualData->GetDesiredVisibleRows(); +} + +PRectangle ListBoxImpl::GetDesiredRect() { + return m_listBox->GetDesiredRect(); +} + + +int ListBoxImpl::CaretFromEdge() { + return m_listBox->CaretFromEdge(); +} + + +void ListBoxImpl::Clear() { + m_listBox->Clear(); +} + + +void ListBoxImpl::Append(char *s, int type) { + m_listBox->Append(s, type); +} + + +void ListBoxImpl::SetList(const char* list, char separator, char typesep) { + m_listBox->SetList(list, separator, typesep); +} + + +int ListBoxImpl::Length() { + return m_listBox->Length(); +} + + +void ListBoxImpl::Select(int n) { + m_listBox->Select(n); +} + + +int ListBoxImpl::GetSelection() { + return m_listBox->GetSelection(); +} + + +int ListBoxImpl::Find(const char *WXUNUSED(prefix)) { + // No longer used + return wxNOT_FOUND; +} + + +void ListBoxImpl::GetValue(int n, char *value, int len) { + m_listBox->GetValue(n, value, len); +} + +void ListBoxImpl::RegisterImageHelper(int type, const wxBitmap& bmp) +{ + m_visualData->RegisterImage(type, bmp); +} + + +void ListBoxImpl::RegisterImage(int type, const char *xpm_data) { + m_visualData->RegisterImage(type, xpm_data); } void ListBoxImpl::RegisterRGBAImage(int type, int width, int height, const unsigned char *pixelsImage) { - wxBitmap bmp = BitmapFromRGBAImage(width, height, pixelsImage); - RegisterImageHelper(type, bmp); + m_visualData->RegisterRGBAImage(type, width, height, pixelsImage); } void ListBoxImpl::ClearRegisteredImages() { - wxDELETE(imgList); - wxDELETE(imgTypeMap); - if (wid) - GETLB(wid)->SetImageList(NULL, wxIMAGE_LIST_SMALL); + m_visualData->ClearRegisteredImages(); } void ListBoxImpl::SetDoubleClickAction(CallBackAction action, void *data) { - GETLBW(wid)->SetDoubleClickAction(action, data); + m_listBox->SetDoubleClickAction(action, data); } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index edb5493161..4f4d768918 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -9,7 +9,8 @@ #include "Platform.h" class wxStyledTextCtrl; - +class wxSTCListBox; +class wxSTCListBoxVisualData; @@ -19,14 +20,8 @@ wxColour wxColourFromCD(const ColourDesired& ca); class ListBoxImpl : public ListBox { private: - int lineHeight; - bool unicodeMode; - int desiredVisibleRows; - int aveCharWidth; - size_t maxStrWidth; - Point location; // Caret location at which the list is opened - wxImageList* imgList; - wxArrayInt* imgTypeMap; + wxSTCListBox* m_listBox; + wxSTCListBoxVisualData* m_visualData; public: ListBoxImpl(); From 0c953308de44571f71bd875aa57485b9b5ff3363 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Thu, 7 Mar 2019 16:13:52 -0600 Subject: [PATCH 11/23] Allow wxSTCPopupWindow to move when its parent wxSTC moves --- src/stc/PlatWX.cpp | 28 +++++++++++++++++++++++++++- src/stc/PlatWX.h | 6 ++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 84ac3c8adc..628ffbc2ec 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2199,11 +2199,26 @@ PRectangle Window::GetMonitorRect(Point pt) { #endif // __WXOSX_COCOA__ -wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent):wxSTCPopupBase(parent) +wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent) + :wxSTCPopupBase(parent), m_initialPosition(wxDefaultPosition) { #if !wxSTC_POPUP_IS_CUSTOM Bind(wxEVT_SET_FOCUS, &wxSTCPopupWindow::OnFocus, this); #endif + + m_tlw = wxDynamicCast(wxGetTopLevelParent(parent), wxTopLevelWindow); + if ( m_tlw ) + { + m_tlw->Bind(wxEVT_MOVE, &wxSTCPopupWindow::OnParentMove, this); + } +} + +wxSTCPopupWindow::~wxSTCPopupWindow() +{ + if ( m_tlw ) + { + m_tlw->Unbind(wxEVT_MOVE, &wxSTCPopupWindow::OnParentMove, this); + } } bool wxSTCPopupWindow::Destroy() @@ -2230,6 +2245,10 @@ bool wxSTCPopupWindow::AcceptsFocus() const void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) { + if ( m_initialPosition == wxDefaultPosition + && x != wxDefaultCoord && y != wxDefaultCoord ) + m_initialPosition = wxPoint(x, y); + // convert coords to screen coords since we're a top-level window if (x != wxDefaultCoord) GetParent()->ClientToScreen(&x, NULL); @@ -2240,6 +2259,13 @@ void wxSTCPopupWindow::DoSetSize(int x, int y, int width, int height, int flags) wxSTCPopupBase::DoSetSize(x, y, width, height, flags); } +void wxSTCPopupWindow::OnParentMove(wxMoveEvent& event) +{ + if ( m_initialPosition != wxDefaultPosition ) + SetPosition(m_initialPosition); + event.Skip(); +} + #if !wxSTC_POPUP_IS_CUSTOM void wxSTCPopupWindow::OnFocus(wxFocusEvent& event) { diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 4f4d768918..9c9aaff038 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -130,15 +130,21 @@ class wxSTCPopupWindow:public wxSTCPopupBase { public: wxSTCPopupWindow(wxWindow*); + virtual ~wxSTCPopupWindow(); virtual bool Destroy() wxOVERRIDE; virtual bool AcceptsFocus() const wxOVERRIDE; protected: virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; + void OnParentMove(wxMoveEvent& event); #if !wxSTC_POPUP_IS_CUSTOM void OnFocus(wxFocusEvent& event); #endif + +private: + wxPoint m_initialPosition; + wxWindow* m_tlw; }; From 0f7552cdb0ca0d506a43e94d187e9f854f31e809 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Thu, 14 Mar 2019 02:15:40 -0500 Subject: [PATCH 12/23] Hide popup when STC app is minimized on macos and GTK+ --- src/stc/PlatWX.cpp | 19 +++++++++++++++++-- src/stc/PlatWX.h | 4 +++- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 628ffbc2ec..42a82cc984 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2210,6 +2210,9 @@ wxSTCPopupWindow::wxSTCPopupWindow(wxWindow* parent) if ( m_tlw ) { m_tlw->Bind(wxEVT_MOVE, &wxSTCPopupWindow::OnParentMove, this); + #if defined(__WXOSX_COCOA__) || (defined(__WXGTK__)&&!wxSTC_POPUP_IS_FRAME) + m_tlw->Bind(wxEVT_ICONIZE, &wxSTCPopupWindow::OnIconize, this); + #endif } } @@ -2218,6 +2221,9 @@ wxSTCPopupWindow::~wxSTCPopupWindow() if ( m_tlw ) { m_tlw->Unbind(wxEVT_MOVE, &wxSTCPopupWindow::OnParentMove, this); + #if defined(__WXOSX_COCOA__) || (defined(__WXGTK__)&&!wxSTC_POPUP_IS_FRAME) + m_tlw->Unbind(wxEVT_ICONIZE, &wxSTCPopupWindow::OnIconize, this); + #endif } } @@ -2266,7 +2272,15 @@ void wxSTCPopupWindow::OnParentMove(wxMoveEvent& event) event.Skip(); } -#if !wxSTC_POPUP_IS_CUSTOM +#if defined(__WXOSX_COCOA__) || (defined(__WXGTK__) && !wxSTC_POPUP_IS_FRAME) + + void wxSTCPopupWindow::OnIconize(wxIconizeEvent& event) + { + Show(!event.IsIconized()); + } + +#elif !wxSTC_POPUP_IS_CUSTOM + void wxSTCPopupWindow::OnFocus(wxFocusEvent& event) { #if wxSTC_POPUP_IS_FRAME @@ -2276,7 +2290,8 @@ void wxSTCPopupWindow::OnParentMove(wxMoveEvent& event) GetParent()->SetFocus(); event.Skip(); } -#endif // !wxSTC_POPUP_IS_CUSTOM + +#endif // __WXOSX_COCOA__ //---------------------------------------------------------------------- diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 9c9aaff038..52c7eb92c9 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -138,7 +138,9 @@ protected: virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO) wxOVERRIDE; void OnParentMove(wxMoveEvent& event); - #if !wxSTC_POPUP_IS_CUSTOM + #if defined(__WXOSX_COCOA__) || (defined(__WXGTK__)&&!wxSTC_POPUP_IS_FRAME) + void OnIconize(wxIconizeEvent& event); + #elif !wxSTC_POPUP_IS_CUSTOM void OnFocus(wxFocusEvent& event); #endif From f0ba9f0ef1f14a95b9b99302788c0ebf489f7671 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 10 Mar 2019 22:10:09 -0500 Subject: [PATCH 13/23] Reduce flicker with STC call tips in MSW When switching between call tips in MSW, there can be a bit of flicker when the first is closed and the new one is opened. To reduce the flicker, store the call tip background in a bitmap and use a very brief fade-in animation when showing the new call tip. --- src/stc/PlatWX.cpp | 5 +++- src/stc/ScintillaWX.cpp | 60 +++++++++++++++++++++++++++++++++++++---- 2 files changed, 59 insertions(+), 6 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 42a82cc984..1d5fa51fc1 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2094,7 +2094,10 @@ PRectangle Window::GetMonitorRect(Point pt) { if ( show ) { HWND hWnd = reinterpret_cast(GetHandle()); - ::ShowWindow(hWnd, SW_SHOWNA ); + if ( GetName() == "wxSTCCallTip" ) + ::AnimateWindow(hWnd, 25, AW_BLEND); + else + ::ShowWindow(hWnd, SW_SHOWNA ); ::SetWindowPos(hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index a15161ffcc..de9bd8196d 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -99,12 +99,38 @@ public: wxSTCPopupWindow(parent), m_ct(ct), m_swx(swx) { Bind(wxEVT_LEFT_DOWN, &wxSTCCallTip::OnLeftDown, this); + Bind(wxEVT_SIZE, &wxSTCCallTip::OnSize, this); Bind(wxEVT_PAINT, &wxSTCCallTip::OnPaint, this); +#ifdef __WXMSW__ + Bind(wxEVT_ERASE_BACKGROUND, &wxSTCCallTip::OnEraseBackground, this); + SetBackgroundStyle(wxBG_STYLE_ERASE); +#else SetBackgroundStyle(wxBG_STYLE_PAINT); +#endif + SetName("wxSTCCallTip"); } + void DrawBack(const wxSize& size) + { + m_back = wxBitmap(size); + wxMemoryDC mem(m_back); + Surface* surfaceWindow = Surface::Allocate(m_swx->technology); + surfaceWindow->Init(&mem, m_ct->wDraw.GetID()); + m_ct->PaintCT(surfaceWindow); + surfaceWindow->Release(); + delete surfaceWindow; + } + + virtual void Refresh(bool eraseBg=true, const wxRect *rect=NULL) wxOVERRIDE + { + if ( rect == NULL ) + DrawBack(GetSize()); + + wxSTCPopupWindow::Refresh(eraseBg, rect); + } + void OnLeftDown(wxMouseEvent& event) { wxPoint pt = event.GetPosition(); @@ -113,19 +139,43 @@ public: m_swx->CallTipClick(); } + void OnSize(wxSizeEvent& event) + { + DrawBack(event.GetSize()); + event.Skip(); + } + +#ifdef __WXMSW__ + + void OnPaint(wxPaintEvent& WXUNUSED(evt)) + { + wxRect upd = GetUpdateClientRect(); + wxMemoryDC mem(m_back); + wxPaintDC dc(this); + + dc.Blit(upd.GetX(), upd.GetY(), upd.GetWidth(), upd.GetHeight(), &mem, + upd.GetX(), upd.GetY()); + } + + void OnEraseBackground(wxEraseEvent& event) + { + event.GetDC()->DrawBitmap(m_back, 0, 0); + } + +#else + void OnPaint(wxPaintEvent& WXUNUSED(evt)) { wxAutoBufferedPaintDC dc(this); - Surface* surfaceWindow = Surface::Allocate(m_swx->technology); - surfaceWindow->Init(&dc, m_ct->wDraw.GetID()); - m_ct->PaintCT(surfaceWindow); - surfaceWindow->Release(); - delete surfaceWindow; + dc.DrawBitmap(m_back, 0, 0); } +#endif // __WXMSW__ + private: CallTip* m_ct; ScintillaWX* m_swx; + wxBitmap m_back; }; From 3900cfec27c0337477491b56568dcdaf7f34f428 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Mon, 18 Mar 2019 22:54:47 -0500 Subject: [PATCH 14/23] Add AutoCompSetColours method to stc MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With some system themes, the default colors used for a list box can be hard to read or otherwise unsuitable for use with an autocompletion popup. This method lets a user manually specify colours for the list box’s background, text, selection background, and selected text. --- src/stc/PlatWX.cpp | 54 +++++++++++++++++++++++++++++++++----- src/stc/PlatWX.h | 2 ++ src/stc/ScintillaWX.cpp | 9 +++++++ src/stc/ScintillaWX.h | 2 ++ src/stc/stc.cpp.in | 8 ++++++ src/stc/stc.h.in | 5 ++++ src/stc/stc.interface.h.in | 24 +++++++++++++++++ 7 files changed, 97 insertions(+), 7 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 1d5fa51fc1..244960c93a 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2321,6 +2321,8 @@ public: // Colour data void ComputeColours(); const wxColour& GetBorderColour() const; + void SetColours(const wxColour&, const wxColour&, + const wxColour&,const wxColour&); const wxColour& GetBgColour() const; const wxColour& GetTextColour() const; const wxColour& GetHighlightBgColour() const; @@ -2337,9 +2339,16 @@ private: wxColour m_textColour; wxColour m_highlightBgColour; wxColour m_highlightTextColour; + bool m_bgColourIsSet; + bool m_textColourIsSet; + bool m_highlightBgColourIsSet; + bool m_highlightTextColourIsSet; }; -wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d) +wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), + m_bgColourIsSet(false), m_textColourIsSet(false), + m_highlightBgColourIsSet(false), + m_highlightTextColourIsSet(false) { ComputeColours(); } @@ -2419,17 +2428,42 @@ void wxSTCListBoxVisualData::ComputeColours() // wxSYS_COLOUR_BTNSHADOW seems to be the closest match with most themes. m_borderColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW ); - m_bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); - m_textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); + if ( !m_bgColourIsSet ) + m_bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); + + if ( !m_textColourIsSet ) + m_textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); #ifdef __WXOSX_COCOA__ - m_highlightBgColour = GetListHighlightColour(); + if ( !m_highlightBgColourIsSet ) + m_highlightBgColour = GetListHighlightColour(); #else - m_highlightBgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + if ( !m_highlightBgColourIsSet ) + m_highlightBgColour = + wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); #endif - m_highlightTextColour = - wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); + if ( !m_highlightTextColourIsSet ) + m_highlightTextColour = + wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); +} + +void SetColourHelper(bool& isSet, wxColour& itemCol, const wxColour& newColour) +{ + isSet = newColour.IsOk(); + itemCol = newColour; +} + +void wxSTCListBoxVisualData::SetColours(const wxColour& bg, + const wxColour& txt, + const wxColour& hlbg, + const wxColour& hltext) +{ + SetColourHelper(m_bgColourIsSet, m_bgColour, bg); + SetColourHelper(m_textColourIsSet, m_textColour, txt); + SetColourHelper(m_highlightBgColourIsSet, m_highlightBgColour, hlbg); + SetColourHelper(m_highlightTextColourIsSet, m_highlightTextColour, hltext); + ComputeColours(); } const wxColour& wxSTCListBoxVisualData::GetBorderColour() const @@ -2974,6 +3008,12 @@ 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); +} + ListBox::ListBox() { } diff --git a/src/stc/PlatWX.h b/src/stc/PlatWX.h index 52c7eb92c9..2540e5e927 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -49,6 +49,8 @@ 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&); }; diff --git a/src/stc/ScintillaWX.cpp b/src/stc/ScintillaWX.cpp index de9bd8196d..7c5d1e5320 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1337,6 +1337,15 @@ 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); +} + 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 92079170e3..a4ab484b10 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -201,6 +201,8 @@ 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&); private: bool capturedMouse; diff --git a/src/stc/stc.cpp.in b/src/stc/stc.cpp.in index fb44624ab7..e6cb53a92e 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -573,6 +573,14 @@ 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); +} + diff --git a/src/stc/stc.h.in b/src/stc/stc.h.in index ef38ee1b20..4c75e1589a 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -304,6 +304,11 @@ 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); + // 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 f2ac38130b..e21f40f546 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -363,6 +363,30 @@ 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); + //@} From 267540d233c9e7f7213b372210da8bfff3e16c2e Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Mon, 18 Mar 2019 22:55:48 -0500 Subject: [PATCH 15/23] Add AutoCompUseListCtrl method to STC The AutoCompUseListCtrl method can be used to make an autocompletion list look like it's being shown with a wxListCtrl instead of a wxListBox. When this style is used, the list will have hot tracking. On MSW, the colours will also be slightly different. --- src/stc/PlatWX.cpp | 227 ++++++++++++++++++++++++++++++++----- src/stc/PlatWX.h | 1 + src/stc/ScintillaWX.cpp | 9 ++ src/stc/ScintillaWX.h | 1 + src/stc/stc.cpp.in | 8 ++ src/stc/stc.h.in | 5 + src/stc/stc.interface.h.in | 24 ++++ 7 files changed, 248 insertions(+), 27 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 244960c93a..04c6e3909c 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -37,6 +37,7 @@ #include "wx/sizer.h" #include "wx/renderer.h" #include "wx/hashset.h" +#include "wx/dcclient.h" #ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" @@ -2328,6 +2329,12 @@ public: const wxColour& GetHighlightBgColour() const; const wxColour& GetHighlightTextColour() const; + // ListCtrl Style + void UseListCtrlStyle(bool, const wxColour&, const wxColour&); + bool HasListCtrlAppearance() const; + const wxColour& GetCurrentBgColour() const; + const wxColour& GetCurrentTextColour() const; + private: WX_DECLARE_HASH_MAP(int, wxBitmap, wxIntegerHash, wxIntegerEqual, ImgList); @@ -2343,12 +2350,21 @@ private: bool m_textColourIsSet; bool m_highlightBgColourIsSet; bool m_highlightTextColourIsSet; + + bool m_hasListCtrlAppearance; + wxColour m_currentBgColour; + wxColour m_currentTextColour; + bool m_currentBgColourIsSet; + bool m_currentTextColourIsSet; }; wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), m_bgColourIsSet(false), m_textColourIsSet(false), m_highlightBgColourIsSet(false), - m_highlightTextColourIsSet(false) + m_highlightTextColourIsSet(false), + m_hasListCtrlAppearance(false), + m_currentBgColourIsSet(false), + m_currentTextColourIsSet(false) { ComputeColours(); } @@ -2434,18 +2450,46 @@ void wxSTCListBoxVisualData::ComputeColours() if ( !m_textColourIsSet ) m_textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); -#ifdef __WXOSX_COCOA__ - if ( !m_highlightBgColourIsSet ) - m_highlightBgColour = GetListHighlightColour(); -#else - if ( !m_highlightBgColourIsSet ) - m_highlightBgColour = - wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); -#endif + if ( m_hasListCtrlAppearance ) + { + // If m_highlightBgColour and/or m_currentBgColour are not + // explicitly set, set them to wxNullColour to indicate that they + // should be drawn with wxRendererNative. + if ( !m_highlightBgColourIsSet ) + m_highlightBgColour = wxNullColour; - if ( !m_highlightTextColourIsSet ) - m_highlightTextColour = - wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); + if ( !m_currentBgColourIsSet ) + m_currentBgColour = wxNullColour; + + #ifdef __WXMSW__ + if ( !m_highlightTextColourIsSet ) + m_highlightTextColour = + wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); + #else + if ( !m_highlightTextColourIsSet ) + m_highlightTextColour = wxSystemSettings::GetColour( + wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); + #endif + + if ( !m_currentTextColour.IsOk() ) + m_currentTextColour = wxSystemSettings::GetColour( + wxSYS_COLOUR_LISTBOXTEXT); + } + else + { + #ifdef __WXOSX_COCOA__ + if ( !m_highlightBgColourIsSet ) + m_highlightBgColour = GetListHighlightColour(); + #else + if ( !m_highlightBgColourIsSet ) + m_highlightBgColour = + wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + #endif + + if ( !m_highlightTextColourIsSet ) + m_highlightTextColour = + wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); + } } void SetColourHelper(bool& isSet, wxColour& itemCol, const wxColour& newColour) @@ -2491,10 +2535,34 @@ const wxColour& wxSTCListBoxVisualData::GetHighlightTextColour() const return m_highlightTextColour; } +void wxSTCListBoxVisualData::UseListCtrlStyle(bool useListCtrlStyle, + const wxColour& curBg, + const wxColour& curText) +{ + m_hasListCtrlAppearance = useListCtrlStyle; + SetColourHelper(m_currentBgColourIsSet, m_currentBgColour, curBg); + SetColourHelper(m_currentTextColourIsSet, m_currentTextColour, curText); + ComputeColours(); +} + +bool wxSTCListBoxVisualData::HasListCtrlAppearance() const +{ + return m_hasListCtrlAppearance; +} + +const wxColour& wxSTCListBoxVisualData::GetCurrentBgColour() const +{ + return m_currentBgColour; +} + +const wxColour& wxSTCListBoxVisualData::GetCurrentTextColour() const +{ + return m_currentTextColour; +} // 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 wxVListBox +class wxSTCListBox : public wxSystemThemedControl { public: wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int); @@ -2530,6 +2598,8 @@ protected: // Event handlers void OnDClick(wxCommandEvent&); void OnSysColourChanged(wxSysColourChangedEvent& event); + void OnMouseMotion(wxMouseEvent& event); + void OnMouseLeaveWindow(wxMouseEvent& event); // wxVListBox overrides virtual wxCoord OnMeasureItem(size_t) const wxOVERRIDE; @@ -2543,6 +2613,7 @@ private: wxVector m_labels; wxVector m_imageNos; size_t m_maxStrWidth; + int m_currentRow; CallBackAction m_doubleClickAction; void* m_doubleClickActionData; @@ -2564,7 +2635,8 @@ private: }; wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) - :wxVListBox(), m_visualData(v), m_maxStrWidth(0), + :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) @@ -2580,6 +2652,20 @@ wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) Bind(wxEVT_LISTBOX_DCLICK, &wxSTCListBox::OnDClick, this); Bind(wxEVT_SYS_COLOUR_CHANGED, &wxSTCListBox::OnSysColourChanged, this); + + if ( m_visualData->HasListCtrlAppearance() ) + { + EnableSystemTheme(); + Bind(wxEVT_MOTION, &wxSTCListBox::OnMouseMotion, this); + Bind(wxEVT_LEAVE_WINDOW, &wxSTCListBox::OnMouseLeaveWindow, this); + + #ifdef __WXMSW__ + // On MSW when using wxRendererNative to draw items in list control + // style, the colours used seem to be based on the parent's + // background colour. So set the popup's background. + parent->SetOwnBackgroundColour(m_visualData->GetBgColour()); + #endif + } } wxSTCListBox::~wxSTCListBox() @@ -2771,8 +2857,37 @@ void wxSTCListBox::OnDClick(wxCommandEvent& WXUNUSED(event)) void wxSTCListBox::OnSysColourChanged(wxSysColourChangedEvent& WXUNUSED(event)) { m_visualData->ComputeColours(); + GetParent()->SetOwnBackgroundColour(m_visualData->GetBgColour()); SetBackgroundColour(m_visualData->GetBgColour()); - Refresh(); + GetParent()->Refresh(); +} + +void wxSTCListBox::OnMouseLeaveWindow(wxMouseEvent& event) +{ + const int old = m_currentRow; + m_currentRow = wxNOT_FOUND; + + if ( old != wxNOT_FOUND ) + RefreshRow(old); + + event.Skip(); +} + +void wxSTCListBox::OnMouseMotion(wxMouseEvent& event) +{ + const int old = m_currentRow; + m_currentRow = VirtualHitTest(event.GetY()); + + if ( old != m_currentRow ) + { + if( m_currentRow != wxNOT_FOUND ) + RefreshRow(m_currentRow); + + if( old != wxNOT_FOUND ) + RefreshRow(old); + } + + event.Skip(); } wxCoord wxSTCListBox::OnMeasureItem(size_t WXUNUSED(n)) const @@ -2821,6 +2936,8 @@ void wxSTCListBox::OnDrawItem(wxDC& dc, const wxRect& rect, size_t n) const if ( IsSelected(n) ) tcc.Set(m_visualData->GetHighlightTextColour()); + else if ( static_cast(n) == m_currentRow ) + tcc.Set(m_visualData->GetCurrentTextColour()); else tcc.Set(m_visualData->GetTextColour()); @@ -2845,19 +2962,50 @@ void wxSTCListBox::OnDrawBackground(wxDC &dc, const wxRect &rect,size_t n) const const wxColour& highlightBgColour =m_visualData->GetHighlightBgColour(); #ifdef __WXMSW__ - // On windows the selection rectangle in Scintilla's - // autocompletion list only covers the text and not the icon. - const int textBoxFromClientEdge = TextBoxFromClientEdge(); - selectionRect.SetLeft(rect.GetLeft() + textBoxFromClientEdge); - selectionRect.SetWidth(rect.GetWidth() - textBoxFromClientEdge); + if ( !m_visualData->HasListCtrlAppearance() ) + { + // On windows the selection rectangle in Scintilla's + // autocompletion list only covers the text and not the icon. + + const int textBoxFromClientEdge = TextBoxFromClientEdge(); + selectionRect.SetLeft(rect.GetLeft() + textBoxFromClientEdge); + selectionRect.SetWidth(rect.GetWidth() - textBoxFromClientEdge); + } #endif // __WXMSW__ - wxDCBrushChanger bc(dc, highlightBgColour); - wxDCPenChanger pc(dc, highlightBgColour); - dc.DrawRectangle(selectionRect); + if ( highlightBgColour.IsOk() ) + { + wxDCBrushChanger bc(dc, highlightBgColour); + wxDCPenChanger pc(dc, highlightBgColour); + dc.DrawRectangle(selectionRect); + } + else + { + wxRendererNative::GetDefault().DrawItemSelectionRect( + const_cast(this), dc, selectionRect, + wxCONTROL_SELECTED | wxCONTROL_FOCUSED); + } - wxRendererNative::GetDefault().DrawFocusRect( - const_cast(this), dc, selectionRect); + if ( !m_visualData->HasListCtrlAppearance() ) + wxRendererNative::GetDefault().DrawFocusRect( + const_cast(this), dc, selectionRect); + } + else if ( static_cast(n) == m_currentRow ) + { + const wxColour& currentBgColour = m_visualData->GetCurrentBgColour(); + + if ( currentBgColour.IsOk() ) + { + wxDCBrushChanger bc(dc, currentBgColour); + wxDCPenChanger pc(dc, currentBgColour); + dc.DrawRectangle(rect); + } + else + { + wxRendererNative::GetDefault().DrawItemSelectionRect( + const_cast(this), dc, rect, + wxCONTROL_CURRENT | wxCONTROL_FOCUSED); + } } } @@ -2867,6 +3015,12 @@ class wxSTCListBoxWin : public wxSTCPopupWindow { public: wxSTCListBoxWin(wxWindow*, wxSTCListBox**, wxSTCListBoxVisualData*, int); + +protected: + void OnPaint(wxPaintEvent&); + +private: + wxSTCListBoxVisualData* m_visualData; }; wxSTCListBoxWin::wxSTCListBoxWin(wxWindow* parent, wxSTCListBox** lb, @@ -2885,9 +3039,22 @@ wxSTCListBoxWin::wxSTCListBoxWin(wxWindow* parent, wxSTCListBox** lb, wxBoxSizer* bSizer = new wxBoxSizer(wxVERTICAL); bSizer->Add(*lb, 1, wxEXPAND|wxALL, borderThickness); SetSizer(bSizer); - (*lb)->SetContainerBorderSize(borderThickness); - SetOwnBackgroundColour(v->GetBorderColour()); + + // When drawing highlighting in listctrl style with wxRendererNative on MSW, + // the colours used seem to be based on the background of the parent window. + // So manually paint this window to give it the border colour instead of + // setting the background colour. + m_visualData = v; + Bind(wxEVT_PAINT, &wxSTCListBoxWin::OnPaint, this); + SetBackgroundStyle(wxBG_STYLE_PAINT); +} + +void wxSTCListBoxWin::OnPaint(wxPaintEvent& WXUNUSED(evt)) +{ + wxPaintDC dc(this); + dc.SetBackground(m_visualData->GetBorderColour()); + dc.Clear(); } @@ -3014,6 +3181,12 @@ void ListBoxImpl::SetColours(const wxColour& background, const wxColour& text, 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 2540e5e927..8449c870d2 100644 --- a/src/stc/PlatWX.h +++ b/src/stc/PlatWX.h @@ -51,6 +51,7 @@ public: 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 7c5d1e5320..14172d1719 100644 --- a/src/stc/ScintillaWX.cpp +++ b/src/stc/ScintillaWX.cpp @@ -1346,6 +1346,15 @@ void ScintillaWX::SetListBoxColours(const wxColour& background, 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 a4ab484b10..5bbe6179c3 100644 --- a/src/stc/ScintillaWX.h +++ b/src/stc/ScintillaWX.h @@ -203,6 +203,7 @@ public: 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.in b/src/stc/stc.cpp.in index e6cb53a92e..91807cf3f9 100644 --- a/src/stc/stc.cpp.in +++ b/src/stc/stc.cpp.in @@ -581,6 +581,14 @@ void wxStyledTextCtrl::AutoCompSetColours(const wxColour& background, 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 4c75e1589a..ea04d4f60c 100644 --- a/src/stc/stc.h.in +++ b/src/stc/stc.h.in @@ -309,6 +309,11 @@ public: 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 e21f40f546..a3c0334908 100644 --- a/src/stc/stc.interface.h.in +++ b/src/stc/stc.interface.h.in @@ -386,6 +386,30 @@ public: 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 fe7b332b7be1f958676f5eccab7459ab3a171403 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Mon, 18 Mar 2019 22:56:09 -0500 Subject: [PATCH 16/23] Regenerate STC files after recent changes --- include/wx/stc/stc.h | 10 +++++++++ interface/wx/stc/stc.h | 48 ++++++++++++++++++++++++++++++++++++++++++ src/stc/stc.cpp | 16 ++++++++++++++ 3 files changed, 74 insertions(+) diff --git a/include/wx/stc/stc.h b/include/wx/stc/stc.h index f069dfe2fb..94ce11aa2c 100644 --- a/include/wx/stc/stc.h +++ b/include/wx/stc/stc.h @@ -5187,6 +5187,16 @@ 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 21a3a4cac4..f7ca8e70c6 100644 --- a/interface/wx/stc/stc.h +++ b/interface/wx/stc/stc.h @@ -7423,6 +7423,54 @@ 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/stc.cpp b/src/stc/stc.cpp index b01802915c..54695d5466 100644 --- a/src/stc/stc.cpp +++ b/src/stc/stc.cpp @@ -5046,6 +5046,22 @@ 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); +} + From 7b0c7495e3563aff1043e636aba183f74df6a4ce Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Wed, 20 Mar 2019 15:17:34 -0500 Subject: [PATCH 17/23] Add gui test for STC popup items With wxSTC, popup autocompletion lists and call tips need to be able to show their information and respond to mouse clicks, but should never take focus from their parent STC. This test verifies that these popups function in this manner. --- build/bakefiles/common.bkl | 2 +- tests/controls/styledtextctrltest.cpp | 157 ++++++++++++++++++++++++++ tests/test.bkl | 4 +- 3 files changed, 161 insertions(+), 2 deletions(-) create mode 100644 tests/controls/styledtextctrltest.cpp diff --git a/build/bakefiles/common.bkl b/build/bakefiles/common.bkl index 7c17434719..1fe539ad02 100644 --- a/build/bakefiles/common.bkl +++ b/build/bakefiles/common.bkl @@ -180,7 +180,7 @@ $(mk.evalExpr(wxwin.mkLibName('richtext'))) - $(mk.evalExpr(wxwin.mkLibName('stc'))) + $(mk.evalExpr(wxwin.mkLibName('stc'))) diff --git a/tests/controls/styledtextctrltest.cpp b/tests/controls/styledtextctrltest.cpp new file mode 100644 index 0000000000..63c8610cb6 --- /dev/null +++ b/tests/controls/styledtextctrltest.cpp @@ -0,0 +1,157 @@ +/////////////////////////////////////////////////////////////////////////////// +// Name: tests/controls/styledtextctrltest.cpp +// Purpose: wxStyledTextCtrl unit test +// Author: New Pagodi +// Created: 2019-03-10 +// Copyright: (c) 2019 wxWidgets development team +// Licence: wxWindows licence +/////////////////////////////////////////////////////////////////////////////// + +#include "testprec.h" + +#if wxUSE_STC + +#if WXUSINGDLL + +#ifdef __BORLANDC__ + #pragma hdrstop +#endif + +#ifndef WX_PRECOMP + #include "wx/app.h" +#endif // WX_PRECOMP + +#include "wx/stc/stc.h" +#include "wx/uiaction.h" + +#if defined(__WXOSX_COCOA__) || defined(__WXMSW__) || defined(__WXGTK__) + +class StcPopupWindowsTestCase +{ +public: + StcPopupWindowsTestCase() + : m_stc(new wxStyledTextCtrl(wxTheApp->GetTopWindow(), wxID_ANY)) + { + m_focusAlwaysRetained=true; + m_calltipClickReceived=false; + + m_stc->Bind(wxEVT_KILL_FOCUS, + &StcPopupWindowsTestCase::OnKillSTCFocus, this); + m_stc->Bind(wxEVT_STC_CALLTIP_CLICK, + &StcPopupWindowsTestCase::OnCallTipClick, this); + } + + ~StcPopupWindowsTestCase() + { + delete m_stc; + } + + void OnKillSTCFocus(wxFocusEvent& WXUNUSED(event)) + { + m_focusAlwaysRetained=false; + } + + void OnCallTipClick(wxStyledTextEvent& WXUNUSED(event)) + { + m_calltipClickReceived=true; + } + +protected: + wxStyledTextCtrl* const m_stc; + bool m_focusAlwaysRetained; + bool m_calltipClickReceived; +}; + +// This set of tests is used to verify that an autocompletion popup does not +// take focus from its parent styled text control. +TEST_CASE_METHOD(StcPopupWindowsTestCase, + "wxStyledTextCtrl::AutoComp", + "[wxStyledTextCtrl][focus]") +{ + m_stc->SetFocus(); + m_focusAlwaysRetained = true; + m_stc->AutoCompShow(0,"ability able about above abroad absence absent"); + +#if wxUSE_UIACTIONSIMULATOR + // Pressing the tab key should cause the current entry in the list to be + // entered into the styled text control. However with GTK+, characters sent + // with the UI simulator seem to arrive too late, so select the current + // entry with a double click instead. + + wxUIActionSimulator sim; + +#ifdef __WXGTK__ + wxPoint zeroPosition = m_stc->PointFromPosition(0); + int textHt = m_stc->TextHeight(0); + int textWd = m_stc->TextWidth(0,"ability"); + wxPoint autoCompPoint(zeroPosition.x + textWd/2, + zeroPosition.y + textHt + textHt/2); + wxPoint scrnPoint = m_stc->ClientToScreen(autoCompPoint); + sim.MouseMove(scrnPoint); + sim.MouseDblClick(); +#else + sim.Char(WXK_TAB); +#endif // __WXGTK__ + ::wxYield(); + CHECK( m_stc->GetText() == "ability" ); +#endif //wxUSE_UIACTIONSIMULATOR + + if ( m_stc->AutoCompActive() ) + m_stc->AutoCompCancel(); + + CHECK( m_stc->HasFocus() ); + CHECK( m_focusAlwaysRetained ); +} + +// This test is used to verify that a call tip receives mouse clicks. However +// the clicks do sent with the UI simulator do not seem to be received on +// cocoa for some reason, so skip the test there for now. +#if !defined(__WXOSX_COCOA__) +TEST_CASE_METHOD(StcPopupWindowsTestCase, + "wxStyledTextCtrl::Calltip", + "[wxStyledTextCtrl][focus]") +{ + m_stc->SetFocus(); + m_calltipClickReceived = false; + m_focusAlwaysRetained = true; + + wxString calltipText = "This is a calltip."; + m_stc->CallTipShow(0,calltipText); + +#if wxUSE_UIACTIONSIMULATOR + wxUIActionSimulator sim; + wxPoint zeroPosition = m_stc->PointFromPosition(0); + int textHt = m_stc->TextHeight(0); + int textWd = m_stc->TextWidth(0,calltipText); + + // zeroPosition is the top left of position 0 and the call tip should have + // roughly the same height as textHt (there seems to be some extra padding + // that makes it a little taller, but it's roughly the same height), + // so (zeroPosition.x+textWd/2,zeroPosition.y+textHt+textHt/2) should + // be the middle of the calltip. + wxPoint calltipMidPoint(zeroPosition.x + textWd/2, + zeroPosition.y + textHt + textHt/2); + wxPoint scrnPoint = m_stc->ClientToScreen(calltipMidPoint); + sim.MouseMove(scrnPoint); + sim.MouseClick(); + ::wxYield(); + + CHECK( m_calltipClickReceived ); +#endif // wxUSE_UIACTIONSIMULATOR + + if ( m_stc->CallTipActive() ) + m_stc->CallTipCancel(); + + // Verify that clicking the call tip did not take focus from the STC. + CHECK( m_stc->HasFocus() ); + CHECK( m_focusAlwaysRetained ); +} + +#endif // !defined(__WXOSX_COCOA__) + +#endif // defined(__WXOSX_COCOA__) || defined(__WXMSW__) || defined(__WXGTK__) + +#endif // WXUSINGDLL + +#endif // wxUSE_STC + diff --git a/tests/test.bkl b/tests/test.bkl index 1f389fa3bf..70326b8dce 100644 --- a/tests/test.bkl +++ b/tests/test.bkl @@ -223,6 +223,7 @@ controls/slidertest.cpp controls/spinctrldbltest.cpp controls/spinctrltest.cpp + controls/styledtextctrltest.cpp controls/textctrltest.cpp controls/textentrytest.cpp controls/togglebuttontest.cpp @@ -282,9 +283,10 @@ Can't use here as it doesn't work with conditionally defined variables, so fall back as we must not link with inexisting webview library to be able to run tests even if - wxWebView is not available. + wxWebView or wxSTC is not available. --> $(WXLIB_WEBVIEW) + $(WXLIB_STC) aui richtext media From a4b688cb45ff9aa87252755b8f723f9625dfd6ff Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Wed, 20 Mar 2019 15:25:19 -0500 Subject: [PATCH 18/23] Regenerate the test make files to include the new STC test --- autoconf_inc.m4 | 2 +- configure | 14 +++++++++++++- tests/Makefile.in | 9 ++++++++- tests/makefile.bcc | 10 +++++++++- tests/makefile.gcc | 12 +++++++++++- tests/makefile.vc | 10 +++++++++- tests/test_vc7_test_gui.vcproj | 11 +++++++---- tests/test_vc8_test_gui.vcproj | 20 ++++++++++++-------- tests/test_vc9_test_gui.vcproj | 20 ++++++++++++-------- 9 files changed, 82 insertions(+), 26 deletions(-) diff --git a/autoconf_inc.m4 b/autoconf_inc.m4 index 8d9e122a8a..7607d65a88 100644 --- a/autoconf_inc.m4 +++ b/autoconf_inc.m4 @@ -278,7 +278,7 @@ dnl ### begin block 20_COND_MONOLITHIC_0_USE_RICHTEXT_1[wx.bkl] ### COND_MONOLITHIC_0_USE_RICHTEXT_1="" fi AC_SUBST(COND_MONOLITHIC_0_USE_RICHTEXT_1) -dnl ### begin block 20_COND_MONOLITHIC_0_USE_STC_1[wx.bkl] ### +dnl ### begin block 20_COND_MONOLITHIC_0_USE_STC_1[../../tests/test.bkl,wx.bkl] ### COND_MONOLITHIC_0_USE_STC_1="#" if test "x$MONOLITHIC" = "x0" -a "x$USE_STC" = "x1" ; then COND_MONOLITHIC_0_USE_STC_1="" diff --git a/configure b/configure index e289050304..1415627456 100755 --- a/configure +++ b/configure @@ -1026,6 +1026,7 @@ infodir docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -1449,6 +1450,7 @@ datadir='${datarootdir}' sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -1701,6 +1703,15 @@ do | -silent | --silent | --silen | --sile | --sil) silent=yes ;; + -runstatedir | --runstatedir | --runstatedi | --runstated \ + | --runstate | --runstat | --runsta | --runst | --runs \ + | --run | --ru | --r) + ac_prev=runstatedir ;; + -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \ + | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \ + | --run=* | --ru=* | --r=*) + runstatedir=$ac_optarg ;; + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) ac_prev=sbindir ;; -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ @@ -1838,7 +1849,7 @@ fi for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ datadir sysconfdir sharedstatedir localstatedir includedir \ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ - libdir localedir mandir + libdir localedir mandir runstatedir do eval ac_val=\$$ac_var # Remove trailing slashes. @@ -1991,6 +2002,7 @@ Fine tuning of the installation directories: --sysconfdir=DIR read-only single-machine data [PREFIX/etc] --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run] --libdir=DIR object code libraries [EPREFIX/lib] --includedir=DIR C header files [PREFIX/include] --oldincludedir=DIR C header files for non-gcc [/usr/include] diff --git a/tests/Makefile.in b/tests/Makefile.in index 626269dfd7..e9f79143a9 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -223,6 +223,7 @@ TEST_GUI_OBJECTS = \ test_gui_slidertest.o \ test_gui_spinctrldbltest.o \ test_gui_spinctrltest.o \ + test_gui_styledtextctrltest.o \ test_gui_textctrltest.o \ test_gui_textentrytest.o \ test_gui_togglebuttontest.o \ @@ -330,6 +331,9 @@ TEST_GUI_ODEP = $(_____pch_testprec_test_gui_testprec_h_gch___depname) COND_MONOLITHIC_0_USE_WEBVIEW_1___WXLIB_WEBVIEW_p = \ -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview-$(WX_RELEASE)$(HOST_SUFFIX) @COND_MONOLITHIC_0_USE_WEBVIEW_1@__WXLIB_WEBVIEW_p = $(COND_MONOLITHIC_0_USE_WEBVIEW_1___WXLIB_WEBVIEW_p) +COND_MONOLITHIC_0_USE_STC_1___WXLIB_STC_p = \ + -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc-$(WX_RELEASE)$(HOST_SUFFIX) +@COND_MONOLITHIC_0_USE_STC_1@__WXLIB_STC_p = $(COND_MONOLITHIC_0_USE_STC_1___WXLIB_STC_p) COND_MONOLITHIC_0___WXLIB_AUI_p = \ -lwx_$(PORTNAME)$(WXUNIVNAME)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui-$(WX_RELEASE)$(HOST_SUFFIX) @COND_MONOLITHIC_0@__WXLIB_AUI_p = $(COND_MONOLITHIC_0___WXLIB_AUI_p) @@ -424,7 +428,7 @@ test$(EXEEXT): $(TEST_OBJECTS) @COND_SHARED_1_USE_GUI_1@ $(SHARED_LD_MODULE_CXX) $@ $(TEST_DRAWINGPLUGIN_OBJECTS) -L$(LIBDIRNAME) $(LDFLAGS) $(__WXLIB_CORE_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) @COND_USE_GUI_1@test_gui$(EXEEXT): $(TEST_GUI_OBJECTS) $(__test_gui___win32rc) -@COND_USE_GUI_1@ $(CXX) -o $@ $(TEST_GUI_OBJECTS) -L$(LIBDIRNAME) $(SAMPLES_RPATH_FLAG) $(LDFLAGS) $(__WXLIB_WEBVIEW_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(EXTRALIBS_MEDIA) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(EXTRALIBS_XML) $(__WXLIB_HTML_p) $(EXTRALIBS_HTML) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) +@COND_USE_GUI_1@ $(CXX) -o $@ $(TEST_GUI_OBJECTS) -L$(LIBDIRNAME) $(SAMPLES_RPATH_FLAG) $(LDFLAGS) $(__WXLIB_WEBVIEW_p) $(__WXLIB_STC_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(EXTRALIBS_MEDIA) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(EXTRALIBS_XML) $(__WXLIB_HTML_p) $(EXTRALIBS_HTML) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) $(EXTRALIBS_FOR_GUI) $(__LIB_ZLIB_p) $(__LIB_REGEX_p) $(__LIB_EXPAT_p) $(EXTRALIBS_FOR_BASE) $(LIBS) @COND_PLATFORM_MACOSX_1_USE_GUI_1@test_gui.app/Contents/PkgInfo: $(__test_gui___depname) $(top_srcdir)/src/osx/carbon/Info.plist.in $(top_srcdir)/src/osx/carbon/wxmac.icns @COND_PLATFORM_MACOSX_1_USE_GUI_1@ mkdir -p test_gui.app/Contents @@ -943,6 +947,9 @@ test_gui_spinctrldbltest.o: $(srcdir)/controls/spinctrldbltest.cpp $(TEST_GUI_OD test_gui_spinctrltest.o: $(srcdir)/controls/spinctrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/spinctrltest.cpp +test_gui_styledtextctrltest.o: $(srcdir)/controls/styledtextctrltest.cpp $(TEST_GUI_ODEP) + $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/styledtextctrltest.cpp + test_gui_textctrltest.o: $(srcdir)/controls/textctrltest.cpp $(TEST_GUI_ODEP) $(CXXC) -c -o $@ $(TEST_GUI_CXXFLAGS) $(srcdir)/controls/textctrltest.cpp diff --git a/tests/makefile.bcc b/tests/makefile.bcc index 51192463b0..53cc3a0f49 100644 --- a/tests/makefile.bcc +++ b/tests/makefile.bcc @@ -210,6 +210,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_slidertest.obj \ $(OBJS)\test_gui_spinctrldbltest.obj \ $(OBJS)\test_gui_spinctrltest.obj \ + $(OBJS)\test_gui_styledtextctrltest.obj \ $(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textentrytest.obj \ $(OBJS)\test_gui_togglebuttontest.obj \ @@ -334,6 +335,10 @@ __DLLFLAG_p_7 = -dWXUSINGDLL __WXLIB_WEBVIEW_p = \ wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview.lib !endif +!if "$(MONOLITHIC)" == "0" && "$(USE_STC)" == "1" +__WXLIB_STC_p = \ + wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc.lib +!endif !if "$(MONOLITHIC)" == "0" __WXLIB_AUI_p = \ wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui.lib @@ -525,7 +530,7 @@ $(OBJS)\test_drawingplugin.dll: $(TEST_DRAWINGPLUGIN_OBJECTS) !if "$(USE_GUI)" == "1" $(OBJS)\test_gui.exe: $(OBJS)\test_gui_dummy.obj $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample.res ilink32 -Tpe -q -L$(BCCDIR)\lib -L$(BCCDIR)\lib\psdk $(__DEBUGINFO) -L$(LIBDIRNAME) -ap $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @&&| - c0x32.obj $(TEST_GUI_OBJECTS),$@,, $(__WXLIB_WEBVIEW_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) ole2w32.lib oleacc.lib uxtheme.lib import32.lib cw32$(__THREADSFLAG)$(__RUNTIME_LIBS_2).lib,, $(OBJS)\test_gui_sample.res + c0x32.obj $(TEST_GUI_OBJECTS),$@,, $(__WXLIB_WEBVIEW_p) $(__WXLIB_STC_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) ole2w32.lib oleacc.lib uxtheme.lib import32.lib cw32$(__THREADSFLAG)$(__RUNTIME_LIBS_2).lib,, $(OBJS)\test_gui_sample.res | !endif @@ -998,6 +1003,9 @@ $(OBJS)\test_gui_spinctrldbltest.obj: .\controls\spinctrldbltest.cpp $(OBJS)\test_gui_spinctrltest.obj: .\controls\spinctrltest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\spinctrltest.cpp +$(OBJS)\test_gui_styledtextctrltest.obj: .\controls\styledtextctrltest.cpp + $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\styledtextctrltest.cpp + $(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp $(CXX) -q -c -P -o$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp diff --git a/tests/makefile.gcc b/tests/makefile.gcc index 94d034dd80..9736869d0a 100644 --- a/tests/makefile.gcc +++ b/tests/makefile.gcc @@ -205,6 +205,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_slidertest.o \ $(OBJS)\test_gui_spinctrldbltest.o \ $(OBJS)\test_gui_spinctrltest.o \ + $(OBJS)\test_gui_styledtextctrltest.o \ $(OBJS)\test_gui_textctrltest.o \ $(OBJS)\test_gui_textentrytest.o \ $(OBJS)\test_gui_togglebuttontest.o \ @@ -337,6 +338,12 @@ __WXLIB_WEBVIEW_p = \ endif endif ifeq ($(MONOLITHIC),0) +ifeq ($(USE_STC),1) +__WXLIB_STC_p = \ + -lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc +endif +endif +ifeq ($(MONOLITHIC),0) __WXLIB_AUI_p = \ -lwx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui endif @@ -503,7 +510,7 @@ endif ifeq ($(USE_GUI),1) $(OBJS)\test_gui.exe: $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample_rc.o - $(CXX) -o $@ $(TEST_GUI_OBJECTS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_WEBVIEW_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lwsock32 -lwininet -loleacc -luxtheme + $(CXX) -o $@ $(TEST_GUI_OBJECTS) $(__DEBUGINFO) $(__THREADSFLAG) -L$(LIBDIRNAME) $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) $(__WXLIB_WEBVIEW_p) $(__WXLIB_STC_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) -lwxzlib$(WXDEBUGFLAG) -lwxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG) -lwxexpat$(WXDEBUGFLAG) $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) -lkernel32 -luser32 -lgdi32 -lcomdlg32 -lwinspool -lwinmm -lshell32 -lshlwapi -lcomctl32 -lole32 -loleaut32 -luuid -lrpcrt4 -ladvapi32 -lversion -lwsock32 -lwininet -loleacc -luxtheme endif data: @@ -975,6 +982,9 @@ $(OBJS)\test_gui_spinctrldbltest.o: ./controls/spinctrldbltest.cpp $(OBJS)\test_gui_spinctrltest.o: ./controls/spinctrltest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< +$(OBJS)\test_gui_styledtextctrltest.o: ./controls/styledtextctrltest.cpp + $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< + $(OBJS)\test_gui_textctrltest.o: ./controls/textctrltest.cpp $(CXX) -c -o $@ $(TEST_GUI_CXXFLAGS) $(CPPDEPS) $< diff --git a/tests/makefile.vc b/tests/makefile.vc index 95861401c6..3b1462545b 100644 --- a/tests/makefile.vc +++ b/tests/makefile.vc @@ -216,6 +216,7 @@ TEST_GUI_OBJECTS = \ $(OBJS)\test_gui_slidertest.obj \ $(OBJS)\test_gui_spinctrldbltest.obj \ $(OBJS)\test_gui_spinctrltest.obj \ + $(OBJS)\test_gui_styledtextctrltest.obj \ $(OBJS)\test_gui_textctrltest.obj \ $(OBJS)\test_gui_textentrytest.obj \ $(OBJS)\test_gui_togglebuttontest.obj \ @@ -486,6 +487,10 @@ __DLLFLAG_p_7 = /d WXUSINGDLL __WXLIB_WEBVIEW_p = \ wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_webview.lib !endif +!if "$(MONOLITHIC)" == "0" && "$(USE_STC)" == "1" +__WXLIB_STC_p = \ + wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_stc.lib +!endif !if "$(MONOLITHIC)" == "0" __WXLIB_AUI_p = \ wx$(PORTNAME)$(WXUNIVNAME)$(WX_RELEASE_NODOT)$(WXUNICODEFLAG)$(WXDEBUGFLAG)$(WX_LIB_FLAVOUR)_aui.lib @@ -716,7 +721,7 @@ $(OBJS)\test_drawingplugin.dll: $(TEST_DRAWINGPLUGIN_OBJECTS) !if "$(USE_GUI)" == "1" $(OBJS)\test_gui.exe: $(OBJS)\test_gui_dummy.obj $(TEST_GUI_OBJECTS) $(OBJS)\test_gui_sample.res link /NOLOGO /OUT:$@ $(__DEBUGINFO_4) /pdb:"$(OBJS)\test_gui.pdb" $(__DEBUGINFO_51) $(LINK_TARGET_CPU) /LIBPATH:$(LIBDIRNAME) /SUBSYSTEM:CONSOLE $(____CAIRO_LIBDIR_FILENAMES) $(LDFLAGS) @<< - $(TEST_GUI_OBJECTS) $(TEST_GUI_RESOURCES) $(__WXLIB_WEBVIEW_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib wsock32.lib wininet.lib + $(TEST_GUI_OBJECTS) $(TEST_GUI_RESOURCES) $(__WXLIB_WEBVIEW_p) $(__WXLIB_STC_p) $(__WXLIB_AUI_p) $(__WXLIB_RICHTEXT_p) $(__WXLIB_MEDIA_p) $(__WXLIB_XRC_p) $(__WXLIB_XML_p) $(__WXLIB_HTML_p) $(__WXLIB_CORE_p) $(__WXLIB_NET_p) $(__WXLIB_BASE_p) $(__WXLIB_MONO_p) $(__LIB_SCINTILLA_IF_MONO_p) $(__LIB_TIFF_p) $(__LIB_JPEG_p) $(__LIB_PNG_p) wxzlib$(WXDEBUGFLAG).lib wxregex$(WXUNICODEFLAG)$(WXDEBUGFLAG).lib wxexpat$(WXDEBUGFLAG).lib $(EXTRALIBS_FOR_BASE) $(__CAIRO_LIB_p) kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib shlwapi.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib version.lib wsock32.lib wininet.lib << !endif @@ -1189,6 +1194,9 @@ $(OBJS)\test_gui_spinctrldbltest.obj: .\controls\spinctrldbltest.cpp $(OBJS)\test_gui_spinctrltest.obj: .\controls\spinctrltest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\spinctrltest.cpp +$(OBJS)\test_gui_styledtextctrltest.obj: .\controls\styledtextctrltest.cpp + $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\styledtextctrltest.cpp + $(OBJS)\test_gui_textctrltest.obj: .\controls\textctrltest.cpp $(CXX) /c /nologo /TP /Fo$@ $(TEST_GUI_CXXFLAGS) .\controls\textctrltest.cpp diff --git a/tests/test_vc7_test_gui.vcproj b/tests/test_vc7_test_gui.vcproj index 5854a3b1a2..83ccfa7655 100644 --- a/tests/test_vc7_test_gui.vcproj +++ b/tests/test_vc7_test_gui.vcproj @@ -49,7 +49,7 @@ + + diff --git a/tests/test_vc8_test_gui.vcproj b/tests/test_vc8_test_gui.vcproj index 6c61aa1c74..5dba30d921 100644 --- a/tests/test_vc8_test_gui.vcproj +++ b/tests/test_vc8_test_gui.vcproj @@ -86,7 +86,7 @@ + + diff --git a/tests/test_vc9_test_gui.vcproj b/tests/test_vc9_test_gui.vcproj index 85e5038f99..fe4f382385 100644 --- a/tests/test_vc9_test_gui.vcproj +++ b/tests/test_vc9_test_gui.vcproj @@ -85,7 +85,7 @@ + + From 5f39bb4157e3af4894e0f48de8a30bb39bd8ce77 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sun, 10 Mar 2019 23:37:09 -0500 Subject: [PATCH 19/23] Update other test build files by hand for the new STC test --- build/cmake/tests/gui/CMakeLists.txt | 4 ++++ tests/descrip.mms | 4 ++++ tests/test_gui.vcxproj | 17 +++++++++-------- tests/test_gui.vcxproj.filters | 3 +++ 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/build/cmake/tests/gui/CMakeLists.txt b/build/cmake/tests/gui/CMakeLists.txt index 44aa37cbdf..75db39bb99 100644 --- a/build/cmake/tests/gui/CMakeLists.txt +++ b/build/cmake/tests/gui/CMakeLists.txt @@ -63,6 +63,7 @@ set(TEST_GUI_SRC controls/slidertest.cpp controls/spinctrldbltest.cpp controls/spinctrltest.cpp + controls/styledtextctrltest.cpp controls/textctrltest.cpp controls/textentrytest.cpp controls/togglebuttontest.cpp @@ -171,6 +172,9 @@ wx_exe_link_libraries(test_gui core) if(wxUSE_RICHTEXT) wx_exe_link_libraries(test_gui richtext) endif() +if(wxUSE_STC) + wx_exe_link_libraries(test_gui stc) +endif() if(wxUSE_MEDIACTRL) wx_exe_link_libraries(test_gui media) endif() diff --git a/tests/descrip.mms b/tests/descrip.mms index d448c7095a..cb3b80f367 100644 --- a/tests/descrip.mms +++ b/tests/descrip.mms @@ -184,6 +184,7 @@ TEST_GUI_OBJECTS2=test_gui_richtextctrltest.obj,\ test_gui_slidertest.obj,\ test_gui_spinctrldbltest.obj,\ test_gui_spinctrltest.obj,\ + test_gui_styledtextctrltest.obj,\ test_gui_textctrltest.obj,\ test_gui_textentrytest.obj,\ test_gui_togglebuttontest.obj,\ @@ -617,6 +618,9 @@ test_gui_spinctrldbltest.obj : [.controls]spinctrldbltest.cpp test_gui_spinctrltest.obj : [.controls]spinctrltest.cpp $(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]spinctrltest.cpp +test_gui_styledtextctrltest.obj : [.controls]styledtextctrltest.cpp + $(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]styledtextctrltest.cpp + test_gui_textctrltest.obj : [.controls]textctrltest.cpp $(CXXC) /object=[]$@ $(TEST_GUI_CXXFLAGS) [.controls]textctrltest.cpp diff --git a/tests/test_gui.vcxproj b/tests/test_gui.vcxproj index dd60da1d58..01d985c991 100644 --- a/tests/test_gui.vcxproj +++ b/tests/test_gui.vcxproj @@ -154,7 +154,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_stc.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -193,7 +193,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_stc.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -236,7 +236,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_stc.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -275,7 +275,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_stc.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -318,7 +318,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_stc.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -357,7 +357,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_stc.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -400,7 +400,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)ud_webview.lib;wxmsw$(wxShortVersionString)ud_richtext.lib;wxmsw$(wxShortVersionString)ud_stc.lib;wxmsw$(wxShortVersionString)ud_aui.lib;wxmsw$(wxShortVersionString)ud_media.lib;wxmsw$(wxShortVersionString)ud_xrc.lib;wxbase$(wxShortVersionString)ud_xml.lib;wxmsw$(wxShortVersionString)ud_html.lib;wxmsw$(wxShortVersionString)ud_core.lib;wxbase$(wxShortVersionString)ud_net.lib;wxbase$(wxShortVersionString)ud.lib;wxtiffd.lib;wxjpegd.lib;wxpngd.lib;wxzlibd.lib;wxregexud.lib;wxexpatd.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -439,7 +439,7 @@ ..\lib\$(wxOutDirName)\$(wxIncSubDir);.\..\include;..\3rdparty\catch\include;.;.\..\samples;%(AdditionalIncludeDirectories) - wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) + wxmsw$(wxShortVersionString)u_webview.lib;wxmsw$(wxShortVersionString)u_richtext.lib;wxmsw$(wxShortVersionString)u_stc.lib;wxmsw$(wxShortVersionString)u_aui.lib;wxmsw$(wxShortVersionString)u_media.lib;wxmsw$(wxShortVersionString)u_xrc.lib;wxbase$(wxShortVersionString)u_xml.lib;wxmsw$(wxShortVersionString)u_html.lib;wxmsw$(wxShortVersionString)u_core.lib;wxbase$(wxShortVersionString)u_net.lib;wxbase$(wxShortVersionString)u.lib;wxtiff.lib;wxjpeg.lib;wxpng.lib;wxzlib.lib;wxregexu.lib;wxexpat.lib;kernel32.lib;user32.lib;gdi32.lib;comdlg32.lib;winspool.lib;winmm.lib;shell32.lib;comctl32.lib;ole32.lib;oleaut32.lib;uuid.lib;rpcrt4.lib;advapi32.lib;wsock32.lib;wininet.lib;%(AdditionalDependencies) true ..\lib\$(wxOutDirName);%(AdditionalLibraryDirectories) true @@ -496,6 +496,7 @@ + diff --git a/tests/test_gui.vcxproj.filters b/tests/test_gui.vcxproj.filters index 38c0bd0806..e61c1bf4fd 100644 --- a/tests/test_gui.vcxproj.filters +++ b/tests/test_gui.vcxproj.filters @@ -239,6 +239,9 @@ Source Files + + Source Files + Source Files From a5a44e8bae3a1eba7474bff96851ba0228cb419f Mon Sep 17 00:00:00 2001 From: VZ Date: Thu, 18 Apr 2019 20:57:01 -0500 Subject: [PATCH 20/23] Apply suggestions from code review Co-Authored-By: NewPagodi --- samples/stc/edit.cpp | 2 +- src/stc/PlatWX.cpp | 6 +++--- src/stc/PlatWXcocoa.mm | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/samples/stc/edit.cpp b/samples/stc/edit.cpp index bd2bfd6fb3..0900639684 100644 --- a/samples/stc/edit.cpp +++ b/samples/stc/edit.cpp @@ -190,7 +190,7 @@ Edit::Edit (wxWindow *parent, wxWindowID id, wxBitmap bmp(hashtag_xpm); RegisterImage(0, bmp); - //call tips + // call tips CallTipSetBackground(*wxYELLOW); m_calltipNo = 1; diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 04c6e3909c..fb77a09881 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2147,7 +2147,7 @@ PRectangle Window::GetMonitorRect(Point pt) { #ifdef __WXMSW__ // Use ShowWithoutActivating instead of show. - bool wxSTCPopupBase::Show(bool show) + bool wxSTCPopupBase::Show(bool show) wxOVERRIDE { if ( show ) { @@ -2165,7 +2165,7 @@ PRectangle Window::GetMonitorRect(Point pt) { // Do not activate in response to mouse clicks on this window. bool wxSTCPopupBase::MSWHandleMessage(WXLRESULT *res, WXUINT msg, - WXWPARAM wParam, WXLPARAM lParam) + WXWPARAM wParam, WXLPARAM lParam) wxOVERRIDE { if ( msg == WM_MOUSEACTIVATE ) { @@ -2492,7 +2492,7 @@ void wxSTCListBoxVisualData::ComputeColours() } } -void SetColourHelper(bool& isSet, wxColour& itemCol, const wxColour& newColour) +static void SetColourHelper(bool& isSet, wxColour& itemCol, const wxColour& newColour) { isSet = newColour.IsOk(); itemCol = newColour; diff --git a/src/stc/PlatWXcocoa.mm b/src/stc/PlatWXcocoa.mm index 0c8ce5ccd3..7b798f954e 100644 --- a/src/stc/PlatWXcocoa.mm +++ b/src/stc/PlatWXcocoa.mm @@ -23,7 +23,7 @@ wxWindow* m_wxWin; } -- (id)initWithwxWin:(wxWindow*) wxwin; +- (id)initWithwxWin:(wxWindow*) wxWin; @end From 9e2089e7020262a443521fac1e4e188013f3ccae Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Fri, 19 Apr 2019 09:55:41 -0500 Subject: [PATCH 21/23] Apply more suggestions from code review This commit removes an attempt to initially hide a frame which was unnecessary since frames are initially hidden by defautlt, removes an unncecessary destructor that only performed actions that would happen anyway, and replaces a Freeze/Thaw pair with wxWindowUpdateLocker. --- src/stc/PlatWX.cpp | 28 ++++++---------------------- 1 file changed, 6 insertions(+), 22 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 04c6e3909c..2eb57559d4 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -38,6 +38,7 @@ #include "wx/renderer.h" #include "wx/hashset.h" #include "wx/dcclient.h" +#include "wx/wupdlock.h" #ifdef wxHAS_RAW_BITMAP #include "wx/rawbmp.h" @@ -2126,19 +2127,11 @@ PRectangle Window::GetMonitorRect(Point pt) { #else - wxSTCPopupBase::wxSTCPopupBase(wxWindow* parent):wxFrame() + wxSTCPopupBase::wxSTCPopupBase(wxWindow* parent) + :wxFrame(parent, wxID_ANY, wxEmptyString, + wxDefaultPosition, wxDefaultSize, + wxFRAME_FLOAT_ON_PARENT | wxBORDER_NONE) { - // Make sure the frame is initially hidden. However, GTK+ will hide the - // frame initially and doesn't like trying to hide it before it's - // created, so don't do it there. - #if !defined(__WXGTK__) - Hide(); - #endif - - wxFrame::Create(parent, wxID_ANY, wxEmptyString, - wxDefaultPosition, wxDefaultSize, - wxFRAME_FLOAT_ON_PARENT | wxBORDER_NONE); - #if defined(__WXGTK__) gtk_window_set_accept_focus(GTK_WINDOW(this->GetHandle()), FALSE); #endif @@ -2566,7 +2559,6 @@ class wxSTCListBox : public wxSystemThemedControl { public: wxSTCListBox(wxWindow*, wxSTCListBoxVisualData*, int); - virtual ~wxSTCListBox(); // wxWindow overrides virtual bool AcceptsFocus() const wxOVERRIDE; @@ -2668,12 +2660,6 @@ wxSTCListBox::wxSTCListBox(wxWindow* parent, wxSTCListBoxVisualData* v, int ht) } } -wxSTCListBox::~wxSTCListBox() -{ - m_labels.clear(); - m_imageNos.clear(); -} - bool wxSTCListBox::AcceptsFocus() const { return false; @@ -2785,7 +2771,7 @@ void wxSTCListBox::SetDoubleClickAction(CallBackAction action, void *data) void wxSTCListBox::SetList(const char* list, char separator, char typesep) { - Freeze(); + wxWindowUpdateLocker noUpdates(this); Clear(); SetOfInts bitmapNos; wxStringTokenizer tkzr(stc2wx(list), (wxChar)separator); @@ -2806,8 +2792,6 @@ void wxSTCListBox::SetList(const char* list, char separator, char typesep) if ( m_imageAreaHeight > 0 ) RecalculateItemHeight(); - - Thaw(); } void wxSTCListBox::AppendHelper(const wxString& text, int type) From 419a053b7db43041904735d264fd76556e474a56 Mon Sep 17 00:00:00 2001 From: New Pagodi Date: Sat, 20 Apr 2019 12:38:29 -0500 Subject: [PATCH 22/23] Change names of XXXIsSet variables in wxSTCListBoxVisualData Instead name the variables useDefaultXXXColour since it more accurately describes what purpose the variables are serving. --- src/stc/PlatWX.cpp | 66 ++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 31 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index f431c77481..03230714ae 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2339,25 +2339,26 @@ private: wxColour m_textColour; wxColour m_highlightBgColour; wxColour m_highlightTextColour; - bool m_bgColourIsSet; - bool m_textColourIsSet; - bool m_highlightBgColourIsSet; - bool m_highlightTextColourIsSet; + bool m_useDefaultBgColour; + bool m_useDefaultTextColour; + bool m_useDefaultHighlightBgColour; + bool m_useDefaultHighlightTextColour; bool m_hasListCtrlAppearance; wxColour m_currentBgColour; wxColour m_currentTextColour; - bool m_currentBgColourIsSet; - bool m_currentTextColourIsSet; + bool m_UseDefaultCurrentBgColour; + bool m_UseDefaultCurrentTextColour; }; wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), - m_bgColourIsSet(false), m_textColourIsSet(false), - m_highlightBgColourIsSet(false), - m_highlightTextColourIsSet(false), + m_useDefaultBgColour(true), + m_useDefaultTextColour(true), + m_useDefaultHighlightBgColour(true), + m_useDefaultHighlightTextColour(true), m_hasListCtrlAppearance(false), - m_currentBgColourIsSet(false), - m_currentTextColourIsSet(false) + m_UseDefaultCurrentBgColour(true), + m_UseDefaultCurrentTextColour(true) { ComputeColours(); } @@ -2437,10 +2438,10 @@ void wxSTCListBoxVisualData::ComputeColours() // wxSYS_COLOUR_BTNSHADOW seems to be the closest match with most themes. m_borderColour = wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW ); - if ( !m_bgColourIsSet ) + if ( m_useDefaultBgColour ) m_bgColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX); - if ( !m_textColourIsSet ) + if ( m_useDefaultTextColour ) m_textColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); if ( m_hasListCtrlAppearance ) @@ -2448,47 +2449,48 @@ void wxSTCListBoxVisualData::ComputeColours() // If m_highlightBgColour and/or m_currentBgColour are not // explicitly set, set them to wxNullColour to indicate that they // should be drawn with wxRendererNative. - if ( !m_highlightBgColourIsSet ) + if ( m_useDefaultHighlightBgColour ) m_highlightBgColour = wxNullColour; - if ( !m_currentBgColourIsSet ) + if ( m_UseDefaultCurrentBgColour ) m_currentBgColour = wxNullColour; #ifdef __WXMSW__ - if ( !m_highlightTextColourIsSet ) + if ( m_useDefaultHighlightTextColour ) m_highlightTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXTEXT); #else - if ( !m_highlightTextColourIsSet ) + if ( m_useDefaultHighlightTextColour ) m_highlightTextColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); #endif - if ( !m_currentTextColour.IsOk() ) + if ( m_UseDefaultCurrentTextColour ) m_currentTextColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT); } else { #ifdef __WXOSX_COCOA__ - if ( !m_highlightBgColourIsSet ) + if ( m_useDefaultHighlightBgColour ) m_highlightBgColour = GetListHighlightColour(); #else - if ( !m_highlightBgColourIsSet ) + if ( m_useDefaultHighlightBgColour ) m_highlightBgColour = - wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); + wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT); #endif - if ( !m_highlightTextColourIsSet ) + if ( m_useDefaultHighlightTextColour ) m_highlightTextColour = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); } } -static void SetColourHelper(bool& isSet, wxColour& itemCol, const wxColour& newColour) +static void SetColourHelper(bool& isDefault, wxColour& itemColour, + const wxColour& newColour) { - isSet = newColour.IsOk(); - itemCol = newColour; + isDefault = !newColour.IsOk(); + itemColour = newColour; } void wxSTCListBoxVisualData::SetColours(const wxColour& bg, @@ -2496,10 +2498,11 @@ void wxSTCListBoxVisualData::SetColours(const wxColour& bg, const wxColour& hlbg, const wxColour& hltext) { - SetColourHelper(m_bgColourIsSet, m_bgColour, bg); - SetColourHelper(m_textColourIsSet, m_textColour, txt); - SetColourHelper(m_highlightBgColourIsSet, m_highlightBgColour, hlbg); - SetColourHelper(m_highlightTextColourIsSet, m_highlightTextColour, hltext); + SetColourHelper(m_useDefaultBgColour, m_bgColour, bg); + SetColourHelper(m_useDefaultTextColour, m_textColour, txt); + SetColourHelper(m_useDefaultHighlightBgColour, m_highlightBgColour, hlbg); + SetColourHelper(m_useDefaultHighlightTextColour, m_highlightTextColour, + hltext); ComputeColours(); } @@ -2533,8 +2536,9 @@ void wxSTCListBoxVisualData::UseListCtrlStyle(bool useListCtrlStyle, const wxColour& curText) { m_hasListCtrlAppearance = useListCtrlStyle; - SetColourHelper(m_currentBgColourIsSet, m_currentBgColour, curBg); - SetColourHelper(m_currentTextColourIsSet, m_currentTextColour, curText); + SetColourHelper(m_UseDefaultCurrentBgColour, m_currentBgColour, curBg); + SetColourHelper(m_UseDefaultCurrentTextColour, m_currentTextColour, + curText); ComputeColours(); } From eebadf34835285fd962b59ae23e6ececfdbed020 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 21 Apr 2019 02:03:05 +0200 Subject: [PATCH 23/23] Rename m_UseXXX variables to m_useXXX for consistency And also to follow the usual naming convention. --- src/stc/PlatWX.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/stc/PlatWX.cpp b/src/stc/PlatWX.cpp index 03230714ae..c9fdfe9ee8 100644 --- a/src/stc/PlatWX.cpp +++ b/src/stc/PlatWX.cpp @@ -2347,8 +2347,8 @@ private: bool m_hasListCtrlAppearance; wxColour m_currentBgColour; wxColour m_currentTextColour; - bool m_UseDefaultCurrentBgColour; - bool m_UseDefaultCurrentTextColour; + bool m_useDefaultCurrentBgColour; + bool m_useDefaultCurrentTextColour; }; wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), @@ -2357,8 +2357,8 @@ wxSTCListBoxVisualData::wxSTCListBoxVisualData(int d):m_desiredVisibleRows(d), m_useDefaultHighlightBgColour(true), m_useDefaultHighlightTextColour(true), m_hasListCtrlAppearance(false), - m_UseDefaultCurrentBgColour(true), - m_UseDefaultCurrentTextColour(true) + m_useDefaultCurrentBgColour(true), + m_useDefaultCurrentTextColour(true) { ComputeColours(); } @@ -2452,7 +2452,7 @@ void wxSTCListBoxVisualData::ComputeColours() if ( m_useDefaultHighlightBgColour ) m_highlightBgColour = wxNullColour; - if ( m_UseDefaultCurrentBgColour ) + if ( m_useDefaultCurrentBgColour ) m_currentBgColour = wxNullColour; #ifdef __WXMSW__ @@ -2465,7 +2465,7 @@ void wxSTCListBoxVisualData::ComputeColours() wxSYS_COLOUR_LISTBOXHIGHLIGHTTEXT); #endif - if ( m_UseDefaultCurrentTextColour ) + if ( m_useDefaultCurrentTextColour ) m_currentTextColour = wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOXTEXT); } @@ -2536,8 +2536,8 @@ void wxSTCListBoxVisualData::UseListCtrlStyle(bool useListCtrlStyle, const wxColour& curText) { m_hasListCtrlAppearance = useListCtrlStyle; - SetColourHelper(m_UseDefaultCurrentBgColour, m_currentBgColour, curBg); - SetColourHelper(m_UseDefaultCurrentTextColour, m_currentTextColour, + SetColourHelper(m_useDefaultCurrentBgColour, m_currentBgColour, curBg); + SetColourHelper(m_useDefaultCurrentTextColour, m_currentTextColour, curText); ComputeColours(); }