本文整理汇总了C++中BRect::Contains方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::Contains方法的具体用法?C++ BRect::Contains怎么用?C++ BRect::Contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BRect
的用法示例。
在下文中一共展示了BRect::Contains方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// _Select
void
PathManipulator::_Select(BRect r)
{
BPoint p;
BPoint pIn;
BPoint pOut;
int32 count = fPath->CountPoints();
Selection temp;
for (int32 i = 0; i < count && fPath->GetPointsAt(i, p, pIn, pOut); i++) {
if (r.Contains(p) || r.Contains(pIn) || r.Contains(pOut)) {
temp.Add(i);
}
}
// merge old and new selection
count = fOldSelection->CountItems();
for (int32 i = 0; i < count; i++) {
int32 index = fOldSelection->IndexAt(i);
if (temp.Contains(index))
temp.Remove(index);
else
temp.Add(index);
}
if (temp != *fSelection) {
*fSelection = temp;
_UpdateSelection();
}
}
示例2: ColumnIconFrameAt
bool
PatchView::GetToolTipAt(BPoint point, BToolTip** tip)
{
bool found = false;
int32 index = 0;
endpoint_itor begin, end;
int32 size = fConsumers.size();
for (int32 i = 0; !found && i < size; i++) {
BRect r = ColumnIconFrameAt(i);
if (r.Contains(point)) {
begin = fConsumers.begin();
end = fConsumers.end();
found = true;
index = i;
}
}
size = fProducers.size();
for (int32 i = 0; !found && i < size; i++) {
BRect r = RowIconFrameAt(i);
if (r.Contains(point)) {
begin = fProducers.begin();
end = fProducers.end();
found = true;
index = i;
}
}
if (!found)
return false;
endpoint_itor itor;
for (itor = begin; itor != end; itor++, index--)
if (index <= 0)
break;
if (itor == end)
return false;
BMidiRoster* roster = BMidiRoster::MidiRoster();
if (roster == NULL)
return false;
BMidiEndpoint* obj = roster->FindEndpoint(itor->ID());
if (obj == NULL)
return false;
BString str;
str << "<" << obj->ID() << ">: " << obj->Name();
obj->Release();
SetToolTip(str.String());
*tip = ToolTip();
return true;
}
示例3: Window
/*****************************************************************************
* PlaylistView::MouseDown
*****************************************************************************/
void
PlaylistView::MouseDown( BPoint where )
{
int32 clicks = 1;
Window()->CurrentMessage()->FindInt32( "clicks", &clicks );
bool handled = false;
for ( int32 i = 0; PlaylistItem* item = (PlaylistItem*)ItemAt( i ); i++ )
{
BRect r = ItemFrame( i );
if ( r.Contains( where ) )
{
if ( clicks == 2 )
{
// only do something if user clicked the same item twice
if ( fLastClickedItem == item )
{
playlist_t * p_playlist;
p_playlist = (playlist_t *) vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
playlist_Goto( p_playlist, i );
vlc_object_release( p_playlist );
}
handled = true;
}
}
else
{
// remember last clicked item
fLastClickedItem = item;
if ( i == fCurrentIndex )
{
r.right = r.left + TEXT_OFFSET;
if ( r.Contains ( where ) )
{
fMainWindow->PostMessage( PAUSE_PLAYBACK );
InvalidateItem( i );
handled = true;
}
}
}
break;
}
}
if ( !handled )
DragSortableListView::MouseDown(where);
}
示例4: WidgetFor
bool
BPose::PointInPose(BPoint loc, const BPoseView* poseView, BPoint where,
BTextWidget** hitWidget) const
{
if (hitWidget)
*hitWidget = NULL;
// check intersection with icon
BRect rect;
rect.left = loc.x + kListOffset;
rect.right = rect.left + B_MINI_ICON;
rect.bottom = loc.y + poseView->ListElemHeight();
rect.top = rect.bottom - B_MINI_ICON;
if (rect.Contains(where))
return true;
for (int32 index = 0; ; index++) {
BColumn* column = poseView->ColumnAt(index);
if (column == NULL)
break;
BTextWidget* widget = WidgetFor(column->AttrHash());
if (widget
&& widget->CalcClickRect(loc, column, poseView).Contains(where)) {
if (hitWidget)
*hitWidget = widget;
return true;
}
}
return false;
}
示例5: Frame
void
BRadioButton::MouseDown(BPoint where)
{
if (!IsEnabled() || !QueryCurrentMouse(true, B_PRIMARY_MOUSE_BUTTON)) return;
#if 0
font_height fontHeight;
GetFontHeight(&fontHeight);
float sHeight = fontHeight.ascent + fontHeight.descent;
BRect rect = Frame().OffsetToSelf(B_ORIGIN);
rect.InsetBy(5, (rect.Height() - sHeight) / 2);
if (rect.IsValid() == false) return;
rect.right = rect.left + rect.Height();
if (rect.Contains(where) == false) return;
#endif
if ((Flags() &B_NAVIGABLE) && !IsFocus()) MakeFocus();
// SetValue((Value() == B_CONTROL_ON) ?B_CONTROL_OFF :B_CONTROL_ON);
if (Value() == B_CONTROL_ON) return;
SetValue(B_CONTROL_ON);
Invoke();
}
示例6: winpt
BView *
DTipWatcherView::ViewForPoint(BPoint pt)
{
int32 winIndex = 0;
BView *view = NULL;
BWindow *win = be_app->WindowAt(winIndex++);
while (win)
{
// Took a hint from Marco Nelissen's BubbleHelper -- the app may have a window that isn't running
// lying around
if (!win->IsHidden() && win->LockWithTimeout(1000000) == B_OK)
{
BRect r = win->Frame();
if (r.Contains(pt))
{
BPoint winpt(pt.x - r.left, pt.y - r.top);
view = win->FindView(winpt);
}
win->Unlock();
}
if (view)
break;
win = be_app->WindowAt(winIndex++);
}
return view;
}
示例7: Window
void
TBarView::MouseMoved(BPoint where, uint32 transit, const BMessage* dragMessage)
{
if (fDragRegion->IsDragging()) {
fDragRegion->MouseMoved(where, transit, dragMessage);
return;
}
if (transit == B_ENTERED_VIEW && EventMask() == 0)
SetEventMask(B_POINTER_EVENTS, B_NO_POINTER_HISTORY);
desk_settings* settings = ((TBarApp*)be_app)->Settings();
bool alwaysOnTop = settings->alwaysOnTop;
bool autoRaise = settings->autoRaise;
bool autoHide = settings->autoHide;
if (!autoRaise && !autoHide) {
if (transit == B_EXITED_VIEW || transit == B_OUTSIDE_VIEW)
SetEventMask(0);
return;
}
bool isTopMost = Window()->Feel() == B_FLOATING_ALL_WINDOW_FEEL;
// Auto-Raise
where = ConvertToScreen(where);
BRect screenFrame = (BScreen(Window())).Frame();
if ((where.x == screenFrame.left || where.x == screenFrame.right
|| where.y == screenFrame.top || where.y == screenFrame.bottom)
&& Window()->Frame().Contains(where)) {
// cursor is on a screen edge within the window frame
if (!alwaysOnTop && autoRaise && !isTopMost)
RaiseDeskbar(true);
if (autoHide && IsHidden())
HideDeskbar(false);
} else {
TBarWindow* window = (TBarWindow*)Window();
if (window->IsShowingMenu())
return;
// cursor is not on screen edge
BRect preventHideArea = Window()->Frame().InsetByCopy(
-kMaxPreventHidingDist, -kMaxPreventHidingDist);
if (preventHideArea.Contains(where))
return;
// cursor to bar distance above threshold
if (!alwaysOnTop && autoRaise && isTopMost) {
RaiseDeskbar(false);
SetEventMask(0);
}
if (autoHide && !IsHidden())
HideDeskbar(true);
}
}
示例8: if
status_t
BDragger::_DetermineRelationship()
{
if (fTarget) {
if (fTarget == Parent())
fRelation = TARGET_IS_PARENT;
else if (fTarget == ChildAt(0))
fRelation = TARGET_IS_CHILD;
else
fRelation = TARGET_IS_SIBLING;
} else {
if (fRelation == TARGET_IS_PARENT)
fTarget = Parent();
else if (fRelation == TARGET_IS_CHILD)
fTarget = ChildAt(0);
else
return B_ERROR;
}
if (fRelation == TARGET_IS_PARENT) {
BRect bounds (Frame());
BRect parentBounds (Parent()->Bounds());
if (!parentBounds.Contains(bounds))
MoveTo(parentBounds.right - bounds.Width(),
parentBounds.bottom - bounds.Height());
}
return B_OK;
}
示例9: Bounds
void
BButton::MouseDown(BPoint point)
{
if (!IsEnabled())
return;
SetValue(B_CONTROL_ON);
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
SetTracking(true);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS);
} else {
BRect bounds = Bounds();
uint32 buttons;
do {
Window()->UpdateIfNeeded();
snooze(40000);
GetMouse(&point, &buttons, true);
bool inside = bounds.Contains(point);
if ((Value() == B_CONTROL_ON) != inside)
SetValue(inside ? B_CONTROL_ON : B_CONTROL_OFF);
} while (buttons != 0);
if (Value() == B_CONTROL_ON)
Invoke();
}
}
示例10: if
void
CaptureView::MouseMoved(BPoint point, uint32 transit,
const BMessage* dragMessage)
{
ConvertToScreen(&point);
if (fMovedOutWhat != 0 && !fMovedOutFrame.Contains(point))
_SendMovedOutNotification();
uint32 modifiers = ::modifiers();
if ((modifiers & fModifierMask) == 0) {
_UpdateLast(point);
return;
}
// TODO: we will need to iterate over all existing screens to find the
// right one!
BScreen screen;
BRect screenFrame = screen.Frame();
uint32 location = kNowhere;
if (point.x <= screenFrame.left && fLastPoint.x > screenFrame.left)
location = kLeftEdge;
else if (point.x >= screenFrame.right && fLastPoint.x < screenFrame.right)
location = kRightEdge;
else if (point.y <= screenFrame.top && fLastPoint.y > screenFrame.top)
location = kTopEdge;
else if (point.y >= screenFrame.bottom && fLastPoint.y < screenFrame.bottom)
location = kBottomEdge;
if (location != kNowhere)
_Notify(location, fLastTeam);
_UpdateLast(point);
}
示例11: GetPointsInRect
int RegionTestcase::GetPointsInRect(BRect theRect, BPoint **pointArrayPtr)
{
*pointArrayPtr = pointArray;
if (!theRect.IsValid()) {
return(0);
}
float xIncrement = (theRect.Width() + 1.0) / (numPointsPerSide - 1);
float yIncrement = (theRect.Height() + 1.0) / (numPointsPerSide - 1);
int numPoints = 0;
for(int i = 0; i < numPointsPerSide; i++) {
float xCoord = theRect.left + (i * xIncrement);
if (i == numPointsPerSide - 1) {
xCoord = theRect.right;
}
for(int j = 0; j < numPointsPerSide; j++) {
float yCoord = theRect.top + (j * yIncrement);
if (j == numPointsPerSide - 1) {
yCoord = theRect.bottom;
}
pointArray[numPoints].Set(floor(xCoord), floor(yCoord));
assert(theRect.Contains(pointArray[numPoints]));
numPoints++;
}
}
return(numPoints);
}
示例12: BScreen
bool
make_sure_frame_is_on_screen(BRect& frame, BWindow* window)
{
BScreen* screen = window != NULL ? new BScreen(window)
: new BScreen(B_MAIN_SCREEN_ID);
bool success = false;
if (frame.IsValid() && screen->IsValid()) {
BRect screenFrame = screen->Frame();
if (!screenFrame.Contains(frame)) {
// make sure frame fits in the screen
if (frame.Width() > screenFrame.Width())
frame.right -= frame.Width() - screenFrame.Width() + 10.0;
if (frame.Height() > screenFrame.Height())
frame.bottom -= frame.Height() - screenFrame.Height() + 30.0;
// frame is now at the most the size of the screen
if (frame.right > screenFrame.right)
frame.OffsetBy(-(frame.right - screenFrame.right), 0.0);
if (frame.bottom > screenFrame.bottom)
frame.OffsetBy(0.0, -(frame.bottom - screenFrame.bottom));
if (frame.left < screenFrame.left)
frame.OffsetBy((screenFrame.left - frame.left), 0.0);
if (frame.top < screenFrame.top)
frame.OffsetBy(0.0, (screenFrame.top - frame.top));
}
success = true;
}
delete screen;
return success;
}
示例13: MouseMoved
void DormantNodeView::MouseMoved(
BPoint point,
uint32 transit,
const BMessage *message) {
D_HOOK(("DormantNodeView::MouseMoved()\n"));
int32 index;
if (!message && ((index = IndexOf(point)) >= 0)) {
DormantNodeListItem *item = dynamic_cast<DormantNodeListItem *>(ItemAt(index));
DormantNodeListItem *last = dynamic_cast<DormantNodeListItem *>(m_lastItemUnder);
BRect r = item->getRealFrame(be_plain_font);
if (item && r.Contains(point)) {
if (item != last) {
if (last)
last->MouseOver(this, point, B_EXITED_VIEW);
item->MouseOver(this, point, B_ENTERED_VIEW);
m_lastItemUnder = item;
}
else {
item->MouseOver(this, point, B_INSIDE_VIEW);
}
}
else if (last) {
last->MouseOver(this, point, B_EXITED_VIEW);
}
}
_inherited::MouseMoved(point, transit, message);
}
示例14: tabSpace
void
Utility::_MakeTabSpaceTransparent(BBitmap* screenshot, BRect frame) const
{
if (!frame.IsValid() || screenshot->ColorSpace() != B_RGBA32)
return;
if (!frame.Contains(tabFrame))
return;
float tabHeight = tabFrame.bottom - tabFrame.top;
BRegion tabSpace(frame);
frame.OffsetBy(0, tabHeight);
tabSpace.Exclude(frame);
tabSpace.Exclude(tabFrame);
frame.OffsetBy(0, -tabHeight);
tabSpace.OffsetBy(-frame.left, -frame.top);
BScreen screen;
BRect screenFrame = screen.Frame();
tabSpace.OffsetBy(-screenFrame.left, -screenFrame.top);
BView view(screenshot->Bounds(), "bitmap", B_FOLLOW_ALL_SIDES, 0);
screenshot->AddChild(&view);
if (view.Looper() && view.Looper()->Lock()) {
view.SetDrawingMode(B_OP_COPY);
view.SetHighColor(B_TRANSPARENT_32_BIT);
for (int i = 0; i < tabSpace.CountRects(); i++)
view.FillRect(tabSpace.RectAt(i));
view.Sync();
view.Looper()->Unlock();
}
screenshot->RemoveChild(&view);
}
示例15: FindView
BView* BubbleHelper::FindView(BPoint where)
{
BView* winview = NULL;
BWindow* win;
long windex = 0;
while ((winview == NULL) && ((win = be_app->WindowAt(windex++)) != NULL)) {
if (win != textwin) {
// lock with timeout, in case somebody has a non-running window around
// in their app.
if (win->LockWithTimeout(1E6) == B_OK) {
BRect frame = win->Frame();
if (frame.Contains(where)) {
BPoint winpoint;
winpoint = where - frame.LeftTop();
winview = win->FindView(winpoint);
if (winview) {
BRegion region;
BPoint newpoint = where;
winview->ConvertFromScreen(&newpoint);
winview->GetClippingRegion(®ion);
if (!region.Contains(newpoint)) winview = 0;
}
}
win->Unlock();
}
}
}
return winview;
}