Put in code to offset drawing, hittest, etc

This commit is contained in:
dcone%netscape.com 1998-09-23 22:08:53 +00:00
parent 06c2b4210f
commit f63fe299a7
4 changed files with 26 additions and 8 deletions

View File

@ -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(&macrect);
::ClipRect(&crect);
::PenNormal();
::RGBForeColor(&blackcolor);
@ -262,6 +273,7 @@ RgnHandle thergn;
::PenSize(1,1);
::SetClip(thergn);
::SetOrigin(0,0);
::SetPort(theport);
}

View File

@ -64,7 +64,7 @@ public:
// Overriden from nsWindow
virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
//virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
private:

View File

@ -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);
}

View File

@ -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);