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


C++ BScrollBar类代码示例

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


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

示例1: r

int32
LibraryWindow::ScanThread(void *data)
{
	LibraryWindow *win = (LibraryWindow *)data;

	float maxwidth;
	BRect r(5,5,105,20);
	
	BView *systemheader = win->AddHeader(r.LeftTop(),TR("System Libraries:"));
	
	win->Lock();
	r = systemheader->Frame();
	win->Unlock();
	maxwidth = r.right;
	
	r.OffsetBy(0,r.Height() + 10);
	
	DPath sysPath = GetSystemPath(B_USER_DEVELOP_DIRECTORY);
	sysPath << "lib/x86";
	BRect out = win->ScanFolder(r.LeftTop(),sysPath.GetFullPath(),&maxwidth);
	if (out != BRect(0,0,-1,-1))
	{
		r = out;
		r.OffsetBy(0,10);
	}
	
	if (gPlatform == PLATFORM_HAIKU || gPlatform == PLATFORM_HAIKU_GCC4)
	{
		BView *commonheader = win->AddHeader(r.LeftTop(),TR("Common Libraries:"));
		win->Lock();
		r = commonheader->Frame();
		win->Unlock();
		maxwidth = MAX(r.right,maxwidth);
		
		r.OffsetBy(0,r.Height() + 10);
		
		out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
							&maxwidth);
		if (out != BRect(0,0,-1,-1))
		{
			r = out;
			r.OffsetBy(0,10);
		}
	}
	
	BView *userheader = win->AddHeader(r.LeftTop(),TR("User Libraries:"));
	win->Lock();
	r = userheader->Frame();
	win->Unlock();
	maxwidth = MAX(r.right,maxwidth);
	
	r.OffsetBy(0,r.Height() + 10);
	
	out = win->ScanFolder(r.LeftTop(),GetSystemPath(B_USER_LIB_DIRECTORY).GetFullPath(),
						&maxwidth);
	if (out.IsValid())
	{
		r = out;
		r.OffsetBy(0,10);
	}
	
	win->Lock();
	BView *top = win->GetBackgroundView();
	BScrollView *scrollView = (BScrollView*)top->FindView("scrollView");
	
	BScrollBar *vbar = scrollView->ScrollBar(B_VERTICAL);
	vbar->SetRange(0, r.bottom - scrollView->Bounds().Height());
	vbar->SetSteps(r.Height() * 2.0,r.Height() * 8.0);
	gSettings.Lock();
	BRect savedframe;
	if (gSettings.FindRect("libwin_frame",&savedframe) == B_OK)
		win->ResizeTo(savedframe.Width(),savedframe.Height());
	gSettings.Unlock();
	
	BStringView *label = (BStringView*)top->FindView("label");
	label->SetText(TR("Choose the system libraries for your project."));
	float minw = label->Frame().right + 10;
	win->SetSizeLimits(minw,30000,200,30000);
	if (win->Bounds().Width() < minw)
		win->ResizeTo(minw,win->Bounds().Height());
	win->fScanThread = -1;
	win->Unlock();
	
	return 0;
}
开发者ID:passick,项目名称:Paladin,代码行数:85,代码来源:LibWindow.cpp

示例2: switch


