Commit graph

74760 commits

Author SHA1 Message Date
Vadim Zeitlin
5b9b817aaa Simplify showing colour values in failing unit tests
Use wxColour::GetAsString() instead of reimplementing it in the test.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
02eb3a26b6 Fix using colours, fonts etc in CATCH assert messages
Include the header declaring the stream insertion operators for these
types before including catch.hpp itself as otherwise they may not be
seen when these classes are used and Catch::StringMaker is instantiated
using the "unstreamable" alternative for them.

It would probably be better to specialize Catch::StringMaker for these
types directly instead of relying on stream insertion operators, but
this would require more changes and in the meanwhile this improves the
display of failing checks.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
d1fedc1415 Get rid of CppUnit boilerplate in wxHyperlinkCtrl unit test
No real changes, just avoid using compatibility macros in this test.
2023-05-15 21:39:13 +01:00
Vadim Zeitlin
0b3d8a3d8b Implement wxGenericHyperlinkCtrl::GetDefaultAttributes()
Return the correct foreground colour from this function for hyper links,
it's different from the default text colour for the links.

This makes it easy to reuse this colour for the link-like elements in
the application code.
2023-05-12 03:58:55 +01:00
Vadim Zeitlin
475477a45f Extract link colour into a reusable helper function
No changes, just a refactoring.
2023-05-12 03:58:14 +01:00
Vadim Zeitlin
7894b56a47 Tweak default wxGenericHyperlinkCtrl colour slightly
Use #0000ee from HTML5 spec instead of #0000ff used previously.
2023-05-12 03:57:50 +01:00
Blake-Madden
c27b711379 Explain how to specify download paths when using wxWebRequest
Add an overview paragraph explaining how to use wxWebRequest's and
wxWebEvent's IDs together to specify a request's download path before
starting it. The sample shows how to interactively prompt for local
paths once a file downloads, but not how to download a file to a
specific location without user prompting, so document how to do it.

See #22986.

Closes #23504.
2023-05-11 22:48:30 +01:00
Vadim Zeitlin
35c328e221 Fix wxStatusBar::GetBackgroundColour() in dark mode under MSW
Get the colour actually used by the theme part we use for the status bar
in the dark mode, which is quite different from the default background
colour (0x333333 vs 0x202020).

This is notably important for the controls that live inside status bar
panes, as they must use the correct background colour to blend in.
2023-05-11 22:45:26 +01:00
Maarten Bent
70c2ddeba3 Add support for wxBG_STYLE_TRANSPARENT to wxMSW
Allow using transparent background style under Windows by mapping it to
WS_EX_TRANSPARENT.

Closes #23412, #23498.
2023-05-11 22:42:13 +01:00
Vadim Zeitlin
f3a4767455 Fix wxMSW wxWindow::GetTextExtent() with given font in high DPI
This function returned wrong results when using a non-default font in
non-standard DPI because it didn't adjust the font to use the window
DPI, as needs to be done manually in wxMSW before using it.

Fix this now and do the same thing here as we already did in
wxWindow::SetFont() (via WXAdjustFontToOwnPPI()) or in wxDC::SetFont().
2023-05-11 18:46:10 +01:00
Vadim Zeitlin
5f5e5c27dd Merge branch 'keep-on-same-display'
Keep window on the same display when its client size is changed.

See #23533.
2023-05-10 22:45:02 +01:00
Vadim Zeitlin
a0e3f1e1ab Use grep instead of fgrep and egrep
The latter are deprecated and shouldn't be used any longer.

No real changes.

Closes #23537.
2023-05-10 23:44:17 +02:00
Vadim Zeitlin
54a8a6ac16 Fix wxTreeCtrl::ScrollTo() with hidden root item in wxMSW
Scroll to the topmost item, as the generic version does, instead of
crashing.

