Commit Graph

4222 Commits

Author SHA1 Message Date
Vadim Zeitlin
e8a15050d2 Add missing references to wxSize parameters in wxBitmapBundle
Pass wxSize by const reference instead of "const" value.

Note that passing wxSize by value might be not such a bad thing,
actually, but we use const reference for it everywhere else, so do it
here as well for consistency (and the original intention was to do it
like this, missing "&" was just a typo subsequently propagated through
copy-pasting).

No real changes.
2021-10-16 15:56:40 +02:00
Vadim Zeitlin
af1069374e Merge branch 'bitmap-bundle'
Add wxBitmapBundle and use it in wxToolBar.

See https://github.com/wxWidgets/wxWidgets/pull/2535
2021-10-05 18:58:18 +02:00
Vadim Zeitlin
fb4e188cea Add wxHAS_SVG feature test macro
This is more clear and future-proof than using wxHAS_RAW_BITMAP for
checking for SVG availability.
2021-10-05 16:12:01 +01:00
Vadim Zeitlin
0216654272 Make wxBitmapBundleImpl public and show how to use it
Show how a custom implementation of wxBitmapBundleImpl can be defined in
the toolbar sample.
2021-10-05 16:06:43 +01:00
Stefan Csomor
fe3e0c558e wxArtProvider with wxBitmapBundle 2021-10-05 16:06:43 +01:00
Vadim Zeitlin
ab619010bd Add FromSVG() overload taking const data
Passing non-const data is inconvenient and error-prone, as data can't be
used again after it was modified by Nano SVG, which resulted in the
button using SVG bitmap not working any longer in the toolbar sample
after recreating the toolbar.

So make it easier to do the right thing, while still keeping the
overload taking non-const data for the situations when avoiding an extra
copy is worth it.
2021-10-05 16:06:43 +01:00
Vadim Zeitlin
ac02ae877f Add simple wxBitmapBundle::FromSVG() implementation using NanoSVG
Add nanosvg submodule and use it in the generic implementation of this
function.

This is incomplete yet and, notably, doesn't cache the rasterized
images, but already shows that using SVG images works (at least in the
toolbar sample).
2021-10-05 16:06:43 +01:00
Vadim Zeitlin
15e35a5e7c Document that FromDIP() is not needed with SetToolBitmapSize()
wxMSW wxToolBar adjusts the bitmap size to DPI automatically.
2021-10-05 15:49:44 +01:00
Vadim Zeitlin
b33df7360a Implement loading resource bundle from Windows resources
This allows to use resources defined in the .rc files under MSW instead
of embedding them in the program text as arrays.
2021-10-05 15:49:43 +01:00
Vadim Zeitlin
97f6c85d9b Add first version of wxBitmapBundle and use it in wxToolBar
This first version provides only a generic implementation of
wxBitmapBundle using a collection of bitmaps and only supports using it
in wxToolBar in wxMSW and wxGTK.

More methods of creating wxBitmapBundle will be provided later and more
functions taking wxBitmap will be changed to take wxBitmapBundle later
too and, of course, all the other ports will be updated to use the new
API too.
2021-10-05 15:49:43 +01:00
Vadim Zeitlin
9b5a72bd1e Document Connect() limitations compared to Bind()
Instead of just saying that Bind() is better, provide some points
illustrating why is it better.

Notable mention that Connect() can only be used with methods of the
classes publicly inheriting from wxEvtHandler, unlike Bind().

Closes #19266.
2021-10-04 00:27:53 +02:00
Vadim Zeitlin
5a91ab92f7 Use high quality in wxBitmap::Rescale()
This function is currently used for relatively small icons in
wxArtProvider and wxSearchCtrl, so it shouldn't be a problem to use
wxIMAGE_QUALITY_HIGH from performance point of view and if it ever does
become a problem, the application could easily use wxImage::Rescale()
with a different option directly instead.
2021-09-24 00:30:02 +02:00
Vadim Zeitlin
024c231624 Replace multiple RescaleBitmap() with wxBitmap::Rescale()
Define a single function and use it in both wxArtProvider and (the
generic implementation of) wxSearchCtrl instead of repeating the same
code elsewhere.

