Commit Graph

68613 Commits

Author SHA1 Message Date
Vadim Zeitlin
585ed986a2 Make wxGridCellChoiceEditor big enough in both directions
Previously, we ensured that the combobox was tall enough, but not that
it was wide enough, which could result in truncation of its contents if
the cell rectangle was too small.

Fix this by increasing the size in both directions, if necessary.

Also make the code simpler by using higher-level wxSize and wxRect
methods instead of fiddling with the coordinates directly.
2020-06-13 17:29:20 +02:00
Vadim Zeitlin
d2a403408f Implement wxGridCellNumberRenderer::GetMaxBestSize()
This allows to make computing the best width of numeric columns an O(1)
operation instead of O(number-of-rows), which can make a huge difference
for big grids.
2020-06-13 16:37:21 +02:00
Vadim Zeitlin
96de24d1bb Add wxGridCellChoiceRenderer to optimize column size calculation
Previously columns using a set of predetermined values used plain
wxGridCellStringRenderer, which didn't allow to determine their best
size efficiently, as wxGrid had to iterate over all the rows of the
table, even if they only took a couple of possible values.

Add wxGridCellChoiceRenderer (refactoring wxGridCellEnumRenderer to
extract the common code from it in the process) which implements
GetMaxBestSize() by just finding the best size of all of these values,
which is much faster for large grids.

This does result in a change in behaviour, as the column now adapts to
its "theoretical" best size and not just the size of the values actually
shown in it, but this seems to be a worthwhile trade-off and could even
be seen as an advantage, as editing a cell won't make its value overflow
the auto-sized column width any more, as it is wide enough to show any
of the column values.
2020-06-13 16:10:14 +02:00
Vadim Zeitlin
71d42a8290 Add wxGridCellRenderer::GetMaxBestSize()
This is another optimization, useful for the renderers that are used
with the values of a fixed form or part of a limited set, as it is much
faster to compute the best size for all values of the set rather than
computing them for all the cells in the column.
2020-06-13 15:51:20 +02:00
Vadim Zeitlin
a1a5c8c1ae Merge branch 'toolbar-bottom'
Fix handling of toolbars using both wxTB_HORIZONTAL and wxTB_BOTTOM (or
both wxTB_VERTICAL and wxTB_RIGHT) styles.

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

Closes #18769.
2020-06-13 14:59:00 +02:00
PB
13b15fecc0 Simplify code dealing with toolbar position in associated frame 2020-06-13 14:57:30 +02:00
Richard Reznicek
83ca3c4ef2 Fix flickering when resizing MDI parent frame in wxMSW
The wxMDIParentFrame::Create() function simply called
wxApp::GetRegisteredClassName(wxT("wxMDIFrame")) without providing
apropriate flags parameter depending on the presence/absence of the
wxFULL_REPAINT_ON_RESIZE flag in style. Thus, the MDI parent frame was
always created using the window class with the CS_HREDRAW | CS_VREDRAW
style flags set. Choosing the appropriate value for the flags parameter
of the wxApp::GetRegisteredClassName() function (like in the
wxWindowMSW::GetMSWClassName() function) fixes the flicker issue. The
wxApp::GetRegisteredClassName() call in wxMDIChildFrame::Create()
is adapted as well just for the sake of consistency.

See #18213.

