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


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

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


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

示例1: Draw

void CCrossHairView::Draw(BRect updateRect)
{
	BRect bounds = Bounds();

	SetHighColor(CColor::Transparent);

	FillRect(bounds);

	BRect bigCircle, smallCircle;
	
	float width  = bounds.Width();
	float height = bounds.Height();
	
	bigCircle = bounds.InsetByCopy(5, 5);
	smallCircle = bounds.InsetByCopy(10, 10);

	SetHighColor(CColor::White);
	StrokeEllipse(bigCircle.OffsetByCopy(1, 1));
	StrokeEllipse(smallCircle.OffsetByCopy(1, 1));
	
	StrokeLine(BPoint(2, height/2+1), BPoint(width, height/2+1));
	StrokeLine(BPoint(width/2+1, 2), BPoint(width/2+1, height));
	
	SetHighColor(CColor::Black);
	StrokeEllipse(bigCircle);
	StrokeEllipse(smallCircle);
	
	StrokeLine(BPoint(1, height/2), BPoint(width-1, height/2));
	StrokeLine(BPoint(width/2, 1), BPoint(width/2, height-1));
	
	Sync();
}
开发者ID:HaikuArchives,项目名称:TaskManager,代码行数:32,代码来源:SelectTeamWindow.cpp

示例2: buttonRect

void
AppGroupView::_DrawCloseButton(const BRect& updateRect)
{
	PushState();
	BRect closeRect = fCloseRect;

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	float tint = B_DARKEN_2_TINT;

	if (fCloseClicked) {
		BRect buttonRect(closeRect.InsetByCopy(-4, -4));
		be_control_look->DrawButtonFrame(this, buttonRect, updateRect,
			base, base,
			BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME);
		be_control_look->DrawButtonBackground(this, buttonRect, updateRect,
			base, BControlLook::B_ACTIVATED);
		tint *= 1.2;
		closeRect.OffsetBy(1, 1);
	}

	base = tint_color(base, tint);
	SetHighColor(base);
	SetPenSize(2);
	StrokeLine(closeRect.LeftTop(), closeRect.RightBottom());
	StrokeLine(closeRect.LeftBottom(), closeRect.RightTop());
	PopState();
}
开发者ID:garodimb,项目名称:haiku,代码行数:27,代码来源:AppGroupView.cpp

示例3: if

void
BScrollView::Draw(BRect updateRect)
{
	if (fBorder == B_PLAIN_BORDER) {
		SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
		StrokeRect(Bounds());
		return;
	} else if (fBorder != B_FANCY_BORDER)
		return;

	BRect bounds = Bounds();
	SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_2_TINT));
	StrokeRect(bounds.InsetByCopy(1, 1));

	if (fHighlighted) {
		SetHighColor(ui_color(B_NAVIGATION_BASE_COLOR));
		StrokeRect(bounds);
	} else {
		SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_1_TINT));
		StrokeLine(bounds.LeftBottom(), bounds.LeftTop());
		bounds.left++;
		StrokeLine(bounds.LeftTop(), bounds.RightTop());
	
		SetHighColor(ui_color(B_SHINE_COLOR));
		StrokeLine(bounds.LeftBottom(), bounds.RightBottom());
		bounds.top++;
		bounds.bottom--;
		StrokeLine(bounds.RightBottom(), bounds.RightTop());
	}
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:30,代码来源:ScrollView.cpp

示例4: innerRect

