add detection of clang

This commit is contained in:
Jinhao 2015-12-07 02:52:30 +08:00
parent dce320d544
commit 8a243ad0d7
3 changed files with 56 additions and 61 deletions

View File

@ -69,8 +69,13 @@
#endif // _MSC_VER == 1900 #endif // _MSC_VER == 1900
#endif // _MSVC #endif // _MSVC
//GCC #if defined(__clang__)
#if defined(__GNUC__) #if defined(__GLIBCPP__) || defined(__GLIBCXX__)
//<codecvt> is a known issue on libstdc++, it works on libc++
#define STD_CODECVT_NOT_SUPPORTED
#endif
#elif defined(__GNUC__) //GCC
#if defined(__GLIBCPP__) || defined(__GLIBCXX__) #if defined(__GLIBCPP__) || defined(__GLIBCXX__)
//<codecvt> is a known issue on libstdc++, it works on libc++ //<codecvt> is a known issue on libstdc++, it works on libc++
#define STD_CODECVT_NOT_SUPPORTED #define STD_CODECVT_NOT_SUPPORTED
@ -99,6 +104,7 @@
#endif #endif
// End compilers ... // End compilers ...

View File

@ -228,18 +228,6 @@ namespace nana
this->create(wd, rectangle(), visible); this->create(wd, rectangle(), visible);
} }
tabbar(window wd, const nana::char_t* text, bool visible)
: tabbar(wd, ::nana::string(text), visible)
{
}
tabbar(window wd, const nana::string& text, bool visible)
: tabbar()
{
this->create(wd, rectangle(), visible);
this->caption(text);
}
tabbar(window wd, const rectangle& r = rectangle(), bool visible = true) tabbar(window wd, const rectangle& r = rectangle(), bool visible = true)
: tabbar() : tabbar()
{ {
@ -256,7 +244,7 @@ namespace nana
return static_cast<value_type&>(this->get_drawer_trigger().at_no_bound_check(pos)); return static_cast<value_type&>(this->get_drawer_trigger().at_no_bound_check(pos));
} }
void activate(std::size_t pos) /// Activates a tab specified by i. void activated(std::size_t pos) /// Activates a tab specified by pos.
{ {
this->get_drawer_trigger().activate(pos); this->get_drawer_trigger().activate(pos);
} }
@ -266,9 +254,9 @@ namespace nana
return this->get_drawer_trigger().activated(); return this->get_drawer_trigger().activated();
} }
value_type & at(std::size_t i) const /// Returns i'th element value_type & at(std::size_t pos) const /// Returns pos'th element
{ {
return static_cast<value_type&>(this->get_drawer_trigger().at(i)); return static_cast<value_type&>(this->get_drawer_trigger().at(pos));
} }
void close_fly(bool fly) /// Draw or not a close button in each tab. void close_fly(bool fly) /// Draw or not a close button in each tab.
@ -277,12 +265,12 @@ namespace nana
API::refresh_window(this->handle()); API::refresh_window(this->handle());
} }
pat::cloneable<item_renderer>& ext_renderer() const pat::cloneable<item_renderer>& renderer() const
{ {
return this->get_drawer_trigger().ext_renderer(); return this->get_drawer_trigger().ext_renderer();
} }
void ext_renderer(const pat::cloneable<item_renderer>& ir) void renderer(const pat::cloneable<item_renderer>& ir)
{ {
this->get_drawer_trigger().ext_renderer(ir); this->get_drawer_trigger().ext_renderer(ir);
} }
@ -292,14 +280,14 @@ namespace nana
return this->get_drawer_trigger().length(); return this->get_drawer_trigger().length();
} }
void append(const std::string& text, window attach_wd, value_type value = {}) tabbar& append(std::string text, window attach_wd, value_type value = {})
{ {
this->append(static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), attach_wd); return this->append(static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), attach_wd);
} }
void append(const std::wstring& text, window attach_wd, value_type value = {}) tabbar& append(std::wstring text, window attach_wd, value_type value = {})
{ {
this->get_drawer_trigger().insert(::nana::npos, std::wstring(text), std::move(value)); this->get_drawer_trigger().insert(::nana::npos, std::move(text), std::move(value));
if (attach_wd) if (attach_wd)
{ {
auto pos = this->get_drawer_trigger().length(); auto pos = this->get_drawer_trigger().length();
@ -307,6 +295,7 @@ namespace nana
} }
API::update_window(*this); API::update_window(*this);
return *this;
} }
void push_back(nana::string text) /// Append a new item. void push_back(nana::string text) /// Append a new item.
@ -315,17 +304,17 @@ namespace nana
API::update_window(*this); API::update_window(*this);
} }
void insert(std::size_t pos, const std::string& text, const value_type& value = {}) void insert(std::size_t pos, std::string text, value_type value = {})
{ {
this->insert(pos, static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), value); return this->insert(pos, static_cast<std::wstring>(nana::charset(text, nana::unicode::utf8)), std::move(value));
} }
void insert(std::size_t pos, const std::wstring& text, const value_type& value = {}) void insert(std::size_t pos, std::wstring text, value_type value = {})
{ {
if (pos > length()) if (pos > length())
throw std::out_of_range("tabbar::insert invalid position"); throw std::out_of_range("tabbar::insert invalid position");
this->get_drawer_trigger().insert(pos, std::wstring(text), value_type(value)); this->get_drawer_trigger().insert(pos, std::move(text), std::move(value));
API::update_window(*this); API::update_window(*this);
} }
@ -345,19 +334,19 @@ namespace nana
this->get_drawer_trigger().erase(pos); this->get_drawer_trigger().erase(pos);
} }
void tab_bgcolor(std::size_t i, const ::nana::color& clr) void tab_bgcolor(std::size_t pos, const ::nana::color& clr)
{ {
this->get_drawer_trigger().tab_color(i, true, clr); this->get_drawer_trigger().tab_color(pos, true, clr);
} }
void tab_fgcolor(std::size_t i, const ::nana::color& clr) void tab_fgcolor(std::size_t pos, const ::nana::color& clr)
{ {
this->get_drawer_trigger().tab_color(i, false, clr); this->get_drawer_trigger().tab_color(pos, false, clr);
} }
void tab_image(std::size_t i, const nana::paint::image& img) void tab_image(std::size_t pos, const nana::paint::image& img)
{ {
this->get_drawer_trigger().tab_image(i, img); this->get_drawer_trigger().tab_image(pos, img);
} }
/// Sets buttons of the tabbar's toolbox, refer to notes for more details. /// Sets buttons of the tabbar's toolbox, refer to notes for more details.
template<typename Add, typename Scroll, typename List, typename Close> template<typename Add, typename Scroll, typename List, typename Close>

