Commit Graph

19763 Commits

Author SHA1 Message Date
Vadim Zeitlin
37dbf9f03a Merge branch 'threadname' of https://github.com/lanurmi/wxWidgets
Add wxThread::SetName for naming threads for debugging purposes.

See https://github.com/wxWidgets/wxWidgets/pull/2572
2021-11-12 17:05:12 +01:00
Vadim Zeitlin
b4ba5ae0b6 Use icons set with SetImages() in Mac wxNotebook implementation
Use GetBitmapBundle(), via a helper GetPageBitmapBundle() function which
is going to be useful elsewhere too, rather than GetImageList(), as the
latter only works if the images were set using SetImageList(), while the
new version does the right thing both in this case and when the images
were set using SetImages().
2021-11-12 14:11:59 +01:00
Vadim Zeitlin
127389b1c7 Update images in wxMSW wxListCtrl on DPI change
Just reuse wxWithImages::GetUpdatedImageList() to update all the image
lists used by the control.
2021-11-11 21:48:31 +00:00
Vadim Zeitlin
aca0c74e60 Add wxListCtrl::Set{Normal,Small}Images()
These new functions allow to use wxBitmapBundle for the images in this
control instead of wxImageList.

Update the sample to use the new API.
2021-11-11 01:20:35 +00:00
Vadim Zeitlin
9ea8feec37 Make GetUpdatedImageListFor() work when using old API too
Return the image list set via {Set,Assign}ImageList() if SetImages()
hadn't been called to make this function return the correct image list
in any case, both when using the old wxImageList API and the new one
using wxBitmapBundle.

This commit is best viewed ignoring whitespace-only changes.
2021-11-11 01:20:35 +00:00
Vadim Zeitlin
907f6da047 Make wxWithImages::GetUpdatedImageListFor() public
It should be possible to call this function on wxWithImages objects
contained in derived classes too.

This commit is best viewed with --color-moved git option.
2021-11-11 00:52:12 +00:00
Vadim Zeitlin
8a3d886135 Replace wxImageLists in wxListCtrlBase with wxWithImages
Still no real changes, but this makes the code simpler and more robust
and prepares the way for adding wxListCtrl methods taking vectors of
bitmap bundles.
2021-11-11 00:52:12 +00:00
Vadim Zeitlin
638d865632 Add more useful wxWithImages::GetUpdatedImageListFor()
This replaces the previously added UpdateImageListIfNecessary() as we
almost always needed the image list after calling that function anyhow,
so it makes more sense to return the image list from it -- which also
required renaming it.

No real changes.
2021-11-11 00:52:12 +00:00
Vadim Zeitlin
5941dea234 Move wxImageList-related code to wxListCtrlBase
Put the code common to all wxListCtrl implementations in the common base
class instead of duplicating it in wxMSW, wxQt and generic versions.

No real changes yet, this is a pure refactoring which prepares for the
upcoming changes.
2021-11-11 00:52:12 +00:00
Vadim Zeitlin
f1da96db27 Add helper wxWithImages::GetBitmapBundle()
This function can be used in the ports that don't require wxImageList
(i.e. anything but wxMSW) to use wxBitmapBundle if it's available,
rather than passing by wxImageList.
2021-11-07 23:39:59 +01:00
Vadim Zeitlin
ced845f006 Update wxTreeCtrl and its sample to work with wxBitmapBundle
Override OnImagesChanged() to call UpdateImageListIfNecessary() even in
wxGenericTreeCtrl for now, although in the future it would really make
sense to stop using wxImageList in its implementation and just use
wxBitmapBundle directly instead.

wxMSW is the only one which really needs an image list, as it's required
by the native control.

Also update the sample, even though it doesn't look very nice because
its icons are only available in a single size, so we have to always
scale them.
2021-11-07 21:46:42 +00:00
Vadim Zeitlin
c777a34d78 Move wxBookCtrlBase::WXHandleDPIChanged() to wxWithImages itself
This function is not really wxBookCtrl-specific and can be used with
other classes as well, so allow reusing it in them.

