Breaking changes for expr_color
expr_color is a temporary class name for new color type experiment.
This commit is contained in:
@@ -22,45 +22,45 @@ namespace gadget
|
||||
{
|
||||
typedef nana::paint::graphics& graph_reference;
|
||||
|
||||
void hollow_triangle(graph_reference graph, int x, int y, nana::color_t color, uint32_t direction)
|
||||
void hollow_triangle(graph_reference graph, int x, int y, uint32_t direction)
|
||||
{
|
||||
x += 3;
|
||||
y += 3;
|
||||
switch(direction)
|
||||
switch (direction)
|
||||
{
|
||||
case directions::to_east:
|
||||
graph.line(x + 3, y + 1, x + 3, y + 9, color);
|
||||
graph.line(x + 4, y + 2 , x + 7, y + 5, color);
|
||||
graph.line(x + 6, y + 6, x + 4, y + 8, color);
|
||||
graph.line(point{ x + 3, y + 1 }, point{ x + 3, y + 9 });
|
||||
graph.line(point{ x + 4, y + 2 }, point{ x + 7, y + 5 });
|
||||
graph.line(point{ x + 6, y + 6 }, point{ x + 4, y + 8 });
|
||||
break;
|
||||
case directions::to_southeast:
|
||||
graph.line(x + 2, y + 7, x + 7, y + 7, color);
|
||||
graph.line(x + 7, y + 2, x + 7, y + 6, color);
|
||||
graph.line(x + 3, y + 6, x + 6, y + 3, color);
|
||||
graph.line(point{ x + 2, y + 7 }, point{ x + 7, y + 7 });
|
||||
graph.line(point{ x + 7, y + 2 }, point{ x + 7, y + 6 });
|
||||
graph.line(point{ x + 3, y + 6 }, point{ x + 6, y + 3 });
|
||||
break;
|
||||
case directions::to_south:
|
||||
y += 3;
|
||||
graph.line(x, y, x + 8, y, color);
|
||||
graph.line(x + 1, y + 1, x + 4, y + 4, color);
|
||||
graph.line(x + 7, y + 1, x + 5, y + 3, color);
|
||||
graph.line(point{ x, y }, point{ x + 8, y });
|
||||
graph.line(point{ x + 1, y + 1 }, point{ x + 4, y + 4 });
|
||||
graph.line(point{ x + 7, y + 1 }, point{ x + 5, y + 3 });
|
||||
break;
|
||||
case directions::to_west:
|
||||
x += 5;
|
||||
y += 1;
|
||||
graph.line(x, y, x, y + 8, color);
|
||||
graph.line(x - 4, y + 4, x - 1, y + 1, color);
|
||||
graph.line(x - 3, y + 5, x - 1, y + 7, color);
|
||||
graph.line(point{ x, y }, point{ x, y + 8 });
|
||||
graph.line(point{ x - 4, y + 4 }, point{ x - 1, y + 1 });
|
||||
graph.line(point{ x - 3, y + 5 }, point{ x - 1, y + 7 });
|
||||
break;
|
||||
case directions::to_north:
|
||||
y += 7;
|
||||
graph.line(x, y, x + 8, y, color);
|
||||
graph.line(x + 1, y - 1, x + 4, y - 4, color);
|
||||
graph.line(x + 5, y - 3, x + 7, y - 1, color);
|
||||
graph.line(point{ x, y }, point{x + 8, y});
|
||||
graph.line(point{x + 1, y - 1}, point{x + 4, y - 4});
|
||||
graph.line(point{x + 5, y - 3}, point{x + 7, y - 1});
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void solid_triangle(graph_reference graph, int x, int y, nana::color_t color, uint32_t dir)
|
||||
void solid_triangle(graph_reference graph, int x, int y, uint32_t dir)
|
||||
{
|
||||
x += 3;
|
||||
y += 3;
|
||||
@@ -68,40 +68,40 @@ namespace gadget
|
||||
{
|
||||
case directions::to_east:
|
||||
for(int i = 0; i < 5; ++i)
|
||||
graph.line(x + 3 + i, y + 1 + i, x + 3 + i, y + 9 - i, color);
|
||||
graph.line(point{ x + 3 + i, y + 1 + i }, point{ x + 3 + i, y + 9 - i });
|
||||
break;
|
||||
case directions::to_southeast:
|
||||
for(int i = 0; i < 6; ++i)
|
||||
graph.line(x + 2 + i, y + 7 - i, x + 7, y + 7 - i, color);
|
||||
graph.line(point{ x + 2 + i, y + 7 - i }, point{ x + 7, y + 7 - i });
|
||||
break;
|
||||
case directions::to_south:
|
||||
y += 3;
|
||||
for(int i = 0; i < 5; ++i)
|
||||
graph.line(x + i, y + i, x + 8 - i, y + i, color);
|
||||
graph.line(point{ x + i, y + i }, point{ x + 8 - i, y + i });
|
||||
break;
|
||||
case directions::to_west:
|
||||
x += 5;
|
||||
y += 1;
|
||||
for(int i = 0; i < 5; ++i)
|
||||
graph.line(x - i, y + i, x - i, y + 8 - i, color);
|
||||
graph.line(point{ x - i, y + i }, point{ x - i, y + 8 - i });
|
||||
break;
|
||||
case directions::to_north:
|
||||
y += 7;
|
||||
for(int i = 0; i < 5; ++i)
|
||||
graph.line(x + i, y - i, x + 8 - i, y - i, color);
|
||||
graph.line(point{ x + i, y - i }, point{ x + 8 - i, y - i });
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void direction_arrow(graph_reference graph, int x, int y, nana::color_t color, uint32_t dir)
|
||||
void direction_arrow(graph_reference graph, int x, int y, uint32_t dir)
|
||||
{
|
||||
graph.set_color({ 0x0, 0x2, 0x62 });
|
||||
y += 5;
|
||||
switch(dir)
|
||||
{
|
||||
case directions::to_north:
|
||||
{
|
||||
x += 3;
|
||||
|
||||
int pixels = 1;
|
||||
for(int l = 0; l < 4; ++l)
|
||||
{
|
||||
@@ -110,7 +110,7 @@ namespace gadget
|
||||
if(l ==3 && i == 3)
|
||||
{}
|
||||
else
|
||||
graph.set_pixel(x + i, y, 0x262);
|
||||
graph.set_pixel(x + i, y);
|
||||
}
|
||||
|
||||
x--;
|
||||
@@ -118,29 +118,28 @@ namespace gadget
|
||||
pixels += 2;
|
||||
}
|
||||
|
||||
graph.set_pixel(x + 1, y, 0x262);
|
||||
graph.set_pixel(x + 2, y, 0x262);
|
||||
graph.set_pixel(x + 6, y, 0x262);
|
||||
graph.set_pixel(x + 7, y, 0x262);
|
||||
graph.set_pixel(x + 1, y);
|
||||
graph.set_pixel(x + 2, y);
|
||||
graph.set_pixel(x + 6, y);
|
||||
graph.set_pixel(x + 7, y);
|
||||
}
|
||||
break;
|
||||
case directions::to_south:
|
||||
{
|
||||
|
||||
graph.set_pixel(x, y, 0x262);
|
||||
graph.set_pixel(x + 1, y, 0x262);
|
||||
graph.set_pixel(x + 5, y, 0x262);
|
||||
graph.set_pixel(x + 6, y, 0x262);
|
||||
graph.set_pixel(x, y);
|
||||
graph.set_pixel(x + 1, y);
|
||||
graph.set_pixel(x + 5, y);
|
||||
graph.set_pixel(x + 6, y);
|
||||
|
||||
++y;
|
||||
int pixels = 7;
|
||||
for(int l = 0; l < 4; ++l)
|
||||
for (int l = 0; l < 4; ++l)
|
||||
{
|
||||
for(int i = 0; i < pixels; ++i)
|
||||
for (int i = 0; i < pixels; ++i)
|
||||
{
|
||||
if(l == 0 && i == 3){}
|
||||
else
|
||||
graph.set_pixel(x + i, y, 0x262);
|
||||
if (l != 0 || i != 3)
|
||||
graph.set_pixel(x + i, y);
|
||||
}
|
||||
|
||||
x++;
|
||||
@@ -152,54 +151,54 @@ namespace gadget
|
||||
}
|
||||
}
|
||||
|
||||
void double_arrow_line(nana::paint::graphics & graph, int x, int y, color_t color, bool horizontal)
|
||||
void double_arrow_line(nana::paint::graphics & graph, int x, int y, bool horizontal)
|
||||
{
|
||||
graph.set_pixel(x, y, color);
|
||||
graph.set_pixel(x, y);
|
||||
if(horizontal)
|
||||
{
|
||||
graph.set_pixel(x + 1, y, color);
|
||||
graph.set_pixel(x + 4, y, color);
|
||||
graph.set_pixel(x + 5, y, color);
|
||||
graph.set_pixel(x + 1, y);
|
||||
graph.set_pixel(x + 4, y);
|
||||
graph.set_pixel(x + 5, y);
|
||||
}
|
||||
else
|
||||
{
|
||||
graph.set_pixel(x, y + 1, color);
|
||||
graph.set_pixel(x, y + 4, color);
|
||||
graph.set_pixel(x, y + 5, color);
|
||||
graph.set_pixel(x, y + 1);
|
||||
graph.set_pixel(x, y + 4);
|
||||
graph.set_pixel(x, y + 5);
|
||||
}
|
||||
}
|
||||
|
||||
void double_arrow(nana::paint::graphics& graph, int x, int y, color_t color, directions::t dir)
|
||||
void double_arrow(nana::paint::graphics& graph, int x, int y, directions::t dir)
|
||||
{
|
||||
switch(dir)
|
||||
{
|
||||
case directions::to_east:
|
||||
double_arrow_line(graph, x + 4, y + 6, color, true);
|
||||
double_arrow_line(graph, x + 5, y + 7, color, true);
|
||||
double_arrow_line(graph, x + 6, y + 8, color, true);
|
||||
double_arrow_line(graph, x + 5, y + 9, color, true);
|
||||
double_arrow_line(graph, x + 4, y + 10, color, true);
|
||||
double_arrow_line(graph, x + 4, y + 6, true);
|
||||
double_arrow_line(graph, x + 5, y + 7, true);
|
||||
double_arrow_line(graph, x + 6, y + 8, true);
|
||||
double_arrow_line(graph, x + 5, y + 9, true);
|
||||
double_arrow_line(graph, x + 4, y + 10, true);
|
||||
break;
|
||||
case directions::to_west:
|
||||
double_arrow_line(graph, x + 5, y + 6, color, true);
|
||||
double_arrow_line(graph, x + 4, y + 7, color, true);
|
||||
double_arrow_line(graph, x + 3, y + 8, color, true);
|
||||
double_arrow_line(graph, x + 4, y + 9, color, true);
|
||||
double_arrow_line(graph, x + 5, y + 10, color, true);
|
||||
double_arrow_line(graph, x + 5, y + 6, true);
|
||||
double_arrow_line(graph, x + 4, y + 7, true);
|
||||
double_arrow_line(graph, x + 3, y + 8, true);
|
||||
double_arrow_line(graph, x + 4, y + 9, true);
|
||||
double_arrow_line(graph, x + 5, y + 10, true);
|
||||
break;
|
||||
case directions::to_south:
|
||||
double_arrow_line(graph, x + 5, y + 4, color, false);
|
||||
double_arrow_line(graph, x + 6, y + 5, color, false);
|
||||
double_arrow_line(graph, x + 7, y + 6, color, false);
|
||||
double_arrow_line(graph, x + 8, y + 5, color, false);
|
||||
double_arrow_line(graph, x + 9, y + 4, color, false);
|
||||
double_arrow_line(graph, x + 5, y + 4, false);
|
||||
double_arrow_line(graph, x + 6, y + 5, false);
|
||||
double_arrow_line(graph, x + 7, y + 6, false);
|
||||
double_arrow_line(graph, x + 8, y + 5, false);
|
||||
double_arrow_line(graph, x + 9, y + 4, false);
|
||||
break;
|
||||
case directions::to_north:
|
||||
double_arrow_line(graph, x + 5, y + 6, color, false);
|
||||
double_arrow_line(graph, x + 6, y + 5, color, false);
|
||||
double_arrow_line(graph, x + 7, y + 4, color, false);
|
||||
double_arrow_line(graph, x + 8, y + 5, color, false);
|
||||
double_arrow_line(graph, x + 9, y + 6, color, false);
|
||||
double_arrow_line(graph, x + 5, y + 6, false);
|
||||
double_arrow_line(graph, x + 6, y + 5, false);
|
||||
double_arrow_line(graph, x + 7, y + 4, false);
|
||||
double_arrow_line(graph, x + 8, y + 5, false);
|
||||
double_arrow_line(graph, x + 9, y + 6, false);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -209,56 +208,59 @@ namespace gadget
|
||||
|
||||
//arrow_16_pixels
|
||||
//param@style: 0 = hollow, 1 = solid
|
||||
void arrow_16_pixels(nana::paint::graphics& graph, int x, int y, unsigned color, uint32_t style, directions::t dir)
|
||||
void arrow_16_pixels(nana::paint::graphics& graph, int x, int y, const nana::expr_color& clr, uint32_t style, directions::t dir)
|
||||
{
|
||||
graph.set_color(clr);
|
||||
switch(style)
|
||||
{
|
||||
case 1:
|
||||
detail::solid_triangle(graph, x, y, color, dir);
|
||||
detail::solid_triangle(graph, x, y, dir);
|
||||
break;
|
||||
case 2:
|
||||
detail::direction_arrow(graph, x, y, color, dir);
|
||||
detail::direction_arrow(graph, x, y, dir);
|
||||
break;
|
||||
case 3:
|
||||
detail::double_arrow(graph, x, y, color, dir);
|
||||
detail::double_arrow(graph, x, y, dir);
|
||||
break;
|
||||
case 0:
|
||||
default:
|
||||
detail::hollow_triangle(graph, x, y, color, dir);
|
||||
detail::hollow_triangle(graph, x, y, dir);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void close_16_pixels(nana::paint::graphics& graph, int x, int y, uint32_t style, uint32_t color)
|
||||
void close_16_pixels(::nana::paint::graphics& graph, int x, int y, uint32_t style, const ::nana::expr_color& clr)
|
||||
{
|
||||
graph.set_color(clr);
|
||||
if(0 == style)
|
||||
{
|
||||
x += 3;
|
||||
y += 3;
|
||||
|
||||
graph.line(x, y, x + 9, y + 9, color);
|
||||
graph.line(x + 1, y, x + 9, y + 8, color);
|
||||
graph.line(x, y + 1, x + 8, y + 9, color);
|
||||
graph.line({ x, y }, { x + 9, y + 9 });
|
||||
graph.line({ x + 1, y }, { x + 9, y + 8 });
|
||||
graph.line({ x, y + 1 }, { x + 8, y + 9 });
|
||||
|
||||
graph.line(x + 9, y, x , y + 9, color);
|
||||
graph.line(x + 8, y, x, y + 8, color);
|
||||
graph.line(x + 9, y + 1, x + 1, y + 9, color);
|
||||
graph.line({ x + 9, y }, { x, y + 9 });
|
||||
graph.line({ x + 8, y }, { x, y + 8 });
|
||||
graph.line({ x + 9, y + 1 }, { x + 1, y + 9 });
|
||||
}
|
||||
else
|
||||
{
|
||||
x += 4;
|
||||
y += 4;
|
||||
|
||||
graph.line(x, y, x + 7, y + 7, color);
|
||||
graph.line(x + 1, y, x + 7, y + 6, color);
|
||||
graph.line(x, y + 1, x + 6, y + 7, color);
|
||||
graph.line({ x, y }, { x + 7, y + 7 });
|
||||
graph.line({ x + 1, y }, { x + 7, y + 6 });
|
||||
graph.line({ x, y + 1 }, { x + 6, y + 7 });
|
||||
|
||||
graph.line(x + 7, y, x , y + 7, color);
|
||||
graph.line(x + 6, y, x, y + 6, color);
|
||||
graph.line(x + 7, y + 1, x + 1, y + 7, color);
|
||||
graph.line({ x + 7, y }, { x, y + 7 });
|
||||
graph.line({ x + 6, y }, { x, y + 6 });
|
||||
graph.line({ x + 7, y + 1 }, { x + 1, y + 7 });
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
void cross(graphics& graph, int x, int y, uint32_t size, uint32_t thickness, ::nana::color_t color) //deprecated
|
||||
{
|
||||
if (thickness + 2 <= size)
|
||||
@@ -309,8 +311,8 @@ namespace gadget
|
||||
graph.rectangle(ps[10].x + 1, ps[10].y + 1, (gap << 1) + thickness - 2, thickness - 2, color, true);
|
||||
graph.rectangle(ps[0].x + 1, ps[0].y + 1, thickness - 2, (gap << 1) + thickness - 2, color, true);
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
void cross(graphics& graph, int x, int y, uint32_t size, uint32_t thickness, const ::nana::expr_color& color)
|
||||
{
|
||||
|
||||
@@ -522,8 +522,8 @@ namespace paint
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned graphics::bidi_string(int x, int y, color_t col, const nana::char_t* str, std::size_t len)
|
||||
/*
|
||||
unsigned graphics::bidi_string(int x, int y, color_t col, const nana::char_t* str, std::size_t len) //deprecated
|
||||
{
|
||||
int origin_x = x;
|
||||
unicode_bidi bidi;
|
||||
@@ -536,7 +536,9 @@ namespace paint
|
||||
}
|
||||
return static_cast<unsigned>(x - origin_x);
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void graphics::string(int x, int y, color_t color, const nana::string& str, std::size_t len)
|
||||
{
|
||||
string(x, y, color, str.c_str(), len);
|
||||
@@ -592,7 +594,9 @@ namespace paint
|
||||
{
|
||||
string(x, y, c, str, nana::strlen(str));
|
||||
}
|
||||
*/
|
||||
|
||||
/*
|
||||
void graphics::set_pixel(int x, int y, color_t color)
|
||||
{
|
||||
if(handle_)
|
||||
@@ -816,7 +820,7 @@ namespace paint
|
||||
#endif
|
||||
if(changed_ == false) changed_ = true;
|
||||
}
|
||||
|
||||
*/
|
||||
void graphics::line_begin(int x, int y)
|
||||
{
|
||||
if(!handle_) return;
|
||||
@@ -828,7 +832,7 @@ namespace paint
|
||||
handle_->line_begin_pos.y = y;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
void graphics::line_to(int x, int y, color_t color)
|
||||
{
|
||||
if(!handle_) return;
|
||||
@@ -846,6 +850,7 @@ namespace paint
|
||||
#endif
|
||||
if(changed_ == false) changed_ = true;
|
||||
}
|
||||
*/
|
||||
|
||||
void graphics::bitblt(int x, int y, const graphics& src)
|
||||
{
|
||||
@@ -1177,7 +1182,7 @@ namespace paint
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
color_t graphics::mix(color_t a, color_t b, double fade_rate) //deprecated
|
||||
{
|
||||
pixel_argb_t pa, pb, ret;
|
||||
@@ -1191,6 +1196,7 @@ namespace paint
|
||||
|
||||
return ret.value;
|
||||
}
|
||||
*/
|
||||
|
||||
void graphics::set_color(const ::nana::expr_color& col)
|
||||
{
|
||||
@@ -1218,6 +1224,39 @@ namespace paint
|
||||
return static_cast<unsigned>(moved_pos.x - pos.x);
|
||||
}
|
||||
|
||||
void graphics::blend(const nana::rectangle& r, const ::nana::expr_color& clr, double fade_rate)
|
||||
{
|
||||
if (handle_)
|
||||
{
|
||||
nana::paint::detail::blend(handle_, r, clr.px_color().value, fade_rate);
|
||||
if (changed_ == false) changed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::set_pixel(int x, int y, const ::nana::expr_color& clr)
|
||||
{
|
||||
if (handle_)
|
||||
{
|
||||
handle_->set_color(clr.px_color().value);
|
||||
set_pixel(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::set_pixel(int x, int y)
|
||||
{
|
||||
if (handle_)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
::SetPixel(handle_->context, x, y, NANA_RGB(handle_->get_color()));
|
||||
#elif defined(NANA_X11)
|
||||
Display* disp = nana::detail::platform_spec::instance().open_display();
|
||||
handle_->update_color();
|
||||
::XDrawPoint(disp, handle_->pixmap, handle_->context, x, y);
|
||||
#endif
|
||||
if (changed_ == false) changed_ = true;
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::string(nana::point pos, const char_t* str, std::size_t len)
|
||||
{
|
||||
if (handle_ && str && len)
|
||||
@@ -1270,6 +1309,12 @@ namespace paint
|
||||
string(pos, str.data(), str.size());
|
||||
}
|
||||
|
||||
void graphics::string(const point& pos, const ::nana::string& text, const expr_color& clr)
|
||||
{
|
||||
set_text_color(clr);
|
||||
string(pos, text.data(), text.size());
|
||||
}
|
||||
|
||||
void graphics::line(const nana::point& pos1, const nana::point& pos2)
|
||||
{
|
||||
if ((!handle_) || (pos1 == pos2)) return;
|
||||
@@ -1288,6 +1333,48 @@ namespace paint
|
||||
if (changed_ == false) changed_ = true;
|
||||
}
|
||||
|
||||
void graphics::line(const point& pos_a, const point& pos_b, const expr_color& clr)
|
||||
{
|
||||
set_color(clr);
|
||||
line(pos_a, pos_b);
|
||||
}
|
||||
|
||||
void graphics::line_to(const point& pos, const expr_color& clr)
|
||||
{
|
||||
if (!handle_) return;
|
||||
handle_->set_color(clr.px_color().value);
|
||||
line_to(pos);
|
||||
}
|
||||
|
||||
void graphics::line_to(const point& pos)
|
||||
{
|
||||
if (!handle_) return;
|
||||
#if defined(NANA_WINDOWS)
|
||||
handle_->update_pen();
|
||||
::LineTo(handle_->context, pos.x, pos.y);
|
||||
#elif defined(NANA_X11)
|
||||
Display* disp = nana::detail::platform_spec::instance().open_display();
|
||||
handle_->update_color();
|
||||
::XDrawLine(disp, handle_->pixmap, handle_->context,
|
||||
handle_->line_begin_pos.x, handle_->line_begin_pos.y,
|
||||
x, y);
|
||||
handle_->line_begin_pos.x = x;
|
||||
handle_->line_begin_pos.y = y;
|
||||
#endif
|
||||
if (changed_ == false) changed_ = true;
|
||||
}
|
||||
|
||||
void graphics::rectangle(bool solid)
|
||||
{
|
||||
rectangle(size(), solid);
|
||||
}
|
||||
|
||||
void graphics::rectangle(bool solid, const ::nana::expr_color& clr)
|
||||
{
|
||||
set_color(clr);
|
||||
rectangle(size(), solid);
|
||||
}
|
||||
|
||||
void graphics::rectangle(const ::nana::rectangle& r, bool solid)
|
||||
{
|
||||
if (r.width && r.height && handle_ && r.right() > 0 && r.bottom() > 0)
|
||||
@@ -1308,6 +1395,23 @@ namespace paint
|
||||
}
|
||||
}
|
||||
|
||||
void graphics::rectangle(const ::nana::rectangle& r, bool solid, const expr_color& clr)
|
||||
{
|
||||
set_color(clr);
|
||||
rectangle(r, solid);
|
||||
}
|
||||
|
||||
void graphics::frame_rectangle(const ::nana::rectangle& r, const ::nana::expr_color& left_clr, const ::nana::expr_color& top_clr, const ::nana::expr_color& right_clr, const ::nana::expr_color& bottom_clr)
|
||||
{
|
||||
int right = r.right() - 1;
|
||||
int bottom = r.bottom() - 1;
|
||||
line_begin(r.x, r.y);
|
||||
line_to({ right, r.y }, top_clr);
|
||||
line_to({ right, bottom }, right_clr);
|
||||
line_to({ r.x, bottom }, bottom_clr);
|
||||
line_to({ r.x, r.y }, left_clr);
|
||||
}
|
||||
|
||||
void graphics::gradual_rectangle(const ::nana::rectangle& r, const ::nana::expr_color& from, const ::nana::expr_color& to, bool vertical)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
@@ -1364,6 +1468,40 @@ namespace paint
|
||||
#endif
|
||||
if (changed_ == false) changed_ = true;
|
||||
}
|
||||
|
||||
void graphics::round_rectangle(const ::nana::rectangle& r, unsigned radius_x, unsigned radius_y, const expr_color& clr, bool solid, const expr_color& solid_clr)
|
||||
{
|
||||
if (handle_)
|
||||
{
|
||||
#if defined(NANA_WINDOWS)
|
||||
handle_->set_color(clr.px_color().value);
|
||||
if (solid)
|
||||
{
|
||||
handle_->update_pen();
|
||||
handle_->brush.set(handle_->context, handle_->brush.Solid, solid_clr.px_color().value);
|
||||
::RoundRect(handle_->context, r.x, r.y, r.right(), r.bottom(), static_cast<int>(radius_x * 2), static_cast<int>(radius_y * 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
handle_->update_brush();
|
||||
handle_->round_region.set(r, radius_x, radius_y);
|
||||
::FrameRgn(handle_->context, handle_->round_region.handle, handle_->brush.handle, 1, 1);
|
||||
}
|
||||
if(changed_ == false) changed_ = true;
|
||||
#elif defined(NANA_X11)
|
||||
if(solid && (color == solid_clr))
|
||||
{
|
||||
rectangle(r, true, color);
|
||||
}
|
||||
else
|
||||
{
|
||||
rectangle(r, false, color);
|
||||
if(solid)
|
||||
rectangle(rectangle(r).pare_off(1), true, solid_clr);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
//end class graphics
|
||||
|
||||
}//end namespace paint
|
||||
|
||||
@@ -118,13 +118,14 @@ namespace nana
|
||||
{
|
||||
graphics & graph;
|
||||
int x, endpos;
|
||||
nana::color_t color; //deprecated
|
||||
//nana::color_t color; //deprecated
|
||||
::nana::expr_color fgcolor;
|
||||
unsigned omitted_pixels;
|
||||
nana::unicode_bidi bidi;
|
||||
std::vector<nana::unicode_bidi::entity> reordered;
|
||||
|
||||
draw_string_omitted(graphics& graph, int x, int endpos, nana::color_t color, bool omitted)
|
||||
: graph(graph), x(x), endpos(endpos), color(color)
|
||||
draw_string_omitted(graphics& graph, int x, int endpos, const ::nana::expr_color& fgcolor, bool omitted)
|
||||
: graph(graph), x(x), endpos(endpos), fgcolor(fgcolor)
|
||||
{
|
||||
omitted_pixels = (omitted ? graph.text_extent_size(STR("..."), 3).width : 0);
|
||||
if(endpos - x > static_cast<int>(omitted_pixels))
|
||||
@@ -169,7 +170,8 @@ namespace nana
|
||||
nana::paint::graphics dum_graph(r.width, r.height);
|
||||
|
||||
dum_graph.bitblt(r, graph, pos);
|
||||
dum_graph.string(0, 0, color, i.begin, len);
|
||||
dum_graph.set_text_color(fgcolor);
|
||||
dum_graph.string({}, i.begin, len);
|
||||
|
||||
r.x = pos.x;
|
||||
r.y = top;
|
||||
@@ -553,7 +555,8 @@ namespace nana
|
||||
: graph_(graph), text_align_(ta)
|
||||
{}
|
||||
|
||||
void text_renderer::render(int x, int y, nana::color_t col, const nana::char_t * str, std::size_t len)
|
||||
/*
|
||||
void text_renderer::render(int x, int y, color_t col, const char_t * str, std::size_t len)
|
||||
{
|
||||
if(graph_)
|
||||
{
|
||||
@@ -562,8 +565,8 @@ namespace nana
|
||||
helper::for_each_line(str, len, y, ds);
|
||||
}
|
||||
}
|
||||
|
||||
void text_renderer::render(int x, int y, nana::color_t col, const nana::char_t * str, std::size_t len, unsigned restricted_pixels, bool omitted)
|
||||
|
||||
void text_renderer::render(int x, int y, color_t col, const char_t * str, std::size_t len, unsigned restricted_pixels, bool omitted) //deprecated
|
||||
{
|
||||
if(graph_)
|
||||
{
|
||||
@@ -572,8 +575,9 @@ namespace nana
|
||||
helper::for_each_line(str, len, y, dso);
|
||||
}
|
||||
}
|
||||
|
||||
void text_renderer::render(int x, int y, nana::color_t col, const nana::char_t * str, std::size_t len, unsigned restricted_pixels)
|
||||
*/
|
||||
/*
|
||||
void text_renderer::render(int x, int y, color_t col, const nana::char_t * str, std::size_t len, unsigned restricted_pixels)
|
||||
{
|
||||
if(graph_)
|
||||
{
|
||||
@@ -582,8 +586,9 @@ namespace nana
|
||||
helper::for_each_line(str, len, y, dsacl);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
nana::size text_renderer::extent_size(int x, int y, const nana::char_t* str, std::size_t len, unsigned restricted_pixels) const
|
||||
nana::size text_renderer::extent_size(int x, int y, const char_t* str, std::size_t len, unsigned restricted_pixels) const
|
||||
{
|
||||
nana::size extents;
|
||||
if(graph_)
|
||||
@@ -596,7 +601,16 @@ namespace nana
|
||||
return extents;
|
||||
}
|
||||
|
||||
void text_renderer::render(const nana::point& pos, const nana::char_t* str, std::size_t len, unsigned restricted_pixels, bool omitted)
|
||||
void text_renderer::render(const point& pos, const char_t * str, std::size_t len)
|
||||
{
|
||||
if (graph_)
|
||||
{
|
||||
helper::draw_string ds(graph_.handle(), pos.x, static_cast<int>(graph_.width()), text_align_);
|
||||
helper::for_each_line(str, len, pos.y, ds);
|
||||
}
|
||||
}
|
||||
|
||||
void text_renderer::render(const point& pos, const char_t* str, std::size_t len, unsigned restricted_pixels, bool omitted)
|
||||
{
|
||||
if (graph_)
|
||||
{
|
||||
@@ -604,6 +618,15 @@ namespace nana
|
||||
helper::for_each_line(str, len, pos.y, dso);
|
||||
}
|
||||
}
|
||||
|
||||
void text_renderer::render(const point& pos, const char_t * str, std::size_t len, unsigned restricted_pixels)
|
||||
{
|
||||
if (graph_)
|
||||
{
|
||||
helper::draw_string_auto_changing_lines dsacl(graph_, pos.x, pos.x + static_cast<int>(restricted_pixels), text_align_);
|
||||
helper::for_each_line(str, len, pos.y, dsacl);
|
||||
}
|
||||
}
|
||||
//end class text_renderer
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user