Commit Graph

68491 Commits

Author SHA1 Message Date
Vadim Zeitlin
f72f2bec3a Merge branch 'dpi-stc' of https://github.com/MaartenBent/wxWidgets
Fix and improve DPI handling in wxStyledTextCtrl.

Fix cursor size after DPI change.

Enable handling DPI events in wxSTCPopupWindow and other popup windows
(that do not inherit from wxTopLevelWindow).

Some cleanup of STC example, and add option to select drawing
technology.

See https://github.com/wxWidgets/wxWidgets/pull/1885
2020-06-09 23:56:37 +02:00
PB
9ff095a852 Use wxCoTaskMemPtr
Use RAII class wxCoTaskMemPtr to manage pointers that must
be freed with ::CoTaskMemFree().
2020-06-09 20:17:25 +02:00
PB
d445111e77 Create wxCoTaskMemPtr class
wxCoTaskMemPtr is a barebone RAII class for pointers
that must freed with ::CoTaskMemFree().
2020-06-09 20:14:33 +02:00
Vadim Zeitlin
8ff6fa6f54 Use GetAnimation() in wxAnimationCtrlXmlHandler again
This function basically only exists in order to be used in this handler,
so extend it to allow doing it by adding wxAnimationCtrlBase argument to
it, allowing it to create wxAnimation object compatible with the given
control.

This reduces code duplication and, incidentally, makes GetAnimation()
more useful for any user-defined XRC handlers.
2020-06-09 18:07:10 +02:00
Vadim Zeitlin
2c4b0b4271 Get rid of src/xrc/xmladv.cpp file
It contained a single function which can be defined in xh_animatctrl.cpp
instead as it's only used there anyhow, and this file has no more reason
to exist, as "adv" library itself doesn't exist any longer.
2020-06-09 18:07:10 +02:00
Ilya Sinitsyn
b1a744ce07 Fix an issue with the background in wxGenericAnimationCtrl
Static bitmap with alpha channel must also be drawn on the memory DC
instead of being used directly, just as the bitmaps with a mask.
2020-06-09 18:07:10 +02:00
Vadim Zeitlin
ac7c40b141 Add dummy wxBitmap::HasAlpha() to wxX11
This allows to write code using this function without any preprocessor
checks.

It should arguably be added to wxBitmapBase to ensure that it's
available in all ports, but should be done together with UseAlpha(),
which is not quite trivial, so leave it for later.
2020-06-09 18:07:10 +02:00
Ilya Sinitsyn
2cdcd84928 Support wxGenericAnimationCtrl by the animation control XRC handler 2020-06-09 18:07:10 +02:00
Ilya Sinitsyn
cc5fb63bf7 Add wxXmlResourceHandler::GetFilePath()
The function already implemented in wxXmlResourceHandlerImpl. Just make it
accessible from wxXmlResourceHandler.
2020-06-09 21:34:10 +07:00
Vadim Zeitlin
e5ce18f0cb Make multiline controls 5 lines high by default under Mac
This is consistent with the current behaviour of GetSizeFromTextSize()
and the behaviour of GetBestSize() before the changes in this branch.

This is still not consistent with the behaviour of the other ports, but
this will be addressed later, by replacing the currently hardcoded 5.

Note that calling usedRectForTextContainer: here was apparently wrong in
any case because we were not sure to have already performed a layout and
we should have had a call to ensureLayoutForTextContainer: before it to
make it actually work. However, this made it work "too well" because it
then correctly returned potentially very big sizes for the text controls
containing a lot of text, which is not what we need here, as explained
in the comment added by this commit.
2020-06-09 11:17:00 +02:00
Vadim Zeitlin
0458ad6c4a Use temporary NSLayoutManager variable
No real changes, just make the code slightly shorter.
2020-06-09 01:11:37 +02:00
Vadim Zeitlin
c351f80481 Don't call GetBestSize() from DoGetSizeFromTextSize() in wxOSX
This could easily result in infinite recursion, as it is very natural to
implement DoGetBestSize() in terms of GetSizeFromTextSize() and, in
fact, our own implementation of the generic wxSpinCtrl did exactly this.

Avoid such problems by only calling GetSizeFromTextSize() from
DoGetBestSize(), but not in the other direction.

This shouldn't have any effect on the returned size values.
2020-06-09 01:10:03 +02:00
Vadim Zeitlin
41f4b1716d Set initial wxTextCtrl text earlier in wxOSX
This reverts the changes of 63bcc669d8 (fixing setting initial value
under osx_cocoa for single line text controls, 2009-10-01) and fixes the
problem which this commit probably tried to fix in a different way,
using the same approach as in 98f5315405 (Don't set initial label in
wxNativeWindow on OS X, 2016-04-29) as the real root of the problem was
that the text set in CreateTextControl() was overwritten later when the
label was set from SetPeer().

