Commit Graph

41731 Commits

Author SHA1 Message Date
Vadim Zeitlin
fdcaeb050f Move GetExtraControlSize() hack from wxFileDialogBase to MSW code
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.
2022-06-03 01:35:31 +01:00
Vadim Zeitlin
f6a261468e Slightly change the logic of CreateExtraControl()
This will make it simpler to extend in the upcoming commits.

No real changes yet.
2022-06-03 01:35:31 +01:00
Vadim Zeitlin
096c4bf195 Remove unnecessary HasExtraControlCreator() check from wxOSX
There is no need to call this function, just call CreateExtraControl()
directly -- it will do nothing if there are no extra controls to create.

No real changes.
2022-06-03 01:35:31 +01:00
Vadim Zeitlin
751a73a2ca Add optional label to wxFileDialogCustomize::AddTextCtrl()
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
095c4dfc94 Add event generation to MSW IFileDialog-based implementation
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
359ab98cb2 Start adding new API for wxFileDialog customization
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
f8976c3247 Implement IUnknown methods manually in wxFileDialogMSWData
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
c93f5350a3 Fix wxFileDialog repositioning
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
63f44b5bfa Call MSWOnInitDone() when using IFileDialog too
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
1de1c62872 Pass the correct HWND to MSWOnInitDone()
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
56bb9c2420 Don't call MSWOnSelChange() from MSWOnInitDone() itself
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
92534cf270 Check if we need to do something in wxFileDialog::MSWOnInitDone()
And don't do anything at all if we don't.

No real changes.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
a137145a44 Update the currently selected file when using IFileDialog too
Implement IFileDialogEvents::OnSelectionChange() to react to the changes
in the dialog selection.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
5bd765355b Make ConvertIShellItemToPath() public and rename
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
0a1714b709 Start using IFileDialogEvents to get notifications about changes
For now only update the currently selected file type using this
interface, but it will be used for more notifications later.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
a341efec34 Add helper FileDialogGetFileTypeIndex()
This is just a refactoring to allow reusing this function later.

No real changes.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
db7cf34e30 Remove unused HWND parameter of MSWOnTypeChange()
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
05fdf15c54 Use NMHDR to refer to the notification code everywhere
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
895b4a0710 Make wxFileDialog::MSWOnXXX() private
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.
2022-06-03 01:35:30 +01:00
Vadim Zeitlin
cf81527cfc Move private wxFileDialog members to wxFileDialogMSWData
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.
2022-06-03 01:35:29 +01:00
Vadim Zeitlin
cdba0ba961 Add IFileDialog-based wxFileDialog implementation
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.
2022-05-25 21:06:42 +01:00
Vadim Zeitlin
d54bf06060 Dynamically load SHCreateItemFromParsingName() only once
Don't do it every time the dialog is shown.
2022-05-25 21:06:42 +01:00
Vadim Zeitlin
4bcbff00f3 Split wxIFileDialog::Show() in multiple functions
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.
2022-05-25 21:06:42 +01:00
Vadim Zeitlin
d77a373118 Extract wxIFileDialog::Show() from wxDirDialog code
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.
2022-05-25 21:06:42 +01:00
Vadim Zeitlin
a623f34b39 Split GetPathsFromIFileOpenDialog() into 2 functions
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.
2022-05-25 21:06:41 +01:00
Vadim Zeitlin
c05d62f94f Put private IFileDialog helpers into an anonymous namespace
Don't use extern linkage for these private helpers.

No real changes.
2022-05-25 21:06:41 +01:00
Vadim Zeitlin
9a17c09834 Pass FOS_xxx options to InitIFileOpenDialog() directly
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.
2022-05-25 21:06:41 +01:00
Vadim Zeitlin
20430728bc Add wxFileDialog::ShowCommFileDialog()
No changes, just extract this function from ShowModal() before adding an
alternative implementation in the upcoming commits.
2022-05-25 21:06:41 +01:00
Vadim Zeitlin
4fb9ce574a Inline ShowCommFileDialog() helper into wxFileDialog::ShowModal()
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.
2022-05-25 21:06:41 +01:00
Randalphwa
76d1b3c9a9 Extend wxBitmap XRC handler to support all button attributes
Add support for the missing wxBU_NOTEXT style, bitmaps for the other
than default states (pressed, focus, disabled and current) and margins
to wxBitmapXmlHandler.

Note that the images for the other states were previously already
supported by wxBitmapButton XRC handler, but not by the wxBitmap one,
even though both bitmap classes support them.

Closes #22451.
2022-05-25 15:33:31 +02:00
Maarten Bent
4f8b49ca43 Create backing bitmap with correct scale factor in wxSTC
Using GetContentScaleFactor() worked just fine for wxOSX and wxGTK,
where it's the same as GetDPIScaleFactor() anyhow, and, until recently,
didn't matter for wxMSW where the scale factor was just ignored.

