From 9a1e820cc1a97f1e0691a17b1acb652cc29ca736 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sat, 5 Dec 2020 22:22:04 +0100 Subject: [PATCH 01/13] Fix restoring application window when clicking on dock icon This didn't work any more since IsShown() returned true even for iconized windows, so we never did anything if all windows (and, in particular, the only window) were (was) iconized. Fix this by checking for IsIconized() first and IsShown() only if it returns false because it seems that IsShown() is indeed supposed to return true for iconized windows -- at least it also does it in wxMSW. Closes #18998. Co-Authored-By: Vadim Zeitlin --- src/osx/carbon/app.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/osx/carbon/app.cpp b/src/osx/carbon/app.cpp index 4d4f3a89ce..1b6cefa687 100644 --- a/src/osx/carbon/app.cpp +++ b/src/osx/carbon/app.cpp @@ -169,16 +169,16 @@ void wxApp::MacReopenApp() while (node) { wxTopLevelWindow* win = (wxTopLevelWindow*) node->GetData(); - if ( win->IsShown() ) - { - // we do have a visible, non-iconized toplevelwindow -> do nothing - return; - } - else if ( win->IsIconized() ) + if ( win->IsIconized() ) { if ( firstIconized == NULL ) firstIconized = win; } + else if ( win->IsShown() ) + { + // we do have a visible, non-iconized toplevelwindow -> do nothing + return; + } node = node->GetNext(); } From e89e76bb82f6d4bd96d1e6943099cd8bfd4e8292 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 02/13] Make wxCOL_WIDTH_AUTOSIZE work correctly in Mac wxDataViewCtrl Update the width when items are expanded and collapsed and also take the expander width into account. Change m_ModelNotifier type to avoid casts when calling wxOSX-specific method on it. Closes #14939. Co-Authored-By: Vadim Zeitlin --- include/wx/osx/cocoa/dataview.h | 3 +++ include/wx/osx/dataview.h | 2 +- src/osx/cocoa/dataview.mm | 25 +++++++++++++++++++++---- src/osx/dataview_osx.cpp | 13 ++++++++++--- 4 files changed, 35 insertions(+), 8 deletions(-) diff --git a/include/wx/osx/cocoa/dataview.h b/include/wx/osx/cocoa/dataview.h index 41d16201d8..e45ed0f358 100644 --- a/include/wx/osx/cocoa/dataview.h +++ b/include/wx/osx/cocoa/dataview.h @@ -557,6 +557,9 @@ private: wxCocoaOutlineDataSource* m_DataSource; wxCocoaOutlineView* m_OutlineView; + + // Width of expander in pixels, computed on demand. + int m_expanderWidth; }; #endif // _WX_DATAVIEWCTRL_COCOOA_H_ diff --git a/include/wx/osx/dataview.h b/include/wx/osx/dataview.h index a7a58d6f54..80e6aa0e99 100644 --- a/include/wx/osx/dataview.h +++ b/include/wx/osx/dataview.h @@ -306,7 +306,7 @@ private: wxDataViewColumnPtrArrayType m_ColumnPtrs; // all column pointers are stored in an array - wxDataViewModelNotifier* m_ModelNotifier; // stores the model notifier for the control (does not own the notifier) + class wxOSXDataViewModelNotifier* m_ModelNotifier; // stores the model notifier for the control (does not own the notifier) // wxWidget internal stuff: wxDECLARE_DYNAMIC_CLASS(wxDataViewCtrl); diff --git a/src/osx/cocoa/dataview.mm b/src/osx/cocoa/dataview.mm index 770719e4a9..9f927f6abf 100644 --- a/src/osx/cocoa/dataview.mm +++ b/src/osx/cocoa/dataview.mm @@ -2045,7 +2045,8 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer, [[NSScrollView alloc] initWithFrame:wxOSXGetFrameForControl(peer,pos,size)] ), m_DataSource(NULL), - m_OutlineView([[wxCocoaOutlineView alloc] init]) + m_OutlineView([[wxCocoaOutlineView alloc] init]), + m_expanderWidth(0) { // initialize scrollview (the outline view is part of a scrollview): NSScrollView* scrollview = (NSScrollView*) GetWXWidget(); @@ -2175,7 +2176,9 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) : m_width(0), m_view(view), m_column(columnIndex), - m_indent(0) + m_indent(0), + m_expander(0), + m_tableColumn(column) { // account for indentation in the column with expander if ( column == [m_view outlineTableColumn] ) @@ -2193,18 +2196,27 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) unsigned cellWidth = [cell cellSize].width + 1/*round the float up*/; if ( m_indent ) - cellWidth += m_indent * ([m_view levelForRow:row] + 1); + cellWidth += m_indent * [m_view levelForRow:row]; + + if ( m_expander == 0 && m_tableColumn == [m_view outlineTableColumn] ) + { + NSRect rc = [m_view frameOfOutlineCellAtRow:row]; + m_expander = ceil(rc.origin.x + rc.size.width); + } m_width = wxMax(m_width, cellWidth); } int GetMaxWidth() const { return m_width; } + int GetExpanderWidth() const { return m_expander; } private: int m_width; wxCocoaOutlineView *m_view; unsigned m_column; int m_indent; + int m_expander; + NSTableColumn *m_tableColumn; }; MaxWidthCalculator calculator(m_OutlineView, column, pos); @@ -2275,7 +2287,12 @@ void wxCocoaDataViewControl::FitColumnWidthToContent(unsigned int pos) count); } - [column setWidth:calculator.GetMaxWidth()]; + // there might not necessarily be an expander in the rows we've examined above so let's + // globally store the expander width for re-use because it should always be the same + if ( m_expanderWidth == 0 ) + m_expanderWidth = calculator.GetExpanderWidth(); + + [column setWidth:calculator.GetMaxWidth() + m_expanderWidth]; } // diff --git a/src/osx/dataview_osx.cpp b/src/osx/dataview_osx.cpp index ad197cc85c..7fc3dec650 100644 --- a/src/osx/dataview_osx.cpp +++ b/src/osx/dataview_osx.cpp @@ -73,14 +73,15 @@ public: virtual bool Cleared() wxOVERRIDE; virtual void Resort() wxOVERRIDE; + // adjust wxCOL_WIDTH_AUTOSIZE columns to fit the data + void AdjustAutosizedColumns(); + protected: // if the dataview control can have a variable row height this method sets the dataview's control row height of // the passed item to the maximum value occupied by the item in all columns void AdjustRowHeight(wxDataViewItem const& item); // ... and the same method for a couple of items: void AdjustRowHeights(wxDataViewItemArray const& items); - // adjust wxCOL_WIDTH_AUTOSIZE columns to fit the data - void AdjustAutosizedColumns(); private: wxDataViewCtrl* m_DataViewCtrlPtr; @@ -505,6 +506,9 @@ int wxDataViewCtrl::GetColumnPosition(wxDataViewColumn const* columnPtr) const void wxDataViewCtrl::Collapse(wxDataViewItem const& item) { GetDataViewPeer()->Collapse(item); + + if ( m_ModelNotifier ) + m_ModelNotifier->AdjustAutosizedColumns(); } void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn const* columnPtr) @@ -518,7 +522,10 @@ void wxDataViewCtrl::EnsureVisible(wxDataViewItem const& item, wxDataViewColumn void wxDataViewCtrl::DoExpand(wxDataViewItem const& item) { - return GetDataViewPeer()->DoExpand(item); + GetDataViewPeer()->DoExpand(item); + + if ( m_ModelNotifier ) + m_ModelNotifier->AdjustAutosizedColumns(); } bool wxDataViewCtrl::IsExpanded( const wxDataViewItem & item ) const From 701334a3ba40fa8d116555e4320d571c71640400 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 03/13] Fix wxListBox horizontal scrollbar updating in wxOSX Keep track of maximum width of the listbox items and update the width of the listbox column whenever it changes. Closes #18860. --- src/osx/cocoa/listbox.mm | 61 +++++++++++++++++++++++++++++++++++----- 1 file changed, 54 insertions(+), 7 deletions(-) diff --git a/src/osx/cocoa/listbox.mm b/src/osx/cocoa/listbox.mm index 766686a81f..216142b026 100644 --- a/src/osx/cocoa/listbox.mm +++ b/src/osx/cocoa/listbox.mm @@ -149,9 +149,15 @@ public : protected : + void AdaptColumnWidth ( int w ); + wxNSTableView* m_tableView ; wxNSTableDataSource* m_dataSource; + + NSMutableArray* m_widths; + int m_maxWidth; + bool m_autoSize; } ; // @@ -333,10 +339,14 @@ wxListWidgetCocoaImpl::wxListWidgetCocoaImpl( wxWindowMac* peer, NSScrollView* v wxWidgetCocoaImpl( peer, view ), m_tableView(tableview), m_dataSource(data) { InstallEventHandler( tableview ); + m_widths = [[NSMutableArray alloc] init]; + m_maxWidth = 0; + m_autoSize = false; } wxListWidgetCocoaImpl::~wxListWidgetCocoaImpl() { + [m_widths release]; [m_dataSource release]; } @@ -371,11 +381,7 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertTextColumn( unsigned pos, const } else { - [col1 setMaxWidth:1000]; - [col1 setMinWidth:10]; - // temporary hack, because I cannot get the automatic column resizing - // to work properly - [col1 setWidth:1000]; + m_autoSize = true; } [col1 setResizingMask: NSTableColumnAutoresizingMask]; @@ -465,24 +471,65 @@ wxListWidgetColumn* wxListWidgetCocoaImpl::InsertCheckColumn( unsigned pos , con return wxcol; } +void wxListWidgetCocoaImpl::AdaptColumnWidth ( int w ) +{ + NSTableColumn *col = [[m_tableView tableColumns] objectAtIndex:0]; + [col setWidth:w]; + m_maxWidth = w; +} // // inserting / removing lines // -void wxListWidgetCocoaImpl::ListInsert( unsigned int WXUNUSED(n) ) +void wxListWidgetCocoaImpl::ListInsert( unsigned int n ) { [m_tableView reloadData]; + + if ( m_autoSize ) + { + NSCell *cell = [m_tableView preparedCellAtColumn:0 row:n]; + NSSize size = [cell cellSize]; + int width = (int) ceil(size.width); + + [m_widths insertObject:[NSNumber numberWithInteger:width] atIndex:n]; + + if ( width > m_maxWidth ) + AdaptColumnWidth( width ); + } } -void wxListWidgetCocoaImpl::ListDelete( unsigned int WXUNUSED(n) ) +void wxListWidgetCocoaImpl::ListDelete( unsigned int n ) { [m_tableView reloadData]; + + if ( m_autoSize ) + { + [m_widths removeObjectAtIndex:n]; + + int maxWidth = 0; + for ( NSNumber *number in m_widths ) + { + int n = [number intValue]; + + if ( n > maxWidth ) + maxWidth = n; + } + + if ( maxWidth < m_maxWidth ) + AdaptColumnWidth( maxWidth ); + } } void wxListWidgetCocoaImpl::ListClear() { [m_tableView reloadData]; + + if ( m_autoSize ) + { + [m_widths removeAllObjects]; + AdaptColumnWidth( 100 ); + } } // selecting From 04a7a3f150e1518ba26b41ca620c73a20932f31d Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 04/13] Fix drawing outside of the splitter sash under macOS Take into account the extra border when using wxSP_3DBORDER. Closes #18861. --- src/osx/carbon/renderer.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/osx/carbon/renderer.cpp b/src/osx/carbon/renderer.cpp index 8d3fd41b54..a49daff549 100644 --- a/src/osx/carbon/renderer.cpp +++ b/src/osx/carbon/renderer.cpp @@ -348,11 +348,14 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win, height = wxRendererNative::Get().GetSplitterParams(win).widthSash; + // Do not draw over border drawn by wxRendererGeneric::DrawSplitterBorder() + const wxCoord borderAdjust = win->HasFlag(wxSP_3DBORDER) ? 2 : 0; + HIRect splitterRect; if (orient == wxVERTICAL) - splitterRect = CGRectMake( position, 0, height, size.y ); + splitterRect = CGRectMake( position, borderAdjust, height, size.y - borderAdjust ); else - splitterRect = CGRectMake( 0, position, size.x, height ); + splitterRect = CGRectMake( borderAdjust, position, size.x - borderAdjust, height ); // under compositing we should only draw when called by the OS, otherwise just issue a redraw command // strange redraw errors occur if we don't do this From f7d50ed18c6e6e7d834266c451c1b11d4d82713c Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 05/13] Don't scroll when inserting items into wxListBox in wxOSX This seems to have been needed in the past (see #12365), but is not needed any more and results in unexpectedly scrolling down to the last inserted item, which is undesirable and inconsistent with the other platforms. Simply revert f58438058b (Show the first, not the last, inserted item in wxListBox in wxOSX., 2010-11-05) to fix this. Closes #18861. --- src/osx/listbox_osx.cpp | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index e97d1b6c88..e153fb48a1 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -367,14 +367,6 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, GetListPeer()->UpdateLineToEnd(startpos); - // Inserting the items may scroll the listbox down to show the last - // selected one but we don't want to do it as it could result in e.g. the - // first items of a listbox be hidden immediately after its creation so - // show the first selected item instead. Ideal would probably be to - // preserve the old selection unchanged, in fact, but I don't know how to - // get the first visible item so for now do at least this. - SetFirstItem(startpos); - InvalidateBestSize(); UpdateOldSelections(); From 8bf53a7782c2c1b065fd7779a74e82621daecfe5 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 06/13] Fix selection after inserting items in wxListBox in wxOSX We need to adjust the indices of the currently selected items as we need to keep the same items, not the same indices, selected after new items insertion. Closes #18902. --- include/wx/osx/listbox.h | 2 ++ src/osx/listbox_osx.cpp | 52 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/include/wx/osx/listbox.h b/include/wx/osx/listbox.h index 5e8949e700..ed86f5c7d8 100644 --- a/include/wx/osx/listbox.h +++ b/include/wx/osx/listbox.h @@ -170,6 +170,8 @@ protected: wxArrayPtrVoid m_itemsClientData; private: + // Mostly the same as DoSetSelection() but doesn't call EnsureVisible(). + void DoSetSelectionWithoutEnsureVisible(int n, bool select); wxDECLARE_DYNAMIC_CLASS(wxListBox); wxDECLARE_EVENT_TABLE(); diff --git a/src/osx/listbox_osx.cpp b/src/osx/listbox_osx.cpp index e153fb48a1..961141df13 100644 --- a/src/osx/listbox_osx.cpp +++ b/src/osx/listbox_osx.cpp @@ -191,6 +191,14 @@ void wxListBox::DoSetSelection(int n, bool select) wxCHECK_RET( n == wxNOT_FOUND || IsValid(n), wxT("invalid index in wxListBox::SetSelection") ); + DoSetSelectionWithoutEnsureVisible(n, select); + + if (select) + EnsureVisible(n); +} + +void wxListBox::DoSetSelectionWithoutEnsureVisible(int n, bool select) +{ m_blockEvents = true; if ( n == wxNOT_FOUND ) @@ -201,9 +209,6 @@ void wxListBox::DoSetSelection(int n, bool select) m_blockEvents = false; UpdateOldSelections(); - - if (select) - EnsureVisible(n); } bool wxListBox::IsSelected(int n) const @@ -349,6 +354,23 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, { int idx = wxNOT_FOUND; unsigned int startpos = pos; + wxArrayInt selections; + + if ( !IsSorted() ) + { + if ( HasMultipleSelection() ) + { + GetSelections(selections); + } + else + { + int sel = GetSelection(); + if ( sel != wxNOT_FOUND ) + { + selections.Add(sel); + } + } + } const unsigned int numItems = items.GetCount(); for ( unsigned int i = 0; i < numItems; ++i ) @@ -367,6 +389,30 @@ int wxListBox::DoInsertItems(const wxArrayStringsAdapter& items, GetListPeer()->UpdateLineToEnd(startpos); + const size_t numSelections = selections.size(); + for ( size_t i = 0; i < numSelections; ++i ) + { + if ( startpos <= selections[i] ) + { + if ( HasMultipleSelection() ) + { + size_t j; + + // Do not deselect item if it is to be selected below + for ( j = 0; j < numSelections; ++j ) + { + if ( selections[i] == selections[j] + numItems ) + break; + } + + if ( j == numSelections ) + Deselect(selections[i]); + } + + DoSetSelectionWithoutEnsureVisible(selections[i] + numItems, true); + } + } + InvalidateBestSize(); UpdateOldSelections(); From 2b51c146091064103046efedd18639a085a01b5e Mon Sep 17 00:00:00 2001 From: Andy Robinson Date: Sat, 5 Dec 2020 23:44:57 +0100 Subject: [PATCH 07/13] Ignore events from unknown buttons in wxOSX In particular, don't map them to left mouse clicks because this is really wrong. Ideal would be to handle them in some way, but for now just throwing them away is better than generating wrong events. Closes #18967. --- src/osx/cocoa/window.mm | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 467998f485..619915b4d9 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -1470,6 +1470,26 @@ void wxWidgetCocoaImpl::mouseEvent(WX_NSEvent event, WXWidget slf, void *_cmd) return; } + // The Infinity IN-USB-2 V15 foot pedal on OS 11 produces spurious mouse + // button events with button number = 10. + // We cannot do anything useful with button numbers > 2, so throw them away. + switch ( [event type] ) + { + case NSLeftMouseDown: + case NSRightMouseDown: + case NSOtherMouseDown: + case NSLeftMouseUp: + case NSRightMouseUp: + case NSOtherMouseUp: + if ( [event buttonNumber] > 2 ) + return; + break; + + default: + // Just to avoid -Wswitch. + break; + } + if ( !DoHandleMouseEvent(event) ) { // for plain NSView mouse events would propagate to parents otherwise From 4390a092f6e9cd5a3e1d51d7abb954ebd1eeee47 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 08/13] Send wxEVT_COMBOBOX immediately in wxOSX To fix the problem with GetValue() not returning the updated value from the event handlers, just set the new value forcefully ourselves before generating the event rather than postponing sending the event. This makes the event order under Mac consistent with those elsewhere, i.e. wxEVT_COMBOBOX_CLOSEUP is now received after wxEVT_COMBOBOX there too, and not before, as without this change. See #18973. --- src/osx/cocoa/combobox.mm | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 7fc69b1276..9277d08d50 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -139,22 +139,25 @@ - (void)comboBoxSelectionDidChange:(NSNotification *)notification { wxUnusedVar(notification); - wxWidgetCocoaImpl* impl = (wxWidgetCocoaImpl* ) wxWidgetImpl::FindFromWXWidget( self ); + wxNSComboBoxControl* const + impl = (wxNSComboBoxControl* ) wxWidgetImpl::FindFromWXWidget( self ); if ( impl && impl->ShouldSendEvents()) { wxComboBox* wxpeer = static_cast(impl->GetWXPeer()); if ( wxpeer ) { const int sel = wxpeer->GetSelection(); + const wxString& val = wxpeer->GetString(sel); + + // We need to manually set the new value because at this time it + // still contains the old value, but we want GetValue() to return + // the new one if it's called from an event handler invoked below. + impl->SetStringValue(val); wxCommandEvent event(wxEVT_COMBOBOX, wxpeer->GetId()); event.SetEventObject( wxpeer ); event.SetInt( sel ); - event.SetString( wxpeer->GetString(sel) ); - // For some reason, wxComboBox::GetValue will not return the newly selected item - // while we're inside this callback, so use AddPendingEvent to make sure - // GetValue() returns the right value. - - wxpeer->GetEventHandler()->AddPendingEvent( event ); + event.SetString( val ); + wxpeer->HandleWindowEvent( event ); } } From cd571515cb385a35c01b619301110df808c27185 Mon Sep 17 00:00:00 2001 From: Andreas Falkenhahn Date: Sat, 5 Dec 2020 22:45:13 +0100 Subject: [PATCH 09/13] Send wxEVT_TEXT when wxComboBox value changes in wxOSX This must be done for consistency with the other ports and because it just generally makes sense. Closes #18973. --- src/osx/cocoa/combobox.mm | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/osx/cocoa/combobox.mm b/src/osx/cocoa/combobox.mm index 9277d08d50..5b8ffd938d 100644 --- a/src/osx/cocoa/combobox.mm +++ b/src/osx/cocoa/combobox.mm @@ -159,6 +159,10 @@ event.SetString( val ); wxpeer->HandleWindowEvent( event ); + wxCommandEvent eventText(wxEVT_TEXT, wxpeer->GetId()); + eventText.SetEventObject( wxpeer ); + eventText.SetString( val ); + wxpeer->HandleWindowEvent( eventText ); } } } From 19f9f6af57e654513c842ba47104e287757e96b5 Mon Sep 17 00:00:00 2001 From: Hartwig Date: Sun, 18 Oct 2020 00:52:22 +0200 Subject: [PATCH 10/13] Mark wxTextCtrl dirty before handling event in wxOSX This fixes behaviour of wxSpinCtrl which otherwise could still use the old value of its text part when processing spin buttons press. Closes https://github.com/wxWidgets/wxWidgets/pull/2092 --- src/osx/cocoa/window.mm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index 619915b4d9..e9e82814d0 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2443,7 +2443,10 @@ void wxWidgetCocoaImpl::controlTextDidChange() wxTextCtrl *tc = wxDynamicCast( wxpeer , wxTextCtrl ); wxComboBox *cb = wxDynamicCast( wxpeer , wxComboBox ); if ( tc ) + { + tc->MarkDirty(); tc->SendTextUpdatedEventIfAllowed(); + } else if ( cb ) cb->SendTextUpdatedEventIfAllowed(); else From 2a8e229238cb5add51fd557b1c1f6293f974fafe Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 6 Dec 2020 00:27:55 +0100 Subject: [PATCH 11/13] Avoid unnecessary wxDynamicCast in wxOSX code There is no need to check if the control is a wxComboBox if it turns out to already be a wxTextCtrl. No real changes, just a micro-optimization and simplification. --- src/osx/cocoa/window.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index e9e82814d0..a658637d42 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -2440,14 +2440,12 @@ void wxWidgetCocoaImpl::controlTextDidChange() if ( wxpeer ) { // since native rtti doesn't have to be enabled and wx' rtti is not aware of the mixin wxTextEntry, workaround is needed - wxTextCtrl *tc = wxDynamicCast( wxpeer , wxTextCtrl ); - wxComboBox *cb = wxDynamicCast( wxpeer , wxComboBox ); - if ( tc ) + if ( wxTextCtrl *tc = wxDynamicCast( wxpeer , wxTextCtrl ) ) { tc->MarkDirty(); tc->SendTextUpdatedEventIfAllowed(); } - else if ( cb ) + else if ( wxComboBox *cb = wxDynamicCast( wxpeer , wxComboBox ) ) cb->SendTextUpdatedEventIfAllowed(); else { From 27d6dce48da5fd165e66846def97b1555fa6b27d Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 6 Dec 2020 04:28:17 +0100 Subject: [PATCH 12/13] Fix appearance of inactive wxAuiNotebook tabs under macOS As we don't use any special value for the inactive caption background, use the same value as for normal caption text for inactive caption text too. This is almost certainly not ideal, but at least allows the tab labels to be readable. Closes #18988. --- src/osx/cocoa/settings.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/osx/cocoa/settings.mm b/src/osx/cocoa/settings.mm index 99fd931774..472d40b424 100644 --- a/src/osx/cocoa/settings.mm +++ b/src/osx/cocoa/settings.mm @@ -128,6 +128,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) case wxSYS_COLOUR_MENUTEXT: case wxSYS_COLOUR_WINDOWTEXT: case wxSYS_COLOUR_CAPTIONTEXT: + case wxSYS_COLOUR_INACTIVECAPTIONTEXT: case wxSYS_COLOUR_INFOTEXT: case wxSYS_COLOUR_LISTBOXTEXT: sysColor = [NSColor controlTextColor]; @@ -138,7 +139,6 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index) case wxSYS_COLOUR_BTNHIGHLIGHT: sysColor = [NSColor controlHighlightColor]; break; - case wxSYS_COLOUR_INACTIVECAPTIONTEXT: case wxSYS_COLOUR_GRAYTEXT: sysColor = [NSColor disabledControlTextColor]; break; From 534445f14b475f7c7d4625a22625b4f853f8855a Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Tue, 8 Dec 2020 04:22:29 +0100 Subject: [PATCH 13/13] Another fix for splitter rectangle calculation under macOS The rect offset was correctly changed in 04a7a3f150 (Fix drawing outside of the splitter sash under macOS, 2020-12-05), but its size was not. Fix it too now. See #18861. --- src/osx/carbon/renderer.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/osx/carbon/renderer.cpp b/src/osx/carbon/renderer.cpp index a49daff549..71e9535c53 100644 --- a/src/osx/carbon/renderer.cpp +++ b/src/osx/carbon/renderer.cpp @@ -353,9 +353,9 @@ void wxRendererMac::DrawSplitterSash( wxWindow *win, HIRect splitterRect; if (orient == wxVERTICAL) - splitterRect = CGRectMake( position, borderAdjust, height, size.y - borderAdjust ); + splitterRect = CGRectMake( position, borderAdjust, height, size.y - 2*borderAdjust ); else - splitterRect = CGRectMake( borderAdjust, position, size.x - borderAdjust, height ); + splitterRect = CGRectMake( borderAdjust, position, size.x - 2*borderAdjust, height ); // under compositing we should only draw when called by the OS, otherwise just issue a redraw command // strange redraw errors occur if we don't do this