Added named colors from 4.3 Extended color keywords

::nana::colors::<named colors>
This commit is contained in:
cnjinhao 2014-12-29 06:20:18 +08:00
parent ecbf71b7e2
commit 052d34a746
9 changed files with 175 additions and 39 deletions

View File

@ -130,13 +130,154 @@ namespace nana
//4.3. Extended color keywords
enum class colors
{
alice_blue = 0xf0f8ff,
antique_white = 0xfaebd7,
aqua = 0xFFFF,
aquamarine = 0x7fffd4,
azure = 0xf0ffff,
beige = 0xf5f5dc,
bisque = 0xffe4ce,
black = 0x0,
blanched_almond = 0xffebcd,
blue = 0x0000FF,
blue_violet = 0x8a2be2,
brown = 0xa52a2a,
burly_wood = 0xdeb887,
cadet_blue = 0x5f9ea0,
chartreuse = 0x7fff00,
chocolate = 0xd2691e,
coral = 0xff7f50,
cornflower_blue = 0x6495ed,
cornsilk = 0xfff8dc,
crimson = 0xdc143c,
cyan = 0xffff,
dark_blue = 0x8b,
dark_cyan = 0x8b8b,
dark_goldenrod = 0xb8860b,
dark_gray = 0xa9a9a9,
dark_green = 0x6400,
dark_grey = dark_gray,
dark_khaki = 0xbdb76b,
dark_magenta = 0x8b008b,
dark_olive_green = 0x556b2f,
dark_orange = 0xff8c00,
dark_orchid = 0x9932cc,
dark_red = 0x8b0000,
dark_salmon = 0xe9976a,
dark_sea_green = 0x8fbc8f,
dark_slate_blue = 0x483d8b,
dark_slate_gray = 0x2f4f4f,
dark_slate_grey = 0x2f4f4f,
dark_turquoise = 0xced1,
dark_violet = 0x9400d3,
deep_pink = 0xff1493,
deep_sky_blue = 0xbfff,
dim_gray = 0x696969,
dim_grey = dim_gray,
dodger_blue = 0x1e90ff,
firebrick = 0xb22222,
floral_white = 0xfffaf0,
forest_green = 0x228b22,
fuchsia = 0xFF00FF,
gainsboro = 0xdcdcdc,
ghost_white = 0xf8f8ff,
gold = 0xffd700,
goldenrod = 0xdaa520,
gray = 0x808080,
green = 0x008000,
green_yellow = 0xadff2f,
grey = gray,
honeydew = 0xf0fff0,
hot_pink = 0xff69b4,
indian_red = 0xcd5c5c,
indigo = 0x4b0082,
ivory = 0xfffff0,
khaki = 0xf0e68c,
lavendar = 0xe6e6fa,
lavender_blush = 0xfff0f5,
lawn_green = 0x7cfc00,
lemon_chiffon = 0xfffacd,
light_blue = 0xadd8e6,
light_coral = 0xf08080,
light_cyan = 0xe0ffff,
light_goldenrod_yellow = 0xfafad2,
light_gray = 0xd3d3d3,
light_green = 0x90ee90,
light_grey = light_gray,
light_pink = 0xffb6c1,
light_salmon = 0xffa07a,
light_sea_green = 0x20b2aa,
light_sky_blue = 0x87cefa,
light_slate_gray = 0x778899,
light_slate_grey = light_slate_gray,
light_steel_blue = 0xb0c4de,
light_yellow = 0xffffe0,
lime = 0x00FF00,
lime_green = 0x32cd32,
linen = 0xfaf0e6,
magenta = 0xff00ff,
maroon = 0x800000,
medium_aquamarine = 0x66cdaa,
medium_blue = 0xcd,
medium_orchid = 0xba55d3,
medium_purple = 0x9370db,
medium_sea_green = 0x3cb371,
medium_slate_blue = 0x7b68ee,
medium_spring_green = 0xfa9a,
medium_turquoise = 0x48d1cc,
medium_violet_red = 0xc71585,
midnight_blue = 0x191970,
mint_cream = 0xf5fffa,
gray = 0x808080,
green = 0x00FF00,
misty_rose = 0xffe4e1,
moccasin = 0xffe4b5,
navajo_white = 0xffdead,
navy = 0x000080,
old_lace = 0xfdf5e6,
olive = 0x808000,
olive_drab = 0x6b8e23,
orange = 0xffa500,
orange_red = 0xff4500,
orchid = 0xda70d6,
pale_goldenrod = 0xeee8aa,
pale_green = 0x98fb98,
pale_turquoise = 0xafeeee,
pale_violet_red = 0xdb7093,
papaya_whip = 0xffefd5,
peach_puff = 0xffdab9,
peru = 0xcd853f,
pink = 0xffc0cb,
plum = 0xdda0dd,
powder_blue = 0xb0e0e6,
purple = 0x800080,
red = 0xFF0000,
rosy_brown = 0xbc8f8f,
royal_blue = 0x4169e1,
saddle_brown = 0x8b4513,
salmon = 0xfa8072,
sandy_brown = 0xf4a460,
sea_green = 0x2e8b57,
sea_shell = 0xfff5ee,
sienna = 0xa0522d,
silver = 0xc0c0c0,
sky_blue = 0x87ceeb,
slate_blue = 0x6a5acd,
slate_gray = 0x708090,
slate_grey = 0x708090,
snow = 0xfffafa,
spring_green = 0xff7f,
steel_blue = 0x4682b4,
tan = 0xd2b48c,
teal = 0x008080,
thistle = 0xd8bfd8,
tomato = 0xff6347,
turquoise = 0x40e0d0,
violet = 0xee82ee,
wheat = 0xf5deb3,
white = 0xFFFFFF,
white_smoke = 0xf5f5f5,
yellow = 0xFFFF00,
yellow_green = 0x9acd32,
//temporary defintions, these will be replaced by color schema
button_face_shadow_start = 0xF5F4F2,

View File

@ -174,13 +174,6 @@ namespace detail
std::shared_ptr<general_events> events_ptr;
general_events* attached_events;
}together;
struct
{
color fgcolor;
color bgcolor;
color activated;
}colors;
widget_colors* expr_colors{ nullptr };