void
MonitorView::Draw(BRect updateRect)
{
	rgb_color darkColor = {160, 160, 160, 255};
	rgb_color blackColor = {0, 0, 0, 255};
	rgb_color redColor = {228, 0, 0, 255};
	rgb_color whiteColor = {255, 255, 255, 255};
	BRect outerRect = _MonitorBounds();

	SetHighColor(fBackgroundColor);
	FillRect(updateRect);

	SetDrawingMode(B_OP_OVER);

	// frame & background

	SetHighColor(darkColor);
	FillRoundRect(outerRect, 3.0, 3.0);

	SetHighColor(blackColor);
	StrokeRoundRect(outerRect, 3.0, 3.0);

	SetHighColor(fDesktopColor);

	BRect innerRect(outerRect.InsetByCopy(4, 4));
	FillRoundRect(innerRect, 2.0, 2.0);

	SetHighColor(blackColor);
	StrokeRoundRect(innerRect, 2.0, 2.0);

	SetDrawingMode(B_OP_COPY);

	// power light

	SetHighColor(redColor);
	BPoint powerPos(outerRect.left + 5, outerRect.bottom - 2);
	StrokeLine(powerPos, BPoint(powerPos.x + 2, powerPos.y));

	// DPI

	if (fDPI == 0)
		return;

	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float height = ceilf(fontHeight.ascent + fontHeight.descent);

	char text[64];
	snprintf(text, sizeof(text), B_TRANSLATE("%ld dpi"), fDPI);

	float width = StringWidth(text);
	if (width > innerRect.Width() || height > innerRect.Height())
		return;

	SetLowColor(fDesktopColor);
	SetHighColor(whiteColor);

	DrawString(text, BPoint(innerRect.left + (innerRect.Width() - width) / 2,
		innerRect.top + fontHeight.ascent + (innerRect.Height() - height) / 2));
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:60,代码来源:MonitorView.cpp

示例5: BTextView

// constructor
PopupTextView::PopupTextView(BRect frame, const BString& text,
							 TextViewPopup* popup)
	: BTextView(frame, "popup text view", frame.InsetByCopy(2, 1),
				B_FOLLOW_ALL, B_WILL_DRAW)
	, fPopup(popup)
{
	SetText(text.String());
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:9,代码来源:TextViewPopup.cpp

示例6: Draw

/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmCaption::Draw( BRect updateRect) {
	BRect r = Bounds();
	if (mHighlight) {
		if (BeamOnDano)
			SetLowColor( keyboard_navigation_color());
		else {
			rgb_color highlightCol = {255, 217, 121, 255};
			SetLowColor( highlightCol);
		}
	}
	else
		SetLowColor( ui_color( B_PANEL_BACKGROUND_COLOR));
#ifndef __HAIKU__
	FillRect( r.InsetByCopy(1.0, 1.0), B_SOLID_LOW);
#else
	FillRect( BRect(r.top + 1, r.left + 1, r.right, r.bottom - 1), B_SOLID_LOW);
#endif
	SetHighColor( ui_color( B_SHINE_COLOR));
	StrokeLine( BPoint(0.0,1.0), BPoint(r.right,1.0));
	StrokeLine( BPoint(0.0,1.0), r.LeftBottom());
	SetHighColor( BmWeakenColor( B_SHADOW_COLOR, BeShadowMod));
	if (BeamOnDano)
		StrokeLine( r.RightTop(), r.RightBottom());
#ifndef __HAIKU__
	else
		// looks better on R5, as it blends with scrollbar:
		StrokeLine( r.RightTop(), r.RightBottom(), B_SOLID_LOW);
#endif
	StrokeLine( r.LeftTop(), r.RightTop());
	StrokeLine( r.LeftBottom(), r.RightBottom());

	SetHighColor( ui_color( B_PANEL_TEXT_COLOR));
	font_height fInfo;
	BFont captionFont;
	GetFont(&captionFont);
	captionFont.GetHeight( &fInfo);
	float offset = (1.0f+r.Height()-(fInfo.ascent+fInfo.descent))/2.0f;
	float freeWidth = r.Width();
	if (mHighlight && mHighlightLabel.Length()) {
		freeWidth -= StringWidth(mHighlightLabel.String())+2;
		BPoint pos( 2.0, fInfo.ascent+offset);
		DrawString( mHighlightLabel.String(), pos);
	}
	const char* text = mText.String();
	float width;
	while(1) {
		width = StringWidth(text);
		if (width+4.0 < freeWidth)
			break;
		text++;
		while((*text & 0xc0) == 0x80)
			text++;		// skip UTF8 subsequence chars
		if (!*text)
			break;
	}
	BPoint pos( r.Width()-width-2.0f, fInfo.ascent+offset);
	DrawString( text, pos);
}
开发者ID:HaikuArchives,项目名称:Beam,代码行数:62,代码来源:BmCaption.cpp

示例7: TypeEditorView

NumberEditor::NumberEditor(BRect rect, DataEditor &editor)
	: TypeEditorView(rect, B_TRANSLATE("Number editor"), B_FOLLOW_LEFT_RIGHT, 0, editor)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	fTextControl = new BTextControl(rect.InsetByCopy(5, 5), B_EMPTY_STRING,
		_TypeLabel(), NULL, new BMessage(kMsgValueChanged), B_FOLLOW_ALL);
	fTextControl->SetDivider(StringWidth(fTextControl->Label()) + 8);
	fTextControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_RIGHT);
	ResizeTo(rect.Width(), 30);

	AddChild(fTextControl);
}
开发者ID:DonCN,项目名称:haiku,代码行数:13,代码来源:TypeEditors.cpp

