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


C++ BFont::SetFamilyAndStyle方法代码示例

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


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

示例1: BView

TView::TView(BRect frame, const char *name, uint32 resizingMode, uint32 flags)
		: BView(frame, name, resizingMode, flags)
{
	BFont font;

	BButton *btn = new BButton(BRect(10, 10, 150, 50), NULL, "Hello World", new BMessage(BTN_HELLO_WORLD_EN_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimSun", "Regular") == B_OK) btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
	btn->SetFontSize(20);
	AddChild(btn);

	btn = new BButton(BRect(10, 100, 50, 120), NULL, "Ciao Mondo", new BMessage(BTN_HELLO_WORLD_IT_MSG));
	btn->ForceFontAliasing(true);
	if (font.SetFamilyAndStyle("SimHei", "Regular") == B_OK) {
		btn->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
		btn->SetFontSize(24);
	}
	AddChild(btn);
	btn->ResizeToPreferred();

	btn = new BButton(BRect(10, 150, 40, 180), NULL, "Disabled", new BMessage(BTN_NOT_ENABLED_MSG));
	btn->SetEnabled(false);
	AddChild(btn);
	btn->ResizeToPreferred();
}
开发者ID:D-os,项目名称:BeFree,代码行数:25,代码来源:button-test.cpp

示例2: Name

void
FontSelectionView::SetDefaults()
{
	font_family family;
	font_style style;
	float size;
	const char* fontName;

	if (strcmp(Name(), "menu") == 0)
		fontName = "plain";
	else
		fontName = Name();

	if (_get_system_default_font_(fontName, family, style, &size) != B_OK) {
		Revert();
		return;
	}

	BFont defaultFont;
	defaultFont.SetFamilyAndStyle(family, style);
	defaultFont.SetSize(size);

	if (defaultFont == fCurrentFont)
		return;

	_SelectCurrentFont(false);

	fCurrentFont = defaultFont;
	_UpdateFontPreview();

	_SelectCurrentFont(true);
	_SelectCurrentSize();
}
开发者ID:looncraz,项目名称:haiku,代码行数:33,代码来源:FontSelectionView.cpp

示例3:

void
TermWindow::_GetPreferredFont(BFont& font)
{
	// Default to be_fixed_font
	font = be_fixed_font;

	const char* family
		= PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY);
	const char* style
		= PrefHandler::Default()->getString(PREF_HALF_FONT_STYLE);
	const char* size = PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE);

	font.SetFamilyAndStyle(family, style);
	font.SetSize(atoi(size));

	// mark the font size menu item
	for (int32 i = 0; i < fFontSizeMenu->CountItems(); i++) {
		BMenuItem* item = fFontSizeMenu->ItemAt(i);
		if (item == NULL)
			continue;

		item->SetMarked(false);
		if (strcmp(item->Label(), size) == 0)
			item->SetMarked(true);
	}
}
开发者ID:DonCN,项目名称:haiku,代码行数:26,代码来源:TermWindow.cpp

示例4: Read

status_t
CanvasMessage::ReadFontState(BFont& font)
{
	uint8 encoding, spacing;
	uint16 face;
	uint32 flags, familyAndStyle;
	font_direction direction;
	float falseBoldWidth, rotation, shear, size;

	Read(direction);
	Read(encoding);
	Read(flags);
	Read(spacing);
	Read(shear);
	Read(rotation);
	Read(falseBoldWidth);
	Read(size);
	Read(face);
	status_t result = Read(familyAndStyle);
	if (result != B_OK)
		return result;

	font.SetFamilyAndStyle(familyAndStyle);
	font.SetEncoding(encoding);
	font.SetFlags(flags);
	font.SetSpacing(spacing);
	font.SetShear(shear);
	font.SetRotation(rotation);
	font.SetFalseBoldWidth(falseBoldWidth);
	font.SetSize(size);
	font.SetFace(face);
	return B_OK;
}
开发者ID:SummerSnail2014,项目名称:haiku,代码行数:33,代码来源:CanvasMessage.cpp

示例5: AttachedToWindow

