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


C++ BView::SetViewUIColor方法代码示例

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


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

示例1: textRect

TextRequestDialog::TextRequestDialog(const char *title, const char *information,
		const char *request, const char *text)
	: BWindow(kWindowRect, title, B_MODAL_WINDOW, B_NOT_RESIZABLE | B_NOT_CLOSABLE, 0),
	fInvoker(NULL)
{
	BRect rect = Bounds();
	BView *backgroundView = new BView(rect, "background", B_FOLLOW_ALL_SIDES, 0);
	backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	rect.InsetBy(5, 5);
	rect.bottom = rect.top;
		// init
	
	if(information) {
		BRect textRect(rect);
		textRect.OffsetTo(0, 0);
		fTextView = new BTextView(rect, "TextView", textRect, B_FOLLOW_NONE,
			B_WILL_DRAW);
		fTextView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
		fTextView->MakeSelectable(false);
		fTextView->MakeEditable(false);
		fTextView->SetText(information);
		float textHeight = fTextView->TextHeight(0, fTextView->CountLines());
		backgroundView->ResizeBy(0, textHeight + 5);
		ResizeBy(0, textHeight + 5);
		fTextView->ResizeBy(0, textHeight - textRect.Height());
		rect.bottom += textHeight + 5;
		backgroundView->AddChild(fTextView);
	} else
		fTextView = NULL;
	
	rect.top = rect.bottom + 5;
	rect.bottom = rect.top + 20;
	fTextControl = new BTextControl(rect, "request", request, text, NULL);
	fTextControl->SetModificationMessage(new BMessage(kMsgUpdateControls));
	fTextControl->SetDivider(fTextControl->StringWidth(fTextControl->Label()) + 5);
	if(text && strlen(text) > 0)
		fTextControl->TextView()->SelectAll();
	
	rect.top = rect.bottom + 10;
	rect.bottom = rect.top + 25;
	rect.left = rect.right - kDefaultButtonWidth;
	BMessage message(kMsgButton);
	message.AddInt32("which", 1);
	fOKButton = new BButton(rect, "okButton", kLabelOK, new BMessage(message));
	rect.right = rect.left - 10;
	rect.left = rect.right - kDefaultButtonWidth;
	message.ReplaceInt32("which", 0);
	BButton *cancelButton = new BButton(rect, "cancelButton", kLabelCancel,
		new BMessage(message));
	backgroundView->AddChild(cancelButton);
	backgroundView->AddChild(fOKButton);
	backgroundView->AddChild(fTextControl);
	AddChild(backgroundView);
	
	fTextControl->MakeFocus(true);
	SetDefaultButton(fOKButton);
	
	UpdateControls();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:59,代码来源:TextRequestDialog.cpp

示例2: floorf

ScreenSaverWindow::ScreenSaverWindow()
	:
	BWindow(BRect(50.0f, 50.0f, 50.0f + kWindowWidth, 50.0f + kWindowHeight),
		B_TRANSLATE_SYSTEM_NAME("ScreenSaver"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	fSettings.Load();

	fMinWidth = floorf(be_control_look->DefaultItemSpacing()
		* (kWindowWidth / kDefaultItemSpacingAt12pt));

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

	fMinHeight = ceilf(std::max(kWindowHeight, textHeight * 28));

	// Create the password editing window
	fPasswordWindow = new PasswordWindow(fSettings);
	fPasswordWindow->Run();

	// Create the tab view
	fTabView = new TabView();
	fTabView->SetBorder(B_NO_BORDER);

	// Create the controls inside the tabs
	fFadeView = new FadeView(B_TRANSLATE("General"), fSettings);
	fModulesView = new ModulesView(B_TRANSLATE("Screensavers"), fSettings);

	fTabView->AddTab(fFadeView);
	fTabView->AddTab(fModulesView);

	// Create the topmost background view
	BView* topView = new BView("topView", B_WILL_DRAW);
	topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	topView->SetExplicitAlignment(BAlignment(B_ALIGN_USE_FULL_WIDTH,
		B_ALIGN_USE_FULL_HEIGHT));
	topView->SetExplicitMinSize(BSize(fMinWidth, fMinHeight));
	BLayoutBuilder::Group<>(topView, B_VERTICAL)
		.SetInsets(0, B_USE_DEFAULT_SPACING, 0, B_USE_WINDOW_SPACING)
		.Add(fTabView)
		.End();

	SetLayout(new BGroupLayout(B_VERTICAL));
	GetLayout()->AddView(topView);

	fTabView->Select(fSettings.WindowTab());

	if (fSettings.WindowFrame().left > 0 && fSettings.WindowFrame().top > 0)
		MoveTo(fSettings.WindowFrame().left, fSettings.WindowFrame().top);

	if (fSettings.WindowFrame().Width() > 0
		&& fSettings.WindowFrame().Height() > 0) {
		ResizeTo(fSettings.WindowFrame().Width(),
			fSettings.WindowFrame().Height());
	}

	CenterOnScreen();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:59,代码来源:ScreenSaverWindow.cpp

示例3: BView

PowerStatusWindow::PowerStatusWindow()
	:
	BWindow(BRect(100, 150, 281, 299), B_TRANSLATE_SYSTEM_NAME("PowerStatus"),
		B_TITLED_WINDOW, B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS)
{
	BView* topView = new BView(Bounds(), NULL, B_FOLLOW_ALL, B_WILL_DRAW);
	topView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(topView);

	topView->AddChild(new PowerStatusReplicant(Bounds(), B_FOLLOW_ALL));
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:11,代码来源:PowerStatusWindow.cpp

示例4: ScreenSaverRunner

void
ModulesView::_OpenSaver()
{
	// create new screen saver preview & config

	BView* view = fPreviewView->AddPreview();
	fCurrentName = fSettings.ModuleName();
	fSaverRunner = new ScreenSaverRunner(view->Window(), view, fSettings);

#ifdef __HAIKU__
	BRect rect = fSettingsBox->InnerFrame().InsetByCopy(4, 4);
#else
	BRect rect = fSettingsBox->Bounds().InsetByCopy(4, 4);
	rect.top += 14;
#endif
	fSettingsView = new BView(rect, "SettingsView", B_FOLLOW_ALL, B_WILL_DRAW);

	fSettingsView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fSettingsBox->AddChild(fSettingsView);

	BScreenSaver* saver = ScreenSaver();
	if (saver != NULL && fSettingsView != NULL) {
		saver->StartConfig(fSettingsView);
		if (saver->StartSaver(view, true) == B_OK) {
			fPreviewView->HideNoPreview();
			fSaverRunner->Run();
		} else
			fPreviewView->ShowNoPreview();
	} else {
		// Failed to load OR this is the "Blackness" screensaver. Show a black
		// preview (this is what will happen in both cases when screen_blanker
		// runs).
		fPreviewView->HideNoPreview();
	}

	if (fSettingsView->ChildAt(0) == NULL) {
		// There are no settings at all, we add the module name here to
		// let it look a bit better at least.
		BPrivate::BuildDefaultSettingsView(fSettingsView,
			fSettings.ModuleName()[0] ? fSettings.ModuleName()
				: B_TRANSLATE("Blackness"),
				saver != NULL || !fSettings.ModuleName()[0]
					? B_TRANSLATE("No options available")
					: B_TRANSLATE("Could not load screen saver"));
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:46,代码来源:ScreenSaverWindow.cpp

示例5: memio

ImageEditor::ImageEditor(const BRect &frame, ResourceData *data, BHandler *owner)
  :	Editor(frame, data, owner)
{
	SetFlags(Flags()  | B_NOT_RESIZABLE | B_NOT_ZOOMABLE);
	SetTitle(data->GetName());
	
	// Set up the image and the viewer for such
	BMemoryIO memio(data->GetData(), data->GetLength());
	fImage = BTranslationUtils::GetBitmap(&memio);
	
	BRect imgsize;
	if (fImage)
		imgsize = ScaleRectToFit(fImage->Bounds(), BRect(0, 0, 200, 200));
	else
		imgsize.Set(0, 0, 200, 200);
	
	BView *back = new BView(Bounds(), "back", B_FOLLOW_ALL, B_WILL_DRAW);
	back->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(back);
	
	BRect r;
	
	float labelwidth = be_plain_font->StringWidth("ID: ");
	float strwidth = be_plain_font->StringWidth("(attr) ");
	
	font_height fh;
	be_plain_font->GetHeight(&fh);
	float strheight = fh.ascent + fh.descent + fh.leading + 5;
	
	fIDBox = new BTextControl(BRect(10, 10, 10 + (strwidth + labelwidth) + 15,
									10 + strheight),
							  "id", "ID: ", data->GetIDString(), NULL);
	fIDBox->SetDivider(labelwidth + 5);
	back->AddChild(fIDBox);
	
	r = fIDBox->Frame();
	r.OffsetBy(r.Width() + 10, 0);
	r.right = Bounds().right - 10;
	fNameBox = new BTextControl(r, "name", "Name: ", data->GetName(), NULL,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fNameBox->SetDivider(be_plain_font->StringWidth("Name: ") + 5);
	back->AddChild(fNameBox);
	
	r = imgsize;
	
	r.OffsetTo( (Bounds().Width() - r.Width()) / 2, fNameBox->Frame().bottom + 10);
	fImageView = new BitmapView(r, "imageview", new BMessage(M_IMAGE_CHANGED), fImage,
								NULL, B_PLAIN_BORDER, B_FOLLOW_NONE,
								B_WILL_DRAW | B_FRAME_EVENTS);
	back->AddChild(fImageView);
	fImageView->SetConstrainDrops(false);
	
	// No limit on bitmap size
	fImageView->SetMaxBitmapSize(0, 0);
	fImageView->SetBitmapRemovable(false);
	
	fOK = new BButton(BRect(10, 10, 11, 11), "ok", "Cancel", new BMessage(M_UPDATE_RESOURCE),
					  B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fOK->ResizeToPreferred();
	fOK->SetLabel("OK");
	fOK->MakeDefault(true);
	back->AddChild(fOK);
	
	fOK->MoveTo(Bounds().right - fOK->Bounds().Width() - 10,
				Bounds().bottom - fOK->Bounds().Height() - 10);
	r = fOK->Frame();
	
	r.OffsetBy(-r.Width() - 10, 0);
	fCancel = new BButton(r, "cancel", "Cancel", new BMessage(B_QUIT_REQUESTED),
					  B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	back->AddChild(fCancel);
	
	ResizeTo(MAX(fImageView->Frame().right, fNameBox->Frame().right) + 20,
			fImageView->Frame().bottom + fOK->Frame().Height() + 20);
	
	SetSizeLimits(Bounds().right, 30000, Bounds().bottom, 30000);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:77,代码来源:ImageEditor.cpp

示例6: BMessage

FindWindow::FindWindow(BRect _rect, BMessage& previous, BMessenger& target,
		const BMessage* settings)
	: BWindow(_rect, B_TRANSLATE("Find"), B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_CLOSE_ON_ESCAPE),
	fTarget(target)
{
	BView* view = new BView(Bounds(), "main", B_FOLLOW_ALL, 0);
	view->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(view);

	int8 mode = kAsciiMode;
	if (previous.FindInt8("find_mode", &mode) != B_OK && settings != NULL)
		settings->FindInt8("find_mode", &mode);

	// add the top widgets

	fMenu = new BPopUpMenu("mode");
	BMessage* message;
	BMenuItem* item;
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE("Text"),
		message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kAsciiMode);
	if (mode == kAsciiMode)
		item->SetMarked(true);
	fMenu->AddItem(item = new BMenuItem(B_TRANSLATE_COMMENT("Hexadecimal", 
		"A menu item, as short as possible, noun is recommended if it is "
		"shorter than adjective."), message = new BMessage(kMsgFindMode)));
	message->AddInt8("mode", kHexMode);
	if (mode == kHexMode)
		item->SetMarked(true);

	BRect rect = Bounds().InsetByCopy(5, 5);
	BMenuField* menuField = new BMenuField(rect, B_EMPTY_STRING,
		B_TRANSLATE("Mode:"), fMenu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	menuField->SetDivider(menuField->StringWidth(menuField->Label()) + 8);
	menuField->ResizeToPreferred();
	view->AddChild(menuField);

	// add the bottom widgets

	BButton* button = new BButton(rect, B_EMPTY_STRING, B_TRANSLATE("Find"),
		new BMessage(kMsgStartFind), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->MakeDefault(true);
	button->ResizeToPreferred();
	button->MoveTo(rect.right - button->Bounds().Width(),
		rect.bottom - button->Bounds().Height());
	view->AddChild(button);

	fCaseCheckBox = new BCheckBox(rect, B_EMPTY_STRING, B_TRANSLATE("Case sensitive"),
		NULL, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	fCaseCheckBox->ResizeToPreferred();
	fCaseCheckBox->MoveTo(5, button->Frame().top);
	bool caseSensitive;
	if (previous.FindBool("case_sensitive", &caseSensitive) != B_OK) {
		if (settings == NULL
			|| settings->FindBool("case_sensitive", &caseSensitive) != B_OK)
			caseSensitive = true;
	}
	fCaseCheckBox->SetValue(caseSensitive);
	view->AddChild(fCaseCheckBox);

	// and now those inbetween

	rect.top = menuField->Frame().bottom + 5;
	rect.bottom = fCaseCheckBox->Frame().top - 8;
	rect.InsetBy(2, 2);
	fTextView = new FindTextView(rect, B_EMPTY_STRING,
		rect.OffsetToCopy(B_ORIGIN).InsetByCopy(3, 3), B_FOLLOW_ALL);
	fTextView->SetWordWrap(true);
	fTextView->SetMode((find_mode)mode);
	fTextView->SetData(previous);

	BScrollView* scrollView = new BScrollView("scroller", fTextView,
		B_FOLLOW_ALL, B_WILL_DRAW, false, false);
	view->AddChild(scrollView);

	ResizeTo(290, button->Frame().Height() * 3 + 30);

	SetSizeLimits(fCaseCheckBox->Bounds().Width() + button->Bounds().Width()
			+ 20, 32768, button->Frame().Height() * 3 + 10, 32768);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:81,代码来源:FindWindow.cpp

示例7: mbRect

ActivityWindow::ActivityWindow()
    :
    BWindow(BRect(100, 100, 500, 350), B_TRANSLATE_SYSTEM_NAME("ActivityMonitor"),
           B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE)
{
    BMessage settings;
    _LoadSettings(settings);

    BRect frame;
    if (settings.FindRect("window frame", &frame) == B_OK) {
        MoveTo(frame.LeftTop());
        ResizeTo(frame.Width(), frame.Height());
    } else {
        float scaling = be_plain_font->Size() / 12.0f;
        ResizeTo(Frame().Width() * scaling, Frame().Height() * scaling);
        CenterOnScreen();
    }

#ifdef __HAIKU__
    BGroupLayout* layout = new BGroupLayout(B_VERTICAL, 0);
    SetLayout(layout);

    // create GUI

    BMenuBar* menuBar = new BMenuBar("menu");
    layout->AddView(menuBar);

    fLayout = new BGroupLayout(B_VERTICAL);
    float inset = ceilf(be_plain_font->Size() * 0.7);
    fLayout->SetInsets(B_USE_WINDOW_SPACING);
    fLayout->SetSpacing(inset);

    BView* top = new BView("top", 0, fLayout);
    layout->AddView(top);
    top->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

    BMessage viewState;
    int32 count = 0;
    for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
            == B_OK; i++) {
        ActivityView* view = new ActivityView("ActivityMonitor", &viewState);
        fLayout->AddItem(view->CreateHistoryLayoutItem());
        fLayout->AddItem(view->CreateLegendLayoutItem());
        count++;
    }
    if (count == 0) {
        // Add default views (memory & CPU usage)
        _AddDefaultView();
        _AddDefaultView();
    }
#else	// !__HAIKU__
    BView *layout = new BView(Bounds(), "topmost", B_FOLLOW_NONE, 0);
    AddChild(layout);

    // create GUI
    BRect mbRect(Bounds());
    mbRect.bottom = 10;
    BMenuBar* menuBar = new BMenuBar(mbRect, "menu");
    layout->AddChild(menuBar);

    BRect topRect(Bounds());
    topRect.top = menuBar->Bounds().bottom + 1;

    BView* top = new BView(topRect, "top", B_FOLLOW_ALL, 0);
    layout->AddChild(top);

    BMessage viewState;
    int32 count = 0;
    ActivityView *aview;
    BRect rect;
    for (int32 i = 0; settings.FindMessage("activity view", i, &viewState)
            == B_OK; i++) {
        aview = new ActivityView("ActivityMonitor", &viewState);
        if (!rect.IsValid())
            rect = aview->Bounds();
        else
            rect.OffsetBySelf(0.0, aview->Bounds().Height());
        top->AddChild(aview);
        count++;
    }
    if (count == 0)
        top->AddChild(new ActivityView("ActivityMonitor", NULL));

#endif
    // add menu

    // "File" menu
    BMenu* menu = new BMenu(B_TRANSLATE("File"));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Add graph"),
                                new BMessage(kMsgAddView)));
    menu->AddSeparatorItem();

    menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
                                new BMessage(B_QUIT_REQUESTED), 'Q'));
    menu->SetTargetForItems(this);
    menuBar->AddItem(menu);

    // "Settings" menu
    menu = new BMenu(B_TRANSLATE("Settings"));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Settings" B_UTF8_ELLIPSIS),
//.........这里部分代码省略.........
开发者ID:jessicah,项目名称:haiku-private,代码行数:101,代码来源:ActivityWindow.cpp


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