当前位置: 首页>>代码示例>>C++>>正文


C++ BRect::IsValid方法代码示例

本文整理汇总了C++中BRect::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ BRect::IsValid方法的具体用法?C++ BRect::IsValid怎么用?C++ BRect::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BRect的用法示例。


在下文中一共展示了BRect::IsValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Bounds

void
BAbstractSpinner::_UpdateFrame()
{
	if (fLayoutData->label_layout_item == NULL
		|| fLayoutData->text_view_layout_item == NULL) {
		return;
	}

	BRect labelFrame = fLayoutData->label_layout_item->Frame();
	BRect textViewFrame = fLayoutData->text_view_layout_item->Frame();

	if (!labelFrame.IsValid() || !textViewFrame.IsValid())
		return;

	// update divider
	fDivider = textViewFrame.left - labelFrame.left;

	BRect frame = textViewFrame | labelFrame;
	MoveTo(frame.left, frame.top);
	BSize oldSize = Bounds().Size();
	ResizeTo(frame.Width(), frame.Height());
	BSize newSize = Bounds().Size();

	// If the size changes, ResizeTo() will trigger a relayout, otherwise
	// we need to do that explicitly.
	if (newSize != oldSize)
		Relayout();
}
开发者ID:simonsouth,项目名称:haiku,代码行数:28,代码来源:AbstractSpinner.cpp

示例2: alpha_mixer_getOutputSize

BRect alpha_mixer_getOutputSize(je_mixer_plugin *cookie, BRect src1, BRect src2)
{
	alpha_mixer_private *self = (alpha_mixer_private *)cookie->data;
	BRect ret;
	
	// check rect validity first!!!
	// at least 1 is guaranteed to be valid
	if (src1.IsValid() && src2.IsValid())
	{
		if (src1.Width() > src2.Width())
		{
			// src1 is wider
			ret = src1;
			// set the scale for the mixer
			self->mix->SetScale(src2, src1);
		}
		else if (src1.Width() < src2.Width())
		{
			// src2 is wider
			ret = src2;
			// set the scale for the mixer
			self->mix->SetScale(src1, src2);
		}
		else if (src1.Height() > src2.Height())
		{
			// widths are equal, but src1 is taller
			ret = src1;
			// set the scale for the mixer
			self->mix->SetScale(src2, src1);
		}
		else
		{
			// widths are equal, src2 is taller or heights are equal
			ret = src2;
			// set the scale for the mixer
			self->mix->SetScale(src1, src2);
		}
	}
	else if (src1.IsValid())
	{
		// set the return value
		ret = src1;
		// set the scale for the mixer
		// 1.0 in this case (src == dst)
		self->mix->SetScale(ret, ret);
	}
	else // src2.IsValid()
	{
		// set the return value
		ret = src2;
		// set the scale for the mixer
		// 1.0 in this case (src == dst)
		self->mix->SetScale(ret, ret);
	}
	
	return ret;
}
开发者ID:jwiggins,项目名称:BeOS-Projects,代码行数:57,代码来源:AlphaMixer.cpp

示例3: Bounds

void
LanguageListView::MouseMoved(BPoint where, uint32 transit,
	const BMessage* dragMessage)
{
	if (dragMessage != NULL && _AcceptsDragMessage(dragMessage)) {
		switch (transit) {
			case B_ENTERED_VIEW:
			case B_INSIDE_VIEW:
			{
				BRect highlightFrame;

				if (fGlobalDropTargetIndicator) {
					highlightFrame = Bounds();
					fDropIndex = 0;
				} else {
					// offset where by half of item height
					BRect r = ItemFrame(0);
					where.y += r.Height() / 2.0;

					int32 index = IndexOf(where);
					if (index < 0)
						index = CountItems();
					highlightFrame = ItemFrame(index);
					if (highlightFrame.IsValid())
						highlightFrame.bottom = highlightFrame.top;
					else {
						highlightFrame = ItemFrame(index - 1);
						if (highlightFrame.IsValid())
							highlightFrame.top = highlightFrame.bottom;
						else {
							// empty view, show indicator at top
							highlightFrame = Bounds();
							highlightFrame.bottom = highlightFrame.top;
						}
					}
					fDropIndex = index;
				}

				if (fDropTargetHighlightFrame != highlightFrame) {
					Invalidate(fDropTargetHighlightFrame);
					fDropTargetHighlightFrame = highlightFrame;
					Invalidate(fDropTargetHighlightFrame);
				}

				BOutlineListView::MouseMoved(where, transit, dragMessage);
				return;
			}
		}
	}

	if (fDropTargetHighlightFrame.IsValid()) {
		Invalidate(fDropTargetHighlightFrame);
		fDropTargetHighlightFrame = BRect();
	}
	BOutlineListView::MouseMoved(where, transit, dragMessage);
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:56,代码来源:LanguageListView.cpp

示例4:

// _InvalidateHighlightPoints
void
PathManipulator::_InvalidateHighlightPoints(int32 newIndex, uint32 newMode)
{
	BRect oldRect = _ControlPointRect(fCurrentPathPoint, fMode);
	BRect newRect = _ControlPointRect(newIndex, newMode);
	if (oldRect.IsValid())
		_InvalidateCanvas(oldRect);
	if (newRect.IsValid())
		_InvalidateCanvas(newRect);
}
开发者ID:mariuz,项目名称:haiku,代码行数:11,代码来源:PathManipulator.cpp

示例5: rect_intersection

inline BRect rect_intersection(BRect r1, BRect r2)
{
	if (r1.IsValid() == false || r2.IsValid() == false) return BRect();

	BRect r3;
	r3.left = max_c(r1.left, r2.left);
	r3.top = max_c(r1.top, r2.top);
	r3.right = min_c(r1.right, r2.right);
	r3.bottom = min_c(r1.bottom, r2.bottom);

	return r3;
}
开发者ID:D-os,项目名称:BeFree,代码行数:12,代码来源:Rect.cpp

示例6: 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();
}
开发者ID:D-os,项目名称:BeFree,代码行数:26,代码来源:RadioButton.cpp

