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


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

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


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

示例1: LocationForReplicant

void
TReplicantTray::RealignReplicants(int32 startIndex)
{
	if (startIndex < 0)
		startIndex = 0;

	int32 count = fShelf->CountReplicants();
	if (count <= 0)
		return;

	if (startIndex == 0)
		fRightBottomReplicant.Set(0, 0, 0, 0);

	BView* view = NULL;
	for (int32 i = startIndex ; i < count ; i++) {
		fShelf->ReplicantAt(i, &view);
		if (view != NULL) {
			BPoint loc = LocationForReplicant(i, view->Frame().Width());
			if (view->Frame().LeftTop() != loc)
				view->MoveTo(loc);
		}
	}
}
开发者ID:DonCN,项目名称:haiku,代码行数:23,代码来源:StatusView.cpp

示例2: LayoutVertical

void ArpKnobPanel::LayoutVertical(	const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceY = 3;
	float			top = 0;
	float			widest = 0;		// Cache the widest view just to save ourselves an
									// extra iteration over the views
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( 0, top, 0 + w, top + fh ),
								"label", label );
		if( sv ) {
			AddChild( sv );
			if( w > widest ) widest = w;
		}
		top += fh + spaceY;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(0, top, knobW, top + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		if( knobW > widest ) widest = knobW;
		top += knobH + spaceY;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(0, top, w, top + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
			if( w > widest ) widest = w;
		}
	}
	/* Now center everything based on the widest view.
	 */
	if( !sv && !intCtrl ) return;
	if( widest <= 0 ) return;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Width() < widest )
			view->MoveTo( (widest - f.Width()) / 2, f.top );
	}		
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:70,代码来源:ArpKnobControl.cpp

示例3: LayoutHorizontal

void ArpKnobPanel::LayoutHorizontal(const char* name, const char* label, BMessage* message,
									int32 minValue, int32 maxValue,
									bool showIntControl, uint32 knobFlags, float labelWidth,
									float intControlWidth)
{
	const BFont*	font = be_plain_font;
	float			fh = arp_get_font_height(font);
	float			spaceX = 8;
	float			left = 0;
	/* Add label
	 */
	BStringView*	sv = 0;
	if( label ) {
		float		w = (labelWidth >= 0) ? labelWidth : font->StringWidth( label );
		sv = new BStringView(	BRect( left, 0, left + w, 0 + fh ),
								"label", label );
		if( sv ) AddChild( sv );
		left += w + spaceX;
	}
	/* Add knob
	 */
	float			knobW, knobH;
	if( knobFlags&ARP_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_X);
		knobH = Prefs().Size(KNOB_RING_Y);
	} else if( knobFlags&ARP_TIGHT_RING_ADORNMENT ) {
		knobW = Prefs().Size(KNOB_RING_TIGHT_X);
		knobH = Prefs().Size(KNOB_RING_TIGHT_Y);
	} else {
		knobW = Prefs().Size(KNOB_X);
		knobH = Prefs().Size(KNOB_Y);
	}
	ArpKnobControl* knob = new ArpKnobControl(	BRect(left, 0, left + knobW, 0 + knobH ),
												name, message, minValue, maxValue, knobFlags);
	if( knob ) {
		AddChild( knob );
		left += knobW + spaceX;
	}
	/* Add int control
	 */
	ArpIntControl*	intCtrl = 0;
	if( showIntControl ) {
		float		w = (intControlWidth >= 0) ? intControlWidth : knobW;
		intCtrl = new ArpIntControl( BRect(left, 0, left + w, 0 + Prefs().Size(INT_CTRL_Y) ),
									"int_control", 0, 0);
		if( intCtrl ) {
			intCtrl->SetLimits( minValue, maxValue );
			if( knob ) knob->SetIntControl( intCtrl );
			AddChild( intCtrl );
		}
	}
	/* Now center everything based on the tallest view.
	 */
	if( !sv && !intCtrl ) return;
	float	tallest = (knobH > fh) ? knobH : fh;

	BView*	view;
	for( view = ChildAt(0); view; view = view->NextSibling() ) {
		BRect	f = view->Frame();
		if( f.Height() < tallest )
			view->MoveTo( f.left, (tallest - f.Height()) / 2 );
	}		
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:63,代码来源:ArpKnobControl.cpp

示例4: BuildGUI