//.........这里部分代码省略.........
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( ++endPos < len);
						if (mods & B_SHIFT_KEY) {
							Select( startPos, wordEnd);
						} else
							Select( wordEnd, wordEnd);
					}
					ScrollToSelection();
				} else
					inherited::KeyDown( bytes, numBytes);
				break;
			}
			case B_LEFT_ARROW: {
				// implement word-wise movement:
				int32 mods = Window()->CurrentMessage()->FindInt32("modifiers");
				if (mods & (B_LEFT_CONTROL_KEY | B_RIGHT_OPTION_KEY)) {
					int32 startPos, endPos;
					GetSelection( &startPos, &endPos);
					if (!startPos)
						break;
					if (startPos==endPos && (mods & B_SHIFT_KEY))
						m_selection_start=B_LEFT_ARROW;
					int32 wordStart, wordEnd;
					if (mods & B_SHIFT_KEY && m_selection_start==B_RIGHT_ARROW) {
						--endPos;
						do {
							FindWord( endPos, &wordStart, &wordEnd);
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( --endPos > 0);
						Select( startPos, MAX( startPos, wordStart));
					} else {
						--startPos;
						do {
							FindWord( startPos, &wordStart, &wordEnd);
							if (wordEnd > wordStart+1)
								break;
							if (wordEnd == wordStart+1 && ByteAt( wordStart)!=' ')
								break;
						} while( --startPos > 0);
						if (mods & B_SHIFT_KEY)
							Select( wordStart, endPos);
						else
							Select( wordStart, wordStart);
					}
					ScrollToSelection();
				} else
					inherited::KeyDown( bytes, numBytes);
				break;
			}
			default:
				inherited::KeyDown( bytes, numBytes);
				break;
		}
	} else if ( numBytes == 1 ) {
		// in read-only mode, we use cursor-keys to move scrollbar, and
		// we remap HOME / END to the vertical scrollbar (not the horizontal,
		// which is default).
		switch( bytes[0]) {
			case B_PAGE_UP:
			case B_PAGE_DOWN:
			case B_UP_ARROW:
			case B_DOWN_ARROW:
			case B_HOME: 
			case B_END: {
				// move vertical scrollbar:
				float min, max, smallStep, bigStep, value;
				BScrollBar* bar = ScrollBar( B_VERTICAL);
				if (!bar) 	return;
				bar->GetRange( &min, &max);
				bar->GetSteps( &smallStep, &bigStep);
				value = bar->Value();
				if (bytes[0] == B_UP_ARROW) {
					value = MAX( value-smallStep, min);
				} else if (bytes[0] == B_DOWN_ARROW) {
					value = MIN( value+smallStep, max);
				} else if (bytes[0] == B_PAGE_UP) {
					value = MAX( value-bigStep, min);
				} else if (bytes[0] == B_PAGE_DOWN) {
					value = MIN( value+bigStep, max);
				} else if (bytes[0] == B_HOME) {
					value = min;
				} else if (bytes[0] == B_END) {
					value = max;
				}
				bar->SetValue( value);
				break;
			}
			default:
				BTextView::KeyDown( bytes, numBytes);
				break;
		}
	} else
		inherited::KeyDown( bytes, numBytes);
}
开发者ID:HaikuArchives,项目名称:Beam,代码行数:101,代码来源:WrappingTextView.cpp

示例3: BFilePanel

// SavePanel class
SavePanel::SavePanel(const char* name,
					 BMessenger* target,
					 entry_ref* startDirectory,
					 uint32 nodeFlavors,
					 bool allowMultipleSelection,
					 BMessage* message,
					 BRefFilter* filter,
					 bool modal,
					 bool hideWhenDone)
	: BFilePanel(B_SAVE_PANEL, target, startDirectory,
				 nodeFlavors, allowMultipleSelection,
				 message, filter, modal, hideWhenDone),
	  BHandler(name),
	  fConfigWindow(NULL),
	  fFormatM(NULL),
	  fExportMode(EXPORT_MODE_ICON_RDEF)
{
	BWindow* window = Window();
	if (!window || !window->Lock())
		return;

	window->SetTitle(B_TRANSLATE("Save image"));

	// add this instance as BHandler to the window's looper
	window->AddHandler(this);
	
	// find a couple of important views and mess with their layout
	BView* background = Window()->ChildAt(0);
	BButton* cancel = dynamic_cast<BButton*>(background->FindView("cancel button"));
	BView* textview = background->FindView("text view");
	BScrollBar* hscrollbar = dynamic_cast<BScrollBar*>(background->FindView("HScrollBar"));

	if (!background || !cancel || !textview || !hscrollbar) {
		printf("SavePanel::SavePanel() - couldn't find necessary controls.\n");
		return;
	}

	_BuildMenu();

	BRect rect = textview->Frame();
	rect.top = cancel->Frame().top;
	font_height fh;
	be_plain_font->GetHeight(&fh);
	rect.bottom = rect.top + fh.ascent + fh.descent + 5.0;

	fFormatMF = new BMenuField(rect, "format popup", B_TRANSLATE("Format"),
								fFormatM, true,	
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
								B_WILL_DRAW | B_NAVIGABLE);
	fFormatMF->SetDivider(be_plain_font->StringWidth(
		B_TRANSLATE("Format")) + 7);
	fFormatMF->MenuBar()->ResizeToPreferred();
	fFormatMF->ResizeToPreferred();

	float height = fFormatMF->Bounds().Height() + 8.0;

	// find all the views that are in the way and
	// move up them up the height of the menu field
	BView *poseview = background->FindView("PoseView");
	if (poseview) poseview->ResizeBy(0, -height);
	BButton *insert = (BButton *)background->FindView("default button");
	if (hscrollbar) hscrollbar->MoveBy(0, -height);
	BScrollBar *vscrollbar = (BScrollBar *)background->FindView("VScrollBar");
	if (vscrollbar) vscrollbar->ResizeBy(0, -height);
	BView *countvw = (BView *)background->FindView("CountVw");
	if (countvw) countvw->MoveBy(0, -height);
	textview->MoveBy(0, -height);

#if HAIKU_TARGET_PLATFORM_DANO
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top + 2);
#else
	fFormatMF->MoveTo(textview->Frame().left, fFormatMF->Frame().top);
