void CStatusWindow::PointerL(const TPointerEvent &aPointer,const TTime &aTime) { #if defined(__WINS__) if (iRect1.Contains(aPointer.iPosition)) { if (aPointer.iType==TPointerEvent::EButton1Down) ChangeXyInputType(); } else #endif if (iRect2.Contains(aPointer.iPosition)) { if (aPointer.iType==TPointerEvent::EButton1Down) ChangePointerCursorMode(); } else if (iRect4.Contains(aPointer.iPosition)) iExit=ETrue; else CTTitledWindow::PointerL(aPointer,aTime); if ((iUpdateNeeded || iExit) && aPointer.iType==TPointerEvent::EButton1Up) { if (iExit) iTest->Request(); else { Client()->iWs.SetPointerCursorMode(iMode); #if defined(__WINS__) Client()->iWs.SimulateXyInputType(iXyInputType); #endif Client()->iWs.Flush(); iUpdateNeeded=EFalse; } } }
/** Gets the RGB colour of an individual pixel on a bitmapped graphics device. The function provides a concrete implementation of the pure virtual function CBitmapDevice::GetPixel(). */ EXPORT_C void CFbsBitmapDevice::GetPixel(TRgb& aColor,const TPoint& aPoint) const { TRect deviceRect; iDrawDevice->GetDrawRect(deviceRect); if (!deviceRect.Contains(aPoint)) return; iFbsBmp->BeginDataAccess(); ((CFbsBitmapDevice*)this)->SetBits(); aColor = iDrawDevice->ReadPixel(aPoint.iX,aPoint.iY); iFbsBmp->EndDataAccess(ETrue); }
void TButton::DoMouseMoved(const TPoint& point, TModifierState state) { if (fTrackingMouse) { TRect bounds; GetLocalBounds(bounds); if (bounds.Contains(point) != fPressed) { fPressed = !fPressed; Redraw(); } } }
/** * Sets a clipping rectangle for hiding the whole or a part of edwin's text. * * The reason for using this function is the multiline edwins. The text inside * an edwin can be broken to two or more lines, which must be hidden or shown * independently from each other. That is why it is not enough just to move * the whole edwin out of the screen. * * @param aClipRect The clipping rect for edwin's text. An empty rect disables * hiding. * * @return How many subcontrols were hidden */ static TInt HideLines_Edwin(CEikEdwin *aEdwin, TRect aClipRect) { aEdwin->SetTextLinesRect(aClipRect); // Create rects of the first and last edwin lines TPoint edwinTl( aEdwin->Rect().iTl ); TPoint edwinBr( aEdwin->Rect().iBr ); TRect textFirstLine; aEdwin->TextLayout()->GetLineRect(edwinTl.iY, textFirstLine); textFirstLine.Move( edwinTl.iX, edwinTl.iY + aEdwin->Margins().iTop ); TRect textLastLine; aEdwin->TextLayout()->GetLineRect(edwinBr.iY, textLastLine); textLastLine.Move( edwinBr.iX, edwinBr.iY - aEdwin->Margins().iTop - textLastLine.Height() ); // Check if at least one line fits to the clipping rect if( aClipRect.Contains(textFirstLine.iTl) && aClipRect.iBr.iY >= textFirstLine.iBr.iY ) // The first line fits return 0; if( aClipRect.Contains(textLastLine.iTl) && aClipRect.iBr.iY >= textLastLine.iBr.iY ) // The last line fits return 0; return 1; }
/** * Tries to hide the specified control. The control will be hidden, if it doesn't * fit to the specified clipping rectangle. Checks if the control exists. * * @return How many subcontrols were hidden */ static TInt HideLines_Ctrl(CCoeControl *aControl, TRect aClipRect) { if ( !aControl ) return 1; // It doesn't exist and hence not visible TRect rect( aControl->Rect() ); if ( !aClipRect.Contains(rect.iTl) || aClipRect.iBr.iY <= rect.iBr.iY ) // Never use TRect::Contains() for checking the bottom right corner, see documentation { // hide it aControl->SetPosition( TPoint(-666,-666) ); return 1; } else return 0; }
///////////////////////////////////////////////////////////////////// // TPreferencesDialog // ------------------ // Look if the dialog control 'resid' window contains the point // 'clientPoint', which is a dialog client coord. of the point BOOL TPreferencesDialog::IsPointInDlgItem (int itemId, TPoint &clientPoint) { HWND hWnd = GetDlgItem (itemId); if ( hWnd == (HWND)NULL ) return FALSE; TWindow wnd(hWnd); TRect wRect; wnd.GetWindowRect (wRect); TPoint TopLeft (wRect.left, wRect.top); TPoint BotRight(wRect.right, wRect.bottom); ScreenToClient (TopLeft); ScreenToClient (BotRight); TRect cRect (TopLeft, BotRight); return cRect.Contains (clientPoint); }
// /// Handles WM_MOUSEMOVE to monitor mouse location when processing mouse down/dblclk /// requests. Updates state of button if we're in 'capture' mode. // void TUrlLink::EvMouseMove(uint modKeys, const TPoint& point) { TStatic::EvMouseMove(modKeys, point); if(bOverControl){ TRect rect; GetClientRect(rect); if(!rect.Contains(point)){ ReleaseCapture(); bOverControl = false; Invalidate(); } } else{ SetCapture(); bOverControl = true; Invalidate(); } }
ScrollBarPart TScrollBar::IdentifyPoint(const TPoint& point, TRect& outTrackingRect) const { GetArrow1(outTrackingRect); if (outTrackingRect.Contains(point)) return kArrow1; GetArrow2(outTrackingRect); if (outTrackingRect.Contains(point)) return kArrow2; TRect thumb; GetThumb(thumb); if (thumb.Contains(point)) { outTrackingRect = thumb; return kThumb; } TRect thumbArea; GetThumbArea(thumbArea); if (! thumbArea.Contains(point)) return kNone; if (IsVertical()) { outTrackingRect.Set(thumbArea.left, thumbArea.top, thumbArea.right, thumb.top); if (outTrackingRect.Contains(point)) return kPageUp; else { outTrackingRect.top = thumb.bottom; outTrackingRect.bottom = thumbArea.bottom; return kPageDown; } } else { outTrackingRect.Set(thumbArea.left, thumbArea.top, thumb.left, thumbArea.bottom); if (outTrackingRect.Contains(point)) return kPageUp; else { outTrackingRect.left = thumb.right; outTrackingRect.right = thumbArea.right; return kPageDown; } } }
CHuiVisual* FindLastHittingChild( const CHuiVisual& aParentVisual, const TPoint& aDisplayPoint ) { // If we want that the pointer event are passed only to the visuals which // (effective) opacity is greater than 50%, this would be the place to // implement it. for ( TInt i = aParentVisual.Count() - 1 ; i >= 0 ; i-- ) { // DisplayRect() returns the current value of the rectange. If the pointer // hit needs to be compared to the target rect, change this function call // from DisplayRect() into DisplayRectTarget() const TRect rect = aParentVisual.Visual( i ).DisplayRect(); if ( rect.Contains( aDisplayPoint ) ) { CHuiVisual* leaf = FindLastHittingChild( aParentVisual.Visual( i ), aDisplayPoint ); return leaf ? leaf : &aParentVisual.Visual( i ); } } return NULL; }
void CListWindow::PointerL(const TPointerEvent &aPointer,const TTime& aTime) { if (aPointer.iType==TPointerEvent::EButton1Down) { TRect rect; for(TInt index=0; index<ListCount(); index++) { RowBox(rect,index); if (rect.Contains(aPointer.iPosition)) { if (index==iListPos && aPointer.iModifiers&EModifierDoubleClick) SelectedL(iListPos); else { iPrevTime=aTime; SetListPos(index); } return; } } } CTTitledWindow::PointerL(aPointer,aTime); }
void CSliderControl::HandlePointerEventL(const TPointerEvent& aEvent) { TRawEvent ev; TInt x,y,middle,key; TRect cba; x=Position().iX+aEvent.iPosition.iX; y=Position().iY+aEvent.iPosition.iY; AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EControlPane,cba); middle=CEikonEnv::Static()->ScreenDevice()->SizeInPixels().iWidth/2; if (cba.Contains(TPoint(x,y))&&(aEvent.iType==aEvent.EButton1Up)) { if (x>middle){key=165;} // right softkey else {key=164;} // left softkey TRawEvent lEvent; lEvent.Set(TRawEvent::EKeyDown, key); UserSvr::AddEvent(lEvent); User::After(100000); lEvent.Set(TRawEvent::EKeyUp, key); UserSvr::AddEvent(lEvent); } CCoeControl::HandlePointerEventL(aEvent); }
TBool CScrollBar::CheckIfHit(const STouchEventLocationConverted& aTouchEvent) { TInt lX = iTextureObject->ReturnLowerLeftCoordinate().iX.GetIntInBaseInt(); TInt lY = iTextureObject->ReturnLowerLeftCoordinate().iY.GetIntInBaseInt(); TRect lHitBox = TRect(TPoint(lX,lY + iSizeOfHitBox.iHeight), iSizeOfHitBox.iWidth, iSizeOfHitBox.iHeight); //need to add Height, since we want iY to be the bottom left corner TBool lHasBeenTouched = lHitBox.Contains(aTouchEvent.VirtualLocation); switch(aTouchEvent.Type) { case ETouchEventHandlerTouchTypeDown: { if(lHasBeenTouched) { iLastPositionDrag = aTouchEvent.VirtualLocation; iState = EStateSelected; iIdOfFinger = aTouchEvent.FingerId; } break; } case ETouchEventHandlerTouchTypeDrag: { if(iState == EStateSelected && iIdOfFinger == aTouchEvent.FingerId) { if(iScrollAxis == EScrollAxisY) { if(iLastPositionDrag.iY > aTouchEvent.VirtualLocation.iY) //move everything down { iScrollVariableRef += (iLastPositionDrag.iY - aTouchEvent.VirtualLocation.iY) * iScrollSpeedFactor; if(iScrollVariableRef > iMaxScroll) iScrollVariableRef = iMaxScroll; } else if(iLastPositionDrag.iY < aTouchEvent.VirtualLocation.iY)//move everything up { iScrollVariableRef -= (aTouchEvent.VirtualLocation.iY - iLastPositionDrag.iY) * iScrollSpeedFactor; if(iScrollVariableRef < 0) iScrollVariableRef = 0; } } else { if(iLastPositionDrag.iX < aTouchEvent.VirtualLocation.iX) //move everything to the left { iScrollVariableRef += (aTouchEvent.VirtualLocation.iX - iLastPositionDrag.iX) * iScrollSpeedFactor; if(iScrollVariableRef > iMaxScroll) iScrollVariableRef = iMaxScroll; }else if(iLastPositionDrag.iX > aTouchEvent.VirtualLocation.iX) //move everything to the right { iScrollVariableRef -= (iLastPositionDrag.iX - aTouchEvent.VirtualLocation.iX) * iScrollSpeedFactor; if(iScrollVariableRef < 0) iScrollVariableRef = 0; } } iLastPositionDrag = aTouchEvent.VirtualLocation; } break; } case ETouchEventHandlerTouchTypeUp: { if(iIdOfFinger == aTouchEvent.FingerId) { iState = EStateDefault; } break; } } //always update ScrollBar Location, this way even if other objective modify the relative location the scroll bar will be updated as well UpdateLocation(); return lHasBeenTouched; }
TBool CTouchSurface::CheckIfHit(const STouchEventLocationConverted& aTouchEvent) { TInt lX = iX.GetIntInBaseInt(); TInt lY = iY.GetIntInBaseInt(); TRect lHitBox = TRect(TPoint(lX,lY + iSizeOfSurface.iHeight), iSizeOfSurface.iWidth, iSizeOfSurface.iHeight); //need to add Height, since we want iY to be the bottom left corner TBool lHasBeenTouched = lHitBox.Contains(aTouchEvent.VirtualLocation); switch(aTouchEvent.Type) { case ETouchEventHandlerTouchTypeDown: { if(lHasBeenTouched) { iLastPositionDrag = aTouchEvent.VirtualLocation; iTouched = true; iIdOfFinger = aTouchEvent.FingerId; } break; } case ETouchEventHandlerTouchTypeDrag: { if(iTouched && iIdOfFinger == aTouchEvent.FingerId) { if(iScrollAxis == EScrollAxisY) { if(iLastPositionDrag.iY > aTouchEvent.VirtualLocation.iY) //move everything up { iScrollVariableRef -= (iLastPositionDrag.iY - aTouchEvent.VirtualLocation.iY) * iScrollSpeedFactor; if(iScrollVariableRef < 0) iScrollVariableRef = 0; } else if(iLastPositionDrag.iY < aTouchEvent.VirtualLocation.iY)//move everything down { iScrollVariableRef += (aTouchEvent.VirtualLocation.iY - iLastPositionDrag.iY) * iScrollSpeedFactor; if(iScrollVariableRef > iMaxScroll) iScrollVariableRef = iMaxScroll; } } else { if(iLastPositionDrag.iX < aTouchEvent.VirtualLocation.iX) //move everything to the right { iScrollVariableRef -= (aTouchEvent.VirtualLocation.iX - iLastPositionDrag.iX) * iScrollSpeedFactor; if(iScrollVariableRef < 0) iScrollVariableRef = 0; }else if(iLastPositionDrag.iX > aTouchEvent.VirtualLocation.iX) //move everything to the left { iScrollVariableRef += (iLastPositionDrag.iX - aTouchEvent.VirtualLocation.iX) * iScrollSpeedFactor; if(iScrollVariableRef > iMaxScroll) iScrollVariableRef = iMaxScroll; } } iLastPositionDrag = aTouchEvent.VirtualLocation; } break; } case ETouchEventHandlerTouchTypeUp: { if(iIdOfFinger == aTouchEvent.FingerId) { iTouched = false; } break; } } return lHasBeenTouched; }