Commit Graph

178 Commits

Author SHA1 Message Date
New Pagodi
c11582320d Fix location of stc autocomp popup with images
The stc autocomp popup is supposed to report the location at which text
is drawn with the wxSTCListBox::CaretFromEdge function. To return the
correct value, the popup needs to compute the largest width of any
bitmap used for icons in the popup since text is drawn to the right of
the popup's images.

Previously the wxSTCListBox tried to compute this largest width when
the listbox items were set. However, Scintilla actually calls
CaretFromEdge before setting the listbox items. Consequently the
CaretFromEdge was returning a value that assumed zero width for the
list's images since images had not been set yet.

Instead, keep a running tally of the widest image width when images are
registered. This means that this variable must be moved to the
wxSTCListBoxVisualData class since that is where image registration is
handled. Also track the largest image height since that is also needed.
2020-06-24 17:23:28 -05:00
Maarten Bent
71773d40ab Avoid ugly casts to wxMemoryDC 2020-06-07 19:14:05 +02:00
Maarten Bent
379cff7d19 Fix building with wxUSE_POPUP==0 2020-06-01 18:16:52 +02:00
Maarten Bent
54e0521fd7 Improve setting wxSTCPopupWindow size
DoSetSize needs to accept absolute size, because other code can call it.
2020-06-01 16:55:42 +02:00
Maarten Bent
83a98e1a3c Handle DPI change in wxSTCListBox popup 2020-06-01 16:54:54 +02:00
Maarten Bent
6eb357f038 Improve DPI handling in wxSTC
Adjusting the zoom level does not work correctly. It could lead to ever
increasing zoom.
Instead, set the correct DPI of the underlying device context.
2020-06-01 16:45:21 +02:00
Maarten Bent
9b0cdc8d7d Only create the wxSTC cursor when it is needed 2020-06-01 16:07:49 +02:00
New Pagodi
4523df5d94 Redirect mouse wheel events when STC autocomp is active
While an autocompletion list is being shown, a native Scintilla window
will use mouse wheel events to scroll the list instead of the editor
window. Match this behavior with wxSTC by intercepting mouse wheel
events and redirecting them to the list.
2019-08-07 21:36:42 -05:00
New Pagodi
c3d9222a7c Fix wxSTCPopupBase::Show for windows
The existing logic for the Show method results in wxWindowBase::Show
being called twice when the argument is false. Slightly rearrange the
code to fix this defect.
2019-08-07 21:36:42 -05:00
New Pagodi
075fa2b764 Record wxSTCPopupWindow position every time its set
The position of wxSTCPopupWindow is currently recorded the first time it
is set so that it can be used to reposition the popup when its parent
window is moved. However Scintilla apparently positions the popup at
least twice when icons are used and the first set position is slightly
wrong. Instead just record the position every time its set by Scintilla.
2019-08-07 21:36:42 -05:00
Vadim Zeitlin
7db13c7b93 Merge branch 'pm-dpi-aware-1-systemmetric' of https://github.com/MaartenBent/wxWidgets
Make GetSystemMetrics() and wxSystemParametersInfo DPI-aware in wxMSW.

See https://github.com/wxWidgets/wxWidgets/pull/1407
2019-07-15 13:21:16 +02:00
Maarten Bent
e32c20ffcc Use const wxWindow in wxSystemSettings::GetMetric 2019-07-15 00:00:20 +02:00
Maarten Bent
f74d756ca5 Use DPI Aware wxGetSystemMetrics
If no wxWindow is known, use wxTheApp->GetTopWindow().
Also use a wxWindow for all wxSystemSettings::GetMetric calls.
2019-07-15 00:00:18 +02:00
New Pagodi
3ccb912e62 Store SELECTION_CHANGE data in wxSTCListBoxVisualData
The first attempt to add the wxEVT_STC_AUTOCOMP_SELECTION_CHANGE event to wxSTC
passed the data needed for the event through the constructor for the
wxSTCListBox class. Instead of mdifying the constructor for wxSTCListBox, it’s
better to store the data in the wxSTCListBoxVisualData class with accessors for
setting and retrieving the data.
2019-07-13 15:53:33 -05:00
New Pagodi
61d4dbc66b Fix crash with wxSTC autocomp on macOS
On macOS, the autocompletion popup maintains a pointer to its parent
control since it sometimes needs to set a cursor on the control. However
when the control is destroyed while the popup is active, the control is
destroyed before the popup because of the delayed destruction used by
the popup. This leaves the popup with a dangling pointer and can lead to
crashes.

