Commit graph

2093 commits

Author SHA1 Message Date
Vadim Zeitlin
a2f7a933e8 Merge branch 'no-global-ops'
Don't define operators for wx types in global scope.

This results in much better error messages when the compiler gives an
error about failing to resolve a call to some operator in user code
because it doesn't list all the wx-defined operators as candidates. In
practice, this cuts down error messages from 500 (!) lines to 2 with
gcc.

See #24190.
2024-01-12 18:42:39 +01:00
Vadim Zeitlin
09eff033d9 Hide operator<<() overloads used for wxVariant support too
Add new wxDECLARE_VARIANT_OBJECT_EXPORTED() macro defining these
operators as friend functions inside the class declaration and replace
all uses of DECLARE_VARIANT_OBJECT_EXPORTED() inside the core library
with the new macro to avoid defining any operator<<() overloads in the
global scope.

Also add wxIMPLEMENT_VARIANT_OBJECT() for consistency, even though it is
not really needed.
2024-01-06 23:06:02 +01:00
Vadim Zeitlin
1d328aa4e1 Add wxSplitterWindow::AlwaysUsesLiveUpdate()
This is similar to wxAuiManager::AlwaysUsesLiveResize() and does the
same thing, i.e. returns true if live update is always used, whether
wxSP_LIVE_UPDATE is enabled or not.

Use the new function in the sample to disable the menu item in the
environments where it doesn't do anything, as it was confusing to have
it under e.g. Wayland.
2023-12-26 19:27:50 +01:00
Blake-Madden
6d89a14c72 Add wxGrid::CopySelection()
This code was already used for Ctrl-C handling, refactor it into a
separate function that can be called from the application now.

This commit is best viewed with --color-moved-ws=ignore-all-space Git
option.

Closes #24124.
2023-12-12 20:18:59 +01:00
Vadim Zeitlin
60f6c0f4e1 Adjust indent and spacing after DPI change if necessary
Although wxGenericTreeCtrl is not used under MSW by default, it still
doesn't hurt to adjust its metrics when DPI changes there.

Note that this shouldn't be done for the platforms using DIPs.
2023-12-11 02:19:02 +01:00
Vadim Zeitlin
7c7429c015 Stop using "short" for wxGenericTreeCtrl::m_indent
There doesn't seem no reason at all not to use "int" for this member.
2023-12-11 02:09:26 +01:00
Paul Cornett
4030f3b90c Remove extraneous semicolons 2023-11-23 09:25:03 -08:00
Vadim Zeitlin
dede4b9326 Use "= default" for all trivial default ctors and dtors
Replace user-specified empty constructors and destructors with the
compiler-generated versions, which has a number of advantages for code
generation, in addition to being more clear.

Closes #22965.

Closes #24058.
2023-11-17 01:33:32 +01:00
Vadim Zeitlin
7a73044fd2 Merge branch 'tree-search'
Don't find hidden items when using incremental tree search.

See #24041.
2023-11-17 01:08:19 +01:00
Vadim Zeitlin
ef4fecc186 Merge branches 'tree-state-bmpbundle' and 'imglist-scalefactor'
Refactor wxImageList and convert it to use physical pixels and
add support for high DPI state images wxTreeCtrl using the new
wxImageList.

See #24000, #24033.
2023-11-17 01:03:27 +01:00
Vadim Zeitlin
8ca1be38e2 Add wxGenericTreeCtrl::DoGetNext(Next_Visible) function
This is similar but not totally identical to the existing
GetNextVisible() as it doesn't require the initial item itself to be
visible (notably, it could be the hidden virtual root).

It is also more efficient than the old GetNextVisible() implementation
calling GetNext() in the loop until finding a visible item, as it avoids
looking inside collapsed items in the first place.
2023-11-08 01:52:00 +01:00
Vadim Zeitlin
0d4792cc2d Refactor wxImageList classes to use wxImageListBase
This ensures that the native MSW and generic implementations provide the
same API by forcing them to implement the same pure virtual functions.
2023-11-03 01:53:36 +01:00
Vadim Zeitlin
3f971f52c1 Add using declaration for ctors to generic wxImageList
Instead of explicitly forwarding the ctors to the base class manually,
just use them.
2023-11-03 01:38:59 +01:00
Vadim Zeitlin
308e902102 Add wxTreeCtrl::SetStateImages()
Unlike the existing SetStateImageList() function, the new one allows to
provide the high-resolution versions of the state images too.

