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.
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.
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.
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.
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
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
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.
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.
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.
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.
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
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
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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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