示例8: BMessage

void 
TTimeWindow::_InitWindow()
{
	SetPulseRate(500000);

	fDateTimeView = new DateTimeView(Bounds());
	
	BRect bounds = fDateTimeView->Bounds();
	fTimeZoneView = new TimeZoneView(bounds);

	fBaseView = new TTimeBaseView(bounds, "baseView");
	AddChild(fBaseView);
	
	fBaseView->StartWatchingAll(fDateTimeView);
	fBaseView->StartWatchingAll(fTimeZoneView);

	bounds.OffsetBy(10.0, 10.0);
	BTabView *tabView = new BTabView(bounds.InsetByCopy(-5.0, -5.0),
		"tabView" , B_WIDTH_AS_USUAL, B_FOLLOW_NONE);
	
	BTab *tab = new BTab();
	tabView->AddTab(fDateTimeView, tab);
	tab->SetLabel("Date & Time");

	tab = new BTab();
	tabView->AddTab(fTimeZoneView, tab);
	tab->SetLabel("Time zone");

	fBaseView->AddChild(tabView);
	tabView->ResizeBy(0.0, tabView->TabHeight());

	BRect rect = Bounds();

	rect.left = 10;
	rect.top = rect.bottom - 10;

	fRevertButton = new BButton(rect, "revert", "Revert",
		new BMessage(kMsgRevert), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM, B_WILL_DRAW);
	
	fRevertButton->ResizeToPreferred();
	fRevertButton->SetEnabled(false);
	float buttonHeight = fRevertButton->Bounds().Height();
	fRevertButton->MoveBy(0, -buttonHeight);
	fBaseView->AddChild(fRevertButton);
	fRevertButton->SetTarget(this);

	fBaseView->ResizeTo(tabView->Bounds().Width() + 10.0, 
		tabView->Bounds().Height() + buttonHeight + 30.0);

	ResizeTo(fBaseView->Bounds().Width(), fBaseView->Bounds().Height());
}
开发者ID:mariuz,项目名称:haiku,代码行数:51,代码来源:TimeWindow.cpp

示例9: bounds