Note that another, but slightly different, version of RescaleBitmap()
still remains in wxPropertyGrid.

Deprecate undocumented wxArtProvider::RescaleBitmap() which is
completely useless now.

No real changes, this is just a refactoring.
2021-09-24 00:30:02 +02:00
Vadim Zeitlin
ed19e5625b Fix wxFileName unit test under Unix after recent changes
Don't use GetVolumeSeparator() to combine UNC or GUID volumes with
paths, this doesn't work because this kind of paths doesn't contain
colons at all.

Update the documentation to mention this.
2021-09-15 13:10:25 +02:00
Vadim Zeitlin
549e0a59b1 Fix handling of single letter shares in UNC paths in wxFileName
This comes at the price of breaking compatibility and returning
"\\share" rather than just "share" from wxFileName::GetVolume() for the
UNC paths. This breakage seems justified because it is required in order
to allow application code to distinguish between paths "x:\foo" and
"\\x\foo", which was previously impossible as GetVolume() returned just
"x" in both cases.

Document this change, adjust the existing checks for the new GetVolume()
semantics and add a new test which passes now, but didn't pass before.

Closes #19255.

This commit is best viewed ignoring whitespace-only changes.
2021-09-15 01:51:35 +01:00
Vadim Zeitlin
8d13440d69 Fix wxPATH_RMDIR_FULL documentation
Explain what this flag really does in Rmdir() documentation itself, as
the old wording was confusing.

Closes #16682.
2021-09-13 21:05:21 +01:00
Vadim Zeitlin
3840b0b1c4 Merge branch 'combo-non-text'
Allow using non-text control as main window of wxComboCtrl.

See https://github.com/wxWidgets/wxWidgets/pull/2515
2021-09-11 14:03:02 +02:00
Iwbnwif Yiw
5ba2461fd1 Switch to using GSpell for wxTextCtrl proof checker in wxGTK
Use GSpell rather than GtkSpell because GSpell also allows to check
single line text controls.

Closes https://github.com/wxWidgets/wxWidgets/pull/2516
2021-09-11 14:02:13 +02:00
Vadim Zeitlin
573e4fa0ec Allow using custom main window in wxComboCtrl
Add wxComboCtrl::SetMainControl() which can be used to use some other
window instead of the default wxTextCtrl as the main window of the
combo control.

Update the sample and the documentation to show the new function.
2021-09-08 20:44:34 +02:00
Vadim Zeitlin
8368914725 Merge branch 'compare-localized'
Allow creating wxUILocale for any locale and add
wxUILocale::CompareStrings().

