Improve colour for selection background in dark mode in wxOSX Use the appropriate constants when available and provide fall back for older versions. Closes #26035.
Avoid duplicate toolbar item IDs on macOS We use the wxToolBarTool address as the native toolbar item ID, which must be unique within the application (at least), not just within the toolbar, and triggers an assertion failure if a wxToolbar is destroyed and re-created with item(s) happening to land at the same memory addresses before the underlying NSToolbar is destroyed. This commit changes the ID to include the NSToolbar address so that an ID won't be reused unless an NSToolbar has been fully destroyed and a new one created at the same address. This may also hint at an (existing) bug since the NSToolbar object clearly exists for longer than the wxToolBarTool, and Cocoa _MIGHT_ ask us for the item after it has been deleted, but I'm not familiar enough with macOS to know whether or not this can happen. Closes #26057.
Return wxACC_NOT_IMPLEMENTED from wxWindowAccessible::GetParent() If a widget has a custom accessibility implementation derived from wxWindowAccessible, there's no guarantee that the parent overrides the nullptr-returning base CreateAccessible. Returning wxACC_NOT_IMPLEMENTED follows the pattern of other accessibility methods to defer to the platform's default implementation, and fixes wx wxWindowAccessible::GetParent() when called on custom accessibility implementations like wxCheckListBoxAccessible. Closes #26063.
Don't use first image for wxListCtrl items without any image Native wxListCtrl in wxMSW behaved inconsistently with the generic one and used the first image for the new items inserted into it even if no image was explicitly specified. Work around this unhelpful native behaviour by using I_IMAGENONE for the items without images. Closes #26062.
| ... | ... | @@ -123,6 +123,11 @@ protected: |
| 123 | 123 | #ifdef __WXOSX_IPHONE__
|
| 124 | 124 | WX_UIView m_macToolbar;
|
| 125 | 125 | #endif
|
| 126 | + |
|
| 127 | +private:
|
|
| 128 | +#if wxOSX_USE_NATIVE_TOOLBAR
|
|
| 129 | + wxString FormatToolId(const wxToolBarToolBase *tool) const;
|
|
| 130 | +#endif
|
|
| 126 | 131 | };
|
| 127 | 132 | |
| 128 | 133 | #endif // wxUSE_TOOLBAR
|
| ... | ... | @@ -3955,7 +3955,7 @@ wxAccStatus wxWindowAccessible::GetParent(wxAccessible** parent) |
| 3955 | 3955 | if (*parent)
|
| 3956 | 3956 | return wxACC_OK;
|
| 3957 | 3957 | else
|
| 3958 | - return wxACC_FAIL;
|
|
| 3958 | + return wxACC_NOT_IMPLEMENTED;
|
|
| 3959 | 3959 | }
|
| 3960 | 3960 | }
|
| 3961 | 3961 |
| ... | ... | @@ -2066,6 +2066,16 @@ long wxListCtrl::InsertItem(const wxListItem& info) |
| 2066 | 2066 | |
| 2067 | 2067 | LV_ITEM item;
|
| 2068 | 2068 | wxConvertToMSWListItem(this, info, item);
|
| 2069 | + |
|
| 2070 | + // When inserting items into a control with an image list, the first image
|
|
| 2071 | + // is used by default, so we need to explicitly specify that we don't want
|
|
| 2072 | + // any image if it wasn't set.
|
|
| 2073 | + if ( !(item.mask & LVIF_IMAGE) )
|
|
| 2074 | + {
|
|
| 2075 | + item.iImage = I_IMAGENONE;
|
|
| 2076 | + item.mask |= LVIF_IMAGE;
|
|
| 2077 | + }
|
|
| 2078 | + |
|
| 2069 | 2079 | item.mask &= ~LVIF_PARAM;
|
| 2070 | 2080 | |
| 2071 | 2081 | // check whether we need to allocate our internal data
|
| ... | ... | @@ -574,9 +574,31 @@ wxRendererMac::DrawItemSelectionRect(wxWindow * WXUNUSED(win), |
| 574 | 574 | if ( !(flags & wxCONTROL_SELECTED) )
|
| 575 | 575 | return;
|
| 576 | 576 | |
| 577 | - wxColour col( wxMacCreateCGColorFromHITheme( (flags & wxCONTROL_FOCUSED) ?
|
|
| 578 | - kThemeBrushAlternatePrimaryHighlightColor
|
|
| 579 | - : kThemeBrushSecondaryHighlightColor ) );
|
|
| 577 | + wxColour col;
|
|
| 578 | + |
|
| 579 | +#if __MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_14_0
|
|
| 580 | + if (WX_IS_MACOS_AVAILABLE(14, 0))
|
|
| 581 | + {
|
|
| 582 | + col = wxColour( (flags & wxCONTROL_FOCUSED)
|
|
| 583 | + ? [NSColor selectedContentBackgroundColor]
|
|
| 584 | + : [NSColor unemphasizedSelectedContentBackgroundColor]
|
|
| 585 | + );
|
|
| 586 | + }
|
|
| 587 | + else
|
|
| 588 | +#endif
|
|
| 589 | + {
|
|
| 590 | + col = wxColour( wxMacCreateCGColorFromHITheme( (flags & wxCONTROL_FOCUSED)
|
|
| 591 | + ? kThemeBrushAlternatePrimaryHighlightColor
|
|
| 592 | + : kThemeBrushSecondaryHighlightColor ) );
|
|
| 593 | + |
|
| 594 | + if (((flags & wxCONTROL_FOCUSED) == 0) && (wxSystemSettings::GetAppearance().IsDark()))
|
|
| 595 | + {
|
|
| 596 | + // OS X has two distinct background greys in dark mode. One very dark
|
|
| 597 | + // gray you can see as the background of e.g. wxListBox and wxTreeCtrl,
|
|
| 598 | + // and a lesser dark grey in some other cases. This looks good on both.
|
|
| 599 | + col = wxColour( 110, 110, 110 );
|
|
| 600 | + }
|
|
| 601 | + }
|
|
| 580 | 602 | wxBrush selBrush( col );
|
| 581 | 603 | |
| 582 | 604 | wxDCPenChanger setPen(dc, *wxTRANSPARENT_PEN);
|
| ... | ... | @@ -430,8 +430,11 @@ private: |
| 430 | 430 | - (NSToolbarItem*) toolbar:(NSToolbar*) toolbar itemForItemIdentifier:(NSString*) itemIdentifier willBeInsertedIntoToolbar:(BOOL) flag
|
| 431 | 431 | {
|
| 432 | 432 | wxUnusedVar(toolbar);
|
| 433 | - wxToolBarTool* tool = (wxToolBarTool*) [itemIdentifier longLongValue];
|
|
| 434 | - if ( tool )
|
|
| 433 | + |
|
| 434 | + // This must be consistent with FormatToolId().
|
|
| 435 | + wxToolBarTool* tool = nullptr;
|
|
| 436 | + void* macToolbar;
|
|
| 437 | + if ( sscanf([itemIdentifier UTF8String], "%p:%p", &macToolbar, &tool) == 2 && tool )
|
|
| 435 | 438 | {
|
| 436 | 439 | wxNSToolbarItem* item = (wxNSToolbarItem*) tool->GetToolbarItemRef();
|
| 437 | 440 | if ( flag && tool->IsControl() )
|
| ... | ... | @@ -1226,7 +1229,7 @@ bool wxToolBar::Realize() |
| 1226 | 1229 | }
|
| 1227 | 1230 | else
|
| 1228 | 1231 | {
|
| 1229 | - cfidentifier = wxCFStringRef(wxString::Format("%ld", (long)tool));
|
|
| 1232 | + cfidentifier = wxCFStringRef(FormatToolId(tool));
|
|
| 1230 | 1233 | nsItemId = cfidentifier.AsNSString();
|
| 1231 | 1234 | }
|
| 1232 | 1235 | |
| ... | ... | @@ -1507,7 +1510,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) |
| 1507 | 1510 | #if wxOSX_USE_NATIVE_TOOLBAR
|
| 1508 | 1511 | if (m_macToolbar != nullptr)
|
| 1509 | 1512 | {
|
| 1510 | - wxString identifier = wxString::Format(wxT("%ld"), (long) tool);
|
|
| 1513 | + wxString identifier = FormatToolId(tool);
|
|
| 1511 | 1514 | wxCFStringRef cfidentifier( identifier );
|
| 1512 | 1515 | wxNSToolbarItem* item = [[wxNSToolbarItem alloc] initWithItemIdentifier:cfidentifier.AsNSString() ];
|
| 1513 | 1516 | [item setImplementation:tool];
|
| ... | ... | @@ -1536,7 +1539,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), wxToolBarToolBase *toolBase) |
| 1536 | 1539 | WXWidget view = (WXWidget) tool->GetControl()->GetHandle() ;
|
| 1537 | 1540 | wxCHECK_MSG( view, false, wxT("control must be non-null") );
|
| 1538 | 1541 | |
| 1539 | - wxString identifier = wxString::Format(wxT("%ld"), (long) tool);
|
|
| 1542 | + wxString identifier = FormatToolId(tool);
|
|
| 1540 | 1543 | wxCFStringRef cfidentifier( identifier );
|
| 1541 | 1544 | wxNSToolbarItem* item = [[wxNSToolbarItem alloc] initWithItemIdentifier:cfidentifier.AsNSString() ];
|
| 1542 | 1545 | [item setImplementation:tool];
|
| ... | ... | @@ -1693,10 +1696,15 @@ void wxToolBar::OSXSelectTool(int toolId) |
| 1693 | 1696 | wxCHECK_RET( tool, "invalid tool ID" );
|
| 1694 | 1697 | wxCHECK_RET( m_macToolbar, "toolbar must be non-null" );
|
| 1695 | 1698 | |
| 1696 | - wxString identifier = wxString::Format(wxT("%ld"), (long)tool);
|
|
| 1699 | + wxString identifier = FormatToolId(tool);
|
|
| 1697 | 1700 | wxCFStringRef cfidentifier(identifier);
|
| 1698 | 1701 | [(NSToolbar*)m_macToolbar setSelectedItemIdentifier:cfidentifier.AsNSString()];
|
| 1699 | 1702 | }
|
| 1703 | + |
|
| 1704 | +wxString wxToolBar::FormatToolId(const wxToolBarToolBase *tool) const
|
|
| 1705 | +{
|
|
| 1706 | + return wxString::Format("%p:%p", m_macToolbar, tool);
|
|
| 1707 | +}
|
|
| 1700 | 1708 | #endif // wxOSX_USE_NATIVE_TOOLBAR
|
| 1701 | 1709 | |
| 1702 | 1710 | #endif // wxUSE_TOOLBAR |
—
View it on GitLab.
You're receiving this email because of your account on gitlab.com. Manage all notifications · Help