Commit Graph

4386 Commits

Author SHA1 Message Date
Gerhard Gruber
1533026945 Allow better control over splitter position on resize
Add an event which can be handled by the application to determine the
splitter position when the splitter window itself is resized.

This can be used to e.g. preserve the splitter at the given proportion
of the window (and not just in the middle, as it would be already
possible by using gravity 0.5).

Closes #22035.
2022-01-27 14:00:51 +01:00
Vadim Zeitlin
4073f3b9bf Use wxBitmapBundle in wxDataViewCtrl-related classes
Extend the existing use of wxIcon in wxDataViewIconText,
wxDataViewCheckIconText, the corresponding renderers and
wxDataViewTreeCtrl to wxBitmapBundle.

As with the other classes, the existing setters have been preserved as
they remain almost entirely compatible with the existing code and the
return type of the existing getters was preserved, with new getters
being introduced for returning wxBitmapBundle only where they're really
required.

Update the sample to use wxBitmapBundle with its wxDataViewTreeCtrl.
2022-01-23 21:55:30 +01:00
Vadim Zeitlin
3cc4ef5f77 Merge branch 'art-wx-logo'
Add wx logo art ID and use SVG to provide it in any size.

See #22046.
2022-01-23 17:29:22 +01:00
Vadim Zeitlin
22a3b4a8af Merge branch 'msw-icon-scale-factor'
Make scale factor-related functions available in wxIcon in wxMSW too.

See #22045.
2022-01-23 17:27:28 +01:00
Vadim Zeitlin
4cc3c5ee87 Merge branch 'bitmap-bundle-icon'
Add functions for wxIcon interoperability to wxBitmapBundle too.

See #22044.
2022-01-23 17:26:27 +01:00
Vadim Zeitlin
fc2b7e5266 Add wxBitmapBundle::GetIconFor()
This is to GetBitmapFor() as GetIcon() is to GetBitmap().
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
84b5e4639e Add wxBitmapBundle::IsSameAs()
This is useful if only for compatibility with wxBitmap or wxIcon, that
have the same member function with the same semantics.
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
fe2aba3b99 Add wxBitmapBundle::GetIcon()
This is just a convenient wrapper for GetBitmap() that will be useful in
the classes using wxIcon in their public API to preserve compatibility
after switching to using wxBitmapBundle instead of wxIcon internally.
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
99445aa64c Document wxBitmapBundle::GetBitmap(wxDefaultSize) behaviour
The size parameter is explicitly allowed to be wxDefaultSize here,
meaning to return the bitmap in the default bundle size.
2022-01-23 16:04:50 +01:00
Vadim Zeitlin
2208f53ba3 Add wxART_WX_LOGO and use it in the webview sample
Embed SVG data of the wx logo into the library itself to make it
available to all wx programs, including the samples. This is a bit
wasteful, but <12KiB is not really noticeable compared to the library
size.
2022-01-23 15:40:04 +01:00
Vadim Zeitlin
b4946c2fe3 Move scale factor-related functions to wxGDIImage from wxBitmap
This makes them available in wxIcon (and, less importantly, wxCursor)
too which is needed in order to use icons correctly in high DPI.

This is also more consistent with the other platforms, where wxIcon does
have these methods.

Document these methods in wxIcon now that they're available there under
all platforms and also document wxIcon::GetSize() which had been
available even before, but wasn't documented.
2022-01-23 01:59:59 +01:00
Vadim Zeitlin
94716fd801 Add wxBitmap::CreateWithLogicalSize()
The new function has a more clear name than CreateScaled() it replaces
and uses a more useful parameter order, with the scale factor, which
must always be specified when using it, coming before, and not after,
the depth, which almost never needs to be specified and so can be left
at its default value in 99% of cases.
2022-01-22 22:44:00 +00:00
Vadim Zeitlin
dad828da38 Use rounding in both wxWindow::FromPhys() and ToPhys()
It seems better to round, rather than truncate, in ToPhys(), for the
same reasons as in wxBitmap::CreateScaled() (see parent commit), and
then ceil() mustn't be used in FromPhys() neither, as this would break
round-tripping via both functions.