示例7: 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);
}
开发者ID:mariuz,项目名称:haiku,代码行数:35,代码来源:Utility.cpp

示例8: screen

// make_sure_frame_is_on_screen
bool
make_sure_frame_is_on_screen( BRect& frame )
{
    BScreen screen( B_MAIN_SCREEN_ID );
    if (frame.IsValid() && screen.IsValid()) {
        if (!screen.Frame().Contains(frame)) {
            // make sure frame fits in the screen
            if (frame.Width() > screen.Frame().Width())
                frame.right -= frame.Width() - screen.Frame().Width() + 10.0;
            if (frame.Height() > screen.Frame().Height())
                frame.bottom -= frame.Height() - screen.Frame().Height() + 30.0;
            // frame is now at the most the size of the screen
            if (frame.right > screen.Frame().right)
                frame.OffsetBy(-(frame.right - screen.Frame().right), 0.0);
            if (frame.bottom > screen.Frame().bottom)
                frame.OffsetBy(0.0, -(frame.bottom - screen.Frame().bottom));
            if (frame.left < screen.Frame().left)
                frame.OffsetBy((screen.Frame().left - frame.left), 0.0);
            if (frame.top < screen.Frame().top)
                frame.OffsetBy(0.0, (screen.Frame().top - frame.top));
        }
        return true;
    }
    return false;
}
开发者ID:FLYKingdom,项目名称:vlc,代码行数:26,代码来源:InterfaceWindow.cpp

示例9: r

/*****************************************************************************
 * DragSortableListView::Draw
 *****************************************************************************/
void
DragSortableListView::Draw( BRect updateRect )
{
    int32 firstIndex = IndexOf( updateRect.LeftTop() );
    int32 lastIndex = IndexOf( updateRect.RightBottom() );
    if ( firstIndex >= 0 )
    {
        if ( lastIndex < firstIndex )
            lastIndex = CountItems() - 1;
        // update rect contains items
        BRect r( updateRect );
        for ( int32 i = firstIndex; i <= lastIndex; i++)
        {
            r = ItemFrame( i );
            DrawListItem( this, i, r );
        }
        updateRect.top = r.bottom + 1.0;
        if ( updateRect.IsValid() )
        {
            SetLowColor( 255, 255, 255, 255 );
            FillRect( updateRect, B_SOLID_LOW );
        }
    }
    else
    {
        SetLowColor( 255, 255, 255, 255 );
        FillRect( updateRect, B_SOLID_LOW );
    }
    // drop anticipation indication
    if ( fDropRect.IsValid() )
    {
        SetHighColor( 255, 0, 0, 255 );
        StrokeRect( fDropRect );
    }
}
开发者ID:forthyen,项目名称:SDesk,代码行数:38,代码来源:ListViews.cpp

示例10: 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); 
}
开发者ID:mariuz,项目名称:haiku,代码行数:29,代码来源:RegionTestcase.cpp

示例11: 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;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:30,代码来源:support.cpp

示例12: Do