To prevent this, let the popup handle the window destroy event for the
control. Reset the pointer to NULL in that handler so that the popup
will no longer try to access its parent control after it is deleted.
2019-07-13 12:40:27 -05:00
New Pagodi
d24f58cc55 Add AUTOCOMP_SELECTION_CHANGE event for wxSTC
The SCN_AUTOCSELECTIONCHANGE notification was added in Scintilla 4.0 to
notify an application when a new item is selected in an autocompletion
or user list. However the version of Scintilla currently used is 3.7.2,
so this potentially useful notification is not available.

These changes allow an event corresponding to this notification to be
generated completely in the wxWidgets portion of wxSTC. If the Scintilla
library is ever updated to 4.0 or later, only one method should need to
be modified let Scintilla generate the event instead.
2019-07-13 12:23:06 -05:00
New Pagodi
caaebf43bc Remove wxSTC methods for configuring autocomp popup
The wxSTC methods AutoCompSetColours and AutoCompUseListCtrl were added
in fe7b332b7b to allow some configuration
of the autocompletion popup window. Based on subsequent discussion, it
was decided that a better method of configuring the popup and getting
information about the configuration is needed. For now, simply remove
the current methods while the better solution is created.

In addition, since the configuration options are being removed, set the
popup to have the appearance of a list control since that was the
appearance before any configuration options were added.
2019-07-13 12:20:10 -05:00
Vadim Zeitlin
eebadf3483 Rename m_UseXXX variables to m_useXXX for consistency
And also to follow the usual naming convention.
2019-04-21 02:03:05 +02:00
New Pagodi
419a053b7d Change names of XXXIsSet variables in wxSTCListBoxVisualData
Instead name the variables useDefaultXXXColour since it more accurately
describes what purpose the variables are serving.
2019-04-20 12:38:29 -05:00
New Pagodi
9fc8642458 Merge branch 'stcpopup' of https://github.com/NewPagodi/wxWidgets into stcpopup 2019-04-19 10:12:29 -05:00
New Pagodi
9e2089e702 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.
2019-04-19 09:55:41 -05:00
VZ
a5a44e8bae Apply suggestions from code review
Co-Authored-By: NewPagodi <NewPagodi@users.noreply.github.com>
2019-04-18 20:57:01 -05:00
New Pagodi
267540d233 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.
2019-03-20 00:15:38 -05:00
New Pagodi
3900cfec27 Add AutoCompSetColours method to stc
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.
2019-03-20 00:15:31 -05:00
New Pagodi
f0ba9f0ef1 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.
2019-03-20 00:15:24 -05:00
New Pagodi
0f7552cdb0 Hide popup when STC app is minimized on macos and GTK+ 2019-03-20 00:15:13 -05:00
New Pagodi
0c953308de Allow wxSTCPopupWindow to move when its parent wxSTC moves 2019-03-20 00:15:05 -05:00
New Pagodi
de0992ea3d 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.
2019-03-20 00:14:58 -05:00
New Pagodi
891f541397 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.
2019-03-20 00:14:43 -05:00
New Pagodi
66d340ae15 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.
2019-03-18 22:25:10 -05:00
New Pagodi
75656067ae 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.
2019-03-18 22:25:02 -05:00
VZ
12749d1a59 Update src/stc/PlatWX.cpp
Co-Authored-By: NewPagodi <NewPagodi@users.noreply.github.com>
2019-03-18 15:43:30 -05:00
New Pagodi
8be4f7dde6 Change wxSTC mapping for SCI_REGISTERIMAGE
Currently the Scintilla message SCI_REGISTERIMAGE is mapped to
wxStyledTextCtrl::RegisterImage(int, const wxBitmap&). This makes
RegisterImage a manually defined method and passes the bitmap directly
to the listbox instead of first converting to an XPM.

To backfill the message map, SCI_REGISTERIMAGE is now mapped to a new
method overload RegisterImage(int, const char* const*). The new method
accepts XPM data instead of a wxBitmap.
2019-03-17 01:48:51 -05:00
New Pagodi
8c180ee7b5 Change the implementation of ListBoxImpl::RegisterImage
The ListBoxImpl::RegisterImage in PlatWX.cpp is supposed to accept an
XPM and convert it into a useable form. For wxWidgets, the useable form
is obviously a wxBitmap. According to the Scintilla specification, the
function should accept both a copy of an XPM file and a set of XPM data.

Currently RegisterImage uses the the wxWidgets XPM image handler. This
has 2 drawbacks. First it requires that the XPM handler is loaded before
the function can be called. Second, the function only accepts a copy of
an XPM file and does not work with XPM data.