No real changes, this is just a refactoring.
2021-11-07 21:13:39 +00:00
Vadim Zeitlin
ddb3b4a80a Use wxWithImages in wxTreeCtrl
Replace direct use of wxImageList with the use of wxWithImages, which
will make adding support for using wxBitmapBundle later simpler.

In fact, this already somewhat simplifies the code by removing the need
to manually take care of m_ownsImageListXXX flags.
2021-11-07 17:52:35 +00:00
Vadim Zeitlin
725c3d5608 Update images when DPI changes in wxBookCtrlBase-derived classes
Just pretend that the images themselves have changed, this should be
enough to recreate wxImageList from the bundle using the new scale
factor in UpdateImageListIfNecessary().
2021-11-07 16:06:55 +00:00
Lauri Nurmi
aace36b17f Add static SetNameForCurrent for setting name of non-wxThreads
Co-authored-by: PB <PBforDev@gmail.com>
2021-11-05 16:11:56 +02:00
Lauri Nurmi
fc756d06a6 Add wxThread::SetName for naming threads for debugging purposes
Such thread names can be shown by some debuggers, and depending on
the OS and compiler versions used, they can be visible in process
lists and crash dumps.

Co-authored-by: PB <PBforDev@gmail.com>
2021-11-05 16:11:55 +02:00
Tobias Taschner
04e4b57a05 Remove unused m_runScriptCount
This was no longer used after the changes to the javascript wrapper
2021-11-05 09:54:44 +01:00
Tobias Taschner
9f9ccf33e1 Initialize syncScriptResult and remove unused parameter 2021-11-05 09:52:53 +01:00
Tobias Taschner
8613f3aa6b Apply suggestions from code review
Co-authored-by: VZ <vz-github@zeitlins.org>
2021-11-05 09:41:39 +01:00
Vadim Zeitlin
eb6e0289d6 Make WXK_LAUNCH_x constants consecutive
No real changes, but don't complicate the constants definitions
needlessly just to avoid changing the numeric value of WXK_LAUNCH_APP
constants as nobody should rely on them anyhow.

Not doing it simplifies things and allows to condense the mapping from
GDK keys to wx ones.
2021-11-05 00:43:39 +01:00
Tobias Taschner
d31f1dc400 Add wxWebViewEvent::IsError() 2021-11-03 13:35:24 +01:00
Tobias Taschner
93f7df50d5 Implement RunScriptAsync for webkit2 2021-11-03 11:19:08 +01:00
Tobias Taschner
7aa1d84e4a Implement RunScriptAsync for macOS 2021-11-03 11:19:08 +01:00
Tobias Taschner
e9dc74cb6d Add wxWebView::RunScriptAsync() 2021-11-03 11:19:07 +01:00
Tobias Taschner
cf6a947dab Use new JS wrapper with edge and IE 2021-11-03 11:19:00 +01:00
Tobias Taschner
2fe12ae6af Restructure javascript result wrapper 2021-11-03 11:18:53 +01:00
Dominique Martinet
61d835d8b3 wxKeyCode: add WXK_LAUNCH_[0-9A-F] for gtk bindings
X11 defines Xf86Launch[0-9a-f], which are then also defined as
GDK_KEY_Launch[0-9A-F].

Unfortunately, keys which are not mapped are just plain ignored and the
application is then not able to receive these keyboard events at all.

The original PR https://github.com/wxWidgets/wxWidgets/pull/157 mapped
only LaunchA/B to WXK_LAUNCH_APP1/2, this patch adds the whole range of
keys and keeps LAUNCH_A/B as aliases for WXK_LAUNCH_APP1/2
2021-11-02 10:18:02 +09:00
Vadim Zeitlin
b0d9465921 Add wxWithImages::SetImages() and update wxMSW wxNotebook for it
This new function will allow selecting the bitmap of the most suitable
size and automatically react to DPI scale changes (although this hasn't
been implemented yet) in all controls using image lists.