Closes https://github.com/wxWidgets/wxWidgets/pull/1892
2020-06-13 13:42:25 +02:00
Vadim Zeitlin
b0f7ecbd0d Fix the initial wxTextCtrl size in wxGTK
We need to explicitly call SetInitialSize() after setting the value of
the control (if it's not empty), as the first call, done from inside of
PostCreation(), doesn't take the initial control contents into account
and so doesn't allocate the height correctly for multiline text controls
containing more than 2 lines of text, for example.

Closes https://github.com/wxWidgets/wxWidgets/pull/1891
2020-06-12 16:11:15 +02:00
Artur Wieczorek
dc92f2e9dc Add compilation guards for macOS 10.14 to avoid warnings
NSColor.linkColor is not available since macOS 10.10 as
it is stated in the Appkit documentation but since 10.14 -
see http://codeworkshop.net/objc-diff/sdkdiffs/macos/10.14/AppKit.html
2020-06-11 15:47:39 +02:00
Artur Wieczorek
32bb2edac7 Mark overriding functions with wxOVERRIDE 2020-06-11 15:47:35 +02:00
Artur Wieczorek
7c3d540c70 Validate input in generic wxSpinCtrl and wxSpinCtrlDouble
Use respective validator to control what is typed in the text field.

Closes #17882.
2020-06-11 15:47:12 +02:00
Vadim Zeitlin
249db04dd3 Add wxGridTableBase::CanMeasureColUsingSameAttr()
This allows to optimize AutoSizeColumns() in the common case when all
cells in the same column can be measured using the same attribute.
2020-06-11 10:03:13 +02:00
Vadim Zeitlin
70768a33d2 Dramatically speed up measuring text extent in wxMSW
Skip correction for the under/overhang for non-italic fonts: it seems to
be pretty small for them and avoiding the calls to ::GetCharABCWidths()
makes GetTextExtent() 7-8 times faster, which seems to be a worthwhile
compensation.

If we decide to restore these calls in the future, we will need to
implement some kind of cache for them, as they're just too slow
otherwise.
2020-06-10 23:46:13 +02:00
Vadim Zeitlin
bfeae1922d Minor optimizations in GetMultiLineTextExtent()
Handle the case of a single line string specially, it's faster to do
this than use slow loop over all characters.

Also avoid constructing the string with the characters to measure one by
one and do it all at once instead.

Add a possibility to benchmark GetMultiLineTextExtent() rather than
GetTextExtent() in the graphics benchmark.
2020-06-10 23:41:24 +02:00
Vadim Zeitlin
09ecfaec8f Reuse wxDC::GetMultiLineTextExtent() in wxGridCellStringRenderer
There is no need to reimplement the same logic in wxGrid code when we
already have a perfectly cromulent way to do it in wxDC itself (which
hadn't existed when this code was originally written, explaining why it
wasn't used here before).

This makes the code shorter and also a bit faster, as we avoid using
wxStringTokenizer unnecessarily.

No changes in behaviour.
2020-06-10 22:57:17 +02:00
Vadim Zeitlin
0ca6be3cf4 Link samples using STC with imm32.lib
This completes the changes of f730da3c14 (Add imm32.lib to
wxStyledTextCtrl, 2020-05-10) that didn't take care of MSW makefiles,
that need to contain the new required library as well.

Closes #18788.
2020-06-10 19:30:48 +02:00
Vadim Zeitlin
5e06174c95 Merge branch 'cotaskmemptr' of https://github.com/PBfordev/wxWidgets
Add wxCoTaskMemPtr and use it instead of manual calls to
::CoTaskMemFree().

See https://github.com/wxWidgets/wxWidgets/pull/1890
2020-06-10 18:02:50 +02:00
PB
88965fc588 Fix whitespace 2020-06-10 17:17:48 +02:00
Vadim Zeitlin
968e94c36d Merge branch 'mac-textctrl-size-refactor'
Don't call GetBestSize() from DoGetSizeFromTextSize() in wxOSX.

See https://github.com/wxWidgets/wxWidgets/pull/1888
2020-06-10 15:48:57 +02:00
Vadim Zeitlin
13477ee164 Merge branch 'xrc-generic-animation-ctrl'
Extend wxAnimationCtrl XRC handler to cover wxGenericAnimationCtrl too.

Also fix a bug with wxGenericAnimationCtrl inactive bitmap background.

See https://github.com/wxWidgets/wxWidgets/pull/1889
2020-06-10 00:02:59 +02:00
Vadim Zeitlin
9e2434d013 Document wxGenericAnimationCtrl XRC handler and it to XRC schema
It's actually the same handler as for wxAnimationCtrl, but it still
needs to be mentioned in the XRC format description and recognized by
its schema.
2020-06-10 00:02:34 +02:00
Maarten Bent
1ed8197dfa CMake: prevent mismatched package name warnings
Use all caps for the packages.

Closes https://github.com/wxWidgets/wxWidgets/pull/1886
2020-06-09 23:57:53 +02:00
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