本文整理汇总了C++中TRect::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ TRect::Contains方法的具体用法?C++ TRect::Contains怎么用?C++ TRect::Contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TRect
的用法示例。
在下文中一共展示了TRect::Contains方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PointerL
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;
}
}
}
示例2: GetPixel
/** 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);
}
示例3: DoMouseMoved
void TButton::DoMouseMoved(const TPoint& point, TModifierState state)
{
if (fTrackingMouse)
{
TRect bounds;
GetLocalBounds(bounds);
if (bounds.Contains(point) != fPressed)
{
fPressed = !fPressed;
Redraw();
}
}
}
示例4: HideLines_Edwin
/**
* 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;
}
示例5: HideLines_Ctrl
/**
* 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;
}
示例6: IsPointInDlgItem
/////////////////////////////////////////////////////////////////////
// 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);
}
示例7: GetClientRect
//
/// 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();
}
}
示例8: IdentifyPoint
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;
}
}
}
示例9: FindLastHittingChild
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;
}
示例10: PointerL
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);
}
示例11: HandlePointerEventL
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);
}
示例12: CheckIfHit
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;
}
示例13: CheckIfHit
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;
}