Closes #23534.
2023-05-10 19:08:00 +01:00
Vadim Zeitlin
62b6e1d0f9 Use wxRect::MakeCenteredIn() in DoSetClientSize()
No real changes, just make the code more clear by adding the new helper
function.
2023-05-10 00:13:35 +01:00
Vadim Zeitlin
5fd6be2f64 Add wxRect::MakeCenteredIn() modifying the rectangle in place
This can be more convenient than calling CenterIn().
2023-05-10 00:09:41 +01:00
Vadim Zeitlin
1a22adb80d Get rid of CppUnit boilerplate in wxRect unit test
No real changes, just clean up the test.
2023-05-10 00:02:58 +01:00
Vadim Zeitlin
540d2c2d39 Improve generic implementation of wxDisplay::GetFromRect()
Account for the special case of partly visible rectangle whose center is
off screen, as in this case GetFromRect() would still be expected to
return a valid display and not wxNOT_FOUND.

Also mention this case in the documentation.
2023-05-09 21:59:46 +01:00
Vadim Zeitlin
bdb78121a2 Provide native implementation of GetFromRect() for wxMSW
Use the Win32 API function directly doing what we need.
2023-05-09 21:59:46 +01:00
Vadim Zeitlin
d9831dc7ba Reuse GetFromRect() for non-wxMSW GetFromWindow() implementation
Use the new function here instead of duplicating what it does in
non-wxMSW ports using MSW API.
2023-05-09 21:59:46 +01:00
Vadim Zeitlin
072d581e87 Keep window on the same display in SetClientSize()
It was unexpected that changing the window client size could change the
display the window was on and, even worse, result in further size
changes because changing the display could change the DPI scaling used.
And, worst of all, if the window wxEVT_DPI_CHANGED handler called
SetClientSize(), possibly indirectly such as via wxSizer::Fit(), this
could result in an infinite recursion when moving the window to a high
definition display located to the left of the standard definition one
(the problem didn't happen for the reciprocal display arrangement
because increasing the window size couldn't change the window display
in that case).

So ensure that the window remains on the same display it is on now, by
keeping its center position unchanged, instead of keeping the position
of its top left corner as we did before.
2023-05-09 21:59:46 +01:00
Vadim Zeitlin
438da9c99a Avoid mis-detecting NULL as part of other identifiers
Tighten the search for NULL in the code style check to avoid flagging
the use of MONITOR_DEFAULTTONULL (Win32 API constant) as violation.
2023-05-08 23:40:51 +01:00
Vadim Zeitlin
0da3f1c11f Add wxDisplay::GetFromRect()
For now this is just the same thing as GetFromPoint(center-of-rectangle)
but it's already more convenient to use and it will also be changed in
the upcoming commits.
2023-05-08 22:47:04 +01:00
Vadim Zeitlin
d39aac0fa8 Merge branch 'aui-tbar-items'
Fix regression in code using pointers to wxAuiToolBar elements.

See #23529.
2023-05-08 15:15:02 +01:00
Vadim Zeitlin
4d48e47811 Fix regression in destroying wxArtProvider objects
Don't delete the art provider object in Remove() as this contradicted
its contract and do restore the call to Remove() from wxArtProvider dtor
as it's actually documented to work.

This fixes a regression due to the changes of 4a294caacd (Stop using
macro-based wxList in wxArtProvider code, 2023-04-11).

Closes #23513.

Closes #23529.
2023-05-08 15:13:35 +01:00
Vadim Zeitlin
50dcf06bff Revert to using wxBaseObjectArray for wxAuiToolBarItemArray
This partially undoes the changes of bc23b1f4f0 (Use wxBaseArray instead
of object array for wxAuiToolBarItemArray, 2023-04-11) as they broke the
existing code using wxAuiToolBar because the pointers to the tools were
not stable any more.

At least avoid the use of the ugly -WX_DECLARE_USER_EXPORTED_OBJARRAY()
macro by just using wxBaseObjectArray<> directly, which is simpler now,
after the change in the parent commit.

Add a trivial test checking that pointers to wxAuiToolBar tools remain
stable when more tools are added.

Closes #23514.
2023-05-07 00:52:07 +01:00
Ivan Sorokin
8a01942f1a Add WXK_NUMPAD_CENTER to refer to numpad "5" in portable code
This key produces events with different key codes in wxMSW (WXK_CLEAR)
and the other ports (WXK_NUMPAD_BEGIN), so add a new constant to allow
to refer to it under the same name everywhere.

