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


C++ CFont::GetHeight方法代码示例

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


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

示例1: Draw

void CCheckBox::Draw() 
{
	////////// Gee: janwas, this is just temp to see it
	glDisable(GL_TEXTURE_2D);
	//////////

	float square_side, buffer_zone;
	CStrW font_name;
	bool checked;
	int cell_id;
	GUI<float>::GetSetting(this, "square_side", square_side);
	GUI<float>::GetSetting(this, "buffer_zone", buffer_zone);
	GUI<CStrW>::GetSetting(this, "font", font_name);
	GUI<bool>::GetSetting(this, "checked", checked);
	GUI<int>::GetSetting(this, "cell_id", cell_id);

	// Get line height
	CFont font (font_name);
	float line_height = (float)font.GetHeight();

	float bz = GetBufferedZ();

	// Get square
	CRect rect;

	rect.left =		m_CachedActualSize.left;
	rect.right =	rect.left + square_side;

	if (square_side >= line_height)
		rect.top =	m_CachedActualSize.top;
	else
		rect.top =	m_CachedActualSize.top + line_height/2.f - square_side/2.f;

	rect.bottom =	rect.top + square_side;

	CGUISpriteInstance *sprite, *sprite_over, *sprite_pressed, *sprite_disabled;

	if (checked)
	{
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2", sprite);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_over", sprite_over);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_pressed", sprite_pressed);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite2_disabled", sprite_disabled);
	}
	else
	{
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite", sprite);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_over", sprite_over);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_pressed", sprite_pressed);
		GUI<CGUISpriteInstance>::GetSettingPointer(this, "sprite_disabled", sprite_disabled);
	}

	DrawButton(rect, 
			   bz,
			   *sprite,
			   *sprite_over,
			   *sprite_pressed,
			   *sprite_disabled,
			   cell_id);

	CColor color = ChooseColor();

	CPos text_pos(m_CachedActualSize.left + square_side + buffer_zone, m_CachedActualSize.top);

	if (square_side > line_height)
		text_pos.y += square_side/2.f - line_height/2.f;

	IGUITextOwner::Draw(0, color, text_pos, bz+0.1f, m_CachedActualSize);
}
开发者ID:,项目名称:,代码行数:69,代码来源:


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