void
TTimeWindow::_AlignWindow()
{
	BPoint pt = TimeSettings().LeftTop();
	MoveTo(pt);

	BRect frame = Frame();
	BRect screen = BScreen().Frame();
	if (!frame.Intersects(screen.InsetByCopy(50.0, 50.0))) {
		BRect bounds(Bounds());
		BPoint leftTop((screen.Width() - bounds.Width()) / 2.0,
			(screen.Height() - bounds.Height()) / 2.0);

		MoveTo(leftTop);
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:16,代码来源:TimeWindow.cpp

示例10: grid

void
Test::SetupClipping(BView* view)
{
    BRect bounds = view->Bounds();
    fClippingRegion.Set(bounds);
    BRect grid(bounds.InsetByCopy(40, 40));
    for (float y = grid.top; y < grid.bottom + 5; y += grid.Height() / 2) {
        for (float x = grid.left; x < grid.right + 5;
                x += grid.Width() / 2) {
            BRect r(x, y, x, y);
            r.InsetBy(-30, -30);
            fClippingRegion.Exclude(r);
        }
    }

    view->ConstrainClippingRegion(&fClippingRegion);
}
开发者ID:yunxiaoxiao110,项目名称:haiku,代码行数:17,代码来源:Test.cpp

示例11: Bounds

void
PictureView::Draw(BRect updateRect)
{
	BRect rect = Bounds();

	// Draw the outer frame
	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	if (IsFocus() && Window() && Window()->IsActive())
		SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
	else
		SetHighColor(tint_color(base, B_DARKEN_3_TINT));
	StrokeRect(rect);

	if (fFocusChanging) {
		// focus frame is already redraw, stop here
		return;
	}

	BBitmap* picture = fPicture ? fPicture : fDefaultPicture;
	if (picture != NULL) {
		// scale to fit and center picture in frame
		BRect frame = rect.InsetByCopy(kPictureMargin, kPictureMargin);
		BRect srcRect = picture->Bounds();
		BSize size = frame.Size();
		if (srcRect.Width() > srcRect.Height())
			size.height = srcRect.Height() * size.width / srcRect.Width();
		else
			size.width = srcRect.Width() * size.height / srcRect.Height();

		fPictureRect = BLayoutUtils::AlignInFrame(frame, size,
			BAlignment(B_ALIGN_HORIZONTAL_CENTER, B_ALIGN_VERTICAL_CENTER));

		SetDrawingMode(B_OP_ALPHA);
		if (picture == fDefaultPicture) {
			SetBlendingMode(B_CONSTANT_ALPHA, B_ALPHA_OVERLAY);
			SetHighColor(0, 0, 0, 24);
		}

 		DrawBitmapAsync(picture, srcRect, fPictureRect,
 			B_FILTER_BITMAP_BILINEAR);

		SetDrawingMode(B_OP_OVER);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:44,代码来源:PictureView.cpp

示例12: _DrawCloseButton

void WebTabView::_DrawCloseButton(BView* owner, BRect& frame,
	const BRect& updateRect, bool isFirst, bool isLast, bool isFront)
{
	BRect closeRect = _CloseRectFrame(frame);
	frame.right = closeRect.left - be_control_look->DefaultLabelSpacing();

	closeRect.left = (closeRect.left + closeRect.right) / 2 - 3;
	closeRect.right = closeRect.left + 6;
	closeRect.top = (closeRect.top + closeRect.bottom) / 2 - 3;
	closeRect.bottom = closeRect.top + 6;

	rgb_color base = ui_color(B_PANEL_BACKGROUND_COLOR);
	float tint = B_DARKEN_1_TINT;
	if (!IsFront()) {
		base = tint_color(base, tint);
		tint *= 1.02;
	}

	if (fOverCloseRect)
		tint *= 1.4;
	else
		tint *= 1.2;

	if (fClicked && fOverCloseRect) {
		// Draw the button frame
		BRect buttonRect(closeRect.InsetByCopy(-4, -4));
		be_control_look->DrawButtonFrame(owner, buttonRect, updateRect,
			base, base,
			BControlLook::B_ACTIVATED | BControlLook::B_BLEND_FRAME);
		be_control_look->DrawButtonBackground(owner, buttonRect, updateRect,
			base, BControlLook::B_ACTIVATED);
		closeRect.OffsetBy(1, 1);
		tint *= 1.2;
	}

	// Draw the ×
	base = tint_color(base, tint);
	owner->SetHighColor(base);
	owner->SetPenSize(2);
	owner->StrokeLine(closeRect.LeftTop(), closeRect.RightBottom());
	owner->StrokeLine(closeRect.LeftBottom(), closeRect.RightTop());
	owner->SetPenSize(1);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:43,代码来源:TabManager.cpp

示例13: Bounds

LiveTextControl::LiveTextControl(BRect frame,
							const char *name,
							const char *label, 
							const char *initial_text, 
							BMessage *message,
							uint32 rmask,
							uint32 flags)
:	BControl(frame, name, label, message, rmask, flags)
{
	// initial_text zuweisen!
	font_height	hoehe;
	GetFontHeight(&hoehe);
	ResizeTo( Bounds().Width(), hoehe.ascent + hoehe.descent + hoehe.leading + 6.0 );
	
	frame = Bounds();
	frame.left = 50.0;
	
	fTextView = new LiveTextView(frame, 0, frame.InsetByCopy(6.0, 3.0).OffsetToCopy( 3.0, 3.0 ), B_FOLLOW_LEFT|B_FOLLOW_TOP );
	AddChild( fTextView );
}
开发者ID:diversys,项目名称:PecoRename,代码行数:20,代码来源:LiveTextControl.cpp

示例14: BMessage

BooleanEditor::BooleanEditor(BRect rect, DataEditor &editor)
	: TypeEditorView(rect, B_TRANSLATE("Boolean editor"), B_FOLLOW_NONE, 0, editor)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BPopUpMenu *menu = new BPopUpMenu("bool");
	BMessage *message;
	menu->AddItem(fFalseMenuItem = new BMenuItem("false",
		new BMessage(kMsgValueChanged)));
	menu->AddItem(fTrueMenuItem = new BMenuItem("true",
		message = new BMessage(kMsgValueChanged)));
	message->AddInt8("value", 1);

	BMenuField *menuField = new BMenuField(rect.InsetByCopy(5, 5),
		B_EMPTY_STRING, B_TRANSLATE("Boolean value:"), menu, B_FOLLOW_LEFT_RIGHT);
	menuField->SetDivider(StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	ResizeTo(menuField->Bounds().Width() + 10,
		menuField->Bounds().Height() + 10);

	_UpdateMenuField();

	AddChild(menuField);
}
开发者ID:DonCN,项目名称:haiku,代码行数:24,代码来源:TypeEditors.cpp

示例15: _

void
ActivityView::_DrawHistory(bool drawBackground)
{
	_UpdateOffscreenBitmap();

	BView* view = this;
	if (fOffscreen != NULL) {
		fOffscreen->Lock();
		view = _OffscreenView();
	}

	BRect frame = _HistoryFrame();
	BRect outerFrame = frame.InsetByCopy(-2, -2);

	// draw the outer frame
	uint32 flags = 0;
	if (!drawBackground)
		flags |= BControlLook::B_BLEND_FRAME;
	be_control_look->DrawTextControlBorder(this, outerFrame,
		outerFrame, fLegendBackgroundColor, flags);

	// convert to offscreen view if necessary
	if (view != this)
		frame.OffsetTo(B_ORIGIN);

	view->SetLowColor(fHistoryBackgroundColor);
	view->FillRect(frame, B_SOLID_LOW);

	uint32 step = 2;
	uint32 resolution = fDrawResolution;
	if (fDrawResolution > 1) {
		step = 1;
		resolution--;
	}

	uint32 width = frame.IntegerWidth() - 10;
	uint32 steps = width / step;
	bigtime_t timeStep = RefreshInterval() * resolution;
	bigtime_t now = system_time();

	// Draw scale
	// TODO: add second markers?

	view->SetPenSize(1);

	rgb_color scaleColor = view->LowColor();
	uint32 average = (scaleColor.red + scaleColor.green + scaleColor.blue) / 3;
	if (average < 96)
		scaleColor = tint_color(scaleColor, B_LIGHTEN_2_TINT);
	else
		scaleColor = tint_color(scaleColor, B_DARKEN_2_TINT);

	view->SetHighColor(scaleColor);
	view->StrokeLine(BPoint(frame.left, frame.top + frame.Height() / 2),
		BPoint(frame.right, frame.top + frame.Height() / 2));

	// Draw values

	view->SetPenSize(1.5);
	BAutolock _(fSourcesLock);

	for (uint32 i = fSources.CountItems(); i-- > 0;) {
		ViewHistory* viewValues = fViewValues.ItemAt(i);
		DataSource* source = fSources.ItemAt(i);
		DataHistory* values = fValues.ItemAt(i);

		viewValues->Update(values, steps, fDrawResolution, now, timeStep,
			RefreshInterval());

		uint32 x = viewValues->Start() * step;
		BShape shape;
		bool first = true;

		for (uint32 i = viewValues->Start(); i < steps; x += step, i++) {
			float y = _PositionForValue(source, values,
				viewValues->ValueAt(i));

			if (first) {
				shape.MoveTo(BPoint(x, y));
				first = false;
			} else
				shape.LineTo(BPoint(x, y));
		}

		view->SetHighColor(source->Color());
		view->SetLineMode(B_BUTT_CAP, B_ROUND_JOIN);
		view->MovePenTo(B_ORIGIN);
		view->StrokeShape(&shape);
	}

	// TODO: add marks when an app started or quit
	view->Sync();
	if (fOffscreen != NULL) {
		fOffscreen->Unlock();
		DrawBitmap(fOffscreen, outerFrame.LeftTop());
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:97,代码来源:ActivityView.cpp


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