зеркало из https://github.com/mozilla/pjs.git
Paint suppression lives! Making cocoa widgets properly show/hide and work with paint suppression.
This commit is contained in:
Родитель
220ffd5fbc
Коммит
7b96c30f32
|
@ -147,6 +147,8 @@ public:
|
|||
NS_IMETHOD Show(PRBool aState);
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
|
||||
virtual nsIWidget* GetParent(void);
|
||||
|
||||
NS_IMETHOD ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
||||
PRBool *aForWindow);
|
||||
|
||||
|
@ -250,6 +252,8 @@ protected:
|
|||
|
||||
id mView; // my parallel cocoa view, [STRONG]
|
||||
|
||||
NSView* mParentView;
|
||||
|
||||
PRBool mDestroyCalled;
|
||||
PRBool mDestructorCalled;
|
||||
PRBool mVisible;
|
||||
|
|
|
@ -137,7 +137,9 @@ nsChildView::nsChildView() : nsBaseWidget() , nsDeleteObserved(this)
|
|||
|
||||
mWindow = nil;
|
||||
mView = nil;
|
||||
|
||||
|
||||
mParentView = nil;
|
||||
|
||||
mDestroyCalled = PR_FALSE;
|
||||
mDestructorCalled = PR_FALSE;
|
||||
mVisible = PR_FALSE;
|
||||
|
@ -162,7 +164,7 @@ nsChildView::nsChildView() : nsBaseWidget() , nsDeleteObserved(this)
|
|||
nsChildView::~nsChildView()
|
||||
{
|
||||
if ( mView ) {
|
||||
[mView removeFromSuperview];
|
||||
[mView removeFromSuperviewWithoutNeedingDisplay];
|
||||
[mView release];
|
||||
}
|
||||
|
||||
|
@ -216,7 +218,7 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
|
|||
|
||||
// inherit things from the parent view and create our parallel
|
||||
// NSView in the Cocoa display system
|
||||
NSView* parentView = nsnull;
|
||||
mParentView = nil;
|
||||
if ( aParent ) {
|
||||
SetBackgroundColor(aParent->GetBackgroundColor());
|
||||
SetForegroundColor(aParent->GetForegroundColor());
|
||||
|
@ -224,8 +226,8 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
|
|||
// inherit the top-level window. NS_NATIVE_WIDGET is always a NSView
|
||||
// regardless of if we're asking a window or a view (for compatibility
|
||||
// with windows).
|
||||
parentView = (NSView*)aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
|
||||
mParentView = (NSView*)aParent->GetNativeData(NS_NATIVE_WIDGET);
|
||||
|
||||
#if 0
|
||||
// get the event sink for our view. Walk up the parent chain to the
|
||||
// toplevel window, it's the sink.
|
||||
|
@ -241,10 +243,10 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
|
|||
#endif
|
||||
|
||||
}
|
||||
else
|
||||
parentView = NS_REINTERPRET_CAST(NSView*,aNativeParent);
|
||||
|
||||
NS_ASSERTION(parentView, "no parent view at all :(");
|
||||
else
|
||||
mParentView = NS_REINTERPRET_CAST(NSView*,aNativeParent);
|
||||
|
||||
NS_ASSERTION(mParentView, "no parent view at all :(");
|
||||
|
||||
// create our parallel NSView and hook it up to our parent. Recall
|
||||
// that NS_NATIVE_WIDGET is the NSView.
|
||||
|
@ -253,10 +255,14 @@ nsresult nsChildView::StandardCreate(nsIWidget *aParent,
|
|||
mView = [CreateCocoaView() retain];
|
||||
[mView setFrame:r];
|
||||
|
||||
NS_ASSERTION(parentView && mView, "couldn't hook up new NSView in hierarchy");
|
||||
if ( parentView && mView ) {
|
||||
[parentView addSubview:mView];
|
||||
mWindow = [parentView window];
|
||||
NS_ASSERTION(mParentView && mView, "couldn't hook up new NSView in hierarchy");
|
||||
if (mParentView && mView ) {
|
||||
if (![mParentView isKindOfClass: [ChildView class]]) {
|
||||
[mParentView addSubview:mView];
|
||||
mVisible = PR_TRUE;
|
||||
}
|
||||
|
||||
mWindow = [mParentView window];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -359,7 +365,10 @@ void* nsChildView::GetNativeData(PRUint32 aDataType)
|
|||
break;
|
||||
|
||||
case NS_NATIVE_WINDOW:
|
||||
retVal = [mView window];
|
||||
if (!mWindow)
|
||||
retVal = [mView window];
|
||||
else
|
||||
retVal = mWindow;
|
||||
break;
|
||||
|
||||
case NS_NATIVE_GRAPHIC: // quickdraw port (for now)
|
||||
|
@ -436,11 +445,22 @@ NS_METHOD nsChildView::IsVisible(PRBool & bState)
|
|||
//
|
||||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsChildView::Show(PRBool bState)
|
||||
{
|
||||
{
|
||||
if (bState != mVisible) {
|
||||
if (bState)
|
||||
[mParentView addSubview: mView];
|
||||
else
|
||||
[mView removeFromSuperviewWithoutNeedingDisplay];
|
||||
}
|
||||
mVisible = bState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsIWidget*
|
||||
nsChildView::GetParent(void)
|
||||
{
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsChildView::ModalEventFilter(PRBool aRealEvent, void *aEvent,
|
||||
PRBool *aForWindow)
|
||||
|
@ -816,7 +836,8 @@ NS_IMETHODIMP nsChildView::Move(PRInt32 aX, PRInt32 aY)
|
|||
{
|
||||
// Invalidate the current location
|
||||
Invalidate(PR_FALSE);
|
||||
[[mView superview] setNeedsDisplayInRect:[mView frame]]; //XXX needed?
|
||||
if (mVisible)
|
||||
[[mView superview] setNeedsDisplayInRect:[mView frame]]; //XXX needed?
|
||||
|
||||
// Set the bounds
|
||||
mBounds.x = aX;
|
||||
|
@ -827,7 +848,9 @@ NS_IMETHODIMP nsChildView::Move(PRInt32 aX, PRInt32 aY)
|
|||
NSRect r;
|
||||
ConvertGeckoToCocoaRect(mBounds, r);
|
||||
[mView setFrame:r];
|
||||
[mView setNeedsDisplay:YES];
|
||||
|
||||
if (mVisible)
|
||||
[mView setNeedsDisplay:YES];
|
||||
|
||||
// Report the event
|
||||
ReportMoveEvent();
|
||||
|
@ -848,14 +871,17 @@ NS_IMETHODIMP nsChildView::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai
|
|||
mBounds.width = aWidth;
|
||||
mBounds.height = aHeight;
|
||||
|
||||
[[mView superview] setNeedsDisplayInRect:[mView frame]]; //XXX needed?
|
||||
if (mVisible)
|
||||
[[mView superview] setNeedsDisplayInRect:[mView frame]]; //XXX needed?
|
||||
|
||||
// Recalculate the regions
|
||||
//CalcWindowRegions();
|
||||
NSRect r;
|
||||
ConvertGeckoToCocoaRect(mBounds, r);
|
||||
[mView setFrame:r];
|
||||
[mView setNeedsDisplay:YES];
|
||||
|
||||
if (mVisible)
|
||||
[mView setNeedsDisplay:YES];
|
||||
|
||||
// Report the event
|
||||
ReportSizeEvent();
|
||||
|
@ -865,7 +891,9 @@ NS_IMETHODIMP nsChildView::Resize(PRInt32 aWidth, PRInt32 aHeight, PRBool aRepai
|
|||
// changed, hence changing our notion of visibility. We then also should make
|
||||
// sure that we invalidate ourselves correctly. Fixes bug 18240 (pinkerton).
|
||||
CalcWindowRegions();
|
||||
[mView setNeedsDisplay:YES];
|
||||
|
||||
if (mVisible)
|
||||
[mView setNeedsDisplay:YES];
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
|
@ -990,9 +1018,9 @@ NS_IMETHODIMP nsChildView::Invalidate(PRBool aIsSynchronous)
|
|||
//-------------------------------------------------------------------------
|
||||
NS_IMETHODIMP nsChildView::Invalidate(const nsRect &aRect, PRBool aIsSynchronous)
|
||||
{
|
||||
if ( !mView )
|
||||
if ( !mView || !mVisible)
|
||||
return NS_OK;
|
||||
|
||||
|
||||
NSRect r;
|
||||
ConvertGeckoToCocoaRect ( aRect, r );
|
||||
|
||||
|
@ -1012,7 +1040,7 @@ NS_IMETHODIMP nsChildView::Invalidate(const nsRect &aRect, PRBool aIsSynchronous
|
|||
|
||||
NS_IMETHODIMP nsChildView::InvalidateRegion(const nsIRegion *aRegion, PRBool aIsSynchronous)
|
||||
{
|
||||
if ( !mView )
|
||||
if ( !mView || !mVisible)
|
||||
return NS_OK;
|
||||
|
||||
//FIXME rewrite to use a Cocoa region when nsIRegion isn't a QD Region
|
||||
|
|
|
@ -116,7 +116,7 @@ public:
|
|||
|
||||
NS_IMETHOD Enable(PRBool aState) { return NS_OK; }
|
||||
NS_IMETHOD SetModal(PRBool aState) { return NS_OK; }
|
||||
NS_IMETHOD IsVisible(PRBool & aState) { return NS_OK; }
|
||||
NS_IMETHOD IsVisible(PRBool & aState);
|
||||
NS_IMETHOD SetFocus(PRBool aState=PR_FALSE) { return NS_OK; }
|
||||
NS_IMETHOD SetMenuBar(nsIMenuBar * aMenuBar) { return NS_OK; }
|
||||
NS_IMETHOD ShowMenuBar(PRBool aShow) { return NS_OK; }
|
||||
|
@ -203,6 +203,7 @@ protected:
|
|||
NSWindow* mWindow; // our cocoa window [STRONG]
|
||||
WindowDelegate* mDelegate; // our delegate for processing window msgs [STRONG]
|
||||
|
||||
PRBool mVisible; // Whether or not we're visible.
|
||||
};
|
||||
|
||||
#endif // MacWindow_h__
|
||||
|
|
|
@ -305,6 +305,8 @@ nsCocoaWindow::nsCocoaWindow()
|
|||
, mWindowMadeHere(PR_FALSE)
|
||||
, mWindow(nil)
|
||||
{
|
||||
printf("COCOA WINDOW GOT MADE!\n");
|
||||
|
||||
#if 0
|
||||
mMacEventHandler.reset(new nsMacEventHandler(this));
|
||||
WIDGET_SET_CLASSNAME("nsCocoaWindow");
|
||||
|
@ -401,6 +403,8 @@ nsresult nsCocoaWindow::StandardCreate(nsIWidget *aParent,
|
|||
[content setFrame:[[mWindow contentView] frame]];
|
||||
[mWindow setContentView:content];
|
||||
|
||||
NSLog(@"New quickdraw view. %@", content);
|
||||
|
||||
// register for mouse-moved events. The default is to ignore them for perf reasons.
|
||||
[mWindow setAcceptsMouseMovedEvents:YES];
|
||||
|
||||
|
@ -853,7 +857,13 @@ nsCocoaWindow::GetNativeData(PRUint32 aDataType)
|
|||
return retVal;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsCocoaWindow::IsVisible(PRBool & aState)
|
||||
{
|
||||
aState = mVisible;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------
|
||||
//
|
||||
// Hide or show this window
|
||||
|
@ -865,7 +875,9 @@ NS_IMETHODIMP nsCocoaWindow::Show(PRBool bState)
|
|||
[mWindow orderFront:NULL];
|
||||
else
|
||||
[mWindow orderOut:NULL];
|
||||
|
||||
|
||||
mVisible = bState;
|
||||
|
||||
#if 0
|
||||
// we need to make sure we call ::Show/HideWindow() to generate the
|
||||
// necessary activate/deactivate events. Calling ::ShowHide() is
|
||||
|
|
|
@ -496,8 +496,9 @@ nsScrollbar::Show(PRBool bState)
|
|||
if ( mParentView )
|
||||
[mParentView addSubview:mView];
|
||||
}
|
||||
|
||||
return Inherited::Show(bState);
|
||||
|
||||
mVisible = bState;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче