void trigger::_m_draw_border(graph_reference graph) { nana::rectangle r(graph.size()); ::nana::color lt(static_cast<color_rgb>(0x7f7f7f)), rb(static_cast<color_rgb>(0x707070)); graph.frame_rectangle(r, lt, lt, rb, rb); graph.palette(false, colors::button_face); draw_corner_point(graph, r); graph.palette(false, static_cast<color_rgb>(0x919191)); draw_corner_point(graph, r.pare_off(1)); if (element_state::pressed == attr_.e_state) graph.rectangle(r, false, static_cast<color_rgb>(0xc3c3c3)); }
void drawer::_m_button_frame(graph_reference graph, rectangle r, int state) { if (!state) return; ::nana::color clr{0x97, 0x97, 0x97}; //highlight switch(state) { case states::actived: clr.from_rgb(0x86, 0xD5, 0xFD); break; case states::selected: clr.from_rgb(0x3C, 0x7F, 0xB1); break; } graph.rectangle(r, false, clr); clr = clr.blend(colors::white, 0.5); graph.palette(false, clr); r.pare_off(2); if(vertical_) { unsigned half = r.width / 2; graph.rectangle({ r.x + static_cast<int>(r.width - half), r.y, half, r.height }, true); r.width -= half; } else { unsigned half = r.height / 2; graph.rectangle({r.x, r.y + static_cast<int>(r.height - half), r.width, half}, true); r.height -= half; } graph.gradual_rectangle(r, colors::white, clr, !vertical_); }
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; } graph.palette(true, 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(mbstr.c_str(), static_cast<unsigned>(shortkey_pos)).width : 0); wchar_t keystr[2] = {nana::utf::char_at(mbstr.c_str() + shortkey_pos, 0, 0), 0}; auto shortkey_size = graph.text_extent_size(keystr, 1); unsigned ascent, descent, inleading; graph.text_metrics(ascent, descent, inleading); pos.x += off_w; pos.y += static_cast<int>(ascent + 2); graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y }, colors::black); } } else { graph.palette(true, ::nana::color(colors::white)); if(attr_.omitted) { tr.render(point{ pos.x + 1, pos.y + 1 }, txtptr, txtlen, omitted_pixels, true); graph.palette(true, ::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.palette(true, ::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); }
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); }