So, finally, keep the behaviour simple and, hopefully, the least
surprising, by just rounding the result in both functions.
2022-01-22 21:40:36 +00:00
Vadim Zeitlin
65bb454311 Add wxBitmap::GetLogical{Width,Height,Size}()
These functions have better names than the existing GetScaledXXX() ones,
so add them to be able to use them in the new code, even if we still
keep the old ones for compatibility.
2022-01-22 18:56:21 +00:00
Tobias Taschner
1ae0037330 Add wxGetNativeCpuArchitectureName()
This allows to retrieve the native CPU architecture name regardless of
the current process CPU architecture.

Common examples for CPU architecture differences are the following:
    - Win32 process in x64 Windows (WoW)
    - Win32 or x64 process on ARM64 Windows (WoW64)
    - x86_64 process on ARM64 macOS (Rosetta 2)

Closes #22036.
2022-01-22 19:32:56 +01:00
Vadim Zeitlin
68e2684d2b Merge branch 'phys-pixels-convert'
Add function for converting between logical and physical pixels too.

See #22013.
2022-01-16 23:39:50 +01:00
Vadim Zeitlin
7e3059dee0 Merge branch 'dvc-multi-format-dnd'
Accept multiple data formats via drag-and-drop in wxDataViewCtrl.

See #2478, #2616.
2022-01-15 23:39:03 +01:00
Vadim Zeitlin
d429eea605 Document that wxTreeEvent::GetItem() is not always valid
Contrary to what the documentation stated, it was possible for the item
to be invalid, so update it to explain this and give an example of a
case in which this happens.

See #19182.
2022-01-14 22:26:27 +00:00
Vadim Zeitlin
421416696f Add wxWindow::FromPhys() and ToPhys() functions
Provide these functions for consistency with the existing FromDIP() and
ToDIP().

We also can use ceil() (rather than round() used by wxSize operators) in
FromPhys() to ensure that we never truncate contents of a physical
bitmap, which allows to replace the existing wxStaticBitmap code with
just a call to this function.
2022-01-13 19:51:58 +01:00
Vadim Zeitlin
1f401475f3 Merge branch 'art-scalefactor'
Fix confusion between different kinds of coordinates in wxAUI code,
restoring correct behaviour in high DPI on all platforms.

See #2620.

Closes #19331.
2022-01-13 17:51:00 +00:00
Vadim Zeitlin
7c7ff3cd42 Add wxBitmap::GetDIPSize() and use it in wxBitmapBundleImplArt
This fixes the problem with wrong standard bitmaps size when using high
DPI for the main monitor with wxMSW, as GetScaledSize() used here since
31f2892200 (Avoid bitmap scaling in wxArtProvider::GetBitmapBundle(),
2021-12-17) was not the right function to use there.

Closes #19331.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
03cf1f4359 Remove wxHAS_BITMAP_SCALE_FACTOR
Now wxMSW also stores the scale factor, even if it doesn't use it in its
GetScaledXXX(), so it doesn't seem useful to have this symbol for
distinguishing the platforms with and without bitmap scale factor
support, when we can just use wxHAS_DPI_INDEPENDENT_PIXELS instead in
the only place where this was used.

And as this symbol was added quite recently, in 2c1f4c002d (Add
wxBitmap::SetScaleFactor(), 2021-10-23), we can hopefully just remove it
without breaking any existing code, if we do it right now.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
f6fbc97c7b Only return really scaled bitmap size under platforms using DIPs
wxBitmap::GetScaledXXX() functions are useful for obtaining the
coordinates in logical pixels, so they should only divide by the scaling
factor on the platforms where logical pixels are actually different from
the physical ones, i.e. those using DPI-independent pixels.

This ensures that their behaviour under MSW remains unchanged even after
a1e4dca067 (Store scale factor in wxMSW bitmaps too, 2021-12-16), which
is the correct way to avoid breaking wxAUI (and other) drawing.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
2945278334 Rename wxHAVE_DPI_INDEPENDENT_PIXELS to wxHAS_XXX and document it
Using wxHAS_ prefix is more consistent with all the other similar
symbols, using wxHAVE_ was a mistake, that we have to pay for by
preserving the old name now (as it is actually already used in some code
outside of the library).

The fact that it's used also shows that it's better to document this
symbol, even if just to explain that it normally shouldn't be used, as
we can't really hide it anyhow.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
10977b0eb6 Don't make wxBitmap::GetScaledXXX() virtual
There should be never any need to override them, their behaviour is
fixed.

