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


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

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


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

示例1: Parent

void
BRadioButton::SetValue(int32 value)
{
	if (value != Value()) {
		BControl::SetValueNoUpdate(value);
		Invalidate(_KnobFrame());
	}

	if (value == 0)
		return;

	BView* parent = Parent();
	BView* child = NULL;

	if (parent != NULL) {
		// If the parent is a BBox, the group parent is the parent of the BBox
		BBox* box = dynamic_cast<BBox*>(parent);

		if (box != NULL && box->LabelView() == this)
			parent = box->Parent();

		if (parent != NULL) {
			BBox* box = dynamic_cast<BBox*>(parent);

			// If the parent is a BBox, skip the label if there is one
			if (box != NULL && box->LabelView())
				child = parent->ChildAt(1);
			else
				child = parent->ChildAt(0);
		} else
			child = Window()->ChildAt(0);
	} else if (Window() != NULL)
		child = Window()->ChildAt(0);

	while (child != NULL) {
		BRadioButton* radio = dynamic_cast<BRadioButton*>(child);

		if (radio != NULL && (radio != this))
			radio->SetValue(B_CONTROL_OFF);
		else {
			// If the child is a BBox, check if the label is a radiobutton
			BBox* box = dynamic_cast<BBox*>(child);

			if (box != NULL && box->LabelView()) {
				radio = dynamic_cast<BRadioButton*>(box->LabelView());

				if (radio != NULL && (radio != this))
					radio->SetValue(B_CONTROL_OFF);
			}
		}

		child = child->NextSibling();
	}

	ASSERT(Value() == B_CONTROL_ON);
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:56,代码来源:RadioButton.cpp

示例2: DeactivateView

void TMediaTabView::DeactivateView(EChildID which)
{
	// Take away the control buttons
	BView* view = ChildAt(which);

	BView* b = view->ChildAt(0);
	while (b) {
		BView* next = b->NextSibling();
		if (dynamic_cast<TRadioBitmapButton*>(b) != 0)
			view->RemoveChild(b);
		b = next;
	}

	// Make sure the view is invisible
	if (!view->IsHidden())
		view->Hide();
}
开发者ID:Barrett17,项目名称:UltraDV,代码行数:17,代码来源:TMediaTabView.cpp

示例3: 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

示例4: settings

status_t
ActivityWindow::_SaveSettings()
{
    BFile file;
    status_t status = _OpenSettings(file, B_WRITE_ONLY | B_CREATE_FILE
                                    | B_ERASE_FILE);
    if (status < B_OK)
        return status;

    BMessage settings('actm');
    status = settings.AddRect("window frame", Frame());
    if (status != B_OK)
        return status;

    status = settings.SetBool("always on top", fAlwaysOnTop->IsMarked());
    if (status != B_OK)
        return status;

#ifdef __HAIKU__
    BView* top = fLayout->View();
#else
    BView* top = ChildAt(0);
#endif
    int32 count = top->CountChildren();
    for (int32 i = 0; i < count; i++) {
        ActivityView* view = dynamic_cast<ActivityView*>(top->ChildAt(i));
        if (view == NULL)
            continue;

        BMessage viewState;
        status = view->SaveState(viewState);
        if (status == B_OK)
            status = settings.AddMessage("activity view", &viewState);
        if (status != B_OK)
            break;
    }

    if (status == B_OK)
        status = settings.Flatten(&file);

    return status;
}
开发者ID:jessicah,项目名称:haiku-private,代码行数:42,代码来源:ActivityWindow.cpp

示例5: MakeBitmask

//------------------------------------------------------------------------------
uint32 WindowEditor::MakeBitmask(void)
{
	uint32 bitmask = 0;

	for (uint32 i = 0; i < fFlagBoxes.size(); ++i)
	{
		if (WindowFlags[i].flag != MSG_WINDOW_ADD_MENU &&
			WindowFlags[i].flip == fFlagBoxes[i]->Value())
		{
			bitmask |= WindowFlags[i].flag;
		}
	}

	return bitmask;
#if 0
	BView *box = ((BTabView *)(main->FindView("tabs")))->TabAt(1)->View()->FindView("flags");
	uint32 bitmask = 0;
	if (((BCheckBox *)(box->ChildAt(0)))->Value() == B_CONTROL_OFF)
		bitmask = bitmask | B_NOT_MOVABLE;
	if (((BCheckBox *)(box->ChildAt(1)))->Value() == B_CONTROL_OFF)
		bitmask = bitmask | B_NOT_CLOSABLE;
	if (((BCheckBox *)(box->ChildAt(2)))->Value() == B_CONTROL_OFF)
		bitmask = bitmask | B_NOT_ZOOMABLE;
	if (((BCheckBox *)(box->ChildAt(3)))->Value() == B_CONTROL_OFF)
		bitmask = bitmask | B_NOT_MINIMIZABLE;
	if (((BCheckBox *)(box->ChildAt(4)))->Value() == B_CONTROL_OFF)
		bitmask = bitmask | B_NOT_H_RESIZABLE;
	if (((BCheckBox *)(box->ChildAt(5)))->Value() == B_CONTROL_OFF)
		bitmask = bitmask | B_NOT_V_RESIZABLE;
	if (((BCheckBox *)(box->ChildAt(7)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_OUTLINE_RESIZE;
	if (((BCheckBox *)(box->ChildAt(8)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_WILL_ACCEPT_FIRST_CLICK;
	if (((BCheckBox *)(box->ChildAt(9)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_AVOID_FRONT;
	if (((BCheckBox *)(box->ChildAt(10)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_AVOID_FOCUS;
	if (((BCheckBox *)(box->ChildAt(11)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_NO_WORKSPACE_ACTIVATION;
	if (((BCheckBox *)(box->ChildAt(12)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_NOT_ANCHORED_ON_ACTIVATE;
	if (((BCheckBox *)(box->ChildAt(13)))->Value() == B_CONTROL_ON)
		bitmask = bitmask | B_ASYNCHRONOUS_CONTROLS;
	return bitmask;
#endif
}
开发者ID:HaikuArchives,项目名称:Resourcer,代码行数:47,代码来源:WindowEditor.cpp

示例6: UpdateLayout

/*------------------------------------------------------------------------------*\
	( )
		-	
\*------------------------------------------------------------------------------*/
void BmToolbar::UpdateLayout(bool recalcSizes) {
	if (LockLooper()) {
		// since we want the background tiles for the complete toolbar to appear
		// as one piece, we can't simply use the toolbar-background as view-bitmap
		// in all toolbar-buttons (horizontal wallpapering wouldn't work).
		// So, we render the complete wallpaper into a special bitmap, which is
		// then used by each toolbar-button when that creates its pictures.
		BRect rect = Bounds();
		BmBitmapHandle* toolbarBackground 
			= TheResources->IconByName("Toolbar_Background");
		if (toolbarBackground) {
			delete mBackgroundBitmap;
			BView* view = new BView( rect, NULL, B_FOLLOW_NONE, 0);
			mBackgroundBitmap = new BBitmap( rect, B_RGBA32, true);
			mBackgroundBitmap->AddChild( view);
			mBackgroundBitmap->Lock();
			
			float y=0.0;
			while(y < rect.Height()) {
				float x=0.0;
				while(x < rect.Width()) {
					view->DrawBitmap(toolbarBackground->bitmap, BPoint(x,y));
					x += toolbarBackground->bitmap->Bounds().Width();
				}
				y += toolbarBackground->bitmap->Bounds().Height();
			}
		
			view->Sync();
			mBackgroundBitmap->Unlock();
			mBackgroundBitmap->RemoveChild(view);
			delete view;
		}
	
		// now step through all toolbar-buttons and let them create
		// their pictures:
		BView* group = ChildAt(0);
		if (group) {
			int32 count = group->CountChildren();
			// Get maximum button size...
			float width=0, height=0;
			for( int32 c=0; c<count; ++c) {
				BmToolbarButton* tbb 
					= dynamic_cast<BmToolbarButton*>(group->ChildAt(c));
				if (tbb)
					BmToolbarButton::CalcMaxSize(
						width, height, tbb->Label().String(), tbb->NeedsLatch()
					);
			}
			//...and layout all buttons according to this size:
			for( int32 c=0; c<count; ++c) {
				BmToolbarButton* tbb 
					= dynamic_cast<BmToolbarButton*>(group->ChildAt(c));
				if (tbb)
					tbb->CreateAllPictures(width, height);
			}
			MWindow* win = dynamic_cast<MWindow*>( Window());
			if (win && recalcSizes)
				win->RecalcSize();
			for( int32 c=0; c<count; ++c)
				group->ChildAt(c)->Invalidate();
		}
		// FIXME: a little hackish, but we need to invalidate the whole window 
		// anyway, since icons in other views will have changed, too. 
		// Strangely enough, calling Invalidate() on the topmost child 
		// doesn't work...
		Window()->ChildAt(0)->Hide();
		Window()->ChildAt(0)->Show();
		UnlockLooper();
	}
}
开发者ID:HaikuArchives,项目名称:Beam,代码行数:74,代码来源:BmToolbarButton.cpp

示例7: fnr

PrefsWindow::PrefsWindow(uint32 msg) : BWindow(BRect(0, 0, 400, 289), GetString(STR_PREFS_TITLE), B_TITLED_WINDOW, B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_ASYNCHRONOUS_CONTROLS), this_messenger(this)
{
	int i;
	ok_message = msg;
	send_quit_on_close = true;
	get_system_info(&sys_info);

	// Move window to right position
	Lock();
	MoveTo(80, 80);

	// Set up menus
	BMenuBar *bar = new BMenuBar(Bounds(), "menu");
	BMenu *menu = new BMenu(GetString(STR_PREFS_MENU));
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ABOUT), new BMessage(B_ABOUT_REQUESTED)));
	menu->AddItem(new BSeparatorItem);
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_START), new BMessage(MSG_OK)));
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_ZAP_PRAM), new BMessage(MSG_ZAP_PRAM)));
	menu->AddItem(new BSeparatorItem);
	menu->AddItem(new BMenuItem(GetString(STR_PREFS_ITEM_QUIT), new BMessage(MSG_CANCEL), 'Q'));
	bar->AddItem(menu);
	AddChild(bar);
	SetKeyMenuBar(bar);
	int mbar_height = int(bar->Bounds().bottom) + 1;

	// Resize window to fit menu bar
	ResizeBy(0, mbar_height);

	// Light gray background
	BRect b = Bounds();
	top = new BView(BRect(0, mbar_height, b.right, b.bottom), "top", B_FOLLOW_NONE, B_WILL_DRAW);
	AddChild(top);
	top->SetViewColor(fill_color);
	top_frame = top->Bounds();

	// Create panes
	panes[0] = create_volumes_pane();
	panes[1] = create_graphics_pane();
	panes[2] = create_serial_pane();
	panes[3] = create_memory_pane();

	// Prefs item tab view
	pane_tabs = new BTabView(BRect(10, 10, top_frame.right-10, top_frame.bottom-50), "items", B_WIDTH_FROM_LABEL);
	for (i=0; i<NUM_PANES; i++)
		pane_tabs->AddTab(panes[i]);
	top->AddChild(pane_tabs);

	volume_list->Select(0);

	// Create volume file panels
	add_volume_panel = new BFilePanel(B_OPEN_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_ADD_VOLUME_PANEL));
	add_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_ADD_VOLUME_PANEL_BUTTON));
	add_volume_panel->Window()->SetTitle(GetString(STR_ADD_VOLUME_TITLE));
	create_volume_panel = new BFilePanel(B_SAVE_PANEL, &this_messenger, NULL, B_FILE_NODE | B_DIRECTORY_NODE, false, new BMessage(MSG_CREATE_VOLUME_PANEL));
	create_volume_panel->SetButtonLabel(B_DEFAULT_BUTTON, GetString(STR_CREATE_VOLUME_PANEL_BUTTON));
	create_volume_panel->Window()->SetTitle(GetString(STR_CREATE_VOLUME_TITLE));

	create_volume_panel->Window()->Lock();
	BView *background = create_volume_panel->Window()->ChildAt(0);
	background->FindView("PoseView")->ResizeBy(0, -30);
	background->FindView("VScrollBar")->ResizeBy(0, -30);
	background->FindView("CountVw")->MoveBy(0, -30);
	BView *v = background->FindView("HScrollBar");
	if (v)
		v->MoveBy(0, -30);
	else {
		i = 0;
		while ((v = background->ChildAt(i++)) != NULL) {
			if (v->Name() == NULL || v->Name()[0] == 0) {
				v->MoveBy(0, -30);	// unnamed horizontal scroll bar
				break;
			}
		}
	}
	BView *filename = background->FindView("text view");
	BRect fnr(filename->Frame());
	fnr.OffsetBy(0, -30);
	NumberControl *nc = new NumberControl(fnr, 80, "hardfile_size", GetString(STR_HARDFILE_SIZE_CTRL), 40, NULL);
	background->AddChild(nc);
	create_volume_panel->Window()->Unlock();

	// "Start" button
	BButton *button = new BButton(BRect(20, top_frame.bottom-35, 90, top_frame.bottom-10), "start", GetString(STR_START_BUTTON), new BMessage(MSG_OK));
	top->AddChild(button);
	SetDefaultButton(button);

	// "Quit" button
	top->AddChild(new BButton(BRect(top_frame.right-90, top_frame.bottom-35, top_frame.right-20, top_frame.bottom-10), "cancel", GetString(STR_QUIT_BUTTON), new BMessage(MSG_CANCEL)));

	Unlock();
	Show();
}
开发者ID:AlexandreCo,项目名称:macemu,代码行数:92,代码来源:prefs_editor_beos.cpp


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