Apply dark mode to the tooltips of the native controls using them
Override the newly added MSWGetToolTipMessage() in the controls using tooltips and apply dark mode to the window returned by this message too to make sure they appear correctly in dark mode.
This commit is contained in:
parent
b284786cf0
commit
ed02083c7e
10 changed files with 46 additions and 3 deletions
|
|
@ -134,6 +134,11 @@ protected:
|
|||
// disables the use of "Explorer" theme by default.
|
||||
virtual const wchar_t* MSWGetDarkThemeId() const { return nullptr; }
|
||||
|
||||
// Return the message that can be used to retrieve the tooltip window used
|
||||
// by a native control. If this message is non-zero and sending it returns
|
||||
// a valid HWND, the dark theme is also applied to it, if appropriate.
|
||||
virtual int MSWGetToolTipMessage() const { return 0; }
|
||||
|
||||
|
||||
// for controls like radiobuttons which are really composite this array
|
||||
// holds the ids (not HWNDs!) of the sub controls
|
||||
|
|
|
|||
|
|
@ -400,6 +400,8 @@ protected:
|
|||
|
||||
virtual const wchar_t* MSWGetDarkThemeName() const override;
|
||||
|
||||
virtual int MSWGetToolTipMessage() const override;
|
||||
|
||||
void OnDPIChanged(wxDPIChangedEvent& event);
|
||||
|
||||
wxSize MSWGetBestViewRect(int x, int y) const;
|
||||
|
|
|
|||
|
|
@ -141,6 +141,8 @@ protected:
|
|||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
virtual int MSWGetToolTipMessage() const override;
|
||||
|
||||
// hides the currently shown page and shows the given one (if not -1) and
|
||||
// updates m_selection accordingly
|
||||
void UpdateSelection(int selNew);
|
||||
|
|
|
|||
|
|
@ -101,6 +101,8 @@ protected:
|
|||
// common part of all ctors
|
||||
void Init();
|
||||
|
||||
virtual int MSWGetToolTipMessage() const override;
|
||||
|
||||
// create the native toolbar control
|
||||
bool MSWCreateToolbar(const wxPoint& pos, const wxSize& size);
|
||||
|
||||
|
|
|
|||
|
|
@ -212,6 +212,8 @@ protected:
|
|||
|
||||
virtual bool MSWShouldSetDefaultFont() const override { return false; }
|
||||
|
||||
virtual int MSWGetToolTipMessage() const override;
|
||||
|
||||
virtual void OnImagesChanged() override;
|
||||
|
||||
// SetImageList helper
|
||||
|
|
|
|||
|
|
@ -138,9 +138,19 @@ bool wxControl::MSWCreateControl(const wxChar *classname,
|
|||
return false;
|
||||
}
|
||||
|
||||
wxMSWDarkMode::AllowForWindow(m_hWnd,
|
||||
MSWGetDarkThemeName(),
|
||||
MSWGetDarkThemeId());
|
||||
if ( wxMSWDarkMode::IsActive() )
|
||||
{
|
||||
wxMSWDarkMode::AllowForWindow(m_hWnd,
|
||||
MSWGetDarkThemeName(),
|
||||
MSWGetDarkThemeId());
|
||||
|
||||
if ( const int msgTT = MSWGetToolTipMessage() )
|
||||
{
|
||||
const HWND hwndTT = (HWND)::SendMessage(GetHwnd(), msgTT, 0, 0);
|
||||
if ( ::IsWindow(hwndTT) )
|
||||
wxMSWDarkMode::AllowForWindow(hwndTT);
|
||||
}
|
||||
}
|
||||
|
||||
// saving the label in m_labelOrig to return it verbatim
|
||||
// later in GetLabel()
|
||||
|
|
|
|||
|
|
@ -694,6 +694,11 @@ const wchar_t* wxListCtrl::MSWGetDarkThemeName() const
|
|||
return L"ItemsView";
|
||||
}
|
||||
|
||||
int wxListCtrl::MSWGetToolTipMessage() const
|
||||
{
|
||||
return LVM_GETTOOLTIPS;
|
||||
}
|
||||
|
||||
wxVisualAttributes wxListCtrl::GetDefaultAttributes() const
|
||||
{
|
||||
wxVisualAttributes attrs = GetClassDefaultAttributes(GetWindowVariant());
|
||||
|
|
|
|||
|
|
@ -281,6 +281,11 @@ WXDWORD wxNotebook::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||
return tabStyle;
|
||||
}
|
||||
|
||||
int wxNotebook::MSWGetToolTipMessage() const
|
||||
{
|
||||
return TCM_GETTOOLTIPS;
|
||||
}
|
||||
|
||||
wxNotebook::~wxNotebook()
|
||||
{
|
||||
#if wxUSE_UXTHEME
|
||||
|
|
|
|||
|
|
@ -714,6 +714,11 @@ WXDWORD wxToolBar::MSWGetStyle(long style, WXDWORD *exstyle) const
|
|||
return msStyle;
|
||||
}
|
||||
|
||||
int wxToolBar::MSWGetToolTipMessage() const
|
||||
{
|
||||
return TB_GETTOOLTIPS;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// adding/removing tools
|
||||
// ----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -2208,6 +2208,11 @@ void wxTreeCtrl::SortChildren(const wxTreeItemId& item)
|
|||
// implementation
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
int wxTreeCtrl::MSWGetToolTipMessage() const
|
||||
{
|
||||
return TVM_GETTOOLTIPS;
|
||||
}
|
||||
|
||||
bool wxTreeCtrl::MSWShouldPreProcessMessage(WXMSG* msg)
|
||||
{
|
||||
if ( msg->message == WM_KEYDOWN )
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue