Merge remote-tracking branch 'nana_jinhao/develop' into develop

This commit is contained in:
qPCR4vir
2015-07-16 15:12:53 +02:00
23 changed files with 870 additions and 128 deletions

View File

@@ -258,7 +258,7 @@ namespace nana{ namespace drawerbase
}
if(attr_.icon)
attr_.icon->paste(graph, 3, (gsize.height - icon_sz.height) / 2);
attr_.icon->paste(graph, point{ 3, static_cast<int>(gsize.height - icon_sz.height) / 2 });
}
void trigger::_m_draw(graph_reference graph)

View File

@@ -0,0 +1,113 @@
/**
* A group widget implementation
* Nana C++ Library(http://www.nanaro.org)
* Copyright(C) 2015 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/widgets/group.cpp
*
* @Author: Stefan Pfeifer(st-321), Ariel Vina-Rodriguez (qPCR4vir)
*
* @brief group is a widget used to visually group and layout other widgets.
*/
#include <nana/gui/widgets/group.hpp>
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/drawing.hpp>
namespace nana{
struct group::implement
{
label caption;
panel<false> content;
place place_outter;
place place_content;
implement(group* host):
caption(*host),
content(*host),
place_outter(*host),
place_content(content)
{}
};
group::group( window parent, ///<
std::wstring titel_ /*={}*/, ///<
bool format /*=false*/, ///<
unsigned gap /*=2*/, ///<
rectangle r /*={} */ ///<
)
: panel (parent, r),
impl_(new implement(this))
{
impl_->caption.format(format);
::nana::size sz = impl_->caption.measure(1000);
std::stringstream ft;
ft << "vert margin=[0," << gap << ","<<gap<<","<<gap<<"]"
<< " <weight=" << sz.height << " <weight=5> <titel weight=" << sz.width+1 << "> >"
<< " <content>";
auto & outter = impl_->place_outter;
outter.div(ft.str().c_str());
outter["titel"] << impl_->caption;
outter["content"] << impl_->content;
outter.collocate();
color pbg = API::bgcolor( parent);
impl_->caption.bgcolor(pbg.blend(colors::black, 0.975) );
color bg=pbg.blend(colors::black, 0.950 );
bgcolor(pbg);
impl_->content.bgcolor(bg);
drawing dw(*this);
// This drawing function is owner by the onwer of dw (the outer panel of the group widget), not by dw !!
dw.draw([gap, sz, bg, pbg](paint::graphics& graph)
{
graph.rectangle(true, pbg);
graph.round_rectangle(rectangle(point(gap - 1, sz.height / 2),
nana::size(graph.width() - 2 * (gap - 1), graph.height() - sz.height / 2 - (gap - 1))
),
3, 3, colors::gray_border, true, bg);
});
}
group::~group()
{
}
place& group::get_place()
{
return impl_->place_content;
}
window group::inner()
{
return impl_->content;
}
void group::_m_add_child(const char* field, widget* wdg)
{
impl_->place_content[field] << wdg->handle();
}
::nana::string group::_m_caption() const
{
return impl_->caption.caption();
}
void group::_m_caption(::nana::string&& str)
{
return impl_->caption.caption(std::move(str));
}
}//end namespace nana

View File

