C++20 introduces these two functions, along with some overloads, to
std::string. Add similar functions to wxString, which simply call the
already existing StartsWith() and EndsWith().
Closes https://github.com/wxWidgets/wxWidgets/pull/1452
13068d3603 introduced code for stripping
CJK mnemonics (i.e. trailing " (&X)") from the menu items, but due to
the use of wxStripMenuCodes() in wxControl::GetLabelText(), it also
applied to the control labels, resulting in wrongly measuring their size
(because the text used for measurement didn't include the "(&X)" part)
and truncating them in display.
Fix this by adding an explicit wxStrip_CJKMnemonics and using it only in
the code dealing with the menu item labels. This requires more changes
than just modifying GetLabelText() to use some wxStrip_NoCJKMnemonics
flag, but is more compatible as it's not impossible that some existing
code using wxStripMenuCodes() could be broken by this change too, while
now the existing behaviour is preserved.
Also improve wxStrip_XXX documentation.
Closes https://github.com/wxWidgets/wxWidgets/pull/1439
See #16736.
Closes#18452.
In wxGTK using negative coordinates with HitTest() happens to work and
it's useful to test that it does, as this test will run when the control
is scrolled even under Travis CI, unlike the test with positive
coordinates which doesn't work under Xvfb there and was disabled in the
previous commit.
Also document that passing negative coordinates to this function only
works in wxGTK.
For some reason, wxTextCtrl scrolls much too far when running under
Xvfb, so the test assumption that it still has some visible characters
after calling SetInsertionPointEnd() fails and must be disabled in this
environment.
For some reason, the height of a text line is 15px there and not 18px as
locally, so 400px high image still fit on the second page in the last
test. Make it higher to ensure that it doesn't.
Set the "printer" PPI explicitly for wxMemoryDC used in the test to
ensure that it's the same in all ports: currently wxGTK3 stands out
because it uses 72 DPI unlike wxMSW and wxGTK2, which use 96.
For some reason, the control does lose focus there, even if it doesn't
happen when using a normal X11 server.
Just disable the test in this environment.
This will allow disabling some tests which fail when running only under
Xvfb.
The new function doesn't work automatically because there doesn't seem
to be any way to distinguish it from the usual server, so it just checks
whether wxUSE_XVFB=1 is set in the environment, as is done by Travis CI
build script.
We need to wait until wxDataViewCtrl is realized for its columns widths
to be actually set, as calling gtk_tree_view_column_set_fixed_width()
just queues a resize that will take effect later, as documented in the
previous commit.
This not only cuts down on its size, but will make it simpler to skip
this test in the environments where web access is unavailable in the
upcoming commit.
Verify that pressing Enter in a dialog activates its default button when
a text-like (i.e. wxTextCtrl or wxComboBox) has focus either if it
doesn't have wxTE_PROCESS_ENTER style or if it does, but its handler
skips the event, but not if the style is used and the event is handled.
This ctor just created unusable wxTimerEvent objects (all of the methods
specific to this class would just crash if called on them) and doesn't
seem to be useful at all.
It was added in e47859daeb apparently only
in order to allow using wxIMPLEMENT_DYNAMIC_CLASS() instead of the
previously used wxIMPLEMENT_ABSTRACT_CLASS() for wxTimerEvent, but there
doesn't seem to be any reason to prefer macro over another, and there
are good reasons to not allow creating objects in an invalid state.
The only place where we relied on having default ctor for this event was
in wxEvent::Clone() unit test, so update it to handle wxTimerEvent
specially now that this ctor doesn't exist any longer.
When processing mnemonics, the resulting string should still contain
them and they need to be stripped before measuring its width, but the
code didn't do it.
This didn't prevent the tests from passing, but only due to another bug
in ellipsization code itself, which lost the mnemonics completely. As
this bug is about to be fixed, the test needs to take mnemonics into
account properly now.
This resulted in wrong letter being underlined in wxGenericStaticText
when the mnemonic occurred after "&&" (i.e. an actual ampersand) in the
label.
Add unit test which passes now, but would fail before on the last check.
Also remove the macros used in the test to perform the same tests for
wxStaticText and wxCheckBox and use a helper function instead, making
the code more clear and extensible.
No real changes.
This shouldn't be done unconditionally, trace mask can always be enabled
using WXTRACE environment variable from outside the test.
Also remove a useless tracing message.
The solution with specializing std::iter_swap() for wxString::iterator
was not conforming as the iterator was still not swappable, as it is
required to be.
Fix this by providing std::swap() overload for wxString::iterator, which
is correct and even simpler.
This allows std::reverse(s.begin(), s.end()) work with clang too and
incidentally avoids warnings about the code relying on non-conforming
extensions with MSVS 2017 which were due to the fact that iter_swap()
workaround wasn't enabled for it, while the new swap() overload is.
These functions were never used anywhere and their meaning was not
clear, so just drop them.
Also remove the now unused "tested" member and "WAIT_DURATION" constant.
Use CallAfter() to perform idle-time initialization, this is shorter and
simpler than dealing with the idle events explicitly.
Unfortunately the remaining use of idle events can't be avoided, explain
the reasons for this in a comment.
Just bind the idle events we want to execute dynamically instead.
This is already more clear and robust than the old version, but will be
simplified event further in the next commit.
This reverts commit a05ae051d8 and allows
to correctly decode UTF-8 output of child processes again.
Also add a (disabled by default) test allowing to verify that this does
work now.
Closes#14720, #18382.
Don't assert in wxBoxSizer when both alignment flags and wxEXPAND are
used together if wxSHAPED is also used, as such flag combinations may
make sense and so shouldn't be forbidden.
Add a unit test checking that this is allowed.
Resetting the insertion point position to 0 after calling
wxTextCtrl::SetValue() or ChangeValue() which didn't really change the
control contents was unexpected, as such calls are supposed to be
"optimized away", and this was indeed the case under wxMSW and wxOSX,
but not in wxGTK.
So change wxGTK to follow the other ports, add a unit test checking for
this behaviour and officially document it.
As a side effect, this ensures that the numeric validator classes don't
reset the insertion point position to 0 on every focus loss under wxGTK,
as happened before.
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.
In wxMSW, a focused wxRadioButton is always checked, which meant that
checking a wxRadioButton while focus was not in the window containing it
and later giving the focus to that window could uncheck it by giving
focus to another wxRadioButton that had had it previously.
Fix this by adding WXSetPendingFocus() to wxMSW wxWindow and calling it
from wxRadioButton::SetValue() to ensure that when the focus is
regained, it goes to the newly checked radio button and not some other
one.
This replaces the previously used, for the same purpose, wxMSW-specific
wxTopLevelWindow::SetLastFocus(), so while this solution is not exactly
pretty, it's not worse than we had before, while being more generic.
Also add a unit test checking that things work correctly in the scenario
described above.
Closes https://github.com/wxWidgets/wxWidgets/pull/1257Closes#18341.
Add a unit test for a special case of a wrap sizer min size caclulation.
Test wxWrapSizer::CalcMinFromMinor function for this case, when a wrap
sizer used inside a sizer with the same alignment.
Don't recognize the "path" following the port number without a slash as
a path, this is invalid according to the RFC.
Also require two leading slashes for URIs without the authority part.
This allows the subsequent tests to still run even if one of the tests
fails, which is more useful in this test than CPPUNIT_ASSERT_EQUAL(),
which maps to REQUIRE() and so stops the test execution as soon as any
check fails, because the tests are independent.
Don't let wxNotebook created in the recently added test for the events
generated when adding pages to it continue to live after the test end as
this breaks the subsequent tests using wxUIActionSimulator (but only
when using MinGW, for some reason).
There were many dozens of such warnings given for the various arrays
used in the tests and it just doesn't seem feasible nor desirable to fix
them all, so just suppress the warnings for all these arrays to get rid
of them with recent (7+?) versions of gcc.
Harmonize events sent by wxNotebook::AddPage(): they are now sent only
when adding any page except the first one if it is selected in all
ports.
See https://github.com/wxWidgets/wxWidgets/pull/1192
No real changes, just clean up sources by removing trailing spaces from
all the non-generated files.
This should hopefully avoid future commits mixing significant changes
with insignificant whitespace ones.
After the addition of EventCounter::WaitEvent() call in the previous
commit these checks pass as well (with another WaitEvent() added to wait
for deactivation event as well).
We already had WX_ASSERT_EVENT_OCCURS_IN macro and a recent commit also
added code doing almost the same thing manually in wxTopLevelWindow unit
test, which was one version too many.
Replace both of them with the new EventCounter::WaitEvent().
No real changes, this is just a refactoring.
Send wxEVT_SHOW explicitly when showing a maximized TLW under MSW as the
system doesn't send WM_SHOW in this case (as documented in the MSDN and
also confirmed by testing).
Closes https://github.com/wxWidgets/wxWidgets/pull/1153
Implement point/pixel size accessors correctly.
Implement support for strike-through fonts.
Also implement DoSetNativeFontInfo() for wxQt.
Make wxFont unit test pass by accounting for Qt-specific aspects.
Closes https://github.com/wxWidgets/wxWidgets/pull/1113
Account for the minimum and maximum dates supported by QDatePicker, both
in the code and in the test suite, which shouldn't rely on not having
any range restrictions in wxQt.
Closes https://github.com/wxWidgets/wxWidgets/pull/1088
Introduce wxQtEdit class and wxQtMultiLineEdit and wxQtSingleLineEdit
derived classes instead of using ifs in many wxTextCtrl methods, making
the code more clear and maintainable.
Also fix some wxTextCtrl-related unit test failures with wxQt and
disable some other ones which still don't pass.
Closes https://github.com/wxWidgets/wxWidgets/pull/1039
Compute the best size of the notebook, taking into account all the
different layout possibilities, and add a test checking that this works
as expected.
Closes https://github.com/wxWidgets/wxWidgets/pull/1085
Add test checking that selection is reset when deleting the selected
item or any item before, but not after, it.
Also explicitly document this behaviour.
This makes it possible to run the tests for all controls implementing
wxItemContainer interface by just passing "[item-container]" on the test
command line.
This method used to return a dangling pointer to a temporary buffer,
which resulted in a crash when using it, e.g. in the unit test.
Fix this by keeping a QImage as a member in wxBitmapRefData, so that the
pointer to its data remain valid until UngetRawData() is called.
Also check that GetRawData() returns a non-null pointer in the test.
Closes https://github.com/wxWidgets/wxWidgets/pull/1067
Fix the test added in dfec7aa0c0 which
deleted the button pointer used by EventCounter by simply moving
EventCounter initialization after the button re-creation.
See #16385.
Disabling a window before actually creating it ought to work, similarly
to hiding a window before creating it which can be used to avoid showing
the window on screen at all, even briefly. However it didn't under MSW
where the window was disabled from wxWidgets point of view, but not at
the MSW level.
Fix this by accounting for the enabled state in MSWGetStyle().
Closes#16385.
In wxMSW, the value of the control was modified after executing the
user-defined wxEVT_SPINCTRL handler which meant that any calls to
SetValue() there were effectively ignored.
Fix this and add a unit test checking for the described scenario.
Closes https://github.com/wxWidgets/wxWidgets/pull/1027Closes#18187.
RandomAccessIterator requirements include LessThanComparable, so
implement the missing comparison operators for this class, as well as
for const_reverse_iterator.
This also fixes compilation problems with MSVS 2013 in debug mode, where
the CRT uses these operators to check the iterators correctness.
See https://github.com/wxWidgets/wxWidgets/pull/1048
There is no need to allocate neither RowRanges nor HeightCache on the
heap, just create them on the stack -- if nothing else, this ensures we
don't leak memory, unlike before.
private field 'm_dwCookie' is not used
'return' will never be executed
result of comparison of unsigned enum expression < 0 is always false
'FlushDC' overrides a member function but is not marked 'override'
potentially uninitialized local variable 'bound' used
Make wxDataViewCtrl::GetIremRect() work under all platforms and improve
tests, documentation and fix a couple of other problems in the same code
area.
See https://github.com/wxWidgets/wxWidgets/pull/1015
For some unfathomable reason IsExpanded() returns wrong value for one of
the items. This should be fixed, but for now just leave a warning in the
test but don't fail it.
Also document this bug to at least spare people some surprises.
A couple of fixes compared to the previous commit:
- Use the correct gtk_tree_view_get_cell_area() rather than
gtk_tree_view_get_background_area() which doesn't work correctly
for the items which are not shown because their parent is collapsed.
- Translate logical coordinates to physical ones using
gtk_tree_view_convert_bin_window_to_widget_coords().
With these fixes, the unit tests for this function pass and can now be
enabled under wxGTK as well.
See https://github.com/wxWidgets/wxWidgets/pull/990
This will allow reusing it in other tests too.
Also make the output slightly more readable by formatting the rectangle
as "{x,y w*h}" instead of "{x,y,w,h}".
No real changes.
No real changes, just avoid mentioning CPPUNIT_ASSERT_EQUAL() in the
comments for the operator<<() overloads as it is used with CATCH too.
Also don't duplicate the same comment 4 times unnecessarily.
This was already the case if the item was not visible because its parent
was not expanded, but now make it also true for the items which are not
visible due to the current scrollbar position.
Add unit tests checking for this and also verifying that GetItemRect()
returns the coordinates in the physical window coordinates.
Replace a redundant (because the same size was already specified in the
ctor) SetSize() call with a Layout() call which resizes
wxDataViewMainWindow to fit the parent control size when using the
generic implementation.
This is important for any tests dealing with the control geometry, i.e.
calling GetItemRect() or HitTest().
Calling GetItemRect() for an item which was not currently visible
because its parent was collapsed resulted in silently returning the
value for a wrong value before the recent fix to GetRowByItem() and in
a crash after it because GetTreeNodeByRow() returned null when passed
invalid row index.
Fix this by explicitly checking whether the item is shown and just
returning an empty rectangle instead.
Also document this behaviour and add a unit test for it.
ChangeValue() must not send events, but did in wxGTK when changing the
contents of a wxTextCtrl to be empty when it had been non-empty before.
Closes#18264.
Comment stated that InsertionPoint() didn't pass, but it was actually
already running (and passing) and the only excluded test was the
TextChangeEvents() one which really should pass for multiline controls
as well, so run it too.
This benchmark shows that wxGetDisplaySize() has only minimal overhead
compared to wxDisplaySize(), but wxDisplay().GetGeometry() is almost 3
times slower (under wxGTK).
wxTreebook is supposed to allow not specifying any valid window for the
top-level pages, but this didn't work any longer, probably since the
changes of 02a92e23f3 (see #4379), as a
possibly null page was dereferenced without checking, resulting in a
crash.
Fix this by adding a missing check.
Also rename DoGetNonNullPage() to TryGetNonNullPage() to make it more
clear that this function can return null and add a unit test checking
that calling AddPage(NULL) really works (or at least doesn't crash).
See https://github.com/wxWidgets/wxWidgets/pull/921
Complete support for fractional point sizes and font weights other than
light/bold.
Also harmonize wxFont API and implementation among all ports (fixing
compilation of those of them that were broken by recent changes).
See https://github.com/wxWidgets/wxWidgets/pull/919
This is a preliminary ARM64 platform support for wxWidgets at "it
compiles" stage. This will allow building and testing wxWidgets based
apps for oncoming Windows 10 ARM64.
Requirements:
- Visual Studio 2017 Update 4 or later with Visual C++ compilers and
libraries for ARM64 component installed
Building:
1. Open command prompt.
2. Change directory to build\msw subfolder.
3. Run "C:\Program Files (x86)\Microsoft Visual
Studio\2017\Community\VC\Auxiliary\Build\vcvarsamd64_arm64.bat" once.
4. Use `nmake TARGET_CPU=ARM64 ...` to build required flavor of wxWidget
libraries.
Notes:
1. Building of *.sln/*.vcxproj files does not support ARM64 yet. This
requires to hardcode Windows SDK to 10.0.15063.0 or later in
*.vcxproj files, which would render them non-compilable in older
Visual Studio versions. Microsoft is aware of this issue and is
planning a fix in the next version of Visual Studio.
2. wxmsw31ud_gl.dll does not build yet. Awaiting Microsoft to deliver
missing opengl32.lib for ARM64. Please, specify USE_OPENGL=0.
Closes https://github.com/wxWidgets/wxWidgets/pull/923
Check that calling SetFractionalPointSize() and SetNumericWeight() at
the very least results in the expected return values from
GetFractionalPointSize() and GetNumericWeight().
Add wxFontBase::AccountForCompatValues() and use it in all ports instead
of redoing the same comparison with wxDEFAULT in all of them.
This is done not so much to avoid the code duplication, which was
minimal anyhow, but to make the code more clear and make it easier to
remove it from all ports at once in the bright (but remote) future when
we don't need these compatibility hacks any more.
Also document that wxDEFAULT and wxNORMAL are only handled specially in
the old-style ctor taking the individual font components and not the new
one using wxFontInfo and extend the unit test to check this.
Similarly to the previous commit, verify that wxNORMAL, wxITALIC and
wxSLANT still work for compatibility (note the latter is synonymous with
wxITALIC under MSW).
This basically removes the "adv" library, even though it's still
preserved for compatibility with user make/project files referring to
it.
It is done because the distinction between "adv" and "core" was never
really clear (e.g. why wxTreeCtrl was in core but wxTreeListCtrl in
adv?) and it prevented some core classes from using adv ones.
This previously worked in wxGTK, but not in wxMSW and even under wxGTK
it could be surprising that the submenu got the event, but its parent
menu did not.
Make things consistent between the platforms and send the event to the
menu directly containing it first, but then also to its parent menu(s).
Document the new behaviour and verify that it works as intended with a
new unit test.
Closes#18202.
This seems to be the case under all still supported MSW versions, so
remove the note saying that the events might not be sent from the
documentation and add a unit test verifying that they are indeed sent.
Contrary to what the documentation stated previously, this function does
generate the wxEVT_TREE_DELETE_ITEM events for all the items being
deleted, in both MSW and generic implementations.
Update the documentation and add a new unit test checking that the
behaviour really conforms to it.
While this doesn't make, and never made, any sense (pointers should be
stored in a plain, non-object array), we still should continue to
support it for compatibility.
Fix the problem introduced by 97684a9267
by writing "T const&" instead of "const T&" as the latter didn't have
the same meaning when the macro parameter "T" expanded into "U*" as
"const" applied to "U", making this type incompatible with the actual
one.
Also extend the unit test to check for this.