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


C++ graph_reference::text_extent_size方法代码示例

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


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

示例1: _m_draw_title

		void trigger::_m_draw_title(graph_reference graph, bool enabled)
		{
			nana::string text = wdg_->caption();

			nana::string::value_type shortkey;
			nana::string::size_type shortkey_pos;
			nana::string str = API::transform_shortkey_text(text, shortkey, &shortkey_pos);

			nana::size ts = graph.text_extent_size(str);
			nana::size gsize = graph.size();

			nana::size icon_sz;
			if(attr_.icon)
			{
				icon_sz = attr_.icon->size();
				icon_sz.width += 5;
			}

			nana::point pos{
				static_cast<int>(gsize.width - 1 - ts.width) >> 1, static_cast<int>(gsize.height - 1 - ts.height) >> 1
			};

			if(pos.x < static_cast<int>(icon_sz.width))
				pos.x = static_cast<int>(icon_sz.width);

			unsigned omitted_pixels = gsize.width - icon_sz.width;
			std::size_t txtlen = str.size();
			const nana::char_t* txtptr = str.c_str();
			if(ts.width)
			{
				nana::paint::text_renderer tr(graph);
				if(enabled)
				{
					if (element_state::pressed == attr_.e_state)
					{
						++pos.x;
						++pos.y;
					}

					graph.set_text_color(attr_.focus_color && attr_.focused ? ::nana::color(colors::blue) : attr_.fgcolor);

					if (attr_.omitted)
						tr.render(pos, txtptr, txtlen, omitted_pixels, true);
					else
						graph.bidi_string(pos, txtptr, txtlen);

					if(shortkey)
					{
						unsigned off_w = (shortkey_pos ? graph.text_extent_size(str, static_cast<unsigned>(shortkey_pos)).width : 0);
						nana::size shortkey_size = graph.text_extent_size(txtptr + shortkey_pos, 1);
						pos.x += off_w;
						pos.y += static_cast<int>(shortkey_size.height);
						graph.set_color(colors::black);
						graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y });
					}
				}
				else
				{
					graph.set_text_color(::nana::color(colors::white));
					if(attr_.omitted)
					{
						tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true);
						graph.set_text_color(::nana::color(colors::gray));
						tr.render(pos, txtptr, txtlen, omitted_pixels, true);
					}
					else
					{
						graph.bidi_string(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen);
						graph.set_text_color(::nana::color(colors::gray));
						graph.bidi_string(pos, txtptr, txtlen);
					}
				}
			}

			if(attr_.icon)
				attr_.icon->paste(graph, point{ 3, static_cast<int>(gsize.height - icon_sz.height) / 2 });
		}

		void trigger::_m_draw_background(graph_reference graph)
		{
			nana::rectangle r(graph.size());
			r.pare_off(1);

			auto from = attr_.bgcolor.blend(colors::white, 0.2);
			auto to = attr_.bgcolor.blend(colors::black, 0.95);

			if (element_state::pressed == attr_.e_state)
			{
				r.x = r.y = 2;
				std::swap(from, to);
			}
			graph.gradual_rectangle(r, from, to, true);
		}
开发者ID:Greentwip,项目名称:Windy,代码行数:93,代码来源:button.cpp

示例2: refresh

			void drawer::refresh(graph_reference graph)
			{
				_m_draw_background(graph);
				_m_draw_title(graph);
				_m_draw_checkbox(graph, graph.text_extent_size(STR("jN"), 2).height + 2);
			}
开发者ID:a397871706,项目名称:plug,代码行数:6,代码来源:checkbox.cpp

示例3: _m_draw_title

		void trigger::_m_draw_title(graph_reference graph, bool enabled)
		{
			wchar_t shortkey;
			std::string::size_type shortkey_pos;
			std::string mbstr = API::transform_shortkey_text(wdg_->caption(), shortkey, &shortkey_pos);
			std::wstring str = to_wstring(mbstr);

			nana::size ts = graph.text_extent_size(str);
			nana::size gsize = graph.size();

			nana::size icon_sz;
			if(attr_.icon)
			{
				icon_sz = attr_.icon->size();
				icon_sz.width += 5;
			}

			nana::point pos{
				static_cast<int>(gsize.width - 1 - ts.width) >> 1, static_cast<int>(gsize.height - 1 - ts.height) >> 1
			};

			if(pos.x < static_cast<int>(icon_sz.width))
				pos.x = static_cast<int>(icon_sz.width);

			unsigned omitted_pixels = gsize.width - icon_sz.width;
			std::size_t txtlen = str.size();
			const auto txtptr = str.c_str();
			if(ts.width)
			{
				nana::paint::text_renderer tr(graph);
				if(enabled)
				{
					if (element_state::pressed == attr_.e_state)
					{
						++pos.x;
						++pos.y;
					}

					auto text_color = (attr_.focus_color && attr_.focused ? ::nana::color(colors::blue) : attr_.fgcolor);
					graph.palette(true, text_color);

					if (attr_.omitted)
						tr.render(pos, txtptr, txtlen, omitted_pixels, true);
					else
#ifdef _nana_std_has_string_view
						graph.bidi_string(pos, { txtptr, txtlen });
#else
						graph.bidi_string(pos, txtptr, txtlen);
#endif

					API::dev::draw_shortkey_underline(graph, mbstr, shortkey, shortkey_pos, pos, text_color);
				}
				else
				{
					graph.palette(true, color{ colors::white });
					if(attr_.omitted)
					{
						tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true);
						graph.palette(true, color{ colors::gray });
						tr.render(pos, txtptr, txtlen, omitted_pixels, true);
					}
					else
					{
#ifdef _nana_std_has_string_view
						graph.bidi_string(point{ pos.x + 1, pos.y + 1 }, { txtptr, txtlen });
						graph.palette(true, color{ colors::gray });
						graph.bidi_string(pos, { txtptr, txtlen });
#else
						graph.bidi_string(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen);
						graph.palette(true, color{ colors::gray });
						graph.bidi_string(pos, txtptr, txtlen);
#endif
					}
				}
			}

			if(attr_.icon)
				attr_.icon->paste(graph, point{ 3, static_cast<int>(gsize.height - icon_sz.height) / 2 });
		}

		void trigger::_m_draw_background(graph_reference graph)
		{
			nana::rectangle r(graph.size());
			r.pare_off(1);

			auto from = attr_.bgcolor.blend(colors::white, 0.8);
			auto to = attr_.bgcolor.blend(colors::black, 0.05);

			if (element_state::pressed == attr_.e_state)
			{
				r.x = r.y = 2;
				std::swap(from, to);
			}
			graph.gradual_rectangle(r, from, to, true);
		}
开发者ID:cnjinhao,项目名称:nana,代码行数:95,代码来源:button.cpp


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