Commit Graph

40482 Commits

Author SHA1 Message Date
Artur Wieczorek
4b7ca0b33d Add assertions to check if generic wxImageList is valid
This is for compatibility with native wxMSW implementation.
2021-04-04 21:06:18 +02:00
Artur Wieczorek
032c443c42 Report failure while creating generic wxImageList with invalid image size
Native wxMSW implementation reports failure if dimensions <= 0.
2021-04-04 21:05:06 +02:00
Artur Wieczorek
51ff4ec08b Dont allow to remove from wxImageList an images with index out of range
Since ImageList_Remove() accepts -1 index as a magic number to remove all
images, we need to explicitly prevent using indices < 0 in the call.
Because wxImageList::RemoveAll() uses the trick with -1 index
to call wxImageList::Remove(-1) we also need to refactor this mehod and
call ImageList_Remove() API directly instead.
2021-04-04 21:01:43 +02:00
Artur Wieczorek
882f0a4631 Don't return a valid image from wxImageList if its index is out of range 2021-04-04 21:00:05 +02:00
Artur Wieczorek
d6443e65ee Don't store negative dimensions for images in wxImageList 2021-04-04 20:59:00 +02:00
Vadim Zeitlin
802c81fff7 Merge branch 'mac-search-menu-check'
Fix check items state in wxSearchCtrl menu under macOS.

See https://github.com/wxWidgets/wxWidgets/pull/2304
2021-04-04 17:04:18 +02:00
Vadim Zeitlin
0a5be41f8a Avoid using uninitialized static wxString in wxOSX code
Global "sCR" and "sLF" string objects could have been not yet
initialized when wxMacConvertNewlines{13To10,10To13}() were called as
these functions can be (implicitly) used when initializing other static
objects.

Fix the problem by avoiding the use of these objects, as well of
wxString::Replace(), entirely and just iterating over the string
directly using a simple, and more efficient, for loop.

Note the use of "auto&&": a more usual "auto&" can't be used with
temporary wxUniCharRef created by dereferencing wxString iterators.
Using just "auto" would have actually worked too, but modifying a value
via a copy would seem surprising, so use "auto&&" as a hopefully
slightly more clear alternative.

Closes #19110.
2021-04-04 15:06:06 +02:00
Vadim Zeitlin
9c1c4817db Remove unused senderWindow argument of wxMenu::HandleCommandXXX()
This parameter isn't used anywhere, so just remove it to simplify the
code.
2021-04-04 14:29:34 +02:00
Vadim Zeitlin
0f1d1d2ae9 Update wxSearchCtrl popup menu state after showing it
Fix the state of the check/radio items in the menu by updating the
template used by macOS to create the actual menu after showing it and
possibly changing the items state.

This is not ideal because changing the state from the program, e.g.
using wxMenuItem::Check(), still doesn't work correctly, i.e. isn't
reflected in the menu when it's shown, but better than nothing until a
better solution (which ideally would update the menu just before showing
it, but it's not clear how exactly can we do it, knowing that we don't
get wxEVT_MENU_OPEN for this menu neither) can be found.
2021-04-04 14:21:27 +02:00
Vadim Zeitlin
5f482e15ab Merge branch 'osx-set-color-without-font'
Set colour without changing font in wxOSX.

See https://github.com/wxWidgets/wxWidgets/pull/2278
2021-04-04 14:19:39 +02:00
Vadim Zeitlin
9f1dc5ffff Merge branch 'macos_webview_clipboard' of https://github.com/TcT2k/wxWidgets
Improve/Fix web view clipboard handling under macOS.

See https://github.com/wxWidgets/wxWidgets/pull/2294
2021-04-03 23:23:52 +02:00
Vadim Zeitlin
d85d22c067 Merge branch 'msw-datepick-size'
Fix wxDatePickerCtrl best size in wxMSW when using wxDP_ALLOWNONE.

See https://github.com/wxWidgets/wxWidgets/pull/2297
2021-04-03 22:17:52 +01:00
Vadim Zeitlin
0af8d6b95a Fix size of 0-width pen for wxPrinterDC in wxGTK
Don't apply scale to the fixed line width used for 0-width pens.

