Add unnecessary virtual dtor to this class just to avoid
-Wdelete-non-virtual-dtor from gcc (which is wrong here as this class is
never used polymorphically, i.e. never deleted via a pointer to its base
class).
Forward the events from the actual wxControls used in the generic
implementation of wxFileDialogCustomize to wxFileDialogCustomControl so
that they could be handled by the application code binding to them.
Keep wxFileDialog HWND valid until it's dismissed in order to allow any
operations involving the dialog geometry to work correctly while it's
shown, so that e.g. resizing windows from the custom controls event
handlers works.
This should be rarely needed, but it doesn't cost anything to support
the new customization API if IFileDialog is not available at either
compile- or run-time, as this just reuses the existing generic
implementation.
The hack with creating a dummy dialog just to get the size of the extra
controls is only used in wxMSW, so move it to MSW-specific file from the
common code.
To allow doing this there, add CreateExtraControlWithParent() helper,
which is still not really used anywhere else than in wxMSW, but at least
doesn't do anything particularly ugly and doesn't really penalize the
common code for wxMSW sins.
No real changes.
Creating a text with a label is a common operation and can be
implemented to look slightly better than AddStaticText() followed by
AddTextCtrl() without a label when using IFileDialog.
Inherit wxFileDialogCustomControl from wxEvtHandler to allow Bind()ing
to events on it and use this to handle wxEVT_BUTTON and wxEVT_CHECKBOX
in the sample.
And inherit from IFileDialogControlEvents in wxMSW code to actually
generate these events when they happen.
wxFileDialog::SetCustomizeHook() can be implemented in terms of
IFileDialogCustomize in wxMSW, which means that it can be used with the
new style dialogs shown by IFileDialog, unlike SetExtraControlCreator(),
which could only be supported when using older style common dialogs.
Add support for a few different controls and wxMSW implementation, more
controls, generic implementation and the documentation will be updated
later.
Also update the sample to show the new API in action and allow toggling
between using it and the old API for testing.
Using the helper macros won't work with multiple inheritance that is
going to be used in the upcoming commits.
We also don't need real reference counting here, so simplify the code by
not using it.
The calls to SetSize() were doing nothing because our own overridden
DoGet{Position,Size}() fooled it into thinking that the window already
had the correct geometry.
Return the actual position and size during MSWOnInitDone(), i.e. when we
have a correct HWND, to prevent this from happening.
This allows to use the new style dialog for the file dialogs for which
Centre() or SetSize() had been called, as we can now position the window
even when not using a hook function.
As there is no IFileDialogEvents function corresponding to CDN_INITDONE
notification, use the first call to OnTypeChange() instead.
Instead of requiring the function itself to use GetParent(), call it in
the hook function and pass the actual dialog HWND to MSWOnInitDone().
No real changes, just refactoring to prepare for further changes.
Call it from the hook function when it gets CDN_INITDONE notification
instead.
This doesn't change anything yet, but will when MSWOnInitDone() is
called from elsewhere.
Extract a private function from src/msw/dirdlg.cpp, change its return
type to avoid losing information about the error and rename it to a more
clear name now that it's used outside of this file.
No real changes.
Also simplify the hook function code a little by using OPENFILENAME
local variable directly instead of using OFNOTIFY only to always use its
OPENFILENAME member and nothing else.
No real changes.
It was confusing to take the notification code from NMHDR itself in one
place and then from OFNOTIFY just below -- use NMHDR in both places, as
OFNOTIFY field refers to the same thing.
No real changes.
These functions were always marked as being implementation-only, but we
can actually do better and make them private, by making the dialog hook
function a (static) member of wxFileDialogMSWData and making this class
(which is now a class and not a struct any more, as it's not just a
collection of fields any longer) a friend of wxFileDialog.
No real changes.
No real changes, just make it possibly to add more fields to the private
struct in the future without affecting the ABI.
This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-space options.
If possible, i.e. if none of the features not supported by IFileDialog
are needed, prefer to use IFileDialog for wxFileDialog rather than the
old common dialog functions.
There are no real differences in appearance because the old functions
actually already forward to the new IFileDialog-based implementation
internally anyhow, if possible, but this provides us with more
flexibility and some things that were ignored by the common dialog
functions now work, such as setting the initial dialog directory.
No real changes, just refactor the code to have separate ctor, setter
functions and Show() instead of doing everything in a single function.
This commit is best viewed ignoring whitespace-only changes.
Add a trivial class for showing an IFileDialog (and not just
IFileOpenDialog) and getting result(s) from it.
This class will be also used by wxFileDialog soon, but this commit only
updates wxDirDialog to use it.
This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-spac options.
Use different functions for the case of multiple paths and a single path
as they are rather different and even use methods of different
interfaces, which will become important soon.
Also pass just raw pointers to these functions, there is no reason to
use wxCOMPtr here as these functions don't take ownership of the
pointer but just use it during their execution.
No real changes yet.
This commit is best viewed ignoring whitespace-only changes.
This is more flexible and will allow using this function for the file
(and not just directory) dialog too in the future and makes the code
more readable and robust already because it removes the use of
non-obvious boolean parameters.
No real changes.
No real changes, just don't use a separate helper function for something
that we do only once to avoid an extra level of indirection which
doesn't help the comprehensibility of this code.
This commit is best viewed with git --color-moved option.
This was broken by 6feeed9fe9 (Handle transparency to the best of our
ability in wxImageList, 2022-05-05) as using alpha, rather than mask,
for these images resulted in alpha channel being just ignored.
Work around this by making at least one pixel not quite transparent in
this case.
This also makes things work for images using alpha channel with only 0
values, rather than mask covering the entire bitmap.
See #22400.
Closes#22437.
The fix of a5a5b1bb15 (Fix restoring focus after showing native modal
dialogs in wxMSW, 2022-04-07) wasn't quite correct as it used the parent
window specified when showing the dialog, but it should have been using
the effective dialog parent, i.e. owner window in MSW terms.
Fix this by passing GetParentForModalDialog() to wxWindowDisabler, which
ensures that the preserve the same behaviour as before, including
refreshing the owner window after the dialog as dismissed -- which turns
out to be important because some existing code relies on this happening,
see #22362.
This commit should hopefully fix the last regression after d311c705d7
(Make native dialogs application-modal in wxMSW, 2022-04-01) and still
solve the original problem (see #11887), while preserving the original
behaviour when there is just one top-level window.
Keys such as Ctrl-C etc could be unexpectedly intercepted by
accelerators defined for the menu items when wxSpinCtrl had focus.
Fix this by always preprocessing such keys in wxSpinCtrl itself, just as
it was already done for wxTextCtrl and even reuse the same function for
doing it (which had to be factored out in order to allow it).
Closes#22404.
Don't take the value of "mask" parameter of wxImageList constructor too
prescriptively, it predates support for alpha in wxWidgets by many years
and was never meant to actually suppress using it.
Instead, do the best thing we can in all cases, i.e. use alpha if it's
specified and supported and use mask otherwise. But only create the mask
from light grey colour if we have nothing else if "mask" is true in
wxImageList constructor, as this is a potentially destructive action
that must not be performed if the user has explicitly decided to set
this parameter to false.
Incidentally fix handling of alpha with comctl32.dll v5 (which is used
in the absence of any manifest) by converting it to a mask in this case:
this is not ideal, but better than just using black background as it
happened before, and restores pre-3.1.5 behaviour.
Also simplify the generic version which just has to create the default
mask if necessary and doesn't have to do anything at all in all the
other cases.
Note that these changes required relaxing some of the existing unit
tests as wxMSW implementation now can add alpha channel to the bitmaps
that didn't have it -- but this is a more useful behaviour, and so it
makes more sense to adapt the tests to it rather than doing a less
useful thing just to conform to the tests.
This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-spac options.
Closes#22349.
Allow reusing the code for creating a mask from wxImage mask from
elsewhere.
No real changes yet, this is a just a refactoring.
This commit is best viewed with git --color-moved
--color-moved-ws=ignore-all-space options.
Increase usable scrolling range in wxMSW by a factor of 10,000 by
switching to handling the device origin in wxWidgets itself instead of
letting GDI handle it.
See #22382.
Use 1992 as the initial date for all non-Mac files, instead of using
slightly later years for some of them without any good reason (or at
least without any good reason still remembered by anybody).
This also allows to simplify the script for updating the year.
It's not enough to just shift the result by the origin shift if there is
a transform matrix, we need to apply the reverse shift transformed by
this matrix in general.
This is not very efficient as we redo the same matrix operations on
every call, but using both device origin shift and transform matrix
together should be quite rare, so it's not clear if it's worth
optimizing this.
Only translate the labels in the native message box if there is a valid
current wxTranslations instance: this is simpler and more robust than
checking if the current language is different from the system language.
Closes#22383.
Using GDI functions for the device origin translation limits the
scrolling range to 2^27 size of the device space in the controls using
PrepareDC(), as it works by adjusting the device origin, and this may be
too small when having many (millions) of rows, which is perfectly
possible with wxDataViewCtrl or wxGrid, for example.
So handle DC device origin translations ourselves in wxMSW, i.e. offset
the coordinates by device origin before passing them to the native
functions as this allows to use the full 32-bit range.
Closes#17550.
Some cleanup in wxDC code: remove unnecessary casts, use RAII helpers
instead of manual memory and other resources management.
No real changes.
See #22378.