@@ -2534,8 +2534,34 @@ namespace nana{ namespace widgets
return true;
}
std::size_t eat_endl(const wchar_t* str, std::size_t pos)
{
auto ch = str[pos];
if (0 == ch)
return pos;
const wchar_t * endlstr;
switch (ch)
{
case L'\n':
endlstr = L"\n\r";
break;
case L'\r':
endlstr = L"\r\n";
break;
default:
return pos;
}
if (std::memcmp(str + pos, endlstr, sizeof(wchar_t) * 2) == 0)
return pos + 2;
return pos + 1;
}
bool text_editor::_m_resolve_text(const nana::string& text, std::vector<std::pair<std::size_t, std::size_t>> & lines)
{
auto const text_str = text.data();
std::size_t begin = 0;
while (true)
{
@@ -2548,13 +2574,23 @@ namespace nana{ namespace widgets
}
lines.emplace_back(begin, pos);
begin = text.find_first_not_of(STR("\r\n"), pos + 1);
pos = eat_endl(text_str, pos);
begin = text.find_first_not_of(STR("\r\n"), pos);
//The number of new lines minus one
const auto chp_end = text.data() + (begin == text.npos ? text.size() : begin);
for (auto chp = text.data() + (pos + 1); chp != chp_end; ++chp)
if (*chp == '\n')
const auto chp_end = text_str + (begin == text.npos ? text.size() : begin);
for (auto chp = text_str + pos; chp != chp_end; ++chp)
{
auto eats = eat_endl(chp, 0);
if (eats)
{
lines.emplace_back(0, 0);
chp += (eats - 1);
}
}
if (text.npos == begin)
{
@@ -2742,50 +2778,43 @@ namespace nana{ namespace widgets
const auto str_end = str + len;
auto & entities = parser.entities();
for (auto & ent : entities)
for (auto & ent : entities)
{
const ::nana::char_t* ent_begin = nullptr;
int ent_off = 0;
if (str <= ent.begin && ent.begin < str_end)
{
const ::nana::char_t* ent_begin = nullptr;
ent_begin = ent.begin;
ent_off = std::accumulate(glyphs, glyphs + (ent.begin - str), 0);
}
else if (ent.begin <= str && str < ent.end)
ent_begin = str;
int ent_off = 0;
if (str <= ent.begin && ent.begin < str_end)
if (ent_begin)
{
auto ent_end = (ent.end < str_end ? ent.end : str_end);
auto ent_pixels = std::accumulate(glyphs + (ent_begin - str), glyphs + (ent_end - str), unsigned{});
canvas.set_color(ent.scheme->bgcolor.invisible() ? _m_bgcolor() : ent.scheme->bgcolor);
canvas.set_text_color(ent.scheme->fgcolor.invisible() ? fgcolor : ent.scheme->fgcolor);
canvas.rectangle(true);
ent_pos.x += ent_off;
if (rtl)
{
ent_begin = ent.begin;
ent_off = std::accumulate(glyphs, glyphs + (ent.begin - str), 0);
//draw the whole text if it is a RTL text, because Arbic language is transformable.
canvas.string({}, str, len);
graph_.bitblt(::nana::rectangle{ ent_pos, ::nana::size{ ent_pixels, canvas.height() } }, canvas, ::nana::point{ ent_off, 0 });
}
else if (ent.begin <= str && str < ent.end)
ent_begin = str;
if (ent_begin)
else
{
auto ent_end = (ent.end < str_end ? ent.end : str_end);
auto ent_pixels = std::accumulate(glyphs + (ent_begin - str), glyphs + (ent_end - str), unsigned{});
if (ent.scheme->bgcolor.invisible())
canvas.set_color(_m_bgcolor());
else
canvas.set_color(ent.scheme->bgcolor);
canvas.rectangle(true);
if (ent.scheme->fgcolor.invisible())
canvas.set_text_color(fgcolor);
else
canvas.set_text_color(ent.scheme->fgcolor);
ent_pos.x += ent_off;
if (rtl)
{
//draw the whole text if it is a RTL text, because Arbic language is transformable.
canvas.string({}, str, len);
graph_.bitblt(::nana::rectangle{ ent_pos, ::nana::size{ ent_pixels, canvas.height() } }, canvas, ::nana::point{ ent_off, 0 });
}
else
{
canvas.string({}, ent_begin, ent_end - ent_begin);
graph_.bitblt(::nana::rectangle{ ent_pos, ::nana::size{ ent_pixels, canvas.height() } }, canvas);
}
canvas.string({}, ent_begin, ent_end - ent_begin);
graph_.bitblt(::nana::rectangle{ ent_pos, ::nana::size{ ent_pixels, canvas.height() } }, canvas);
}
}
}
}
void text_editor::_m_draw_string(int top, const ::nana::color& clr, const nana::upoint& str_pos, const nana::string& str, bool if_mask) const
@@ -2797,7 +2826,6 @@ namespace nana{ namespace widgets
if (if_mask && mask_char_)
mask_str.reset(new nana::string(str.size(), mask_char_));
auto & linestr = (if_mask && mask_char_ ? *mask_str : str);
unicode_bidi bidi;

View File

@@ -1263,7 +1263,7 @@ namespace nana
img->stretch(::nana::rectangle{ size }, graph, attr.area);
}
else
img->paste(graph, attr.area.x + static_cast<int>(attr.area.width - size.width) / 2, attr.area.y + static_cast<int>(attr.area.height - size.height) / 2);
img->paste(graph, point{ attr.area.x + static_cast<int>(attr.area.width - size.width) / 2, attr.area.y + static_cast<int>(attr.area.height - size.height) / 2 });
}
}
}