Commit Graph

19583 Commits

Author SHA1 Message Date
Vadim Zeitlin
304d5e6c59 Merge branch 'regex-prepare-pcre'
Cleanup and simplify wxRegEx code.

See https://github.com/wxWidgets/wxWidgets/pull/2437
2021-07-17 17:13:38 +02:00
Vadim Zeitlin
fa1f7e74ce Merge branch 'deprecate-filename-normalize'
Deprecate wxFilename::Normalize() without flags and add convenient
GetAbsolutePath() to be used instead.

See https://github.com/wxWidgets/wxWidgets/pull/2428
2021-07-17 17:10:40 +02:00
Vadim Zeitlin
7ebb20fb04 Merge branch 'combo-simplify'
Simplify wxComboCtrl code by always using wxPopupTransientWindow if it's
available instead of various platform-specific workarounds that
shouldn't be needed any longer.

See https://github.com/wxWidgets/wxWidgets/pull/2423
2021-07-17 17:08:29 +02:00
Vadim Zeitlin
f41564a3e2 Add wxRegEx::ConvertFromBasic() helper
This will be used to implement support for BREs using PCRE which doesn't
support them directly in the upcoming commits.
2021-07-15 22:45:29 +02:00
Vadim Zeitlin
d3eafa4d18 Fix compilation of wxFormBuilder-generated code using wxTE_XXX
Move definitions of wxTE_XXX flags that can be used with the controls
other than wxTextCtrl to wx/defs.h, as wxFormBuilder generates code
using them without including wx/textctrl.h, so that this code doesn't
compile.

This was already addressed in 2970f22a89 (Include <wx/textctrl.h> from
<wx/combobox.h> for compatibility., 2012-03-25) for wxComboBox, but it
also happened for wxSpinCtrl, so fix it once and for all by always
defining these styles.

This partially reverts the changes done in c57e33394c ([...] moved
wxTextCtrl-specific stuff from defs.h/event.h to textctrl.h, 2001-07-29)
as it turns out, 20 years later, that this wasn't such a great idea.

See #14132.

Closes #19225.
2021-07-14 21:40:45 +01:00
Vadim Zeitlin
3b5a0914dc Add GlobalPtr::Release() to wxMSW private header
Add a unique_ptr<>-like function to this RAII HGLOBAL wrapper.

This is not used yet, but will be in the upcoming commit.
2021-07-13 23:39:03 +01:00
Vadim Zeitlin
b9a2469ace Use wxRescaleCoord() in wxMSW DPI update code too
Use the same scaling function as elsewhere instead of using
ceil/floor().

Provide wxRescaleCoordWithFrom specialization for int to allow using it
with just single coordinates too.
2021-07-13 23:05:17 +01:00
Vadim Zeitlin
035c29e6a2 Make wxRescaleCoord() safer by requiring explicitly using From/To
This should help with accidentally exchanging the order of parameters
and makes the code using this function more readable.

No real changes.
2021-07-13 23:05:17 +01:00
Vadim Zeitlin
7843c99d5b Make wxRescaleCoord() private functions
They're probably not that useful in application code, which should just
use wxDPIChangedEvent::Scale() instead, so move them to a private
header instead of making them part of the public API.
2021-07-13 23:05:16 +01:00
Vadim Zeitlin
3787f55a6b Add wxDPIChangedEvent::Scale() and use it in this event handlers
This is more concise and less error-prone than multiplying/dividing DPI
values manually.

No real changes except, maybe, in wxSlider code where the rounding was
done differently before for some reason.
2021-07-13 23:05:16 +01:00
Vadim Zeitlin
453468f2f9 Add wxRescaleCoord() helper and use it
No real changes, just make the code a bit shorter and more clear by
using a dedicated function rather than wxMulDivInt32() directly.
2021-07-13 23:05:16 +01:00
Vadim Zeitlin
f37d449208 Add convenient wxFileName::GetAbsolutePath() wrapper and use it
This wrapper simply combines the calls to MakeAbsolute() and
GetFullPath(), but using it results in shorter and more clear code, so
it seems to be worth having.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
702c221901 Deprecate wxPATH_NORM_ALL and Normalize() with default flags
Using wxFileName::Normalize() with default flags could be surprising and
result in bugs in the code, as shown by our own wrong use of it in
wxFileSystemWatcher corrected in the previous commit.