However since 9e5c8a8027 (Respect bitmap content scale factor in wxMSW
wxMemoryDC, 2022-03-26) it is important to specify the actually correct
scale factor when creating the backing bitmap in wxSTC code, as
otherwise wxMemoryDC would try to compensate for it by rescaling the
font, which should be unnecessary and resulted in a very noticeable
performance regression.

Simply using GetDPIScaleFactor() fixes the problem for wxMSW without
affecting the other platforms.

Closes #22450.
2022-05-25 15:26:59 +02:00
Maarten Bent
80a736250e Fix margin between wxBitmapComboBox images and text in high DPI
Don't use FromDIP() with m_usedImgSize which is expressed in logical,
and not DPI-independent, pixels already and also update the image size
when the DPI changes.

Closes #22436.
2022-05-25 15:22:15 +02:00
valid-ptr
76797ab9e1 Fix calling wxGTK wxDropTarget::GetMatchingPair() from OnData()
This function didn't work at all in this case because the drag context
wasn't set in target_drag_data_received(), unlike in all the other
callbacks.

Do set it here too to fix it, this notably makes dropping data on
generic wxDataViewCtrl work correctly in wxGTK.

Closes #22453.
2022-05-25 15:11:12 +02:00
DietmarSchwertberger
0dc9b292fe Fix regression in wxGrid row/col dragging to corner label
Recent changes to wxGrid (see #22292) resulted in an assertion being
triggered when dragging row or column to the corner window. Fix this by
adding a check for the new position validity.

Closes #22432.

Closes #22443.
2022-05-23 22:28:10 +01:00
Vadim Zeitlin
411c150bba Merge branch 'print-preview-layout'
Print preview layout and appearance fixes.

See #22441.
2022-05-23 22:25:16 +01:00
Vadim Zeitlin
c5f64e0509 Fix showing fully fully transparent bitmaps in wxMSW wxImageList
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.
2022-05-23 22:24:41 +01:00
Vadim Zeitlin
9042b529fa Merge branch 'dvc-bitmap-renderer-bundle'
Allow using wxBitmapBundle with wxDataViewBitmapRenderer.

See #22411.
2022-05-23 22:22:53 +01:00
Vadim Zeitlin
663fa1c77b Still use wxPreviewFrame size if it was explicitly specified
Even though it's better to not specify the preview frame size at all,
the size should still be used if it was explicitly specified, but this
didn't happen any more after the addition of the call to Fit().

Fix this now by only doing the equivalent of Fit() if no size was
explicitly given.

Also add advice about not setting the size explicitly to the
documentation.
2022-05-23 15:07:06 +01:00
Vadim Zeitlin
fc0a4d4e62 Correct client/window confusing in wxPreviewFrame code
Pass the window size to SetSizeHints() to make sure the window minimum
size is set as expected.
2022-05-23 15:07:06 +01:00
Artur Wieczorek
d90cb7511b Change the order of data member initializers
To suppress compiler warning that the order of member initializers
does not match the order in which they are executed.
2022-05-21 22:54:27 +02:00
Artur Wieczorek
a292ebe6ae Change the order of data member initializers
To suppress compiler warning that the order of member initializers
does not match the order in which they are executed.
2022-05-21 22:41:14 +02:00
Artur Wieczorek
e772cb1907 Use NULL literal to represent null pointer 2022-05-21 22:08:35 +02:00
Artur Wieczorek
21fe682187 Don't store wxBitmap objects on the heap in wxPropertyGrid
To simplify managing the life cycle of the objects.
2022-05-21 22:08:02 +02:00
Artur Wieczorek
5e417302c5 Don't store wxCursor object on the heap in wxPropertyGrid
To simplify managing the life cycle of the object.
2022-05-21 22:07:42 +02:00
Artur Wieczorek
d872229be3 Get rid of redundant casts 2022-05-21 22:05:12 +02:00
Artur Wieczorek
6652243b6f Don't override Refresh() in wxPropertyGridManager
It just forwards call to the base class so it's redundant.
2022-05-21 22:04:26 +02:00
Artur Wieczorek
19e0cf0095 Declare variable inside loop 2022-05-21 22:03:52 +02:00
Artur Wieczorek
547afc66c4 Pass large object by a const reference 2022-05-21 22:03:08 +02:00
Artur Wieczorek
598a21da9d Remove useless parentheses 2022-05-21 22:02:38 +02:00
Artur Wieczorek
1c292cfe2c Initialize data members in initialization lists 2022-05-21 22:01:58 +02:00