Also generate a key event for it in wxOSX where it previously wasn't
generated at all.

Closes #23478.

Closes #23491.
2023-05-06 21:57:47 +01:00
Vadim Zeitlin
91ded239e9 Allow using wxBaseObjectArray without defining traits
This makes it possible to use this class with the complete classes
without using any macros.
2023-05-06 19:59:44 +01:00
Vadim Zeitlin
4df2c878f4 Add wxSTC project to the GUI tests MSVS solution
The tests depend on wxSTC library, so add the project to ensure that it
is (re)built when building them.
2023-05-06 19:43:00 +01:00
Vadim Zeitlin
130e6693e1 Merge branch 'xrc-load'
Improve error reporting in wxXmlResource::Load().

See #23524.
2023-05-05 15:22:10 +02:00
Vadim Zeitlin
2358323d37 Merge branch 'ftp-list'
Fix wxFTP::GetFilesList() and other uses of wxProtocol::ReadLine().

See #23521.
2023-05-05 15:21:11 +02:00
Lauri Nurmi
9f94f4069c Support wxDP_DROPDOWN mode for native date pickers on macOS
According to Apple's documentation, the presentsCalendarOverlay property
is supported in macOS 10.15.4 and later.

Closes #23520.
2023-05-05 15:19:49 +02:00
Vadim Zeitlin
b5313bacca Improve check in wxFindNextFile()
Show the expected assert about calling wxFindNextFile() without
(successfully) calling wxFindFirstFile() first instead of not triggering
this assert if the last call to wxFindFirstFile() failed but a preceding
one had succeeded and triggering another, less clear, assert in wxDir
instead, complaining about using a not-opened directory.

Do this by only setting gs_dir to a valid value if wxFindFirstFile()
succeeded and resetting it to empty pointer if it didn't.
2023-05-05 01:12:11 +01:00
Vadim Zeitlin
81d96e875f Don't assert when loading XML resources from inexistent directory
Calling wxXmlResource::Load() with a file using an inexistent path
resulted in an assert in wxFindNextFile() because it was called when the
preceding call to wxFindFirstFile() failed.

Avoid this by simply not calling it in this case.
2023-05-05 01:07:31 +01:00
Vadim Zeitlin
685044b03f Avoid using macros in wxXmlResource::Load()
No real changes, just use lambdas instead of macros.
2023-05-05 00:54:42 +01:00
Vadim Zeitlin
821c2a07fe Fix editing cells without values in wxGTK wxDataViewCtrl
Do not hide cells without values at GTK level, as this makes them not
only appear as blank (which is fine), but also prevents them from being
edited, which is not, as the user should be able to enter values into
the previously empty cells.

This fixes regression introduced back in 74e1c444fa (Don't show bogus
value when there are none in wxGTK wxDVC neither, 2021-12-01).

Note that this also undoes the changes of 8aefedcb45 (Remove duplicated
HasValue() call from wxGTK wxDataViewCtrl code, 2022-05-08) and
HasValue() is called twice again now, but this is less of a problem than
wrong behaviour fixed by this commit and we can address it later, e.g.
by passing the cell value to PrepareForItem() instead of retrieving it
inside it, if it turns out to be really worth it.

Closes #23523.
2023-05-04 22:11:01 +02:00
Vadim Zeitlin
c1a27f3beb Fix wxProtocolError::ReadLine() if the socket was closed
Don't hang forever in this case but just return an error immediately.

This notably fixes hanging in wxFTP::GetFilesList() as the socket it
used for retrieving the list of files was always closed by the server
after sending the full list, but we kept trying reading from it.

Closes #23519.
2023-05-04 17:06:34 +01:00
Vadim Zeitlin
a2e3dd563e Check that we retrieve the same numbers of files in wxFTP test
GetFilesList() and GetDirList() should return the same number of lines,
normally, so check for this.
2023-05-04 17:06:02 +01:00
Vadim Zeitlin
5e3c2fb1c6 Don't use raw pointers in wxFTP unit test
Use std::unique_ptr<> and vector<> instead.
2023-05-04 16:38:29 +01:00
Vadim Zeitlin
649c64bab1 Replace CPPUNIT_ASSERT with CATCH macros in wxFTP unit test
No real changes, just stop using legacy macros.
2023-05-04 16:36:28 +01:00
Vadim Zeitlin
26d342cb05 Merge branch 'msw-dpi-handling-fixes'
Fixes to make processing wxEVT_DPI_CHANGED work better.