void DrumsetDropField::AttachedToWindow() {
	
	BFont font;
	font.SetFamilyAndStyle("Swis721 BT","Roman"); 
	font.SetSize( 8.0 );
	SetFont(&font);
	
	SetLowColor( 66, 99, 132 );
	SetHighColor( 210, 220, 230 );
		
	BeginPicture( new BPicture() );
	DrawBitmap(((App *)be_app)->FetchResourceBitmap("dropfield"), BPoint(0.0, 0.0));
	DrawString("Drop instrument here!", BPoint(6.0, 12.0));
	fNormalBitmap = EndPicture();
	
	BeginPicture( new BPicture() );
	DrawBitmap(((App *)be_app)->FetchResourceBitmap("dropfield"), BPoint(0.0, 0.0));
	SetDrawingMode(B_OP_ALPHA);
	SetHighColor(0,0,0,80);
	FillRect(Bounds().InsetByCopy(1.0, 1.0));
	SetHighColor( 255, 255, 255 );
	DrawString("Drop instrument here!", BPoint(7.0, 13.0));
	fActiveBitmap = EndPicture();

	SetTarget(Parent());

}
开发者ID:HaikuArchives,项目名称:PecoBeat,代码行数:27,代码来源:DrumsetDropField.cpp

示例6:

void
CharacterWindow::_SetFont(const char* family, const char* style)
{
	BFont font = fCharacterView->CharacterFont();
	font.SetFamilyAndStyle(family, style);

	fCharacterView->SetCharacterFont(font);
}
开发者ID:mariuz,项目名称:haiku,代码行数:8,代码来源:CharacterWindow.cpp

示例7:

void
CharacterWindow::_SetFont(const char* family, const char* style)
{
	BFont font = fCharacterView->CharacterFont();
	font.SetFamilyAndStyle(family, style);

	fCharacterView->SetCharacterFont(font);
	fGlyphView->SetFont(&font, B_FONT_FAMILY_AND_STYLE);
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:9,代码来源:CharacterWindow.cpp

示例8: Read

bool Bookmark::Read(const char* name) {
	Scanner scnr(name);
	if (scnr.InitCheck() == B_OK) {
		BString s; float version; bool ok;
		ok = scnr.ReadName(&s) && scnr.ReadFloat(&version);
		if (!ok || strcmp(s.String(), "Bookmarks") != 0 || (version != 1.0 && version != 2.0) ) {
			REPORT(kError, 0, "Bookmarks (line %d, column %d): '%s' not a bookmarks file or wrong version!", scnr.Line(), scnr.Column(), name);
			return false;
		}
		
		while (!scnr.IsEOF()) {
			float   level, size;
			bool    expanded = false;
			BString family, style, expand;
			if (!(scnr.ReadFloat(&level) && level >= 1.0 && level <= 10.0)) {
				REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid level", scnr.Line(), scnr.Column());
				return false;
			}
			if (!scnr.ReadString(&family)) {
				REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font family", scnr.Line(), scnr.Column());
				return false;
			}
			if (!scnr.ReadString(&style)) {
				REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font style", scnr.Line(), scnr.Column());
				return false;
			}
			if (!scnr.ReadFloat(&size)) {
				REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid font size", scnr.Line(), scnr.Column());
				return false;
			}
			if (version == 2.0) {
				if (!scnr.ReadName(&expand) || (strcmp(expand.String(), "expanded") != 0 && strcmp(expand.String(), "collapsed") != 0)) {
					REPORT(kError, 0, "Bookmarks (line %d, column %d): Invalid expanded value", scnr.Line(), scnr.Column());
					return false;
				}
				expanded = strcmp(expand.String(), "expanded") == 0;
			}
			
			if (Exists(family.String(), style.String())) {
				BFont font;
				font.SetFamilyAndStyle(family.String(), style.String());
				font.SetSize(size);
			
				AddDefinition((int)level, &font, expanded);
			} else {
				REPORT(kWarning, 0, "Bookmarks (line %d, column %d): Font %s-%s not available!", scnr.Line(), scnr.Column(), family.String(), style.String());
			}
			
			scnr.SkipSpaces();
		}
		return true;
	} else {
		REPORT(kError, 0, "Bookmarks: Could not open bookmarks file '%d'", name);
	}
	return false;
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:56,代码来源:Bookmark.cpp

示例9: Bounds

KouhoWindow::KouhoWindow( BFont *font, BLooper *looper )
	:BWindow(	DUMMY_RECT,
				"kouho", B_MODAL_WINDOW_LOOK,
				B_FLOATING_ALL_WINDOW_FEEL,
				B_NOT_RESIZABLE | B_NOT_CLOSABLE |
				B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_AVOID_FOCUS |
				B_NOT_ANCHORED_ON_ACTIVATE )
{
	float fontHeight;
	BRect frame;
	BFont indexfont;

	cannaLooper = looper;
	kouhoFont = font;

	font_family family;
	font_style style;
	strcpy( family, "Haru" );
	strcpy( style, "Regular" );
	indexfont.SetFamilyAndStyle( family, style );
	indexfont.SetSize( 10 );

#ifdef DEBUG
SERIAL_PRINT(( "kouhoWindow: Constructor called.\n" ));
#endif

	//setup main pane
	indexWidth = indexfont.StringWidth( "W" ) + INDEXVIEW_SIDE_MARGIN * 2;
	minimumWidth = indexfont.StringWidth( "ギリシャ  100/100" );

	frame = Bounds();
	frame.left = indexWidth + 2;
	frame.bottom -= INFOVIEW_HEIGHT;
	kouhoView = new KouhoView( frame );
	BRect screenrect = BScreen( this ).Frame();
	kouhoView->SetTextRect( screenrect ); //big enough
	kouhoView->SetFontAndColor( kouhoFont );
	kouhoView->SetWordWrap( false );
	AddChild( kouhoView );
	fontHeight = kouhoView->LineHeight();

	frame = Bounds();
	frame.right = indexWidth;
	frame.bottom = frame.bottom - INFOVIEW_HEIGHT + 1;
	indexView = new KouhoIndexView( frame, fontHeight );
	indexView->SetFont( &indexfont );
	AddChild( indexView );

	frame = Bounds();
	frame.top = frame.bottom - INFOVIEW_HEIGHT + 1;
	infoView = new KouhoInfoView( frame );
	infoView->SetFont( &indexfont );
	infoView->SetAlignment( B_ALIGN_RIGHT );
	AddChild( infoView );
}
开发者ID:anilkagak2,项目名称:haiku,代码行数:55,代码来源:KouhoWindow.cpp

示例10:

// GetBFont
BFont
Font::GetBFont() const
{
	BFont font;
	font.SetFamilyAndStyle(fFamily.String(), fStyle.String());
	font.SetSize(fSize);
	font.SetRotation(fRotation);
	font.SetShear(fShear);
	font.SetSpacing(fSpacing);
	return font;
}
开发者ID:stippi,项目名称:Clockwerk,代码行数:12,代码来源:Font.cpp

示例11:

/***********************************************************
 * DrawString
 ***********************************************************/
void
HToolbarButton::DrawString(BView *view ,const char* label,bool downState,bool enabled)
{
	BRect bounds = view->Bounds();
	if(NORMAL_WIDTH == bounds.Width())
		return;
	int32 x,y;
	
	BFont font;
	font.SetFamilyAndStyle("Swis721 BT","Roman");
	font.SetSize(10);
	font.SetSpacing(B_BITMAP_SPACING);
	font_height height;
	font.GetHeight(&height);
	
	float h = height.ascent + height.descent;
	y = (int32)(bounds.bottom - h + 4);
	
	float w = view->StringWidth(label);
	if(w > bounds.Width())
		x = 1;
	else{
		x = (int32)(bounds.Width() - w)/2;
	}
	
	if(downState)
	{
		x ++;
		y ++;
	}
	view->SetLowColor(bgcolor);
	/*
	if(enabled && !downState)
	{
		view->SetHighColor(237,237,237);
	
		view->SetDrawingMode(B_OP_COPY);
		font.SetFace(B_BOLD_FACE);
		view->SetFont(&font);
		view->DrawString(label,BPoint(x+1,y+1));
	}
	*/
	if(enabled)
	{
		if(!downState)	
			view->SetHighColor(Black);
		else
			view->SetHighColor(255,0,0);
	}else
		view->SetHighColor(BeDarkShadow);
	font.SetFace(B_REGULAR_FACE);
	view->SetFont(&font);
	view->DrawString(label,BPoint(x,y));
}
开发者ID:kallisti5,项目名称:libtoolbar,代码行数:57,代码来源:HToolbarButton.cpp

示例12: fTermPref

status_t
TerminalThemesAddon::MakeThemeR5(BMessage &theme, uint32 flags)
{
	BMessage termpref;
	status_t err;
	struct termprefs tp;
	BPath pTermPref;
	
	(void)flags;
	err = MyMessage(theme, termpref);
	if (err)
		termpref.MakeEmpty();
	
	if (find_directory(B_USER_SETTINGS_DIRECTORY, &pTermPref) < B_OK)
		return EINVAL;
	pTermPref.Append("Terminal");
	BFile fTermPref(pTermPref.Path(), B_READ_ONLY);
	if (fTermPref.InitCheck() != B_OK)
		return fTermPref.InitCheck();
	if (fTermPref.Read(&tp, sizeof(struct termprefs)) < (ssize_t)sizeof(struct termprefs))
		return EIO;
	if ((tp.magic != TP_MAGIC) || (tp.version != TP_VERSION))
		return EINVAL;
	termpref.AddInt32(TP_COLS, tp.p.cols);
	termpref.AddInt32(TP_ROWS, tp.p.rows);
	termpref.AddInt32(TP_TABWIDTH, tp.p.tab_width);
	BFont tFont;
	font_family ff;
	font_style fs;
	BString str(tp.p.font);
	str.Truncate(str.FindFirst('/'));
	strncpy(ff, str.String(), sizeof(ff));
	str.SetTo(tp.p.font);
	str.Remove(0, str.FindFirst('/')+1);
	strncpy(fs, str.String(), sizeof(fs));
	tFont.SetFamilyAndStyle(ff, fs);
	tFont.SetSize(tp.p.font_size);
	AddFont(termpref, TP_FONT, &tFont);
	AddRGBColor(termpref, TP_BG, tp.p.bg);
	AddRGBColor(termpref, TP_FG, tp.p.fg);
	AddRGBColor(termpref, TP_CURBG, tp.p.curbg);
	AddRGBColor(termpref, TP_CURFG, tp.p.curfg);
	AddRGBColor(termpref, TP_SELBG, tp.p.selbg);
	AddRGBColor(termpref, TP_SELFG, tp.p.selfg);
	termpref.AddInt32(TP_ENCODING, tp.p.encoding);

	err = SetMyMessage(theme, termpref);
	return B_OK;
}
开发者ID:HaikuArchives,项目名称:HaikuThemeManager,代码行数:49,代码来源:TerminalAddon.cpp

示例13: BPopUpMenu

/*static*/ BMenu*
AppearancePrefView::_MakeFontMenu(uint32 command,
	const char* defaultFamily, const char* defaultStyle)
{
	BPopUpMenu* menu = new BPopUpMenu("");
	int32 numFamilies = count_font_families();
	uint32 flags;

	for (int32 i = 0; i < numFamilies; i++) {
		font_family family;
		if (get_font_family(i, &family, &flags) == B_OK) {
			BFont font;
			font_style style;
			int32 numStyles = count_font_styles(family);
			for (int32 j = 0; j < numStyles; j++) {
				if (get_font_style(family, j, &style) == B_OK) {
					font.SetFamilyAndStyle(family, style);
					if (IsFontUsable(font)) {
						BMessage* message = new BMessage(command);
						const char* size
							= PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE);
						message->AddString("font_family", family);
						message->AddString("font_style", style);
						message->AddString("font_size", size);
						char fontMenuLabel[134];
						snprintf(fontMenuLabel, sizeof(fontMenuLabel),
							"%s - %s", family, style);
						BMenu* fontSizeMenu = _MakeFontSizeMenu(fontMenuLabel,
							MSG_HALF_FONT_CHANGED, family, style, size);
						BMenuItem* item = new BMenuItem(fontSizeMenu, message);
						menu->AddItem(item);
						if (strcmp(defaultFamily, family) == 0
							&& strcmp(defaultStyle, style) == 0)
							item->SetMarked(true);
					}
				}
			}
		}
	}

	if (menu->FindMarked() == NULL)
		menu->ItemAt(0)->SetMarked(true);

	return menu;
}
开发者ID:sahil9912,项目名称:haiku,代码行数:45,代码来源:AppearPrefView.cpp

示例14: testSetFontFamilyAndStyle

static void testSetFontFamilyAndStyle(BView *view, BRect frame)
{
	view->DrawString("This is a test", BPoint(2, 6));
	
	BFont font;
	view->GetFont(&font);
	
	int32 families = count_font_families();
	font_family familyName;
	get_font_family(families - 1, &familyName);
	
	int32 styles = count_font_styles(familyName);
	font_style styleName;
	get_font_style(familyName, styles - 1, &styleName);
	font.SetFamilyAndStyle(familyName, styleName);
	view->SetFont(&font);
	view->DrawString( "This is a test", BPoint(2, 19));
}
开发者ID:mariuz,项目名称:haiku,代码行数:18,代码来源:PictureTestCases.cpp

示例15:

BFont
PSettings::GetFont(const char *name)
{
	BFont font = be_plain_font;
	font_data *val;
	ssize_t	  size;
	status_t s=FindData(name,B_ANY_TYPE,(const void**)&val,&size);
	if(s==B_OK)
	{
		char *fstyle=NULL,*ffamily=NULL;
		if(val->style[0]!=0)fstyle=val->style;
		if(val->family[0]!=0)ffamily=val->family;
		font.SetFamilyAndStyle(ffamily,fstyle);
		font.SetSize(val->size);
		font.SetShear(val->shear);
	}
	return font;	
}
开发者ID:threedeyes,项目名称:DjVuViewer,代码行数:18,代码来源:Settings.cpp


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