Merge branch 'mac'
Assorted macOS fixes, see https://github.com/wxWidgets/wxWidgets/pull/625
This commit is contained in:
@@ -551,8 +551,6 @@ private:
|
|||||||
wxCocoaOutlineDataSource* m_DataSource;
|
wxCocoaOutlineDataSource* m_DataSource;
|
||||||
|
|
||||||
wxCocoaOutlineView* m_OutlineView;
|
wxCocoaOutlineView* m_OutlineView;
|
||||||
|
|
||||||
bool m_removeIndentIfNecessary;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // _WX_DATAVIEWCTRL_COCOOA_H_
|
#endif // _WX_DATAVIEWCTRL_COCOOA_H_
|
||||||
|
@@ -482,6 +482,13 @@ wxTreeListModel::InsertItem(Node* parent,
|
|||||||
{
|
{
|
||||||
// Not flat any more, this is a second level child.
|
// Not flat any more, this is a second level child.
|
||||||
m_isFlat = false;
|
m_isFlat = false;
|
||||||
|
|
||||||
|
// This is a hack needed to work around wxOSX wxDataViewCtrl
|
||||||
|
// implementation which removes the indent if it thinks that the model
|
||||||
|
// is flat. We need to re-add the indent back if it turns out that it
|
||||||
|
// isn't flat, in fact.
|
||||||
|
wxDataViewCtrl* const dvc = m_treelist->GetDataView();
|
||||||
|
dvc->SetIndent(dvc->GetIndent());
|
||||||
}
|
}
|
||||||
|
|
||||||
wxScopedPtr<Node>
|
wxScopedPtr<Node>
|
||||||
|
@@ -2033,8 +2033,7 @@ wxCocoaDataViewControl::wxCocoaDataViewControl(wxWindow* peer,
|
|||||||
[[NSScrollView alloc] initWithFrame:wxOSXGetFrameForControl(peer,pos,size)]
|
[[NSScrollView alloc] initWithFrame:wxOSXGetFrameForControl(peer,pos,size)]
|
||||||
),
|
),
|
||||||
m_DataSource(NULL),
|
m_DataSource(NULL),
|
||||||
m_OutlineView([[wxCocoaOutlineView alloc] init]),
|
m_OutlineView([[wxCocoaOutlineView alloc] init])
|
||||||
m_removeIndentIfNecessary(false)
|
|
||||||
{
|
{
|
||||||
// initialize scrollview (the outline view is part of a scrollview):
|
// initialize scrollview (the outline view is part of a scrollview):
|
||||||
NSScrollView* scrollview = (NSScrollView*) GetWXWidget();
|
NSScrollView* scrollview = (NSScrollView*) GetWXWidget();
|
||||||
@@ -2408,11 +2407,13 @@ bool wxCocoaDataViewControl::AssociateModel(wxDataViewModel* model)
|
|||||||
m_DataSource = NULL;
|
m_DataSource = NULL;
|
||||||
[m_OutlineView setDataSource:m_DataSource]; // if there is a data source the data is immediately going to be requested
|
[m_OutlineView setDataSource:m_DataSource]; // if there is a data source the data is immediately going to be requested
|
||||||
|
|
||||||
// Set this to true to check if we need to remove the indent in the next
|
// By default, the first column is indented to leave enough place for the
|
||||||
// OnSize() call: we can't do it directly here because the model might not
|
// expanders, but this looks bad if there are no expanders, so don't use
|
||||||
// be fully initialized yet and so might not know whether it has any items
|
// indent in this case.
|
||||||
// with children or not.
|
if ( model && model->IsListModel() )
|
||||||
m_removeIndentIfNecessary = true;
|
{
|
||||||
|
DoSetIndent(0);
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -2577,21 +2578,6 @@ void wxCocoaDataViewControl::SetRowHeight(const wxDataViewItem& WXUNUSED(item),
|
|||||||
|
|
||||||
void wxCocoaDataViewControl::OnSize()
|
void wxCocoaDataViewControl::OnSize()
|
||||||
{
|
{
|
||||||
if ( m_removeIndentIfNecessary )
|
|
||||||
{
|
|
||||||
m_removeIndentIfNecessary = false;
|
|
||||||
|
|
||||||
const wxDataViewModel* const model = GetDataViewCtrl()->GetModel();
|
|
||||||
|
|
||||||
// By default, the first column is indented to leave enough place for the
|
|
||||||
// expanders, but this looks bad if there are no expanders, so don't use
|
|
||||||
// indent in this case.
|
|
||||||
if ( model && model->IsListModel() )
|
|
||||||
{
|
|
||||||
DoSetIndent(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ([m_OutlineView numberOfColumns] == 1)
|
if ([m_OutlineView numberOfColumns] == 1)
|
||||||
[m_OutlineView sizeLastColumnToFit];
|
[m_OutlineView sizeLastColumnToFit];
|
||||||
}
|
}
|
||||||
|
@@ -769,6 +769,30 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void SetDrawingEnabledIfFrozenRecursive(wxWidgetCocoaImpl *impl, bool enable)
|
||||||
|
{
|
||||||
|
if (!impl->GetWXPeer())
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (impl->GetWXPeer()->IsFrozen())
|
||||||
|
impl->SetDrawingEnabled(enable);
|
||||||
|
|
||||||
|
for ( wxWindowList::iterator i = impl->GetWXPeer()->GetChildren().begin();
|
||||||
|
i != impl->GetWXPeer()->GetChildren().end();
|
||||||
|
++i )
|
||||||
|
{
|
||||||
|
wxWindow *child = *i;
|
||||||
|
if ( child->IsTopLevel() || !child->IsFrozen() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Skip any user panes as they'll handle this themselves
|
||||||
|
if ( !child->GetPeer() || child->GetPeer()->IsUserPane() )
|
||||||
|
continue;
|
||||||
|
|
||||||
|
SetDrawingEnabledIfFrozenRecursive((wxWidgetCocoaImpl *)child->GetPeer(), enable);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@implementation wxNSView
|
@implementation wxNSView
|
||||||
|
|
||||||
+ (void)initialize
|
+ (void)initialize
|
||||||
@@ -887,6 +911,24 @@ void wxWidgetCocoaImpl::SetupMouseEvent( wxMouseEvent &wxevent , NSEvent * nsEve
|
|||||||
return [super hitTest:aPoint];
|
return [super hitTest:aPoint];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) viewWillMoveToWindow:(NSWindow *)newWindow
|
||||||
|
{
|
||||||
|
wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl*) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
|
if (viewimpl)
|
||||||
|
SetDrawingEnabledIfFrozenRecursive(viewimpl, true);
|
||||||
|
|
||||||
|
[super viewWillMoveToWindow:newWindow];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) viewDidMoveToWindow
|
||||||
|
{
|
||||||
|
wxWidgetCocoaImpl* viewimpl = (wxWidgetCocoaImpl*) wxWidgetImpl::FindFromWXWidget( self );
|
||||||
|
if (viewimpl)
|
||||||
|
SetDrawingEnabledIfFrozenRecursive(viewimpl, false);
|
||||||
|
|
||||||
|
[super viewDidMoveToWindow];
|
||||||
|
}
|
||||||
|
|
||||||
@end // wxNSView
|
@end // wxNSView
|
||||||
|
|
||||||
// We need to adopt NSTextInputClient protocol in order to interpretKeyEvents: to work.
|
// We need to adopt NSTextInputClient protocol in order to interpretKeyEvents: to work.
|
||||||
@@ -2487,7 +2529,7 @@ void wxWidgetCocoaImpl::Init()
|
|||||||
wxWidgetCocoaImpl::~wxWidgetCocoaImpl()
|
wxWidgetCocoaImpl::~wxWidgetCocoaImpl()
|
||||||
{
|
{
|
||||||
if ( GetWXPeer() && GetWXPeer()->IsFrozen() )
|
if ( GetWXPeer() && GetWXPeer()->IsFrozen() )
|
||||||
[[m_osxView window] enableFlushWindow];
|
SetDrawingEnabled(true);
|
||||||
|
|
||||||
RemoveAssociations( this );
|
RemoveAssociations( this );
|
||||||
|
|
||||||
@@ -3035,6 +3077,10 @@ void wxWidgetCocoaImpl::SetDropTarget(wxDropTarget* target)
|
|||||||
|
|
||||||
void wxWidgetCocoaImpl::RemoveFromParent()
|
void wxWidgetCocoaImpl::RemoveFromParent()
|
||||||
{
|
{
|
||||||
|
// User panes will be thawed in the removeFromSuperview call below
|
||||||
|
if (!IsUserPane() && m_wxPeer->IsFrozen())
|
||||||
|
SetDrawingEnabled(true);
|
||||||
|
|
||||||
[m_osxView removeFromSuperview];
|
[m_osxView removeFromSuperview];
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3044,8 +3090,9 @@ void wxWidgetCocoaImpl::Embed( wxWidgetImpl *parent )
|
|||||||
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
|
wxASSERT_MSG( container != NULL , wxT("No valid mac container control") ) ;
|
||||||
[container addSubview:m_osxView];
|
[container addSubview:m_osxView];
|
||||||
|
|
||||||
if( m_wxPeer->IsFrozen() )
|
// User panes will be frozen elsewhere
|
||||||
[[m_osxView window] disableFlushWindow];
|
if( m_wxPeer->IsFrozen() && !IsUserPane() )
|
||||||
|
SetDrawingEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col )
|
void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col )
|
||||||
@@ -3694,6 +3741,9 @@ void wxWidgetCocoaImpl::SetFlipped(bool flipped)
|
|||||||
|
|
||||||
void wxWidgetCocoaImpl::SetDrawingEnabled(bool enabled)
|
void wxWidgetCocoaImpl::SetDrawingEnabled(bool enabled)
|
||||||
{
|
{
|
||||||
|
if ( [m_osxView window] == nil )
|
||||||
|
return;
|
||||||
|
|
||||||
if ( enabled )
|
if ( enabled )
|
||||||
{
|
{
|
||||||
[[m_osxView window] enableFlushWindow];
|
[[m_osxView window] enableFlushWindow];
|
||||||
|
@@ -49,8 +49,7 @@ class WXDLLEXPORT wxBitmapRefData: public wxGDIRefData
|
|||||||
friend class WXDLLIMPEXP_FWD_CORE wxIcon;
|
friend class WXDLLIMPEXP_FWD_CORE wxIcon;
|
||||||
friend class WXDLLIMPEXP_FWD_CORE wxCursor;
|
friend class WXDLLIMPEXP_FWD_CORE wxCursor;
|
||||||
public:
|
public:
|
||||||
wxBitmapRefData(int width , int height , int depth, double logicalscale);
|
wxBitmapRefData(int width , int height , int depth, double logicalscale = 1.0);
|
||||||
wxBitmapRefData(int width , int height , int depth);
|
|
||||||
wxBitmapRefData(CGContextRef context);
|
wxBitmapRefData(CGContextRef context);
|
||||||
wxBitmapRefData(CGImageRef image, double scale);
|
wxBitmapRefData(CGImageRef image, double scale);
|
||||||
wxBitmapRefData();
|
wxBitmapRefData();
|
||||||
@@ -106,8 +105,7 @@ public:
|
|||||||
|
|
||||||
int GetBytesPerRow() const { return m_bytesPerRow; }
|
int GetBytesPerRow() const { return m_bytesPerRow; }
|
||||||
private :
|
private :
|
||||||
bool Create(int width , int height , int depth);
|
bool Create(int width , int height , int depth, double logicalscale);
|
||||||
bool Create(int width , int height , int depth, double logicalScale);
|
|
||||||
bool Create( CGImageRef image, double scale );
|
bool Create( CGImageRef image, double scale );
|
||||||
bool Create( CGContextRef bitmapcontext);
|
bool Create( CGContextRef bitmapcontext);
|
||||||
void Init();
|
void Init();
|
||||||
@@ -269,12 +267,6 @@ wxBitmapRefData::wxBitmapRefData()
|
|||||||
Init() ;
|
Init() ;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmapRefData::wxBitmapRefData( int w , int h , int d )
|
|
||||||
{
|
|
||||||
Init() ;
|
|
||||||
Create( w , h , d ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxBitmapRefData::wxBitmapRefData( int w , int h , int d , double logicalscale)
|
wxBitmapRefData::wxBitmapRefData( int w , int h , int d , double logicalscale)
|
||||||
{
|
{
|
||||||
Init() ;
|
Init() ;
|
||||||
@@ -370,11 +362,12 @@ bool wxBitmapRefData::Create(CGContextRef context)
|
|||||||
return m_ok ;
|
return m_ok ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapRefData::Create( int w , int h , int d )
|
bool wxBitmapRefData::Create( int w , int h , int d, double logicalscale )
|
||||||
{
|
{
|
||||||
m_width = wxMax(1, w);
|
m_width = wxMax(1, w);
|
||||||
m_height = wxMax(1, h);
|
m_height = wxMax(1, h);
|
||||||
m_depth = d ;
|
m_depth = d ;
|
||||||
|
m_scaleFactor = logicalscale;
|
||||||
m_hBitmap = NULL ;
|
m_hBitmap = NULL ;
|
||||||
|
|
||||||
m_bytesPerRow = GetBestBytesPerRow( m_width * 4 ) ;
|
m_bytesPerRow = GetBestBytesPerRow( m_width * 4 ) ;
|
||||||
@@ -395,12 +388,6 @@ bool wxBitmapRefData::Create( int w , int h , int d )
|
|||||||
return m_ok ;
|
return m_ok ;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBitmapRefData::Create( int w , int h , int d, double logicalScale )
|
|
||||||
{
|
|
||||||
m_scaleFactor = logicalScale;
|
|
||||||
return Create(w*logicalScale,h*logicalScale,d);
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBitmapRefData::UseAlpha( bool use )
|
void wxBitmapRefData::UseAlpha( bool use )
|
||||||
{
|
{
|
||||||
if ( m_hasAlpha == use )
|
if ( m_hasAlpha == use )
|
||||||
@@ -1125,7 +1112,7 @@ bool wxBitmap::CreateScaled(int w, int h, int d, double logicalScale)
|
|||||||
if ( d < 0 )
|
if ( d < 0 )
|
||||||
d = wxDisplayDepth() ;
|
d = wxDisplayDepth() ;
|
||||||
|
|
||||||
m_refData = new wxBitmapRefData( w , h , d, logicalScale );
|
m_refData = new wxBitmapRefData( w*logicalScale , h*logicalScale , d, logicalScale );
|
||||||
|
|
||||||
return M_BITMAPDATA->IsOk() ;
|
return M_BITMAPDATA->IsOk() ;
|
||||||
}
|
}
|
||||||
@@ -1220,7 +1207,7 @@ wxBitmap::wxBitmap(const wxImage& image, int depth, double scale)
|
|||||||
|
|
||||||
wxBitmapRefData* bitmapRefData;
|
wxBitmapRefData* bitmapRefData;
|
||||||
|
|
||||||
m_refData = bitmapRefData = new wxBitmapRefData( width/scale, height/scale, depth, scale) ;
|
m_refData = bitmapRefData = new wxBitmapRefData( width, height, depth, scale) ;
|
||||||
|
|
||||||
if ( bitmapRefData->IsOk())
|
if ( bitmapRefData->IsOk())
|
||||||
{
|
{
|
||||||
|
@@ -1638,6 +1638,15 @@ void wxWindowMac::RemoveChild( wxWindowBase *child )
|
|||||||
if ( child == m_growBox )
|
if ( child == m_growBox )
|
||||||
m_growBox = NULL ;
|
m_growBox = NULL ;
|
||||||
#endif
|
#endif
|
||||||
|
if (!child->IsBeingDeleted() && !child->IsTopLevel())
|
||||||
|
{
|
||||||
|
// Must be removed prior to RemoveChild and next AddChild call
|
||||||
|
// Otherwise the next AddChild may freeze the wrong window
|
||||||
|
wxWindowMac *mac = (wxWindowMac *)child;
|
||||||
|
if (mac->GetPeer() && mac->GetPeer()->IsOk())
|
||||||
|
mac->GetPeer()->RemoveFromParent();
|
||||||
|
}
|
||||||
|
|
||||||
wxWindowBase::RemoveChild( child ) ;
|
wxWindowBase::RemoveChild( child ) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2458,10 +2467,9 @@ bool wxWindowMac::Reparent(wxWindowBase *newParentBase)
|
|||||||
if ( !wxWindowBase::Reparent(newParent) )
|
if ( !wxWindowBase::Reparent(newParent) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
GetPeer()->RemoveFromParent();
|
|
||||||
GetPeer()->Embed( GetParent()->GetPeer() );
|
GetPeer()->Embed( GetParent()->GetPeer() );
|
||||||
|
|
||||||
MacChildAdded();
|
GetParent()->MacChildAdded();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -490,9 +490,10 @@ void ScintillaWX::NotifyParent(SCNotification scn) {
|
|||||||
// a side effect that the AutoComp will also not be destroyed when switching
|
// a side effect that the AutoComp will also not be destroyed when switching
|
||||||
// to another window, but I think that is okay.
|
// to another window, but I think that is okay.
|
||||||
void ScintillaWX::CancelModes() {
|
void ScintillaWX::CancelModes() {
|
||||||
if (! focusEvent)
|
if (! focusEvent) {
|
||||||
AutoCompleteCancel();
|
AutoCompleteCancel();
|
||||||
ct.CallTipCancel();
|
ct.CallTipCancel();
|
||||||
|
}
|
||||||
Editor::CancelModes();
|
Editor::CancelModes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user