Breaking changes for expr_color

Removed the typedef-name nana::color_t
This commit is contained in:
cnjinhao 2014-12-18 13:08:44 +08:00
parent 42788db077
commit e64b6ec2b2
43 changed files with 185 additions and 915 deletions

View File

@ -98,33 +98,30 @@ namespace nana
typedef unsigned char uint8_t; typedef unsigned char uint8_t;
typedef unsigned long uint32_t; typedef unsigned long uint32_t;
typedef unsigned uint_t; typedef unsigned uint_t;
typedef unsigned color_t; //deprecated
typedef long long long_long_t; typedef long long long_long_t;
//const color_t null_color = 0xFFFFFFFF; //deprecated
union pixel_argb_t union pixel_argb_t
{ {
struct element_tag struct element_tag
{ {
unsigned int blue:8; unsigned char blue;
unsigned int green:8; unsigned char green;
unsigned int red:8; unsigned char red;
unsigned int alpha_channel:8; unsigned char alpha_channel;
}element; }element;
color_t value; unsigned value;
}; };
union pixel_rgba_t union pixel_rgba_t
{ {
struct element_tag struct element_tag
{ {
unsigned int alpha_channel : 8; unsigned char alpha_channel;
unsigned int blue : 8; unsigned char blue;
unsigned int green : 8; unsigned char green;
unsigned int red : 8; unsigned char red;
}element; }element;
color_t value; unsigned value;
}; };
using pixel_color_t = pixel_argb_t; using pixel_color_t = pixel_argb_t;
@ -150,12 +147,24 @@ namespace nana
highlight = 0x1CC4F7 highlight = 0x1CC4F7
}; };
#pragma pack(1)
struct rgb_color
{
unsigned char blue;
unsigned char green;
unsigned char red;
rgb_color(unsigned clr);
};
#pragma pack()
class expr_color class expr_color
{ {
public: public:
expr_color() = default; expr_color() = default;
expr_color(colors); expr_color(colors);
expr_color(colors, double alpha); expr_color(colors, double alpha);
expr_color(const rgb_color&);
expr_color(unsigned red, unsigned green, unsigned blue); expr_color(unsigned red, unsigned green, unsigned blue);
expr_color(unsigned red, unsigned green, unsigned blue, double alpha); expr_color(unsigned red, unsigned green, unsigned blue, double alpha);

View File

@ -1,6 +1,7 @@
/* /*
* Platform Specification Implementation * Platform Specification Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -99,15 +100,14 @@ namespace detail
#if defined(NANA_UNICODE) #if defined(NANA_UNICODE)
XftDraw * xftdraw; XftDraw * xftdraw;
XftColor xft_fgcolor; XftColor xft_fgcolor;
//XftColor xft_bgcolor; //deprecated
const std::string charset(const nana::string& str, const std::string& strcode); const std::string charset(const nana::string& str, const std::string& strcode);
#endif #endif
drawable_impl_type(); drawable_impl_type();
~drawable_impl_type(); ~drawable_impl_type();
void fgcolor(nana::color_t); //deprecated void fgcolor(const ::nana::expr_color&); //deprecated
void set_color(nana::color_t); void set_color(const ::nana::expr_color&);
void set_text_color(nana::color_t); void set_text_color(const ::nana::expr_color&);
void update_color(); void update_color();
void update_text_color(); void update_text_color();

View File

@ -1,6 +1,7 @@
/* /*
* Platform Specification Implementation * Platform Specification Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -102,7 +103,7 @@ namespace detail
int style; int style;
int width; int width;
void set(HDC context, int style, int width, nana::color_t color); void set(HDC context, int style, int width,unsigned color);
}pen; }pen;
struct brush_spec struct brush_spec
@ -111,9 +112,9 @@ namespace detail
HBRUSH handle; HBRUSH handle;
t style; t style;
nana::color_t color; unsigned color;
void set(HDC context, t style, nana::color_t color); void set(HDC context, t style, unsigned color);
}brush; }brush;
struct round_region_spec struct round_region_spec
@ -136,10 +137,10 @@ namespace detail
drawable_impl_type(); drawable_impl_type();
~drawable_impl_type(); ~drawable_impl_type();
void fgcolor(nana::color_t); //deprecated void fgcolor(const ::nana::expr_color&); //deprecated
unsigned get_color() const; unsigned get_color() const;
void set_color(nana::color_t); void set_color(const ::nana::expr_color&);
void set_text_color(nana::color_t); void set_text_color(const ::nana::expr_color&);
void update_pen(); void update_pen();
void update_brush(); void update_brush();

View File

@ -97,25 +97,6 @@ namespace nana
os_insert = 0x2D, os_del os_insert = 0x2D, os_del
}; };
}; };
/*
namespace color //deprecated
{
enum
{
white = 0xFFFFFF,
blue = 0x0000FF,
green = 0x00FF00,
red = 0xFF0000,
button_face_shadow_start = 0xF5F4F2,
button_face_shadow_end = 0xD5D2CA,
button_face = 0xD4D0C8,
dark_border = 0x404040,
gray_border = 0x808080,
highlight = 0x1CC4F7
};
};
*/
enum class cursor enum class cursor
{ {

View File

@ -177,10 +177,6 @@ namespace detail
struct struct
{ {
//color_t foreground; //deprecated
//color_t background; //deprecated
//color_t active; //deprecated
expr_color fgcolor; expr_color fgcolor;
expr_color bgcolor; expr_color bgcolor;
expr_color activated; expr_color activated;

View File

@ -120,12 +120,12 @@ namespace nana{
good_r.x = good_r.y = 1; good_r.x = good_r.y = 1;
good_r.width = r.width - 2; good_r.width = r.width - 2;
good_r.height = r.height - 2; good_r.height = r.height - 2;
pixbuf.rectangle(good_r, wd->colors.activated.px_color().value, 0.95, false); pixbuf.rectangle(good_r, wd->colors.activated, 0.95, false);
good_r.x = good_r.y = 0; good_r.x = good_r.y = 0;
good_r.width = r.width; good_r.width = r.width;
good_r.height = r.height; good_r.height = r.height;
pixbuf.rectangle(good_r, wd->colors.activated.px_color().value, 0.4, false); pixbuf.rectangle(good_r, wd->colors.activated, 0.4, false);
pixbuf.pixel(0, 0, px0); pixbuf.pixel(0, 0, px0);
pixbuf.pixel(r.width - 1, 0, px1); pixbuf.pixel(r.width - 1, 0, px1);

View File

@ -202,15 +202,6 @@ namespace API
void modal_window(window); ///< Blocks the routine til the specified window is closed. void modal_window(window); ///< Blocks the routine til the specified window is closed.
void wait_for(window); void wait_for(window);
/*
color_t foreground(window); //deprecated
color_t foreground(window, color_t); //deprecated
color_t background(window); //deprecated
color_t background(window, color_t); //deprecated
color_t active(window); //deprecated
color_t active(window, color_t); //deprecated
*/
expr_color fgcolor(window); expr_color fgcolor(window);
expr_color fgcolor(window, const expr_color&); expr_color fgcolor(window, const expr_color&);
expr_color bgcolor(window); expr_color bgcolor(window);

View File

@ -68,8 +68,6 @@ namespace nana{
bool enable_pushed; bool enable_pushed;
bool focus_color; bool focus_color;
paint::image * icon; paint::image * icon;
//color_t bgcolor; //deprecated
//color_t fgcolor;
::nana::expr_color bgcolor; ::nana::expr_color bgcolor;
::nana::expr_color fgcolor; ::nana::expr_color fgcolor;
}attr_; }attr_;

View File

@ -45,7 +45,6 @@ namespace nana
void week_name(unsigned index, const nana::string&); void week_name(unsigned index, const nana::string&);
void month_name(unsigned index, const nana::string&); void month_name(unsigned index, const nana::string&);
private: private:
//void _m_init_color(); //deprecated
where _m_pos_where(graph_reference, int x, int y); where _m_pos_where(graph_reference, int x, int y);
void _m_draw(graph_reference); void _m_draw(graph_reference);
void _m_draw_topbar(graph_reference); void _m_draw_topbar(graph_reference);

View File

@ -26,7 +26,6 @@ namespace nana
public: public:
void attached(widget_reference, graph_reference) override; void attached(widget_reference, graph_reference) override;
void refresh(graph_reference) override; void refresh(graph_reference) override;
//void resized(graph_reference, const arg_resized&) override; //deprecated
private: private:
widget* wd_{nullptr}; widget* wd_{nullptr};
}; };

View File

@ -37,8 +37,6 @@ namespace nana
struct struct
{ {
//unsigned background_shadow_start; //deprecated
//unsigned background_shadow_end;
::nana::expr_color gradual_from; ::nana::expr_color gradual_from;
::nana::expr_color gradual_to; ::nana::expr_color gradual_to;
bool horizontal; bool horizontal;

View File

@ -278,14 +278,14 @@ namespace nana
this->get_drawer_trigger().relate(pos, wd); this->get_drawer_trigger().relate(pos, wd);
} }
void tab_bgcolor(std::size_t i, nana::color_t color) void tab_bgcolor(std::size_t i, const ::nana::expr_color& clr)
{ {
this->get_drawer_trigger().tab_color(i, true, color); this->get_drawer_trigger().tab_color(i, true, clr);
} }
void tab_fgcolor(std::size_t i, nana::color_t color) void tab_fgcolor(std::size_t i, const ::nana::expr_color& clr)
{ {
this->get_drawer_trigger().tab_color(i, false, color); this->get_drawer_trigger().tab_color(i, false, clr);
} }
void tab_image(std::size_t i, const nana::paint::image& img) void tab_image(std::size_t i, const nana::paint::image& img)

View File

@ -73,13 +73,6 @@ namespace nana
void move(int x, int y); void move(int x, int y);
void move(const rectangle&); void move(const rectangle&);
/*
void foreground(nana::color_t); //deprecated
nana::color_t foreground() const;
void background(nana::color_t);
nana::color_t background() const;
*/
void fgcolor(const nana::expr_color&); void fgcolor(const nana::expr_color&);
nana::expr_color fgcolor() const; nana::expr_color fgcolor() const;
void bgcolor(const nana::expr_color&); void bgcolor(const nana::expr_color&);

View File

@ -352,8 +352,9 @@ namespace detail
if(d_rgb && s_rgb) if(d_rgb && s_rgb)
{ {
unsigned char* tablebuf = detail::alloc_fade_table(fade_rate);//new unsigned char[0x100 * 2]; auto ptr = detail::alloc_fade_table(fade_rate);//new unsigned char[0x100 * 2];
unsigned char* d_table = tablebuf;
unsigned char* d_table = ptr.get();
unsigned char* s_table = d_table + 0x100; unsigned char* s_table = d_table + 0x100;
const unsigned rest = s_r.width & 0x3; const unsigned rest = s_r.width & 0x3;
@ -396,7 +397,6 @@ namespace detail
d_rgb = pixel_at(d_rgb, d_step_bytes); d_rgb = pixel_at(d_rgb, d_step_bytes);
s_rgb = pixel_at(s_rgb, s_step_bytes); s_rgb = pixel_at(s_rgb, s_step_bytes);
} }
detail::free_fade_table(tablebuf);
} }
} }
}; };
@ -405,15 +405,19 @@ namespace detail
class bresenham_line class bresenham_line
: public image_process::line_interface : public image_process::line_interface
{ {
virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, nana::color_t color, double fade_rate) const virtual void process(paint::pixel_buffer & pixbuf, const nana::point& pos_beg, const nana::point& pos_end, const ::nana::expr_color& clr, double fade_rate) const
{ {
auto rgb_color = clr.px_color().value;
const std::size_t bytes_pl = pixbuf.bytes_per_line(); const std::size_t bytes_pl = pixbuf.bytes_per_line();
unsigned char * fade_table = nullptr; unsigned char * fade_table = nullptr;
std::unique_ptr<unsigned char[]> autoptr;
nana::pixel_argb_t rgb_imd; nana::pixel_argb_t rgb_imd;
if(fade_rate != 0.0) if(fade_rate != 0.0)
{ {
fade_table = detail::alloc_fade_table(1 - fade_rate); autoptr = detail::alloc_fade_table(1 - fade_rate);
rgb_imd.value = color; fade_table = autoptr.get();
rgb_imd.value = rgb_color;
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table); rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);
} }
@ -447,7 +451,7 @@ namespace detail
{ {
for(int x = 0; x < delta.x; ++x) for(int x = 0; x < delta.x; ++x)
{ {
i->value = color; i->value = rgb_color;
i = pixel_at(i, step_bytes); i = pixel_at(i, step_bytes);
} }
} }
@ -479,7 +483,7 @@ namespace detail
{ {
for(int x = 0; x < delta.x; ++x) for(int x = 0; x < delta.x; ++x)
{ {
i->value = color; i->value = rgb_color;
if(error >= 0) if(error >= 0)
{ {
error -= dx_2; error -= dx_2;
@ -513,7 +517,7 @@ namespace detail
{ {
for (int y = 0; y < delta.y; ++y) for (int y = 0; y < delta.y; ++y)
{ {
i->value = color; i->value = rgb_color;
if(error >= 0) if(error >= 0)
{ {
error -= dy_2; error -= dy_2;
@ -525,8 +529,6 @@ namespace detail
} }
} }
} }
detail::free_fade_table(fade_table);
} }
}; };

View File

@ -21,16 +21,16 @@ namespace detail
{ {
nana::size drawable_size(drawable_type); nana::size drawable_size(drawable_type);
unsigned char * alloc_fade_table(double fade_rate); std::unique_ptr<unsigned char[]> alloc_fade_table(double fade_rate);
void free_fade_table(const unsigned char*); void free_fade_table(const unsigned char*);
//color = bgcolor * fade_rate + fgcolor * (1 - fade_rate); //color = bgcolor * fade_rate + fgcolor * (1 - fade_rate);
//nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, double fade_rate); //deprecated //nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, double fade_rate); //deprecated
nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, const unsigned char* const fade_table); nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, const unsigned char* const fade_table);
nana::pixel_color_t fade_color_intermedia(nana::pixel_color_t fgcolor, const unsigned char* fade_table); nana::pixel_color_t fade_color_intermedia(pixel_color_t fgcolor, const unsigned char* fade_table);
nana::pixel_color_t fade_color_by_intermedia(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor_intermedia, const unsigned char* const fade_table); nana::pixel_color_t fade_color_by_intermedia(pixel_color_t bgcolor, nana::pixel_color_t fgcolor_intermedia, const unsigned char* const fade_table);
void blend(drawable_type dw, const nana::rectangle& r, nana::color_t, double fade_rate); void blend(drawable_type dw, const nana::rectangle& r, pixel_color_t, double fade_rate);
nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len); nana::size raw_text_extent_size(drawable_type, const nana::char_t*, std::size_t len);
nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len); nana::size text_extent_size(drawable_type, const nana::char_t*, std::size_t len);

View File

@ -1,6 +1,7 @@
/* /*
* Paint Graphics Implementation * Paint Graphics Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -99,29 +100,6 @@ namespace nana
bool text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const; bool text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const;
//unsigned bidi_string(int x, int y, color_t, const char_t *, std::size_t len); //deprecated
//void string(int x, int y, color_t, const ::nana::string&, std::size_t len);
//void string(int x, int y, color_t, const ::nana::string&);
//void string(int x, int y, color_t, const char_t*, std::size_t len);
//void string(int x, int y, color_t, const char_t*);
/*
void set_pixel(int x, int y, color_t);
void rectangle(int x, int y, unsigned width, unsigned height, color_t, bool solid);
void rectangle(color_t, bool solid);
void rectangle(const ::nana::rectangle&, color_t, bool solid);
void rectangle_line(const ::nana::rectangle&, color_t left, color_t top, color_t right, color_t bottom);
void round_rectangle(int x, int y, unsigned width, unsigned height, unsigned radius_x, unsigned radius_y, color_t, bool solid, color_t color_if_solid);
void round_rectangle(const ::nana::rectangle&, unsigned radius_x, unsigned radius_y, color_t, bool solid, color_t color_if_solid);
void shadow_rectangle(const ::nana::rectangle&, color_t beg_color, color_t end_color, bool vertical); //deprecated
void shadow_rectangle(int x, int y, unsigned width, unsigned height, color_t beg_color, color_t end_color, bool vertical); ///< Draws a width and height rectangle at (x, y) and the color in range of [begin, end]
void line(int x1, int y1, int x2, int y2, color_t); ///< Draws a line from point (x1, y1) to point (x2, y2) in the specified color.
void line(const point& beg, const point& end, color_t);
void lines(const point* points, std::size_t n_of_points, color_t);
void line_to(int x, int y, color_t);
*/
void line_begin(int x, int y); void line_begin(int x, int y);
void bitblt(int x, int y, const graphics& source); ///< Transfers the source to the specified point. void bitblt(int x, int y, const graphics& source); ///< Transfers the source to the specified point.
@ -131,7 +109,6 @@ namespace nana
void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics. void bitblt(const ::nana::rectangle& r_dst, const graphics& src, const point& p_src);///< Transfers the color data corresponding to r_dst from the src graphics at point p_src to this graphics.
void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object. void blend(const ::nana::rectangle& s_r, graphics& dst, const point& d_pos, double fade_rate) const;///< blends with the dst object.
void blend(const ::nana::rectangle& r, color_t, double fade_rate); ///< blends the specifed block width the specified color.
void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process. void blur(const ::nana::rectangle& r, std::size_t radius); ///< Blur process.
@ -154,8 +131,6 @@ namespace nana
void release(); void release();
void save_as_file(const char*); void save_as_file(const char*);
//static color_t mix(color_t colorX, color_t colorY, double persent); //deprecated
void set_color(const ::nana::expr_color&); void set_color(const ::nana::expr_color&);
void set_text_color(const ::nana::expr_color&); void set_text_color(const ::nana::expr_color&);

View File

@ -24,7 +24,7 @@ namespace nana
class stretch_interface class stretch_interface
{ {
public: public:
virtual ~stretch_interface() = 0; virtual ~stretch_interface() = default;
/// Copies the image from a source rectangle into a destination rectangle, stretching or compressing the image to fit the dimensions of the destination rectangle in destination(d_pixbuf). /// Copies the image from a source rectangle into a destination rectangle, stretching or compressing the image to fit the dimensions of the destination rectangle in destination(d_pixbuf).
virtual void process(const paint::pixel_buffer & s_pixbuf, virtual void process(const paint::pixel_buffer & s_pixbuf,
const nana::rectangle& source_rectangle, const nana::rectangle& source_rectangle,
@ -36,14 +36,14 @@ namespace nana
class alpha_blend_interface class alpha_blend_interface
{ {
public: public:
virtual ~alpha_blend_interface() = 0; virtual ~alpha_blend_interface() = default;
virtual void process(const paint::pixel_buffer& s_pixbuf, const nana::rectangle& s_r, paint::pixel_buffer& d_pixbuf, const point& d_pos) const = 0; virtual void process(const paint::pixel_buffer& s_pixbuf, const nana::rectangle& s_r, paint::pixel_buffer& d_pixbuf, const point& d_pos) const = 0;
}; };
/// The interface of a blend algorithm. /// The interface of a blend algorithm.
class blend_interface class blend_interface
{ {
public: public:
virtual ~blend_interface() = 0; virtual ~blend_interface() = default;
/// \brief Blends two images with specified area and blend rate. /// \brief Blends two images with specified area and blend rate.
/// ///
/// Semantics: \code dest_pixbuf = dest_pixbuf * fade_rate + scr_pixbuf * (1 - fade_rate); \endcode /// Semantics: \code dest_pixbuf = dest_pixbuf * fade_rate + scr_pixbuf * (1 - fade_rate); \endcode
@ -59,16 +59,16 @@ namespace nana
class line_interface class line_interface
{ {
public: public:
virtual ~line_interface() = 0; virtual ~line_interface() = default;
/// \brief Draws a line /// \brief Draws a line
/// ///
/// Semantics: \code pixbuf = pixbuf * (1 - fade_rate) + color * fade_rate \endcode /// Semantics: \code pixbuf = pixbuf * (1 - fade_rate) + color * fade_rate \endcode
/// The two points are calculated by Nana, they are always valid, and pos_beg.x <= pos_end.x /// The two points are calculated by Nana, they are always valid, and pos_beg.x <= pos_end.x
virtual void process(paint::pixel_buffer & pixbuf, virtual void process(paint::pixel_buffer & pixbuf,
const nana::point& pos_beg, ///< left point const point& pos_beg, ///< left point
const nana::point& pos_end, ///< right point const point& pos_end, ///< right point
nana::color_t color, const ::nana::expr_color&,
double fade_rate ///< blend rate in the range of [0, 1] If not 0, the line is blended to the pixbuf double fade_rate ///< blend rate in the range of [0, 1] If not 0, the line is blended to the pixbuf
) const = 0; ) const = 0;
}; };
@ -76,7 +76,7 @@ namespace nana
class blur_interface class blur_interface
{ {
public: public:
virtual ~blur_interface() = 0; virtual ~blur_interface() = default;
virtual void process(paint::pixel_buffer&, const nana::rectangle& r, std::size_t radius) const = 0; virtual void process(paint::pixel_buffer&, const nana::rectangle& r, std::size_t radius) const = 0;
}; };
} }

View File

@ -67,10 +67,10 @@ namespace nana{ namespace paint
void put(const unsigned char* rawbits, std::size_t width, std::size_t height, std::size_t bits_per_pixel, std::size_t bytes_per_line, bool is_negative); void put(const unsigned char* rawbits, std::size_t width, std::size_t height, std::size_t bits_per_pixel, std::size_t bytes_per_line, bool is_negative);
void line(const std::string& name); void line(const std::string& name);
void line(const nana::point& pos_beg, const nana::point& pos_end, nana::color_t color, double fade_rate); void line(const ::nana::point& pos_beg, const ::nana::point& pos_end, const ::nana::expr_color&, double fade_rate);
void rectangle(const nana::rectangle&, nana::color_t, double fade_rate, bool solid); void rectangle(const nana::rectangle&, const ::nana::expr_color&, double fade_rate, bool solid);
void shadow_rectangle(const nana::rectangle&, nana::color_t beg, nana::color_t end, double fade_rate, bool vertical); //deprecated //void shadow_rectangle(const nana::rectangle&, nana::color_t beg, nana::color_t end, double fade_rate, bool vertical); //deprecated
void gradual_rectangle(const ::nana::rectangle&, const ::nana::expr_color& from, const ::nana::expr_color& to, double fade_rate, bool vertical); void gradual_rectangle(const ::nana::rectangle&, const ::nana::expr_color& from, const ::nana::expr_color& to, double fade_rate, bool vertical);
pixel_argb_t pixel(int x, int y) const; pixel_argb_t pixel(int x, int y) const;

View File

@ -13,15 +13,21 @@
namespace nana namespace nana
{ {
rgb_color::rgb_color(unsigned clr)
: blue((0xFF00 & clr) >> 8), green(0xFF & clr), red((0xFF0000 & clr) >> 16)
{}
//class color //class color
expr_color::expr_color(colors clr)
: expr_color((static_cast<unsigned>(clr)& 0xFF0000) >> 16, (static_cast<unsigned>(clr)& 0xFF00) >> 8, static_cast<unsigned>(clr)& 0xFF)
{}
expr_color::expr_color(colors col) expr_color::expr_color(colors clr, double alpha)
: expr_color((static_cast<unsigned>(col)& 0xFF0000) >> 16, (static_cast<unsigned>(col)& 0xFF00) >> 8, static_cast<unsigned>(col)& 0xFF) : expr_color((static_cast<unsigned>(clr)& 0xFF0000) >> 16, (static_cast<unsigned>(clr)& 0xFF00) >> 8, static_cast<unsigned>(clr)& 0xFF, alpha)
{ {}
}
expr_color::expr_color(colors col, double alpha) expr_color::expr_color(const rgb_color& rgb)
: expr_color((static_cast<unsigned>(col)& 0xFF0000) >> 16, (static_cast<unsigned>(col)& 0xFF00) >> 8, static_cast<unsigned>(col)& 0xFF, alpha) : a_(1.0), r_(rgb.red), g_(rgb.green), b_(rgb.blue)
{ {
} }

View File

@ -301,14 +301,14 @@ namespace detail
#endif #endif
} }
void drawable_impl_type::set_color(nana::color_t col) void drawable_impl_type::set_color(const ::nana::expr_color& clr)
{ {
color_ = col; color_ = clr.px_color().value;
} }
void drawable_impl_type::set_text_color(nana::color_t col) void drawable_impl_type::set_text_color(const ::nana::expr_color& clr)
{ {
text_color_ = col; text_color_ = clr.px_color().value;
update_text_color(); update_text_color();
} }
@ -363,28 +363,30 @@ namespace detail
} }
} }
void drawable_impl_type::fgcolor(nana::color_t color) void drawable_impl_type::fgcolor(const ::nana::expr_color& clr)
{ {
if (color != current_color_) auto rgb = clr.px_color().value;
if (rgb != current_color_)
{ {
auto & spec = nana::detail::platform_spec::instance(); auto & spec = nana::detail::platform_spec::instance();
platform_scope_guard psg; platform_scope_guard psg;
current_color_ = color; current_color_ = rgb;
switch(spec.screen_depth()) switch(spec.screen_depth())
{ {
case 16: case 16:
color = ((((color >> 16) & 0xFF) * 31 / 255) << 11) | rgb = ((((color >> 16) & 0xFF) * 31 / 255) << 11) |
((((color >> 8) & 0xFF) * 63 / 255) << 5) | ((((color >> 8) & 0xFF) * 63 / 255) << 5) |
(color & 0xFF) * 31 / 255; (color & 0xFF) * 31 / 255;
break; break;
} }
::XSetForeground(spec.open_display(), context, color); ::XSetForeground(spec.open_display(), context, rgb);
::XSetBackground(spec.open_display(), context, color); ::XSetBackground(spec.open_display(), context, rgb);
#if defined(NANA_UNICODE) #if defined(NANA_UNICODE)
xft_fgcolor.color.red = ((0xFF0000 & color) >> 16) * 0x101; xft_fgcolor.color.red = ((0xFF0000 & rgb) >> 16) * 0x101;
xft_fgcolor.color.green = ((0xFF00 & color) >> 8) * 0x101; xft_fgcolor.color.green = ((0xFF00 & rgb) >> 8) * 0x101;
xft_fgcolor.color.blue = (0xFF & color) * 0x101; xft_fgcolor.color.blue = (0xFF & rgb) * 0x101;
xft_fgcolor.color.alpha = 0xFFFF; xft_fgcolor.color.alpha = 0xFFFF;
#endif #endif
} }

View File

@ -48,9 +48,9 @@ namespace detail
::DeleteObject(round_region.handle); ::DeleteObject(round_region.handle);
} }
void drawable_impl_type::fgcolor(nana::color_t col) void drawable_impl_type::fgcolor(const ::nana::expr_color& clr)
{ {
set_text_color(col); set_text_color(clr);
} }
unsigned drawable_impl_type::get_color() const unsigned drawable_impl_type::get_color() const
@ -58,17 +58,18 @@ namespace detail
return color_; return color_;
} }
void drawable_impl_type::set_color(nana::color_t col) void drawable_impl_type::set_color(const ::nana::expr_color& clr)
{ {
color_ = col; color_ = clr.px_color().value;
} }
void drawable_impl_type::set_text_color(nana::color_t col) void drawable_impl_type::set_text_color(const ::nana::expr_color& clr)
{ {
if(text_color_ != col) auto rgb = clr.px_color().value;
if (text_color_ != rgb)
{ {
::SetTextColor(context, NANA_RGB(col)); ::SetTextColor(context, NANA_RGB(rgb));
text_color_ = col; text_color_ = rgb;
} }
} }
@ -88,28 +89,28 @@ namespace detail
brush.set(context, brush.style, color_); brush.set(context, brush.style, color_);
} }
void drawable_impl_type::pen_spec::set(HDC context, int style, int width, nana::color_t color) //deprecated void drawable_impl_type::pen_spec::set(HDC context, int style, int width, unsigned clr)
{ {
if(this->color != color || this->width != width || this->style != style) if (this->color != clr || this->width != width || this->style != style)
{ {
this->color = color; this->color = clr;
this->width = width; this->width = width;
this->style = style; this->style = style;
this->handle = ::CreatePen(style, width, NANA_RGB(color)); this->handle = ::CreatePen(style, width, NANA_RGB(clr));
::DeleteObject(::SelectObject(context, this->handle)); ::DeleteObject(::SelectObject(context, this->handle));
} }
} }
void drawable_impl_type::brush_spec::set(HDC context, drawable_impl_type::brush_spec::t style, nana::color_t color) void drawable_impl_type::brush_spec::set(HDC context, drawable_impl_type::brush_spec::t style, unsigned rgb)
{ {
if(this->color != color || this->style != style) if (this->color != rgb || this->style != style)
{ {
this->color = color; this->color = rgb;
this->style = style; this->style = style;
switch(style) switch(style)
{ {
case brush_spec::HatchBDiagonal: case brush_spec::HatchBDiagonal:
this->handle = ::CreateHatchBrush(HS_BDIAGONAL, NANA_RGB(color)); this->handle = ::CreateHatchBrush(HS_BDIAGONAL, NANA_RGB(rgb));
break; break;
case brush_spec::Solid: case brush_spec::Solid:
default: default:

View File

@ -347,9 +347,6 @@ namespace nana
visible = false; visible = false;
//colors.foreground = 0x0; //deprecated
//colors.background = nana::color::button_face;
//colors.active = 0x60C8FD;
colors.fgcolor = ::nana::colors::black; colors.fgcolor = ::nana::colors::black;
colors.bgcolor = ::nana::colors::button_face; colors.bgcolor = ::nana::colors::button_face;
colors.activated.from_rgb(0x60, 0xc8, 0xfd); colors.activated.from_rgb(0x60, 0xc8, 0xfd);

View File

@ -26,8 +26,6 @@ namespace nana
{ {
if(fade_rate_ < 0.001) if(fade_rate_ < 0.001)
return; return;
//nana::color_t color = API::background(wd); //deprecated
graph.blend(graph.size(), API::bgcolor(wd), fade_rate_); graph.blend(graph.size(), API::bgcolor(wd), fade_rate_);
} }
private: private:

View File

@ -1,3 +1,15 @@
/*
* Elements of GUI Gadgets
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
*
* @file: nana/gui/element.cpp
*/
#include <nana/gui/element.hpp> #include <nana/gui/element.hpp>
#include <nana/gui/detail/bedrock.hpp> #include <nana/gui/detail/bedrock.hpp>
#include <nana/gui/detail/element_store.hpp> #include <nana/gui/detail/element_store.hpp>
@ -129,7 +141,6 @@ namespace nana
} }
else else
{ {
//const nana::color_t highlighted = 0x5EB6F7; //deprecated
nana::expr_color highlighted(0x5e, 0xb6, 0xf7); nana::expr_color highlighted(0x5e, 0xb6, 0xf7);
auto bld_bgcolor = bgcolor; auto bld_bgcolor = bgcolor;
auto bld_fgcolor = fgcolor; auto bld_fgcolor = fgcolor;
@ -139,18 +150,13 @@ namespace nana
case element_state::focus_hovered: case element_state::focus_hovered:
bld_bgcolor.blend(highlighted, 0.8); bld_bgcolor.blend(highlighted, 0.8);
bld_fgcolor.blend(highlighted, 0.8); bld_fgcolor.blend(highlighted, 0.8);
//bgcolor = graph.mix(bgcolor, highlighted, 0.8); //deprecated
//fgcolor = graph.mix(fgcolor, highlighted, 0.8);
break; break;
case element_state::pressed: case element_state::pressed:
bld_bgcolor.blend(highlighted, 0.4); bld_bgcolor.blend(highlighted, 0.4);
bld_fgcolor.blend(highlighted, 0.4); bld_fgcolor.blend(highlighted, 0.4);
//bgcolor = graph.mix(bgcolor, highlighted, 0.4); //deprecated
//fgcolor = graph.mix(fgcolor, highlighted, 0.4);
break; break;
case element_state::disabled: case element_state::disabled:
bld_bgcolor = bld_fgcolor = nana::expr_color(0xb2, 0xb7, 0xbc); bld_bgcolor = bld_fgcolor = nana::expr_color(0xb2, 0xb7, 0xbc);
//bgcolor = fgcolor = 0xB2B7BC; //deprecated
break; break;
default: default:
//Leave things as they are //Leave things as they are
@ -250,15 +256,6 @@ namespace nana
graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 }); graph.line(point{ x + 7, y + 10 }, point{ x + 12, y + 5 });
graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 }); graph.line(point{ x + 4, y + 7 }, point{ x + 6, y + 9 });
graph.line(point{ x + 7, y + 8 }, point{ x + 11, y + 4 }); graph.line(point{ x + 7, y + 8 }, point{ x + 11, y + 4 });
//nana::color_t light = graph.mix(fgcolor, 0xFFFFFF, 0.5); //deprecated
/*
graph.line(point{ x + 3, y + 7 }, point{ x + 6, y + 10 }, fgcolor); //deprecated
graph.line(x + 7, y + 9, x + 12, y + 4, fgcolor);
graph.line(x + 3, y + 8, x + 6, y + 11, light);
graph.line(x + 7, y + 10, x + 12, y + 5, light);
graph.line(x + 4, y + 7, x + 6, y + 9, light);
graph.line(x + 7, y + 8, x + 11, y + 4, light);
*/
} }
return true; return true;
} }