#endif

	background->AddChild(fFormatMF);

	// Build the "Settings" button relative to the format menu
	rect = cancel->Frame();
	rect.OffsetTo(fFormatMF->Frame().right + 5.0, rect.top);
	fSettingsB = new BButton(rect, "settings", 
							 B_TRANSLATE("Settings"B_UTF8_ELLIPSIS),
							 new BMessage(MSG_SETTINGS),
							 B_FOLLOW_LEFT | B_FOLLOW_BOTTOM,
							 B_WILL_DRAW | B_NAVIGABLE);
	fSettingsB->ResizeToPreferred();
	background->AddChild(fSettingsB);
	fSettingsB->SetTarget(this);

	textview->ResizeTo(fSettingsB->Frame().right - fFormatMF->Frame().left,
					   textview->Frame().Height());

	// Make sure the smallest window won't draw the "Settings" button over anything else
	float minWindowWidth = textview->Bounds().Width()
							+ cancel->Bounds().Width()
							+ (insert ? insert->Bounds().Width() : 0.0)
							+ 90;
	Window()->SetSizeLimits(minWindowWidth, 10000, 250, 10000);
	if (Window()->Bounds().IntegerWidth() + 1 < minWindowWidth)
		Window()->ResizeTo(minWindowWidth, Window()->Bounds().Height());
//.........这里部分代码省略.........
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:101,代码来源:SavePanel.cpp

示例4: DWindow