See #23510.
2023-05-02 18:01:06 +01:00
Kvaz1r
79fa753641 Fix showing hint in wxUniv wxTextCtrl
Correctly remove the hint when the text control is focused.

Closes #23511.
2023-05-02 18:58:36 +02:00
Vadim Zeitlin
0329dfecd8 Update wxSlider thumb before processing wxEVT_DPI_CHANGED
This changes of 4713301cf5 (Fix font and thumb size of wxSlider after
DPI change, 2019-08-27) fixed updating the slider thumb length on DPI
change, but this happened too late because it was done after executing
the user-defined handler for this event which could have updated the
slider size, which led to a call to its overridden DoMoveWindow() which
would use the old thumb length, resulting in the size remaining too big
when switching from higher to lower DPI and, worse, too small (and not
showing the thumb entirely) when switching in the other direction.

Fix this by updating the thumb length earlier, by using the just added
MSWBeforeDPIChangedEvent() for doing it instead of doing it in the event
handler.
2023-05-01 17:23:09 +01:00
Vadim Zeitlin
0f19c0a074 Pass wxDPIChangedEvent to the just added MSWBeforeDPIChangedEvent()
This is unusual, but this function may need to rescale some coordinates
and it's convenient to just call event.Scale() then.

So pass it the event that we are preparing to process to it instead of
passing it new and old DPI separately and forcing it to deal with them
itself (instead of using Scale()).
2023-05-01 17:21:03 +01:00
Vadim Zeitlin
7cee6d59c3 Fix updating wxFrame client size in wxEVT_DPI_CHANGED handler
This didn't work correctly when switching from higher to lower DPI if
the frame had a status bar because this status bar still had its old,
bigger height, by the time SetClientSize() was called from the event
handler, resulting in the frame size becoming too big.

It notably resulted in having an unwanted gap between the frame contents
and the status bar if the event handler called GetSizer()->Fit().

Fix this by calling PositionStatusBar(), which also updates the status
bar height to correspond to the new DPI as a side effect, from a new
virtual MSWBeforeDPIChangedEvent() function which had to be added to
allow wxFrame to customize DPI handling.

Adding this new virtual function just for this isn't great, but the only
alternatives seem even worse.
2023-05-01 17:21:03 +01:00
Vadim Zeitlin
b2bb68dc36 Add wxDPIChangedEvent::Scale() overloads for wxPoint and wxRect
Allow scaling positions, in addition to the sizes, and, also, entire
rectangles.
2023-05-01 17:21:03 +01:00
Vadim Zeitlin
1093bb492b Merge branch 'msw-statusbar-improv'
Minor MSW wxStatusBar cleanup.

See #23509.
2023-04-30 17:42:45 +02:00
Vadim Zeitlin
d27dff8c3a Merge branch 'msw-bmpbndl-enh'
Some minor QoL improvements to using bitmaps bundles in wxMSW.

See #23503.
2023-04-30 17:42:13 +02:00
Vadim Zeitlin
1b26a85534 Update comment in .git-blame-ignore-revs after renaming it
Just fix a misleading comment using the wrong (old) file name.

This should have been done in cacfcb1e61 (Allow ignoring revisions when
viewing blame on GitHub, 2022-03-24).
2023-04-30 15:35:02 +02:00
Vadim Zeitlin
2acf999f39 Merge branch 'xrc-getposition-win'
Add windowToUse argument to wxXRC GetPosition() too.

See #23507.
2023-04-30 01:18:01 +02:00
PB
c5dc85f398 Remove mentions of no longer supported MSVS versions
The oldest supported MSVS version for wxWidgets 3.3 is 2015,
so remove mentions of limitations of older MSVS versions.

Closes #23508.
2023-04-30 01:17:28 +02:00