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


C++ Render::GetTextSize方法代码示例

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


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

示例1: Draw

	void UICheckBox::Draw(Render& p) {
		int x = 0;
		int y = -2;

		Vector2 size = p.GetTextSize(this->GetText());
		if (this->Align == TextAlign::MidLeft || this->Align == TextAlign::MidCenter || this->Align == TextAlign::MidRight) y = this->H / 2 - (int)size.Y / 2;
		if (this->Align == TextAlign::BotLeft || this->Align == TextAlign::BotCenter || this->Align == TextAlign::BotRight) y = this->H - (int)size.Y / 2 + 2;

		if (this->Align == TextAlign::TopCenter || this->Align == TextAlign::MidCenter || this->Align == TextAlign::BotCenter) x = this->W / 2 - (int)size.X / 2;
		if (this->Align == TextAlign::TopRight || this->Align == TextAlign::MidRight || this->Align == TextAlign::BotRight) x = this->W - (int)size.X;


		if (this->BoxOnleftSide) {
			p.Box(0, 0, this->H, this->H, Color::Black);
			p.Box(1, 1, this->H - 2, this->H - 2, Color(80, 80, 80, 255));

			if (this->IsChecked) {
				p.Line(this->Padding, this->Padding, this->H - this->Padding, this->H - this->Padding, this->LineSize, this->LineColor);
				p.Line(this->H - this->Padding, this->Padding, this->Padding, this->H - this->Padding, this->LineSize, this->LineColor);
			}

			if (x == 0) x += this->H + (int)this->Padding;
		} else {
			int addx = (int)size.X;

			p.Box(addx, 0, this->H, this->H, Color::Black);
			p.Box(addx + 1, 1, this->H - 2, this->H - 2, Color(80, 80, 80, 255));

			if (this->IsChecked) {
				p.Line(addx + this->Padding, this->Padding, addx + this->H - this->Padding, this->H - this->Padding, this->LineSize, this->LineColor);
				p.Line(addx + this->H - this->Padding, this->Padding, addx + this->Padding, this->H - this->Padding, this->LineSize, this->LineColor);
			}
		}

		std::string text = this->GetText();
		p.Text(text, x, y, this->TextColor);
		if (this->Underline) {
			if (text.find('\n')) {
				int lastindex = 0;
				for (unsigned int i = 0; i < text.size(); i++) {
					if (text[i] == '\n') {
						size = p.GetTextSize(text.substr(lastindex, i - lastindex));
						p.Box(x, y, (int)size.X, 1, this->TextColor);
						lastindex = i + 1;
					}
				}

				if (lastindex < (int)text.size()) {
					size = p.GetTextSize(text.substr(lastindex, (int)text.size() - lastindex));
					p.Box(x, y + (int)size.Y, (int)size.X, 1, this->TextColor);
				}
			} else {
				p.Box(x, y, (int)size.X, 1, Color::Black);
			}
		}
	}
开发者ID:CptAsgard,项目名称:TomatoLib,代码行数:56,代码来源:UICheckBox.cpp


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