View File

@ -790,85 +790,6 @@ namespace API
restrict::bedrock.pump_event(wd, false); restrict::bedrock.pump_event(wd, false);
} }
/*
nana::color_t foreground(window wd) //deprecated
{
internal_scope_guard lock;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return reinterpret_cast<restrict::core_window_t*>(wd)->colors.fgcolor.px_color().value;
return 0;
}
color_t foreground(window wd, color_t col) //deprecated
{
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard lock;
if(restrict::window_manager.available(iwd))
{
color_t prev = iwd->colors.fgcolor.px_color().value;
if(prev != col)
{
iwd->colors.fgcolor = static_cast<colors>(col);
restrict::window_manager.update(iwd, true, false);
}
return prev;
}
return 0;
}
color_t background(window wd) //deprecated
{
internal_scope_guard lock;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return reinterpret_cast<restrict::core_window_t*>(wd)->colors.bgcolor.px_color().value;
return 0;
}
color_t background(window wd, color_t col) //deprecated
{
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard lock;
if(restrict::window_manager.available(iwd))
{
color_t prev = iwd->colors.bgcolor.px_color().value;
if(prev != col)
{
iwd->colors.bgcolor = static_cast<colors>(col);
restrict::window_manager.update(iwd, true, false);
}
return prev;
}
return 0;
}
color_t active(window wd) //deprecated
{
internal_scope_guard lock;
if(restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)))
return reinterpret_cast<restrict::core_window_t*>(wd)->colors.activated.px_color().value;
return 0;
}
color_t active(window wd, color_t clr) //deprecated
{
auto iwd = reinterpret_cast<restrict::core_window_t*>(wd);
internal_scope_guard lock;
if(restrict::window_manager.available(iwd))
{
color_t prev = iwd->colors.activated.px_color().value;
if (prev != clr)
{
iwd->colors.activated = static_cast<colors>(clr);
restrict::window_manager.update(iwd, true, false);
}
return prev;
}
return 0;
}
*/
expr_color fgcolor(window wd) expr_color fgcolor(window wd)
{ {
internal_scope_guard lock; internal_scope_guard lock;

View File

@ -197,8 +197,6 @@ namespace nana{ namespace drawerbase
icon_sz.width += 5; icon_sz.width += 5;
} }
//int x = (static_cast<int>(gsize.width - 1 - ts.width) >> 1); //deprecated
//int y = (static_cast<int>(gsize.height - 1 - ts.height) >> 1);
nana::point pos{ nana::point pos{
static_cast<int>(gsize.width - 1 - ts.width) >> 1, static_cast<int>(gsize.height - 1 - ts.height) >> 1 static_cast<int>(gsize.width - 1 - ts.width) >> 1, static_cast<int>(gsize.height - 1 - ts.height) >> 1
}; };
@ -226,15 +224,8 @@ namespace nana{ namespace drawerbase
graph.set_text_color(fgcolor); graph.set_text_color(fgcolor);
/*
if(attr_.omitted)
tr.render(x, y, fgcolor.argb().value, txtptr, txtlen, omitted_pixels, true); //deprecated
else
graph.bidi_string(x, y, fgcolor, txtptr, txtlen);
*/
if (attr_.omitted) if (attr_.omitted)
tr.render(pos, txtptr, txtlen, omitted_pixels, true); //deprecated tr.render(pos, txtptr, txtlen, omitted_pixels, true);
else else
graph.bidi_string(pos, txtptr, txtlen); graph.bidi_string(pos, txtptr, txtlen);
@ -244,8 +235,7 @@ namespace nana{ namespace drawerbase
nana::size shortkey_size = graph.text_extent_size(txtptr + shortkey_pos, 1); nana::size shortkey_size = graph.text_extent_size(txtptr + shortkey_pos, 1);
pos.x += off_w; pos.x += off_w;
pos.y += static_cast<int>(shortkey_size.height); pos.y += static_cast<int>(shortkey_size.height);
//graph.line(x, y, x + shortkey_size.width - 1, y, 0x0); //deprecated graph.set_color(colors::black);
graph.set_color(::nana::expr_color(colors::black));
graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y }); graph.line(pos, point{ pos.x + static_cast<int>(shortkey_size.width) - 1, pos.y });
} }
} }
@ -308,8 +298,6 @@ namespace nana{ namespace drawerbase
nana::rectangle r(graph.size()); nana::rectangle r(graph.size());
r.pare_off(1); r.pare_off(1);
//nana::color_t color_start = nana::paint::graphics::mix(attr_.bgcolor.argb().value, 0xFFFFFF, 0.2); //deprecated
//nana::color_t color_end = nana::paint::graphics::mix(attr_.bgcolor.argb().value, 0x0, 0.95);
::nana::expr_color from(colors::white); ::nana::expr_color from(colors::white);
from.blend(attr_.bgcolor, 0.8); from.blend(attr_.bgcolor, 0.8);
::nana::expr_color to(colors::black); ::nana::expr_color to(colors::black);
@ -320,7 +308,6 @@ namespace nana{ namespace drawerbase
r.x = r.y = 2; r.x = r.y = 2;
std::swap(from, to); std::swap(from, to);
} }
//graph.shadow_rectangle(r, color_start, color_end, true); //deprecated
graph.gradual_rectangle(r, from, to, true); graph.gradual_rectangle(r, from, to, true);
} }