Closes #17056.
2021-04-03 23:17:39 +02:00
Stefan Csomor
41bf57fee3 guard against SDK < 10.12 2021-04-03 22:40:08 +02:00
Paul Cornett
334cf1cc91 Take HiDPI scale into account for wxGCDC 0-width pen
See #19077, #19115
2021-04-03 13:03:56 -07:00
Stefan Csomor
5628a4a334 adding Big Sur update fix
see #19111
(include linking against QuartzCore which contains the kCAContentsFormatRGBA8Uint reference)
2021-04-03 21:12:54 +02:00
Artur Wieczorek
ba588fd072 Take into account scale actor while resizing the image in generic wxImageList
Too small image needs to be resized to the required physical size first
and next converted to wxBitmap with actual scale factor.
2021-04-03 18:56:29 +02:00
Artur Wieczorek
b6d305e4f2 Assure that all images in the generic wxImageList have the same scale factor
Mixing images with various scale factors could be misleading and error
prone.
2021-04-03 18:54:32 +02:00
Daniel Kulp
eb52e86553 Take into account scale factor of images added to wxImageList
Closes #19114.
2021-04-03 18:54:32 +02:00
Stefan Csomor
767de514c1 fixing update area being to big
see #19111
2021-04-03 18:30:57 +02:00
Vadim Zeitlin
a244059934 Avoid using DTM_GETIDEALSIZE with DTS_SHOWNONE
This message is completely broken when DTS_SHOWNONE is used, it returns
wrong result (less than the size without DTS_SHOWNONE) initially and
completely wrong results after a DPI change.

Create a temporary date time picker control without DTS_SHOWNONE and
call DTM_GETIDEALSIZE for it instead. This is wasteful, but at least
returns correct results.

This commit is best viewed ignoring whitespace-only changes.
2021-03-28 03:22:17 +02:00
Vadim Zeitlin
aa50c6d829 Further improve best size of wxDatePickerCtrl with wxDP_ALLOWNONE
Compute the best size more precisely to be exactly compatible with the
control appearance when not using wxDP_ALLOWNONE. This unfortunately
requires hardcoding an arbitrary constant in DoGetBestSize().

Patch used for testing this code for future reference:

diff --git a/samples/minimal/minimal.cpp b/samples/minimal/minimal.cpp
index 470e765423..a1d5fb9938 100644
--- a/samples/minimal/minimal.cpp
+++ b/samples/minimal/minimal.cpp
@@ -26,6 +26,8 @@
     #include "wx/wx.h"
 #endif

+#include "wx/datectrl.h"
+
 // ----------------------------------------------------------------------------
 // resources
 // ----------------------------------------------------------------------------
@@ -175,6 +177,28 @@ bool MyApp::OnInit()
     CreateStatusBar(2);
     SetStatusText("Welcome to wxWidgets!");
 #endif // wxUSE_STATUSBAR
+
+    auto sz = new wxBoxSizer(wxVERTICAL);
+    auto addDPC = [this, sz](int style)
+    {
+        sz->Add(new wxDatePickerCtrl(this, wxID_ANY, wxDefaultDateTime,
+                                     wxDefaultPosition, wxDefaultSize, style),
+                wxSizerFlags().Right());
+    };
+
+    addDPC(wxDP_DROPDOWN | wxDP_ALLOWNONE | wxDP_SHOWCENTURY);
+    addDPC(wxDP_DROPDOWN | wxDP_SHOWCENTURY);
+    addDPC(wxDP_DROPDOWN | wxDP_ALLOWNONE);
+    addDPC(wxDP_DROPDOWN);
+
+    sz->AddSpacer(10);
+
+    addDPC(wxDP_SPIN | wxDP_ALLOWNONE | wxDP_SHOWCENTURY);
+    addDPC(wxDP_SPIN | wxDP_SHOWCENTURY);
+    addDPC(wxDP_SPIN | wxDP_ALLOWNONE);
+    addDPC(wxDP_SPIN);
+
+    SetSizerAndFit(sz);
 }
