diff --git a/widget/src/mac/nsButton.cpp b/widget/src/mac/nsButton.cpp index 442a36963a18..d7524e27e27e 100644 --- a/widget/src/mac/nsButton.cpp +++ b/widget/src/mac/nsButton.cpp @@ -73,6 +73,7 @@ void nsButton::Create(nsIWidget *aParent, nsIToolkit *aToolkit, nsWidgetInitData */*aInitData*/) { + mParent = aParent; aParent->AddChild(this); @@ -83,7 +84,7 @@ void nsButton::Create(nsIWidget *aParent, } else if (aAppShell) { window = (WindowPtr) aAppShell->GetNativeData(NS_NATIVE_SHELL); } - + mIsMainWindow = PR_FALSE; mWindowMadeHere = PR_TRUE; mWindowRecord = (WindowRecord*)window; @@ -155,6 +156,7 @@ PRBool nsButton::OnResize(nsSizeEvent &aEvent) return PR_FALSE; } +#ifdef NOTNOW /* * @update gpk 08/27/98 * @param aX -- x offset in widget local coordinates @@ -167,12 +169,16 @@ nsButton::PtInWindow(PRInt32 aX,PRInt32 aY) PRBool result = PR_FALSE; nsPoint hitPt(aX,aY); nsRect bounds; + PRInt32 offx,offy; + CalcOffset(offx,offy); GetBounds(bounds); + bounds.MoveBy(offx,offy); if(bounds.Contains(hitPt)) result = PR_TRUE; return(result); } +#endif PRBool nsButton::DispatchMouseEvent(nsMouseEvent &aEvent) @@ -185,6 +191,7 @@ PRBool result; mMouseDownInButton = PR_TRUE; DrawWidget(PR_TRUE); result = nsWindow::DispatchMouseEvent(aEvent); + result = nsEventStatus_eConsumeDoDefault; break; case NS_MOUSE_LEFT_BUTTON_UP: mMouseDownInButton = PR_FALSE; @@ -218,21 +225,25 @@ void nsButton::DrawWidget(PRBool aMouseInside) { PRInt16 width,x,y; +PRInt32 offx,offy; nsRect therect; -Rect macrect; +Rect macrect,crect; GrafPtr theport; RGBColor blackcolor = {0,0,0}; RgnHandle thergn; -//FontInfo fi; - +//FontInfo fi; + CalcOffset(offx,offy); GetPort(&theport); ::SetPort(mWindowPtr); + ::SetOrigin(-offx,-offy); GetBounds(therect); nsRectToMacRect(therect,macrect); + + crect = macrect; thergn = ::NewRgn(); ::GetClip(thergn); - ::ClipRect(¯ect); + ::ClipRect(&crect); ::PenNormal(); ::RGBForeColor(&blackcolor); @@ -262,6 +273,7 @@ RgnHandle thergn; ::PenSize(1,1); ::SetClip(thergn); + ::SetOrigin(0,0); ::SetPort(theport); } diff --git a/widget/src/mac/nsButton.h b/widget/src/mac/nsButton.h index 96730b6b18cb..72d740333549 100644 --- a/widget/src/mac/nsButton.h +++ b/widget/src/mac/nsButton.h @@ -64,7 +64,7 @@ public: // Overriden from nsWindow - virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY); + //virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY); private: diff --git a/widget/src/mac/nsCheckButton.cpp b/widget/src/mac/nsCheckButton.cpp index a15f69347f6f..5f03f13d755b 100644 --- a/widget/src/mac/nsCheckButton.cpp +++ b/widget/src/mac/nsCheckButton.cpp @@ -209,6 +209,7 @@ PRBool nsCheckButton::OnResize(nsSizeEvent &aEvent) return PR_FALSE; } +#ifdef NOTNOW /* @@ -229,6 +230,7 @@ nsCheckButton::PtInWindow(PRInt32 aX,PRInt32 aY) result = PR_TRUE; return(result); } +#endif PRBool nsCheckButton::DispatchMouseEvent(nsMouseEvent &aEvent) @@ -241,6 +243,7 @@ PRBool result; mMouseDownInButton = PR_TRUE; DrawWidget(PR_TRUE); result = nsWindow::DispatchMouseEvent(aEvent); + result = nsEventStatus_eConsumeDoDefault; break; case NS_MOUSE_LEFT_BUTTON_UP: mMouseDownInButton = PR_FALSE; @@ -276,6 +279,7 @@ void nsCheckButton::DrawWidget(PRBool aMouseInside) { PRInt16 width,x,y,buttonsize=14; +PRInt32 offx,offy; nsRect therect; Rect macrect,rb; GrafPtr theport; @@ -283,9 +287,10 @@ RGBColor blackcolor = {0,0,0}; RgnHandle thergn; Str255 tempstring; - + CalcOffset(offx,offy); GetPort(&theport); ::SetPort(mWindowPtr); + ::SetOrigin(-offx,-offy); GetBounds(therect); nsRectToMacRect(therect,macrect); thergn = ::NewRgn(); @@ -325,6 +330,7 @@ Str255 tempstring; ::PenSize(1,1); ::SetClip(thergn); + ::SetOrigin(0,0); ::SetPort(theport); } diff --git a/widget/src/mac/nsCheckButton.h b/widget/src/mac/nsCheckButton.h index 45ab8463a3ec..eb9d998bba75 100644 --- a/widget/src/mac/nsCheckButton.h +++ b/widget/src/mac/nsCheckButton.h @@ -67,7 +67,7 @@ public: virtual PRBool DispatchMouseEvent(nsMouseEvent &aEvent); // Overriden from nsWindow - virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY); + //virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY); // Mac specific methods void LocalToWindowCoordinate(nsPoint& aPoint);