View File

@ -605,60 +605,60 @@ namespace nana
void attach(std::size_t pos, window wd) void attach(std::size_t pos, window wd)
{ {
if(pos < list_.size()) if (pos >= list_.size())
{ throw std::out_of_range("tabbar: invalid position");
iterator_at(pos)->relative = wd;
API::show_window(wd, basis_.active == pos); API::show_window(wd, basis_.active == pos);
}
} }
bool tab_color(std::size_t pos, bool is_bgcolor, const ::nana::color& clr) bool tab_color(std::size_t pos, bool is_bgcolor, const ::nana::color& clr)
{ {
if(pos < list_.size()) if (pos >= list_.size())
throw std::out_of_range("tabbar: invalid position");
auto & m = *iterator_at(pos);
auto & m_clr = (is_bgcolor ? m.bgcolor : m.fgcolor);
if (m_clr != clr)
{ {
auto & m = *iterator_at(pos); m_clr = clr;
auto & m_clr = (is_bgcolor ? m.bgcolor : m.fgcolor); return true;
if (m_clr != clr)
{
m_clr = clr;
return true;
}
} }
return false; return false;
} }
bool tab_image(std::size_t pos, const nana::paint::image& img) void tab_image(std::size_t pos, const nana::paint::image& img)
{ {
if(pos > list_.size()) return false; if (pos >= list_.size())
throw std::out_of_range("tabbar: invalid position");
auto & m = *iterator_at(pos); auto & m = *iterator_at(pos);
if(img) if(img)
m.img = img; m.img = img;
else else
m.img.close(); m.img.close();
return true;
} }
bool text(std::size_t pos, const nana::string& str) bool text(std::size_t pos, const nana::string& str)
{ {
if(pos < list_.size()) if (pos >= list_.size())
throw std::out_of_range("tabbar: invalid position");
auto & m = *iterator_at(pos);
if(m.text != str)
{ {
auto & m = *iterator_at(pos); m.text = str;
if(m.text != str) return true;
{
m.text = str;
return true;
}
} }
return false; return false;
} }
nana::string text(std::size_t pos) const nana::string text(std::size_t pos) const
{ {
if(pos < list_.size()) if (pos >= list_.size())
return iterator_at(pos)->text; throw std::out_of_range("tabbar: invalid position");
return nana::string(); return iterator_at(pos)->text;
} }
bool toolbox_answer(const arg_mouse& arg) bool toolbox_answer(const arg_mouse& arg)
@ -1195,8 +1195,8 @@ namespace nana
void trigger::tab_image(std::size_t i, const nana::paint::image& img) void trigger::tab_image(std::size_t i, const nana::paint::image& img)
{ {
if(layouter_->tab_image(i, img)) layouter_->tab_image(i, img);
API::refresh_window(layouter_->widget_handle()); API::refresh_window(layouter_->widget_handle());
} }
void trigger::text(std::size_t i, const nana::string& str) void trigger::text(std::size_t i, const nana::string& str)