This change means that the text is now set correctly before SetPeer()
calls SetInitialSize() call, which makes it possible to set the correct
initial size based on the initial text, as will be done in later
commits.

It also makes Cocoa port more consistent with iOS one, as a nice side
effect.
2020-06-08 15:29:42 +02:00
Vadim Zeitlin
de2fba540b Document wxSizer::RecalcSizes() and RepositionChildren() better
Mention that RecalcSizes() shouldn't be called any more, after the
changes of 622deec262 (Replace wxSizer::RecalcSizes() with
RepositionChildren(), 2015-10-11), and that RepositionChildren()
replacing it shouldn't be directly called neither.
2020-06-08 13:26:59 +02:00
Maarten Bent
9b8cc49568 Fix missing include for WM_DPICHANGED 2020-06-07 19:14:36 +02:00
Maarten Bent
71773d40ab Avoid ugly casts to wxMemoryDC 2020-06-07 19:14:05 +02:00
Vadim Zeitlin
0d68a6d42e Fix formatting of @since in the list items in wxGauge docs
The line break after "Since" doesn't look good in this context, so avoid
using @since and spell it out explicitly.
2020-06-07 18:55:11 +02:00
Vadim Zeitlin
90783fec05 Merge branch 'generic-dvc-improve-dnd'
Improve drag-and-drop in generic wxDataViewCtrl.

See https://github.com/wxWidgets/wxWidgets/pull/1836
2020-06-07 17:22:05 +02:00
Konstantin S. Matveyev
1795ecdb78 Show the proposed drop index in the dataview sample
This allows to check interactively that the proposed index is set
correctly depending on the drop position.
2020-06-07 17:21:35 +02:00
Vadim Zeitlin
79d25664eb Optimize wxGrid::GetBestSize() when using uniform row/column size
There is no need to iterate over all rows or columns if all of them have
the same size anyhow.
2020-06-07 17:04:49 +02:00
Vadim Zeitlin
f9780847b8 Refactor dialog testing code to avoid gcc 10 -Wduplicated-branches
The old version resulted in

error: this condition has identical branches [-Werror=duplicated-branches]
    |                                 (dlg ? typeid(*dlg) : typeid(T)).name());
    |                                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~

from gcc 10 when compiling with -O2.

Change the code to avoid using this condition entirely: not only this
avoids the warning, but it also makes it unnecessary to make
wxGetDialogClassDescription() function a template, so should result in
slightly faster compilation and smaller code size too.

No real changes.
2020-06-07 13:00:14 +02:00
Ian McInerney
0941b25a97 Improve wxBitmapButton best size for small bitmaps in wxOSX
The correct condition for adding the extra border to the buttons that
would be clipped without it due to the bezel style used for them is to
check that their height is < 20, as SetBezelStyleFromBorderFlags(),
which determines the bezel to use, does, and not if their width is 16,
as this is not the same thing, especially for non-square buttons.

Closes https://github.com/wxWidgets/wxWidgets/pull/1887
2020-06-07 12:47:56 +02:00
Paul Cornett
d0ed90075c Fix wxToggleButton image when state is changed programmatically
See #18779
2020-06-02 12:16:57 -07:00
Vadim Zeitlin
cbe21c0cc9 Recommend SetMinSize() instead of wxSizerItem::SetInitSize()
It's not really clear why do we have this function at all, but
SetMinSize() name is more clear and consistent with wxWindow, so prefer
using it instead.
2020-06-02 18:33:57 +02:00
Ian McInerney
68561ecea8 Minor doc fixes for wxSizerItem methods
Fix typo in GetRatio() documentation and add documentation for
SetInitSize().

Closes https://github.com/wxWidgets/wxWidgets/pull/1882
2020-06-02 18:33:02 +02:00
Stefan Brüns
d56d676450 Add missing QPainterPath include required with Qt 5.15
The header is no longer pulled in by QPainter, omitting it causes
failing builds due to incomplete type QPainterPath.

Closes https://github.com/wxWidgets/wxWidgets/pull/1880
2020-06-02 16:48:38 +02:00
Maarten Bent
379cff7d19 Fix building with wxUSE_POPUP==0 2020-06-01 18:16:52 +02:00
Vadim Zeitlin
5b810b129d Fix wxUIActionSimulator::Text() parameter documentation
This function explicitly accepts ASCII strings only, so it's limited to
"const char*", but was incorrectly documented as taking wxString.

Closes https://github.com/wxWidgets/wxWidgets/pull/1879
2020-06-01 17:25:41 +02:00
Maarten Bent
5fa8280fd8 Hide wxSTC popup when the DPI changes
After a DPI change, the position of the popup is wrong. It is not shown at the
cursor position anymore.
The correct size and position are calculated by scintilla, and there is no easy
way to access this without modifying scintilla sources.
2020-06-01 17:02:08 +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
4700298c26 Move DPI handling from wxTopLevelWindow to wxNonOwnedWindow
This way, other windows (like wxPopupWindow) will also be able to handle DPI events.

Override InheritAttributes() and use it to set the initial DPI values.
2020-06-01 16:47:50 +02:00
Maarten Bent
a29aae25fc Use a different font for the MinimalEditor in the STC example
wxSYS_ANSI_FIXED_FONT uses 'Courier' font, which is rendered small on high DPI displays.
Use wxFONTFAMILY_TELETYPE instead, which will use font 'Courier New'.
2020-06-01 16:47:50 +02:00
Maarten Bent
a500c60feb Add option to STC example to select drawing technology 2020-06-01 16:47:50 +02:00
Maarten Bent
0195d82832 Remove unimplemented functions and code from STC example 2020-06-01 16:47:50 +02:00
Maarten Bent
951974f808 Reset the wxSTC cursor when the DPI changes
This causes the cursor to be recreated (when necessary) at the correct DPI.
2020-06-01 16:47:47 +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
Maarten Bent
5166ddea2b Create cursors with correct size when DPI changes
GetIconInfo does not return DPI aware results.
Adjust it to the DPI of the display that shows the cursor.
2020-06-01 16:07:48 +02:00
Vadim Zeitlin
66c8437952 Add notes about standard threading classes to the documentation
There is no reason to use wxMutex and wxCondition in C++11 programs as
they have about the same API as the corresponding standard classes but
are, well, non-standard.

wxThread API is different from std::thread, so it's a less obvious
replacement, but still at least mention the standard class in its
documentation.
2020-06-01 15:10:24 +02:00
Vadim Zeitlin
192e8befb8 Fix example showing wxMutex usage in documentation
Fix wrong use of pointer and wrong variable name.

Closes #18778.
2020-06-01 15:04:45 +02:00
Vadim Zeitlin
123e21c181 Refactor wxGrid::SetOrCalcColumnSizes() and SetOrCalcRowSizes()
Get rid of the unnecessarily complicated functions doing two quite
different things depending on whether their first boolean parameter was
true of false.

Instead, split their body between AutoSize{Columns,Rows}() (which used
to call them) and DoGetBestSize(), keeping just the part needed in each
case.

This is much simpler and even more efficient, as it avoids a completely
unnecessary call to CalcDimensions() and Refresh() from DoGetBestSize(),
which doesn't change the current size at all and so doesn't need to
refresh anything, but previously did it and not only once, but twice,
because both of SetOrCalc{Column,Row}Sizes() did it.
2020-05-31 17:51:12 +02:00
Vadim Zeitlin
eac58e7f87 Simplify wxGrid best size computations
Remove needless subtraction of row/column label size before adding it
back again, as this seems completely unnecessary.

No real changes, this is just a simplification.
2020-05-31 16:12:26 +02:00
Vadim Zeitlin
68feb3e7ff Fix linking monolithic wxMSW DLL after STC IME changes
Link wxMSW monolithic library with imm32.lib as it's not required by
wxscintilla.lib.

This should have been been part of f730da3c14 (Add imm32.lib to
wxStyledTextCtrl, 2020-05-10).

See https://github.com/wxWidgets/wxWidgets/pull/1852

Closes #18776.
2020-05-31 14:33:30 +02:00
Vadim Zeitlin
789c7cec7b Merge branch 'grid-col-row-sel'
Fix returning duplicates from Get{Row,Col}Selection(); add more tests.

See https://github.com/wxWidgets/wxWidgets/pull/1874
2020-05-31 00:43:23 +02:00
Jouk
e59a5d17da Make gtk1.x happy again 2020-05-29 09:16:25 +02:00
Lauri Nurmi
fa16bc05da Test DESELECTED events in both virtual and non-virtual listctrls. 2020-05-28 10:51:58 +03:00
Lauri Nurmi
96b83a1523 Make virtual lists send DESELECTED events consistently on both implementations
In the case when a listctrl is clicked outside of any item, the item is
visually deselected, and it is logical that a DESELECTED is sent.

For non-virtual lists this would happen, but for virtual lists it would
either happen or not happen depending on implementation (MSW/generic)
and mode (single/multi). From now on the DESELECTED event is always sent.
2020-05-28 10:51:58 +03:00
Lauri Nurmi
9d9b0c51c8 A test button to the listctrl sample 2020-05-28 10:51:58 +03:00
Vadim Zeitlin
27495c5484 Merge branch 'textctrl-getsizefromtextsize'
Improve wxTextCtrl and wxSpinCtrl sizing under macOS.

See https://github.com/wxWidgets/wxWidgets/pull/1861
2020-05-28 02:21:35 +02:00