Derive wxGenericComboCtrl from wxNavigationEnabled<> to make TAB work
correctly when the focus was on it, otherwise it didn't move it
correctly to the next control.
This notably allows TAB to cycle through all the controls in the "combo"
sample whereas previously it stopped on reaching the combo control with
the list popup with wxGTK.
This header doesn't really need to be included from here and it was done
solely in order to get the value of wxALWAYS_NATIVE_DOUBLE_BUFFER from
it.
Move the code using this macro in the .cpp file instead.
The old wxEVT_SEARCHCTRL_{SEARCH,CANCEL}_BTN event names were unwieldy
and misleading because both of these events can be generated without
using the buttons, but by pressing Enter or Esc (the latter currently
works under macOS only, but this could change in the future).
This was broken because wxSearchCtrl inherited the base class version of
ChangeValue() which didn't really work for it due to the poor way in
which wxTextEntry is designed (see #18071).
Closes#16998.
This was useless as wxCompositeWindow, from which the generic
wxSearchCtrl derives, already sets focus to its first child and, since
the last commit, even harmful as it now resulted in calls to SetFocus()
from inside wxEVT_SET_FOCUS handler which is forbidden at least under
MSW.
See #15569.
wxCompositeWindow already connected to child wxEVT_KILL_FOCUS events and
generated the same event for the composite window itself, but didn't do
it for wxEVT_SET_FOCUS, resulting in not getting these events for the
main window as expected. E.g. this resulted in never getting any
wxEVT_SET_FOCUS events for wxSearchCtrl when using its generic version
(i.e. not under Mac).
Fix this by connecting to wxEVT_SET_FOCUS events for the children too.
Note that this relies on having a correct "previously focused window" in
these events, if this doesn't work reliably for some ports, we might
need to maintain a "bool m_hasFocus" field in wxCompositeWindow itself
instead.
Also note that we might avoid having all this code in wxCompositeWindow
if we translated the underlying native focus event to wxFocusEvents for
both the real window and its GetMainWindowOfCompositeControl() if it's
different. This could potentially be simpler and would definitely be
more efficient, but would require more changes.
Closes#15569.
The change of 2a8c290e0d was wrong as it
unconditionally restored m_oldClipRect in dtor, even when it was empty,
indicating that no clipping had been in effect when wxDCClipper was
constructed. This totally broke all the code using wxDCClipper, notably
generic wxListCtrl which wasn't repainted correctly at all.
Fix this by checking if the clipping rectangle is not empty before
restoring it, this should work as well as we can make it without having
GetClippingRegion() that could return an invalid region if no clipping
is in effect.
See #13834.
Closes#18066.
ProcessPendingEvents() was never called when using MFC event loop,
meaning that queued events were never processed, so that using
CallAfter() didn't work.
Fix this and also ensure that these events are processed soon enough by
also implementing WakeUpIdle() for such applications, as wxWakeUpIdle()
didn't do anything neither for them.
Fix a trivial "TODO" remaining from 2.8 days and declare the functions
that are part of the public control API as pure virtuals in the base
class.
No real changes.
Doing two different things in the same class, using m_isDynamicCompleter
to determine which kind of completion is used, was not very clear, so
create two simple classes each of which does one and one thing only and
create the one we need in wxTextEntry methods.
Note that wxTextAutoCompleteDynamic can assume to always have a valid
wxTextCompleter as otherwise no wxTextAutoCompleteData is needed at all,
which results in more simplifications.
There should be no changes in behaviour.
This allows to avoid initializing the variables to 0 in all the
overloaded ctors: wxSize default ctor already does it.
It's also more convenient to use GetScaledSize() rather than assigning
m_width and m_height separately, even if the rest of the code is broadly
unchanged.
We can reuse another ctor taking wxWindow* instead. Although this does
require an ugly cast, it's more explicit than just passing 0 which
could, in principle, match both the ctor taking wxWindow* and another
one taking double, and so is still preferable.
This is similar to the previous commit and is done for the same reasons:
screen DC needs to use the same DPI as the screen itself, instead of the
default Cairo 72 DPI.
For wxDC associated with a window, such as wx{Window,Client,Paint}DC,
this method should return the window PPI, not the hard coded 72 DPI of
Cairo graphics context.
This still doesn't work correctly when using multiple monitors with
different DPI settings, but is still a (modest) improvement.
MinGW compiler predefines WIN32, meaning that wx/msw/winundef.h was
always included from wx/defs.h, even when it was completely unnecessary.
This was just inefficient, but harmless, until the changes of
042d922e88 which broke MinGW compilation
as wxUSE_UNICODE_WINDOWS_H was incorrectly defined during the very first
inclusion of wx/msw/winundef.h, before _UNICODE could be defined
correctly by windows.h.
Fix this by checking whether windows.h was really already included.
Remove various definitions and symbol declarations from
numerous files using msw/uxtheme.h to a single file.
When possible vssym32.h is included from the Windows SDK.
For older SDKs tmschema.h is included and missing symbols
are defined in msw/uxtheme.h.
This undocumented "private" class was used for various windows UxTheme
functions which are available since WinXP. As wxWidgets 3.1 is XP+ it
does not make sense anymore to load the theme functions dynamically.
When having a certain creation sequence, these popup windows were not focused correctly, see https://github.com/wxWidgets/wxWidgets/pull/672 , commit d2265136e359df4d14054860a68bbc7f4910279d , revert this change if problems arise to see whether this is a recursion
Commit bc13119494 removed the inclusion of
xlocale.h because it is not (and never was) needed under Linux with
glibc, but it is still needed under macOS, so this (silently) disabled
wxXLocale support under Mac when using configure and broke the build
when using cmake.
Fix both problems by using xlocale.h only if it's available, both in
configure and in cmake.
The underlying Windows TaskDialog supports adding an additional footer
to the message dialog. This makes the native functionality available
and implements it in the generic version.
See https://github.com/wxWidgets/wxWidgets/pull/573
Testing for xlocale.h was due to a misunderstanding, this header wasn't
supposed to define locale_t which is defined by locale.h itself and was
just some internal glibc header which was removed in its 2.26 release,
see
https://sourceware.org/glibc/wiki/Release/2.26#Removal_of_.27xlocale.h.27
Stop checking for it in configure and also don't always define
wxUSE_XLOCALE but only do it if the configure test succeeded.
Trying to be smart by setting m_isEnabled to false in
wxStaticBox::Enable() without actually disabling the box itself (because
it can't be done if its label window is to remain enabled) didn't really
work. For example, it was impossible to TAB to a checkbox label of the
box when it was disabled, because keyboard navigation (correctly)
doesn't recurse into disabled windows and there could be similar
problems with any other code iterating over windows and skipping over
the disabled ones.
So, finally, simplify things and keep m_isEnabled in sync with the real
box state, even if this, counter-intuitively, means that IsEnabled() on
the box returns true after calling Enable(false) on it.
This also reverts 4ee35cf5ee569b6ee6c7d0d5702484d4d2a20f96 ("Don't
disable wxStaticBox children at wx level when disabling it") as we can't
avoid really disabling the children any more now that their parent is
not disabled: without this, their IsEnabled() would return true, i.e.
they wouldn't be disabled at all, from the program point of view. This
is unfortunate for the reasons that originally motivated that commit,
i.e. if some wxStaticBox child is disabled, disabling and re-enabling
the box will now re-enable this child, even if it shouldn't, but seems
impossible to avoid. The only possible alternative is to modify
IsEnabled() to add some wxStaticBox-specific hook to it, e.g. instead of
calling GetParent()->IsEnabled() there, we could call some now
AreChildrenEnable() method, which would delegate to IsEnabled() by
default but overridden in wxStaticBox. However this seems complicated,
and will add an extra virtual function call to all (frequently
happening) IsEnabled() calls.
Remove wxBookCtrlBase::AcceptsFocus() returning false as it didn't make
any sense: even though wxBookCtrlBase doesn't, indeed, accept focus on
itself, it does accept it for its children and returning false prevented
the focus from ever getting inside it.
This fixes, for example, keyboard navigation in a window containing
wxSimplebook and TAB can now be used to move to the controls inside it
from the outside.
Also remove the now unnecessary AcceptsFocus() override which was just
undoing the damage of the base class method and is not needed any more.
Reset m_pMainWnd in wxMFCApp::ExitInstance() to avoid crash when
deleting it again in OnMainWindowDestroyed() that could happen if
ExitInstance() was called not because the main window was closed (normal
case) but because wxApp::ExitMainLoop() was called, as it happens when
an unhandled exception is thrown.
There is no need to handle this style specially here, it's supposed to
be handled at wxWindow level and is, indeed, at least in all the major
ports.
So revert 2119b213e3 (see #13616) and the
workaround for it applied later for macOS (see #14856). And this also
removes the need for handling wx[HV]SCROLL in wxScrolled (see #17846).
Closes#14856, #17846.
When using configure, use the same family of hash sets/maps when
building wxWidgets and the applications using it as doing otherwise
results in ABI incompatibility.
Due to the same problem with sizeof(long) mismatch as in the previous
commit, we can't use struct timeval, with its long fields, in 64 bit
Cygwin builds, and need to use __ms_timeval instead.
Add wxTimeVal_t type to hide this difference and update all code
compiled under MSW (there is no need to uglify Unix-only code using
timeval, as in wxSelectDispatcher, for example) to use it instead of
timeval.
Use __ms_u_long instead of just u_long with Cygwin to avoid mismatch
between (64 bit) Cygwin long and (still 32 bit, even in 64 bit build)
Windows API long.
Calling Enable() on all children from wxStaticBox::Enable() was wrong,
the actual status of the child, returned by wxWindow::IsThisEnabled(),
is not supposed to change just because its parent was disabled.
Call NotifyWindowOnEnableChange() to avoid this, while still disabling
the children visually.
There doesn't seem to be any need to have this symbol in the header,
when it's only used in NotifyWindowOnEnableChange() in wincmn.cpp.
No real changes.
It just forwards to (virtual) WakeUp() and there should be no need to
ever override this method itself (nor even to keep it, except for
backwards compatibility).
No real changes.
Since the switch to using an event object for idle handling wakeup,
WM_NULLs are not being sent any longer, so wxIdleWakeUpModule didn't do
anything, resulting in pending event dispatching being paused while our
event loop was not running, as it happened, for example, while the
window was resized.
See #17579.
This reverts commit ebb3a791b9,
effectively reapplying 6c40531fb7 once
again.
This breaks wake up when not running our own event loop once again
(see #17579), but this will be fixed in the next commit.
Translate all strings in the new GetNodeText() function replacing the
old GetText() which was mostly used for translatable strings before --
except that <item> tag contents didn't use it because it also performed
string unescaping, not wanted for the control items, in addition to
translation.
Replace the old GetText() (while still keeping it for compatibility,
i.e. to avoid breaking any custom XRC handlers using it) with the new
function which is more flexible and can be used for all tags.
No real changes, this is just a refactoring.
Fix the problem with compiling user code including wx/debug.h as the
first wxWidgets header under MSW. This ought to work, but didn't,
because wx/debug.h included wx/chartype.h without including wx/defs.h
(because there is already an inclusion in the other direction), which
defines SIZEOF_WCHAR_T required by wx/chartype.h, first.
Notice that we repurpose the existing but completely unused (no mentions
of it or the symbols defined in it anywhere neither in wxWidgets nor in
any of the code search engines) wx/types.h header as it has a fitting
name and this avoids having to add a new header and remove the existing
one.
Override SetWindow() to check that the validator is being associated
with the window of the correct type, this allows to trigger an assert
immediately if this is not the case, making it simpler to find the error
as the call to SetValitator() on the wrong window will be in the call
stack when this happens, unlike before when the assert would happen only
at some later time.
Allow overriding the method called when the validator is associated with
the window, this can be convenient to perform some initialization on the
validator instance actually used as it can't be done on the initially
created object itself because it will be cloned by SetValidator(),
creating a new instance.
Also change SetWindow() to take wxWindow instead of wxWindowBase, this
still requires the cast in wxWindow::SetValidator(), but it's better to
have it there rather than in wxValidator and use the simpler type in the
public function signature.
This behaviour might be not completely intuitive, but it makes it much
simpler to handle the box state using a checkbox as the label control
(which is by far the most common case of using box window labels).
Notice that while we could add a separate EnableWithoutLabel() method to
wxStaticBox to make it possible to set the state of the box directly
relatively easily, it wouldn't help with using wxEVT_UPDATE_UI for
managing the box state indirectly as it relies on calling Enable() only.
And this solution does allow wxEVT_UPDATE_UI handlers for the box itself
to work (provided the handler takes care to check for the event object
being the box itself, as otherwise it would still disable the child
checkbox when its wxEVT_UPDATE_UI bubbles up to the box).
wxFloatingPointValidator and wxIntegerValidator copy ctor didn't copy
the associated window, so it was lost when the validator was Clone()'d.
Fix this by correctly using wxValidator copy ctor, instead of the
default one, in the copy ctor of the common wxNumValidatorBase base
class.
Avoid problems when using this header in code also include <windows.h>
(and not doing it via wx/msw/wrapwin.h) by ensuring that min and max
used here are not defined as macros.
We need to explicitly generate this event from the char hook handler as
we don't get the normal WM_CHAR for it, it is apparently intercepted by
the window proc installed by the auto-completing code, so check if
wxTE_PROCESS_ENTER is used for the text entry and call a special new
MSWProcessSpecialKey() method to do the right thing if it is.
Similarly, handle Tab presses correctly if wxTE_PROCESS_TAB is used.
Closes#12613.
Inherit from wxCompositeWindowSettersOnly<> to make sure all the usual
setters, such as SetForegroundColour() and SetFont(), called on
wxStaticBox are propagated to the label window too.
However also prevent SetBackgroundColour() from being propagated
unnecessarily -- because the checkbox already inherits the parent
background colour by default in wxMSW anyhow -- and still override
SetFont() to adjust the label window position after the font change,
otherwise it could be truncated after increasing the font size, for
example.
Because of these issues, wxCompositeWindowSettersOnly is not ideally
suited for its use here, but on balance it still seems to be better to
use it rather than reimplement parts of its functionality here.
Extract this class from wxCompositeWindow, as sometimes it can be
convenient to just define the setter functions to do the right thing for
a window containing sub-windows, but without dealing with focus too.
This will be used in wxMSW wxStaticBox in the next commit.
As this class is only supposed to be used as a base class, its ctor
doesn't need to be, and hence ought not to be, public.
Also update an outdated comment stating that the ctor didn't do anything
when it, in fact, does perform an important task.
Remove wxSIZE_AUTO from the SetSize() call, this was completely
unnecessary and unexpectedly (and wrongly) resized composite windows
managed by sizers as SetLayoutDirection() side-effect.
This allows to call the protected wxWindowGTK::DoApplyWidgetStyle()
method when it's really necessary, e.g. when forwarding to it from
DoApplyWidgetStyle() implementation for another window.
Factor out the code from wxStaticBoxSizer dtor into a wxStaticBox method
to improve encapsulation: the static box knows better than another class
how to detach its children from it before destroying it.
No real changes yet.
MSVS 2017 (which uses _MSC_VER from 1910 to 1912 currently) is
ABI-compatible with MSVS 2015 (_MSC_VER 1900), so do allow linking code
compiled with one of them with the library built by the other one.
Closes#18024.
When using two-step creation, as when loading from resources, for
example, it can be convenient to create wxMFCWnd as part of the (parent)
wxWindow object, but only attach it to the real HWND later, once it
becomes available.
This avoids using m_pMainWnd after its HWND becomes invalid, as this
resulted in assert failures from CWnd::WalkPreTranslateTree() called
with this HWND as its hWndStop argument from PreTranslateMessage() which
was used to pre-translate a WM_NULL message the application sometimes
received while closing down.
Still use the active event loop if there is one, just in case it
customizes messages pre-processing, but fall back on the standard
pre-processing code even if there is no active wx event loop and we're
only running the MFC one, as without doing this there are just too many
things that don't work (e.g. menu accelerators didn't work at all in
mixed wx/MFC applications previously).
When porting an existing MFC codebase to wxWidgets, it may be useful to
continue using the existing CWinApp-derived application class, so allow
deriving wxMFCApp from it instead of always deriving it from CWinApp
itself.
This can be used in order to use normal Unicode build of wxWidgets with
an application that needs to use ANSI versions of Win32 functions, e.g.
because it doesn't compile with UNICODE defined.
Allow reusing this functionality from outside the library, it can he
useful if an MFC window needs to be embedded into a wx application (or
vice versa).
Also use a better wxEntryStart() overload as a side effect, this should,
in particular, fix the problem with command line arguments processing in
mixed MFC/wx applications pointed out in a comment in the sample
previously.
Do not use 'RADIO_SIZE 20' as the fixed width of the radio button, but use the actual width as returned by wxRendererNative.
wxRendererNative has no GetRadioButtonSize, so for now use GetCheckBoxSize. It returns the same sizes.
Also add a half character width to account for the space between the button and the label.
There is no need to add extra width to the label of the static box.
Closes#18010.