BMessage* Resize::Do(PDocument *doc, BMessage *settings)
{
	BMessage		*undoMessage		= new BMessage();
	BList			*selected			= doc->GetSelected();
	BList			*changed			= doc->GetChangedNodes();
	float			dx,dy;
	BRect			*newFrame			= new BRect(0,0,100,100);
	BRect			*oldFrame			= new BRect(0,0,100,100);
	BMessage		*node				= new BMessage();
	int32			i					= 0;
	if ( (settings->FindFloat("dx",&dx)==B_OK) && (settings->FindFloat("dy",&dy)==B_OK) )
	{
		for (i=0;i<selected->CountItems();i++)
		{
			node=(BMessage *)selected->ItemAt(i);
			node->FindRect("Node::frame",oldFrame);
			undoMessage->AddRect("oldFrame",*oldFrame);
			undoMessage->AddPointer("node",node);
			*newFrame			=	*oldFrame;
			newFrame->right		+=	dx;
			newFrame->bottom	+=	dy;
			if ( (newFrame->IsValid()) && (newFrame->Width()>20) && ((newFrame->Height()>20)) )
			{
				node->ReplaceRect("Node::frame",*newFrame);
				changed->AddItem(node);
			}
		}
	}
	doc->SetModified();
	settings->RemoveName("Resize::Undo");
	settings->AddMessage("Resize::Undo",undoMessage);
	settings= PCommand::Do(doc,settings);
	return settings;
}
开发者ID:BackupTheBerlios,项目名称:projectconcepto-svn,代码行数:34,代码来源:Resize.cpp

示例13: r

BRect
CanvasView::_LayoutCanvas()
{
	// size of zoomed bitmap
	BRect r(_CanvasRect());
	r.OffsetTo(B_ORIGIN);

	// ask current view state to extend size
	// TODO: Ask StateViewState to extend bounds...
	BRect stateBounds = r; //ViewStateBounds();

	// resize for empty area around bitmap
	// (the size we want, but might still be much smaller than view)
	r.InsetBy(-50, -50);

	// center data rect in bounds
	BRect bounds(Bounds());
	if (bounds.Width() > r.Width())
		r.InsetBy(-ceilf((bounds.Width() - r.Width()) / 2), 0);
	if (bounds.Height() > r.Height())
		r.InsetBy(0, -ceilf((bounds.Height() - r.Height()) / 2));

	if (stateBounds.IsValid()) {
		stateBounds.InsetBy(-20, -20);
		r = r | stateBounds;
	}

	return r;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:29,代码来源:CanvasView.cpp

示例14:

// _Clipped
BRect
Painter::_Clipped(const BRect& rect) const
{
	if (rect.IsValid() && fClippingRegion)
		return rect & _Transform(fClippingRegion->Frame());
	return rect;
}
开发者ID:mmanley,项目名称:Antares,代码行数:8,代码来源:Painter.cpp

示例15: BMessage

SettingsWindow::SettingsWindow(BRect frame, SettingsMessage* settings)
	:
	BWindow(frame, B_TRANSLATE("Settings"), B_TITLED_WINDOW_LOOK,
		B_NORMAL_WINDOW_FEEL, B_AUTO_UPDATE_SIZE_LIMITS
			| B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE),
	fSettings(settings)
{
	fApplyButton = new BButton(B_TRANSLATE("Apply"), new BMessage(MSG_APPLY));
	fCancelButton = new BButton(B_TRANSLATE("Cancel"),
		new BMessage(MSG_CANCEL));
	fRevertButton = new BButton(B_TRANSLATE("Revert"),
		new BMessage(MSG_REVERT));

	fOpenFilePanel = NULL;

	float spacing = be_control_look->DefaultItemSpacing();

	BTabView* tabView = new BTabView("settings pages", B_WIDTH_FROM_LABEL);
	tabView->SetBorder(B_NO_BORDER);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(0, B_USE_DEFAULT_SPACING, 0, B_USE_WINDOW_SPACING)
		.Add(tabView)
		.Add(new BSeparatorView(B_HORIZONTAL))
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_WINDOW_SPACING, B_USE_DEFAULT_SPACING,
				B_USE_WINDOW_SPACING, 0)
			.Add(fRevertButton)
			.AddGlue()
			.Add(fCancelButton)
			.Add(fApplyButton);

	tabView->AddTab(_CreateGeneralPage(spacing));
	tabView->AddTab(_CreateFontsPage(spacing));
	tabView->AddTab(_CreateProxyPage(spacing));

	_SetupFontSelectionView(fStandardFontView,
		new BMessage(MSG_STANDARD_FONT_CHANGED));
	_SetupFontSelectionView(fSerifFontView,
		new BMessage(MSG_SERIF_FONT_CHANGED));
	_SetupFontSelectionView(fSansSerifFontView,
		new BMessage(MSG_SANS_SERIF_FONT_CHANGED));
	_SetupFontSelectionView(fFixedFontView,
		new BMessage(MSG_FIXED_FONT_CHANGED));

	fApplyButton->MakeDefault(true);

	if (!frame.IsValid())
		CenterOnScreen();

	// load settings from disk
	_RevertSettings();
	// apply to WebKit
	_ApplySettings();

	// Start hidden
	Hide();
	Show();
}
开发者ID:looncraz,项目名称:haiku,代码行数:59,代码来源:SettingsWindow.cpp


注:本文中的BRect::IsValid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。