View File

@ -79,7 +79,6 @@ namespace nana
if(ue.what == ue.none || (API::window_enabled(wd) == false)) if(ue.what == ue.none || (API::window_enabled(wd) == false))
{ //the mouse is out of the widget. { //the mouse is out of the widget.
style_.bgcolor.blend(expr_color{ 0xa0, 0xc9, 0xf5 }, 0.9); style_.bgcolor.blend(expr_color{ 0xa0, 0xc9, 0xf5 }, 0.9);
//style_.bgcolor = nana::paint::graphics::mix(style_.bgcolor, 0xA0C9F5, 0.9); //deprecated
} }
graph.rectangle(r, true, style_.bgcolor); graph.rectangle(r, true, style_.bgcolor);
} }
@ -131,21 +130,16 @@ namespace nana
::nana::expr_color clr{ 0x3C, 0x7F, 0xB1 }; ::nana::expr_color clr{ 0x3C, 0x7F, 0xB1 };
if(has_child) if(has_child)
{ {
int left = r.x + r.width - 16;
_m_item_bground(graph, left, top, 15, height, state_arrow);
width -= 16; width -= 16;
--left;
//graph.line(left, top, left, r.y + height, 0x3C7FB1);//deprecated int left = r.x + r.width - 17;
graph.set_color(clr); _m_item_bground(graph, left + 1, top, 15, height, state_arrow);
graph.line({ left, top }, { left, r.y + static_cast<int>(height) }); graph.line({ left, top }, { left, r.y + static_cast<int>(height) }, clr);
} }
_m_item_bground(graph, r.x + 1, top, width, height, state_name); _m_item_bground(graph, r.x + 1, top, width, height, state_name);
//graph.rectangle(r, 0x3C7FB1, false); //deprecated graph.rectangle(r, false, clr);
graph.set_color(clr);
graph.rectangle(r, false);
} }
//graph.string(strpos.x, strpos.y, style_.fgcolor, name); //deprecated
graph.string(strpos, name, style_.fgcolor); graph.string(strpos, name, style_.fgcolor);
if(has_child) if(has_child)
@ -159,17 +153,11 @@ namespace nana
{ {
rectangle r{ graph.size() }; rectangle r{ graph.size() };
graph.set_color({ 0xf0, 0xf0, 0xf0 }); graph.rectangle(r, false, { 0xf0, 0xf0, 0xf0 });
graph.rectangle(r, false);
expr_color lb(0x9d, 0xab, 0xb9); expr_color lb(0x9d, 0xab, 0xb9);
expr_color tr(0x48, 0x4e, 0x55); expr_color tr(0x48, 0x4e, 0x55);
graph.frame_rectangle(r.pare_off(1), lb, tr, tr, lb); graph.frame_rectangle(r.pare_off(1), lb, tr, tr, lb);
//deprecated
//graph.rectangle(0xF0F0F0, false);
//graph.rectangle_line(nana::rectangle(graph.size()).pare_off(1),
// 0x9DABB9, 0x484E55, 0x484E55, 0x9DABB9);
} }
private: private:
void _m_item_bground(graph_reference graph, int x, int y, unsigned width, unsigned height, mouse_action state) void _m_item_bground(graph_reference graph, int x, int y, unsigned width, unsigned height, mouse_action state)
@ -177,35 +165,25 @@ namespace nana
const unsigned half = (height - 2) / 2; const unsigned half = (height - 2) / 2;
int left = x + 1; int left = x + 1;
int top = y + 1; int top = y + 1;
//nana::color_t upcol, downcol; // deprecated
nana::expr_color clr_top(0xea, 0xea, 0xea), clr_bottom(0xdc, 0xdc, 0xdc); nana::expr_color clr_top(0xea, 0xea, 0xea), clr_bottom(0xdc, 0xdc, 0xdc);
switch(state) switch(state)
{ {
case mouse_action::over: case mouse_action::over:
clr_top = expr_color(0xdf, 0xf2, 0xfc); clr_top.from_rgb(0xdf, 0xf2, 0xfc);
clr_bottom = expr_color(0xa9, 0xda, 0xf5); clr_bottom.from_rgb(0xa9, 0xda, 0xf5);
//upcol = 0x0DFF2FC; //deprecated
//downcol = 0xA9DAF5;
break; break;
case mouse_action::pressed: case mouse_action::pressed:
//upcol = 0xA6D7F2; //deprecated clr_top.from_rgb(0xa6, 0xd7, 0xf2);
//downcol = 0x92C4F6; clr_bottom.from_rgb(0x92, 0xc4, 0xf6);
clr_top = expr_color(0xa6, 0xd7, 0xf2);
clr_bottom = expr_color(0x92, 0xc4, 0xf6);
++left; ++left;
++top; ++top;
break; break;
//case mouse_action::normal: //deprecated
default: default:
//upcol = 0xEAEAEA; //deprecated
//downcol = 0xDCDCDC;
break; break;
} }
graph.rectangle(rectangle{ left, top, width - 2, half }, true, clr_top); graph.rectangle(rectangle{ left, top, width - 2, half }, true, clr_top);
graph.rectangle(rectangle{ left, top + static_cast<int>(half), width - 2, (height - 2) - half }, true, clr_bottom); graph.rectangle(rectangle{ left, top + static_cast<int>(half), width - 2, (height - 2) - half }, true, clr_bottom);
//graph.rectangle(left, top, width - 2, half, upcol, true); //deprecated
//graph.rectangle(left, top + static_cast<int>(half), width - 2, (height - 2) - half, downcol, true);
if(mouse_action::pressed == state) if(mouse_action::pressed == state)
{ {
int bottom = y + height - 1; int bottom = y + height - 1;
@ -219,13 +197,6 @@ namespace nana
graph.set_color(expr_color(0xa6, 0xc7, 0xd9)); graph.set_color(expr_color(0xa6, 0xc7, 0xd9));
graph.line(point{ x, y }, point{ right, y }); graph.line(point{ x, y }, point{ right, y });
graph.line(point{ x, y + 1 }, point{ x, bottom }); graph.line(point{ x, y + 1 }, point{ x, bottom });
//graph.line(x, y, right, y, 0x6E8D9F); //deprecated
//graph.line(x, y + 1, x, bottom, 0x6E8D9F);
//++x;
//++y;
//graph.line(x, y, right, y, 0xA6C7D9);
//graph.line(x, y + 1, x, bottom, 0xA6C7D9);
} }
} }
@ -416,7 +387,6 @@ namespace nana
void attach(window wd, nana::paint::graphics* graph) void attach(window wd, nana::paint::graphics* graph)
{ {
window_ = wd; window_ = wd;
//API::background(wd, 0xFFFFFF); //deprecated
API::bgcolor(wd, colors::white); API::bgcolor(wd, colors::white);
graph_ = graph; graph_ = graph;
} }