View File

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

View File

@ -202,6 +202,7 @@ namespace API
void refresh_window_tree(window); ///< Refreshs the specified window and all its children windows, then display it immediately
void update_window(window); ///< Copies the off-screen buffer to the screen for immediate display.
void window_caption(window, const std::string& title_utf8);
void window_caption(window, const nana::string& title);
nana::string window_caption(window);

View File

@ -30,7 +30,7 @@ namespace nana
{
typedef void(*dummy_bool_type)(widget* (*)(const widget&));
public:
virtual ~widget();
virtual ~widget() = default;
virtual window handle() const = 0; ///< Returns the handle of window, returns 0 if window is not created.
bool empty() const; ///< Determines whether the manipulator is handling a window.
void close();
@ -38,6 +38,7 @@ namespace nana
window parent() const;
nana::string caption() const;
void caption(std::string utf8);
void caption(nana::string);
template<typename ...Args>

View File

@ -130,8 +130,8 @@ namespace nana
pos.y += effective_range_.y;
}
if( (pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.x + static_cast<int>(rect.width)) ||
(pos.y + static_cast<int>(size.height) <= rect.y) || (pos.y >= rect.y + static_cast<int>(rect.height))
if( (pos.x + static_cast<int>(size.width) <= rect.x) || (pos.x >= rect.right()) ||
(pos.y + static_cast<int>(size.height) <= rect.y) || (pos.y >= rect.bottom())
)
{//Out of Range without overlap
if(false == out_of_range_)
@ -149,7 +149,7 @@ namespace nana
size.width -= (rect.x - pos.x);
pos.x = rect.x;
}
else if(pos.x + size.width > rect.right())
else if(pos.x + static_cast<int>(size.width) > rect.right())
{
size.width -= pos.x + size.width - rect.right();
}
@ -159,7 +159,7 @@ namespace nana
size.width -= (rect.y - pos.y);
pos.y = rect.y;
}
else if(pos.y + size.height > rect.bottom())
else if(pos.y + static_cast<int>(size.height) > rect.bottom())
size.height -= pos.y + size.height - rect.bottom();
if(out_of_range_)
@ -297,11 +297,8 @@ namespace nana
pos_owner = pos_root = r;
dimension = r;
if(parent)
{
pos_root.x += parent->pos_root.x;
pos_root.y += parent->pos_root.y;
}
if (parent)
pos_root += parent->pos_root;
}
void basic_window::_m_initialize(basic_window* agrparent)
@ -345,10 +342,6 @@ namespace nana
visible = false;
colors.fgcolor = ::nana::colors::black;
colors.bgcolor = ::nana::colors::button_face;
colors.activated.from_rgb(0x60, 0xc8, 0xfd);
effect.edge_nimbus = effects::edge_nimbus::none;
effect.bground = nullptr;
effect.bground_fade_rate = 0;