No real changes.
2022-01-13 17:34:49 +00:00
Vadim Zeitlin
f78db92462 Avoid bitmap scaling in wxArtProvider::GetBitmapBundle()
Instead of immediately constructing the bitmap with the requested size,
possibly by downscaling a higher-resolution bitmap, and then potentially
having to upscale it if we actually need a bitmap of a bigger size, just
retrieve the bitmap in the actually needed size from wxArtProvider when
needed.

This makes bitmaps obtained from wxArtProvider::GetBitmapBundle() look
good, rather than fuzzy and ugly, in high DPI if they're actually
available in the appropriate size.
2022-01-13 17:34:49 +00:00
Serghei Amelian
16d096b7ef Add wxWebRequestEvent::GetRequest()
It is more convenient to be able to retrieve the request object (which
is needed at least for authentication) from the event than to have to
store it separately.

Closes https://github.com/wxWidgets/wxWidgets/pull/2644

Closes #19360.
2022-01-11 18:16:09 +01:00
Vadim Zeitlin
916df1a1d1 Fix recurring typo in validator parameter description
It can be used for "data checks", not "date checks" (the latter might
work for wxDatePickerCtrl, but use "data" for it too for consistency).
2022-01-11 18:08:25 +01:00
Paul Cornett
ef779835b4 Document when GetItemParent() was added 2022-01-07 22:00:00 -08:00
Paul Cornett
3cd791de21 Add GetItemParent() to wxDataViewTreeCtrl
Makes it a little easier to convert from using wxTreeCtrl to wxDataViewTreeCtrl
2022-01-07 14:48:36 -08:00
Vadim Zeitlin
27d5306bdd Make wxToolBar::SetToolBitmapSize() work again
It didn't do anything since wxBitmapBundle-related changes, as could be
seen by toggling the bitmap size in the toolbar sample -- the bitmaps
size didn't actually change.

Make it work again by only using the best bitmap size if it's greater
than the currently set bitmap size, but not shrinking the bitmaps to it
if it's smaller. This doesn't seem especially useful, but this is how
the code behaved with single bitmaps before and there doesn't seem to be
any good reason to change this.

At least document that calling SetToolBitmapSize() is unnecessary and
normally shouldn't be done.
2022-01-07 00:13:52 +01:00
Vadim Zeitlin
af641ba7b8 Merge branch 'skip-dpichange-events'
Fix wxGenericColourButton after recent bitmap changes and, more
generally, always skip wxDPIChangedEvent and document that this should
be done.

See https://github.com/wxWidgets/wxWidgets/pull/2637
2022-01-06 23:46:35 +01:00
Vadim Zeitlin
f5e0076f04 Advise to skip wxDPIChangedEvent when handling them in the manual
Not skipping them is almost invariably a bug, as shown by the
grandparent commit.
2022-01-06 23:45:28 +01:00
Vadim Zeitlin
c864c9119b Document wxIMPLEMENT_{APP,WXWIN_MAIN}_CONSOLE macros too
Even though they're less useful than their non-CONSOLE counterparts,
they still should be documented.

Closes #19358.
2022-01-04 22:51:06 +01:00
Vadim Zeitlin
3bc0f44163 Update copyright years to 2021
Just run misc/scripts/inc_year and commit the results.

Closes #18690.
2022-01-02 13:32:23 +01:00
Vadim Zeitlin
ffe73b4353 Merge branch 'fs-mem-string-data'
Use UTF-8 for memory FS data if it's not in Latin-1.

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

See #19314.
2022-01-02 12:46:05 +01:00
Scott Talbert
44997466fb Undocument SetClippingRegion overload in wxSVGFileDC
Documentation of the other overloads was removed in 6a442d2 and there is
nothing special about the wxCoord variant in wxSVGFileDC, so remove it so
all the overloads are consistently documented in just wxDC.

Closes https://github.com/wxWidgets/wxWidgets/pull/2627
2022-01-02 12:30:53 +01:00
Paul Cornett
aacada0ea2 wxEVT_DATAVIEW_ITEM_CONTEXT_MENU position should be in client coordinates
For consistency with wxTreeCtrl and wxListCtrl. See #19188
2021-12-22 17:12:45 -08:00
Vadim Zeitlin
f84c3a7968 Fall back to using UTF-8 in wxMemoryFSHandler::AddFile()
This seems to be better than just losing the data completely if
converting it to Latin-1 fails.
2021-12-16 21:54:43 +01:00
Vadim Zeitlin
673593f911 Document that wxString passed to AddFile() must use Latin-1
Otherwise To8BitData() would return an empty buffer for it.
2021-12-16 21:48:49 +01:00
Vadim Zeitlin
3c7b40e999 Merge branch 'clang-13-no-depr-copy'
Fix clang 13 -Wdeprecated-copy warnings and ensure that we test for them
in the allheaders test.