Deprecate using it without any flags and recommend using MakeAbsolute()
instead.

Also improve the related parts of the documentation.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
2cd7025d7b Replace more uses of wxFileName::Normalize() with MakeAbsolute()
Unlike the parent commit, this one does change the behaviour by not
applying some normalizations any more, but these changes are correct,
i.e. we really don't need to call Normalize(), which expands environment
variables in the file names by default, here and just want to make the
file paths absolute.

In particular, this fixes the problem of mangling file names containing
dollar signs in wxFileSystemWatcher.

Closes #19214.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
6d2af9e7a1 Use wxFileName::MakeAbsolute() instead of Normalize()
Make the code more clear by being more explicit about what it does.

No real changes and no changes in behaviour at all.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
1f2413c461 Improve wxPATH_NORM_LONG documentation
Notably mention that this flag is obsolete.
2021-07-11 14:51:31 +01:00
Vadim Zeitlin
f6da66debc Disable use of [[deprecated]] with gcc 5
This gcc version claims support for this attribute, but actually doesn't
support it and returns unclear errors when it is used, e.g.

	$ echo '[[deprecated]] int x;' | g++-5 -fsyntax-only -x c++ -
	<stdin>:1:1: error: expected unqualified-id before ‘[’ token

so disable its use with gcc < 6.
2021-07-11 15:02:41 +02:00
Vadim Zeitlin
7a8f2dffbd Use standard [[deprecated]] attribute if available
Add yet another wxDEPRECATED_XXX macro, this one simply expanding to
C++14 [[deprecated]] attribute if it's available and nothing otherwise.

It's a bit ridiculous to have so many different macros for deprecating
things, but the new one is useful because the standard attribute can be
used to deprecated enum elements, which is impossible with MSVC-specific
__declspec(deprecated).
2021-07-11 14:47:47 +02:00
Vadim Zeitlin
aa42d9c805 Use wxPopupTransientWindow in wxComboCtrl in wxMSW too
This seems to work fine with current version of wxPopupTransientWindow
and wxPU_CONTAINS_CONTROLS style and allows to drastically simplify the
whole mess of preprocessor checks in wxComboCtrl code, reducing the
logic to just 2 cases: either wxUSE_POPUPWIN == 1 under any of the major
platforms and then we use wxPopupTransientWindow or wxUSE_POPUPWIN == 0
or we use some other platform and then a TLW-based fallback is used
instead.

In spite of the amount of changes, this should only modify behaviour
under MSW where wxPopupTransientWindow is used now instead of whatever
was used before.
2021-07-10 19:35:53 +01:00
Vadim Zeitlin
d7d5231e96 Replace wxComboPopupEvtHandler with calls to Bind() as well
This is not as much of a simplification as the previous two commits
because there is no simple replacement of EVT_MOUSE_EVENTS() using
Bind() and a loop over all mouse event types has to be written
explicitly, but it still avoids the need to allocate and delete a
separate object, so is still worth it.
2021-07-10 19:35:31 +01:00
Vadim Zeitlin
f3fb6dc833 Get rid of wxComboPopupWindowEvtHandler in wxComboCtrlBase too
Use Bind() calls instead of another event handler too, for the same
reasons as in the previous commit.
2021-07-10 18:04:38 +01:00
Vadim Zeitlin
d6426168a3 Remove wxComboBoxExtraInputHandler and use Bind() instead
There is no need to use a separate wxEvtHandler here when we can just
use Bind() to directly handle the child text control events in
wxComboCtrlBase itself, this code was a left over from pre-wx3 days.

No real changes, just make the code simpler and smaller (and also
marginally more efficient at run-time).
2021-07-10 18:04:38 +01:00
Vadim Zeitlin
cf3ebcea1a Merge wxComboCtrl::InstallInputHandlers() into CreateTextCtrl()
This function was always called after calling CreateTextCtrl() and
couldn't be called at any other moment, so it didn't make much sense to
have it as a separate function, just install the custom input handler
when (re)creating the text control.

This simplifies the derived classes code.
2021-07-10 18:04:38 +01:00
Maarten Bent
75c4735016 Fix using wxDCTextBgModeChanger
Correctly initialize the old background mode.
2021-07-08 20:46:36 +02:00
Vadim Zeitlin
07e80803da Merge branch 'grid-resize-fixes'
Fix spurious asserts about invalid drag row/column index in wxGrid.

See https://github.com/wxWidgets/wxWidgets/pull/2413
2021-07-06 14:28:53 +02:00
Vadim Zeitlin
0685086a7b Merge branch 'univmenucapture19208' of https://github.com/Kvaz1r/wxWidgets
Fix handling mouse capture in wxUniv menus.

Avoid crashing on losing it unexpectedly.

See https://github.com/wxWidgets/wxWidgets/pull/2407
2021-07-06 14:23:36 +02:00
Marc Jessome
a052557af3 Add wxKeyEvent::IsAutoRepeat()
The new method is currently supported in Qt, Cocoa, MSW ports (i.e. all
major ones except for wxGTK).

Keyboard example updated with a "Repeat" column.

Closes https://github.com/wxWidgets/wxWidgets/pull/2414
2021-07-06 12:58:05 +01:00
Vadim Zeitlin
0112a2dd1b Merge branch 'renderer'
Preserve wxDC attributes (pen, brush, colours) in wxRenderer functions.

Also fix Explorer listview theme name in wxMSW renderer.

See https://github.com/wxWidgets/wxWidgets/pull/2412
2021-07-06 12:50:35 +01:00
Vadim Zeitlin
3f3ea4d266 Add a comment documenting wxRenderer drawing functions behaviour
Now that all ports behave consistently and preserve wxDC attributes,
document this behaviour.
2021-07-06 13:49:14 +02:00
Artur Wieczorek
cc5bfc0fb1 Implement DrawSpline in wxSVGFileDC
Drawing Bézier curves is supported natively in SVG so these curves
should be used instead of generic wxDC implementation based on
polygonal approximation.
2021-07-04 19:22:02 +02:00
Vadim Zeitlin
5cac8a6918 Enforce valid drag column/row index in DoGridDragResize()
Add an assert to this function checking that the index is valid before
using it with wxGridOperations::GetLineStartPos(), and actually avoid
calling the function when this is not the case to avoid assertion
failures when wxEVT_GRID_CELL_LEFT_CLICK is handled in user code.

Also add comments clarifying the preconditions for calling various
drag-related functions.

Closes #19218.
2021-07-03 16:31:15 +01:00
Artur Wieczorek
0939130158 Refactor wxGCDC to delegate acquiring/releasing HDC to wxGraphicsContext
Instead of implementing MSW-specific code to handle HDC for GDI+ context
directly in wxGCDC delegate acquiring/releasing HDC to underlying
wxGraphicsContext. Decoupling GDI+-specific code from wxGCDC will allow
us to implement handling HDC in other graphics renderers in a clean way.
2021-06-27 23:46:21 +02:00
Kvaz1r
2209ec29f7 Add handling LEFT_UP 2021-06-27 21:50:09 +03:00
Kvaz1r
05875a76e9 Fix handling mouse capture 2021-06-26 17:11:41 +03:00
Vadim Zeitlin
8e2cac22ba Add support for std::string_view to wx vararg functions
Allow using wxPrintf() etc with std::string_view arguments when using
C++17.

This is inefficient but still more convenient than not being able to use
string_view at all.
2021-06-24 14:53:05 +01:00
Tim Stahlhut
fcfe91b16d Fix warnings about inline {From,To}DIP() in wxGTK/Win32 build
Define these functions in the class declaration to avoid gcc warning
about "redeclaring them without dllimport attribute after being
referenced with dll linkage".

This commit just moves the existing code around, no real changes.

Closes https://github.com/wxWidgets/wxWidgets/pull/2400
2021-06-24 14:50:32 +01:00
Vadim Zeitlin
2d9c9d9689 Fix handling of ampersands in wxCheckListBox under MSW
They were incorrectly interpreted as mnemonics when drawing
wxCheckListBox items, which didn't make sense and was inconsistent with
the other ports and even wxListBox in wxMSW itself.

It also affected wxRearrangeCtrl under MSW, which uses wxCheckListBox
for its implementation.

Closes #19201.
2021-06-24 14:49:08 +01:00
Tim Stahlhut
efc6a811f5 Add wxOVERRIDE to GTK/Qt wxGUIAppTraits classes in wxMSW too
wxOVERRIDE was already used for the native MSW version, but not the
other ones, which prevented this header from compiling cleanly with
-Wsuggest-override and so broke allheaders test in these ports.

Closes https://github.com/wxWidgets/wxWidgets/pull/2396
2021-06-15 17:47:30 +02:00
Kvaz1r
a0d67a3ca5 Remove redundant code 2021-06-14 15:10:46 +03:00
Vadim Zeitlin
01fd98c783 Merge branch 'generic-dvc-composite'
Use wxCompositeWindow for generic wxDVC implementation.

See https://github.com/wxWidgets/wxWidgets/pull/2382
2021-05-31 16:33:50 +02:00
Vadim Zeitlin
f1d84277b4 Merge branch 'nicer-boxsizer-asserts'
Improve the error messages by indicating what should be done to avoid
the asserts and provide a way to disable them if really needed.

See https://github.com/wxWidgets/wxWidgets/pull/2375
2021-05-31 15:18:37 +02:00
Vadim Zeitlin
f16b502f66 Forward key down/up events from wxCompositeWindow children too
There doesn't seem to be any reason to only forward CHAR events, but not
KEY_{DOWN,UP} ones, so do the same thing for the latter ones too.

This allows to get rid of GetMainWindow() call in wxDataViewCtrl unit
tests, as wxEVT_KEY_DOWN are now correctly received in the control
itself and not just its main window.
2021-05-24 14:24:24 +01:00
Vadim Zeitlin
3ed930c736 Use wxCompositeWindow for generic wxDataViewCtrl implementation
This makes several methods that didn't have any effect before work
correctly, including SetToolTip(), whose effect is now shown in the
sample, but also SetCursor() and SetLayoutDirection().

Some methods would now actually work too well: SetForegroundColour() and
SetBackgroundColour() implementations in wxCompositeWindow apply to all
sub-windows, but in wxDataViewCtrl they are only supposed to affect the
items, but not the header, so we need to override them to prevent the
base class version from being used. It is still preferable to explicitly
disable these two methods and inherit all the other ones (including any
possibly added in the future) from wxCompositeWindow to implementing all
the methods manually in wxDataViewCtrl itself.
2021-05-24 14:24:24 +01:00
Vadim Zeitlin
fa00fd24f0 Fix event origin for wxEVT_CHAR from wxCompositeWindow children
Use the just added wxEventObjectOriginSetter to set the event object and
ID to that of wxCompositeWindow itself, rather than that of the child
window where the event had actually occurred.
2021-05-24 14:24:24 +01:00
Vadim Zeitlin
9a150ba486 Add wxEventObjectOriginSetter helper class
This RAII helper can be used to temporarily change the event object and
ID of a wxEvent and will be used when redirecting events to make events
from one object to appear as coming from another one.
2021-05-24 14:24:24 +01:00
Vadim Zeitlin
0b20b97704 Merge branch 'spinctrl-digits'
Improve setting the number of digits in wxSpinCtrlDouble and make it
consistent on all platforms.

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

Closes #17085.
2021-05-22 21:25:32 +01:00
Vadim Zeitlin
2e289d7231 Add wxSizerFlags::DisableConsistencyChecks()
This allows to (hopefully temporarily) disable size flag check asserts.
2021-05-20 13:27:06 +01:00
Vadim Zeitlin
a352dee1f1 Disable warnings inside winsock2.h when using MSVC too
We already disabled the warnings inside windows.h, but since bf5090bcf3
(Enable Winsock 2 and IPv6 build options by default, 2021-04-24) we
could get warnings from winsock2.h, so move its inclusion inside the
region where the warnings were disabled too.

For the record, the warnings were, rather surprisingly, C4668, which is
disabled by default, but apparently was enabled somewhere inside (at
least some versions of) SDK headers.

This commit is best viewed with --color-moved git option.
2021-05-19 18:51:30 +01:00
Vadim Zeitlin
fc2e01d9a2 Make GtkPageSetup-related functions private
These functions don't need to be members of wxGtkPrintNativeData as they
don't use this object at all, so one shouldn't be required to call them.

And rather than making them static, just make them private functions
instead.

No real changes, this is just a refactoring.
2021-05-16 00:55:04 +02:00
Vadim Zeitlin
0585c96a3b Restore wxObject::ms_classInfo public access
This undoes accidental change of ms_classInfo from public to protected
in 95c98a0b5f (Work around -Wuggest-override for event table macros from
gcc 11, 2021-04-25).

Also add a unit test checking that using wxCLASSINFO(wxObject) compiles
and works as expected.
2021-05-04 23:14:41 +02:00