Update the treectrl sample to use the new API.

Closes #23993.
2023-11-03 00:53:40 +01:00
Vadim Zeitlin
9d06e4c4a7 Implement wxSearchCtrl::GetEditHWND() correctly in wxMSW
Since the changes of 4d76a87015 (Make wxSearchCtrl inherit from
wxTextEntry in all ports, 2023-07-09, see #23697) GetEditHWND() returned
null for wxSearchCtrl which was considered to be correct because all
wxTextEntry functions were supposed to be forwarded to wxSearchTextCtrl
anyhow.

This wasn't really correct, however, as GetEditHWND() was also called
from SetHint(), resulting in an assert failure and falling back on
generic hint implementation which, while mostly working, suffers from
some problems that the native implementation doesn't have.

So make this function return the actual HWND used by the associated text
entry to fix this and allow SetHint() to work as before and also
forestall any problems due to not having the right HWND in the future.

See #23983.

Closes #23975.
2023-10-25 23:45:23 +02:00
Vadim Zeitlin
e43f913313 Remove all blank "Modified by:" lines from top comment blocks
Having this line is not useful at all as it doesn't contain any
information and shouldn't be filled in the future as git-shortlog can
provide the information about people who changed the given file more
more reliably than consulting the comments in any case.

Keep the non-blank lines for historical purposes.
2023-10-22 01:22:48 +02:00
Blake-Madden
4235a018be Document that wxGetSingleChoice() geometry parameters are ignored
Also make it clear that wxCHOICE_{HEIGHT,WIDTH} constants are not really
used for anything.

Closes #23949.

Co-authored-by: Vadim Zeitlin <vadim@wxwidgets.org>
2023-10-07 18:58:58 +02:00
Maarten Bent
fa26c8724d
Don't use internal check state for generic virtual wxListCtrl
Just like the MSW virtual wxListCtrl, the checkbox state is determined by OnGetItemIsChecked.

See #23869
2023-09-30 17:32:54 +02:00
Vadim Zeitlin
2dd39d6b8c Stop using wxClientDC in wxGenericAnimationCtrl
Just refresh the window and repaint it from OnPaint().

This was already effectively done under Mac and now this class can be
also used in wxGTK (where it may be preferable to the native one as the
latter one doesn't support high DPI animations yet).
2023-08-25 20:51:21 +02:00
Vadim Zeitlin
27e80f81b4 Add high DPI support to generic wxAnimationCtrl
Allow specifying multiple animation versions, for different resolutions,
when setting the animation to use via wxAnimationBundle class which is a
much simpler version of wxBitmapBundle used elsewhere.

This is not implemented for the native GTK version yet.

Update the sample, even though the difference in it is not really
noticeable as the "high DPI" throbber is just a scaled up version of the
existing standard DPI animation produced using gifsicle.
2023-08-25 20:51:21 +02:00
Vadim Zeitlin
0436cebd82 Fix recently broken assert for virtual wxGenericListCtrl
The changes of 8c1234ea66 (Improve assert checking line index validity
in wxGenericListCtrl, 2023-07-24) were wrong for virtual list controls
as the lines vector is not used for them, so restrict the assert to the
non-virtual case only.
2023-07-24 15:23:40 +02:00
Vadim Zeitlin
8c1234ea66 Improve assert checking line index validity in wxGenericListCtrl
Don't just check that the index is not -1, but also that it's valid,
which can catch other problems.

Also replace the ASSERT with CHECK to avoid dereferencing invalid
pointer, it's better to crash when trying to dereference a NULL one.
2023-07-24 14:03:34 +02:00
Vadim Zeitlin
d5ef9d4387 Add wxGenericAboutDialog::GetCustomControlParent()
This function should be used to get the parent for the custom controls
instead of relying on them being reparented under it by the code added
in the last commit.

Change the type of m_contents to be wxWindow and not wxPanel as it
doesn't really matter, but wxPanel is not fully declared in this header
while wxWindow is.
2023-06-20 19:19:49 +02:00
Vadim Zeitlin
0b3d8a3d8b Implement wxGenericHyperlinkCtrl::GetDefaultAttributes()
Return the correct foreground colour from this function for hyper links,
it's different from the default text colour for the links.

This makes it easy to reuse this colour for the link-like elements in
the application code.
2023-05-12 03:58:55 +01:00
Vadim Zeitlin
1f05f3b5a0 Fix wxAboutDialog compilation in wxUniv build
Add missing wxPanel forward declaration as it's used in this header and
not already declared by some other header when using wxUniv.
2023-04-22 16:37:27 +02:00
Vadim Zeitlin
73c0998cd9 Use std::unordered_map<> in HeightCache private class
Replace a wx hash map of raw pointers with a standard container of
objects.
2023-04-18 00:54:12 +02:00
Vadim Zeitlin
f1f9cda458 Use std::unordered_xxx in wxGrid
Make wxGridFixedIndicesSet a std::unordered_set and use unordered_map
for the other maps used by wxGrid.

Remove the initial buckets assignment, as it isn't really clear if it's
helpful.

Also remove the casts that are not needed now that we use a map with the
correct type for the keys and values.
2023-04-12 18:15:46 +01:00
Vadim Zeitlin
d4f592c2a4 Stop using object array for wxGridCellCoordsArray
This type is part of the public API, so it can't be just replaced by a
std::vector<>, but it can at least be replaced by wxBaseArray<> which
inherits from std::vector<>.

Also accept just a vector, unimaginatively called wxGridCellCoordsVector
in the code, on input, as this is backwards-compatible with passing in a
wxGridCellCoordsArray.

Finally, simplify the code a bit by using range-for loop.

No real changes.
2023-04-12 18:09:47 +01:00
Vadim Zeitlin
dbcbb254f5 Use std::vector instead of wxGridStringArray in wxGrid code
This allows to simplify the code by directly using the standard class
methods.

Note that wxGridStringArray is used outside of wxWidgets, so we still
preserve its definition but make it just a simple vector of objects
instead of a legacy object array as there is really no need to keep
pointers to wxArrayString here.
2023-04-12 18:09:47 +01:00
Vadim Zeitlin
a4e8e7066d Replace all remaining occurrences of wxScopedPtr
Use std::unique_ptr<> in the library code instead of the legacy wx
class.
2023-03-06 23:53:13 +01:00
Vadim Zeitlin
a0a49f5391 Make wxGenericAboutDialog look more similar to MSW message box
Use white background for the upper part to mimic the message box
appearance.
2023-02-24 00:42:13 +00:00
Vadim Zeitlin
ff0a255a80 Replace wxGenericAboutDialog::Init() with member initialization
No real changes, just modernize the code a bit.
2023-02-23 19:07:25 +00:00
Vadim Zeitlin
6bdac08b75 Allow parent background to show through wxCollapsibleHeaderCtrl
This fixes wxCollapsiblePane appearance inside a wxNotebook in wxMSW, as
it now correctly uses wxNotebook (white) background instead of the
default (light grey) one.

Closes #23274.
2023-02-20 22:11:23 +00:00
Vadim Zeitlin
d8edc746e2 Don't make internal wxGenericTreeCtrl classes visible
Remove WXDLLEXPORT from the internal classes used only inside the
implementation.

Also remove forward declarations of classes not used in the header from
it.
2023-02-07 11:06:39 +01:00
Vadim Zeitlin
2969453637 Move copyright to the bottom of the generic About dialog
This is consistent with the native GTK and macOS dialogs and it makes
sense to try be more consistent with them, as the generic version is
used as a fallback under Mac.

Also use a smaller font for the copyright as is customary.
2023-01-30 21:11:42 +01:00
Vadim Zeitlin
b6937799e6 Store wxListLineData objects, not pointers, in the vector
This could be a noticeable optimization as it should be much more
efficient to store many lines in a single block of memory instead of
using pointers to them and it also simplifies the code as we don't need
to delete the pointers any more.
2023-01-19 02:11:43 +01:00
Vadim Zeitlin
93da9ff74e Use std::unique_ptr<> in wxListLineData and make it movable
Don't manage the pointer lifetime manually but use a smart pointer for
it: this is simpler and allows to make this class default-movable.

Also make it non-copyable as it never actually was (copying it would
have resulted in a double free of the owned pointer).
2023-01-19 02:11:43 +01:00
Vadim Zeitlin
f62047f867 Replace wxList classes used in wxGenericListCtrl with vectors
This simplifies the code and avoids unnecessary heap allocations as we
can store the objects in the vectors directly instead of storing
pointers to them.
2023-01-19 02:11:43 +01:00
Vadim Zeitlin
a5777cdcbd Make wxListItemData movable and not copyable
This class contains (sometimes) owned pointers and so can't be copied
but it can be moved, so make it moveable.

No real changes, this is done in preparation for storing objects of this
type in a std::vector.
2023-01-19 02:11:43 +01:00
Vadim Zeitlin
f547bf0647 Replace wxListItemData::Init() with member initialization
Get rid of Init() function and just initialize all the members in their
declarations, as this is less verbose, more clear and more robust.

Note that we also initialize m_rect now, which was left uninitialized by
Init() before, as it's simpler and more reliable to always do even if we
happen to overwrite it in the ctor.
2023-01-19 02:11:43 +01:00
Vadim Zeitlin
53188d30f0 Make wxListHeaderData::GetItem() const
Because there is no reason for it not to be it.
2023-01-19 00:27:24 +00:00
Vadim Zeitlin
b7e7d506c5 Use std::vector instead of wx array in wxGenericListCtrl code
This not only simplifies the code but also makes it more efficient by
avoiding unnecessary heap allocations, as we can now just store the
objects themselves in the vector instead of storing pointers to them.

No real changes, this is just a code cleanup/modernization.
2023-01-18 23:56:55 +00:00
Vadim Zeitlin
be7860c766 Remove wxUSE_STD_STRING and wxUSE_STD_CONTAINERS_COMPATIBLY
Assume they are always 1 now, there is no good reason to ever set them
to 0 any more.

Note that we still keep wxUSE_STD_IOSTREAM for now, but we can drop
wxUSE_STD_DEFAULT as it's not worth having it just for this single
option (previously it was used as the default value for 3 of them).
2022-11-17 00:40:50 +01:00
Vadim Zeitlin
20571f07e2 Get rid of platform-specific wxPanel classes
There is no need to have them as they were identical for all platforms.

This basically reverts 5b87bd6c0b (Split wxPanel in wxPanelBase and
platform-specific files., 2011-03-20) as, 10+ years later, it turns out
that we're not going to have more MSW-specific parts, but none of them.

No real changes.
2022-11-12 21:54:35 +01:00
Vadim Zeitlin
c501fd0c0f Derive generic wxSearchCtrl from only wxTextEntry too
This is similar to the changes of 020b6ebcb8 (Derive from wxTextEntry
instead of wxTextCtrlBase, 2019-12-29) for wxGTK and removes the methods
that don't exist in the other ports from the generic wxSearchCtrl too.
2022-11-08 23:28:24 +00:00
Vadim Zeitlin
fec8c06a53 Merge branch 'drop-ansi'
Remove support for "ANSI" build not using Unicode.

See #22920.
2022-10-29 18:09:00 +02:00
Vadim Zeitlin
66a148d51e Merge branch 'grid-refresh' of https://github.com/AliKet/wxWidgets
Simplify and improve wxGrid refresh logic.

See #22893.
2022-10-28 01:42:45 +02:00
Vadim Zeitlin
4519d8e08a Remove wxUSE_UNICODE checks as they're always true now
Also remove all code guarded by "#if !wxUSE_UNICODE".
2022-10-27 19:43:30 +02:00
Vadim Zeitlin
6dd4e73ea3 Add wxDrawImageBitmap() helper and use it in wx{List,Tree}Ctrl
Add a helper function calling wxDC::DrawBitmap() and hiding its ugly
"useMask" boolean parameter which was also error-prone, e.g. some
recently modified code passed wxIMAGELIST_DRAW_TRANSPARENT to it by
mistake.

No real changes, this is just a refactoring.
2022-10-25 23:48:25 +02:00
Gerhard Stein
502e189f47 Support high DPI bitmaps in wxGenericListCtrl
Use wxWithImages::GetImageBitmapFor() instead of wxImageList in this
control code to ensure that we use the provided high DPI bitmaps, if we
have them, instead of always scaling up the fixed-size image list
images.

Closes #22907.
2022-10-25 23:48:25 +02:00