See https://github.com/wxWidgets/wxWidgets/pull/2506
2021-09-05 23:16:10 +02:00
Vadim Zeitlin
2c580c9190 Add wxUILocale::FromTag() helper
This is exactly the same as wxUILocale(wxLocaleIdent::FromTag()) but
shorter.
2021-09-05 01:00:04 +02:00
Vadim Zeitlin
6b26deaddc Replace wxLocaleIdent ctor from language with FromTag()
This static function parses a subset of the language tags described in
BCP 47 (see https://www.rfc-editor.org/rfc/bcp/bcp47.txt).

Use the tag, as specified by this function, rather than the locale
identifiers components under MSW, where this should allow us to use even
locales that can't be described using just language-script-region.
2021-09-05 01:00:04 +02:00
Vadim Zeitlin
a47a885718 Check that locale ID argument of wxUILocale ctor is not empty
Disallow using empty wxLocaleIdent here, GetDefault() can, and should,
be used for the user default locale.
2021-09-05 01:00:04 +02:00
Vadim Zeitlin
be01b0c36a Rename wxLocaleIdent::IsDefault() to IsEmpty()
We don't use empty wxLocaleIdent as default user locale and it doesn't
make much sense to do it, as the default locale is already accessible
via wxUILocale::GetDefault().
2021-09-05 00:15:39 +02:00
Vadim Zeitlin
44a5cf78d1 Allow rescaling larger images in Win64 builds
Use wxUIntPtr rather than (unsigned) long in wxImage::ResampleNearest()
as long is still 32 bits under Win64 and so doesn't allow the code there
to work with images larger than 2^16 in either direction, when it could
be allowed in this case.

Document the current limits on the size of the image and add a unit test
checking that resizing images of size greater than 2^16 works in 64 bits.

See #18550.
2021-09-04 18:59:33 +01:00
Vadim Zeitlin
0f79f69d88 Return empty bitmaps from wxButton if not explicitly set in wxMSW
Do this for consistency with the other ports and because this seems more
useful anyhow.

Update the documentation to make this behaviour more clear and document
this change as a (minor) incompatibility in wxMSW.

Also add more unit tests to check for this behaviour. Note this also
fixes the problem with the unit test added in the grandparent commit
under MSW.
2021-09-03 21:22:05 +02:00
Vadim Zeitlin
836f5abc3d Try to improve CompareStrings() documentation
Explain why this function should be used and give an example of how this
function works in different locales.
2021-09-01 18:12:07 +02:00
Vadim Zeitlin
32316af106 Add wxUILocale::IsSupported()
This function can now be implemented relatively straightforwardly
(although it does require an extra check under Mac), so add it, as it
can be generally useful and we're also going to need it for our own
tests in the upcoming commit.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
ae81d9d207 Implement wxUILocale::CompareStrings() for Unix systems
This required changing CompareStrings() to be a method of wxUILocale
object, rather than just as a static function, as we must only allocate
the locale_t object once, and not during each to this function, as this
could make it unusably slow when using it as a comparison function when
sorting a large list of strings.

This is also more efficient under Mac, where we can similarly allocate
NSLocale only once and even marginally more efficient under MSW, where
we don't have to construct the locale string during each call. And,
under all platforms, it also simplifies code by separating this function
implementation from the initialization of wxUILocaleImpl.

Also document that case-insensitive comparison is not available under
Unix and adjust the tests accordingly.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
45f9908e05 Allow creating wxUILocale objects for any locale
Creating such objects (without using them for the UI) is supported under
all platforms, so allow doing it.

Note that this is only supported under Unix systems when locale_t and
related functionality is available, but this should be the case just
about everywhere by now.

Add a test (or, rather, replace an existing test which was disabled by
default) checking that we can now get locale information about any
locale, not necessarily the currently used one.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
592e1678ce Add charset support to wxLocaleIdent and accessors
Charset is important for Unix systems as some locales may not be
available without it, e.g. "xx_XX" may not be supported, but
"xx_XX.utf8" could be.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
20e3697f00 Change wxLocaleIdent ctor to take char* rather than wxString
This is convenient, as it allows using a simple string such as "en" as
an argument to the functions taking wxLocaleIdent and rely on implicit
conversion, whereas previously explicitly writing either wxString("en")
or wxLocaleIdent("en") would be necessary.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
ddd60d5a39 Add link to ISO 639 language codes to the documentation
This can be useful as not all of them are really obvious.
2021-09-01 18:11:40 +02:00
Vadim Zeitlin
e27497774a Optionally use case-insensitive comparison in CompareStrings()
Harmonize Mac and MSW versions by using case-sensitive comparison in
both of them by default, but allowing to use a flag to use
case-insensitive comparison instead.
2021-09-01 18:11:40 +02:00
Alexander Koshelev
c8269210a2 Add wxUILocale::CompareStrings() function
This function allows comparing strings using the sort order of the
specified locale, represented by the new wxLocaleIdent class.

It is implemented using CompareStringEx()[1] under MSW and
NSString::compare:options:range:locale:[2] under macOS, generic
implementation for the other platforms is upcoming.

[1]: https://docs.microsoft.com/en-us/windows/win32/api/stringapiset/nf-stringapiset-comparestringex
[2]: https://developer.apple.com/documentation/foundation/nsstring/1414561-compare?language=objc
2021-09-01 18:11:33 +02:00
Vadim Zeitlin
61340fcc82 Merge branch 'textctrl-spellcheck'
Add wxTextCtrl::EnableProofCheck() to use native spell checking support.

See https://github.com/wxWidgets/wxWidgets/pull/2473
2021-08-27 21:58:32 +02:00
Vadim Zeitlin
e307945170 Merge branch 'ui-locale'
Add wxUILocale class providing functionality which can be implemented
portably for all major platforms, including macOS, and doesn't force
the change of the global C locale, unlike wxLocale.

See https://github.com/wxWidgets/wxWidgets/pull/2464
2021-08-26 15:49:57 +02:00
Blake-Madden
78952e8ed5 Improve ListCtrl::EnableAlternateRowColours() documentation
Mention that it needs to be called again after calling
SetBackgroundColour().

Closes https://github.com/wxWidgets/wxWidgets/pull/2493
2021-08-25 16:02:29 +02:00
Vadim Zeitlin
45dcb1a8a5 Replace IsProofCheckEnabled() with GetProofCheckOptions()
This is more consistent with EnableProofCheck() and allows to retrieve
the current state of grammar checking under macOS, which can be checked
by user and so can be useful to know.
2021-08-23 14:19:11 +02:00
Vadim Zeitlin
db30397921 Implement support for grammar checking in wxOSX
Use native support for grammar checking in NSTextView.

As we're not passing wxTextProofOptions to the lower level function,
this functionality now depends on wxUSE_SPELLCHECK, meaning that even
the previously existing MacCheckSpelling() function is not defined any
more when wxUSE_SPELLCHECK is set to 0. This is not completely
backwards-compatible, but hopefully shouldn't be a problem in practice
and shouldn't break any existing applications which can't disable the
just added wxUSE_SPELLCHECK.
2021-08-23 14:18:42 +02:00
Vadim Zeitlin
2bb3083a93 Use wxTextProofOptions itself to enable or disable the checks
Remove a separate "bool enable" argument of EnableProofCheck() and use
wxTextProofOptions::IsSpellCheckingEnabled() to decide whether the
checks should be enabled or disabled.

Also remove wxTextProofOptions ctor and provide named static factory
functions for creating the objects of this class with clearly defined
meaning.
2021-08-23 14:18:19 +02:00
Vadim Zeitlin
90e79d8ed4 Implement minimal support for spell checking in wxOSX too
Reuse the existing CheckSpelling() function.

Also deprecate wxTextCtrl::MacCheckSpelling() in favour of the new
portable EnableProofCheck().
2021-08-23 14:17:16 +02:00
Vadim Zeitlin
af43b7c965 Correct description of EnableProofCheck() requirements
This functionality is available since Windows 8 only, not 7.
2021-08-23 14:16:54 +02:00
Vadim Zeitlin
25f9127499 Mark wxTextProofOptions as being new in 3.1.6 in the docs too 2021-08-23 14:16:54 +02:00
iwbnwif
472aec2d7e Add support for using native spell checking in wxTextCtrl
Add wxTextCtrl::EnableSpellCheck() and implement it for wxMSW and
wxGTK3.

Closes #17544.
2021-08-23 14:15:38 +02:00
Scott Talbert
8d2de3dd91 Add missing wxEventType declarations to notifmsg interface header
Closes https://github.com/wxWidgets/wxWidgets/pull/2475
2021-08-21 15:06:12 +02:00
Vadim Zeitlin
8fa853a3e2 Add wxGetUIDateFormat() helper function
Retrieve thr date format to use, even when wxUSE_INTL==0.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
3fc031e75b Add wxNumberFormatter::Format() for floating point numbers
The existing ToString() is not flexible enough to be used in wxGrid,
which supports specifying the width (and not just the precision) as well
as using formats other than "%g" and "%f" which are the only ones
supported by the existing function.

Note that currently the implementation simply calls wxString::Format()
and then adjusts the decimal separator, but it could, in principle, use
wxUILocale methods for formatting the floating point numbers using
native platform functions for doing this, e.g. CFNumberFormatter under
macOS.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
b3cab73680 Use wxUILocale in wxNumberFormatter
Always use the UI locale conventions for floating point numbers in
wxNumberFormatter, making it different from wxString::{To,From}Double()
functions that use C locale, which may, or not, correspond to the UI
locale.
2021-08-20 23:37:28 +02:00
Vadim Zeitlin
6689feb648 Merge branch 'osx-text-undo'
Implement undo/redo for (multiline) wxTextCtrl in wxOSX.

See https://github.com/wxWidgets/wxWidgets/pull/2474
2021-08-20 22:10:48 +02:00