See https://github.com/wxWidgets/wxWidgets/pull/2619
2021-12-16 21:13:55 +01:00
Vadim Zeitlin
6f8bc1018b Avoid -Wdeprecated-copy for many event classes from clang 13
Add new macros wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN_DEF_COPY() and
wxDECLARE_NO_ASSIGN_DEF_COPY() and use them instead of
wxDECLARE_DYNAMIC_CLASS_NO_ASSIGN() and wxDECLARE_NO_ASSIGN_CLASS()
respectively to ensure that we declare a (default, if possible) copy
ctor in the classes declaring an assignment operator to avoid clang
warnings about not doing it.
2021-12-15 17:50:55 +01:00
Vadim Zeitlin
0a8f7233cc Merge branch 'virtual-list-sort-indicator'
Simplify recently added wxListCtrl sort indicators support and allow
using it with virtual list controls too.

See https://github.com/wxWidgets/wxWidgets/pull/2618
2021-12-14 19:28:20 +00:00
Vadim Zeitlin
e3ec9fb124 Fix using wxMemoryDC without a GUI wxApp instance
This used to work, at least in wxMSW, but stopped working after the
(perfectly valid, on their own) changes of 2508efdd6e (Initialize
wxMemoryDC with a default font, 2019-08-13), as this resulted in calling
wxApp::GetTopWindow() that can only be called from the GUI code.

Fix this by adding wxApp::GetGUIInstance() and using it in
GetMainTopWindow(), so that we only call GetTopWindow() if we actually
have a GUI wxApp object on which to call it.

Implement this in terms of a new virtual IsGUI() which seems slightly
better than, although roughly equivalent to, using wxDynamicCast().

Closes https://github.com/wxWidgets/wxWidgets/pull/2617

Closes #19343.
2021-12-14 19:28:02 +00:00
Vadim Zeitlin
c834c0b8b7 Add GetUpdatedAscendingSortIndicator() helper function
It seems like this function will need to be used in every implementation
of EVT_LIST_COL_CLICK handler when using sorting, so it makes sense to
provide it in the library itself.
2021-12-14 14:22:08 +00:00
Vadim Zeitlin
0a8e82b010 Rename formal parameter of ShowSortIndicator() to "col"
No real changes, just use a more appropriate parameter name, as it's a
column index and not just "index".
2021-12-14 14:19:10 +00:00
Vadim Zeitlin
52649cc566 Remove wxListCtrl::EnableSortIndicator()
The old API seems unnecessarily complex, it is simpler to just let the
application call ShowSortIndicator() itself from its
wxEVT_LIST_COL_CLICK handler, which needs to be defined anyhow in order
to actually sort the items, rather than require it to enable sort
indicator, explicitly set it initially and then remember to not set it
any longer in response to the column clicks.

Also make RemoveSortIndicator() non-virtual and implement it simply as
ShowSortIndicator(-1) because this actually simplifies the code too.
2021-12-14 14:09:23 +00:00
Vadim Zeitlin
30ce892ed5 Let wxListCtrl::ShowSortIndicator() implicitly enable indicators
It doesn't seem right for ShowSortIndicator() to silently do nothing if
EnableSortIndicator() hadn't been called before, so make it enable the
sort indicators if they hadn't been enabled yet.

The alternative would be to assert in this function, but this seems less
useful.

Also add some comments to wxMSW version.
2021-12-13 14:31:49 +00:00
Vadim Zeitlin
58290168e5 Remove top level "const" from {Enable,Show}SortIndicator()
Don't use "const int" or "const bool" for parameter types, the "const"
here is ignored and using it is inconsistent with all the rest of the
library.

No real changes.
2021-12-13 14:18:18 +00:00
Vadim Zeitlin
cd555f9ff5 Use vector instead of array of wxDataFormats
Also rename EnableDropTarget() to EnableDropTargets(), as calling
EnableDropTarget(wxDF_XXX) would be ambiguous due to the existence of a
non-explicit wxVector ctor taking size_t (which is a mistake on its own,
but is probably not worth changing any more).
2021-12-10 19:57:41 +01:00