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


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

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


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

示例1: messenger

DialUpView::DialUpView(BRect frame)
	: BView(frame, "DialUpView", B_FOLLOW_ALL, 0),
	fListener(this),
	fUpDownThread(-1),
	fDriverSettings(NULL),
	fCurrentItem(NULL),
	fWatching(PPP_UNDEFINED_INTERFACE_ID),
	fKeepLabel(false)
{
	BRect bounds = Bounds();
		// for caching
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	
	// add messenger to us so add-ons can contact us
	BMessenger messenger(this);
	fAddons.AddMessenger(DUN_MESSENGER, messenger);
	
	// create pop-up with all interfaces and "New..."/"Delete current" items
	fInterfaceMenu = new BPopUpMenu(kLabelCreateNew);
	BRect rect = bounds;
	rect.InsetBy(5, 5);
	rect.bottom = rect.top + 20;
	fMenuField = new BMenuField(rect, "Interfaces", kLabelInterface, fInterfaceMenu);
	fMenuField->SetDivider(StringWidth(fMenuField->Label()) + 5);
	
	rect.top = rect.bottom + 10;
	rect.bottom = bounds.bottom
		- 20 // height of bottom controls
		- 20; // space for bottom controls
	fTabView = new BTabView(rect, "TabView", B_WIDTH_FROM_LABEL);
	BRect tabViewRect(fTabView->Bounds());
	tabViewRect.bottom -= fTabView->TabHeight();
	fAddons.AddRect(DUN_TAB_VIEW_RECT, tabViewRect);
	
	BRect tmpRect(rect);
	tmpRect.top += (tmpRect.Height() - 15) / 2;
	tmpRect.bottom = tmpRect.top + 15;
	fStringView = new BStringView(tmpRect, "NoInterfacesFound",
		kTextNoInterfacesFound);
	fStringView->SetAlignment(B_ALIGN_CENTER);
	fStringView->Hide();
	tmpRect.top = tmpRect.bottom + 10;
	tmpRect.bottom = tmpRect.top + 25;
	fCreateNewButton = new BButton(tmpRect, "CreateNewButton",
		kLabelCreateNewInterface, new BMessage(kMsgCreateNew));
	fCreateNewButton->ResizeToPreferred();
	tmpRect.left = (rect.Width() - fCreateNewButton->Bounds().Width()) / 2 + rect.left;
	fCreateNewButton->MoveTo(tmpRect.left, tmpRect.top);
	fCreateNewButton->Hide();
	
	rect.top = rect.bottom + 15;
	rect.bottom = rect.top + 15;
	rect.right = rect.left + 200;
	fStatusView = new BStringView(rect, "StatusView", kTextNotConnected, B_FOLLOW_BOTTOM);
	
	rect.InsetBy(0, -5);
	rect.left = rect.right + 5;
	rect.right = bounds.right - 5;
	fConnectButton = new BButton(rect, "ConnectButton", kLabelConnect,
		new BMessage(kMsgConnectButton), B_FOLLOW_BOTTOM);
	
	AddChild(fMenuField);
	AddChild(fTabView);
	AddChild(fStringView);
	AddChild(fCreateNewButton);
	AddChild(fStatusView);
	AddChild(fConnectButton);
	
	// initialize
	LoadInterfaces();
	LoadAddons();
	CreateTabs();
	fCurrentItem = NULL;
		// reset, otherwise SelectInterface will not load the settings
	SelectInterface(0);
	UpdateControls();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:77,代码来源:DialUpView.cpp

示例2: BMessage

void 
PasswordWindow::_Setup()
{
	BRect bounds = Bounds();
	BView* topView = new BView(bounds, "topView", B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	bounds.InsetBy(10.0, 10.0);
	fUseNetwork = new BRadioButton(bounds, "useNetwork", "Use network password",
		new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
	topView->AddChild(fUseNetwork);
	fUseNetwork->ResizeToPreferred();
	fUseNetwork->MoveBy(10.0, 0.0);

	bounds.OffsetBy(0.0, fUseNetwork->Bounds().Height());
	BBox *customBox = new BBox(bounds, "customBox", B_FOLLOW_NONE);
	topView->AddChild(customBox);

	fUseCustom = new BRadioButton(BRect(), "useCustom", "Use custom password",
		new BMessage(kMsgPasswordTypeChanged), B_FOLLOW_NONE);
	customBox->SetLabel(fUseCustom);
	fUseCustom->ResizeToPreferred();

	fPasswordControl = new BTextControl(bounds, "passwordControl", "Password:", 
		NULL, B_FOLLOW_NONE);
	customBox->AddChild(fPasswordControl);
	fPasswordControl->ResizeToPreferred();
	fPasswordControl->TextView()->HideTyping(true);
	fPasswordControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);
	
	bounds.OffsetBy(0.0, fPasswordControl->Bounds().Height() + 5.0);
	fConfirmControl = new BTextControl(bounds, "confirmControl", 
		"Confirm password:", "VeryLongPasswordPossible", B_FOLLOW_NONE);
	customBox->AddChild(fConfirmControl);
	fConfirmControl->TextView()->HideTyping(true);
	fConfirmControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	float width, height;
	fConfirmControl->GetPreferredSize(&width, &height);
	fPasswordControl->ResizeTo(width, height);
	fConfirmControl->ResizeTo(width, height);
	
	float divider = be_plain_font->StringWidth("Confirm password:") + 5.0;
	fConfirmControl->SetDivider(divider);
	fPasswordControl->SetDivider(divider);
	
	customBox->ResizeTo(fConfirmControl->Frame().right + 10.0,
		fConfirmControl->Frame().bottom + 10.0);
	
	BButton* button = new BButton(BRect(), "done", "Done", new BMessage(kMsgDone));
	topView->AddChild(button);
	button->ResizeToPreferred();

	BRect frame = customBox->Frame();
	button->MoveTo(frame.right - button->Bounds().Width(), frame.bottom + 10.0);

	frame = button->Frame();
	button->MakeDefault(true);

	button = new BButton(frame, "cancel", "Cancel", new BMessage(B_CANCEL));
	topView->AddChild(button);
	button->ResizeToPreferred();
	button->MoveBy(-(button->Bounds().Width() + 10.0), 0.0);

	ResizeTo(customBox->Frame().right + 10.0, frame.bottom + 10.0);
}
开发者ID:mariuz,项目名称:haiku,代码行数:67,代码来源:PasswordWindow.cpp

示例3: if

void
PowerStatusView::_DrawBattery(BRect rect)
{
	float quarter = floorf((rect.Height() + 1) / 4);
	rect.top += quarter;
	rect.bottom -= quarter;

	rect.InsetBy(2, 0);

	float left = rect.left;
	rect.left += rect.Width() / 11;

	SetHighColor(0, 0, 0);

	float gap = 1;
	if (rect.Height() > 8) {
		gap = ceilf((rect.left - left) / 2);

		// left
		FillRect(BRect(rect.left, rect.top, rect.left + gap - 1, rect.bottom));
		// right
		FillRect(BRect(rect.right - gap + 1, rect.top, rect.right,
			rect.bottom));
		// top
		FillRect(BRect(rect.left + gap, rect.top, rect.right - gap,
			rect.top + gap - 1));
		// bottom
		FillRect(BRect(rect.left + gap, rect.bottom + 1 - gap,
			rect.right - gap, rect.bottom));
	} else
		StrokeRect(rect);

	FillRect(BRect(left, floorf(rect.top + rect.Height() / 4) + 1,
		rect.left - 1, floorf(rect.bottom - rect.Height() / 4)));

	int32 percent = fPercent;
	if (percent > 100)
		percent = 100;
	else if (percent < 0 || !fHasBattery)
		percent = 0;

	if (percent > 0) {
		rect.InsetBy(gap, gap);
		rgb_color base = {84, 84, 84, 255};
		if (be_control_look != NULL) {
			BRect empty = rect;
			if (fHasBattery && percent > 0)
				empty.left += empty.Width() * percent / 100.0;

			be_control_look->DrawButtonBackground(this, empty, empty, base,
				fHasBattery
					? BControlLook::B_ACTIVATED : BControlLook::B_DISABLED,
				fHasBattery && percent > 0
					? (BControlLook::B_ALL_BORDERS
						& ~BControlLook::B_LEFT_BORDER)
					: BControlLook::B_ALL_BORDERS);
		}

		if (fHasBattery) {
			if (percent <= 15)
				base.set_to(180, 0, 0);
			else
				base.set_to(20, 180, 0);

			rect.right = rect.left + rect.Width() * percent / 100.0;

			if (be_control_look != NULL) {
				be_control_look->DrawButtonBackground(this, rect, rect, base,
					fHasBattery ? 0 : BControlLook::B_DISABLED);
			} else
				FillRect(rect);
		}
	}

	SetHighColor(0, 0, 0);
}
开发者ID:RTOSkit,项目名称:haiku,代码行数:76,代码来源:PowerStatusView.cpp

示例4: iconRect

void
NotificationView::Draw(BRect updateRect)
{
	BRect progRect;

	// Draw progress background
	if (fType == B_PROGRESS_NOTIFICATION) {
		PushState();

		font_height fh;
		be_plain_font->GetHeight(&fh);
		float fontHeight = fh.ascent + fh.descent + fh.leading;

		progRect = Bounds();
		progRect.InsetBy(kEdgePadding, kEdgePadding);
		progRect.top = progRect.bottom - (kSmallPadding * 2) - fontHeight;
		StrokeRect(progRect);

		BRect barRect = progRect;		
		barRect.InsetBy(1.0, 1.0);
		barRect.right *= fProgress;
		SetHighColor(ui_color(B_CONTROL_HIGHLIGHT_COLOR));
		FillRect(barRect);

		SetHighColor(ui_color(B_PANEL_TEXT_COLOR));

		BString label = "";
		label << (int)(fProgress * 100) << " %";

		float labelWidth = be_plain_font->StringWidth(label.String());
		float labelX = progRect.left + (progRect.IntegerWidth() / 2) - (labelWidth / 2);

		SetLowColor(B_TRANSPARENT_COLOR);
		SetDrawingMode(B_OP_ALPHA);
		DrawString(label.String(), label.Length(),
			BPoint(labelX, progRect.top + fh.ascent + fh.leading + kSmallPadding));

		PopState();
	}

	SetDrawingMode(B_OP_ALPHA);
	SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);

	// Icon size
	float iconSize = (float)fParent->IconSize();

	// Rectangle for icon and overlay icon
	BRect iconRect(0, 0, 0, 0);

	// Draw icon
	if (fBitmap) {
		LineInfo* appLine = fLines.back();
		font_height fh;
		appLine->font.GetHeight(&fh);

		float title_bottom = appLine->location.y + fh.descent;

		float ix = kEdgePadding;
		float iy = 0;
		if (fParent->Layout() == TitleAboveIcon)
			iy = title_bottom + kEdgePadding + (Bounds().Height() - title_bottom
				- kEdgePadding * 2 - iconSize) / 2;
		else
			iy = (Bounds().Height() - iconSize) / 2.0;

		if (fType == B_PROGRESS_NOTIFICATION)
			// Move icon up by half progress bar height if it's present
			iy -= (progRect.Height() + kEdgePadding) / 2.0;

		iconRect.left = ix;
		iconRect.top = iy;
		iconRect.right = ix + iconSize;
		iconRect.bottom = iy + iconSize;

		DrawBitmapAsync(fBitmap, fBitmap->Bounds(),
			iconRect, B_FILTER_BITMAP_BILINEAR);
	}

	// Draw content
	LineInfoList::iterator lIt;
	for (lIt = fLines.begin(); lIt != fLines.end(); lIt++) {
		LineInfo *l = (*lIt);
	
		SetFont(&l->font);
		DrawString(l->text.String(), l->text.Length(), l->location);
	}

	rgb_color detailCol = ui_color(B_CONTROL_BORDER_COLOR);
	detailCol = tint_color(detailCol, B_LIGHTEN_2_TINT);

	// Draw the close widget
	BRect closeRect = Bounds();
	closeRect.InsetBy(kEdgePadding, kEdgePadding);
	closeRect.left = closeRect.right - kCloseSize;
	closeRect.bottom = closeRect.top + kCloseSize;

	PushState();
		SetHighColor(detailCol);
		StrokeRoundRect(closeRect, kSmallPadding, kSmallPadding);
		BRect closeCross = closeRect.InsetByCopy(kSmallPadding, kSmallPadding);
//.........这里部分代码省略.........
开发者ID:mariuz,项目名称:haiku,代码行数:101,代码来源:NotificationView.cpp

示例5: BMessage

PPPStatusView::PPPStatusView(BRect rect, ppp_interface_id id)
	: BView(rect, "PPPStatusView", B_FOLLOW_NONE, B_PULSE_NEEDED),
	fInterface(id)
{
	SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	
	rect = Bounds();
	rect.InsetBy(5, 5);
	rect.left = rect.right - 80;
	rect.bottom = rect.top + 25;
	fButton = new BButton(rect, "DisconnectButton", kLabelDisconnect,
		new BMessage(kMsgDisconnect));
	
	rect.right = rect.left - 10;
	rect.left = rect.right - 80;
	rect.top += 5;
	rect.bottom = rect.top + 15;
	fTime = new BStringView(rect, "Time", "");
	fTime->SetAlignment(B_ALIGN_RIGHT);
	fTime->SetFont(be_fixed_font);
	rect.right = rect.left - 10;
	rect.left = 5;
	BStringView *connectedSince = new BStringView(rect, "ConnectedSince",
		kLabelConnectedSince);
	connectedSince->SetFont(be_fixed_font);
	
	rect = Bounds();
	rect.InsetBy(5, 5);
	rect.top += 35;
	rect.right = rect.left + (rect.Width() - 5) / 2;
	BBox *received = new BBox(rect, "Received");
	received->SetLabel(kLabelReceived);
	rect = received->Bounds();
	rect.InsetBy(10, 15);
	rect.bottom = rect.top + 15;
	fBytesReceived = new BStringView(rect, "BytesReceived", "");
	fBytesReceived->SetAlignment(B_ALIGN_RIGHT);
	fBytesReceived->SetFont(be_fixed_font);
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 15;
	fPacketsReceived = new BStringView(rect, "PacketsReceived", "");
	fPacketsReceived->SetAlignment(B_ALIGN_RIGHT);
	fPacketsReceived->SetFont(be_fixed_font);
	
	rect = received->Frame();
	rect.OffsetBy(rect.Width() + 5, 0);
	BBox *sent = new BBox(rect, "sent");
	sent->SetLabel(kLabelSent);
	rect = received->Bounds();
	rect.InsetBy(10, 15);
	rect.bottom = rect.top + 15;
	fBytesSent = new BStringView(rect, "BytesSent", "");
	fBytesSent->SetAlignment(B_ALIGN_RIGHT);
	fBytesSent->SetFont(be_fixed_font);
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 15;
	fPacketsSent = new BStringView(rect, "PacketsSent", "");
	fPacketsSent->SetAlignment(B_ALIGN_RIGHT);
	fPacketsSent->SetFont(be_fixed_font);
	
	received->AddChild(fBytesReceived);
	received->AddChild(fPacketsReceived);
	sent->AddChild(fBytesSent);
	sent->AddChild(fPacketsSent);
	
	AddChild(fButton);
	AddChild(fTime);
	AddChild(connectedSince);
	AddChild(received);
	AddChild(sent);
	
	ppp_interface_info_t info;
	fInterface.GetInterfaceInfo(&info);
	fConnectedSince = info.info.connectedSince;
}
开发者ID:looncraz,项目名称:haiku,代码行数:75,代码来源:PPPStatusView.cpp

示例6: windowRect


//.........这里部分代码省略.........
	fDock->AddItem(btn);
		
//	Email button
	icon = IconForHandler("text/x-email", iconBarSize);
	btn = MakeButton(icon, "Send email to contact", new BMessage(EMAIL), buttonRect);
	fDock->AddItem(btn);
	
//	Block Button
	iconPath = iconDir;
	iconPath.Append("Block");
	icon = ReadNodeIcon(iconPath.Path(), iconBarSize, true);
	btn = MakeButton(icon, "Block messages from contact", new BMessage(BLOCK), buttonRect);
	fDock->AddItem(btn);

//	Log Button
	icon = IconForHandler("application/x-vnd.BeClan.im_binlog_viewer", iconBarSize);
	btn = MakeButton(icon, "View chat history for contact", new BMessage(VIEW_LOG), buttonRect);
	fDock->AddItem(btn);
	
//	Webpage Button
	icon = IconForHandler("text/html", iconBarSize);
	btn = MakeButton(icon, "View contact's web page", new BMessage(VIEW_WEBPAGE), buttonRect);
	fDock->AddItem(btn);
	
// Emoticons	
	iconPath = iconDir;
	iconPath.Append("emoticons");
	icon = ReadNodeIcon(iconPath.Path(), iconBarSize);
	btn = MakeButton(icon, "Emoticons", new BMessage(VIEW_EMOTICONS), buttonRect);
	fDock->AddItem(btn);
	

	textRect.top = fDock->Bounds().bottom+1;
	textRect.InsetBy(2,2);
	textRect.bottom = inputDivider.y;
	textRect.right -= B_V_SCROLL_BAR_WIDTH;
	
	float sendButtonWidth = sendButton ? 50 : 0;
	
	inputRect.InsetBy(2.0, 2.0);
	inputRect.top = inputDivider.y + 7;
	inputRect.right -= B_V_SCROLL_BAR_WIDTH + sendButtonWidth;
	inputRect.bottom -= fFontHeight + (kPadding * 4);
	
	BRect inputTextRect = inputRect;
	inputTextRect.OffsetTo(kPadding, kPadding);
	inputTextRect.InsetBy(kPadding * 2, kPadding * 2);
	
	fInput = new BTextView(inputRect, "input", inputTextRect, B_FOLLOW_ALL,
		B_WILL_DRAW);
	
#if B_BEOS_VERSION > B_BEOS_VERSION_5
	fInput->SetViewUIColor(B_UI_DOCUMENT_BACKGROUND_COLOR);
	fInput->SetLowUIColor(B_UI_DOCUMENT_BACKGROUND_COLOR);
	fInput->SetHighUIColor(B_UI_DOCUMENT_TEXT_COLOR);
#else
	fInput->SetViewColor(245, 245, 245, 0);
	fInput->SetLowColor(245, 245, 245, 0);
	fInput->SetHighColor(0, 0, 0, 0);
#endif

	fInputScroll = new BScrollView(
		"input_scroller", fInput,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_BOTTOM, 0,
		false,
		true,
开发者ID:HaikuArchives,项目名称:IMKit,代码行数:67,代码来源:ChatWindow.cpp

示例7: DynamicScrollView

BView *
DefaultMediaTheme::MakeViewFor(BParameterWeb *web, const BRect *hintRect)
{
	CALLED();

	if (web == NULL)
		return NULL;

	BRect rect;
	if (hintRect)
		rect = *hintRect;
		
	BRect bestRect;

	// do we have more than one attached parameter group?
	// if so, use a tabbed view with a tab for each group

	TabView *tabView = NULL;

	if (web->CountGroups() > 1)
		tabView = new TabView(rect, "web");

	rect.OffsetTo(B_ORIGIN);

	for (int32 i = 0; i < web->CountGroups(); i++) {
		BParameterGroup *group = web->GroupAt(i);
		if (group == NULL)
			continue;

		BView *groupView = MakeViewFor(*group, hintRect ? &rect : NULL);
		if (groupView == NULL)
			continue;

		if (GroupView *view = dynamic_cast<GroupView *>(groupView)) {
			// the top-level group views must not be larger than their hintRect,
			// but unlike their children, they should follow all sides when
			// their parent is resized
			if (hintRect != NULL)
				view->ResizeTo(rect.Width() - 10, rect.Height() - 10);
			view->SetResizingMode(B_FOLLOW_ALL);
		}

		if (tabView == NULL) {
			// if we don't need a container to put that view into,
			// we're done here (but the groupView may span over the
			// whole hintRect)
			if (groupView->Frame().LeftTop() == BPoint(5, 5)) {
				// remove insets, as they are not needed
				groupView->MoveBy(-5, -5);
				groupView->ResizeBy(10, 10);
			}

			return new DynamicScrollView(groupView->Name(), groupView);
		}
		
		DynamicScrollView *scrollView = new DynamicScrollView(groupView->Name(), groupView);		
		tabView->AddTab(scrollView);
		
		if (!hintRect) {			
			bestRect = bestRect | scrollView->Bounds();			
		}	
	}
	
	if (tabView != NULL) {		
		// this adjustment must be kept in sync with TabView::FrameResized
		bestRect.bottom += tabView->TabHeight();
		bestRect.InsetBy(-3.0,-3.0);	
		
		tabView->ResizeTo(bestRect.Width(), bestRect.Height());
		tabView->FrameResized(bestRect.Width(), bestRect.Height());
			//needed since we're not attached to a window yet
	}

	return tabView;
}
开发者ID:mmanley,项目名称:Antares,代码行数:75,代码来源:DefaultMediaTheme.cpp

示例8: IsFocus

// Draw
void
AlphaSlider::Draw(BRect updateRect)
{
    BRect b = _BitmapRect();
    b.InsetBy(-2.0, -2.0);

    bool isFocus = IsFocus() && Window()->IsActive();

    rgb_color bg = LowColor();
    rgb_color shadow;
    rgb_color darkShadow;
    rgb_color light;
    rgb_color black;

    if (IsEnabled()) {
        shadow = tint_color(bg, B_DARKEN_1_TINT);
        darkShadow = tint_color(bg, B_DARKEN_3_TINT);
        light = tint_color(bg, B_LIGHTEN_MAX_TINT);
        black = tint_color(bg, B_DARKEN_MAX_TINT);
    } else {
        shadow = bg;
        darkShadow = tint_color(bg, B_DARKEN_1_TINT);
        light = tint_color(bg, B_LIGHTEN_2_TINT);
        black = tint_color(bg, B_DARKEN_2_TINT);
    }

    rgb_color focus = isFocus ? ui_color(B_KEYBOARD_NAVIGATION_COLOR)
                      : black;

    stroke_frame(this, b, shadow, shadow, light, light);
    b.InsetBy(1.0, 1.0);
    if (isFocus)
        stroke_frame(this, b, focus, focus, focus, focus);
    else
        stroke_frame(this, b, darkShadow, darkShadow, bg, bg);
    b.InsetBy(1.0, 1.0);

    DrawBitmap(fBitmap, b.LeftTop());

    // value marker
    if (fOrientation == B_HORIZONTAL) {
        float pos = floorf(b.left + Value() * b.Width() / 255.0 + 0.5);

        if (pos - 2 >= b.left) {
            SetHighColor(kWhite);
            StrokeLine(BPoint(pos - 2, b.top), BPoint(pos - 2, b.bottom));
        }
        if (pos - 1 >= b.left) {
            SetHighColor(kBlack);
            StrokeLine(BPoint(pos - 1, b.top), BPoint(pos - 1, b.bottom));
        }
        if (pos + 1 <= b.right) {
            SetHighColor(kBlack);
            StrokeLine(BPoint(pos + 1, b.top), BPoint(pos + 1, b.bottom));
        }
        if (pos + 2 <= b.right) {
            SetHighColor(kWhite);
            StrokeLine(BPoint(pos + 2, b.top), BPoint(pos + 2, b.bottom));
        }
    } else {
        float pos = floorf(b.top + Value() * b.Height() / 255.0 + 0.5);

        if (pos - 2 >= b.top) {
            SetHighColor(kWhite);
            StrokeLine(BPoint(b.left, pos - 2), BPoint(b.right, pos - 2));
        }
        if (pos - 1 >= b.top) {
            SetHighColor(kBlack);
            StrokeLine(BPoint(b.left, pos - 1), BPoint(b.right, pos - 1));
        }
        if (pos + 1 <= b.bottom) {
            SetHighColor(kBlack);
            StrokeLine(BPoint(b.left, pos + 1), BPoint(b.right, pos + 1));
        }
        if (pos + 2 <= b.bottom) {
            SetHighColor(kWhite);
            StrokeLine(BPoint(b.left, pos + 2), BPoint(b.right, pos + 2));
        }
    }
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:81,代码来源:AlphaSlider.cpp

示例9: rintf

void
WorkspacesView::MouseMoved(BMessage* message, BPoint where)
{
	if (fSelectedWindow == NULL && fSelectedWorkspace < 0)
		return;

	// check if the correct mouse button is pressed
	int32 buttons;
	if (message->FindInt32("buttons", &buttons) != B_OK
		|| (buttons & B_PRIMARY_MOUSE_BUTTON) == 0)
		return;

	if (!fHasMoved) {
		Window()->Desktop()->SetMouseEventWindow(Window());
			// don't let us off the mouse
	}

	int32 index;
	BRect workspaceFrame = _WorkspaceAt(where, index);

	if (fSelectedWindow == NULL) {
		if (fSelectedWorkspace >= 0 && fSelectedWorkspace != index) {
			fSelectedWorkspace = index;
			_Invalidate();
		}
		return;
	}

	workspaceFrame.InsetBy(1, 1);

	if (index != fSelectedWorkspace) {
		if (fSelectedWindow->IsNormal() && !fSelectedWindow->InWorkspace(index)) {
			// move window to this new workspace
			uint32 newWorkspaces = (fSelectedWindow->Workspaces()
				& ~(1UL << fSelectedWorkspace)) | (1UL << index);

			Window()->Desktop()->SetWindowWorkspaces(fSelectedWindow,
				newWorkspaces);
		}
		fSelectedWorkspace = index;
	}

	BRect screenFrame = _ScreenFrame(index);
	float left = rintf((where.x - workspaceFrame.left - fLeftTopOffset.x)
		* screenFrame.Width() / workspaceFrame.Width());
	float top = rintf((where.y - workspaceFrame.top - fLeftTopOffset.y)
		* screenFrame.Height() / workspaceFrame.Height());

	BPoint leftTop;
	if (fSelectedWorkspace == Window()->Desktop()->CurrentWorkspace())
		leftTop = fSelectedWindow->Frame().LeftTop();
	else {
		if (fSelectedWindow->Anchor(fSelectedWorkspace).position
				== kInvalidWindowPosition) {
			fSelectedWindow->Anchor(fSelectedWorkspace).position
				= fSelectedWindow->Frame().LeftTop();
		}
		leftTop = fSelectedWindow->Anchor(fSelectedWorkspace).position;
	}

	// Don't treat every little mouse move as a window move - this would
	// make it too hard to activate a workspace.
	float diff = max_c(fabs(fClickPoint.x - where.x),
		fabs(fClickPoint.y - where.y));
	if (!fHasMoved && diff > 2)
		fHasMoved = true;

	if (fHasMoved) {
		Window()->Desktop()->MoveWindowBy(fSelectedWindow, left - leftTop.x,
			top - leftTop.y, fSelectedWorkspace);
	}
}
开发者ID:mmanley,项目名称:Antares,代码行数:72,代码来源:WorkspacesView.cpp

示例10: BMessage

PoorManPreferencesWindow::PoorManPreferencesWindow(BRect frame, char * name)
	: BWindow(frame, name, B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE
		| B_CLOSE_ON_ESCAPE),
	webDirFilePanel(NULL),
	logFilePanel(NULL)
{
	frame = Bounds();

	prefView = new PoorManView(frame, STR_WIN_NAME_PREF);
	//prefView->SetViewColor(216,216,216,255);
	prefView->SetViewColor(BACKGROUND_COLOR);
	AddChild(prefView);


	// Button View
	BRect buttonRect;
	buttonRect = Bounds();
	buttonRect.top = buttonRect.bottom - 30;

	buttonView = new PoorManView(buttonRect, "Button View");
	buttonView->SetViewColor(BACKGROUND_COLOR);
	prefView->AddChild(buttonView);

	// Buttons
	float buttonTop = 0.0f;
	float buttonHeight = 26.0f;

	float widthCancel = prefView->StringWidth(B_TRANSLATE("Cancel")) + 24.0f;
	float widthDone = prefView->StringWidth(B_TRANSLATE("Done")) + 24.0f;

	float gap = 5.0f;

	BRect button1(prefView->Bounds().Width() - 2 * gap - widthCancel
		- widthDone, buttonTop, prefView->Bounds().Width() - 2 * gap - widthDone, 
		buttonTop + buttonHeight);
	cancelButton = new BButton(button1, "Cancel Button", B_TRANSLATE("Cancel"), 
		new BMessage(MSG_PREF_BTN_CANCEL));

	BRect button2(prefView->Bounds().Width() - gap - widthDone, buttonTop, 
		prefView->Bounds().Width() - gap, buttonTop + buttonHeight);
	doneButton = new BButton(button2, "Done Button", B_TRANSLATE("Done"), 
		new BMessage(MSG_PREF_BTN_DONE));

	buttonView->AddChild(cancelButton);
	buttonView->AddChild(doneButton);

	// Create tabs
	BRect r;
	r = Bounds();
	//r.InsetBy(5, 5);
	r.top	 += 8.0;
	r.bottom -= 38.0;

	prefTabView = new BTabView(r, "Pref Tab View");
	prefTabView->SetViewColor(BACKGROUND_COLOR);

	r = prefTabView->Bounds();
	r.InsetBy(5, 5);
	r.bottom -= prefTabView->TabHeight();

	// Site Tab
	siteTab = new BTab();
	siteView = new PoorManSiteView(r, "Site View");
	prefTabView->AddTab(siteView, siteTab);
	siteTab->SetLabel(STR_TAB_SITE);

	// Logging Tab
	loggingTab = new BTab();
	loggingView = new PoorManLoggingView(r, "Logging View");
	prefTabView->AddTab(loggingView, loggingTab);
	loggingTab->SetLabel(STR_TAB_LOGGING);

	// Advanced Tab
	advancedTab = new BTab();
	advancedView = new PoorManAdvancedView(r, "Advanced View");
	prefTabView->AddTab(advancedView, advancedTab);
	advancedTab->SetLabel(STR_TAB_ADVANCED);

	prefView->AddChild(prefTabView);

	// FilePanels
	BWindow * change_title;

	BMessenger messenger(this);
	BMessage message(MSG_FILE_PANEL_SELECT_WEB_DIR);
	webDirFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, NULL,
		B_DIRECTORY_NODE, false, &message, NULL, true);

	webDirFilePanel->SetPanelDirectory(new BDirectory("/boot/home/public_html"));
	webDirFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Select"));
	change_title = webDirFilePanel->Window();
	change_title->SetTitle(STR_FILEPANEL_SELECT_WEB_DIR);

	message.what = MSG_FILE_PANEL_CREATE_LOG_FILE;
	logFilePanel = new BFilePanel(B_SAVE_PANEL, &messenger, NULL,
		B_FILE_NODE, false, &message);
	logFilePanel->SetButtonLabel(B_DEFAULT_BUTTON, B_TRANSLATE("Create"));
	change_title = logFilePanel->Window();
	change_title->SetTitle(STR_FILEPANEL_CREATE_LOG_FILE);
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:100,代码来源:PoorManPreferencesWindow.cpp

示例11: workspace

void
WorkspacesView::MouseDown(BMessage* message, BPoint where)
{
	// reset tracking variables
	fSelectedWorkspace = -1;
	fSelectedWindow = NULL;
	fHasMoved = false;

	// check if the correct mouse button is pressed
	int32 buttons;
	if (message->FindInt32("buttons", &buttons) != B_OK
		|| (buttons & B_PRIMARY_MOUSE_BUTTON) == 0)
		return;

	int32 index;
	BRect workspaceFrame = _WorkspaceAt(where, index);
	if (index < 0)
		return;

	Workspace workspace(*Window()->Desktop(), index);
	workspaceFrame.InsetBy(1, 1);

	BRect screenFrame = _ScreenFrame(index);

	::Window* window;
	BRect windowFrame;
	BPoint leftTop;
	while (workspace.GetPreviousWindow(window, leftTop) == B_OK) {
		BRect frame = _WindowFrame(workspaceFrame, screenFrame, window->Frame(),
			leftTop);
		if (frame.Contains(where) && window->Feel() != kDesktopWindowFeel
			&& window->Feel() != kWindowScreenFeel) {
			fSelectedWindow = window;
			windowFrame = frame;
			break;
		}
	}

	// Some special functionality (clicked with modifiers)

	int32 modifiers;
	if (fSelectedWindow != NULL
		&& message->FindInt32("modifiers", &modifiers) == B_OK) {
		if ((modifiers & B_CONTROL_KEY) != 0) {
			// Activate window if clicked with the control key pressed,
			// minimize it if control+shift - this mirrors Deskbar
			// shortcuts (when pressing a team menu item).
			if ((modifiers & B_SHIFT_KEY) != 0)
				fSelectedWindow->ServerWindow()->NotifyMinimize(true);
			else
				Window()->Desktop()->ActivateWindow(fSelectedWindow);
			fSelectedWindow = NULL;
		} else if ((modifiers & B_OPTION_KEY) != 0) {
			// Also, send window to back if clicked with the option
			// key pressed.
			Window()->Desktop()->SendWindowBehind(fSelectedWindow);
			fSelectedWindow = NULL;
		}
	}

	// If this window is movable, we keep it selected
	// (we prevent our own window from being moved, too)

	if ((fSelectedWindow != NULL
			&& (fSelectedWindow->Flags() & B_NOT_MOVABLE) != 0)
		|| fSelectedWindow == Window()) {
		fSelectedWindow = NULL;
	}

	fLeftTopOffset = where - windowFrame.LeftTop();
	fSelectedWorkspace = index;
	fClickPoint = where;

	if (index >= 0)
		_Invalidate();
}
开发者ID:mmanley,项目名称:Antares,代码行数:76,代码来源:WorkspacesView.cpp

示例12: BMessage

ExtensionWindow::ExtensionWindow(FileTypesWindow* target, BMimeType& type,
		const char* extension)
	: BWindow(BRect(100, 100, 350, 200), "Extension", B_MODAL_WINDOW_LOOK,
		B_MODAL_SUBSET_WINDOW_FEEL, B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE
			| B_ASYNCHRONOUS_CONTROLS),
	fTarget(target),
	fMimeType(type.Type()),
	fExtension(extension)
{
	BRect rect = Bounds();
	BView* topView = new BView(rect, NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(topView);

	rect.InsetBy(8.0f, 8.0f);
	fExtensionControl = new BTextControl(rect, "extension", "Extension:", extension,
		NULL, B_FOLLOW_LEFT_RIGHT);

	float labelWidth = fExtensionControl->StringWidth(fExtensionControl->Label()) + 2.0f;
	fExtensionControl->SetModificationMessage(new BMessage(kMsgExtensionUpdated));
	fExtensionControl->SetDivider(labelWidth);
	fExtensionControl->SetAlignment(B_ALIGN_RIGHT, B_ALIGN_LEFT);

	// filter out invalid characters that can't be part of an extension
	BTextView* textView = fExtensionControl->TextView();
	const char* disallowedCharacters = "/:";
	for (int32 i = 0; disallowedCharacters[i]; i++) {
		textView->DisallowChar(disallowedCharacters[i]);
	}

	float width, height;
	fExtensionControl->GetPreferredSize(&width, &height);
	fExtensionControl->ResizeTo(rect.Width(), height);
	topView->AddChild(fExtensionControl);

	fAcceptButton = new BButton(rect, "add", extension ? "Done" : "Add",
		new BMessage(kMsgAccept), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fAcceptButton->ResizeToPreferred();
	fAcceptButton->MoveTo(Bounds().Width() - 8.0f - fAcceptButton->Bounds().Width(),
		Bounds().Height() - 8.0f - fAcceptButton->Bounds().Height());
	fAcceptButton->SetEnabled(false);
	topView->AddChild(fAcceptButton);

	BButton* button = new BButton(rect, "cancel", "Cancel",
		new BMessage(B_QUIT_REQUESTED), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveTo(fAcceptButton->Frame().left - 10.0f - button->Bounds().Width(),
		fAcceptButton->Frame().top);
	topView->AddChild(button);

	ResizeTo(labelWidth * 4.0f + 24.0f, fExtensionControl->Bounds().Height()
		+ fAcceptButton->Bounds().Height() + 28.0f);
	SetSizeLimits(button->Bounds().Width() + fAcceptButton->Bounds().Width() + 26.0f,
		32767.0f, Frame().Height(), Frame().Height());

	// omit the leading dot
	if (fExtension.ByteAt(0) == '.')
		fExtension.Remove(0, 1);

	fAcceptButton->MakeDefault(true);
	fExtensionControl->MakeFocus(true);

	target->PlaceSubWindow(this);
	AddToSubset(target);
}
开发者ID:mmanley,项目名称:Antares,代码行数:65,代码来源:ExtensionWindow.cpp

示例13: Frame

void
BRadioButton::Draw(BRect updateRect)
{
	if (Window() == NULL) return;

	BFont font;
	GetFont(&font);
	font_height fontHeight;
	font.GetHeight(&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;

	if ((IsFocus() || IsFocusChanging()) && IsEnabled() && Label() != NULL) {
		BPoint penLocation;
		penLocation.Set(rect.left + rect.Height() + 5, rect.Center().y + sHeight / 2 + 1);

		SetHighColor((IsFocus() && Window()->IsActivate()) ? ui_color(B_NAVIGATION_BASE_COLOR) : ViewColor());
		StrokeLine(penLocation, penLocation + BPoint(font.StringWidth(Label()), 0));
	}

	if (IsFocusChanging()) return;

	rgb_color shineColor = ui_color(B_SHINE_COLOR);
	rgb_color shadowColor = ui_color(B_SHADOW_COLOR);

	if (!IsEnabled()) {
		shineColor.disable(ViewColor());
		shadowColor.disable(ViewColor());
	}

	rect.right = rect.left + rect.Height();
	SetHighColor(shineColor.mix_copy(0, 0, 0, 5));
	FillEllipse(rect);
	SetHighColor(shineColor);
	StrokeArc(rect, 225, 180);
	SetHighColor(shadowColor);
	StrokeArc(rect, 45, 180);

	if (Value() == B_CONTROL_ON) {
		SetHighColor(shadowColor.mix_copy(255, 255, 255, 50));
		BRect r = rect.InsetByCopy(3, 3);
		FillEllipse(r);
	}

	if (Label() != NULL) {
		BPoint penLocation;
		penLocation.x = rect.right + 5;
		penLocation.y = rect.Center().y - sHeight / 2.f;
		penLocation.y += fontHeight.ascent + 1;

		SetHighColor(IsEnabled() ? ui_color(B_PANEL_TEXT_COLOR) : ui_color(B_SHINE_COLOR).disable(ViewColor()));
		SetLowColor(ViewColor());

		DrawString(Label(), penLocation);
		if (!IsEnabled()) {
			SetHighColor(ui_color(B_SHADOW_COLOR).disable(ViewColor()));
			DrawString(Label(), penLocation - BPoint(1, 1));
		}
	}
}
开发者ID:D-os,项目名称:BeFree,代码行数:63,代码来源:RadioButton.cpp

示例14: cadre

void
KernelMemoryBarMenuItem::DrawBar(bool force)
{
	bool selected = IsSelected();
	BRect frame = Frame();
	BMenu* menu = Menu();

	// draw the bar itself
	BRect cadre (frame.right - kMargin - kBarWidth, frame.top + 5,
		frame.right - kMargin, frame.top + 13);

	if (fLastSum < 0)
		force = true;
	if (force) {
		if (selected)
			menu->SetHighColor(gFrameColorSelected);
		else
			menu->SetHighColor(gFrameColor);
		menu->StrokeRect (cadre);
	}
	cadre.InsetBy(1, 1);
	BRect r = cadre;

	float grenze1 = cadre.left + (cadre.right - cadre.left)
						* fCachedMemory / fPhysicalMemory;
	float grenze2 = cadre.left + (cadre.right - cadre.left)
						* fCommittedMemory / fPhysicalMemory;
	if (grenze1 > cadre.right)
		grenze1 = cadre.right;
	if (grenze2 > cadre.right)
		grenze2 = cadre.right;
	r.right = grenze1;
	if (!force)
		r.left = fGrenze1;
	if (r.left < r.right) {
		if (selected)
			menu->SetHighColor(gKernelColorSelected);
		else
			menu->SetHighColor(gKernelColor);
//		menu->SetHighColor(gKernelColor);
		menu->FillRect (r);
	}
	r.left = grenze1;
	r.right = grenze2;
	if (!force) {
		if (fGrenze2 > r.left && r.left >= fGrenze1)
			r.left = fGrenze2;
		if (fGrenze1 < r.right && r.right <= fGrenze2)
			r.right = fGrenze1;
	}
	if (r.left < r.right) {
		if (selected)
			menu->SetHighColor(tint_color (kLavender, B_HIGHLIGHT_BACKGROUND_TINT));
		else
			menu->SetHighColor(kLavender);
//		menu->SetHighColor(gUserColor);
		menu->FillRect (r);
	}
	r.left = grenze2;
	r.right = cadre.right;
	if (!force)
		r.right = fGrenze2;
	if (r.left < r.right) {
		if (selected)
			menu->SetHighColor(gWhiteSelected);
		else
			menu->SetHighColor(kWhite);
		menu->FillRect(r);
	}
	menu->SetHighColor(kBlack);
	fGrenze1 = grenze1;
	fGrenze2 = grenze2;

	// draw the value
	double sum = fCachedMemory * FLT_MAX + fCommittedMemory;
	if (force || sum != fLastSum) {
		if (selected) {
			menu->SetLowColor(gMenuBackColorSelected);
			menu->SetHighColor(gMenuBackColorSelected);
		} else {
			menu->SetLowColor(gMenuBackColor);
			menu->SetHighColor(gMenuBackColor);
		}
		BRect trect(cadre.left - kMargin - gMemoryTextWidth, frame.top,
			cadre.left - kMargin, frame.bottom);
		menu->FillRect(trect);
		menu->SetHighColor(kBlack);

		char infos[128];
		string_for_size(fCachedMemory * 1024.0, infos, sizeof(infos));
		BPoint loc(cadre.left, cadre.bottom + 1);
		loc.x -= kMargin + gMemoryTextWidth / 2 + menu->StringWidth(infos);
		menu->DrawString(infos, loc);
		string_for_size(fCommittedMemory * 1024.0, infos, sizeof(infos));
		loc.x = cadre.left - kMargin - menu->StringWidth(infos);
		menu->DrawString(infos, loc);
		fLastSum = sum;
	}
}
开发者ID:veer77,项目名称:Haiku-services-branch,代码行数:99,代码来源:KernelMemoryBarMenuItem.cpp

示例15: _

// constructor
NavigationInfoPanel::NavigationInfoPanel(BWindow* parent,
		const BMessage& message, const BMessenger& target)
	: BWindow(BRect(0, 0, 200, 30), "Navigation Info", B_FLOATING_WINDOW_LOOK,
		B_FLOATING_SUBSET_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_V_RESIZABLE)
	, fMessage(message)
	, fTarget(target)
{
	// create the interface and resize to fit

	BRect frame = Bounds();
	frame.InsetBy(5, 5);
	frame.bottom = frame.top + 15;

	// label string view
	fLabelView = new BStringView(frame, "label", kLabel,
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fLabelView->ResizeToPreferred();
	frame = fLabelView->Frame();

	// target clip text control
	frame.OffsetBy(0, frame.Height() + 5);
	fTargetClipTC = new BTextControl(frame, "clip id",
		"Target Playlist ID", "", new BMessage(MSG_INVOKE),
		B_FOLLOW_TOP | B_FOLLOW_LEFT_RIGHT);
	fTargetClipTC->ResizeToPreferred();
	frame = fTargetClipTC->Frame();

	// help string view
	frame.OffsetBy(0, frame.Height() + 5);
	BStringView* helpView = new BStringView(frame, "help",
		"Drag and drop a playlist clip here.",
		B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	BFont font;
	helpView->GetFont(&font);
	font.SetFace(B_ITALIC_FACE);
	font.SetSize(font.Size() * 0.9);
	helpView->SetFont(&font);
	helpView->SetAlignment(B_ALIGN_CENTER);
	helpView->ResizeToPreferred();

	// parent view
	frame = fLabelView->Frame() | fTargetClipTC->Frame() | helpView->Frame();
	frame.InsetBy(-5, -5);
	fInfoView = new InfoView(frame, this);
	fInfoView->AddChild(fLabelView);
	fInfoView->AddChild(fTargetClipTC);
	fInfoView->AddChild(helpView);

	// resize to fit and adjust size limits
	ResizeTo(fInfoView->Frame().Width(), fInfoView->Frame().Height());
	AddChild(fInfoView);
	float minWidth, maxWidth, minHeight, maxHeight;
	GetSizeLimits(&minWidth, &maxWidth, &minHeight, &maxHeight);
	minWidth = Frame().Width();
	minHeight = maxHeight = Frame().Height();
	SetSizeLimits(minWidth, maxWidth, minHeight, maxHeight);

	// modify the high color after the help view is attached to a window
	helpView->SetHighColor(tint_color(helpView->LowColor(),
		B_DISABLED_LABEL_TINT));
	helpView->SetFlags(helpView->Flags() | B_FULL_UPDATE_ON_RESIZE);
		// help the buggy BeOS BStringView (when text alignment != left...)

	fInfoView->SetEventMask(B_POINTER_EVENTS);

	// resize controls to the same (maximum) width
	float maxControlWidth = fLabelView->Frame().Width();
	maxControlWidth = max_c(maxControlWidth, fTargetClipTC->Frame().Width());
	maxControlWidth = max_c(maxControlWidth, helpView->Frame().Width());
	fLabelView->ResizeTo(maxControlWidth, fLabelView->Frame().Height());
	fTargetClipTC->ResizeTo(maxControlWidth, fTargetClipTC->Frame().Height());
	helpView->ResizeTo(maxControlWidth, helpView->Frame().Height());

	// center above parent window
	BAutolock _(parent);
	frame = Frame();
	BRect parentFrame = parent->Frame();
	MoveTo((parentFrame.left + parentFrame.right - frame.Width()) / 2,
		(parentFrame.top + parentFrame.bottom - frame.Height()) / 2);

	AddToSubset(parent);
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:84,代码来源:NavigationInfoPanel.cpp


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