2021-03-27 21:55:13 +01:00
Vadim Zeitlin
8ceca69064 Always handle wxDP_ALLOWNONE ourselves in best size computation
DTM_GETIDEALSIZE doesn't seem to account for it, so we need to do it
ourselves even when using it.

Closes #19120.
2021-03-27 21:52:04 +01:00
Tobias Taschner
e63fd03611 macOS: Improve wxWebView::Paste()
The default (javascript) implementation presents the user with a popup
menu containing a single 'Paste' menu item.
Send this action to directly paste as expected.
2021-03-26 10:28:48 +01:00
Tobias Taschner
b4de7358b5 macOS: Implement keyboard shortcuts in webview
Enable usage of standard editing keys Cmd+A/C/V/X
2021-03-26 10:11:37 +01:00
Vadim Zeitlin
4f6cf6da5b Don't call GetTextExtent() if we don't use its result
It's unnecessary to call GetTextExtent() just to discard/overwrite its
result immediately with the value returned from DTM_GETIDEALSIZE, so
don't do it.

This reverts another part of a98d8448fa (Fix size of
wxDateTimePickerCtrl after DPI change, 2019-01-13) which wasn't done in
7de85d7470 (Restore correct best width of wxDatePickerCtrl in MSW,
2020-05-24).included

This commit is best viewed ignoring whitespace-only changes.
2021-03-25 14:49:54 +01:00
Vadim Zeitlin
67e9829b55 Remove unneeded wxClientDC wxDateTimePickerCtrl::DoGetBestSize()
Just call GetTextExtent() on the window itself, it does the same thing
anyhow.

No real changes, just a tiny simplification.
2021-03-25 14:46:37 +01:00
Vadim Zeitlin
776c3e5b73 Don't make wxConfig::Do{Read,Write}LongLong() pure virtual
These functions, added in the recent fce8780297 (Add 64-bit integers
support to wxConfig, 2021-03-09) break compilation of existing code
defining classes inheriting from wxConfig, and we can avoid it by using
strings for storing long long values by default -- as this is what
wxFileConfig is doing, and wxRegConfig provides its own overridden
version anyhow.
2021-03-25 14:06:12 +01:00
Vadim Zeitlin
85b944d164 Merge branch 'webrequest-keep-alive'
Ensure that wxWebRequest objects stay alive as long as the request is in
progress.

See https://github.com/wxWidgets/wxWidgets/pull/2292
2021-03-25 14:04:24 +01:00
Vadim Zeitlin
0959cdb4e0 Check for memory allocation failure in all wxImage::ResampleXXX()
This was previously done in ResampleNearest() but not in all the other
variants, so add the checks there too to avoid crashing when trying to
use too big image sizes.

Closes #19119.
2021-03-25 14:03:06 +01:00
Paul Cornett
024d1543f1 Fix conditional-uninitialized warning in a different way
Rather than dummy initializations, reorganize the code so
there is no way the variables can appear to be uninitialized
2021-03-24 11:35:38 -07:00
Paul Cornett
0995797158 Remove run-time dependencies on X11 backend with GTK3
As with Wayland, the X11 backend may not be available at run-time,
so types defined in it can't be used
2021-03-24 11:25:01 -07:00
Vadim Zeitlin
afc3aa773a Don't try scaling wxHtmlImageCell if it has 0 size
This just results in assertion failures from wxImage and nothing useful.
2021-03-24 19:14:47 +01:00
Vadim Zeitlin
43d359f96d Merge branch 'xrc-load-url'
Fix loading XRC from URLs.

See https://github.com/wxWidgets/wxWidgets/pull/2288
2021-03-24 18:24:12 +01:00
Vadim Zeitlin
360268ee25 Extend life time of wxWebRequest while it is in process
We already did it just before processing the state change event, but
this was too late, as the object could have been already deleted by then
and this actually happened with the example from wxWebRequest
documentation.

Do it earlier now, as soon as the request becomes active, which normally
happens when Start() is called, and keep the reference until the event
is processed after the request reaches one of the final states
(completed, failed or cancelled).