//.........这里部分代码省略.........
					name, _T(desc), enabling);
			
				if (active) ((BCheckBox*)control)->SetValue(B_CONTROL_ON);
				
			} break;			
			default: {
				continue;
			};
		};
		
		if (!value) value = "";
		
		if (!control) {
			if (freeText) {
				if (multiLine == false) {
					control = new BTextControl(
						BRect(0, 0, kControlWidth, fFontHeight), name,
						_T(desc), value, NULL);
					if (secret) {
						((BTextControl *)control)->TextView()->HideTyping(true);
						((BTextControl *)control)->SetText(_T(value));
					};
					((BTextControl *)control)->SetDivider(kDividerWidth);
				} else 
				{
					BRect rect;
					BRect textRect;
					if (desc) //andrea: add description only if available.
					{
						BRect labelRect(0, 0, kDividerWidth, fFontHeight);
						BStringView *label = new BStringView(labelRect, "NA", _T(desc),
							B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
						view->AddChild(label);
						label->MoveTo(kEdgeOffset, yOffset);

						rect = BRect(0, 0, kControlWidth - kDividerWidth, fFontHeight * 4);
						rect.right -= B_V_SCROLL_BAR_WIDTH + kEdgeOffset + kControlOffset;
						xOffset = kEdgeOffset + kDividerWidth;
					}
					else
					{
						rect = BRect(0, 0, kControlWidth, fFontHeight * 4);
						rect.right -= B_V_SCROLL_BAR_WIDTH + kControlOffset;
						xOffset = 0;
					}
					
					textRect = rect;
					textRect.InsetBy(kEdgeOffset, kEdgeOffset);
					textRect.OffsetTo(1.0, 1.0);
						
					BTextView *textView = new BTextView(rect, name, textRect,
						B_FOLLOW_ALL_SIDES, B_WILL_DRAW);

					control = new BScrollView("NA", textView, B_FOLLOW_ALL_SIDES,
						B_WILL_DRAW | B_NAVIGABLE, false, true);
					textView->SetText(_T(value));			
				};
			} else {
				control = new BMenuField(BRect(0, 0, kControlWidth, fFontHeight),
					name, _T(desc), menu);
				
				float size=kDividerWidth;
				if(control->StringWidth(_T(desc)) > kDividerWidth)
					size=control->StringWidth(_T(desc)) + 20;
				
				((BMenuField *)control)->SetDivider(size);
开发者ID:Haikeek,项目名称:BePodder,代码行数:67,代码来源:PBox.cpp

示例5: MouseMoved

void SeqSplitterView::MouseMoved(	BPoint where,
									uint32 code,
									const BMessage* message)
{
	if (code == B_ENTERED_VIEW) {
		if (mDirection == B_VERTICAL && gVrtCursor) SetViewCursor(gVrtCursor);
		if (mDirection == B_HORIZONTAL && gHrzCursor) SetViewCursor(gHrzCursor);
	}
	if( !mMouseDown || !Window() || !Window()->CurrentMessage() ) return;
	BView*	prev = PreviousSibling();
	BView*	next = NextSibling();
	if( !prev || !next ) return;
	
	// The mouse moved message's "where" field is in window
	// coordinates.  We need to use that instead of view
	// coordinates because the changes in this view's frame
	// are asynchronous with the mouse events we receive.
	BPoint	screenWhere;
	Window()->CurrentMessage()->FindPoint("where", &screenWhere);
	Window()->ConvertToScreen(&screenWhere);
	BPoint	delta = screenWhere - mPointDown;
	
	bool	locked = false;
//printf("recived mouse of %f\n", where.x);

if( Window() && Window()->Lock() ) {
	locked = true;
	Window()->BeginViewTransaction();
}
	if( mDirection == B_VERTICAL ) {
		/* Move me
		 */
		float	prevLeft = prev->Frame().left;
		float	nextRight = next->Frame().right;
		float	x = mFrameDown.left + delta.x;
		float	y = mFrameDown.top;
		if( x < prevLeft ) x = prevLeft;
		if( x + Bounds().Width() > nextRight ) x = nextRight - Bounds().Width();
		MoveTo( x, y );
		/* Move prev
		 */
		float	height = prev->Bounds().Height();
		float	prevRight = Frame().left - 1;
		prev->ResizeTo( prevRight - prevLeft, height );
		/* Move next
		 */
		height = next->Bounds().Height();
		float	nextTop = next->Frame().top;
		float	nextLeft = Frame().right + 1;
//printf("\tsending out move to %f\n", nextLeft);
		BRect	f = next->Frame();
		if( f.left != nextLeft ) next->MoveTo( nextLeft, nextTop );
		if( f.Width() != nextRight - nextLeft ) next->ResizeTo( nextRight - nextLeft, height );
#if 0
		next->MoveTo( nextLeft, nextTop );
		next->ResizeTo( nextRight - nextLeft, height );
#endif
	} else {
		/* Move me
		 */
		float	prevTop = prev->Frame().top;
		float	nextBottom = next->Frame().bottom;
		float	x = mFrameDown.left;
		float	y = mFrameDown.top + delta.y;
		if( y < prevTop ) y = prevTop;
		if( y + Bounds().Height() > nextBottom ) y = nextBottom - Bounds().Height();
		MoveTo( x, y );
		/* Move prev
		 */
		float	width = prev->Bounds().Width();
		float	prevBottom = Frame().top - 1;
		prev->ResizeTo( width, prevBottom - prevTop );
		/* Move next
		 */
		width = next->Bounds().Width();
		float	nextLeft = next->Frame().left;
		float	nextTop = Frame().bottom + 1;
		next->MoveTo( nextLeft, nextTop );
		next->ResizeTo( width, nextBottom - nextTop );
	}
if( locked ) {
	Window()->EndViewTransaction();
	Window()->Unlock();
}
}
开发者ID:tgkokk,项目名称:Sequitur,代码行数:85,代码来源:SeqSplitterView.cpp

示例6: if


//.........这里部分代码省略.........
			{
				MyButton * pholdDemoMyButton = new MyButton(	"demoButton", 
																myPrefs->DemoButtonLabel, 
																DEMOBUTTONMSG,
																pholdDemoLayoutMatrix);
				kindDemo = KIND_MYBUTTON;
				pholdDemo = (void *)pholdDemoMyButton;
			}
			break;
			case SPECIFIC_COLOR_PICTURE:
			{
				BPicture * pOnPicture;
				BPicture * pOnDisabledPicture;
				BPicture * pOffPicture;
				BPicture * pOffDisabledPicture;
				BWindow * bWindow = new BWindow(	BRect(0, 0, 32, 32), //manditory for BPicture
													NULL, 
													B_DOCUMENT_WINDOW, 
													0);
				BView * bView = new BView(	BRect(0, 0, 32, 32), 
											NULL, 
											B_FOLLOW_NONE, 
											0);
//				BWindow bWindow(	BRect(0, 0, 32, 32), //manditory for BPicture
//									NULL, 
//									B_DOCUMENT_WINDOW, 
//									0);
//				BView bView(	BRect(0, 0, 32, 32), 
//								NULL, 
//								B_FOLLOW_NONE, 
//								0);
				bWindow->AddChild(bView);
				bView->BeginPicture(new BPicture);
				bView->MoveTo(5, 5);
				bView->StrokeRect(BRect(0,0,8,8));
				pOffPicture = bView->EndPicture();
				
				bView->BeginPicture(new BPicture);
				bView->MoveTo(10, 5);
				bView->StrokeRect(BRect(0,0,10,15));
				pOnPicture = bView->EndPicture();
				
				bView->BeginPicture(new BPicture);
				bView->MoveTo(2, 5);
				bView->FillRect(BRect(0,0,22,20));
				pOffDisabledPicture = bView->EndPicture();
				
				bView->BeginPicture(new BPicture);
				bView->MoveTo(1, 5);
				bView->FillRect(BRect(0,0,6,15));
				pOnDisabledPicture = bView->EndPicture();
				//bView.RemoveSelf();
				bWindow->Run();
				bWindow->PostMessage(B_QUIT_REQUESTED);
				MyPictureButton * pholdDemoMyPictureButton = new MyPictureButton(	BRect(0, 0, 32, 32),
																					"DemoPictureButton", 
																					pOffPicture,
																					pOnPicture,
																					pOffDisabledPicture,
																					pOnDisabledPicture,
																					DEMOPICTUREBUTTONMSG,
																					B_TWO_STATE_BUTTON,//B_ONE_STATE_BUTTON
																					pholdDemoLayoutMatrix);
				kindDemo = KIND_MYPICTUREBUTTON;
				pholdDemo = (void *)pholdDemoMyPictureButton;
			}
开发者ID:DonkeyWs,项目名称:BeGUI,代码行数:67,代码来源:specificColorWindowCTOR.cpp

示例7: separatorRect


//.........这里部分代码省略.........
	TitleView *titleView = dynamic_cast<TitleView *>((BView *)views.ItemAt(0));
	if (titleView != NULL) {
		view->AddChild(titleView);
		rect.OffsetBy(0, titleView->Bounds().Height());
	}

	// Add the sub-group views

	rect.right = rect.left + 20;
	rect.bottom = rect.top + 20;
	float lastHeight = 0;

	for (int32 i = 0; i < group.CountGroups(); i++) {
		BParameterGroup *subGroup = group.GroupAt(i);
		if (subGroup == NULL)
			continue;

		BView *groupView = MakeViewFor(*subGroup, &rect);
		if (groupView == NULL)
			continue;

		if (i > 0) {
			// add separator view
			BRect separatorRect(groupView->Frame());
			separatorRect.left -= 3;
			separatorRect.right = separatorRect.left + 1;
			if (lastHeight > separatorRect.Height())
				separatorRect.bottom = separatorRect.top + lastHeight;

			view->AddChild(new SeparatorView(separatorRect));
		}

		view->AddChild(groupView);

		rect.OffsetBy(groupView->Bounds().Width() + 5, 0);

		lastHeight = groupView->Bounds().Height();
		if (lastHeight > rect.Height())
			rect.bottom = rect.top + lastHeight - 1;
	}

	view->ResizeTo(rect.left + 10, rect.bottom + 5);
	view->SetContentBounds(view->Bounds());

	if (group.CountParameters() == 0)
		return view;

	// add the parameter views part of the group

	if (group.CountGroups() > 0) {
		rect.top = rect.bottom + 10;
		rect.bottom = rect.top + 20;
	}

	bool center = false;

	for (int32 i = 0; i < views.CountItems(); i++) {
		BView *parameterView = static_cast<BView *>(views.ItemAt(i));

		if (parameterView->Bounds().Width() + 5 > rect.Width())
			rect.right = parameterView->Bounds().Width() + rect.left + 5;

		// we don't need to add the title view again
		if (parameterView == titleView)
			continue;

		// if there is a BChannelSlider (ToDo: or any vertical slider?)
		// the views will be centered
		if (dynamic_cast<BChannelSlider *>(parameterView) != NULL)
			center = true;

		parameterView->MoveTo(parameterView->Frame().left, rect.top);
		view->AddChild(parameterView);

		rect.OffsetBy(0, parameterView->Bounds().Height() + 5);
	}

	if (views.CountItems() > (titleView != NULL ? 1 : 0))
		view->ResizeTo(rect.right + 5, rect.top + 5);

	// center the parameter views if needed, and tweak some views

	float width = view->Bounds().Width();

	for (int32 i = 0; i < views.CountItems(); i++) {
		BView *subView = static_cast<BView *>(views.ItemAt(i));
		BRect frame = subView->Frame();

		if (center)
			subView->MoveTo((width - frame.Width()) / 2, frame.top);
		else {
			// tweak the PopUp views to look better
			if (dynamic_cast<BOptionPopUp *>(subView) != NULL)
				subView->ResizeTo(width, frame.Height());
		}
	}

	view->SetContentBounds(view->Bounds());
	return view;
}
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:DefaultMediaTheme.cpp

示例8: MakeTermSettings

void TestWindow::MakeTermSettings()
{
	BView* settings = 0;
	BView* root = 0;
	BWindow* win = 0;
	
	try {
		// Pick some arbitrary initial frame for the window.
		BRect initFrame(0,0,100,100);
		
		// Create our three objects: the settings view, the top-level view
		// in the window, and the window itself.
		settings = GetTermSettings(BMessenger(), BMessage());
		root = new BView(initFrame, "root", B_FOLLOW_ALL, B_WILL_DRAW);
		win = new BWindow(initFrame, "Terminal Settings",
							B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
							B_ASYNCHRONOUS_CONTROLS);
		
		// Set the background color of the root view and add it to the window.
		root->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		win->AddChild(root);
		
		// Set the size and position of the settings view -- inset a little
		// from the root -- and add it.
		float fw = be_plain_font->StringWidth("W");
		font_height fhs;
		be_plain_font->GetHeight(&fhs);
		float fh = fhs.ascent+fhs.descent+fhs.leading;
		
		settings->MoveTo(fw, fh);
		settings->ResizeTo(initFrame.right-fw*2, initFrame.bottom-fh*2);
		root->AddChild(settings);
		
		win->Run();
		mTermWin = win;
		mTermSet = settings;
		
		if( root ) {
			// Send a message to the view with our current global settings.
			// If the view is an ArpRootView, it will get the message and
			// know what to do with it.
			const BMessage* curGlobs = this->root->Globals()->GlobalValues();
			if( curGlobs ) {
				BMessage globals(*curGlobs);
				globals.what = ARP_PREF_MSG;
				BMessage ret;
				mTermSet.SendMessage(&globals, &ret);
			}
		}
		
		// Get preferred size of settings view, and make final window dimensions
		// from this.
		float width=0, height=0;
		settings->GetPreferredSize(&width, &height);
		width += fw*2;
		height += fh*2;
		
		float minw=0,minh=0,maxw=0,maxh=0;
		win->GetSizeLimits(&minw,&maxw,&minh,&maxh);
		win->SetSizeLimits(width,maxw,height,maxh);
		
		BRect frm = Frame();
		win->ResizeTo(width, height);
		BRect cfrm = Frame();
		win->MoveTo( frm.left
					+ (frm.Width()-cfrm.Width())/2,
				 	frm.top
				 	+ (frm.Height()-cfrm.Height())/2);
		
		win->Show();
		mTermWin = win;
		mTermSet = settings;
	} catch(...) {
		delete settings;
		delete root;
		delete win;
	}
}
开发者ID:HaikuArchives,项目名称:Sequitur,代码行数:78,代码来源:LayoutTest.cpp


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