For now, only wxNotebook in wxMSW has been updated to work with it, the
other classes and ports will be updated to override OnImagesChanged()
instead of SetImageList() later.

Also update the notebook sample to use SetImages() rather than
SetImageList() -- which means that it doesn't show the icons any longer
in non-MSW ports, which haven't been updated yet.
2021-10-31 20:54:58 +01:00
Vadim Zeitlin
55819925dc Add wxBitmapBundle::GetConsensusSizeFor()
Move the code for determining the size preferred by a bunch of bitmap
bundles from wxToolBar to wxBitmapBundle itself to allow reusing it from
other classes.

No real changes, this is just a refactoring.

This commit is best viewed with --color-moved git option.
2021-10-31 20:40:06 +01:00
Vadim Zeitlin
0df49f0a54 Add wxWithImages::GetImageCount() and HasImages() helpers
These functions allow avoiding using wxImageList explicitly in a couple
of places.

No real changes, this just prepares for adding new API not based on
wxImageList.
2021-10-31 17:34:44 +01:00
Stefan Csomor
a7f5e3c5c3 OSX wxBitmapBundle::FromFiles implementation for macOS (#2561)
* adding macOS wxBitmapBundle::FromFiles implementation

* adding FromFiles overload, generic implementation

* Update interface/wx/bmpbndl.h

* Removing outdated comment

Co-authored-by: VZ <vz-github@zeitlins.org>
2021-10-26 22:27:36 +02:00
Vadim Zeitlin
5f8e9c14ae Merge branch 'wxrichtextctrl_word_wrapping_opt' of https://github.com/mehmet-soyturk/wxWidgets
Optimize wrapping long lines in wxRichTextCtrl.

See https://github.com/wxWidgets/wxWidgets/pull/2523
2021-10-26 19:43:03 +02:00
Vadim Zeitlin
8d14270636 Merge branches 'statbmp-bundle', 'upscale-only-bitmap' and 'bitmap-from-icon'
Fixes for wxBitmapBundle behaviour and use it in wxStaticBitmap too now.

See https://github.com/wxWidgets/wxWidgets/pull/2560,
    https://github.com/wxWidgets/wxWidgets/pull/2566,
    https://github.com/wxWidgets/wxWidgets/pull/2567
2021-10-26 19:38:21 +02:00
Vadim Zeitlin
04828b7225 Update wxStaticBitmap in wxMSW on DPI change
Use the appropriately sized bitmap when the resolution changes.
2021-10-26 00:11:57 +02:00
Vadim Zeitlin
3abec9254f Take wxBitmapBundle in wxStaticBitmap::SetBitmap()
This allows using higher resolution bitmaps when using high DPI
automatically in this control too.
2021-10-26 00:11:57 +02:00
Vadim Zeitlin
41b1ba3c9e Replace many identical wxBitmap::CopyFromIcon() with a single one
Define CopyFromIcon() directly in wxBitmapBase for the non-MSW ports, as
it was implemented exactly in the same way in all ports using this class
anyhow.

This means this function is not virtual any longer, but this shouldn't
be a problem as it was never supposed to be overridden in application
code and this couldn't be done with wxMSW, where it never was virtual in
the first place, anyhow.

No real changes, just a simplification.
2021-10-25 23:36:45 +02:00
Vadim Zeitlin
dc1c2c91b3 Fix setting size of wxStaticBitmap in wxOSX too
This is the same change as was done in the previous commit for
wxGenericStaticBitmap, see that commit message for more details.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
eba93fb5e7 Fix setting size of wxGenericStaticBitmap
We must call SetInitialSize() in Create() in order to take the size
argument passed to ctor/Create() into account -- it was completely
ignored previously.

But calling SetBitmap() must not change the initial size, as it can also
be done later, so just change the current size there instead (which is
consistent with wxMSW version and original behaviour, so keep it like
this, even though it's not totally clear if all ports do it).

Remove the now unused wxGenericStaticBitmap::GetBitmapSize().
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
b403624f22 Add common implementations of wxStaticBitmap icon methods
Instead of defining them, slightly differently, in all the non-MSW
ports, define them once in wxStaticBitmapBase.

No real changes, this is just a simplification.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
5773a8736c Define wxICON_IS_BITMAP when this is indeed the case
This symbol is useful for testing if wxIcon can be just converted to
wxBitmap, as is the case in all ports except for wxMSW currently.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
e126ddc11c Use more suitable type for MSWReplaceImageHandle() parameter
It's a handle, so make it a WXHANDLE rather than WXLPARAM and avoid
casting the handle when calling it (there is still a cast when calling
::SendMessage() inside this function, but this is unavoidable and this
cast was already there anyhow).

No real changes.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
c1abbe6473 Refactor wxMSW wxStaticBitmap to separate bitmaps and icons
Use different members for storing wxBitmap and wxIcon instead of using a
single pointer for storing a heap-allocated copy of either of them
because this is simpler, more efficient due to avoiding unnecessary
conversions and RTTI, and will be simpler to generalize to using
wxBitmapBundle instead of wxBitmap in the upcoming commits.

As a side effect, don't assert in GetIcon() or GetBitmap() if there is
no valid icon or bitmap, as this is inconsistent with the other ports
and wasn't even consistent between these functions in wxMSW itself.

There should be no other changes in behaviour.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
373653e4e5 Remove unnecessary wxStaticBitmap::DeleteCurrentHandleIfNeeded()
This function was used exactly once and it's simpler and more clear to
just inline it into Free() where it was called.

No real changes, this is just a small simplification.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
9326aa3b6c Add wxBitmapBundle::GetBitmapFor() helper
This can be used to get the bitmap of the size appropriate for the DPI
scaling used for the given window.
2021-10-25 13:40:18 +01:00
Vadim Zeitlin
e5a7e9ccbd Take const wxWindow in wxBitmapBundle::GetPreferredSizeFor()
This function should be usable in const methods of wxWindow-derived
classes too.
2021-10-25 12:21:15 +01:00
Vadim Zeitlin
30aad30a0a Don't create unnecessary vector in wxBitmapBundle::FromBitmap()
Just use wxBitmapBundle ctor instead, this is both simpler and more
efficient.

No real changes.
2021-10-24 23:09:31 +02:00
Vadim Zeitlin
1056ba19af Move scale factor-related wxBitmap functions out of line
This will make it possible to change them later without breaking ABI,
which is probably worth paying the price of a function call (assuming
the compiler could de-virtualize this call and inline it before).

No real changes.
2021-10-24 23:04:45 +02:00
Vadim Zeitlin
2c1f4c002d Add wxBitmap::SetScaleFactor()
We need to be able to change the scale factor of the bitmaps returned by
wxBitmapBundle::GetBitmap(), so add a function allowing to do this.

Also add wxHAS_BITMAP_SCALE_FACTOR allowing to check whether this
function actually does something non-trivial and explain in the docs
that GetScaleFactor() always returns 1 on the platforms where this
symbol is not defined.
2021-10-24 19:04:51 +02:00
Vadim Zeitlin
c8f76dea8e Simplify wxBitmap::GetScaledXXX() in wxMSW
The scale factor is always 1 in this port, so don't bother dividing or
rounding by it.
2021-10-23 21:38:32 +02:00
Vadim Zeitlin
1fb7b13812 Fix typo in "class" in wxUSE_STOPWATCH comment
Closes https://github.com/wxWidgets/wxWidgets/pull/2556
2021-10-22 01:42:53 +02:00