View File

@ -600,7 +600,6 @@ namespace nana
void trigger::attached(widget_reference wdg, graph_reference graph) void trigger::attached(widget_reference wdg, graph_reference graph)
{ {
wdg.bgcolor(colors::white); wdg.bgcolor(colors::white);
//wdg.background(0xFFFFFF); //deprecated
drawer_->attached(wdg, graph); drawer_->attached(wdg, graph);
API::effects_edge_nimbus(wdg, effects::edge_nimbus::active); API::effects_edge_nimbus(wdg, effects::edge_nimbus::active);

View File

@ -1,6 +1,7 @@
/* /*
* A date chooser Implementation * A date chooser Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -63,15 +64,6 @@ namespace nana
if(0 <= index && index < 12) if(0 <= index && index < 12)
this->monthstr_[index] = str; this->monthstr_[index] = str;
} }
/*
void trigger::_m_init_color() //deprecated
{
color_.selected = 0x2F3699;
color_.highlight = 0x4D56C8;
color_.normal = 0x0;
color_.bkcolor = 0x88C4FF;
}
*/
trigger::where trigger::_m_pos_where(graph_reference graph, int x, int y) trigger::where trigger::_m_pos_where(graph_reference graph, int x, int y)
{ {
@ -99,13 +91,8 @@ namespace nana
void trigger::_m_draw(graph_reference graph) void trigger::_m_draw(graph_reference graph)
{ {
//_m_init_color(); //deprecated
const unsigned width = graph.width() - 2; const unsigned width = graph.width() - 2;
//graph.rectangle(0xB0B0B0, false); //deprecated
//graph.rectangle(1, 1, width, topbar_height, 0xFFFFFF, true);
graph.rectangle(false, {0xb0, 0xb0, 0xb0}); graph.rectangle(false, {0xb0, 0xb0, 0xb0});
graph.rectangle({ 1, 1, width, static_cast<unsigned>(topbar_height) }, true, colors::white); graph.rectangle({ 1, 1, width, static_cast<unsigned>(topbar_height) }, true, colors::white);

View File

@ -37,22 +37,12 @@ namespace nana
::nana::expr_color clr{ 0xaf, 0xc7, 0xe3 }; ::nana::expr_color clr{ 0xaf, 0xc7, 0xe3 };
graph.rectangle(r, false, clr); graph.rectangle(r, false, clr);
//graph.set_pixel(r.x, r.y, 0xFFFFFF); //deprecated
//graph.set_pixel(r.x + r.width - 1, r.y, 0xFFFFFF);
//graph.set_pixel(r.x, r.y + r.height - 1, 0xFFFFFF);
//graph.set_pixel(r.x + r.width - 1, r.y + r.height - 1, 0xFFFFFF);
graph.set_color(colors::white); graph.set_color(colors::white);
graph.set_pixel(r.x, r.y); graph.set_pixel(r.x, r.y);
graph.set_pixel(r.x + r.width - 1, r.y); graph.set_pixel(r.x + r.width - 1, r.y);
graph.set_pixel(r.x, r.y + r.height - 1); graph.set_pixel(r.x, r.y + r.height - 1);
graph.set_pixel(r.x + r.width - 1, r.y + r.height - 1); graph.set_pixel(r.x + r.width - 1, r.y + r.height - 1);
//graph.set_pixel(r.x + 1, r.y + 1, 0xAFC7E3); //deprecated
//graph.set_pixel(r.x + r.width - 2, r.y + 1, 0xAFC7E3);
//graph.set_pixel(r.x + 1, r.y + r.height - 2, 0xAFC7E3);
//graph.set_pixel(r.x + r.width - 2, r.y + r.height - 2, 0xAFC7E3);
graph.set_color(clr); graph.set_color(clr);
graph.set_pixel(r.x + 1, r.y + 1); graph.set_pixel(r.x + 1, r.y + 1);
graph.set_pixel(r.x + r.width - 2, r.y + 1); graph.set_pixel(r.x + r.width - 2, r.y + 1);

View File

@ -27,13 +27,6 @@ namespace nana
{ {
graph.rectangle(true, API::bgcolor(*wd_)); graph.rectangle(true, API::bgcolor(*wd_));
} }
/*
void trigger::resized(graph_reference graph, const arg_resized&) //deprecated
{
graph.rectangle(API::background(*wd_), true);
API::lazy_refresh();
}
*/
}//end namespace form }//end namespace form
}//end namespace drawerbase }//end namespace drawerbase

View File

@ -577,8 +577,6 @@ namespace nana
typedef std::vector<cell> container; typedef std::vector<cell> container;
container cells; container cells;
//color_t bgcolor{0xFF000000}; //deprecated
//color_t fgcolor{0xFF000000};
nana::expr_color bgcolor; nana::expr_color bgcolor;
nana::expr_color fgcolor; nana::expr_color fgcolor;
paint::image img; paint::image img;
@ -2345,8 +2343,6 @@ namespace nana
size_type n = essence_->number_of_lister_items(true); size_type n = essence_->number_of_lister_items(true);
if(0 == n)return; if(0 == n)return;
widget * wdptr = essence_->lister.wd_ptr(); widget * wdptr = essence_->lister.wd_ptr();
//nana::color_t bgcolor = wdptr->background();
//nana::color_t txtcolor = wdptr->foreground(); //deprecated
auto bgcolor = wdptr->bgcolor(); auto bgcolor = wdptr->bgcolor();
auto fgcolor = wdptr->fgcolor(); auto fgcolor = wdptr->fgcolor();
@ -2515,7 +2511,7 @@ namespace nana
auto graph = essence_->graph; auto graph = essence_->graph;
if (essence_t::state_t::highlighted == state) if (essence_t::state_t::highlighted == state)
bgcolor.blend(::nana::expr_color(0x99, 0xde, 0xfd), 0.8);// = graph->mix(bgcolor, 0x99DEFD, 0.8); //deprecated bgcolor.blend(::nana::expr_color(0x99, 0xde, 0xfd), 0.8);
unsigned show_w = width - essence_->scroll.offset_x; unsigned show_w = width - essence_->scroll.offset_x;
if(show_w >= r.width) show_w = r.width; if(show_w >= r.width) show_w = r.width;
@ -2579,7 +2575,7 @@ namespace nana
{ {
auto cell_bgcolor = m_cell.custom_format->bgcolor; auto cell_bgcolor = m_cell.custom_format->bgcolor;
if (essence_t::state_t::highlighted == state) if (essence_t::state_t::highlighted == state)
cell_bgcolor.blend(::nana::expr_color(0x99, 0xde, 0xfd), 0.8); //= graph->mix(cell_bgcolor, 0x99DEFD, 0.8); //deprecated cell_bgcolor.blend(::nana::expr_color(0x99, 0xde, 0xfd), 0.8);
graph->set_color(cell_bgcolor); graph->set_color(cell_bgcolor);
graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true); graph->rectangle(rectangle{ item_xpos, y, header.pixels, essence_->item_size }, true);
} }

View File

@ -209,7 +209,6 @@ namespace nana
graph.rectangle(r, false, clr); graph.rectangle(r, false, clr);
graph.set_color(clr.blend(colors::white, 0.5)); graph.set_color(clr.blend(colors::white, 0.5));
//unsigned color_x = graph.mix(color, 0xFFFFFF, 0.5); //deprecated
r.pare_off(2); r.pare_off(2);

View File

@ -1662,7 +1662,6 @@ namespace nana{ namespace widgets
auto fgcolor = API::fgcolor(window_); auto fgcolor = API::fgcolor(window_);
if (!API::window_enabled(window_)) if (!API::window_enabled(window_))
fgcolor.blend(bgcolor, 0.5); fgcolor.blend(bgcolor, 0.5);
//fgcolor = nana::paint::graphics::mix(bgcolor, fgcolor, 0.5); //deprecated
//Draw background //Draw background
if(attributes_.enable_background) if(attributes_.enable_background)
@ -2544,7 +2543,6 @@ namespace nana{ namespace widgets
{ {
if (selected) if (selected)
{ {
//color = 0xFFFFFF; //deprecated
graph_.set_text_color(colors::white); graph_.set_text_color(colors::white);
graph_.rectangle({ x, top, str_w, line_h_pixels }, true); graph_.rectangle({ x, top, str_w, line_h_pixels }, true);
} }

View File

@ -23,11 +23,6 @@ namespace nana
//draw border //draw border
::nana::expr_color lt(0x83, 0x90, 0x97), rb(0x9d,0xae,0xc2); ::nana::expr_color lt(0x83, 0x90, 0x97), rb(0x9d,0xae,0xc2);
graph.frame_rectangle(bi.r, lt, lt, rb, rb); graph.frame_rectangle(bi.r, lt, lt, rb, rb);
//const nana::color_t dark = 0x83909F; //deprecated
//const nana::color_t gray = 0x9DAEC2;
//graph.rectangle_line(bi.r,
// dark, dark, gray, gray); //deprecated
} }
virtual void adorn(window, graph_reference graph, const adorn_t& ad) virtual void adorn(window, graph_reference graph, const adorn_t& ad)
@ -38,15 +33,11 @@ namespace nana
::nana::expr_color clr_from(0x84, 0xc5, 0xff), clr_trans(0x0f, 0x41, 0xcd), clr_to(0x6e, 0x96, 0xff); ::nana::expr_color clr_from(0x84, 0xc5, 0xff), clr_trans(0x0f, 0x41, 0xcd), clr_to(0x6e, 0x96, 0xff);
if(ad.horizontal) if(ad.horizontal)
{ {
//graph.shadow_rectangle(ad.bound.x, ad.fixedpos, len, upperblock, 0x84C5FF, 0x0F41CD, true); //deprecated
//graph.shadow_rectangle(ad.bound.x, ad.fixedpos + upperblock, len, ad.block - upperblock, 0x0F41CD, 0x6E96FF, true);
graph.gradual_rectangle({ ad.bound.x, ad.fixedpos, len, upperblock }, clr_from, clr_trans, true); graph.gradual_rectangle({ ad.bound.x, ad.fixedpos, len, upperblock }, clr_from, clr_trans, true);
graph.gradual_rectangle({ ad.bound.x, ad.fixedpos + static_cast<int>(upperblock), len, ad.block - upperblock }, clr_trans, clr_to, true); graph.gradual_rectangle({ ad.bound.x, ad.fixedpos + static_cast<int>(upperblock), len, ad.block - upperblock }, clr_trans, clr_to, true);
} }
else else
{ {
//graph.shadow_rectangle(ad.fixedpos, ad.bound.x, upperblock, len, 0x84C5FF, 0x0F41CD, false); //deprecatd
//graph.shadow_rectangle(ad.fixedpos + upperblock, ad.bound.x, ad.block - upperblock, len, 0x0F41CD, 0x6E96FF, false);
graph.gradual_rectangle({ ad.fixedpos, ad.bound.x, upperblock, len }, clr_from, clr_trans, false); //deprecatd graph.gradual_rectangle({ ad.fixedpos, ad.bound.x, upperblock, len }, clr_from, clr_trans, false); //deprecatd
graph.gradual_rectangle({ ad.fixedpos + static_cast<int>(upperblock), ad.bound.x, ad.block - upperblock, len }, clr_trans, clr_to, false); graph.gradual_rectangle({ ad.fixedpos + static_cast<int>(upperblock), ad.bound.x, ad.block - upperblock, len }, clr_trans, clr_to, false);
} }

View File

@ -66,7 +66,6 @@ namespace nana
{ {
bgcolor = m.bgcolor; bgcolor = m.bgcolor;
blcolor = expr_color{ colors::black }.blend(m.bgcolor, 0.5); blcolor = expr_color{ colors::black }.blend(m.bgcolor, 0.5);
//dark_bgcolor = nana::paint::graphics::mix(m.bgcolor, 0, 0.9); //deprecated
dark_bgcolor = expr_color{ colors::black }.blend(m.bgcolor, 0.1); dark_bgcolor = expr_color{ colors::black }.blend(m.bgcolor, 0.1);
} }
@ -89,7 +88,6 @@ namespace nana
if (sta == item_renderer::highlight) if (sta == item_renderer::highlight)
beg.blend(colors::white, 0.5); beg.blend(colors::white, 0.5);
//graph.shadow_rectangle(r.x + 2, r.y + 2, r.width - 4, r.height - 2, beg, end, true); //deprecated
graph.gradual_rectangle(round_r.pare_off(2), beg, end, true); graph.gradual_rectangle(round_r.pare_off(2), beg, end, true);
} }

View File

@ -1356,14 +1356,12 @@ namespace nana
} }
private: private:
trigger::implement * impl_; trigger::implement * impl_;
//nana::color_t bgcolor_; //deprecated ::nana::expr_color bgcolor_;
//nana::color_t fgcolor_; ::nana::expr_color fgcolor_;
nana::expr_color bgcolor_; ::nana::point pos_;
nana::expr_color fgcolor_;
nana::point pos_;
const node_type * iterated_node_; const node_type * iterated_node_;
item_attribute_t node_attr_; item_attribute_t node_attr_;
nana::rectangle node_r_; ::nana::rectangle node_r_;
}; };
} }

