예제 #1
0
			void drawer::_m_draw_title(graph_reference graph)
			{
				if (graph.width() > 16 + interval)
				{
					nana::string title = widget_->caption();

					unsigned pixels = graph.width() - (16 + interval);

					nana::paint::text_renderer tr(graph);
					if (API::window_enabled(widget_->handle()) == false)
					{
						graph.set_text_color(colors::white);
						tr.render({ 17 + interval, 2 }, title.c_str(), title.length(), pixels);
						graph.set_text_color({ 0x80, 0x80, 0x80 });
					}
					else
						graph.set_text_color(widget_->fgcolor());

					tr.render({ 16 + interval, 1 }, title.c_str(), title.length(), pixels);
				}
			}
예제 #2
0
파일: button.cpp 프로젝트: Greentwip/Windy
		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);
		}