Instead use wxXPMDecoder. This class can be decode both types of input
and can be used to build a wxBitmap.
2019-03-17 01:47:36 -05:00
New Pagodi
91d3981a7b Implement BitmapFromRGBAImage without raw bitmap
The function BitmapFromRGBAImage in PlatWX.cpp is currently only
used when wxHAS_RAW_BITMAP is defined. Consequently some functions in
PlatWX.cpp simply do nothing when wxHAS_RAW_BITMAP is not defined. This
provides a second implementation of the function based on wxImage that
is used when wxHAS_RAW_BITMAP is not defined.
2019-02-02 17:45:30 -06:00
Vadim Zeitlin
4ad9cde380 Use the new wxDisplay(wxWindow*) ctor to simplify the code
Make the code simpler and, in a couple of places where the fall back to
the primary display in case wxDisplay::GetFromWindow() returned -1 was
missing, also more correct.
2018-11-01 00:06:34 +01:00
Vadim Zeitlin
761f9f74fc Merge branch 'simplify-display'
Centralize all display-related code in wxDisplay class and avoid
duplicating or reimplementing it in wxDisplaySize() and
wxClientDisplayRect() functions.

See https://github.com/wxWidgets/wxWidgets/pull/955
2018-10-01 13:52:07 +02:00
Maarten Bent
487a3854a3 Fix building stc library with WXQT
When using MSVC compiler, wxUSE_GRAPHICS_DIRECT2D is automatically enabled in setup.h.
But it is only available with WXMSW toolkit, not WXGTK or WXQT.
2018-09-30 17:23:58 +02:00
Vadim Zeitlin
587a510028 Remove unnecessary wxUSE_DISPLAY preprocessor checks
Most of the methods of wxDisplay are always available, they just only
support primary display when wxUSE_DISPLAY==0, so there is no need to
check for wxUSE_DISPLAY before using them as they already contain the
only possible fallback anyhow and such checks are useless.

This incidentally closes #18115, due to removing "#if wxUSE_DISPLAY"
around wx/display.h inclusion.
2018-09-30 00:38:26 +02:00
Jouk
fd4d38e657 Always include wx/display.h (also when wxUSE_DISPLAY=0) 2018-07-19 09:52:44 +02:00
Teodor Petrov
4cdd3001c2 Keep wxSTC call tips inside the current display
Make it harder for the calltip to be invisible

* This required changes to the Window::SetPositionRelative.
* Use the Qt version as a base.
* The idea is to confine the window to the boundaries of the display the
  scintilla control is at the moment of the call.

Closes #18115.
2018-04-01 16:43:24 +02:00
New Pagodi
c83ddec75f Fix drawing call tips in wxSTC when using Direct2D
Use the correct window as the containing control in SurfaceD2D.

Closes #18080.
2018-02-17 19:49:48 +01:00
Maarten Bent
8577d9ddca Fix build warnings in Direct2D related code
Regressions since df1456e4e2 and
b936bfe85e.

See https://github.com/wxWidgets/wxWidgets/pull/731
2018-02-16 15:55:33 +01:00
Vadim Zeitlin
1119a44cdd Simplify and make more portable DWrite font weight translation
There doesn't seem to be any need for painstakingly translating STC font
weight to DWRITE_FONT_WEIGHT when they seem to use exactly the same
numeric values anyhow.

This also fixes compilation when using older SDK versions that don't
define DWRITE_FONT_WEIGHT_SEMI_LIGHT constant, which is relatively
recent (and presence of which can't be easily checked, as it's an enum
element and not a preprocessor constant).
2018-01-30 01:21:24 +01:00
Vadim Zeitlin
264f93aad9 Fix harmless signed/unsigned comparison warning in wxSTC code
Cast int to size_t before comparing it with the wxString length.
2018-01-27 13:37:53 +01:00
Vadim Zeitlin
4e6763ccc2 Fix harmless unused parameter warning in wxSTC code
The recently added "technology" parameter is unused when Direct2D is not
used, avoid compiler complains about this.
2018-01-25 17:21:15 -06:00
Vadim Zeitlin
8d75368a30 Minor formatting and style fixes to the previous commit
Fix indentation and spacing.

Also declare some variables when initializing them and make them const
if they don't change later.
2018-01-25 17:18:27 -06:00
New Pagodi
df1456e4e2 Apply erans patch to allow building with MinGW 2018-01-25 16:08:33 -06:00
New Pagodi
b936bfe85e Add Direct2D support to wxSTC 2018-01-25 16:07:54 -06:00
Artur Wieczorek
d0a07b665f Fix MSVC14 warnings about shadowed variables in wxSTC
Just to suppress harmless warnings.
2017-04-09 21:29:31 +02:00