Fixed a mac problem, a variable scoping problem was fixed in the handle method.

This commit is contained in:
dcone%netscape.com 1998-10-07 15:17:27 +00:00
Родитель e75f5217d6
Коммит 8199823d72
1 изменённых файлов: 36 добавлений и 11 удалений

Просмотреть файл

@ -838,13 +838,19 @@ void nsScrollingView :: Notify(nsITimer * aTimer)
NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags, NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEventFlags,
nsEventStatus &aStatus) nsEventStatus &aStatus)
{ {
PRInt32 offX,offY;
nsIWidget *win;
nsIDeviceContext *dx;
float p2t;
switch (aEvent->message) switch (aEvent->message)
{ {
case NS_MOUSE_LEFT_BUTTON_DOWN: case NS_MOUSE_LEFT_BUTTON_DOWN:
case NS_MOUSE_MIDDLE_BUTTON_DOWN: case NS_MOUSE_MIDDLE_BUTTON_DOWN:
case NS_MOUSE_RIGHT_BUTTON_DOWN: case NS_MOUSE_RIGHT_BUTTON_DOWN:
{ {
nsIWidget *win;
GetWidget(win); GetWidget(win);
if (nsnull != win) if (nsnull != win)
@ -887,7 +893,6 @@ NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEvent
case NS_VK_DOWN : case NS_VK_DOWN :
case NS_VK_UP : { case NS_VK_UP : {
nsIScrollbar *scrollv = nsnull, *scrollh = nsnull; nsIScrollbar *scrollv = nsnull, *scrollh = nsnull;
nsIWidget *win;
mVScrollBarView->GetWidget(win); mVScrollBarView->GetWidget(win);
if (NS_OK == win->QueryInterface(kIScrollbarIID, (void **)&scrollv)) if (NS_OK == win->QueryInterface(kIScrollbarIID, (void **)&scrollv))
@ -916,26 +921,38 @@ NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEvent
case NS_MOUSE_MOVE: case NS_MOUSE_MOVE:
{ {
nsRect trect; nsRect brect;
nscoord lx, ly; nscoord lx, ly;
GetBounds(trect); GetWidget(win);
lx = aEvent->point.x - trect.x; GetBounds(brect);
ly = aEvent->point.y - trect.y;
// get the offset for this view, since we are not 0,0 based on the mac
mViewManager->GetDeviceContext(dx);
dx->GetDevUnitsToAppUnits(p2t);
offX = offY = 0;
win->ConvertToDeviceCoordinates(offX,offY);
offX = NSIntPixelsToTwips(offX, p2t);
offY = NSIntPixelsToTwips(offY, p2t);
lx = aEvent->point.x - (brect.x+offX);
ly = aEvent->point.y - (brect.y+offY);
//nscoord xoff, yoff; //nscoord xoff, yoff;
//GetScrolledView()->GetScrollOffset(&xoff, &yoff); //GetScrolledView()->GetScrollOffset(&xoff, &yoff);
//printf("%d %d %d\n", trect.y, trect.height, yoff); //printf("%d %d %d\n", trect.y, trect.height, yoff);
//printf("mouse %d %d \n", aEvent->point.x, aEvent->point.y); //printf("mouse %d %d \n", aEvent->point.x, aEvent->point.y);
if (!trect.Contains(lx, ly)) if (!brect.Contains(lx, ly))
{ {
if (mScrollingTimer == nsnull) if (mScrollingTimer == nsnull)
{ {
if (nsnull != mClientData) if (nsnull != mClientData)
{ {
if (ly < 0 || ly > trect.y) if (ly < 0 || ly > brect.y)
{ {
mScrollingDelta = ly < 0 ? -100 : 100; mScrollingDelta = ly < 0 ? -100 : 100;
NS_NewTimer(&mScrollingTimer); NS_NewTimer(&mScrollingTimer);
@ -968,8 +985,16 @@ NS_IMETHODIMP nsScrollingView :: HandleEvent(nsGUIEvent *aEvent, PRUint32 aEvent
GetBounds(trect); GetBounds(trect);
lx = aEvent->point.x - trect.x; GetWidget(win);
ly = aEvent->point.y - trect.y; mViewManager->GetDeviceContext(dx);
dx->GetDevUnitsToAppUnits(p2t);
offX = offY = 0;
win->ConvertToDeviceCoordinates(offX,offY);
offX = NSIntPixelsToTwips(offX, p2t);
offY = NSIntPixelsToTwips(offY, p2t);
lx = aEvent->point.x - (trect.x+offX);
ly = aEvent->point.y - (trect.y+offY);
if (!trect.Contains(lx, ly)) if (!trect.Contains(lx, ly))
{ {