Add a unit test checking that deleting the wxWebRequest object doesn't
prevent the request from running to the completion any more.
2021-03-24 17:45:01 +01:00
Vadim Zeitlin
d7235ebb05 Show states using names, not ordinals, in trace message
This is much more readable.
2021-03-24 17:45:01 +01:00
Vadim Zeitlin
c0f8c0e0f2 Be stricter about changing to the same state in wxWebRequest
This shouldn't happen, and doesn't, but if it ever does we'd better
return immediately rather than doing something that will almost surely
be wrong.
2021-03-24 16:04:02 +01:00
Vadim Zeitlin
dd23d7dcd2 Merge branch 'safe-show-message'
Show message box from wxSafeShowMessage() in the other ports too, if
possible.

Currently this is done using wxMessageBox() if it can be sure that it's
safe to call and only MSW uses native function which is always safe to
call. Ideal would be to also use a native function under Mac, where it
should also be the case, but this doesn't seem to work for whichever
reason.

See https://github.com/wxWidgets/wxWidgets/pull/2270
2021-03-23 18:59:51 +01:00
Vadim Zeitlin
e442d90b0d Merge branch 'webrequest-build-fixes' of https://github.com/MaartenBent/wxWidgets
wxWebRequest-related build fixes for MinGW.

See https://github.com/wxWidgets/wxWidgets/pull/2283
2021-03-23 14:16:07 +01:00
Vadim Zeitlin
9e96ff972b Fix wxXmlResource::Load() with HTTP URLs
Make the code in this function work even with wxFileSystemHandlers that
don't implement FindFirst() at all: we can, and should, still try
loading the passed in path with them, rather than not doing anything at
all.

This makes Load() works with HTTP URLs again, as it apparently used to
do a long time ago, but didn't do any more.

Add a unit test, even if only a semi-manual one, to try to help with
this not getting broken again (ideal would be to launch our own HTTP
server inside the test, but this is a bit more complicated).

Closes #19109.
2021-03-23 13:43:20 +01:00
Maarten Bent
1f36582d87 Initialize wxWinHTTP when wxWebSessionFactoryWinHTTP is created 2021-03-23 00:42:46 +01:00
Maarten Bent
953b71196b Fix extra semi warning in wxWebSessionCURL implementation 2021-03-23 00:42:06 +01:00
Maarten Bent
c4343ed2d4 Load winhttp functions dynamically
winhttp cannot be added to the makefiles, because some MinGW distributions
(MinGW 5.3) do not have this library.
2021-03-23 00:42:02 +01:00
Paul Cornett
91bb265e90 Fix build with wxNO_RTTI
wxWidgets RTTI can be used instead
2021-03-21 12:16:12 -07:00
Paul Cornett
ef5076f852 Fix build with wxUSE_PALETTE==0 2021-03-21 12:16:01 -07:00
Artur Wieczorek
dc11bb18cf Use new CoreGraphics API to reset clipping region
Since 10.13 there is available a dedicated CGContextResetClip()
API to reset a clipping region so we don't need to use current
workaround anymore.
2021-03-21 18:44:06 +01:00
Stefan Csomor
d1c0d3b18c keeping the OSX specific use of origin for non-native borders
fixes #19108
2021-03-20 22:09:31 +01:00
Vadim Zeitlin
362012ab9c Merge branch 'cmake_warnings' of https://github.com/TcT2k/wxWidgets
Enable more warnings for GCC/Clang with CMake.

See https://github.com/wxWidgets/wxWidgets/pull/2281
2021-03-19 22:41:01 +01:00
Vadim Zeitlin
5d6525ccf1 Merge branch 'webview_useragent' of https://github.com/TcT2k/wxWidgets
Add support for custom user agent to wxWebView.

See https://github.com/wxWidgets/wxWidgets/pull/2280
2021-03-19 22:39:00 +01:00
Pierluigi Passaro
b824ed8fe6 Support Wayland in wxGTK wxMediaCtrl
For GTK, the current implementation assumes X11 is the only window option.
Introduce runtime checks to manage Wayland too.

Signed-off-by: Pierluigi Passaro <pierluigi.p@variscite.com>

Closes https://github.com/wxWidgets/wxWidgets/pull/2257
2021-03-19 22:36:59 +01:00