mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-11 20:35:50 +00:00
Put in code to offset drawing, hittest, etc
This commit is contained in:
parent
06c2b4210f
commit
f63fe299a7
@ -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);
|
||||
}
|
||||
|
||||
|
@ -64,7 +64,7 @@ public:
|
||||
|
||||
|
||||
// Overriden from nsWindow
|
||||
virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
|
||||
//virtual PRBool PtInWindow(PRInt32 aX,PRInt32 aY);
|
||||
|
||||
|
||||
private:
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user