View File

@ -141,28 +141,6 @@ namespace nana
_m_move(r); _m_move(r);
} }
/*
void widget::foreground(nana::color_t value) //deprecated
{
_m_fgcolor(expr_color(static_cast<colors>(value)));
}
nana::color_t widget::foreground() const
{
return _m_fgcolor().argb().value;
}
void widget::background(nana::color_t value)
{
_m_bgcolor(expr_color(static_cast<colors>(value)));
}
nana::color_t widget::background() const
{
return _m_bgcolor().argb().value;
}
*/
void widget::fgcolor(const nana::expr_color& col) void widget::fgcolor(const nana::expr_color& col)
{ {
_m_fgcolor(col); _m_fgcolor(col);

View File

@ -6,16 +6,6 @@ namespace nana
{ {
namespace paint namespace paint
{ {
namespace image_process
{
//There are definitions of pure virtual destructor of image processor interfaces
stretch_interface::~stretch_interface(){}
alpha_blend_interface::~alpha_blend_interface(){}
blend_interface::~blend_interface(){}
line_interface::~line_interface(){}
blur_interface::~blur_interface(){}
}
namespace detail namespace detail
{ {
//class image_process_provider //class image_process_provider

View File

@ -48,9 +48,10 @@ namespace detail
} }
unsigned char * alloc_fade_table(double fade_rate) std::unique_ptr<unsigned char[]> alloc_fade_table(double fade_rate)
{ {
unsigned char* tablebuf = new unsigned char[0x100 * 2]; std::unique_ptr<unsigned char[]> ptr(new unsigned char[0x100 * 2]);
unsigned char* tablebuf = ptr.get();
unsigned char* d_table = tablebuf; unsigned char* d_table = tablebuf;
unsigned char* s_table = d_table + 0x100; unsigned char* s_table = d_table + 0x100;
@ -76,37 +77,9 @@ namespace detail
d_table += 4; d_table += 4;
s_table += 4; s_table += 4;
} }
return tablebuf; return ptr;
} }
void free_fade_table(const unsigned char* table)
{
delete [] table;
}
/*
nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, double fade_rate) //deprecated
{
pixel_color_t ret;
double lrate = 1.0 - fade_rate;
ret.element.red = static_cast<unsigned char>(bgcolor.element.red * fade_rate + fgcolor.element.red * lrate);
ret.element.green = static_cast<unsigned char>(bgcolor.element.green * fade_rate + fgcolor.element.green * lrate);
ret.element.blue = static_cast<unsigned char>(bgcolor.element.blue * fade_rate + fgcolor.element.blue * lrate);
ret.element.alpha_channel = 0;
return ret;
}
nana::pixel_color_t fade_color(nana::pixel_color_t bgcolor, nana::pixel_color_t fgcolor, const unsigned char* const fade_table) //deprecated
{
const unsigned char * const s_fade_table = fade_table + 0x100;
bgcolor.element.red = fade_table[bgcolor.element.red] + s_fade_table[fgcolor.element.red];
bgcolor.element.green = fade_table[bgcolor.element.green] + s_fade_table[fgcolor.element.green];
bgcolor.element.blue = fade_table[bgcolor.element.blue] + s_fade_table[fgcolor.element.blue];
return bgcolor;
}
*/
nana::pixel_color_t fade_color_intermedia(nana::pixel_color_t fgcolor, const unsigned char* fade_table) nana::pixel_color_t fade_color_intermedia(nana::pixel_color_t fgcolor, const unsigned char* fade_table)
{ {
fade_table += 0x100; fade_table += 0x100;
@ -124,7 +97,7 @@ namespace detail
return bgcolor; return bgcolor;
} }
void blend(drawable_type dw, const nana::rectangle& area, unsigned color, double fade_rate) void blend(drawable_type dw, const nana::rectangle& area, pixel_color_t color, double fade_rate)
{ {
if(fade_rate <= 0) return; if(fade_rate <= 0) return;
if(fade_rate > 1) fade_rate = 1; if(fade_rate > 1) fade_rate = 1;
@ -133,9 +106,9 @@ namespace detail
if(false == nana::overlap(drawable_size(dw), area, r)) if(false == nana::overlap(drawable_size(dw), area, r))
return; return;
unsigned red = static_cast<unsigned>((color & 0xFF0000) * fade_rate); unsigned red = static_cast<unsigned>((color.value & 0xFF0000) * fade_rate);
unsigned green = static_cast<unsigned>((color & 0xFF00) * fade_rate); unsigned green = static_cast<unsigned>((color.value & 0xFF00) * fade_rate);
unsigned blue = static_cast<unsigned>((color & 0xFF) * fade_rate); unsigned blue = static_cast<unsigned>((color.value & 0xFF) * fade_rate);
double lrate = 1 - fade_rate; double lrate = 1 - fade_rate;
pixel_buffer pixbuf(dw, r.y, r.height); pixel_buffer pixbuf(dw, r.y, r.height);

View File

@ -1,7 +1,7 @@
/* /*
* Paint Graphics Implementation * Paint Graphics Implementation
* Nana C++ Library(http://www.nanapro.org) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
* *
* Distributed under the Boost Software License, Version 1.0. * Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at * (See accompanying file LICENSE_1_0.txt or copy at
@ -319,8 +319,8 @@ namespace paint
if(dw) if(dw)
{ {
//dw->fgcolor(0); //dw->fgcolor(0);
dw->set_color(0x0); dw->set_color(colors::black);
dw->set_text_color(0x0); dw->set_text_color(colors::black);
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
dw->bytes_per_line = width * sizeof(pixel_argb_t); dw->bytes_per_line = width * sizeof(pixel_argb_t);
#else #else
@ -522,305 +522,7 @@ namespace paint
} }
return false; return false;
} }
/*
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;
std::vector<unicode_bidi::entity> reordered;
bidi.linestr(str, len, reordered);
for(auto & i : reordered)
{
string(x, y, col, i.begin, i.end - i.begin);
x += static_cast<int>(text_extent_size(i.begin, i.end - i.begin).width);
}
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);
}
void graphics::string(int x, int y, color_t color, const nana::string& str)
{
string(x, y, color, str.c_str(), str.size());
}
void graphics::string(int x, int y, color_t color, const nana::char_t* str, std::size_t len)
{
if(handle_ && str && len)
{
handle_->set_text_color(color);
const nana::char_t * end = str + len;
const nana::char_t * i = std::find(str, end, '\t');
if(i != end)
{
std::size_t tab_pixels = handle_->string.tab_length * handle_->string.tab_pixels;
while(true)
{
len = i - str;
if(len)
{
//Render a part that does not contains a tab
detail::draw_string(handle_, point{ x, y }, str, len);
x += detail::raw_text_extent_size(handle_, str, len).width;
}
str = i;
while(str != end && (*str == '\t'))
++str;
if(str != end)
{
//Now i_tab is not a tab, but a non-tab character following the previous tabs
x += static_cast<int>(tab_pixels * (str - i));
i = std::find(str, end, '\t');
}
else
break;
}
}
else
detail::draw_string(handle_, point{ x, y }, str, len);
if(changed_ == false) changed_ = true;
}
}
void graphics::string(int x, int y, color_t c, const nana::char_t* str)
{
string(x, y, c, str, nana::strlen(str));
}
*/
/*
void graphics::set_pixel(int x, int y, color_t color)
{
if(handle_)
{
#if defined(NANA_WINDOWS)
::SetPixel(handle_->context, x, y, NANA_RGB(color));
#elif defined(NANA_X11)
Display* disp = nana::detail::platform_spec::instance().open_display();
handle_->fgcolor(color);
::XDrawPoint(disp, handle_->pixmap, handle_->context,x, y);
#endif
if(changed_ == false) changed_ = true;
}
}
void graphics::rectangle(int x, int y, unsigned width, unsigned height, color_t color, bool solid)
{
if((static_cast<int>(width) > -x) && (static_cast<int>(height) > -y) && width && height && handle_)
{
#if defined(NANA_WINDOWS)
::RECT r = {x, y, static_cast<long>(x + width), static_cast<long>(y + height)};
handle_->brush.set(handle_->context, handle_->brush.Solid, color);
(solid ? ::FillRect : ::FrameRect)(handle_->context, &r, handle_->brush.handle);
#elif defined(NANA_X11)
Display* disp = nana::detail::platform_spec::instance().open_display();
handle_->fgcolor(color);
if(solid)
::XFillRectangle(disp, handle_->pixmap, handle_->context, x, y, width, height);
else
::XDrawRectangle(disp, handle_->pixmap, handle_->context, x, y, width - 1, height - 1);
#endif
if(changed_ == false) changed_ = true;
}
}
void graphics::rectangle(nana::color_t color, bool solid)
{
rectangle(0, 0, size_.width, size_.height, color, solid);
}
void graphics::rectangle(const nana::rectangle & r, color_t color, bool solid)
{
rectangle(r.x, r.y, r.width, r.height, color, solid);
}
void graphics::rectangle_line(const nana::rectangle& r, color_t color_left, color_t color_top, color_t color_right, color_t color_bottom)
{
int right = r.x + r.width - 1;
int bottom = r.y + r.height -1;
line_begin(r.x, r.y);
line_to(right, r.y, color_top);
line_to(right, bottom, color_right);
line_to(r.x, bottom, color_bottom);
line_to(r.x, r.y, color_left);
}
void graphics::round_rectangle(int x, int y, unsigned width, unsigned height, unsigned radius_x, unsigned radius_y, color_t color, bool solid, color_t color_if_solid)
{
if(handle_)
{
#if defined(NANA_WINDOWS)
handle_->pen.set(handle_->context, PS_SOLID, 1, color);
if(solid)
{
handle_->brush.set(handle_->context, handle_->brush.Solid, color_if_solid);
::RoundRect(handle_->context, x, y, x + static_cast<int>(width), y + static_cast<int>(height), static_cast<int>(radius_x * 2), static_cast<int>(radius_y * 2));
}
else
{
handle_->brush.set(handle_->context, handle_->brush.Solid, color);
handle_->round_region.set(nana::rectangle(x, y, width, height), 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 == color_if_solid))
{
rectangle(x, y, width, height, color, true);
}
else
{
rectangle(x, y, width, height, color, false);
if(solid)
rectangle(x + 1, y + 1, width - 2, height - 2, color_if_solid, true);
}
#endif
}
}
void graphics::round_rectangle(const nana::rectangle& r, unsigned radius_x, unsigned radius_y, color_t color, bool solid, color_t color_if_solid)
{
round_rectangle(r.x, r.y, r.width, r.height, radius_x, radius_y, color, solid, color_if_solid);
}
void graphics::shadow_rectangle(const nana::rectangle& r, color_t beg_color, color_t end_color, bool vertical)
{
#if defined(NANA_WINDOWS)
if(pxbuf_.open(handle_))
{
pxbuf_.shadow_rectangle(r, beg_color, end_color, 0.0, vertical);
pxbuf_.paste(handle_, 0, 0);
}
#elif defined(NANA_X11)
shadow_rectangle(r.x, r.y, r.width, r.height, beg_color, end_color, vertical);
#endif
}
void graphics::shadow_rectangle(int x, int y, unsigned width, unsigned height, color_t color_begin, color_t color_end, bool vertical)
{
#if defined(NANA_WINDOWS)
if(pxbuf_.open(handle_))
{
pxbuf_.shadow_rectangle(nana::rectangle(x, y, width, height), color_begin, color_end, 0.0, vertical);
pxbuf_.paste(handle_, 0, 0);
}
#elif defined(NANA_X11)
if(0 == handle_) return;
int deltapx = int(vertical ? height : width);
double r, g, b;
const double delta_r = int(((color_end & 0xFF0000) >> 16) - (r = ((color_begin & 0xFF0000) >> 16))) / double(deltapx);
const double delta_g = int(((color_end & 0xFF00) >> 8) - (g = ((color_begin & 0xFF00) >> 8))) / double(deltapx);
const double delta_b = int((color_end & 0xFF) - (b = (color_begin & 0xFF))) / double(deltapx);
unsigned last_color = (int(r) << 16) | (int(g) << 8) | int(b);
Display * disp = nana::detail::platform_spec::instance().open_display();
handle_->fgcolor(last_color);
const int endpos = deltapx + (vertical ? y : x);
if(endpos > 0)
{
if(vertical)
{
int x1 = x, x2 = x + static_cast<int>(width);
for(; y < endpos; ++y)
{
::XDrawLine(disp, handle_->pixmap, handle_->context, x1, y, x2, y);
unsigned new_color = (int(r += delta_r) << 16) | (int(g += delta_g) << 8) | int(b += delta_b);
if(new_color != last_color)
{
last_color = new_color;
handle_->fgcolor(last_color);
}
}
}
else
{
int y1 = y, y2 = y + static_cast<int>(height);
for(; x < endpos; ++x)
{
::XDrawLine(disp, handle_->pixmap, handle_->context, x, y1, x, y2);
unsigned new_color = (int(r += delta_r) << 16) | (int(g += delta_g) << 8) | int(b += delta_b);
if(new_color != last_color)
{
last_color = new_color;
handle_->fgcolor(last_color);
}
}
}
}
#endif
if(changed_ == false) changed_ = true;
}
void graphics::line(int x1, int y1, int x2, int y2, color_t color)
{
if(!handle_) return;
handle_->set_color(color);
#if defined(NANA_WINDOWS)
if(x1 != x2 || y1 != y2)
{
handle_->update_pen();
//handle_->pen.set(handle_->context, PS_SOLID, 1, color); //deprecated
::MoveToEx(handle_->context, x1, y1, 0);
::LineTo(handle_->context, x2, y2);
}
::SetPixel(handle_->context, x2, y2, NANA_RGB(color));
#elif defined(NANA_X11)
Display* disp = nana::detail::platform_spec::instance().open_display();
//handle_->fgcolor(color); //deprecated
handle_->update_color();
::XDrawLine(disp, handle_->pixmap, handle_->context, x1, y1, x2, y2);
#endif
if(changed_ == false) changed_ = true;
}
void graphics::line(const point& beg, const point& end, color_t color)
{
line(beg.x, beg.y, end.x, end.y, color);
}
void graphics::lines(const point* points, std::size_t n_of_points, color_t color)
{
if(!handle_ || nullptr == points || 0 == n_of_points) return;
#if defined(NANA_WINDOWS)
handle_->pen.set(handle_->context, PS_SOLID, 1, color);
::MoveToEx(handle_->context, points->x, points->y, nullptr);
const point * end = points + n_of_points;
for(const point * i = points + 1; i != end; ++i)
::LineTo(handle_->context, i->x, i->y);
if(*points != *(end - 1))
::SetPixel(handle_->context, (end-1)->x, (end-1)->y, NANA_RGB(color));
#elif defined(NANA_X11)
Display* disp = nana::detail::platform_spec::instance().open_display();
handle_->fgcolor(color);
XPoint * const x11points = new XPoint[n_of_points];
XPoint * end = x11points + n_of_points;
for(XPoint * i = x11points; i != end; ++i)
{
i->x = points->x;
i->y = points->y;
++points;
}
::XDrawLines(disp, handle_->pixmap, handle_->context, x11points, static_cast<int>(n_of_points), CoordModePrevious);
delete [] x11points;
#endif
if(changed_ == false) changed_ = true;
}
*/
void graphics::line_begin(int x, int y) void graphics::line_begin(int x, int y)
{ {
if(!handle_) return; if(!handle_) return;
@ -832,25 +534,6 @@ namespace paint
handle_->line_begin_pos.y = y; handle_->line_begin_pos.y = y;
#endif #endif
} }
/*
void graphics::line_to(int x, int y, color_t color)
{
if(!handle_) return;
#if defined(NANA_WINDOWS)
handle_->pen.set(handle_->context, PS_SOLID, 1, color);
::LineTo(handle_->context, x, y);
#elif defined(NANA_X11)
Display* disp = nana::detail::platform_spec::instance().open_display();
handle_->fgcolor(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::bitblt(int x, int y, const graphics& src) void graphics::bitblt(int x, int y, const graphics& src)
{ {
@ -937,15 +620,6 @@ namespace paint
} }
} }
void graphics::blend(const nana::rectangle& r, nana::color_t color, double fade_rate)
{
if(handle_)
{
nana::paint::detail::blend(handle_, r, color, fade_rate);
if(changed_ == false) changed_ = true;
}
}
void graphics::blur(const nana::rectangle& r, std::size_t radius) void graphics::blur(const nana::rectangle& r, std::size_t radius)
{ {
if(handle_) if(handle_)
@ -1182,32 +856,17 @@ namespace paint
#endif #endif
} }
} }
/*
color_t graphics::mix(color_t a, color_t b, double fade_rate) //deprecated
{
pixel_argb_t pa, pb, ret;
ret.value = 0;
pa.value = a;
pb.value = b;
ret.element.red = static_cast<unsigned char>(pa.element.red * fade_rate + pb.element.red * (1 - fade_rate));
ret.element.green = static_cast<unsigned char>(pa.element.green * fade_rate + pb.element.green * (1 - fade_rate));
ret.element.blue = static_cast<unsigned char>(pa.element.blue * fade_rate + pb.element.blue * (1 - fade_rate));
return ret.value;
}
*/
void graphics::set_color(const ::nana::expr_color& col) void graphics::set_color(const ::nana::expr_color& col)
{ {
if (handle_) if (handle_)
handle_->set_color(col.argb().value); handle_->set_color(col);
} }
void graphics::set_text_color(const ::nana::expr_color& col) void graphics::set_text_color(const ::nana::expr_color& col)
{ {
if (handle_) if (handle_)
handle_->set_text_color(col.argb().value); handle_->set_text_color(col);
} }
unsigned graphics::bidi_string(const nana::point& pos, const char_t * str, std::size_t len) unsigned graphics::bidi_string(const nana::point& pos, const char_t * str, std::size_t len)
@ -1228,7 +887,7 @@ namespace paint
{ {
if (handle_) if (handle_)
{ {
nana::paint::detail::blend(handle_, r, clr.px_color().value, fade_rate); nana::paint::detail::blend(handle_, r, clr.px_color(), fade_rate);
if (changed_ == false) changed_ = true; if (changed_ == false) changed_ = true;
} }
} }
@ -1237,7 +896,7 @@ namespace paint
{ {
if (handle_) if (handle_)
{ {
handle_->set_color(clr.px_color().value); handle_->set_color(clr);
set_pixel(x, y); set_pixel(x, y);
} }
} }
@ -1342,7 +1001,7 @@ namespace paint
void graphics::line_to(const point& pos, const expr_color& clr) void graphics::line_to(const point& pos, const expr_color& clr)
{ {
if (!handle_) return; if (!handle_) return;
handle_->set_color(clr.px_color().value); handle_->set_color(clr);
line_to(pos); line_to(pos);
} }
@ -1474,7 +1133,7 @@ namespace paint
if (handle_) if (handle_)
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
handle_->set_color(clr.px_color().value); handle_->set_color(clr);
if (solid) if (solid)
{ {
handle_->update_pen(); handle_->update_pen();

View File

@ -776,7 +776,7 @@ namespace nana{ namespace paint
} }
} }
void pixel_buffer::line(const nana::point &pos_beg, const nana::point &pos_end, nana::color_t color, double fade_rate) void pixel_buffer::line(const point &pos_beg, const point &pos_end, const ::nana::expr_color& clr, double fade_rate)
{ {
pixel_buffer_storage * sp = storage_.get(); pixel_buffer_storage * sp = storage_.get();
if(nullptr == sp) return; if(nullptr == sp) return;
@ -785,21 +785,25 @@ namespace nana{ namespace paint
//are always in the area of rectangle, good_pos_beg is left point, good_pos_end is right. //are always in the area of rectangle, good_pos_beg is left point, good_pos_end is right.
nana::point good_pos_beg, good_pos_end; nana::point good_pos_beg, good_pos_end;
if(intersection(nana::rectangle(sp->pixel_size), pos_beg, pos_end, good_pos_beg, good_pos_end)) if(intersection(nana::rectangle(sp->pixel_size), pos_beg, pos_end, good_pos_beg, good_pos_end))
(*(sp->img_pro.line))->process(*this, good_pos_beg, good_pos_end, color, fade_rate); (*(sp->img_pro.line))->process(*this, good_pos_beg, good_pos_end, clr, fade_rate);
} }
void pixel_buffer::rectangle(const nana::rectangle &r, nana::color_t col, double fade_rate, bool solid) void pixel_buffer::rectangle(const nana::rectangle &r, const ::nana::expr_color& clr, double fade_rate, bool solid)
{ {
pixel_buffer_storage * sp = storage_.get(); pixel_buffer_storage * sp = storage_.get();
if((nullptr == sp) || (fade_rate == 1.0)) return; if((nullptr == sp) || (fade_rate == 1.0)) return;
bool fade = (fade_rate != 0.0); bool fade = (fade_rate != 0.0);
unsigned char * fade_table = nullptr; unsigned char * fade_table = nullptr;
std::unique_ptr<unsigned char[]> autoptr;
auto rgb_color = clr.px_color().value;
nana::pixel_argb_t rgb_imd; nana::pixel_argb_t rgb_imd;
if(fade) if(fade)
{ {
fade_table = detail::alloc_fade_table(1 - fade_rate); autoptr = detail::alloc_fade_table(1 - fade_rate);
rgb_imd.value = col; fade_table = autoptr.get();
rgb_imd.value = rgb_color;
rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table); rgb_imd = detail::fade_color_intermedia(rgb_imd, fade_table);
} }
@ -830,7 +834,7 @@ namespace nana{ namespace paint
for (int top = ybeg; top < yend; ++top) for (int top = ybeg; top < yend; ++top)
{ {
for (auto i = lineptr; i != end; ++i) for (auto i = lineptr; i != end; ++i)
i->value = col; i->value = rgb_color;
lineptr += sp->pixel_size.width; lineptr += sp->pixel_size.width;
end = lineptr + (xend - xbeg); end = lineptr + (xend - xbeg);
@ -857,8 +861,8 @@ namespace nana{ namespace paint
{ {
for(;i != end; ++i, ++i_other) for(;i != end; ++i, ++i_other)
{ {
i->value = col; i->value = rgb_color;
i_other->value = col; i_other->value = rgb_color;
} }
} }
} }
@ -877,7 +881,7 @@ namespace nana{ namespace paint
else else
{ {
for(;i != end; ++i) for(;i != end; ++i)
i->value = col; i->value = rgb_color;
} }
} }
@ -895,7 +899,7 @@ namespace nana{ namespace paint
else else
{ {
for(;i != end; ++i) for(;i != end; ++i)
i->value = col; i->value = rgb_color;
} }
} }
} }
@ -924,8 +928,8 @@ namespace nana{ namespace paint
{ {
while(true) while(true)
{ {
i->value = col; i->value = rgb_color;
i_other->value = col; i_other->value = rgb_color;
if(i == end) if(i == end)
break; break;
@ -955,7 +959,7 @@ namespace nana{ namespace paint
{ {
while(true) while(true)
{ {
i->value = col; i->value = rgb_color;
if(i == end) break; if(i == end) break;
i += sp->pixel_size.width; i += sp->pixel_size.width;
@ -981,80 +985,13 @@ namespace nana{ namespace paint
{ {
while(true) while(true)
{ {
i->value = col; i->value = rgb_color;
if(i == end) break; if(i == end) break;
i += sp->pixel_size.width; i += sp->pixel_size.width;
} }
} }
} }
} }
detail::free_fade_table(fade_table);
}
void pixel_buffer::shadow_rectangle(const nana::rectangle& draw_rct, nana::color_t beg, nana::color_t end, double fade_rate, bool vertical)
{
pixel_buffer_storage * sp = storage_.get();
if(nullptr == sp) return;
nana::rectangle rct;
if(false == overlap(nana::rectangle(sp->pixel_size), draw_rct, rct))
return;
int deltapx = int(vertical ? rct.height : rct.width);
if(sp && deltapx)
{
nana::color_t r, g, b;
const int delta_r = (int(end & 0xFF0000) - int(r = (beg & 0xFF0000))) / deltapx;
const int delta_g = (int((end & 0xFF00) << 8) - int(g = ((beg & 0xFF00) << 8))) / deltapx;
const int delta_b = (int((end & 0xFF) << 16 ) - int(b = ((beg & 0xFF)<< 16))) / deltapx;
auto pxbuf = sp->raw_pixel_buffer + rct.x + rct.y * sp->pixel_size.width;
if(vertical)
{
if(deltapx + rct.y > 0)
{
unsigned align_4 = (rct.width & ~3);
unsigned align_reset = rct.width & 3;
while(deltapx--)
{
nana::pixel_argb_t px;
px.value = ((r += delta_r) & 0xFF0000) | (((g += delta_g) & 0xFF0000) >> 8) | (((b += delta_b) & 0xFF0000) >> 16);
auto dpx = pxbuf;
for(auto dpx_end = pxbuf + align_4; dpx != dpx_end; dpx += 4)
{
*dpx = px;
dpx[1] = px;
dpx[2] = px;
dpx[3] = px;
}
for(auto dpx_end = dpx + align_reset; dpx != dpx_end; ++dpx)
*dpx = px;
pxbuf += sp->pixel_size.width;
}
}
}
else
{
if(deltapx + rct.x > 0)
{
auto pxbuf_end = pxbuf + rct.width;
for(; pxbuf != pxbuf_end; ++pxbuf)
{
nana::pixel_argb_t px;
px.value = ((r += delta_r) & 0xFF0000) | (((g += delta_g) & 0xFF0000) >> 8) | (((b += delta_b) & 0xFF0000) >> 16);
auto dpx_end = pxbuf + rct.height * sp->pixel_size.width;
for(auto dpx = pxbuf; dpx != dpx_end; dpx += sp->pixel_size.width)
*dpx = px;
}
}
}
}
} }
void pixel_buffer::gradual_rectangle(const ::nana::rectangle& draw_rct, const ::nana::expr_color& from, const ::nana::expr_color& to, double fade_rate, bool vertical) void pixel_buffer::gradual_rectangle(const ::nana::rectangle& draw_rct, const ::nana::expr_color& from, const ::nana::expr_color& to, double fade_rate, bool vertical)
@ -1071,7 +1008,7 @@ namespace nana{ namespace paint
{ {
auto beg = from.argb().value; auto beg = from.argb().value;
auto end = to.argb().value; auto end = to.argb().value;
nana::color_t r, g, b; unsigned r, g, b;
const int delta_r = (int(end & 0xFF0000) - int(r = (beg & 0xFF0000))) / deltapx; const int delta_r = (int(end & 0xFF0000) - int(r = (beg & 0xFF0000))) / deltapx;
const int delta_g = (int((end & 0xFF00) << 8) - int(g = ((beg & 0xFF00) << 8))) / deltapx; const int delta_g = (int((end & 0xFF00) << 8) - int(g = ((beg & 0xFF00) << 8))) / deltapx;
const int delta_b = (int((end & 0xFF) << 16) - int(b = ((beg & 0xFF) << 16))) / deltapx; const int delta_b = (int((end & 0xFF) << 16) - int(b = ((beg & 0xFF) << 16))) / deltapx;

View File

@ -118,7 +118,6 @@ namespace nana
{ {
graphics & graph; graphics & graph;
int x, endpos; int x, endpos;
//nana::color_t color; //deprecated
::nana::expr_color fgcolor; ::nana::expr_color fgcolor;
unsigned omitted_pixels; unsigned omitted_pixels;
nana::unicode_bidi bidi; nana::unicode_bidi bidi;
@ -452,7 +451,8 @@ namespace nana
std::size_t len = i.end - i.begin; std::size_t len = i.end - i.begin;
if(len > 1) if(len > 1)
{ {
unsigned * pxbuf = new unsigned[len]; std::unique_ptr<unsigned[]> scope_res(new unsigned[len]);
auto pxbuf = scope_res.get();
//Find the char that should be splitted //Find the char that should be splitted
graph.glyph_pixels(i.begin, len, pxbuf); graph.glyph_pixels(i.begin, len, pxbuf);
std::size_t idx_head = 0, idx_splitted; std::size_t idx_head = 0, idx_splitted;
@ -520,8 +520,6 @@ namespace nana
} }
} }
}while(idx_head < len); }while(idx_head < len);
delete [] pxbuf;
} }
else else
xpos = x + static_cast<int>(i_ts_keeper->width); xpos = x + static_cast<int>(i_ts_keeper->width);
@ -555,39 +553,6 @@ namespace nana
: graph_(graph), text_align_(ta) : graph_(graph), text_align_(ta)
{} {}
/*
void text_renderer::render(int x, int y, color_t col, const char_t * str, std::size_t len)
{
if(graph_)
{
helper::draw_string ds(graph_.handle(), x, static_cast<int>(graph_.width()), text_align_);
ds.dw->fgcolor(col);
helper::for_each_line(str, len, y, ds);
}
}
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_)
{
helper::draw_string_omitted dso(graph_, x, x + static_cast<int>(restricted_pixels), col, omitted);
graph_.handle()->fgcolor(col);
helper::for_each_line(str, len, y, dso);
}
}
*/
/*
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_)
{
helper::draw_string_auto_changing_lines dsacl(graph_, x, x + static_cast<int>(restricted_pixels), text_align_);
graph_.handle()->fgcolor(col);
helper::for_each_line(str, len, y, dsacl);
}
}
*/
nana::size text_renderer::extent_size(int x, int y, const 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; nana::size extents;
@ -628,7 +593,5 @@ namespace nana
} }
} }
//end class text_renderer //end class text_renderer
} }
} }