//.........这里部分代码省略.........
	
	r = label->Frame();
	r.OffsetBy(0,r.Height() + 5.0);
	
	// We create a button now so that the list expands to fill the entire window
	// while leaving space for the two buttons at the bottom. Note that we do not
	// actually add the button to the window until later to preserve proper
	// keyboard navigation order
	BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"),
								new BMessage(M_SHOW_ADD_PATH),
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	add->ResizeToPreferred();
	add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height());
	
	r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH;
	r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT;
	fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder());
	BScrollView *scrollView = new BScrollView("scrollview",fIncludeList,
											B_FOLLOW_ALL,0, true, true);
	scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fGeneralView->AddChild(scrollView);
	
	float width = 0.0;
	for (int32 i = 0; i < fProject->CountLocalIncludes(); i++)
	{
		BStringItem *item = new BStringItem(fProject->LocalIncludeAt(i).Relative().String());
		float strwidth = fIncludeList->StringWidth(item->Text());
		width = MAX(width, strwidth);
		fIncludeList->AddItem(item);
	}
	
	if (width > fIncludeList->Bounds().Width())
	{
		BScrollBar *hbar = scrollView->ScrollBar(B_HORIZONTAL);
		hbar->SetRange(0.0, width - fIncludeList->Bounds().Width());
	}
	
	SetToolTip(fIncludeList,TR("The folders you want Paladin to search for header files"));
	
	fGeneralView->AddChild(add);
	
	BButton *remove = new BButton(BRect(0,0,1,1),"removebutton",TR("Remove"),
								new BMessage(M_REMOVE_PATH), 
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	remove->ResizeToPreferred();
	remove->MoveTo(add->Frame().right + 10.0, add->Frame().top);
	fGeneralView->AddChild(remove);
	
	r = bounds;
	fBuildView = new BView(bounds.OffsetByCopy(5,5),TR("Build"),B_FOLLOW_ALL,B_WILL_DRAW);
	fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTabView->AddTab(fBuildView);
	
	menu = new BMenu(TR("Optimization"));
	menu->AddItem(new BMenuItem(TR("None"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("Some"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("More"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("Full"),new BMessage(M_SET_OP_VALUE)));
	
	r.right = (bounds.right - 5.0) / 2.0;
	r.bottom = r.top + 25;
	fOpField = new BMenuField(r,"optimize",TR("Optimize"),menu);
	fBuildView->AddChild(fOpField);
	fOpField->SetDivider(fOpField->StringWidth(TR("Optimize")) + 5.0);
	
	SetToolTip(fOpField,TR("Compiler optimization level. Disabled when debugging info is checked."));
开发者ID:passick,项目名称:Paladin,代码行数:67,代码来源:ProjectSettingsWindow.cpp

示例5: Bounds

void ColumnListView::UpdateScrollBars()
{
	if(fScrollView)
	{
		//Figure out the bounds and scroll if necessary
		BRect ViewBounds;
		float DeltaX,DeltaY;
		do
		{
			ViewBounds = Bounds();
			//Figure out the width of the page rectangle
			fPageWidth = fDataWidth;
			fPageHeight = fDataHeight;
			//If view runs past the end, make more visible at the beginning
			DeltaX = 0.0;
			if(ViewBounds.right > fDataWidth && ViewBounds.left > 0)
			{
				DeltaX = ViewBounds.right-fDataWidth;
				if(DeltaX > ViewBounds.left)
					DeltaX = ViewBounds.left;
			}
			DeltaY = 0.0;
			if(ViewBounds.bottom > fDataHeight && ViewBounds.top > 0)
			{
				DeltaY = ViewBounds.bottom-fDataHeight;
				if(DeltaY > ViewBounds.top)
					DeltaY = ViewBounds.top;
			}
			if(DeltaX != 0.0 || DeltaY != 0.0)
			{
				ScrollTo(BPoint(ViewBounds.left-DeltaX,ViewBounds.top-DeltaY));
				ViewBounds = Bounds();
			}
			if(ViewBounds.right-ViewBounds.left > fDataWidth)
				fPageWidth = ViewBounds.right;
			if(ViewBounds.bottom-ViewBounds.top > fDataHeight)
				fPageHeight = ViewBounds.bottom;
		}while(DeltaX != 0.0 || DeltaY != 0.0);
	
		//Figure out the ratio of the bounds rectangle width or height to the page rectangle width or height
		float WidthProp = (ViewBounds.right-ViewBounds.left)/fPageWidth;
		float HeightProp = (ViewBounds.bottom-ViewBounds.top)/fPageHeight;

		BScrollBar* HScrollBar = fScrollView->ScrollBar(B_HORIZONTAL);
		BScrollBar* VScrollBar = fScrollView->ScrollBar(B_VERTICAL);
		//Set the scroll bar ranges and proportions.  If the whole document is visible, inactivate the
		//slider
		if(HScrollBar)
		{
			if(WidthProp >= 1.0 && ViewBounds.left == 0.0)
				HScrollBar->SetRange(0.0,0.0);
			else
				HScrollBar->SetRange(0.0,fPageWidth-(ViewBounds.right-ViewBounds.left));
			HScrollBar->SetProportion(WidthProp);
			//Set the step values
			HScrollBar->SetSteps(20.0,ViewBounds.right-ViewBounds.left);
		}
		if(VScrollBar)
		{
			if(HeightProp >= 1.0 && ViewBounds.top == 0.0)
			{
				VScrollBar->SetRange(0.0,0.0);
				if(fFillerView)
					fFillerView->SetViewColor(BeInactiveControlGrey);
			}
			else
			{
				VScrollBar->SetRange(0.0,fPageHeight-(ViewBounds.bottom-ViewBounds.top));
				if(fFillerView)
					fFillerView->SetViewColor(BeBackgroundGrey);
			}
			VScrollBar->SetProportion(HeightProp);
		}
	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:75,代码来源:ColumnListView.cpp

示例6: switch

void ChatWindow::MessageReceived( BMessage* aMessage ) {
	switch( aMessage->what ) {
		case SHOW_MESSAGE:
			{
			const char *msg;
			aMessage->FindString( "msg", &msg );
			time_t _now = time( NULL );
			struct tm *now = localtime( &_now );
			BString *str = NULL;
			BString *str2 = NULL;
			char *string = NULL;
			Person *person = NULL;
			for( int i = 0; i < iWindow->GetProfile()->GetUserlist()->GetList()->CountItems(); i++ ) {
				person = ( Person* ) iWindow->GetProfile()->GetUserlist()->GetList()->ItemAt( i );
				if( iWho == person->GetUIN() ) {
					str = new BString();
					str->SetTo( person->GetDisplay() );
					break;
				}
			}
			if( !str ) {
				str = new BString();
				*str << ( int32 ) iWho;
			}
			BFont *font = new BFont( be_plain_font );
			font->SetSize( 16.0 );
			font->SetEncoding( B_ISO_8859_2 );
			rgb_color yellow = { 255, 255, 0, 0 };
			rgb_color red = { 255, 0, 0, 0 };
			rgb_color white = { 255, 255, 255, 0 };
			string = ( char* ) calloc( strlen( "[00:00] " ), 1 );
			sprintf( string, "[%02d:%02d] ", now->tm_hour, now->tm_min);
			str2 = new BString();
			str2->SetTo( string );
			free( string );
			iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2->Length(), font, B_FONT_ALL, &yellow );
			iChat->Insert( iChat->TextLength(), str2->String(), str2->Length() );
			str->Append( ": " );

			iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str->Length(), font, B_FONT_ALL, &red );
			iChat->Insert( iChat->TextLength(), str->String(), str->Length() );

			str2->SetTo( msg );
			str2->Append( "\n" );
			iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2->Length(), font, B_FONT_ALL, &white );
			iChat->Insert( iChat->TextLength(), str2->String(), str2->Length() );
			BScrollBar * scrollBar = iScrollView->ScrollBar( B_VERTICAL );
			if( scrollBar->LockLooper() ) {
				float max,min;
				scrollBar->GetRange( &min, &max );
				scrollBar->SetValue( max );
				scrollBar->UnlockLooper();
			}
			delete str;
			delete str2;
			break;			
			}
		case BEGG_SEND:
			{
			if( iSayControl->LockLooper()) {
				if( !(*iSayControl->Text() ) ) {
					/* nothing to send */
					iSayControl->UnlockLooper();
					break;
				}
				/* first we add message into chat window */
				time_t _now = time( NULL );
				struct tm * now = localtime( &_now );
				BString str;
				BString str2;
				char *string;
//				int id = iNetwork->GetIdent();

				BFont *font = new BFont( be_plain_font );
				font->SetSize( 16.0 );
				font->SetEncoding( B_ISO_8859_2 );
				rgb_color yellow = { 255, 255, 0, 0 };
				rgb_color green = { 0, 255, 0, 0 };
				rgb_color white = { 255, 255, 255, 0 };
				string = ( char* ) calloc( strlen( "[00:00] " ), 1 );
				sprintf( string, "[%02d:%02d] ", now->tm_hour, now->tm_min );
				str2.SetTo( string );
				free( string );
				iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2.Length(), font, B_FONT_ALL, &yellow );
				iChat->Insert( iChat->TextLength(), str2.String(), str2.Length() );

				str.SetTo( iWindow->GetProfile()->GetProfileName() );
				str.Append( ": " );
				iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str.Length(), font, B_FONT_ALL, &green );
				iChat->Insert( iChat->TextLength(), str.String(), str.Length() );

				str2.SetTo( iSayControl->Text() );
				str2.Append( "\n" );
				iChat->SetFontAndColor( iChat->TextLength(), iChat->TextLength() + str2.Length(), font, B_FONT_ALL, &white );
				iChat->Insert( iChat->TextLength(), str2.String(), str2.Length() );

				/* scroll down */
				BScrollBar * scrollBar = iScrollView->ScrollBar( B_VERTICAL );
				if( scrollBar->LockLooper() ) {
					float max,min;
//.........这里部分代码省略.........
开发者ID:louisdem,项目名称:beos-begadu,代码行数:101,代码来源:Chat.cpp


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