View File

@ -173,7 +173,7 @@ namespace API
if(restrict::window_manager.available(iwd))
{
iwd->drawer.graphics.make(iwd->dimension.width, iwd->dimension.height);
iwd->drawer.graphics.rectangle(true, iwd->colors.bgcolor);
iwd->drawer.graphics.rectangle(true, iwd->expr_colors->background.get_color());
iwd->drawer.attached(wd, dr);
iwd->drawer.refresh(); //Always redrawe no matter it is visible or invisible. This can make the graphics data correctly.
}
@ -685,6 +685,12 @@ namespace API
restrict::window_manager.update(reinterpret_cast<restrict::core_window_t*>(wd), false, true);
}
void window_caption(window wd, const std::string& title_utf8)
{
window_caption(wd, std::wstring(::nana::charset(title_utf8, ::nana::unicode::utf8)));
}
void window_caption(window wd, const nana::string& title)
{
auto const iwd = reinterpret_cast<restrict::core_window_t*>(wd);

View File

@ -2373,18 +2373,16 @@ namespace nana{ namespace widgets
nana::size text_editor::_m_text_extent_size(const char_type* str, size_type n) const
{
if(graph_)
if (!graph_)
return{};
if(mask_char_)
{
if(mask_char_)
{
nana::string maskstr;
maskstr.append(n, mask_char_);
return graph_.text_extent_size(maskstr);
}
else
return graph_.text_extent_size(str, static_cast<unsigned>(n));
nana::string maskstr;
maskstr.append(n, mask_char_);
return graph_.text_extent_size(maskstr);
}
return{};
return graph_.text_extent_size(str, static_cast<unsigned>(n));
}
//_m_move_offset_x_while_over_border
@ -2415,7 +2413,7 @@ namespace nana{ namespace widgets
width += text_area_.area.x;
if(static_cast<int>(width) - points_.offset.x >= _m_endx())
{ //Out of screen text area
points_.offset.x = width - _m_endx() + 1;
points_.offset.x = static_cast<int>(width) -_m_endx() + 1;
auto rest_size = lnstr.size() - points_.caret.x;
points_.offset.x += static_cast<int>(_m_text_extent_size(lnstr.c_str() + points_.caret.x, (rest_size >= static_cast<unsigned>(many) ? static_cast<unsigned>(many) : rest_size)).width);
return true;

View File

@ -20,13 +20,16 @@ namespace nana
}
//class widget
//@brief:The definition of class widget
widget::~widget(){}
nana::string widget::caption() const
{
return this->_m_caption();
}
void widget::caption(std::string utf8)
{
_m_caption(std::wstring(::nana::charset(utf8, ::nana::unicode::utf8)));
}
void widget::caption(nana::string str)
{
_m_caption(std::move(str));