From 658ab3fb7fc572231763aa3440beb67d5c600270 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 14 Aug 2015 04:09:35 +0800 Subject: [PATCH 01/65] new docker-place branch --- include/nana/gui/element.hpp | 101 +- include/nana/gui/place.hpp | 16 +- include/nana/gui/programming_interface.hpp | 2 +- source/gui/dragger.cpp | 2 +- source/gui/element.cpp | 250 +++- source/gui/place.cpp | 1326 +++++++++++++------- source/gui/programming_interface.cpp | 4 +- source/gui/widgets/widget.cpp | 2 +- 8 files changed, 1210 insertions(+), 493 deletions(-) diff --git a/include/nana/gui/element.hpp b/include/nana/gui/element.hpp index ee63ecf0..9ffa721d 100644 --- a/include/nana/gui/element.hpp +++ b/include/nana/gui/element.hpp @@ -98,25 +98,31 @@ namespace nana } }; - void add_crook(const std::string& name, const pat::cloneable>&); - crook_interface* const * keeper_crook(const std::string& name); + void add_arrow(const std::string&, const pat::cloneable>&); + arrow_interface* const * cite_arrow(const std::string&); void add_border(const std::string&, const pat::cloneable>&); - border_interface* const * keeper_border(const std::string&); - - void add_arrow(const std::string&, const pat::cloneable>&); - arrow_interface* const * keeper_arrow(const std::string&); + border_interface* const * cite_border(const std::string&); void add_button(const std::string&, const pat::cloneable>&); - element_interface* const* keeper_button(const std::string&); + element_interface* const* cite_button(const std::string&); + + void add_x_icon(const std::string& name, const pat::cloneable>&); + element_interface* const* cite_x_icon(const std::string&); + + void add_crook(const std::string& name, const pat::cloneable>&); + crook_interface* const * cite_crook(const std::string& name); + + void add_cross(const std::string& name, const pat::cloneable>&); + element_interface* const* cite_cross(const std::string&); }; - class crook; - template - void add_crook(const std::string& name) + class arrow; + template + void add_arrow(const std::string& name) { - using factory_t = provider::factory; - provider().add_crook(name, pat::cloneable(factory_t())); + using factory_t = provider::factory; + provider().add_arrow(name, pat::cloneable(factory_t())); } class border; @@ -127,14 +133,6 @@ namespace nana provider().add_border(name, pat::cloneable(factory_t())); } - class arrow; - template - void add_arrow(const std::string& name) - { - using factory_t = provider::factory; - provider().add_arrow(name, pat::cloneable(factory_t())); - } - class button; template void add_button(const std::string& name) @@ -142,6 +140,30 @@ namespace nana using factory_t = provider::factory; provider().add_button(name, pat::cloneable(factory_t())); } + + class x_icon; + template + void add_x_icon(const std::string& name) + { + using factory_t = provider::factory; + provider().add_x_icon(name, pat::cloneable(factory_t())); + } + + class crook; + template + void add_crook(const std::string& name) + { + using factory_t = provider::factory; + provider().add_crook(name, pat::cloneable(factory_t())); + } + + class cross; + template + void add_cross(const std::string& name) + { + using factory_t = provider::factory; + provider().add_cross(name, pat::cloneable(factory_t())); + } }//end namespace element template class facade; @@ -169,9 +191,27 @@ namespace nana bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state) override; private: element::crook_interface::data data_; - element::crook_interface* const * keeper_; + element::crook_interface* const * cite_; }; //end class facade + template<> class facade + : public element::element_interface + { + public: + facade(const char* name = nullptr); + void switch_to(const char*); + + void thickness(unsigned thk); + void size(unsigned size_pixels); + public: + //Implement element_interface + bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state) override; + private: + unsigned thickness_{6}; + unsigned size_{ 14 }; + element::element_interface* const * cite_; + }; + template<> class facade : public element::element_interface @@ -185,7 +225,7 @@ namespace nana //Implement element_interface bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state) override; private: - element::border_interface* const * keeper_; + element::border_interface* const * cite_; };//end class facade template<> @@ -207,7 +247,7 @@ namespace nana //Implement element_interface bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state) override; private: - element::arrow_interface* const * keeper_; + element::arrow_interface* const * cite_; ::nana::direction dir_{::nana::direction::north}; };//end class facade @@ -222,9 +262,22 @@ namespace nana //Implement element_interface bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state) override; private: - element::element_interface* const * keeper_; + element::element_interface* const * cite_; };//end class facade + template<> + class facade + : public element::element_interface + { + public: + facade(const char* name = nullptr); + void switch_to(const char*); + public: + //Implement element_interface + bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state) override; + private: + element::element_interface* const * cite_; + };//end class facade namespace element { diff --git a/include/nana/gui/place.hpp b/include/nana/gui/place.hpp index a7e7e0ea..8faedf91 100644 --- a/include/nana/gui/place.hpp +++ b/include/nana/gui/place.hpp @@ -109,9 +109,11 @@ namespace nana window window_handle() const; void div(const char* s); ///< Divides the attached widget into fields. + void modify(const char* field_name, const char* div_text); ///< Modifies a specified field. + field_reference field(const char* name);///< Returns a field with the specified name. - void field_visible(const char* filed_name, bool visible); ///< + void dock(const std::string& dockname, Args&& ... args) + { + dock(dockname, std::bind([](window parent, Args && ... args) + { + return std::unique_ptr(new Panel(parent, std::forward(args)...)); + }, std::placeholders::_1, std::forward(args)...)); + } + + void dock(const std::string& dockname, std::function(window)> factory); private: implement * impl_; }; diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 167fd8d8..bfbcd138 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -191,7 +191,7 @@ namespace API } point window_position(window); - void move_window(window, int x, int y); + void move_window(window, const point&); void move_window(window wd, const rectangle&); void bring_top(window, bool activated); diff --git a/source/gui/dragger.cpp b/source/gui/dragger.cpp index dac2c6c8..5bb82baf 100644 --- a/source/gui/dragger.cpp +++ b/source/gui/dragger.cpp @@ -164,7 +164,7 @@ namespace nana if (!t.restrict_area.empty()) _m_check_restrict_area(wdps, API::window_size(t.wd), t.restrict_area); - API::move_window(t.wd, wdps.x, wdps.y); + API::move_window(t.wd, wdps); } } } diff --git a/source/gui/element.cpp b/source/gui/element.cpp index 1852a554..cbccebed 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -141,7 +141,7 @@ namespace nana } else { - ::nana::color highlighted(static_cast(0x5eb6f7)); + ::nana::color highlighted(0x5e, 0xb6, 0xf7); auto bld_bgcolor = bgcolor; auto bld_fgcolor = fgcolor; switch(es) @@ -156,7 +156,7 @@ namespace nana bld_fgcolor = fgcolor.blend(highlighted, 0.4); break; case element_state::disabled: - bld_bgcolor = bld_fgcolor.from_rgb(0xb2, 0xb7, 0xbc); + bld_bgcolor = bld_fgcolor = nana::color(0xb2, 0xb7, 0xbc); break; default: //Leave things as they are @@ -264,7 +264,7 @@ namespace nana bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, unsigned weight) { graph.rectangle(r, false, static_cast((element_state::focus_hovered == estate || element_state::focus_normal == estate) ? 0x0595E2 : 0x999A9E)); - graph.rectangle(::nana::rectangle(r).pare_off(1), false, bgcolor); + graph.rectangle(::nana::rectangle{r}.pare_off(1), false, bgcolor); return true; } }; @@ -529,6 +529,63 @@ namespace nana return true; } };//end class annex_button + + class x_icon + : public element_interface + { + bool draw(graph_reference graph, const ::nana::color&, const ::nana::color& fgcolor, const rectangle& r, element_state estate) override + { + auto clr = fgcolor; + + switch (estate) + { + case element_state::hovered: + case element_state::pressed: + clr = clr.blend(colors::black, 0.8); + break; + case element_state::disabled: + clr = colors::dark_gray; + default: + break; + } + + graph.set_color(clr); + + const int x = r.x + 4; + const int y = r.y + 4; + + point p1{ x, y }, p2{ x + 7, y + 7 }; + + graph.line(p1, p2); + + ++p1.x; + --p2.y; + graph.line(p1, p2); + + p1.x = x; + ++p1.y; + p2.x = x + 6; + p2.y = y + 7; + graph.line(p1, p2); + + p1.x += 7; + p1.y = y; + p2.x = x; + graph.line(p1, p2); + + p1.x = x + 6; + p2.y = y + 6; + graph.line(p1, p2); + + ++p1.x; + ++p1.y; + ++p2.x; + ++p2.y; + graph.line(p1, p2); + + return true; + } + }; }//end namespace element template @@ -567,7 +624,7 @@ namespace nana spare_.emplace_back(keep_e, keep_f); } - element_t * const * keeper() const + element_t * const * cite() const { return &element_ptr_; } @@ -580,6 +637,9 @@ namespace nana class element_manager : nana::noncopyable, nana::nonmovable { + //VC2012 does not support alias declaration. + //template using factory_interface = element::provider::factory_interface; + template struct item { @@ -613,6 +673,8 @@ namespace nana element::add_arrow("hollow_triangle"); element::add_button(""); //"annex" in default + + element::add_x_icon(""); } return obj; } @@ -624,7 +686,17 @@ namespace nana element::crook_interface * const * crook(const std::string& name) const { - return _m_get(name, crook_).keeper(); + return _m_get(name, crook_).cite(); + } + + void cross(const std::string& name, const pat::cloneable>& factory) + { + _m_add(name, cross_, factory); + } + + element::element_interface* const * cross(const std::string& name) const + { + return _m_get(name, cross_).cite(); } void border(const std::string& name, const pat::cloneable>& factory) @@ -634,7 +706,7 @@ namespace nana element::border_interface * const * border(const std::string& name) const { - return _m_get(name, border_).keeper(); + return _m_get(name, border_).cite(); } void arrow(const std::string& name, const pat::cloneable>& factory) @@ -644,7 +716,7 @@ namespace nana element::arrow_interface * const * arrow(const std::string& name) const { - return _m_get((name.empty() ? "arrowhead" : name), arrow_).keeper(); + return _m_get((name.empty() ? "arrowhead" : name), arrow_).cite(); } void button(const std::string& name, const pat::cloneable>& factory) @@ -654,7 +726,17 @@ namespace nana element::element_interface * const * button(const std::string& name) const { - return _m_get((name.empty() ? "annex" : name), button_).keeper(); + return _m_get((name.empty() ? "annex" : name), button_).cite(); + } + + void x_icon(const std::string& name, const pat::cloneable>& factory) + { + _m_add(name, x_icon_, factory); + } + + element::element_interface * const * x_icon(const std::string& name) const + { + return _m_get(name, x_icon_).cite(); } private: using lock_guard = std::lock_guard; @@ -689,9 +771,11 @@ namespace nana private: mutable std::recursive_mutex mutex_; item crook_; + item cross_; item border_; item arrow_; item button_; + item x_icon_; }; namespace element @@ -702,17 +786,27 @@ namespace nana element_manager::instance().crook(name, factory); } - crook_interface* const * provider::keeper_crook(const std::string& name) + crook_interface* const * provider::cite_crook(const std::string& name) { return element_manager::instance().crook(name); } + void provider::add_cross(const std::string& name, const pat::cloneable>& factory) + { + element_manager::instance().cross(name, factory); + } + + element_interface* const* provider::cite_cross(const std::string& name) + { + return element_manager::instance().cross(name); + } + void provider::add_border(const std::string& name, const pat::cloneable>& factory) { element_manager::instance().border(name, factory); } - border_interface* const * provider::keeper_border(const std::string& name) + border_interface* const * provider::cite_border(const std::string& name) { return element_manager::instance().border(name); } @@ -722,7 +816,7 @@ namespace nana element_manager::instance().arrow(name, factory); } - arrow_interface* const * provider::keeper_arrow(const std::string& name) + arrow_interface* const * provider::cite_arrow(const std::string& name) { return element_manager::instance().arrow(name); } @@ -732,16 +826,26 @@ namespace nana element_manager::instance().button(name, factory); } - element_interface* const* provider::keeper_button(const std::string& name) + element_interface* const* provider::cite_button(const std::string& name) { return element_manager::instance().button(name); } + + void provider::add_x_icon(const std::string& name, const pat::cloneable>& factory) + { + element_manager::instance().x_icon(name, factory); + } + + element_interface* const* provider::cite_x_icon(const std::string& name) + { + return element_manager::instance().x_icon(name); + } }//end namespace element //facades //template<> class facade facade::facade(const char* name) - : keeper_(element::provider().keeper_crook(name ? name : "")) + : cite_(element::provider().cite_crook(name ? name : "")) { data_.check_state = state::unchecked; data_.radio = false; @@ -777,40 +881,120 @@ namespace nana void facade::switch_to(const char* name) { - keeper_ = element::provider().keeper_crook(name ? name : ""); + cite_ = element::provider().cite_crook(name ? name : ""); } bool facade::draw(graph_reference graph, const ::nana::color& bgcol, const ::nana::color& fgcol, const nana::rectangle& r, element_state es) { - return (*keeper_)->draw(graph, bgcol, fgcol, r, es, data_); + return (*cite_)->draw(graph, bgcol, fgcol, r, es, data_); } //end class facade + //class facade + facade::facade(const char* name) + : cite_(element::provider().cite_cross(name ? name : "")) + { + + } + + void facade::switch_to(const char* name) + { + cite_ = element::provider().cite_cross(name ? name : ""); + } + + void facade::thickness(unsigned thk) + { + thickness_ = thk; + } + + void facade::size(unsigned size_px) + { + size_ = size_px; + } + + //Implement element_interface + bool facade::draw(graph_reference graph, const ::nana::color&, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state) + { + if (thickness_ + 2 <= size_) + { + int gap = (static_cast(size_) - static_cast(thickness_)) / 2; + + nana::point ps[12]; + ps[0].x = r.x + gap; + ps[1].x = ps[0].x + static_cast(thickness_) - 1; + ps[1].y = ps[0].y = r.y; + + ps[2].x = ps[1].x; + ps[2].y = r.y + gap; + + ps[3].x = ps[2].x + gap; + ps[3].y = ps[2].y; + + ps[4].x = ps[3].x; + ps[4].y = ps[3].y + static_cast(thickness_)-1; + + ps[5].x = ps[1].x; + ps[5].y = ps[4].y; + + ps[6].x = ps[5].x; + ps[6].y = ps[5].y + gap; + + ps[7].x = r.x + gap; + ps[7].y = ps[6].y; + + ps[8].x = ps[7].x; + ps[8].y = ps[4].y; + + ps[9].x = r.x; + ps[9].y = ps[4].y; + + ps[10].x = r.x; + ps[10].y = r.y + gap; + + ps[11].x = r.x + gap; + ps[11].y = r.y + gap; + + graph.set_color(fgcolor.blend(colors::black, true)); + + for (int i = 0; i < 11; ++i) + graph.line(ps[i], ps[i + 1]); + graph.line(ps[11], ps[0]); + + graph.set_color(fgcolor); + + unsigned thk_minus_2 = thickness_ - 2; + graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thk_minus_2, thk_minus_2 }, true); + graph.rectangle(rectangle{ ps[0].x + 1, ps[0].y + 1, thk_minus_2, (gap << 1) + thk_minus_2 }, true); + } + return true; + } + //end class facade + //class facade facade::facade(const char* name) - : keeper_(element::provider().keeper_border(name ? name : "")) + : cite_(element::provider().cite_border(name ? name : "")) {} void facade::switch_to(const char* name) { - keeper_ = element::provider().keeper_border(name ? name : ""); + cite_ = element::provider().cite_border(name ? name : ""); } bool facade::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state es) { - return (*keeper_)->draw(graph, bgcolor, fgcolor, r, es, 2); + return (*cite_)->draw(graph, bgcolor, fgcolor, r, es, 2); } //end class facade //class facade facade::facade(const char* name) - : keeper_(element::provider().keeper_arrow(name ? name : "")) + : cite_(element::provider().cite_arrow(name ? name : "")) { } void facade::switch_to(const char* name) { - keeper_ = element::provider().keeper_arrow(name ? name : ""); + cite_ = element::provider().cite_arrow(name ? name : ""); } void facade::direction(::nana::direction dir) @@ -822,27 +1006,45 @@ namespace nana bool facade::draw(graph_reference graph, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle& r, element_state estate) { graph.set_color(fgcolor); - return (*keeper_)->draw(graph, bgcolor, fgcolor, r, estate, dir_); + return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate, dir_); } //end class facade //class facade:: facade::facade(const char* name) - : keeper_(element::provider().keeper_button(name ? name : "")) + : cite_(element::provider().cite_button(name ? name : "")) {} void facade::switch_to(const char* name) { - keeper_ = element::provider().keeper_button(name ? name : ""); + cite_ = element::provider().cite_button(name ? name : ""); } //Implement element_interface bool facade::draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate) { - return (*keeper_)->draw(graph, bgcolor, fgcolor, r, estate); + return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate); } //end class facade + + //class facade + facade::facade(const char* name) + : cite_(element::provider().cite_x_icon(name ? name : "")) + {} + + void facade::switch_to(const char* name) + { + cite_ = element::provider().cite_x_icon(name ? name : ""); + } + + //Implement element_interface + bool facade::draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate) + { + return (*cite_)->draw(graph, bgcolor, fgcolor, r, estate); + } + //end class facade + namespace element { void set_bground(const char* name, const pat::cloneable& obj) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index f57df5e5..7a6325ef 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1,4 +1,4 @@ -/** +/* * An Implementation of Place for Layout * Nana C++ Library(http://www.nanapro.org) * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) @@ -8,333 +8,35 @@ * http://www.boost.org/LICENSE_1_0.txt) * * @file: nana/gui/place.cpp + * @contributors: qPCR4vir */ -#include + #include #include -#include -#include +#include +#include #include #include #include +#include #include +#include #include -#include -#include +#include //numeric_limits + +#include "place_parts.hpp" namespace nana { namespace place_parts { + //check the name void check_field_name(const char* name) { - //check the name if (*name && (*name != '_' && !(('a' <= *name && *name <= 'z') || ('A' <= *name && *name <= 'Z')))) - throw std::invalid_argument("place.field: bad field name"); + throw std::invalid_argument("nana.place: bad field name"); } - - class splitter_interface - { - public: - virtual ~splitter_interface(){} - }; - - class splitter_dtrigger - : public drawer_trigger - { - }; - - template - class splitter - : public widget_object ::type, splitter_dtrigger>, - public splitter_interface - { - }; - - //number_t is used for storing a number type variable - //such as integer, real and percent. Essentially, percent is a typo of real. - class number_t - { - public: - enum class kind{ none, integer, real, percent }; - - number_t() - : kind_(kind::none) - { - value_.integer = 0; - } - - void reset() - { - kind_ = kind::none; - value_.integer = 0; - } - - bool is_negative() const - { - switch (kind_) - { - case kind::integer: - return (value_.integer < 0); - case kind::real: - case kind::percent: - return (value_.real < 0); - default: - break; - } - return false; - } - - bool is_none() const - { - return (kind::none == kind_); - } - - bool is_not_none() const - { - return (kind::none != kind_); - } - - kind kind_of() const - { - return kind_; - } - - double get_value(int ref_percent) const - { - switch (kind_) - { - case kind::integer: - return value_.integer; - case kind::real: - return value_.real; - case kind::percent: - return value_.real * ref_percent; - default: - break; - } - return 0; - } - - int integer() const - { - if (kind::integer == kind_) - return value_.integer; - return static_cast(value_.real); - } - - double real() const - { - if (kind::integer == kind_) - return value_.integer; - return value_.real; - } - - void assign(int i) - { - kind_ = kind::integer; - value_.integer = i; - } - - void assign(double d) - { - kind_ = kind::real; - value_.real = d; - } - - void assign_percent(double d) - { - kind_ = kind::percent; - value_.real = d / 100; - } - private: - kind kind_; - union valueset - { - int integer; - double real; - }value_; - };//end class number_t - - class margin - { - public: - margin& operator=(margin&& rhs) - { - if (this != &rhs) - { - all_edges_ = rhs.all_edges_; - margins_ = std::move(rhs.margins_); - } - return *this; - } - - void clear() - { - all_edges_ = true; - margins_.clear(); - } - - void push(const number_t& v) - { - margins_.emplace_back(v); - } - - void set_value(const number_t& v) - { - clear(); - margins_.emplace_back(v); - } - - void set_array(const std::vector& v) - { - all_edges_ = false; - margins_ = v; - } - - nana::rectangle area(const ::nana::rectangle& field_area) const - { - if (margins_.empty()) - return field_area; - - auto r = field_area; - if (all_edges_) - { - auto px = static_cast(margins_.back().get_value(static_cast(r.width))); - const auto dbl_px = static_cast(px << 1); - r.x += px; - r.width = (r.width < dbl_px ? 0 : r.width - dbl_px); - - r.y += px; - r.height = (r.height < dbl_px ? 0 : r.height - dbl_px); - } - else - { - int il{ -1 }, ir{ -1 }, it{ -1 }, ib{ -1 }; //index of four corners in margin - switch (margins_.size()) - { - case 0: break; - case 1: //top - it = 0; - break; - case 2://top,bottom and left,right - it = ib = 0; - il = ir = 1; - break; - default: - il = 3; //left - case 3: //top, right, bottom - it = 0; - ir = 1; - ib = 2; - } - - typedef decltype(r.height) px_type; - auto calc = [](px_type a, px_type b) - { - return (a > b ? a - b : 0); - }; - - if (0 == it) //top - { - auto px = static_cast(margins_[it].get_value(static_cast(field_area.height))); - r.y += px; - r.height = calc(r.height, static_cast(px)); - } - - if (-1 != ib) //bottom - { - auto px = static_cast(margins_[ib].get_value(static_cast(field_area.height))); - r.height = calc(r.height, static_cast(px)); - } - - if (-1 != il) //left - { - auto px = static_cast(margins_[il].get_value(static_cast(field_area.width))); - r.x += px; - r.width = calc(r.width, static_cast(px)); - } - - if (-1 != ir) //right - { - auto px = static_cast(margins_[ir].get_value(static_cast(field_area.width))); - r.width = calc(r.width, static_cast(px)); - } - } - return r; - } - private: - bool all_edges_ = true; - std::vector margins_; - };//end class margin - - class repeated_array - { - public: - - //A workaround for VC2013, becuase it does not generated an implicit declared move-constructor as defaulted. - repeated_array() = default; - - repeated_array(repeated_array && other) - : repeated_{other.repeated_}, - values_(std::move(other.values_)) - { - } - - repeated_array& operator=(repeated_array&& other) - { - if(this != &other) - { - repeated_ = other.repeated_; - other.repeated_ = false; - values_ = std::move(other.values_); - } - return *this; - } - - void assign(std::vector&& c) - { - values_ = std::move(c); - } - - bool empty() const - { - return values_.empty(); - } - - void reset() - { - repeated_ = false; - values_.clear(); - } - - void repeated() - { - repeated_ = true; - } - - void push(const number_t& n) - { - values_.emplace_back(n); - } - - number_t at(std::size_t pos) const - { - if (values_.empty()) - return{}; - - if (repeated_) - pos %= values_.size(); - else if (pos >= values_.size()) - return{}; - - return values_[pos]; - } - private: - bool repeated_ = false; - std::vector values_; - }; }//end namespace place_parts typedef place_parts::number_t number_t; @@ -348,8 +50,8 @@ namespace nana enum class token { div_start, div_end, splitter, - identifier, vert, grid, number, array, reparray, - weight, gap, margin, arrange, variable, repeated, min_px, max_px, + identifier, dock, vert, grid, number, array, reparray, + weight, gap, margin, arrange, variable, repeated, min_px, max_px, left, right, top, bottom, collapse, parameters, equal, eof, error @@ -384,6 +86,16 @@ namespace nana return parameters_; } + std::size_t pos() const + { + return (sp_ - divstr_); + } + + std::string pos_str() const + { + return std::to_string(pos()); + } + token read() { sp_ = _m_eat_whitespace(sp_); @@ -415,46 +127,46 @@ namespace nana ++sp_; return token::array; } - - { - //When search the repeated. - bool repeated = false; - - while (true) + else { - sp_ = _m_eat_whitespace(sp_); - auto tk = read(); - if (token::number != tk && token::variable != tk && token::repeated != tk) - _m_throw_error("invalid array element"); + //When search the repeated. + bool repeated = false; - if (!repeated) + while (true) { - switch (tk) + sp_ = _m_eat_whitespace(sp_); + auto tk = read(); + if (token::number != tk && token::variable != tk && token::repeated != tk) + _m_throw_error("invalid array element"); + + if (!repeated) { - case token::number: - array_.push_back(number_); - break; - case token::variable: - array_.push_back({}); - break; - default: - repeated = true; - reparray_.repeated(); - reparray_.assign(std::move(array_)); + switch (tk) + { + case token::number: + array_.push_back(number_); + break; + case token::variable: + array_.push_back({}); + break; + default: + repeated = true; + reparray_.repeated(); + reparray_.assign(std::move(array_)); + } } + + sp_ = _m_eat_whitespace(sp_); + char ch = *sp_++; + + if (ch == ']') + return (repeated ? token::reparray : token::array); + + if (ch != ',') + _m_throw_error("invalid array"); } - - sp_ = _m_eat_whitespace(sp_); - char ch = *sp_++; - - if (ch == ']') - return (repeated ? token::reparray : token::array); - - if (ch != ',') - _m_throw_error("invalid array"); } - } - break; + break; case '(': parameters_.clear(); sp_ = _m_eat_whitespace(sp_ + 1); @@ -497,7 +209,7 @@ namespace nana return token::number; } else - _m_throw_error(*sp_); + _m_throw_error("invalid character '" + std::string(1, *sp_) + "'"); break; default: if ('0' <= *sp_ && *sp_ <= '9') @@ -532,6 +244,8 @@ namespace nana case 'a': return token::max_px; } } + else if ("dock" == idstr_) + return token::dock; else if ("vertical" == idstr_ || "vert" == idstr_) return token::vert; else if ("variable" == idstr_ || "repeated" == idstr_) @@ -556,10 +270,24 @@ namespace nana _m_throw_error("a parameter list is required after 'collapse'"); return token::collapse; } + else if ("left" == idstr_ || "right" == idstr_ || "top" == idstr_ || "bottom" == idstr_) + { + switch (idstr_.front()) + { + case 'l': return token::left; + case 'r': return token::right; + case 't': return token::top; + case 'b': return token::bottom; + } + } return token::identifier; } - _m_throw_error(*sp_); + std::string err = "an invalid character '"; + err += *sp_; + err += "'"; + + _m_throw_error(err); return token::error; //Useless, just for syntax correction. } private: @@ -570,7 +298,7 @@ namespace nana str += '\''; _m_throw_error(str); } - + void _m_throw_error(const std::string& err) { std::stringstream ss; @@ -583,7 +311,7 @@ namespace nana if (token::equal != read()) _m_throw_error("an equal sign is required after '" + idstr_ + "'"); - const char* p = _m_eat_whitespace(sp_); + auto p = _m_eat_whitespace(sp_); auto neg_ptr = p; if ('-' == *p) @@ -696,29 +424,44 @@ namespace nana }; //end class tokenizer } - //struct implement struct place::implement { - class field_impl; + class field_gather; + class field_dock; + class division; class div_arrange; class div_grid; class div_splitter; + class div_dock; + class div_dockpane; window window_handle{nullptr}; event_handle event_size_handle{nullptr}; std::unique_ptr root_division; - std::map fields; + std::map fields; + std::map docks; + + //A temporary pointer used to refer to a specified div object which + //will be deleted in modification process. + std::unique_ptr tmp_replaced; //The following functions are defined behind the definition of class division. //because the class division here is an incomplete type. ~implement(); + + void collocate(); + static division * search_div_name(division* start, const std::string&); std::unique_ptr scan_div(place_parts::tokenizer&); + void check_unique(const division*) const; + + //connect the field/dock with div object + void connect(division* start); }; //end struct implement - class place::implement::field_impl + class place::implement::field_gather : public place::field_interface { public: @@ -732,11 +475,11 @@ namespace nana {} }; - field_impl(place * p) + field_gather(place * p) : place_ptr_(p) {} - ~field_impl() + ~field_gather() { for (auto & e : elements) API::umake_event(e.evt_destroy); @@ -778,7 +521,7 @@ namespace nana { return API::events(wd).destroy.connect([this, wd](const arg_destroy& arg) { - if (erase_element(elements, arg.window_handle)) + for (auto i = elements.begin(), end = elements.end(); i != end; ++i) { if (!API::is_destroying(API::get_parent_window(wd))) place_ptr_->collocate(); @@ -840,12 +583,22 @@ namespace nana std::vector fastened; private: place * place_ptr_; - };//end class field_impl + };//end class field_gather + + class place::implement::field_dock + { + + public: + div_dockpane * attached{ nullptr }; //attached div object + place_parts::dockarea dockarea; //the dockable widget + };//end class field_dock + + class place::implement::division { public: - enum class kind{ arrange, vertical_arrange, grid, splitter }; + enum class kind{ arrange, vertical_arrange, grid, splitter, dock, dockpane}; division(kind k, std::string&& n) : kind_of_division(k), @@ -879,6 +632,50 @@ namespace nana _m_visible_for_child(this, dsp); visible = dsp; display = dsp; + + if (kind::splitter != kind_of_division) + { + //Don't display the previous one, if it is a splitter + auto div = previous(); + if (div && (kind::splitter == div->kind_of_division)) + { + if (dsp) + { + auto leaf = div->previous(); + if (leaf && leaf->display) + div->set_display(true); + } + else + div->set_display(false); + } + + //Don't display the next one, if it is a splitter + if (div_next && (kind::splitter == div_next->kind_of_division)) + { + if (dsp) + { + auto leaf = div_next->div_next; + if (leaf && leaf->display) + div_next->set_display(true); + } + else + div_next->set_display(false); + } + } + else + { + //This is a splitter, it only checks when it is being displayed + if (dsp) + { + auto left = this->previous(); + if (left && !left->display) + left->set_display(true); + + auto right = div_next; + if (right && !right->display) + right->set_display(true); + } + } } bool is_back(const division* div) const @@ -924,6 +721,18 @@ namespace nana { return margin.area(field_area); } + + division * previous() const + { + if (div_owner) + { + for (auto & child : div_owner->children) + if (child->div_next == this) + return child.get(); + } + return nullptr; + + } public: void _m_visible_for_child(division * div, bool vsb) { @@ -943,21 +752,22 @@ namespace nana kind kind_of_division; bool display{ true }; bool visible{ true }; - const std::string name; + ::nana::direction dir{::nana::direction::west}; + std::string name; std::vector> children; - nana::rectangle field_area; + ::nana::rectangle field_area; number_t weight; number_t min_px, max_px; place_parts::margin margin; place_parts::repeated_array gap; - field_impl * field; + field_gather * field; division * div_next, *div_owner; };//end class division template - void place::implement::field_impl::_m_for_each(division * div, Function fn) + void place::implement::field_gather::_m_for_each(division * div, Function fn) { for (auto & up : div->children) //The element of children is unique_ptr fn(up.get()); @@ -1503,23 +1313,28 @@ namespace nana class place::implement::div_splitter : public division { + struct div_block + { + division * div; + int pixels; + double scale; + + div_block(division* d, int px) + : div(d), pixels(px) + {} + }; + enum{splitter_px = 4}; public: div_splitter(place_parts::number_t init_weight) : division(kind::splitter, std::string()), splitter_cursor_(cursor::arrow), - leaf_left_(nullptr), leaf_right_(nullptr), pause_move_collocate_(false), init_weight_(init_weight) { this->weight.assign(splitter_px); } - void set_leaf(bool is_left, division * d) - { - (is_left ? leaf_left_ : leaf_right_) = d; - } - void direction(bool horizontal) { splitter_cursor_ = (horizontal ? cursor::size_we : cursor::size_ns); @@ -1546,8 +1361,8 @@ namespace nana auto px_ptr = &nana::rectangle::width; //Use field_area of leaf, not margin_area. Otherwise splitter would be at wrong position - auto area_left = leaf_left_->field_area; - auto area_right = leaf_right_->field_area; + auto area_left = _m_leaf_left()->field_area; + auto area_right = _m_leaf_right()->field_area; if (nana::cursor::size_we != splitter_cursor_) { @@ -1582,9 +1397,10 @@ namespace nana else if (left_px < 0) left_px = 0; + auto leaf_left = _m_leaf_left(); double imd_rate = 100.0 / area_px; - left_px = static_cast(limit_px(leaf_left_, left_px, area_px)); - leaf_left_->weight.assign_percent(imd_rate * left_px); + left_px = static_cast(limit_px(_m_leaf_left(), left_px, area_px)); + _m_leaf_left()->weight.assign_percent(imd_rate * left_px); auto right_px = static_cast(right_pixels_)-delta; if (right_px > total_pixels) @@ -1592,15 +1408,15 @@ namespace nana else if (right_px < 0) right_px = 0; - right_px = static_cast(limit_px(leaf_right_, right_px, area_px)); - leaf_right_->weight.assign_percent(imd_rate * right_px); + right_px = static_cast(limit_px(_m_leaf_right(), right_px, area_px)); + _m_leaf_right()->weight.assign_percent(imd_rate * right_px); pause_move_collocate_ = true; div_owner->collocate(splitter_.parent()); //After the collocating, the splitter keeps the calculated weight of left division, //and clear the weight of right division. - leaf_right_->weight.reset(); + _m_leaf_right()->weight.reset(); pause_move_collocate_ = false; }); @@ -1612,10 +1428,12 @@ namespace nana { const bool vert = (::nana::cursor::size_we != splitter_cursor_); - rectangle_rotator left(vert, leaf_left_->field_area); - rectangle_rotator right(vert, leaf_right_->field_area); + auto leaf_left = _m_leaf_left(); + auto leaf_right = _m_leaf_right(); + rectangle_rotator left(vert, leaf_left->field_area); + rectangle_rotator right(vert, leaf_right->field_area); auto area_px = right.right() - left.x(); - auto right_px = static_cast(limit_px(leaf_right_, init_weight_.get_value(area_px), static_cast(area_px))); + auto right_px = static_cast(limit_px(leaf_right, init_weight_.get_value(area_px), static_cast(area_px))); auto pos = area_px - right_px - splitter_px; //New position of splitter if (pos < limited_range.x()) @@ -1623,7 +1441,7 @@ namespace nana else if (pos > limited_range.right()) pos = limited_range.right(); - nana::rectangle_rotator sp_r(vert, field_area); + rectangle_rotator sp_r(vert, field_area); sp_r.x_ref() = pos; left.w_ref() = static_cast(pos - left.x()); @@ -1633,17 +1451,17 @@ namespace nana right.w_ref() = static_cast(right_pos - pos - splitter_px); field_area = sp_r.result(); - leaf_left_->field_area = left.result(); - leaf_right_->field_area = right.result(); - leaf_left_->collocate(wd); - leaf_right_->collocate(wd); + leaf_left->field_area = left.result(); + leaf_right->field_area = right.result(); + leaf_left->collocate(wd); + leaf_right->collocate(wd); //Set the leafs' weight rectangle_rotator area(vert, div_owner->field_area); double imd_rate = 100.0 / static_cast(area.w()); - leaf_left_->weight.assign_percent(imd_rate * static_cast(left.w())); - leaf_right_->weight.assign_percent(imd_rate * static_cast(right.w())); + leaf_left->weight.assign_percent(imd_rate * static_cast(left.w())); + leaf_right->weight.assign_percent(imd_rate * static_cast(right.w())); splitter_.move(this->field_area); @@ -1654,40 +1472,53 @@ namespace nana splitter_.move(this->field_area); } private: + division * _m_leaf_left() const + { + return previous(); + } + + division * _m_leaf_right() const + { + return div_next; + } + rectangle_rotator _m_update_splitter_range() { const bool vert = (cursor::size_ns == splitter_cursor_); rectangle_rotator area(vert, div_owner->margin_area()); - rectangle_rotator left(vert, leaf_left_->field_area); - rectangle_rotator right(vert, leaf_right_->field_area); + auto leaf_left = _m_leaf_left(); + auto leaf_right = _m_leaf_right(); + + rectangle_rotator left(vert, leaf_left->field_area); + rectangle_rotator right(vert, leaf_right->field_area); const int left_base = left.x(), right_base = right.right(); int pos = left_base; int endpos = right_base; - if (leaf_left_->min_px.is_not_none()) + if (leaf_left->min_px.is_not_none()) { - auto v = leaf_left_->min_px.get_value(area.w()); + auto v = leaf_left->min_px.get_value(area.w()); pos += static_cast(v); } - if (leaf_left_->max_px.is_not_none()) + if (leaf_left->max_px.is_not_none()) { - auto v = leaf_left_->max_px.get_value(area.w()); + auto v = leaf_left->max_px.get_value(area.w()); endpos = left_base + static_cast(v); } - if (leaf_right_->min_px.is_not_none()) + if (leaf_right->min_px.is_not_none()) { - auto v = leaf_right_->min_px.get_value(area.w()); + auto v = leaf_right->min_px.get_value(area.w()); auto x = right_base - static_cast(v); if (x < endpos) endpos = x; } - if (leaf_right_->max_px.is_not_none()) + if (leaf_right->max_px.is_not_none()) { - auto v = leaf_right_->max_px.get_value(area.w()); + auto v = leaf_right->max_px.get_value(area.w()); auto x = right_base - static_cast(v); if (x > pos) pos = x; @@ -1702,10 +1533,9 @@ namespace nana } private: nana::cursor splitter_cursor_; + bool created_{ false }; place_parts::splitter splitter_; nana::point begin_point_; - division * leaf_left_; - division * leaf_right_; int left_pos_, right_pos_; unsigned left_pixels_, right_pixels_; dragger dragger_; @@ -1713,12 +1543,372 @@ namespace nana place_parts::number_t init_weight_; }; + class place::implement::div_dockpane + : public division, public place_parts::dock_notifier_interface + { + public: + div_dockpane(std::string && name, implement* impl, direction pane_dir) + : division(kind::dockpane, std::move(name)), + impl_ptr_{impl} + { + dir = pane_dir; + } + + ~div_dockpane() + { + if (dockable_field) + { + dockable_field->dockarea.close(); + dockable_field->attached = nullptr; + } + } + + void collocate(window wd) override + { + if (!dockable_field) + { + // + if (name.empty()) + return; + + auto &dock_ptr = impl_ptr_->docks[name]; + if (!dock_ptr) + dock_ptr = new field_dock; + + dock_ptr->attached = this; + dockable_field = dock_ptr; + } + + auto & dockarea = dockable_field->dockarea; + if (!created_) + { + created_ = true; + dockarea.create(wd, this); + } + + + if (!dockarea.empty() && !dockarea.floating()) + { + dockarea.move(this->field_area); + indicator_.r = this->field_area; + } + } + private: + //Implement dock_notifier_interface + void notify_float() override + { + set_display(false); + + impl_ptr_->collocate(); + } + + void notify_dock() override + { + indicator_.docker.reset(); + set_display(true); + impl_ptr_->collocate(); + } + + void notify_move() override + { + if (!_m_indicator()) + { + indicator_.docker.reset(); + return; + } + + if (!indicator_.docker) + { + auto host_size = API::window_size(impl_ptr_->window_handle); + indicator_.docker.reset(new form(impl_ptr_->window_handle, { static_cast(host_size.width) / 2 - 16, static_cast(host_size.height) / 2 - 16, 32, 32 }, form::appear::bald<>())); + drawing dw(indicator_.docker->handle()); + dw.draw([](paint::graphics& graph) + { + graph.rectangle(false, colors::midnight_blue); + graph.rectangle({ 1, 1, 30, 30 }, true, colors::light_sky_blue); + + facade arrow; + arrow.direction(::nana::direction::south); + arrow.draw(graph, colors::light_sky_blue, colors::midnight_blue, { 12, 0, 16, 16 }, element_state::normal); + + rectangle r{ 4, 16, 24, 11 }; + graph.rectangle(r, true, colors::midnight_blue); + + r.x = 5; + r.y = 19; + r.width = 22; + r.height = 7; + graph.rectangle(r, true, colors::button_face); + }); + + indicator_.docker->z_order(nullptr, ::nana::z_order_action::topmost); + indicator_.docker->show(); + + indicator_.docker->events().destroy([this] + { + if (indicator_.dock_area) + { + indicator_.dock_area.reset(); + indicator_.graph.release(); + } + }); + } + + if (_m_dockable()) + { + if (!indicator_.dock_area) + { + indicator_.graph.make(API::window_size(impl_ptr_->window_handle)); + API::window_graphics(impl_ptr_->window_handle, indicator_.graph); + + indicator_.dock_area.reset(new panel(impl_ptr_->window_handle, false)); + indicator_.dock_area->move(indicator_.r); + + ::nana::drawing dw(indicator_.dock_area->handle()); + dw.draw([this](paint::graphics& graph) + { + indicator_.graph.paste(indicator_.r, graph, 0, 0); + + const int border_px = 4; + rectangle r{ graph.size() }; + int right = r.right(); + int bottom = r.bottom(); + + graph.blend(r.pare_off(border_px), colors::blue, 0.3); + + ::nana::color clr = colors::deep_sky_blue; + r.y = 0; + r.height = border_px; + graph.blend(r, clr, 0.5); + r.y = bottom - border_px; + graph.blend(r, clr, 0.5); + + r.x = r.y = 0; + r = graph.size(); + r.width = border_px; + graph.blend(r, clr, 0.5); + r.x = right - border_px; + graph.blend(r, clr, 0.5); + + }); + + //indicator_.dock_area->z_order(nullptr, ::nana::z_order_action::top); //deprecated + API::bring_top(indicator_.dock_area->handle(), false); + indicator_.dock_area->show(); + } + } + else + { + if (indicator_.dock_area) + { + indicator_.dock_area.reset(); + indicator_.graph.release(); + } + } + + } + + void notify_move_stopped() + { + if (_m_dockable() && dockable_field) + dockable_field->dockarea.dock(); + + indicator_.docker.reset(); + } + private: + bool _m_indicator() const + { + ::nana::point pos; + API::calc_screen_point(impl_ptr_->window_handle, pos); + + rectangle r{ pos, API::window_size(impl_ptr_->window_handle) }; + return r.is_hit(API::cursor_position()); + } + + bool _m_dockable() const + { + if (!indicator_.docker) + return false; + + ::nana::point pos; + API::calc_screen_point(indicator_.docker->handle(), pos); + + rectangle r{ pos, API::window_size(indicator_.docker->handle()) }; + return r.is_hit(API::cursor_position()); + } + public: + field_dock * dockable_field{ nullptr }; + private: + implement * impl_ptr_; + bool created_{ false }; + + struct indicator_tag + { + paint::graphics graph; + //panel widget; + rectangle r; + std::unique_ptr> dock_area; + std::unique_ptr
docker; + }indicator_; + }; + + class place::implement::div_dock + : public division + { + public: + div_dock(std::string && name, implement* impl) + : division(kind::dock, std::move(name)) + {} + + void collocate(window wd) override + { + auto area = this->margin_area(); + + unsigned vert_count = 0, horz_count = 0; + unsigned vert_weight = 0, horz_weight = 0; + + bool prev_attr = _m_is_vert(children.front()->dir); + (prev_attr ? horz_count : vert_count) = 1; + + for (auto & child : children) + { + auto is_vert = _m_is_vert(child->dir); + + if (child->weight.is_not_none()) + { + if (is_vert) + vert_weight += static_cast(child->weight.get_value(area.height)); + else + horz_weight += static_cast(child->weight.get_value(area.width)); + } + + if (is_vert == prev_attr) + { + if (is_vert) + ++vert_count; + else + ++horz_count; + } + else + { + if (is_vert) + ++horz_count; + else + ++vert_count; + } + prev_attr = is_vert; + } + if (0 == vert_count) + ++vert_count; + if (0 == horz_count) + ++horz_count; + + double auto_horz_w = double(area.width - horz_weight) / horz_count; + double auto_vert_w = double(area.height - vert_weight) / vert_count; + + double left = area.x; + double right = area.right(); + double top = area.y; + double bottom = area.bottom(); + + for (auto & child : children) + { + double weight; + if (child->weight.is_not_none()) + weight = child->weight.get_value(_m_is_vert(child->dir) ? area.height : area.height); + else + weight = (_m_is_vert(child->dir) ? auto_vert_w : auto_horz_w); + + ::nana::rectangle child_r; + switch (child->dir) + { + default: + case ::nana::direction::west: + child_r.x = static_cast(left); + child_r.y = static_cast(top); + child_r.width = static_cast(weight); + child_r.height = static_cast(bottom - top); + left += weight; + break; + case ::nana::direction::east: + right -= weight; + child_r.x = static_cast(right); + child_r.y = static_cast(top); + child_r.width = static_cast(weight); + child_r.height = static_cast(bottom - top); + break; + case ::nana::direction::north: + child_r.x = static_cast(left); + child_r.y = static_cast(top); + child_r.width = static_cast(right - left); + child_r.height = static_cast(weight); + top += weight; + break; + case ::nana::direction::south: + child_r.x = static_cast(left); + bottom -= weight; + child_r.y = static_cast(bottom); + child_r.width = static_cast(right - left); + child_r.height = static_cast(weight); + break; + } + + child->field_area = child_r; + child->collocate(wd); + } + } + private: + static bool _m_is_vert(::nana::direction dir) + { + return (dir == ::nana::direction::north || dir == ::nana::direction::south); + } + }; + place::implement::~implement() { API::umake_event(event_size_handle); root_division.reset(); + for (auto & pair : fields) delete pair.second; + + for (auto & dock : docks) + delete dock.second; + } + + void place::implement::collocate() + { + if (root_division && window_handle) + { + root_division->field_area = API::window_size(window_handle); + + if (root_division->field_area.empty()) + return; + + root_division->collocate(window_handle); + + for (auto & field : fields) + { + bool is_show = false; + if (field.second->attached && field.second->attached->visible && field.second->attached->display) + { + is_show = true; + auto div = field.second->attached->div_owner; + while (div) + { + if (!div->visible || !div->display) + { + is_show = false; + break; + } + div = div->div_owner; + } + } + + for (auto & el : field.second->elements) + API::show_window(el.handle, is_show); + } + } } //search_div_name @@ -1755,18 +1945,24 @@ namespace nana std::vector array; std::vector collapses; std::vector> children; + ::nana::direction div_dir = ::nana::direction::west; for (token tk = tknizer.read(); tk != token::eof; tk = tknizer.read()) { bool exit_for = false; switch (tk) { + case token::dock: + if (token::eof != div_type && token::dock != div_type) + throw std::invalid_argument("nana.place: conflict of div type at " + tknizer.pos_str()); + + div_type = token::dock; + break; case token::splitter: //Ignore the splitter when there is not a division. if (!children.empty() && (division::kind::splitter != children.back()->kind_of_division)) { auto splitter = new div_splitter(tknizer.number()); - splitter->set_leaf(true, children.back().get()); children.back()->div_next = splitter; children.emplace_back(splitter); } @@ -1774,12 +1970,9 @@ namespace nana case token::div_start: { auto div = scan_div(tknizer); - if (children.size()) - { + if (!children.empty()) children.back()->div_next = div.get(); - if (division::kind::splitter == children.back()->kind_of_division) - dynamic_cast(*children.back()).set_leaf(false, div.get()); - } + children.emplace_back(div.release()); } break; @@ -1815,7 +2008,7 @@ namespace nana else if (arg.kind_of() == number_t::kind::real) return static_cast(arg.real()); - throw std::runtime_error("place: the type of the "+ nth +" parameter for collapse should be integer."); + throw std::invalid_argument("nana.place: the type of the "+ nth +" parameter for collapse should be integer."); }; ::nana::rectangle col; @@ -1851,7 +2044,7 @@ namespace nana } } else - throw std::runtime_error("place: collapse requires 4 parameters."); + throw std::invalid_argument("nana.place: collapse requires 4 parameters."); break; case token::weight: case token::min_px: case token::max_px: { @@ -1904,13 +2097,22 @@ namespace nana case token::identifier: name = tknizer.idstr(); break; + case token::left: + div_dir = ::nana::direction::west; break; + case token::right: + div_dir = ::nana::direction::east; break; + case token::top: + div_dir = ::nana::direction::north; break; + case token::bottom: + div_dir = ::nana::direction::south; break; default: break; } if (exit_for) break; } - field_impl * attached_field = nullptr; + field_gather * attached_field = nullptr; + field_dock* attached_dock = nullptr; if (name.size()) { //find the field with specified name. @@ -1951,8 +2153,16 @@ namespace nana div = std::move(p); } break; + case token::dock: + //deprecated + // + //if (name.empty()) + // throw std::invalid_argument("nana.place: dock must have a name."); + + div.reset(new div_dock(std::move(name), this)); + break; default: - throw std::runtime_error("nana.place: invalid division type."); + throw std::invalid_argument("nana.place: invalid division type."); } //Requirements for min/max @@ -1999,13 +2209,123 @@ namespace nana if (division::kind::splitter == child->kind_of_division) dynamic_cast(*child).direction(div_type != token::vert); } + + if (token::dock == div_type) + { + //adjust these children for dock division + std::vector> adjusted_children; + for (auto & child : children) + { + adjusted_children.emplace_back(new div_dockpane(std::move(child->name), this, child->dir)); + } + + children.swap(adjusted_children); + } } div->children.swap(children); div->margin = std::move(margin); + div->dir = div_dir; return div; } + void place::implement::check_unique(const division* div) const + { + //The second field_impl is useless. Reuse the map type in order to + //reduce the size of the generated code, becuase std::set + //will create a new template class. + std::map unique; + field_gather tmp(nullptr); + + std::function check_fn; + check_fn = [&check_fn, &unique, &tmp](const implement::division* div) + { + if (!div->name.empty()) + { + auto & ptr = unique[div->name]; + if (ptr) + throw std::invalid_argument("place, the name '" + div->name + "' is redefined."); + ptr = &tmp; + } + + for (auto & child : div->children) + { + check_fn(child.get()); + } + }; + + if (div) + check_fn(div); + } + + //connect the field/dock with div object, + void place::implement::connect(division* start) + { + if (!start) + return; + + //disconnect + for (auto & fd : fields) + { + if (fd.second->attached) + { + fd.second->attached->field = nullptr; + fd.second->attached = nullptr; + } + } + + std::map docks_to_be_closed; + //disconnect + for (auto & dk : docks) + { + if (dk.second->attached) + docks_to_be_closed[dk.first] = dk.second; + } + + std::function check_fn; + check_fn = [&check_fn, this, &docks_to_be_closed](division* div) + { + if (div->name.size()) + { + if (division::kind::dock == div->kind_of_division) + { + auto i = docks.find(div->name); + if (i != docks.end()) + { + docks_to_be_closed.erase(div->name); + auto pane = dynamic_cast(div); + pane->dockable_field = i->second; + pane->dockable_field->attached = pane; + } + } + else + { + auto i = fields.find(div->name); + if (i != fields.end()) + { + div->field = i->second; + div->field->attached = div; + } + } + + } + + for (auto & child : div->children) + { + check_fn(child.get()); + } + }; + + check_fn(start); + + for (auto& e : docks_to_be_closed) + { + e.second->dockarea.close(); + e.second->attached->dockable_field = nullptr; + e.second->attached = nullptr; + } + } + //class place place::place() : impl_(new implement) @@ -2046,8 +2366,141 @@ namespace nana void place::div(const char* s) { place_parts::tokenizer tknizer(s); - impl_->root_division.reset(); //clear atachments div-fields - impl_->scan_div(tknizer).swap(impl_->root_division); + auto div = impl_->scan_div(tknizer); + try + { + impl_->check_unique(div.get()); //may throw if there is a redefined name of field. + impl_->connect(div.get()); + impl_->root_division.reset(); //clear atachments div-fields + impl_->root_division.swap(div); + } + catch (...) + { + //redefined a name of field + throw; + } + } + + void place::modify(const char* name, const char* div_text) + { + if (nullptr == div_text) + throw std::invalid_argument("nana.place: invalid div-text"); + + if (nullptr == name) name = ""; + + //check the name, it throws std::invalid_argument + //if name violate the naming convention. + place_parts::check_field_name(name); + + /* //deprecated + implement::division * div_ptr = nullptr; + implement::field_gather * field_ptr = nullptr; + { + auto i = impl_->fields.find(name); + if (i != impl_->fields.end()) + field_ptr = i->second; + } + + if (field_ptr) + { + //remove the existing div object + div_ptr = field_ptr->attached; + } + else + div_ptr = impl_->search_div_name(impl_->root_division.get(), name); + + if (nullptr == div_ptr) + { + std::string what = "nana::place: field '"; + what += name; + what += "' is not found."; + + throw std::invalid_argument(what); + } + */ + + auto div_ptr = impl_->search_div_name(impl_->root_division.get(), name); + if (!div_ptr) + { + std::string what = "nana::place: field '"; + what += name; + what += "' is not found."; + + throw std::invalid_argument(what); + } + + + std::unique_ptr* replaced = nullptr; + + implement::division * div_owner = div_ptr->div_owner; + implement::division * div_next = div_ptr->div_next; + implement::division * div_bro = nullptr; + if (div_owner) + { + for (auto i = div_owner->children.begin(); i != div_owner->children.end(); ++i) + { + if (i->get() == div_ptr) + { + replaced = &(*i); + break; + } + div_bro = i->get(); + } + } + else + replaced = &(impl_->root_division); + + replaced->swap(impl_->tmp_replaced); + + try + { + place_parts::tokenizer tknizer(div_text); + auto modified = impl_->scan_div(tknizer); + auto modified_ptr = modified.get(); + modified_ptr->name = name; + //modified_ptr->field = field_ptr; + + replaced->swap(modified); + + impl_->check_unique(impl_->root_division.get()); + impl_->connect(impl_->root_division.get()); + impl_->tmp_replaced.reset(); + + modified_ptr->div_owner = div_owner; + modified_ptr->div_next = div_next; + //if (field_ptr) + // field_ptr->attached = modified_ptr; + /* + std::function attach; + attach = [this, &attach](implement::division* div) + { + if (!div->name.empty()) + { + auto i = impl_->fields.find(div->name); + if (impl_->fields.end() != i) + { + if (i->second->attached != div) + { + i->second->attached = div; + div->field = i->second; + } + } + } + + for (auto& child : div->children) + { + attach(child.get()); + } + }; + + attach(impl_->root_division.get()); + */ + } + catch (...) + { + replaced->swap(impl_->tmp_replaced); + throw; + } } place::field_reference place::field(const char* name) @@ -2055,14 +2508,15 @@ namespace nana if (nullptr == name) name = ""; - //May throw std::invalid_argument + //check the name, it throws std::invalid_argument + //if name violate the naming convention. place_parts::check_field_name(name); //get the field with specified name, if no such field with specified name //then create one. auto & p = impl_->fields[name]; if (nullptr == p) - p = new implement::field_impl(this); + p = new implement::field_gather(this); if ((!p->attached) && impl_->root_division) { @@ -2129,33 +2583,7 @@ namespace nana void place::collocate() { - if (impl_->root_division && impl_->window_handle) - { - impl_->root_division->field_area = API::window_size(impl_->window_handle); - impl_->root_division->collocate(impl_->window_handle); - - for (auto & field : impl_->fields) - { - bool is_show = false; - if (field.second->attached && field.second->attached->visible && field.second->attached->display) - { - is_show = true; - auto div = field.second->attached->div_owner; - while (div) - { - if (!div->visible || !div->display) - { - is_show = false; - break; - } - div = div->div_owner; - } - } - - for (auto & el : field.second->elements) - API::show_window(el.handle, is_show); - } - } + impl_->collocate(); } void place::erase(window handle) @@ -2170,7 +2598,7 @@ namespace nana recollocate |= (nullptr != fld.second->attached); } - API::umake_event( fld.second->erase_element(fld.second->fastened, handle)); + API::umake_event(fld.second->erase_element(fld.second->fastened, handle)); } if (recollocate) @@ -2181,5 +2609,25 @@ namespace nana { return field(name); } + + void place::dock(const std::string& name, std::function(window)> factory) + { + //check the name, it throws std::invalid_argument + //if name violate the naming convention. + place_parts::check_field_name(name.data()); + + auto & dock_ptr = impl_->docks[name]; + if (!dock_ptr) + dock_ptr = new implement::field_dock; + + dock_ptr->dockarea.add_factory(std::move(factory)); + + auto div = dynamic_cast(impl_->search_div_name(impl_->root_division.get(), name)); + if (div) + { + dock_ptr->attached = div; + div->dockable_field = dock_ptr; + } + } //end class place }//end namespace nana diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 6a64dc2d..94ca4fe4 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -538,11 +538,11 @@ namespace API return nana::point{}; } - void move_window(window wd, int x, int y) + void move_window(window wd, const point& pos) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.move(iwd, x, y, false)) + if(restrict::window_manager.move(iwd, pos.x, pos.y, false)) { restrict::core_window_t* update_wd = nullptr; if (iwd->displayed() && iwd->effect.bground) diff --git a/source/gui/widgets/widget.cpp b/source/gui/widgets/widget.cpp index af853b38..c7ecc667 100644 --- a/source/gui/widgets/widget.cpp +++ b/source/gui/widgets/widget.cpp @@ -305,7 +305,7 @@ namespace nana void widget::_m_move(int x, int y) { - API::move_window(handle(), x, y); + API::move_window(handle(), { x, y }); } void widget::_m_move(const rectangle& r) From 2a53467b24527616c66ec1a4664a81eb957ac656 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 14 Aug 2015 04:13:16 +0800 Subject: [PATCH 02/65] add missing header for docker-place --- source/gui/place_parts.hpp | 563 +++++++++++++++++++++++++++++++++++++ 1 file changed, 563 insertions(+) create mode 100644 source/gui/place_parts.hpp diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp new file mode 100644 index 00000000..3a1b670e --- /dev/null +++ b/source/gui/place_parts.hpp @@ -0,0 +1,563 @@ +/* + * Parts of Class Place + * Nana C++ Library(http://www.nanapro.org) + * Copyright(C) 2003-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/place_parts.hpp + */ +#ifndef NANA_GUI_PLACE_PARTS_HPP +#define NANA_GUI_PLACE_PARTS_HPP + +#include +#include +#include +#include +#include + +namespace nana +{ + namespace place_parts + { + class splitter_interface + { + public: + virtual ~splitter_interface(){} + }; + + class splitter_dtrigger + : public drawer_trigger + { + }; + + template + class splitter + : public widget_object ::type, splitter_dtrigger>, + public splitter_interface + { + private: + void _m_complete_creation() override + { + this->caption("place-splitter"); + widget_object ::type, splitter_dtrigger>::_m_complete_creation(); + } + }; + + + class dock_notifier_interface + { + public: + virtual ~dock_notifier_interface() = default; + + virtual void notify_float() = 0; + virtual void notify_dock() = 0; + virtual void notify_move() = 0; + virtual void notify_move_stopped() = 0; + }; + + class dockcaption_dtrigger + : public drawer_trigger + { + public: + private: + virtual void attached(widget_reference, graph_reference graph) override + { + graph.set_color(colors::slate_blue); + graph.set_text_color(colors::white); + } + + void refresh(graph_reference& graph) override + { + graph.rectangle(true, colors::red); + + ::nana::rectangle r{ graph.size() }; + + r.x = r.right() - 20; + r.y = (r.height - 16) / 2; + r.width = r.height = 16; + + button_.draw(graph, colors::red, colors::white, r, element_state::normal); + x_icon_.draw(graph, colors::red, colors::white, r, element_state::normal); + } + public: + ::nana::string caption; + facade button_; + facade x_icon_; + }; + + class dockarea_caption + : public widget_object < category::widget_tag, dockcaption_dtrigger > + {}; + + class dock_page + : public form + { + public: + dock_page(window host, const rectangle& r, const rectangle & tab_r) + : form(host, r, form::appear::bald<>()) + { + tab_form_.reset(new form(handle(), tab_r, form::appear::bald<>())); + + } + private: + std::unique_ptr tab_form_; + }; + + class dockarea + : public widget_object + { + using base_type = widget_object; + + using factory = std::function(window)>; + + struct panel + { + factory factory_fn; + std::unique_ptr widget_ptr; + + panel(factory && fn) + : factory_fn(std::move(fn)) + {} + }; + public: + void create(window parent, place_parts::dock_notifier_interface* notifier) + { + notifier_ = notifier; + host_window_ = parent; + base_type::create(parent, true); + this->caption("dockarea"); + caption_.create(*this, true); + caption_.caption("dockarea-caption"); + + this->events().resized([this](const arg_resized& arg) + { + rectangle r{ 0, 0, arg.width, 20 }; + caption_.move(r); + + if (arg.height > 20) + { + r.y = 20; + if (tabbar_) + { + tabbar_->move({ 0, int(arg.height) - 20, arg.width, 20 }); + r.height = arg.height - 40; + } + else + r.height = arg.height - 20; + } + + + for (auto & pn : panels_) + { + if (pn.widget_ptr) + pn.widget_ptr->move(r); + } + }); + + caption_.events().mouse_down([this](const arg_mouse& arg) + { + if (::nana::mouse::left_button == arg.button) + { + moves_.started = true; + moves_.start_pos = API::cursor_position(); + moves_.start_container_pos = (floating() ? container_->pos() : this->pos()); + API::capture_window(caption_, true); + } + }); + + caption_.events().mouse_move([this](const arg_mouse& arg) + { + if (arg.left_button && moves_.started) + { + auto move_pos = API::cursor_position() - moves_.start_pos; + if (!floating()) + { + if (std::abs(move_pos.x) > 4 || abs(move_pos.y) > 4) + float_away(move_pos); + } + else + { + move_pos += moves_.start_container_pos; + API::move_window(container_->handle(), move_pos); + notifier_->notify_move(); + } + } + }); + + caption_.events().mouse_up([this](const arg_mouse& arg) + { + if ((::nana::mouse::left_button == arg.button) && moves_.started) + { + moves_.started = false; + API::capture_window(caption_, false); + notifier_->notify_move_stopped(); + } + }); + + if (panels_.size() > 1) + tabbar_.reset(new tabbar(*this)); + + std::size_t pos = 0; + for (auto & pn : panels_) + { + if (!pn.widget_ptr) + { + pn.widget_ptr = pn.factory_fn(*this); + if (tabbar_) + { + tabbar_->push_back(pn.widget_ptr->caption()); + tabbar_->relate(pos++, pn.widget_ptr->handle()); + } + } + } + } + + void add_factory(factory && fn) + { + panels_.emplace_back(std::move(fn)); + } + + void float_away(const ::nana::point& move_pos) + { + if (container_) + return; + + API::capture_window(caption_, false); + + rectangle r{ pos() + move_pos, size() }; + container_.reset(new form(host_window_, r.pare_off(-1), form::appear::bald<>())); + drawing dw(container_->handle()); + dw.draw([](paint::graphics& graph) + { + graph.rectangle(false, colors::coral); + }); + + API::set_parent_window(handle(), container_->handle()); + this->move({ 1, 1 }); + + container_->show(); + API::capture_window(caption_, true); + + notifier_->notify_float(); + } + + void dock() + { + API::capture_window(caption_, false); + API::set_parent_window(handle(), host_window_); + container_.reset(); + notifier_->notify_dock(); + } + + bool floating() const + { + return (nullptr != container_); + } + private: + window host_window_{nullptr}; + place_parts::dock_notifier_interface* notifier_{ nullptr }; + std::unique_ptr container_; + dockarea_caption caption_; + std::deque panels_; + std::unique_ptr> tabbar_; + + struct moves + { + bool started{ false }; + ::nana::point start_pos; + ::nana::point start_container_pos; + }moves_; + };//class dockarea + + + //number_t is used for storing a number type variable + //such as integer, real and percent. Essentially, percent is a typo of real. + class number_t + { + public: + enum class kind{ none, integer, real, percent }; + + number_t() + : kind_(kind::none) + { + value_.integer = 0; + } + + void reset() + { + kind_ = kind::none; + value_.integer = 0; + } + + bool is_negative() const + { + switch (kind_) + { + case kind::integer: + return (value_.integer < 0); + case kind::real: + case kind::percent: + return (value_.real < 0); + default: + break; + } + return false; + } + + bool is_none() const + { + return (kind::none == kind_); + } + + bool is_not_none() const + { + return (kind::none != kind_); + } + + kind kind_of() const + { + return kind_; + } + + double get_value(int ref_percent) const + { + switch (kind_) + { + case kind::integer: + return value_.integer; + case kind::real: + return value_.real; + case kind::percent: + return value_.real * ref_percent; + default: + break; + } + return 0; + } + + int integer() const + { + if (kind::integer == kind_) + return value_.integer; + return static_cast(value_.real); + } + + double real() const + { + if (kind::integer == kind_) + return value_.integer; + return value_.real; + } + + void assign(int i) + { + kind_ = kind::integer; + value_.integer = i; + } + + void assign(double d) + { + kind_ = kind::real; + value_.real = d; + } + + void assign_percent(double d) + { + kind_ = kind::percent; + value_.real = d / 100; + } + private: + kind kind_; + union valueset + { + int integer; + double real; + }value_; + };//end class number_t + + + class margin + { + public: + margin& operator=(margin&& rhs) + { + if (this != &rhs) + { + all_edges_ = rhs.all_edges_; + margins_ = std::move(rhs.margins_); + } + return *this; + } + + void clear() + { + all_edges_ = true; + margins_.clear(); + } + + void push(const number_t& v) + { + margins_.emplace_back(v); + } + + void set_value(const number_t& v) + { + clear(); + margins_.emplace_back(v); + } + + void set_array(const std::vector& v) + { + all_edges_ = false; + margins_ = v; + } + + nana::rectangle area(const ::nana::rectangle& field_area) const + { + if (margins_.empty()) + return field_area; + + auto r = field_area; + if (all_edges_) + { + auto px = static_cast(margins_.back().get_value(static_cast(r.width))); + const auto dbl_px = static_cast(px << 1); + r.x += px; + r.width = (r.width < dbl_px ? 0 : r.width - dbl_px); + + r.y += px; + r.height = (r.height < dbl_px ? 0 : r.height - dbl_px); + } + else + { + int il{ -1 }, ir{ -1 }, it{ -1 }, ib{ -1 }; //index of four corners in margin + switch (margins_.size()) + { + case 0: break; + case 1: //top + it = 0; + break; + case 2://top,bottom and left,right + it = ib = 0; + il = ir = 1; + break; + default: + il = 3; //left + case 3: //top, right, bottom + it = 0; + ir = 1; + ib = 2; + } + + typedef decltype(r.height) px_type; + auto calc = [](px_type a, px_type b) + { + return (a > b ? a - b : 0); + }; + + if (0 == it) //top + { + auto px = static_cast(margins_[it].get_value(static_cast(field_area.height))); + r.y += px; + r.height = calc(r.height, static_cast(px)); + } + + if (-1 != ib) //bottom + { + auto px = static_cast(margins_[ib].get_value(static_cast(field_area.height))); + r.height = calc(r.height, static_cast(px)); + } + + if (-1 != il) //left + { + auto px = static_cast(margins_[il].get_value(static_cast(field_area.width))); + r.x += px; + r.width = calc(r.width, static_cast(px)); + } + + if (-1 != ir) //right + { + auto px = static_cast(margins_[ir].get_value(static_cast(field_area.width))); + r.width = calc(r.width, static_cast(px)); + } + } + return r; + } + private: + bool all_edges_ = true; + std::vector margins_; + };//end class margin + + class repeated_array + { + public: + + //A workaround for VC2013, becuase it does not generated an implicit declared move-constructor as defaulted. + repeated_array() = default; + + repeated_array(repeated_array && other) + : repeated_{ other.repeated_ }, + values_(std::move(other.values_)) + { + } + + repeated_array& operator=(repeated_array&& other) + { + if (this != &other) + { + repeated_ = other.repeated_; + other.repeated_ = false; + values_ = std::move(other.values_); + } + return *this; + } + + void assign(std::vector&& c) + { + values_ = std::move(c); + } + + bool empty() const + { + return values_.empty(); + } + + void reset() + { + repeated_ = false; + values_.clear(); + } + + void repeated() + { + repeated_ = true; + } + + void push(const number_t& n) + { + values_.emplace_back(n); + } + + number_t at(std::size_t pos) const + { + if (values_.empty()) + return{}; + + if (repeated_) + pos %= values_.size(); + else if (pos >= values_.size()) + return{}; + + return values_[pos]; + } + private: + bool repeated_ = false; + std::vector values_; + }; + }//end namespace place_parts +}//end namespace nana + +#endif //NANA_GUI_PLACE_PARTS_HPP \ No newline at end of file From c859b86a3f8e2b3dcab3692f29b8829bc44f8957 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 15 Aug 2015 06:57:36 +0800 Subject: [PATCH 03/65] fix an issue of dock place --- include/nana/gui/place.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nana/gui/place.hpp b/include/nana/gui/place.hpp index 8faedf91..bd50bee7 100644 --- a/include/nana/gui/place.hpp +++ b/include/nana/gui/place.hpp @@ -129,10 +129,10 @@ namespace nana template void dock(const std::string& dockname, Args&& ... args) { - dock(dockname, std::bind([](window parent, Args && ... args) + dock(dockname, std::bind([](window parent, Args & ... args) { return std::unique_ptr(new Panel(parent, std::forward(args)...)); - }, std::placeholders::_1, std::forward(args)...)); + }, std::placeholders::_1, args...)); } void dock(const std::string& dockname, std::function(window)> factory); From 4323977908aeca47f7631cf004e81b4a61f9cd75 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 17 Aug 2015 01:37:56 +0800 Subject: [PATCH 04/65] change the implementation of pat::cloneable --- include/nana/gui/element.hpp | 43 ++++---- include/nana/gui/widgets/scroll.hpp | 2 +- include/nana/gui/widgets/tabbar.hpp | 2 +- include/nana/gui/widgets/treebox.hpp | 2 +- include/nana/pat/cloneable.hpp | 142 ++++++++++++++++++++------- source/gui/element.cpp | 43 +++++--- source/gui/widgets/categorize.cpp | 2 +- source/gui/widgets/checkbox.cpp | 2 +- source/gui/widgets/date_chooser.cpp | 2 +- source/gui/widgets/tabbar.cpp | 20 ++-- 10 files changed, 183 insertions(+), 77 deletions(-) diff --git a/include/nana/gui/element.hpp b/include/nana/gui/element.hpp index 9ffa721d..599aa87a 100644 --- a/include/nana/gui/element.hpp +++ b/include/nana/gui/element.hpp @@ -27,19 +27,35 @@ namespace nana namespace element { + namespace detail + { + class element_abstract + { + public: + using graph_reference = ::nana::paint::graphics&; + virtual ~element_abstract() = default; + }; + + class factory_abstract + { + public: + virtual ~factory_abstract() = default; + + virtual void destroy(element_abstract *); + }; + } + class element_interface + : public detail::element_abstract { public: - using graph_reference = paint::graphics&; - - virtual ~element_interface() = default; virtual bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state) = 0; }; class crook_interface + : public detail::element_abstract { public: - using graph_reference = paint::graphics&; using state = checkstate; struct data @@ -47,25 +63,21 @@ namespace nana state check_state; bool radio; }; - - virtual ~crook_interface() = default; + virtual bool draw(graph_reference, const nana::color& bgcolor, const nana::color& fgcolor, const nana::rectangle&, element_state, const data&) = 0; }; class border_interface + : public detail::element_abstract { public: - using graph_reference = paint::graphics&; - - virtual ~border_interface() = default; virtual bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state, unsigned weight) = 0; }; class arrow_interface + : public detail::element_abstract { public: - using graph_reference = paint::graphics&; - virtual ~arrow_interface() = default; virtual bool draw(graph_reference, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle&, element_state, direction) = 0; }; @@ -74,10 +86,10 @@ namespace nana public: template struct factory_interface + : public detail::factory_abstract { virtual ~factory_interface(){} virtual ElementInterface* create() const = 0; - virtual void destroy(ElementInterface*) const = 0; }; template @@ -85,17 +97,12 @@ namespace nana : public factory_interface { public: - typedef factory_interface interface_type; + using interface_type = factory_interface; ElementInterface * create() const override { return (new Element); } - - void destroy(ElementInterface * p) const override - { - delete p; - } }; void add_arrow(const std::string&, const pat::cloneable>&); diff --git a/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp index 54a04de0..9a0690da 100644 --- a/include/nana/gui/widgets/scroll.hpp +++ b/include/nana/gui/widgets/scroll.hpp @@ -14,7 +14,7 @@ #define NANA_GUI_WIDGET_SCROLL_HPP #include "widget.hpp" -#include +//#include //deprecated #include namespace nana diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 1160c724..69917ca6 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -14,7 +14,7 @@ #ifndef NANA_GUI_WIDGET_TABBAR_HPP #define NANA_GUI_WIDGET_TABBAR_HPP #include "widget.hpp" -#include "../../paint/gadget.hpp" +//#include "../../paint/gadget.hpp" //deprecated #include #include diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index db15a6cd..cd7a6e3e 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -19,7 +19,7 @@ #define NANA_GUI_WIDGETS_TREEBOX_HPP #include "widget.hpp" #include "detail/compset.hpp" -#include +//#include //deprecated #include "detail/tree_cont.hpp" #include #include diff --git a/include/nana/pat/cloneable.hpp b/include/nana/pat/cloneable.hpp index 281c36f2..3651743c 100644 --- a/include/nana/pat/cloneable.hpp +++ b/include/nana/pat/cloneable.hpp @@ -21,36 +21,38 @@ namespace nana{ namespace pat{ namespace detail { + /* template - class cloneable_interface + class cloneable_interface //deprecated { public: - typedef T interface_t; + using interface_t = T; typedef cloneable_interface cloneable_t; + virtual ~cloneable_interface() = default; virtual interface_t& refer() = 0; virtual const interface_t& refer() const = 0; virtual cloneable_t* clone() const = 0; virtual void self_delete() const = 0; }; + */ - + /* template class cloneable_wrapper - : public cloneable_interface + : public cloneable_interface //deprecated { public: - typedef T value_t; - typedef typename cloneable_interface::interface_t interface_t; + using value_type = T; + using interface_t = typename cloneable_interface::interface_t; - cloneable_wrapper() - {} + cloneable_wrapper() = default; - cloneable_wrapper(const value_t& obj) + cloneable_wrapper(const value_type& obj) :object_(obj) {} - cloneable_wrapper(value_t&& rv) + cloneable_wrapper(value_type&& rv) :object_(std::move(rv)) {} @@ -66,17 +68,17 @@ namespace nana{ namespace pat{ virtual interface_t& refer() override { - return object_; + return value_obj_; } virtual const interface_t& refer() const override { - return object_; + return value_obj_; } virtual cloneable_interface* clone() const override { - return (new cloneable_wrapper(object_)); + return (new cloneable_wrapper{ value_obj_ }); } virtual void self_delete() const override @@ -84,28 +86,87 @@ namespace nana{ namespace pat{ (delete this); } private: - value_t object_; + value_type value_obj_; + }; + */ + + class cloneable_interface + { + public: + virtual ~cloneable_interface() = default; + virtual void * get() = 0; + virtual cloneable_interface* clone() const = 0; + virtual void self_delete() const = 0; }; + struct cloneable_interface_deleter + { + void operator()(cloneable_interface * p) + { + if (p) + p->self_delete(); + } + }; + + template + class cloneable_wrapper + : public cloneable_interface + { + public: + using value_type = T; + + cloneable_wrapper() = default; + + cloneable_wrapper(const value_type& obj) + :value_obj_(obj) + {} + + cloneable_wrapper(value_type&& rv) + :value_obj_(std::move(rv)) + {} + + /* + template + cloneable_wrapper(const U& u) //deprecated + : object_(u) + {} + + template + cloneable_wrapper(U&& u) + : object_(std::move(u)) + {} + */ + private: + //Implement cloneable_interface + virtual void* get() override + { + return &value_obj_; + } + + virtual cloneable_interface* clone() const override + { + return (new cloneable_wrapper{ value_obj_ }); + } + + virtual void self_delete() const override + { + (delete this); + } + private: + value_type value_obj_; + }; }//end namespace detail template class cloneable { using base_t = Base; - using interface_t = detail::cloneable_interface < base_t > ; + using cloneable_interface = detail::cloneable_interface; using const_base_ptr = typename std::conditional::type; using const_base_ref = typename std::conditional::type; - struct deleter - { - void operator()(interface_t * p) - { - if(p) - p->self_delete(); - } - }; + template friend class cloneable; struct inner_bool { @@ -125,16 +186,16 @@ namespace nana{ namespace pat{ template::type* = nullptr> cloneable(T&& t) - : cwrapper_(new detail::cloneable_wrapper::type>::type, base_t>(std::forward(t)), deleter()), - fast_ptr_(&(cwrapper_->refer())) + : cwrapper_(new detail::cloneable_wrapper::type>::type>(std::forward(t)), detail::cloneable_interface_deleter()), + fast_ptr_(reinterpret_cast::type>::type*>(cwrapper_->get())) {} cloneable(const cloneable& r) { if(r.cwrapper_) { - cwrapper_ = std::shared_ptr(r.cwrapper_->clone(), deleter()); - fast_ptr_ = &(cwrapper_->refer()); + cwrapper_ = std::move(std::shared_ptr(r.cwrapper_->clone(), detail::cloneable_interface_deleter{})); + fast_ptr_ = reinterpret_cast(cwrapper_->get()); } } @@ -145,12 +206,27 @@ namespace nana{ namespace pat{ r.fast_ptr_ = nullptr; } + template::value>::type* = nullptr> + cloneable(const cloneable& other) + { + if (other) + { + char* value_ptr = reinterpret_cast(other.cwrapper_->get()); + char* base_ptr = reinterpret_cast(other.fast_ptr_); + + auto ptr_diff = std::distance(base_ptr, value_ptr); + + cwrapper_.reset(other.cwrapper_->clone(), detail::cloneable_interface_deleter{}); + fast_ptr_ = reinterpret_cast(reinterpret_cast(cwrapper_->get()) - ptr_diff); + } + } + cloneable & operator=(const cloneable& r) { if((this != &r) && r.cwrapper_) { - cwrapper_ = std::shared_ptr(r.cwrapper_->clone(), deleter()); - fast_ptr_ = &(cwrapper_->refer()); + cwrapper_ = std::shared_ptr(r.cwrapper_->clone(), detail::cloneable_interface_deleter()); + fast_ptr_ = reinterpret_cast(cwrapper_->get()); } return *this; } @@ -159,10 +235,8 @@ namespace nana{ namespace pat{ { if(this != &r) { - cwrapper_ = r.cwrapper_; + cwrapper_ = std::move(r.cwrapper_); fast_ptr_ = r.fast_ptr_; - - r.cwrapper_.reset(); r.fast_ptr_ = nullptr; } return *this; @@ -204,12 +278,12 @@ namespace nana{ namespace pat{ return (fast_ptr_ ? &inner_bool::true_stand : nullptr); } private: - std::shared_ptr cwrapper_; + std::shared_ptr cwrapper_; base_t * fast_ptr_{nullptr}; }; template - using mutable_cloneable = cloneable < T, true > ; + using mutable_cloneable = cloneable; }//end namespace pat }//end namespace nana diff --git a/source/gui/element.cpp b/source/gui/element.cpp index cbccebed..0263338a 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -28,6 +28,14 @@ namespace nana //Element definitions namespace element { + namespace detail + { + void factory_abstract::destroy(element_abstract* ptr) + { + delete ptr; + } + } + class crook : public crook_interface { @@ -592,8 +600,9 @@ namespace nana class element_object : nana::noncopyable, nana::nonmovable { - typedef ElementInterface element_t; - typedef pat::cloneable> factory_interface; + using element_type = ElementInterface; + using factory_interface = pat::cloneable>; //deprecated + //using factory_interface = pat::cloneable; public: ~element_object() @@ -608,7 +617,8 @@ namespace nana auto keep_e = element_ptr_; factory_ = rhs; - element_ptr_ = factory_->create(); + element_ptr_ = factory_->create(); //deprecated + //element_ptr_ = static_cast(static_cast&>(*factory_).create()); if(nullptr == factory_ || nullptr == element_ptr_) { @@ -624,22 +634,27 @@ namespace nana spare_.emplace_back(keep_e, keep_f); } - element_t * const * cite() const + element_type * const * cite() const { return &element_ptr_; } private: factory_interface factory_; //Keep the factory for destroying the element - element_t * element_ptr_{nullptr}; - std::vector> spare_; + element_type * element_ptr_{nullptr}; + std::vector> spare_; }; class element_manager : nana::noncopyable, nana::nonmovable { - //VC2012 does not support alias declaration. - //template using factory_interface = element::provider::factory_interface; - + /* + template //deprecated + struct item + { + element_object * employee; + std::map>> table; + }; + */ template struct item { @@ -1047,19 +1062,21 @@ namespace nana namespace element { + using brock = ::nana::detail::bedrock; + void set_bground(const char* name, const pat::cloneable& obj) { - detail::bedrock::instance().get_element_store().bground(name, obj); + brock::instance().get_element_store().bground(name, obj); } void set_bground(const char* name, pat::cloneable && obj) { - detail::bedrock::instance().get_element_store().bground(name, std::move(obj)); + brock::instance().get_element_store().bground(name, std::move(obj)); } //class cite cite_bground::cite_bground(const char* name) - : ref_ptr_(detail::bedrock::instance().get_element_store().bground(name)) + : ref_ptr_(brock::instance().get_element_store().bground(name)) { } @@ -1073,7 +1090,7 @@ namespace nana void cite_bground::set(const char* name) { holder_.reset(); - ref_ptr_ = detail::bedrock::instance().get_element_store().bground(name); + ref_ptr_ = brock::instance().get_element_store().bground(name); } bool cite_bground::draw(graph_reference dst, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const nana::rectangle& r, element_state state) diff --git a/source/gui/widgets/categorize.cpp b/source/gui/widgets/categorize.cpp index 4351a719..20afdfbf 100644 --- a/source/gui/widgets/categorize.cpp +++ b/source/gui/widgets/categorize.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +//#include //deprecated #include #include diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index 49626834..608f3fa5 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -11,7 +11,7 @@ */ #include -#include +//#include //deprecated #include #include #include diff --git a/source/gui/widgets/date_chooser.cpp b/source/gui/widgets/date_chooser.cpp index 7da5474c..a56a3202 100644 --- a/source/gui/widgets/date_chooser.cpp +++ b/source/gui/widgets/date_chooser.cpp @@ -12,7 +12,7 @@ #include #include -#include +//#include //deprecated #include #include diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 6532bf6e..c4a0e63b 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -112,12 +112,16 @@ namespace nana clr = { 0xF0, 0xF0, 0xF0 }; } graph.rectangle(r, true, bgcolor_); - nana::paint::gadget::cross(graph, x, y, 14, 6, clr); + facade cross; + cross.draw(graph, {}, clr, { x, y, 14, 6 }, element_state::normal); + //nana::paint::gadget::cross(graph, x, y, 14, 6, clr); //deprecated } virtual void close(graph_reference graph, const nana::rectangle& r, state_t sta) { - nana::paint::gadget::close_16_pixels(graph, r.x + (r.width - 16) / 2, r.y + (r.height - 16) / 2, 1, colors::black); + //nana::paint::gadget::close_16_pixels(graph, r.x + (r.width - 16) / 2, r.y + (r.height - 16) / 2, 1, colors::black); //deprecated + facade x_icon; + x_icon.draw(graph, {}, colors::black, { r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); if(item_renderer::highlight == sta) graph.rectangle(r, false, {0xa0, 0xa0, 0xa0}); } @@ -140,24 +144,28 @@ namespace nana else if (!active) clr = ::nana::color{ 0x92, 0x99, 0xA4 }; - gadget::close_16_pixels(graph, r.x - (16 - r.width) / 2, r.y - (16 - r.height) / 2, 1, clr); + + //gadget::close_16_pixels(graph, r.x - (16 - r.width) / 2, r.y - (16 - r.height) / 2, 1, clr); //deprecated + facade x_icon; + x_icon.draw(graph, {}, colors::black, { r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); + } virtual void back(graph_reference graph, const nana::rectangle& r, state_t sta) { - using namespace nana::paint::gadget; + //using namespace nana::paint::gadget; //deprecated _m_draw_arrow(graph, r, sta, direction::west); } virtual void next(graph_reference graph, const nana::rectangle& r, state_t sta) { - using namespace nana::paint::gadget; + //using namespace nana::paint::gadget; //deprecated _m_draw_arrow(graph, r, sta, direction::east); } virtual void list(graph_reference graph, const nana::rectangle& r, state_t sta) { - using namespace nana::paint::gadget; + //using namespace nana::paint::gadget; //deprecated _m_draw_arrow(graph, r, sta, direction::south); } private: From 42443dcafd47be64efb59f884a4a73b1a29e4976 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 20 Aug 2015 01:09:29 +0800 Subject: [PATCH 05/65] remove paint::gadget --- build/codeblocks/nana.cbp | 1 - build/codeblocks/nana.depend | 630 ++++++++++++++++++ build/codeblocks/nana.layout | 143 ++-- build/vc2013/nana.vcxproj | 7 +- build/vc2013/nana.vcxproj.filters | 9 +- build/vc2015/nana.sln | 20 +- build/vc2015/nana.vcxproj | 89 +-- build/vc2015/nana.vcxproj.filters | 503 +++++++------- extrlib/readme (2).txt | 1 - extrlib/readme.txt | 2 + include/nana/gui/widgets/scroll.hpp | 3 +- include/nana/gui/widgets/tabbar.hpp | 3 +- include/nana/gui/widgets/treebox.hpp | 1 - include/nana/paint/gadget.hpp | 33 - include/nana/pat/cloneable.hpp | 81 --- source/gui/detail/native_window_interface.cpp | 26 - source/gui/element.cpp | 16 +- source/gui/msgbox.cpp | 6 +- source/gui/place.cpp | 81 +-- source/gui/widgets/categorize.cpp | 1 - source/gui/widgets/checkbox.cpp | 1 - source/gui/widgets/date_chooser.cpp | 1 - source/gui/widgets/menu.cpp | 1 - source/gui/widgets/skeletons/text_editor.cpp | 6 +- source/gui/widgets/tabbar.cpp | 10 +- source/paint/gadget.cpp | 108 --- source/paint/graphics.cpp | 4 +- 27 files changed, 1024 insertions(+), 763 deletions(-) delete mode 100644 extrlib/readme (2).txt delete mode 100644 include/nana/paint/gadget.hpp delete mode 100644 source/paint/gadget.cpp diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp index fb1a1b55..9302ebd6 100644 --- a/build/codeblocks/nana.cbp +++ b/build/codeblocks/nana.cbp @@ -102,7 +102,6 @@ - diff --git a/build/codeblocks/nana.depend b/build/codeblocks/nana.depend index a2318fdf..f7f24eaa 100644 --- a/build/codeblocks/nana.depend +++ b/build/codeblocks/nana.depend @@ -537,3 +537,633 @@ 1399002439 source:d:\privates\nana\release\nana.cpp11\source\gui\detail\element_store.cpp +1363362719 source:d:\git.repo\nana\source\any.cpp + + +1362509572 source:d:\git.repo\nana\source\audio\detail\audio_device.cpp + + + + + + + +1439496157 source:d:\git.repo\nana\source\audio\detail\audio_stream.cpp + + + +1362509721 source:d:\git.repo\nana\source\audio\detail\buffer_preparation.cpp + + + +1353253406 source:d:\git.repo\nana\source\audio\player.cpp + + + + + + +1439496157 source:d:\git.repo\nana\source\basic_types.cpp + + + + + + +1439496157 source:d:\git.repo\nana\source\charset.cpp + + + + + + + + +1439496157 source:d:\git.repo\nana\source\datetime.cpp + + + + + +1439496157 source:d:\git.repo\nana\source\deploy.cpp + + + + + + + +1439496157 source:d:\git.repo\nana\source\detail\platform_spec_selector.cpp + + "win32/platform_spec.cpp" + "linux_X11/platform_spec.cpp" + +1439496157 d:\git.repo\nana\source\detail\win32\platform_spec.cpp + + + + + +1439496157 d:\git.repo\nana\source\detail\linux_x11\platform_spec.cpp + + + + + + + + + + + + + "msg_dispatcher.hpp" + +1439496157 d:\git.repo\nana\source\detail\linux_x11\msg_dispatcher.hpp + + + + + + + + + + +1365203880 source:d:\git.repo\nana\source\exceptions.cpp + + +1365203878 source:d:\git.repo\nana\source\filesystem\file_iterator.cpp + + +1365203878 source:d:\git.repo\nana\source\filesystem\fs_utility.cpp + + + + + + + + + + + + + + + + +1439496157 source:d:\git.repo\nana\source\gui\animation.cpp + + + + + + + + + + + + + + +1423350892 source:d:\git.repo\nana\source\gui\basis.cpp + + +1439496157 source:d:\git.repo\nana\source\gui\detail\basic_window.cpp + + + +1439496157 source:d:\git.repo\nana\source\gui\detail\bedrock_pi.cpp + + + + + + + + + + + + + +1439496157 source:d:\git.repo\nana\source\gui\detail\bedrock_selector.cpp + + "win32/bedrock.cpp" + "linux_X11/bedrock.cpp" + +1439496157 d:\git.repo\nana\source\gui\detail\win32\bedrock.cpp + + + + + + + + + + + + + + +1439496157 d:\git.repo\nana\source\gui\detail\linux_x11\bedrock.cpp + + + + + + + + + + +1423350892 source:d:\git.repo\nana\source\gui\detail\color_schemes.cpp + + + +1439496157 source:d:\git.repo\nana\source\gui\detail\drawer.cpp + + + + + + + + +1408986718 source:d:\git.repo\nana\source\gui\detail\element_store.cpp + + +1439496157 source:d:\git.repo\nana\source\gui\detail\events_operation.cpp + + +1439828940 source:d:\git.repo\nana\source\gui\detail\native_window_interface.cpp + + + + + + + "../../paint/detail/image_ico.hpp" + + + +1439496158 d:\git.repo\nana\source\paint\detail\image_ico.hpp + + +1439496157 source:d:\git.repo\nana\source\gui\detail\window_layout.cpp + + + + + + +1439496157 source:d:\git.repo\nana\source\gui\detail\window_manager.cpp + + + + + + + + + + + +1439746409 source:d:\git.repo\nana\source\gui\dragger.cpp + + +1423350892 source:d:\git.repo\nana\source\gui\drawing.cpp + + + + +1439496157 source:d:\git.repo\nana\source\gui\effects.cpp + + + +1439829040 source:d:\git.repo\nana\source\gui\element.cpp + + + + + + + + + +1439496157 source:d:\git.repo\nana\source\gui\filebox.cpp + + + + + + + + + + + + + + + + +1439496157 source:d:\git.repo\nana\source\gui\layout_utility.cpp + + +1439496157 source:d:\git.repo\nana\source\gui\msgbox.cpp + + + + + + + + + + + + + + + + + + +1439496157 source:d:\git.repo\nana\source\gui\notifier.cpp + + + + + + + + + + + + +1439746410 source:d:\git.repo\nana\source\gui\programming_interface.cpp + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\screen.cpp + + + + + + + +1415011766 source:d:\git.repo\nana\source\gui\state_cursor.cpp + + + + +1439496158 source:d:\git.repo\nana\source\gui\timer.cpp + + + + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\tooltip.cpp + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\button.cpp + + + +1439829040 source:d:\git.repo\nana\source\gui\widgets\categorize.cpp + + + + + + + +1439829040 source:d:\git.repo\nana\source\gui\widgets\checkbox.cpp + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\combox.cpp + + + + + + + + + +1439829040 source:d:\git.repo\nana\source\gui\widgets\date_chooser.cpp + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\float_listbox.cpp + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\form.cpp + + +1408985395 source:d:\git.repo\nana\source\gui\widgets\frame.cpp + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\group.cpp + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\label.cpp + + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\listbox.cpp + + + + + + + + + + + + +1439828820 source:d:\git.repo\nana\source\gui\widgets\menu.cpp + + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\menubar.cpp + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\panel.cpp + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\picture.cpp + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\progress.cpp + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\scroll.cpp + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\skeletons\text_editor.cpp + + + + + + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\slider.cpp + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\spinbox.cpp + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\textbox.cpp + + + + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\toolbar.cpp + + + + +1439496158 source:d:\git.repo\nana\source\gui\widgets\treebox.cpp + + + + + + + +1439746410 source:d:\git.repo\nana\source\gui\widgets\widget.cpp + + + + +1408984042 source:d:\git.repo\nana\source\gui\wvl.cpp + + +1425221155 source:d:\git.repo\nana\source\internationalization.cpp + + + + + + + +1423350893 source:d:\git.repo\nana\source\paint\detail\image_process_provider.cpp + + + +1439496158 source:d:\git.repo\nana\source\paint\detail\native_paint_interface.cpp + + + + + + + +1439746289 source:d:\git.repo\nana\source\paint\graphics.cpp + + + + + + + + + + + +1439496158 source:d:\git.repo\nana\source\paint\image.cpp + + + + + + + + + "detail/image_png.hpp" + "detail/image_bmp.hpp" + "detail/image_ico.hpp" + +1439687843 d:\git.repo\nana\source\paint\detail\image_png.hpp + + + + + + +1439496158 d:\git.repo\nana\source\paint\detail\image_bmp.hpp + + + +1376313789 source:d:\git.repo\nana\source\paint\image_process_selector.cpp + + +1439496158 source:d:\git.repo\nana\source\paint\pixel_buffer.cpp + + + + + + + +1423350893 source:d:\git.repo\nana\source\paint\text_renderer.cpp + + + + + +1439496158 source:d:\git.repo\nana\source\system\dataexch.cpp + + + + + + + + + +1387007333 source:d:\git.repo\nana\source\system\platform.cpp + + + + + + + + +1365203879 source:d:\git.repo\nana\source\system\shared_wrapper.cpp + + + + + + +1342280997 source:d:\git.repo\nana\source\system\timepiece.cpp + + + + + +1386165989 source:d:\git.repo\nana\source\threads\pool.cpp + + + + + + + + + + + + + +1365203748 source:d:\git.repo\nana\source\traits.cpp + + +1439496158 source:d:\git.repo\nana\source\unicode_bidi.cpp + + +1439830958 source:d:\git.repo\nana\source\gui\widgets\tabbar.cpp + + + + + + + + diff --git a/build/codeblocks/nana.layout b/build/codeblocks/nana.layout index 92b352dc..587b86f1 100644 --- a/build/codeblocks/nana.layout +++ b/build/codeblocks/nana.layout @@ -1,24 +1,9 @@ - + - - - - - - - - - - - - - - - - + @@ -26,9 +11,9 @@ - + - + @@ -36,66 +21,26 @@ - - - - - - - - - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - @@ -126,29 +71,89 @@ - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc2013/nana.vcxproj b/build/vc2013/nana.vcxproj index 610054bc..7ed1c2f9 100644 --- a/build/vc2013/nana.vcxproj +++ b/build/vc2013/nana.vcxproj @@ -243,7 +243,6 @@ - @@ -277,8 +276,8 @@ - - + + @@ -383,4 +382,4 @@ - + \ No newline at end of file diff --git a/build/vc2013/nana.vcxproj.filters b/build/vc2013/nana.vcxproj.filters index 6ade66c7..e58eb56b 100644 --- a/build/vc2013/nana.vcxproj.filters +++ b/build/vc2013/nana.vcxproj.filters @@ -119,7 +119,7 @@ Source Files\nana\detail\win32 - + Source Files\nana\filesystem @@ -261,9 +261,6 @@ Source Files\nana\paint\detail - - Source Files\nana\paint - Source Files\nana\paint @@ -645,7 +642,7 @@ Header Files\extrlib - + Header Files\filesystem @@ -719,4 +716,4 @@ Header Files\gui\widgets - + \ No newline at end of file diff --git a/build/vc2015/nana.sln b/build/vc2015/nana.sln index eab31ab5..6de06997 100644 --- a/build/vc2015/nana.sln +++ b/build/vc2015/nana.sln @@ -1,9 +1,9 @@  Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio 14 -VisualStudioVersion = 14.0.22823.1 +VisualStudioVersion = 14.0.23107.0 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nana", "nana.vcxproj", "{25B21068-491B-4A9F-B99F-6C27BF31BAAD}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "nana", "nana.vcxproj", "{98091380-2EC4-44B4-82A2-F0A6393BA908}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -13,14 +13,14 @@ Global Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x64.ActiveCfg = Debug|x64 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x64.Build.0 = Debug|x64 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x86.ActiveCfg = Debug|Win32 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Debug|x86.Build.0 = Debug|Win32 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x64.ActiveCfg = Release|x64 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x64.Build.0 = Release|x64 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x86.ActiveCfg = Release|Win32 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD}.Release|x86.Build.0 = Release|Win32 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Debug|x64.ActiveCfg = Debug|x64 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Debug|x64.Build.0 = Debug|x64 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Debug|x86.ActiveCfg = Debug|Win32 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Debug|x86.Build.0 = Debug|Win32 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Release|x64.ActiveCfg = Release|x64 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Release|x64.Build.0 = Release|x64 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Release|x86.ActiveCfg = Release|Win32 + {98091380-2EC4-44B4-82A2-F0A6393BA908}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/build/vc2015/nana.vcxproj b/build/vc2015/nana.vcxproj index d4f7f5d3..9b0433bd 100644 --- a/build/vc2015/nana.vcxproj +++ b/build/vc2015/nana.vcxproj @@ -5,24 +5,24 @@ Debug Win32 - - Debug - x64 - Release Win32 + + Debug + x64 + Release x64 - {25B21068-491B-4A9F-B99F-6C27BF31BAAD} + {98091380-2EC4-44B4-82A2-F0A6393BA908} Win32Proj nana - 8.1 + 8.1 @@ -31,12 +31,6 @@ v140 Unicode - - StaticLibrary - true - v140 - Unicode - StaticLibrary false @@ -44,6 +38,12 @@ true Unicode + + StaticLibrary + true + v140 + Unicode + StaticLibrary false @@ -54,46 +54,30 @@ - - + - + - + + + + - - ../bin/ - ..\..\include;$(IncludePath) - ..\..\source;$(VC_SourcePath); - $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) - ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ + + ../../include;$(IncludePath) + ..\bin\vc2015\ + lib$(ProjectName) - ..\..\include;$(IncludePath) - ..\..\source;$(VC_SourcePath); - ../bin/ - $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) - ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ - - - ../bin/ - ..\..\include;$(IncludePath) - ..\..\source;$(VC_SourcePath); - $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) - ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ - - - ..\..\include;$(IncludePath) - ..\..\source;$(VC_SourcePath); - ../bin/ - $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) - ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ + ../../include;$(IncludePath) + ..\bin\vc2015\ + lib$(ProjectName)d @@ -102,17 +86,11 @@ Level3 Disabled WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreadedDebug - true - false Windows true - - $(TargetPath) - @@ -120,15 +98,14 @@ Level3 Disabled - WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreadedDebug + _DEBUG;_LIB;%(PreprocessorDefinitions) Windows true - $(TargetPath) + $(OutDir)$(TargetName)$(TargetExt) @@ -140,8 +117,6 @@ true true WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded - true Windows @@ -149,9 +124,6 @@ true true - - $(TargetPath) - @@ -161,8 +133,7 @@ MaxSpeed true true - WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions) - MultiThreaded + NDEBUG;_LIB;%(PreprocessorDefinitions) Windows @@ -171,7 +142,7 @@ true - $(TargetPath) + $(OutDir)$(TargetName)$(TargetExt) @@ -244,7 +215,6 @@ - @@ -252,7 +222,6 @@ - diff --git a/build/vc2015/nana.vcxproj.filters b/build/vc2015/nana.vcxproj.filters index 81495341..42482ba2 100644 --- a/build/vc2015/nana.vcxproj.filters +++ b/build/vc2015/nana.vcxproj.filters @@ -13,298 +13,289 @@ {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms - - {b0bd11b1-bcbb-4e05-885e-44295bc1a7bb} + + {9630500a-5aca-4625-a11b-1ba83a93895c} - - {aab16aa3-c8d4-4495-8606-1b21ae739ee5} + + {d43db913-0472-45f6-889e-b147a7b3eb7e} - - {c395f107-7102-415b-a019-54e7cf3575af} + + {4e91af62-8e45-41d5-8bb9-1deb850de937} - - {e2569be2-9e68-477d-8b59-e248595de6c7} + + {c575e702-d7d3-48d2-a465-30e51ca72f8d} - - {52ed7f8e-fa48-495e-af1f-4df013205a35} + + {e1fbd69a-2a82-419e-854a-0b5dbd0e0237} - - {87d14798-9015-4162-b9ab-72c741cff063} + + {295ba47e-9dc7-4375-82bc-443b767eb87d} - - {4f8e7d23-9fe1-4409-bb03-2bd0809e606b} + + {b0854b25-60fc-47e2-a9df-5e4f2d28065c} - - {85c9c1bb-d87b-4481-bf3c-7425f680a12d} + + {b3023f5e-2759-409d-b6e8-5ef2fe6601ae} - - {8058b530-86ec-4d72-890d-345aa30db056} + + {2ce139f3-ef8e-48b7-a82a-68003eac75da} - - {87b124cb-408d-460b-a81b-8a788bbae0d9} + + {b9f9a5a8-fd1a-4b99-b530-d8a4c45e62ec} - - {b10db2f1-0542-421a-9e1d-4357e3be5f68} + + {4b04c197-4a1e-41f9-bfa3-d82c18bcad51} - - {59f186c8-f5f8-4499-8e19-f278d4754220} + + {cd6e7f3f-fe5b-44c6-ae8d-15554f926055} - - {5acf1733-47b2-4872-a105-66c7ad15cd39} + + {60f588f2-bdb9-4b1d-9e23-40a73f327283} - - {a81fa10e-1274-44e0-92a0-434fa28f89ae} - - - {e95b4a72-643f-4416-af95-b0bbaf7f0c57} + + {53feb93f-2b86-4bf5-b2f3-f60ef1bbbf76} - - Source Files\nana\audio\detail - - - Source Files\nana\audio\detail - - - Source Files\nana\audio\detail - - - Source Files\nana\audio - - - Source Files\nana\detail\win32 - - - Source Files\nana\filesystem - - - Source Files\nana\filesystem - - - Source Files\nana\gui\detail\win32 - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\widgets\skeletons - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui\widgets - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\gui - - - Source Files\nana\paint\detail - - - Source Files\nana\paint\detail - - - Source Files\nana\paint - - - Source Files\nana\paint - - - Source Files\nana\paint - - - Source Files\nana\paint - - - Source Files\nana\paint - - - Source Files\nana\paint - - - Source Files\nana\system - - - Source Files\nana\system - - - Source Files\nana\system - - - Source Files\nana\system - - - Source Files\nana\threads - - Source Files\nana + Source Files - Source Files\nana + Source Files - Source Files\nana + Source Files - Source Files\nana + Source Files - Source Files\nana + Source Files - Source Files\nana - - - Source Files\nana - - - Source Files\nana - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\detail - - - Source Files\nana\gui\detail - - - Source Files\nana\gui - - - Source Files\nana\gui + Source Files - Source Files\nana + Source Files - - Source Files\nana\gui\detail + + Source Files - - Source Files\nana\gui + + Source Files - - Source Files\nana\gui\widgets + + Source Files\audio\detail + + + Source Files\audio\detail + + + Source Files\audio\detail + + + Source Files\audio + + + Source Files\detail\win32 + + + Source Files\filesystem - Source Files\nana\filesystem + Source Files\filesystem + + + Source Files\filesystem + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail + + + Source Files\gui\detail\win32 + + + Source Files\gui\widgets\skeletons + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets - Source Files\nana\gui\widgets + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui\widgets + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\gui + + + Source Files\threads + + + Source Files\system + + + Source Files\system + + + Source Files\system + + + Source Files\paint\detail + + + Source Files\paint\detail + + + Source Files\paint + + + Source Files\paint + + + Source Files\paint + + + Source Files\paint + + + Source Files\paint \ No newline at end of file diff --git a/extrlib/readme (2).txt b/extrlib/readme (2).txt deleted file mode 100644 index 84359ae5..00000000 --- a/extrlib/readme (2).txt +++ /dev/null @@ -1 +0,0 @@ -The libpng.a is for MinGW(Not linux), and other .lib files are for VS2013 \ No newline at end of file diff --git a/extrlib/readme.txt b/extrlib/readme.txt index e5edb297..c54ee0ad 100644 --- a/extrlib/readme.txt +++ b/extrlib/readme.txt @@ -1 +1,3 @@ +The libpng.a is for MinGW(Not linux), and other .lib files are for VS2013 + You can download the precompiled external libraries at http://sourceforge.net/projects/nanapro/files/extrlib/ \ No newline at end of file diff --git a/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp index 9a0690da..917a5da5 100644 --- a/include/nana/gui/widgets/scroll.hpp +++ b/include/nana/gui/widgets/scroll.hpp @@ -14,7 +14,6 @@ #define NANA_GUI_WIDGET_SCROLL_HPP #include "widget.hpp" -//#include //deprecated #include namespace nana @@ -444,7 +443,7 @@ namespace nana /// @return true if the vlaue is changed. bool make_page_scroll(bool forward) { - return this->make_step(forward, range() - 1); + return this->make_step(forward, static_cast(range() - 1)); } };//end class scroll }//end namespace nana diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 69917ca6..02722d96 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -14,7 +14,6 @@ #ifndef NANA_GUI_WIDGET_TABBAR_HPP #define NANA_GUI_WIDGET_TABBAR_HPP #include "widget.hpp" -//#include "../../paint/gadget.hpp" //deprecated #include #include @@ -30,7 +29,7 @@ namespace nana T & value; arg_tabbar(tabbar& wdg, T& v) - : widget{ wdg }, value{ v } + : widget(wdg), value{ v } {} }; diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index cd7a6e3e..5e317781 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -19,7 +19,6 @@ #define NANA_GUI_WIDGETS_TREEBOX_HPP #include "widget.hpp" #include "detail/compset.hpp" -//#include //deprecated #include "detail/tree_cont.hpp" #include #include diff --git a/include/nana/paint/gadget.hpp b/include/nana/paint/gadget.hpp deleted file mode 100644 index d64c9293..00000000 --- a/include/nana/paint/gadget.hpp +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Graphics Gadget Implementation - * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-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/paint/gadget.hpp - */ - -#ifndef NANA_PAINT_GADGET_HPP -#define NANA_PAINT_GADGET_HPP -#include "graphics.hpp" -#include "image.hpp" -#include - -namespace nana -{ -namespace paint -{ -namespace gadget -{ - void close_16_pixels(::nana::paint::graphics&, int x, int y, unsigned style, const color&); - void cross(::nana::paint::graphics&, int x, int y, unsigned size, unsigned thickness, const nana::color&); - -}//end namespace gadget - -}//end namespace paint -}//end namespace nana - -#endif diff --git a/include/nana/pat/cloneable.hpp b/include/nana/pat/cloneable.hpp index 3651743c..16a9dfcd 100644 --- a/include/nana/pat/cloneable.hpp +++ b/include/nana/pat/cloneable.hpp @@ -21,75 +21,6 @@ namespace nana{ namespace pat{ namespace detail { - /* - template - class cloneable_interface //deprecated - { - public: - using interface_t = T; - typedef cloneable_interface cloneable_t; - - virtual ~cloneable_interface() = default; - virtual interface_t& refer() = 0; - virtual const interface_t& refer() const = 0; - virtual cloneable_t* clone() const = 0; - virtual void self_delete() const = 0; - }; - */ - - /* - template - class cloneable_wrapper - : public cloneable_interface //deprecated - { - public: - using value_type = T; - using interface_t = typename cloneable_interface::interface_t; - - cloneable_wrapper() = default; - - cloneable_wrapper(const value_type& obj) - :object_(obj) - {} - - cloneable_wrapper(value_type&& rv) - :object_(std::move(rv)) - {} - - template - cloneable_wrapper(const U& u) - : object_(u) - {} - - template - cloneable_wrapper(U& u) - :object_(u) - {} - - virtual interface_t& refer() override - { - return value_obj_; - } - - virtual const interface_t& refer() const override - { - return value_obj_; - } - - virtual cloneable_interface* clone() const override - { - return (new cloneable_wrapper{ value_obj_ }); - } - - virtual void self_delete() const override - { - (delete this); - } - private: - value_type value_obj_; - }; - */ - class cloneable_interface { public: @@ -124,18 +55,6 @@ namespace nana{ namespace pat{ cloneable_wrapper(value_type&& rv) :value_obj_(std::move(rv)) {} - - /* - template - cloneable_wrapper(const U& u) //deprecated - : object_(u) - {} - - template - cloneable_wrapper(U&& u) - : object_(std::move(u)) - {} - */ private: //Implement cloneable_interface virtual void* get() override diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index d706b43d..6dd9a583 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -542,32 +542,6 @@ namespace nana{ return false; } - /* - bool native_interface::window_icon(native_window_type wd, const paint::image& big_icon, const paint::image& small_icon) //deprecated - { -#if defined(NANA_WINDOWS) - HICON h_big_icon = paint::image_accessor::icon(big_icon); - HICON h_small_icon = paint::image_accessor::icon(small_icon); - if (h_big_icon || h_small_icon) - { - nana::detail::platform_spec::instance().keep_window_icon(wd, (!big_icon.empty() ? big_icon : small_icon)); - if (h_big_icon) { - ::SendMessage(reinterpret_cast(wd), WM_SETICON, ICON_BIG, reinterpret_cast(h_big_icon)); - } - if (h_small_icon) { - ::SendMessage(reinterpret_cast(wd), WM_SETICON, ICON_SMALL, reinterpret_cast(h_small_icon)); - } - return true; - } -#elif defined(NANA_X11) - return window_icon(wd, big_icon); -#endif - return false; - } - */ - - - void native_interface::activate_owner(native_window_type wd) { #if defined(NANA_WINDOWS) diff --git a/source/gui/element.cpp b/source/gui/element.cpp index 0263338a..4271a4d2 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -272,7 +272,7 @@ namespace nana bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, unsigned weight) { graph.rectangle(r, false, static_cast((element_state::focus_hovered == estate || element_state::focus_normal == estate) ? 0x0595E2 : 0x999A9E)); - graph.rectangle(::nana::rectangle{r}.pare_off(1), false, bgcolor); + graph.rectangle(::nana::rectangle(r).pare_off(1), false, bgcolor); return true; } }; @@ -601,8 +601,7 @@ namespace nana : nana::noncopyable, nana::nonmovable { using element_type = ElementInterface; - using factory_interface = pat::cloneable>; //deprecated - //using factory_interface = pat::cloneable; + using factory_interface = pat::cloneable; public: ~element_object() @@ -617,8 +616,7 @@ namespace nana auto keep_e = element_ptr_; factory_ = rhs; - element_ptr_ = factory_->create(); //deprecated - //element_ptr_ = static_cast(static_cast&>(*factory_).create()); + element_ptr_ = static_cast(static_cast&>(*factory_).create()); if(nullptr == factory_ || nullptr == element_ptr_) { @@ -647,14 +645,6 @@ namespace nana class element_manager : nana::noncopyable, nana::nonmovable { - /* - template //deprecated - struct item - { - element_object * employee; - std::map>> table; - }; - */ template struct item { diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index c514f124..44addaa6 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -959,7 +959,7 @@ namespace nana int inputbox::date::month() const { if (!impl_->wdg_month.empty()) - return impl_->wdg_month.option() + 1; + return static_cast(impl_->wdg_month.option()) + 1; return impl_->month; } @@ -1028,7 +1028,7 @@ namespace nana impl->wdg_day.events().destroy.connect_unignorable([impl] { impl->day = impl->wdg_day.to_int(); - impl->month = impl->wdg_month.option() + 1; + impl->month = static_cast(impl->wdg_month.option()) + 1; }); impl->wdg_year.events().destroy.connect_unignorable([impl] @@ -1040,7 +1040,7 @@ namespace nana { auto month = impl->wdg_month.option() + 1; auto year = impl->wdg_year.to_int(); - int days = ::nana::date::month_days(year, month); + int days = ::nana::date::month_days(year, static_cast(month)); auto day = impl->wdg_day.to_int(); impl->wdg_day.range(1, days, 1); //It resets the current value of wdg_day diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 7a6325ef..aa1f02f8 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -24,6 +24,8 @@ #include #include //numeric_limits +#include //std::abs +#include //std::memset #include "place_parts.hpp" @@ -93,7 +95,13 @@ namespace nana std::string pos_str() const { +#ifdef NANA_MINGW + std::stringstream ss; + ss<(limit_px(_m_leaf_left(), left_px, area_px)); _m_leaf_left()->weight.assign_percent(imd_rate * left_px); @@ -1692,7 +1699,6 @@ namespace nana }); - //indicator_.dock_area->z_order(nullptr, ::nana::z_order_action::top); //deprecated API::bring_top(indicator_.dock_area->handle(), false); indicator_.dock_area->show(); } @@ -2112,7 +2118,6 @@ namespace nana } field_gather * attached_field = nullptr; - field_dock* attached_dock = nullptr; if (name.size()) { //find the field with specified name. @@ -2154,11 +2159,6 @@ namespace nana } break; case token::dock: - //deprecated - // - //if (name.empty()) - // throw std::invalid_argument("nana.place: dock must have a name."); - div.reset(new div_dock(std::move(name), this)); break; default: @@ -2258,7 +2258,7 @@ namespace nana check_fn(div); } - //connect the field/dock with div object, + //connect the field/dock with div object, void place::implement::connect(division* start) { if (!start) @@ -2307,7 +2307,7 @@ namespace nana div->field->attached = div; } } - + } for (auto & child : div->children) @@ -2392,33 +2392,6 @@ namespace nana //if name violate the naming convention. place_parts::check_field_name(name); - /* //deprecated - implement::division * div_ptr = nullptr; - implement::field_gather * field_ptr = nullptr; - { - auto i = impl_->fields.find(name); - if (i != impl_->fields.end()) - field_ptr = i->second; - } - - if (field_ptr) - { - //remove the existing div object - div_ptr = field_ptr->attached; - } - else - div_ptr = impl_->search_div_name(impl_->root_division.get(), name); - - if (nullptr == div_ptr) - { - std::string what = "nana::place: field '"; - what += name; - what += "' is not found."; - - throw std::invalid_argument(what); - } - */ - auto div_ptr = impl_->search_div_name(impl_->root_division.get(), name); if (!div_ptr) { @@ -2434,7 +2407,6 @@ namespace nana implement::division * div_owner = div_ptr->div_owner; implement::division * div_next = div_ptr->div_next; - implement::division * div_bro = nullptr; if (div_owner) { for (auto i = div_owner->children.begin(); i != div_owner->children.end(); ++i) @@ -2444,7 +2416,6 @@ namespace nana replaced = &(*i); break; } - div_bro = i->get(); } } else @@ -2458,7 +2429,6 @@ namespace nana auto modified = impl_->scan_div(tknizer); auto modified_ptr = modified.get(); modified_ptr->name = name; - //modified_ptr->field = field_ptr; replaced->swap(modified); @@ -2468,33 +2438,6 @@ namespace nana modified_ptr->div_owner = div_owner; modified_ptr->div_next = div_next; - //if (field_ptr) - // field_ptr->attached = modified_ptr; - /* - std::function attach; - attach = [this, &attach](implement::division* div) - { - if (!div->name.empty()) - { - auto i = impl_->fields.find(div->name); - if (impl_->fields.end() != i) - { - if (i->second->attached != div) - { - i->second->attached = div; - div->field = i->second; - } - } - } - - for (auto& child : div->children) - { - attach(child.get()); - } - }; - - attach(impl_->root_division.get()); - */ } catch (...) { @@ -2538,7 +2481,7 @@ namespace nana void place::field_visible(const char* name, bool vsb) { if (!name) name = ""; - + //May throw std::invalid_argument place_parts::check_field_name(name); diff --git a/source/gui/widgets/categorize.cpp b/source/gui/widgets/categorize.cpp index 20afdfbf..92fb9743 100644 --- a/source/gui/widgets/categorize.cpp +++ b/source/gui/widgets/categorize.cpp @@ -14,7 +14,6 @@ #include #include #include -//#include //deprecated #include #include diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index 608f3fa5..582803cc 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -11,7 +11,6 @@ */ #include -//#include //deprecated #include #include #include diff --git a/source/gui/widgets/date_chooser.cpp b/source/gui/widgets/date_chooser.cpp index a56a3202..b46b29a5 100644 --- a/source/gui/widgets/date_chooser.cpp +++ b/source/gui/widgets/date_chooser.cpp @@ -12,7 +12,6 @@ #include #include -//#include //deprecated #include #include diff --git a/source/gui/widgets/menu.cpp b/source/gui/widgets/menu.cpp index d42f2b79..fd206764 100644 --- a/source/gui/widgets/menu.cpp +++ b/source/gui/widgets/menu.cpp @@ -12,7 +12,6 @@ #include #include -#include #include #include #include diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index e568fbee..29e5a181 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -2250,7 +2250,7 @@ namespace nana{ namespace widgets break; case keyboard::os_end: if (caret.y != nlines - 1) { - caret.y = nlines - 1; + caret.y = static_cast(nlines - 1); changed = true; } break; @@ -2265,7 +2265,7 @@ namespace nana{ namespace widgets }else { if (caret.y != 0) { --caret.y; - caret.x = textbase_.getline(caret.y).size(); + caret.x = static_cast(textbase_.getline(caret.y).size()); changed = true; } } @@ -2309,7 +2309,7 @@ namespace nana{ namespace widgets break; case keyboard::os_end: if (caret.x < lnsz) { - caret.x = lnsz; + caret.x = static_cast(lnsz); changed = true; } break; diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index c4a0e63b..624b5db1 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -97,7 +97,7 @@ namespace nana { int x = r.x + (static_cast(r.width) - 14) / 2; int y = r.y + (static_cast(r.height) - 14) / 2; - + ::nana::color clr; switch(sta) @@ -114,12 +114,10 @@ namespace nana graph.rectangle(r, true, bgcolor_); facade cross; cross.draw(graph, {}, clr, { x, y, 14, 6 }, element_state::normal); - //nana::paint::gadget::cross(graph, x, y, 14, 6, clr); //deprecated } virtual void close(graph_reference graph, const nana::rectangle& r, state_t sta) { - //nana::paint::gadget::close_16_pixels(graph, r.x + (r.width - 16) / 2, r.y + (r.height - 16) / 2, 1, colors::black); //deprecated facade x_icon; x_icon.draw(graph, {}, colors::black, { r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); if(item_renderer::highlight == sta) @@ -144,8 +142,6 @@ namespace nana else if (!active) clr = ::nana::color{ 0x92, 0x99, 0xA4 }; - - //gadget::close_16_pixels(graph, r.x - (16 - r.width) / 2, r.y - (16 - r.height) / 2, 1, clr); //deprecated facade x_icon; x_icon.draw(graph, {}, colors::black, { r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); @@ -153,19 +149,16 @@ namespace nana virtual void back(graph_reference graph, const nana::rectangle& r, state_t sta) { - //using namespace nana::paint::gadget; //deprecated _m_draw_arrow(graph, r, sta, direction::west); } virtual void next(graph_reference graph, const nana::rectangle& r, state_t sta) { - //using namespace nana::paint::gadget; //deprecated _m_draw_arrow(graph, r, sta, direction::east); } virtual void list(graph_reference graph, const nana::rectangle& r, state_t sta) { - //using namespace nana::paint::gadget; //deprecated _m_draw_arrow(graph, r, sta, direction::south); } private: @@ -1448,7 +1441,6 @@ namespace nana private: void _m_calc_metrics(graph_reference graph, std::forward_list& items) { - const auto height_px = graph.height(); std::vector pxs; unsigned pixels = 0; diff --git a/source/paint/gadget.cpp b/source/paint/gadget.cpp deleted file mode 100644 index c6da79e6..00000000 --- a/source/paint/gadget.cpp +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Graphics Gadget Implementation - * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-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/paint/gadget.cpp - */ - -#include -#include - -namespace nana -{ -namespace paint -{ -namespace gadget -{ - void close_16_pixels(::nana::paint::graphics& graph, int x, int y, unsigned style, const ::nana::color& clr) - { - graph.set_color(clr); - if(0 == style) - { - x += 3; - y += 3; - - graph.line({ x, y }, { x + 9, y + 9 }); - graph.line({ x + 1, y }, { x + 9, y + 8 }); - graph.line({ x, y + 1 }, { x + 8, y + 9 }); - - graph.line({ x + 9, y }, { x, y + 9 }); - graph.line({ x + 8, y }, { x, y + 8 }); - graph.line({ x + 9, y + 1 }, { x + 1, y + 9 }); - } - else - { - x += 4; - y += 4; - - graph.line({ x, y }, { x + 7, y + 7 }); - graph.line({ x + 1, y }, { x + 7, y + 6 }); - graph.line({ x, y + 1 }, { x + 6, y + 7 }); - - graph.line({ x + 7, y }, { x, y + 7 }); - graph.line({ x + 6, y }, { x, y + 6 }); - graph.line({ x + 7, y + 1 }, { x + 1, y + 7 }); - } - } - - void cross(graphics& graph, int x, int y, unsigned size, unsigned thickness, const ::nana::color& clr) - { - if (thickness + 2 <= size) - { - int gap = (size - thickness) / 2; - - nana::point ps[12]; - ps[0].x = x + gap; - ps[1].x = ps[0].x + thickness - 1; - ps[1].y = ps[0].y = y; - - ps[2].x = ps[1].x; - ps[2].y = y + gap; - - ps[3].x = ps[2].x + gap; - ps[3].y = ps[2].y; - - ps[4].x = ps[3].x; - ps[4].y = ps[3].y + thickness - 1; - - ps[5].x = ps[1].x; - ps[5].y = ps[4].y; - - ps[6].x = ps[5].x; - ps[6].y = ps[5].y + gap; - - ps[7].x = x + gap; - ps[7].y = ps[6].y; - - ps[8].x = ps[7].x; - ps[8].y = ps[4].y; - - ps[9].x = x; - ps[9].y = ps[4].y; - - ps[10].x = x; - ps[10].y = y + gap; - - ps[11].x = x + gap; - ps[11].y = y + gap; - - graph.set_color(clr.blend(colors::black, true)); - - for (int i = 0; i < 11; ++i) - graph.line(ps[i], ps[i + 1]); - graph.line(ps[11], ps[0]); - - graph.set_color(clr); - graph.rectangle(rectangle{ ps[10].x + 1, ps[10].y + 1, (gap << 1) + thickness - 2, thickness - 2 }, true); - graph.rectangle(rectangle{ ps[0].x + 1, ps[0].y + 1, thickness - 2, (gap << 1) + thickness - 2 }, true); - } - } -}//end namespace gadget - -}//end namespace paint -}//end namespace nana diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index cba4b272..562d6fac 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -845,13 +845,13 @@ namespace paint BITMAPFILEHEADER bmFileHeader = { 0 }; bmFileHeader.bfType = 0x4d42; //bmp bmFileHeader.bfOffBits = sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER); - bmFileHeader.bfSize = bmFileHeader.bfOffBits + imageBytes; + bmFileHeader.bfSize = bmFileHeader.bfOffBits + static_cast(imageBytes); HANDLE hFile = ::CreateFileW(static_cast(::nana::charset(file_utf8, ::nana::unicode::utf8)).data(), GENERIC_WRITE, 0, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); DWORD dwWrite = 0; ::WriteFile(hFile, &bmFileHeader, sizeof(BITMAPFILEHEADER), &dwWrite, nullptr); ::WriteFile(hFile, &bmpInfo.bmiHeader, sizeof(BITMAPINFOHEADER), &dwWrite, nullptr); - ::WriteFile(hFile, pData, imageBytes, &dwWrite, nullptr); + ::WriteFile(hFile, pData, static_cast(imageBytes), &dwWrite, nullptr); ::CloseHandle(hFile); ::DeleteObject(hBmp); From ebd8da13f0a0f395dbbce9749583c65f9ddaf555 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 1 Sep 2015 03:49:38 +0800 Subject: [PATCH 06/65] adjust dockpanes when a dockpane is floating/docking --- include/nana/gui/widgets/tabbar.hpp | 10 +- source/gui/place.cpp | 139 ++++++++++++++++++++++++++-- source/gui/place_parts.hpp | 10 +- source/gui/widgets/tabbar.cpp | 62 ++++++++++++- 4 files changed, 199 insertions(+), 22 deletions(-) diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 02722d96..a788dc29 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -337,8 +337,6 @@ namespace nana namespace nana { - namespace ng - { namespace drawerbase { namespace tabbar_lite @@ -352,7 +350,7 @@ namespace nana driver(); ~driver(); - model* get_model(); + model* get_model() const throw(); private: //Overrides drawer_trigger's method void attached(widget_reference, graph_reference) override; @@ -373,11 +371,15 @@ namespace nana tabbar_lite() = default; tabbar_lite(window, bool visible = true, const::nana::rectangle& = {}); + public: //capacity + std::size_t length() const; + + public: //modifiers + void attach(std::size_t pos, window); void push_back(std::string text, ::nana::any par = {}); void push_front(std::string text, ::nana::any par = {}); }; - } } #endif diff --git a/source/gui/place.cpp b/source/gui/place.cpp index aa1f02f8..92033b99 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1602,16 +1602,83 @@ namespace nana } private: //Implement dock_notifier_interface + /* + static div_dockpane* _m_left(div_dockpane* dockpn) + { + for (auto & dv : dockpn->div_owner->children) + { + if (dv->div_next == dockpn) + return static_cast(dv.get()); + } + return nullptr; + } + + ::nana::size _m_calc_space_if_remove(div_dockpane* dockpn) + { + div_owner->field_area; + + auto left = _m_left(dockpn); + while (left && !left->display) + left = _m_left(left); + + auto right = dockpn->div_next; + while (right && !right->display) + right = right->div_next; + + } + */ void notify_float() override { set_display(false); + /* + this->width_percent = field_area.width / div_owner->field_area.width * 100.0; + this->height_percent = field_area.height / div_owner->field_area.height * 100.0; + + + //Re-layout the siblings + double other_px = this->div_owner->field_area.height - this->field_area.height; + for (auto& div : this->div_owner->children) + { + if (!div->display) + continue; + + //deprecated + //auto wgt_percent = div->field_area.height / other_px; + //div->weight.assign_percent(wgt_percent * 100.0); + + //???? other_px issue, have + auto dockpn = dynamic_cast(div.get()); + dockpn->width_percent = div->field_area.width / other_px * 100.0; + dockpn->height_percent = div->field_area.height / other_px * 100.0; + } + + this->weight.assign_percent((double(field_area.height) / this->div_owner->field_area.height) * 100.0); + */ impl_ptr_->collocate(); } void notify_dock() override { indicator_.docker.reset(); + + /* + //Re-layout the siblings + auto px = this->weight.get_value(div_owner->field_area.height); + + double other_px = this->div_owner->field_area.height - px; + + this->weight.assign_percent(px / div_owner->field_area.height * 100); + for (auto& div : this->div_owner->children) + { + if (!div->display) + continue; + + auto px = div->weight.get_value(static_cast(other_px)); + div->weight.assign_percent(px / div_owner->field_area.height * 100); + } + */ + set_display(true); impl_ptr_->collocate(); } @@ -1744,6 +1811,8 @@ namespace nana } public: field_dock * dockable_field{ nullptr }; + double width_percent{ -1 }; //[-1, 100] it's invalid if it is less than zero + double height_percent{ -1 }; //[-1, 100] private: implement * impl_ptr_; bool created_{ false }; @@ -1751,7 +1820,7 @@ namespace nana struct indicator_tag { paint::graphics graph; - //panel widget; + //panel widget; //deprecated rectangle r; std::unique_ptr> dock_area; std::unique_ptr docker; @@ -1766,6 +1835,19 @@ namespace nana : division(kind::dock, std::move(name)) {} + division* front() const + { + auto i = children.cbegin(); + + for (auto i = children.cbegin(); i != children.cend(); ++i) + { + if (i->get()->display) + return i->get(); + } + + return nullptr; + } + void collocate(window wd) override { auto area = this->margin_area(); @@ -1773,20 +1855,30 @@ namespace nana unsigned vert_count = 0, horz_count = 0; unsigned vert_weight = 0, horz_weight = 0; - bool prev_attr = _m_is_vert(children.front()->dir); + bool prev_attr = _m_is_vert(front()->dir); (prev_attr ? horz_count : vert_count) = 1; for (auto & child : children) { - auto is_vert = _m_is_vert(child->dir); + if (!child->display) + continue; - if (child->weight.is_not_none()) + auto child_dv = dynamic_cast(child.get()); + + const auto is_vert = _m_is_vert(child->dir); + + /* + if (is_vert) { - if (is_vert) - vert_weight += static_cast(child->weight.get_value(area.height)); - else - horz_weight += static_cast(child->weight.get_value(area.width)); + if (child_dv->height_percent >= 0) + vert_weight += static_cast(child_dv->height_percent * area.height); } + else + { + if (child_dv->width_percent >= 0) + horz_weight += static_cast(child_dv->width_percent * area.width); + } + */ if (is_vert == prev_attr) { @@ -1819,12 +1911,36 @@ namespace nana for (auto & child : children) { + if (!child->display) + continue; + + auto child_dv = dynamic_cast(child.get()); double weight; + + /* //deprecated if (child->weight.is_not_none()) weight = child->weight.get_value(_m_is_vert(child->dir) ? area.height : area.height); else weight = (_m_is_vert(child->dir) ? auto_vert_w : auto_horz_w); + if (_m_is_vert(child->dir)) + { + if (child_dv->height_percent >= 0) + weight = child_dv->height_percent * area.height; + else + weight = auto_vert_w; + } + else + { + if (child_dv->width_percent >= 0) + weight = child_dv->width_percent * area.width; + else + weight = auto_horz_w; + } + */ + + weight = (_m_is_vert(child->dir) ? auto_vert_w : auto_horz_w); + ::nana::rectangle child_r; switch (child->dir) { @@ -2216,7 +2332,12 @@ namespace nana std::vector> adjusted_children; for (auto & child : children) { - adjusted_children.emplace_back(new div_dockpane(std::move(child->name), this, child->dir)); + //ignores weight if it is a dockpane + //internally, width_percent/height_percent are employed for weight + auto dockpn = new div_dockpane(std::move(child->name), this, child->dir); + dockpn->div_next = child->div_next; + dockpn->div_owner = child->div_owner; + adjusted_children.emplace_back(dockpn); } children.swap(adjusted_children); diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 3a1b670e..b90732f5 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -198,7 +198,7 @@ namespace nana }); if (panels_.size() > 1) - tabbar_.reset(new tabbar(*this)); + tabbar_.reset(new tabbar_lite(*this)); std::size_t pos = 0; for (auto & pn : panels_) @@ -208,8 +208,10 @@ namespace nana pn.widget_ptr = pn.factory_fn(*this); if (tabbar_) { - tabbar_->push_back(pn.widget_ptr->caption()); - tabbar_->relate(pos++, pn.widget_ptr->handle()); + tabbar_->push_back(::nana::charset(pn.widget_ptr->caption())); + tabbar_->attach(pos++, pn.widget_ptr->handle()); + //tabbar_->push_back(pn.widget_ptr->caption()); + //tabbar_->relate(pos++, pn.widget_ptr->handle()); } } } @@ -262,7 +264,7 @@ namespace nana std::unique_ptr container_; dockarea_caption caption_; std::deque panels_; - std::unique_ptr> tabbar_; + std::unique_ptr tabbar_; struct moves { diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 624b5db1..3796a1ac 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1275,8 +1275,6 @@ namespace nana #include namespace nana { - namespace ng - { namespace drawerbase { namespace tabbar_lite @@ -1286,6 +1284,7 @@ namespace nana ::std::string text; ::nana::any value; ::std::pair pos_ends; + ::nana::window attached_window{ nullptr }; item(std::string t, ::nana::any v) : text(std::move(t)), value(std::move(v)) @@ -1361,6 +1360,23 @@ namespace nana return items_; } + void show_attached_window() + { + if (indexes_.active_pos != npos) + { + auto i = items_.cbegin(); + std::advance(i, indexes_.active_pos); + API::show_window(i->attached_window, true); + + std::size_t pos = 0; + for (auto & m : items_) + { + if (pos++ != indexes_.active_pos) + API::show_window(m.attached_window, false); + } + } + } + bool track_pointer(const point& pos) { std::size_t item_pos = 0; @@ -1476,7 +1492,7 @@ namespace nana delete model_; } - model* driver::get_model() + model* driver::get_model() const throw() { return model_; } @@ -1514,10 +1530,12 @@ namespace nana void driver::mouse_down(graph_reference graph, const arg_mouse&) { auto & indexes = model_->get_indexes(); - if (indexes.hovered_pos == model_->npos) + if ((indexes.hovered_pos == model_->npos) || (indexes.active_pos == indexes.hovered_pos)) return; indexes.active_pos = indexes.hovered_pos; + model_->show_attached_window(); + refresh(graph); API::lazy_refresh(); } @@ -1532,6 +1550,41 @@ namespace nana this->create(parent_wd, r, visible); } + //capacity + std::size_t tabbar_lite::length() const + { + auto& items = get_drawer_trigger().get_model()->items(); + internal_scope_guard lock; + + std::size_t off = 0; + auto i = items.cbegin(), end = items.cend(); + while (i != end) + { + ++i; + ++off; + } + return off; + } + + //modifiers + void tabbar_lite::attach(std::size_t pos_set, window wd) + { + auto model = get_drawer_trigger().get_model(); + internal_scope_guard lock; + + for (auto & m : model->items()) + { + if (0 == pos_set--) + { + m.attached_window = wd; + model->show_attached_window(); + return; + } + } + + throw std::out_of_range("invalid position of tabbar_lite"); + } + void tabbar_lite::push_back(std::string text, ::nana::any any) { auto & items = get_drawer_trigger().get_model()->items(); @@ -1561,5 +1614,4 @@ namespace nana API::refresh_window(handle()); } //end class tabbar - } }//end namespace nana From 33006ddc4dd9872c787e4a76a95c9a1956412672 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 1 Sep 2015 23:37:08 +0800 Subject: [PATCH 07/65] re-collocate when drag the float dockpane over indicato indicatorr --- source/gui/place.cpp | 130 ++++--------------------------------------- 1 file changed, 11 insertions(+), 119 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 92033b99..27124a99 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1574,7 +1574,6 @@ namespace nana { if (!dockable_field) { - // if (name.empty()) return; @@ -1597,64 +1596,14 @@ namespace nana if (!dockarea.empty() && !dockarea.floating()) { dockarea.move(this->field_area); - indicator_.r = this->field_area; + //indicator_.r = this->field_area; //deprecated } } private: //Implement dock_notifier_interface - /* - static div_dockpane* _m_left(div_dockpane* dockpn) - { - for (auto & dv : dockpn->div_owner->children) - { - if (dv->div_next == dockpn) - return static_cast(dv.get()); - } - return nullptr; - } - - ::nana::size _m_calc_space_if_remove(div_dockpane* dockpn) - { - div_owner->field_area; - - auto left = _m_left(dockpn); - while (left && !left->display) - left = _m_left(left); - - auto right = dockpn->div_next; - while (right && !right->display) - right = right->div_next; - - } - */ void notify_float() override { set_display(false); - - /* - this->width_percent = field_area.width / div_owner->field_area.width * 100.0; - this->height_percent = field_area.height / div_owner->field_area.height * 100.0; - - - //Re-layout the siblings - double other_px = this->div_owner->field_area.height - this->field_area.height; - for (auto& div : this->div_owner->children) - { - if (!div->display) - continue; - - //deprecated - //auto wgt_percent = div->field_area.height / other_px; - //div->weight.assign_percent(wgt_percent * 100.0); - - //???? other_px issue, have - auto dockpn = dynamic_cast(div.get()); - dockpn->width_percent = div->field_area.width / other_px * 100.0; - dockpn->height_percent = div->field_area.height / other_px * 100.0; - } - - this->weight.assign_percent((double(field_area.height) / this->div_owner->field_area.height) * 100.0); - */ impl_ptr_->collocate(); } @@ -1662,23 +1611,6 @@ namespace nana { indicator_.docker.reset(); - /* - //Re-layout the siblings - auto px = this->weight.get_value(div_owner->field_area.height); - - double other_px = this->div_owner->field_area.height - px; - - this->weight.assign_percent(px / div_owner->field_area.height * 100); - for (auto& div : this->div_owner->children) - { - if (!div->display) - continue; - - auto px = div->weight.get_value(static_cast(other_px)); - div->weight.assign_percent(px / div_owner->field_area.height * 100); - } - */ - set_display(true); impl_ptr_->collocate(); } @@ -1705,14 +1637,8 @@ namespace nana arrow.direction(::nana::direction::south); arrow.draw(graph, colors::light_sky_blue, colors::midnight_blue, { 12, 0, 16, 16 }, element_state::normal); - rectangle r{ 4, 16, 24, 11 }; - graph.rectangle(r, true, colors::midnight_blue); - - r.x = 5; - r.y = 19; - r.width = 22; - r.height = 7; - graph.rectangle(r, true, colors::button_face); + graph.rectangle({ 4, 16, 24, 11 }, true, colors::midnight_blue); + graph.rectangle({ 5, 19, 22, 7 }, true, colors::button_face); }); indicator_.docker->z_order(nullptr, ::nana::z_order_action::topmost); @@ -1732,16 +1658,19 @@ namespace nana { if (!indicator_.dock_area) { + set_display(true); + impl_ptr_->collocate(); + indicator_.graph.make(API::window_size(impl_ptr_->window_handle)); API::window_graphics(impl_ptr_->window_handle, indicator_.graph); indicator_.dock_area.reset(new panel(impl_ptr_->window_handle, false)); - indicator_.dock_area->move(indicator_.r); + indicator_.dock_area->move(this->field_area); ::nana::drawing dw(indicator_.dock_area->handle()); dw.draw([this](paint::graphics& graph) { - indicator_.graph.paste(indicator_.r, graph, 0, 0); + indicator_.graph.paste(this->field_area, graph, 0, 0); const int border_px = 4; rectangle r{ graph.size() }; @@ -1772,6 +1701,8 @@ namespace nana } else { + set_display(false); + impl_ptr_->collocate(); if (indicator_.dock_area) { indicator_.dock_area.reset(); @@ -1811,8 +1742,6 @@ namespace nana } public: field_dock * dockable_field{ nullptr }; - double width_percent{ -1 }; //[-1, 100] it's invalid if it is less than zero - double height_percent{ -1 }; //[-1, 100] private: implement * impl_ptr_; bool created_{ false }; @@ -1820,8 +1749,7 @@ namespace nana struct indicator_tag { paint::graphics graph; - //panel widget; //deprecated - rectangle r; + //rectangle r; //deprecated std::unique_ptr> dock_area; std::unique_ptr docker; }indicator_; @@ -1867,19 +1795,6 @@ namespace nana const auto is_vert = _m_is_vert(child->dir); - /* - if (is_vert) - { - if (child_dv->height_percent >= 0) - vert_weight += static_cast(child_dv->height_percent * area.height); - } - else - { - if (child_dv->width_percent >= 0) - horz_weight += static_cast(child_dv->width_percent * area.width); - } - */ - if (is_vert == prev_attr) { if (is_vert) @@ -1917,28 +1832,6 @@ namespace nana auto child_dv = dynamic_cast(child.get()); double weight; - /* //deprecated - if (child->weight.is_not_none()) - weight = child->weight.get_value(_m_is_vert(child->dir) ? area.height : area.height); - else - weight = (_m_is_vert(child->dir) ? auto_vert_w : auto_horz_w); - - if (_m_is_vert(child->dir)) - { - if (child_dv->height_percent >= 0) - weight = child_dv->height_percent * area.height; - else - weight = auto_vert_w; - } - else - { - if (child_dv->width_percent >= 0) - weight = child_dv->width_percent * area.width; - else - weight = auto_horz_w; - } - */ - weight = (_m_is_vert(child->dir) ? auto_vert_w : auto_horz_w); ::nana::rectangle child_r; @@ -2333,7 +2226,6 @@ namespace nana for (auto & child : children) { //ignores weight if it is a dockpane - //internally, width_percent/height_percent are employed for weight auto dockpn = new div_dockpane(std::move(child->name), this, child->dir); dockpn->div_next = child->div_next; dockpn->div_owner = child->div_owner; From 66d531c520d5b2c47d0a52e63b3a7dffc32a973e Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 6 Sep 2015 22:33:39 +0800 Subject: [PATCH 08/65] add splitbars between dockable panes --- source/gui/place.cpp | 179 ++++++++++++++++++++++++++++++++++++------- 1 file changed, 151 insertions(+), 28 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 27124a99..401f5294 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1592,12 +1592,8 @@ namespace nana dockarea.create(wd, this); } - if (!dockarea.empty() && !dockarea.floating()) - { dockarea.move(this->field_area); - //indicator_.r = this->field_area; //deprecated - } } private: //Implement dock_notifier_interface @@ -1746,10 +1742,10 @@ namespace nana implement * impl_ptr_; bool created_{ false }; - struct indicator_tag + // + struct indicator_rep { paint::graphics graph; - //rectangle r; //deprecated std::unique_ptr> dock_area; std::unique_ptr docker; }indicator_; @@ -1758,9 +1754,74 @@ namespace nana class place::implement::div_dock : public division { + static const unsigned splitter_px = 5; + + class splitter : public panel + { + public: + splitter(window wd, bool vert) + : panel(wd, true), vert_(vert) + { + this->bgcolor(colors::alice_blue); + this->cursor(vert ? ::nana::cursor::size_ns : ::nana::cursor::size_we); + + this->events().mouse_down([this](const arg_mouse& arg) + { + if (arg.button != ::nana::mouse::left_button) + return; + + API::capture_window(this->handle(), true); + auto basepos = API::cursor_position(); + base_pos_.x = (vert_ ? basepos.y : basepos.x); + + basepos = this->pos(); + base_pos_.y = (vert_ ? basepos.y : basepos.x); + }); + + this->events().mouse_up([this] + { + API::capture_window(this->handle(), false); + }); + + this->events().mouse_move([this](const arg_mouse& arg) + { + if (!arg.is_left_button()) + return; + + auto now_pos = API::cursor_position(); + int delta = (vert_ ? now_pos.y : now_pos.x) - base_pos_.x; + int new_pos = base_pos_.y + delta; + if (new_pos < range_.x) + new_pos = range_.x; + else if (new_pos >= range_.y) + new_pos = range_.y - 1; + + now_pos = this->pos(); + if (vert_) + now_pos.y = new_pos; + else + now_pos.x = new_pos; + this->move(now_pos); + }); + } + + void range(int begin, int end) + { + range_.x = begin; + range_.y = end; + } + private: + const bool vert_; + ::nana::point range_; + ::nana::point base_pos_; //x = mouse pos, y = splitter pos + division * left_; + division * right_; + + }; public: + div_dock(std::string && name, implement* impl) - : division(kind::dock, std::move(name)) + : division(kind::dock, std::move(name)), impl_(impl) {} division* front() const @@ -1781,10 +1842,9 @@ namespace nana auto area = this->margin_area(); unsigned vert_count = 0, horz_count = 0; - unsigned vert_weight = 0, horz_weight = 0; - bool prev_attr = _m_is_vert(front()->dir); - (prev_attr ? horz_count : vert_count) = 1; + bool is_first = true; + bool prev_attr; for (auto & child : children) { @@ -1794,21 +1854,18 @@ namespace nana auto child_dv = dynamic_cast(child.get()); const auto is_vert = _m_is_vert(child->dir); + if (is_first) + { + is_first = false; + (is_vert ? horz_count : vert_count) = 1; + prev_attr = is_vert; + } - if (is_vert == prev_attr) - { - if (is_vert) - ++vert_count; - else - ++horz_count; - } + if ((is_vert == prev_attr) == is_vert) + ++vert_count; else - { - if (is_vert) - ++horz_count; - else - ++vert_count; - } + ++horz_count; + prev_attr = is_vert; } if (0 == vert_count) @@ -1816,23 +1873,39 @@ namespace nana if (0 == horz_count) ++horz_count; - double auto_horz_w = double(area.width - horz_weight) / horz_count; - double auto_vert_w = double(area.height - vert_weight) / vert_count; + double auto_horz_w = double(area.width - splitter_px * (horz_count - 1))/ horz_count; + double auto_vert_w = double(area.height - splitter_px * (vert_count - 1)) / vert_count; double left = area.x; double right = area.right(); double top = area.y; double bottom = area.bottom(); + std::map> swp_splitters; + for (auto & child : children) { if (!child->display) continue; auto child_dv = dynamic_cast(child.get()); - double weight; + const bool is_vert = _m_is_vert(child->dir); - weight = (_m_is_vert(child->dir) ? auto_vert_w : auto_horz_w); + double weight = (is_vert ? auto_vert_w : auto_horz_w); + + auto div_next = _m_right(child_dv); + + auto & splitter_ptr = swp_splitters[child_dv]; + + auto si = splitters_.find(child_dv); + if (si == splitters_.end()) + { + splitter_ptr.reset(new splitter(impl_->window_handle, is_vert)); + } + else + { + splitter_ptr.swap(si->second); + } ::nana::rectangle child_r; switch (child->dir) @@ -1844,6 +1917,12 @@ namespace nana child_r.width = static_cast(weight); child_r.height = static_cast(bottom - top); left += weight; + if (div_next) + { + splitter_ptr->move(rectangle{child_r.right(), child_r.y, splitter_px, child_r.height}); + splitter_ptr->range(left - weight, right - static_cast(splitter_px)); + left += splitter_px; + } break; case ::nana::direction::east: right -= weight; @@ -1851,6 +1930,12 @@ namespace nana child_r.y = static_cast(top); child_r.width = static_cast(weight); child_r.height = static_cast(bottom - top); + if (div_next) + { + splitter_ptr->move(rectangle{ child_r.x - static_cast(splitter_px), child_r.y, splitter_px, child_r.height }); + splitter_ptr->range(left, right - static_cast(splitter_px) + weight); + right -= splitter_px; + } break; case ::nana::direction::north: child_r.x = static_cast(left); @@ -1858,6 +1943,12 @@ namespace nana child_r.width = static_cast(right - left); child_r.height = static_cast(weight); top += weight; + if (div_next) + { + splitter_ptr->move(rectangle{ child_r.x, child_r.bottom(), child_r.width, splitter_px }); + splitter_ptr->range(top - weight, bottom - static_cast(splitter_px)); + top += splitter_px; + } break; case ::nana::direction::south: child_r.x = static_cast(left); @@ -1865,18 +1956,44 @@ namespace nana child_r.y = static_cast(bottom); child_r.width = static_cast(right - left); child_r.height = static_cast(weight); + if (div_next) + { + bottom -= splitter_px; + splitter_ptr->move(rectangle{ child_r.x, child_r.y - static_cast(splitter_px), child_r.width, splitter_px }); + splitter_ptr->range(top, bottom + weight); + } break; } + + child->field_area = child_r; child->collocate(wd); } + + splitters_.swap(swp_splitters); } private: static bool _m_is_vert(::nana::direction dir) { return (dir == ::nana::direction::north || dir == ::nana::direction::south); } + + static div_dockpane* _m_right(division* dv) + { + dv = dv->div_next; + while (dv) + { + if (dv->display) + return dynamic_cast(dv); + + dv = dv->div_next; + } + return nullptr; + } + private: + implement * const impl_; + std::map> splitters_; }; place::implement::~implement() @@ -2227,11 +2344,17 @@ namespace nana { //ignores weight if it is a dockpane auto dockpn = new div_dockpane(std::move(child->name), this, child->dir); - dockpn->div_next = child->div_next; dockpn->div_owner = child->div_owner; adjusted_children.emplace_back(dockpn); } + division * next = nullptr; + for (auto i = adjusted_children.rbegin(); i != adjusted_children.rend(); ++i) + { + i->get()->div_next = next; + next = i->get(); + } + children.swap(adjusted_children); } } From 651d0f72ddea12e4ce82e53c3e3dfb7c3898d4a7 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 7 Sep 2015 00:24:44 +0800 Subject: [PATCH 09/65] add process of dockpane splitbar --- source/gui/place.cpp | 73 ++++++++++++++++++++++++++++++++++---------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 401f5294..b7feadbe 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1759,11 +1759,11 @@ namespace nana class splitter : public panel { public: - splitter(window wd, bool vert) - : panel(wd, true), vert_(vert) + splitter(window wd, ::nana::direction dir, division* dock_dv, division* pane_dv) + : panel(wd, true), dir_(dir), dock_dv_(dock_dv), pane_dv_(pane_dv) { this->bgcolor(colors::alice_blue); - this->cursor(vert ? ::nana::cursor::size_ns : ::nana::cursor::size_we); + this->cursor(_m_is_vert(dir_) ? ::nana::cursor::size_ns : ::nana::cursor::size_we); this->events().mouse_down([this](const arg_mouse& arg) { @@ -1772,10 +1772,10 @@ namespace nana API::capture_window(this->handle(), true); auto basepos = API::cursor_position(); - base_pos_.x = (vert_ ? basepos.y : basepos.x); + base_pos_.x = (_m_is_vert(dir_) ? basepos.y : basepos.x); basepos = this->pos(); - base_pos_.y = (vert_ ? basepos.y : basepos.x); + base_pos_.y = (_m_is_vert(dir_) ? basepos.y : basepos.x); }); this->events().mouse_up([this] @@ -1783,13 +1783,13 @@ namespace nana API::capture_window(this->handle(), false); }); - this->events().mouse_move([this](const arg_mouse& arg) + this->events().mouse_move([this, wd](const arg_mouse& arg) { if (!arg.is_left_button()) return; auto now_pos = API::cursor_position(); - int delta = (vert_ ? now_pos.y : now_pos.x) - base_pos_.x; + int delta = (_m_is_vert(dir_) ? now_pos.y : now_pos.x) - base_pos_.x; int new_pos = base_pos_.y + delta; if (new_pos < range_.x) new_pos = range_.x; @@ -1797,11 +1797,36 @@ namespace nana new_pos = range_.y - 1; now_pos = this->pos(); - if (vert_) + if (_m_is_vert(dir_)) now_pos.y = new_pos; else now_pos.x = new_pos; this->move(now_pos); + + auto & px = (_m_is_vert(dir_) ? pane_dv_->field_area.height : pane_dv_->field_area.width); + switch (dir_) + { + case ::nana::direction::west: + case ::nana::direction::north: + if (delta < 0) + px -= static_cast(-delta); + else + px += static_cast(delta); + break; + case ::nana::direction::east: + case ::nana::direction::south: + if (delta < 0) + px += static_cast(-delta); + else + px -= static_cast(delta); + break; + } + + auto dock_px = (_m_is_vert(dir_) ? dock_dv_->field_area.height : dock_dv_->field_area.width); + + pane_dv_->weight.assign_percent(px / dock_px * 100); + + dock_dv_->collocate(wd); }); } @@ -1811,11 +1836,11 @@ namespace nana range_.y = end; } private: - const bool vert_; + const ::nana::direction dir_; + division* const dock_dv_; + division* const pane_dv_; ::nana::point range_; ::nana::point base_pos_; //x = mouse pos, y = splitter pos - division * left_; - division * right_; }; public: @@ -1873,8 +1898,11 @@ namespace nana if (0 == horz_count) ++horz_count; - double auto_horz_w = double(area.width - splitter_px * (horz_count - 1))/ horz_count; - double auto_vert_w = double(area.height - splitter_px * (vert_count - 1)) / vert_count; + //room indicates the size without splitters + ::nana::size room(area.width - splitter_px * (horz_count - 1), area.height - splitter_px * (vert_count - 1)); + + //double auto_horz_w = double(area.width - splitter_px * (horz_count - 1))/ horz_count; + //double auto_vert_w = double(area.height - splitter_px * (vert_count - 1)) / vert_count; double left = area.x; double right = area.right(); @@ -1891,7 +1919,11 @@ namespace nana auto child_dv = dynamic_cast(child.get()); const bool is_vert = _m_is_vert(child->dir); - double weight = (is_vert ? auto_vert_w : auto_horz_w); + double weight; + if (child->weight.is_none()) + weight = (is_vert ? (room.height / double(vert_count)) : (room.width / double(horz_count))); + else + weight = child->weight.get_value(is_vert ? area.height : area.width); auto div_next = _m_right(child_dv); @@ -1900,7 +1932,7 @@ namespace nana auto si = splitters_.find(child_dv); if (si == splitters_.end()) { - splitter_ptr.reset(new splitter(impl_->window_handle, is_vert)); + splitter_ptr.reset(new splitter(impl_->window_handle, child->dir, this, child_dv)); } else { @@ -1965,7 +1997,16 @@ namespace nana break; } - + if (is_vert) + { + room.height -= child_r.height; + --vert_count; + } + else + { + room.width -= child_r.width; + --horz_count; + } child->field_area = child_r; child->collocate(wd); From b453529366a569c17710250162e48c0751ebdd42 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 7 Sep 2015 08:55:49 +0800 Subject: [PATCH 10/65] add process of dockpane's splitbar --- source/gui/place.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index b7feadbe..1f046799 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1776,6 +1776,8 @@ namespace nana basepos = this->pos(); base_pos_.y = (_m_is_vert(dir_) ? basepos.y : basepos.x); + + base_px_ = (_m_is_vert(dir_) ? pane_dv_->field_area.height : pane_dv_->field_area.width); }); this->events().mouse_up([this] @@ -1803,7 +1805,7 @@ namespace nana now_pos.x = new_pos; this->move(now_pos); - auto & px = (_m_is_vert(dir_) ? pane_dv_->field_area.height : pane_dv_->field_area.width); + auto px = base_px_; switch (dir_) { case ::nana::direction::west: @@ -1824,7 +1826,7 @@ namespace nana auto dock_px = (_m_is_vert(dir_) ? dock_dv_->field_area.height : dock_dv_->field_area.width); - pane_dv_->weight.assign_percent(px / dock_px * 100); + pane_dv_->weight.assign_percent(double(px) / double(dock_px) * 100); dock_dv_->collocate(wd); }); @@ -1841,6 +1843,7 @@ namespace nana division* const pane_dv_; ::nana::point range_; ::nana::point base_pos_; //x = mouse pos, y = splitter pos + unsigned base_px_; //weight of div_dockpane when mouse button is been pressing; }; public: From 65a876cc74ab07e6bbf21ff2ec7996bc5fcbcedb Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 7 Sep 2015 09:12:51 +0800 Subject: [PATCH 11/65] the dockpane splitbar is done --- source/gui/place.cpp | 64 +++++++++++++++++++++++++++----------------- 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 1f046799..6e82a599 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1794,9 +1794,15 @@ namespace nana int delta = (_m_is_vert(dir_) ? now_pos.y : now_pos.x) - base_pos_.x; int new_pos = base_pos_.y + delta; if (new_pos < range_.x) + { new_pos = range_.x; + delta = new_pos - base_pos_.y; + } else if (new_pos >= range_.y) + { new_pos = range_.y - 1; + delta = new_pos - base_pos_.y; + } now_pos = this->pos(); if (_m_is_vert(dir_)) @@ -1922,24 +1928,32 @@ namespace nana auto child_dv = dynamic_cast(child.get()); const bool is_vert = _m_is_vert(child->dir); + auto room_px = (is_vert ? room.height : room.width); + double weight; - if (child->weight.is_none()) - weight = (is_vert ? (room.height / double(vert_count)) : (room.width / double(horz_count))); - else - weight = child->weight.get_value(is_vert ? area.height : area.width); - - auto div_next = _m_right(child_dv); - - auto & splitter_ptr = swp_splitters[child_dv]; - - auto si = splitters_.find(child_dv); - if (si == splitters_.end()) + if (child->weight.is_not_none()) { - splitter_ptr.reset(new splitter(impl_->window_handle, child->dir, this, child_dv)); + weight = child->weight.get_value(is_vert ? area.height : area.width); + if (weight > room_px) + weight = room_px; } else + weight = room_px / double(is_vert ? vert_count : horz_count); + + splitter* split = nullptr; + if (_m_right(child_dv)) { - splitter_ptr.swap(si->second); + //Creates a splitbar if the 'right' leaf is not empty + + auto & splitter_ptr = swp_splitters[child_dv]; + + auto si = splitters_.find(child_dv); + if (si == splitters_.end()) + splitter_ptr.reset(new splitter(impl_->window_handle, child->dir, this, child_dv)); + else + splitter_ptr.swap(si->second); + + split = splitter_ptr.get(); } ::nana::rectangle child_r; @@ -1952,10 +1966,10 @@ namespace nana child_r.width = static_cast(weight); child_r.height = static_cast(bottom - top); left += weight; - if (div_next) + if (split) { - splitter_ptr->move(rectangle{child_r.right(), child_r.y, splitter_px, child_r.height}); - splitter_ptr->range(left - weight, right - static_cast(splitter_px)); + split->move(rectangle{ child_r.right(), child_r.y, splitter_px, child_r.height }); + split->range(left - weight, right - static_cast(splitter_px)); left += splitter_px; } break; @@ -1965,10 +1979,10 @@ namespace nana child_r.y = static_cast(top); child_r.width = static_cast(weight); child_r.height = static_cast(bottom - top); - if (div_next) + if (split) { - splitter_ptr->move(rectangle{ child_r.x - static_cast(splitter_px), child_r.y, splitter_px, child_r.height }); - splitter_ptr->range(left, right - static_cast(splitter_px) + weight); + split->move(rectangle{ child_r.x - static_cast(splitter_px), child_r.y, splitter_px, child_r.height }); + split->range(left, right - static_cast(splitter_px)+weight); right -= splitter_px; } break; @@ -1978,10 +1992,10 @@ namespace nana child_r.width = static_cast(right - left); child_r.height = static_cast(weight); top += weight; - if (div_next) + if (split) { - splitter_ptr->move(rectangle{ child_r.x, child_r.bottom(), child_r.width, splitter_px }); - splitter_ptr->range(top - weight, bottom - static_cast(splitter_px)); + split->move(rectangle{ child_r.x, child_r.bottom(), child_r.width, splitter_px }); + split->range(top - weight, bottom - static_cast(splitter_px)); top += splitter_px; } break; @@ -1991,11 +2005,11 @@ namespace nana child_r.y = static_cast(bottom); child_r.width = static_cast(right - left); child_r.height = static_cast(weight); - if (div_next) + if (split) { bottom -= splitter_px; - splitter_ptr->move(rectangle{ child_r.x, child_r.y - static_cast(splitter_px), child_r.width, splitter_px }); - splitter_ptr->range(top, bottom + weight); + split->move(rectangle{ child_r.x, child_r.y - static_cast(splitter_px), child_r.width, splitter_px }); + split->range(top, bottom + weight); } break; } From edd7de4e8b848f6251613af3c3e8b6519f6e1305 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 10 Sep 2015 23:36:16 +0800 Subject: [PATCH 12/65] fix a color issue --- source/detail/linux_X11/platform_spec.cpp | 4 ++-- source/detail/win32/platform_spec.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index 7501158d..0765b46c 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -304,12 +304,12 @@ namespace detail void drawable_impl_type::set_color(const ::nana::color& clr) { - color_ = clr.px_color().value; + color_ = (clr.px_color().value & 0xFFFFFF); } void drawable_impl_type::set_text_color(const ::nana::color& clr) { - text_color_ = clr.px_color().value; + text_color_ = (clr.px_color().value & 0xFFFFFF); update_text_color(); } diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index cb064545..dcc22037 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -65,12 +65,12 @@ namespace detail void drawable_impl_type::set_color(const ::nana::color& clr) { - color_ = clr.px_color().value; + color_ = (clr.px_color().value & 0xFFFFFF); } void drawable_impl_type::set_text_color(const ::nana::color& clr) { - auto rgb = clr.px_color().value; + auto rgb = (clr.px_color().value & 0xFFFFFF); if (text_color_ != rgb) { ::SetTextColor(context, NANA_RGB(rgb)); From ec098640fd044272252ad2563162a57f7107e1cd Mon Sep 17 00:00:00 2001 From: Robert Date: Sun, 13 Sep 2015 19:27:55 +0200 Subject: [PATCH 13/65] Fix Visual Studio 2015 codecvt linker errors Add missing defines --- CMakeLists.txt | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 242a1ea2..3fbd6ed5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,8 +34,13 @@ if(BIICODE) # we'll use the default config file so we can iliminate the following macro definitions if(MSVC) # More MSVC specific compilation flags - add_definitions(-D_SCL_SECURE_NO_WARNINGS) - add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + add_definitions(-D_SCL_SECURE_NO_WARNINGS) + add_definitions(-D_CRT_SECURE_NO_DEPRECATE) + if(MSVC14) + add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) + else() + add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept) + endif() endif() add_biicode_targets() From e97d2cb20f18444a5b3a97d19aa5537c68d5b955 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 14 Sep 2015 01:48:30 +0800 Subject: [PATCH 14/65] fix color issues --- .../nana/detail/linux_X11/platform_spec.hpp | 2 ++ include/nana/detail/win32/platform_spec.hpp | 1 + include/nana/paint/graphics.hpp | 7 +++++-- source/detail/linux_X11/platform_spec.cpp | 10 +++++++++ source/detail/win32/platform_spec.cpp | 5 +++++ source/paint/graphics.cpp | 21 +++++++++++++++++++ source/paint/text_renderer.cpp | 7 +++++-- 7 files changed, 49 insertions(+), 4 deletions(-) diff --git a/include/nana/detail/linux_X11/platform_spec.hpp b/include/nana/detail/linux_X11/platform_spec.hpp index ae4a1830..461517f9 100644 --- a/include/nana/detail/linux_X11/platform_spec.hpp +++ b/include/nana/detail/linux_X11/platform_spec.hpp @@ -106,6 +106,8 @@ namespace detail ~drawable_impl_type(); void fgcolor(const ::nana::color&); //deprecated + unsigned get_color() const; + unsigned get_text_color() const; void set_color(const ::nana::color&); void set_text_color(const ::nana::color&); diff --git a/include/nana/detail/win32/platform_spec.hpp b/include/nana/detail/win32/platform_spec.hpp index e8db5fff..3afea077 100644 --- a/include/nana/detail/win32/platform_spec.hpp +++ b/include/nana/detail/win32/platform_spec.hpp @@ -146,6 +146,7 @@ namespace detail void fgcolor(const ::nana::color&); //deprecated unsigned get_color() const; + unsigned get_text_color() const; void set_color(const ::nana::color&); void set_text_color(const ::nana::color&); diff --git a/include/nana/paint/graphics.hpp b/include/nana/paint/graphics.hpp index ad2c8a6c..a194aa7e 100644 --- a/include/nana/paint/graphics.hpp +++ b/include/nana/paint/graphics.hpp @@ -136,8 +136,11 @@ namespace nana /// @param file_utf8 A UTF-8 string to a filename void save_as_file(const char* file_utf8) const throw(); - void set_color(const ::nana::color&); - void set_text_color(const ::nana::color&); + void set_color(const ::nana::color&); //deprecated, graphics::palette() instead + void set_text_color(const ::nana::color&); //deprecated, graphics::palette() instead + + ::nana::color palette(bool for_text) const; + graphics& palette(bool for_text, const ::nana::color&); unsigned bidi_string(const nana::point&, const char_t *, std::size_t len); unsigned bidi_string(const point& pos, const char*, std::size_t len); diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index 0765b46c..8d4ff735 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -302,6 +302,16 @@ namespace detail #endif } + unsigned drawable_impl_type::get_color() const + { + return color_; + } + + unsigned drawable_impl_type::get_text_color() const + { + return text_color_; + } + void drawable_impl_type::set_color(const ::nana::color& clr) { color_ = (clr.px_color().value & 0xFFFFFF); diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index dcc22037..767b843f 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -63,6 +63,11 @@ namespace detail return color_; } + unsigned drawable_impl_type::get_text_color() const + { + return text_color_; + } + void drawable_impl_type::set_color(const ::nana::color& clr) { color_ = (clr.px_color().value & 0xFFFFFF); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index cba4b272..e95e4ef8 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -874,6 +874,27 @@ namespace paint handle_->set_text_color(col); } + ::nana::color graphics::palette(bool for_text) const + { + if (handle_) + return static_cast(for_text ? handle_->get_text_color() : handle_->get_color()); + + return{}; + } + + graphics& graphics::palette(bool for_text, const ::nana::color& clr) + { + if (handle_) + { + if (for_text) + handle_->set_text_color(clr); + else + handle_->set_color(clr); + } + + return *this; + } + unsigned graphics::bidi_string(const nana::point& pos, const char_t * str, std::size_t len) { auto moved_pos = pos; diff --git a/source/paint/text_renderer.cpp b/source/paint/text_renderer.cpp index 9fbcf8f6..eaa87349 100644 --- a/source/paint/text_renderer.cpp +++ b/source/paint/text_renderer.cpp @@ -118,11 +118,12 @@ namespace nana { graphics & graph; int x, endpos; - ::nana::color fgcolor; + //::nana::color fgcolor; //deprecated unsigned omitted_pixels; nana::unicode_bidi bidi; std::vector reordered; + /* //deprecated draw_string_omitted(graphics& graph, int x, int endpos, const ::nana::color& fgcolor, bool omitted) : graph(graph), x(x), endpos(endpos), fgcolor(fgcolor) { @@ -132,6 +133,7 @@ namespace nana else this->endpos = x; } + */ draw_string_omitted(graphics& graph, int x, int endpos, bool omitted) : graph(graph), x(x), endpos(endpos) @@ -169,7 +171,8 @@ namespace nana nana::paint::graphics dum_graph({ r.width, r.height }); dum_graph.bitblt(r, graph, pos); - dum_graph.set_text_color(fgcolor); + //dum_graph.set_text_color(fgcolor); //deprecated + dum_graph.set_text_color(graph.palette(true)); dum_graph.string({}, i.begin, len); r.x = pos.x; From f21ceb0fac24e97b0d48c67cd44c17fe6efb18ae Mon Sep 17 00:00:00 2001 From: Robert Date: Mon, 14 Sep 2015 12:37:28 +0200 Subject: [PATCH 15/65] Add VS2015 Linker fix also for Cmake --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fbd6ed5..2c82d2b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,12 @@ cmake_minimum_required(VERSION 2.8) if(WIN32) add_definitions(-DNANA_WINDOWS) add_definitions(-DPLATFORM_SPEC_HPP=) - + if(MSVC14) + add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) + else() + add_definitions(-DNOT_IMPLEMENTED_KEYWORD_noexcept) + endif() + #Test if it is MINGW if(MINGW) add_definitions(-DNANA_MINGW) From 44a067fd519028b104307aa277384ec38de7887f Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 18 Sep 2015 08:19:25 +0800 Subject: [PATCH 16/65] implement dockpane titlebar --- source/gui/place_parts.hpp | 60 +++++++++++++++++++++++++++++--------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index b90732f5..914dc405 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -63,28 +64,60 @@ namespace nana { public: private: - virtual void attached(widget_reference, graph_reference graph) override + virtual void attached(widget_reference wdg, graph_reference graph) override { - graph.set_color(colors::slate_blue); - graph.set_text_color(colors::white); + window_handle_ = wdg; + text_rd_.reset(new paint::text_renderer(graph)); } void refresh(graph_reference& graph) override { - graph.rectangle(true, colors::red); + graph.set_color(static_cast(0x83EB)); + graph.set_text_color(colors::white); + graph.rectangle(true); + + //draw caption + auto text = API::window_caption(window_handle_); + text = L"dockarea-caption"; + text_rd_->render({ 3, 1 }, text.data(), text.size(), graph.size().width - 20, true); + + //draw x button + auto r = _m_button_area(); + if (x_pointed_) + graph.rectangle(r, true, colors::red); - ::nana::rectangle r{ graph.size() }; - - r.x = r.right() - 20; + r.x += (r.width - 16) / 2; r.y = (r.height - 16) / 2; - r.width = r.height = 16; - - button_.draw(graph, colors::red, colors::white, r, element_state::normal); x_icon_.draw(graph, colors::red, colors::white, r, element_state::normal); } + + void mouse_move(graph_reference graph, const arg_mouse& arg) override + { + x_pointed_ = _m_button_area().is_hit(arg.pos); + + refresh(graph); + API::lazy_refresh(); + } + + void mouse_leave(graph_reference graph, const arg_mouse&) override + { + x_pointed_ = false; + refresh(graph); + API::lazy_refresh(); + } + private: + ::nana::rectangle _m_button_area() const + { + ::nana::rectangle r{API::window_size(window_handle_)}; + + r.x = r.right() - 20; + r.width = 20; + return r; + } public: - ::nana::string caption; - facade button_; + window window_handle_; + std::unique_ptr text_rd_; + bool x_pointed_{ false }; facade x_icon_; }; @@ -130,7 +163,6 @@ namespace nana base_type::create(parent, true); this->caption("dockarea"); caption_.create(*this, true); - caption_.caption("dockarea-caption"); this->events().resized([this](const arg_resized& arg) { @@ -175,7 +207,7 @@ namespace nana auto move_pos = API::cursor_position() - moves_.start_pos; if (!floating()) { - if (std::abs(move_pos.x) > 4 || abs(move_pos.y) > 4) + if (std::abs(move_pos.x) > 4 || std::abs(move_pos.y) > 4) float_away(move_pos); } else From 1d7781e1a6b3322b8a122f2d564e7f71e44a6ab0 Mon Sep 17 00:00:00 2001 From: Pr0curo Date: Fri, 18 Sep 2015 17:20:45 +0200 Subject: [PATCH 17/65] fix for gcc/mingw --- source/filesystem/filesystem.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index 51d70ff4..80396b00 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -430,7 +430,8 @@ namespace nana { delete[] p; return s; } - return buf; + nana::string s = buf; + return s; } #elif defined(NANA_LINUX) const char * s = ::getenv("PWD"); From 5d2127e6131b441ee07c761ab8794243b11a095b Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 19 Sep 2015 05:18:15 +0800 Subject: [PATCH 18/65] improve dockpane factory --- include/nana/gui/place.hpp | 7 ++-- source/gui/place.cpp | 73 +++++++++++++++++++++++++++++++++----- source/gui/place_parts.hpp | 65 ++++++++++++++++++++------------- 3 files changed, 109 insertions(+), 36 deletions(-) diff --git a/include/nana/gui/place.hpp b/include/nana/gui/place.hpp index bd50bee7..2e3676de 100644 --- a/include/nana/gui/place.hpp +++ b/include/nana/gui/place.hpp @@ -127,15 +127,16 @@ namespace nana /// Add a panel factory template - void dock(const std::string& dockname, Args&& ... args) + place& dock(const std::string& dockname, const std::string& factory_name, Args&& ... args) { - dock(dockname, std::bind([](window parent, Args & ... args) + return dock(dockname, factory_name, std::bind([](window parent, Args & ... args) { return std::unique_ptr(new Panel(parent, std::forward(args)...)); }, std::placeholders::_1, args...)); } - void dock(const std::string& dockname, std::function(window)> factory); + place& dock(const std::string& dockname, std::string factory_name, std::function(window)> factory); + place& dock_create(const std::string& factory); private: implement * impl_; }; diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 6e82a599..ce0351c3 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -450,6 +450,7 @@ namespace nana std::unique_ptr root_division; std::map fields; std::map docks; + std::map dock_factoris; //A temporary pointer used to refer to a specified div object which //will be deleted in modification process. @@ -597,8 +598,9 @@ namespace nana { public: - div_dockpane * attached{ nullptr }; //attached div object - place_parts::dockarea dockarea; //the dockable widget + div_dockpane * attached{ nullptr }; //attached div object + std::unique_ptr dockarea; //the dockable widget + std::map(window)>> factories; //factories for dockpane };//end class field_dock @@ -1559,13 +1561,14 @@ namespace nana impl_ptr_{impl} { dir = pane_dir; + this->display = false; } ~div_dockpane() { if (dockable_field) { - dockable_field->dockarea.close(); + dockable_field->dockarea.reset(); dockable_field->attached = nullptr; } } @@ -1586,6 +1589,8 @@ namespace nana } auto & dockarea = dockable_field->dockarea; + + /* if (!created_) { created_ = true; @@ -1594,6 +1599,10 @@ namespace nana if (!dockarea.empty() && !dockarea.floating()) dockarea.move(this->field_area); + */ + + if (dockarea && !dockarea->floating()) + dockarea->move(this->field_area); } private: //Implement dock_notifier_interface @@ -1710,8 +1719,8 @@ namespace nana void notify_move_stopped() { - if (_m_dockable() && dockable_field) - dockable_field->dockarea.dock(); + if (_m_dockable() && dockable_field && dockable_field->dockarea) + dockable_field->dockarea->dock(); indicator_.docker.reset(); } @@ -2514,7 +2523,7 @@ namespace nana for (auto& e : docks_to_be_closed) { - e.second->dockarea.close(); + e.second->dockarea.reset(); e.second->attached->dockable_field = nullptr; e.second->attached = nullptr; } @@ -2747,7 +2756,7 @@ namespace nana return field(name); } - void place::dock(const std::string& name, std::function(window)> factory) + place& place::dock(const std::string& name, std::string factory_name, std::function(window)> factory) { //check the name, it throws std::invalid_argument //if name violate the naming convention. @@ -2757,7 +2766,16 @@ namespace nana if (!dock_ptr) dock_ptr = new implement::field_dock; - dock_ptr->dockarea.add_factory(std::move(factory)); + //Register the factory if it has a name + if (!factory_name.empty()) + { + auto i = impl_->dock_factoris.find(factory_name); + if (i != impl_->dock_factoris.end()) + throw std::invalid_argument("nana::place - the specified factory name(" + factory_name + ") already exists"); + + impl_->dock_factoris[factory_name] = dock_ptr; + dock_ptr->factories[factory_name].swap(factory); + } auto div = dynamic_cast(impl_->search_div_name(impl_->root_division.get(), name)); if (div) @@ -2765,6 +2783,45 @@ namespace nana dock_ptr->attached = div; div->dockable_field = dock_ptr; } + + //Create the pane if it has not a name + if (factory_name.empty()) + { + dock_ptr->attached->set_display(true); + impl_->collocate(); + + if (!dock_ptr->dockarea) + { + dock_ptr->dockarea.reset(new ::nana::place_parts::dockarea); + dock_ptr->dockarea->create(impl_->window_handle, dock_ptr->attached); + dock_ptr->dockarea->move(dock_ptr->attached->field_area); + } + dock_ptr->dockarea->add_pane(factory); + } + + return *this; + } + + place& place::dock_create(const std::string& factory) + { + auto i = impl_->dock_factoris.find(factory); + if (i == impl_->dock_factoris.end()) + throw std::invalid_argument("nana::place - invalid factory name(" + factory + ")"); + + auto dock_ptr = i->second; + dock_ptr->attached->set_display(true); + impl_->collocate(); + + if (!dock_ptr->dockarea) + { + dock_ptr->dockarea.reset(new ::nana::place_parts::dockarea); + dock_ptr->dockarea->create(impl_->window_handle, dock_ptr->attached); + dock_ptr->dockarea->move(dock_ptr->attached->field_area); + } + + dock_ptr->dockarea->add_pane(i->second->factories[factory]); + + return *this; } //end class place }//end namespace nana diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 914dc405..621b93aa 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -148,12 +148,7 @@ namespace nana struct panel { - factory factory_fn; std::unique_ptr widget_ptr; - - panel(factory && fn) - : factory_fn(std::move(fn)) - {} }; public: void create(window parent, place_parts::dock_notifier_interface* notifier) @@ -229,29 +224,49 @@ namespace nana } }); - if (panels_.size() > 1) - tabbar_.reset(new tabbar_lite(*this)); - - std::size_t pos = 0; - for (auto & pn : panels_) - { - if (!pn.widget_ptr) - { - pn.widget_ptr = pn.factory_fn(*this); - if (tabbar_) - { - tabbar_->push_back(::nana::charset(pn.widget_ptr->caption())); - tabbar_->attach(pos++, pn.widget_ptr->handle()); - //tabbar_->push_back(pn.widget_ptr->caption()); - //tabbar_->relate(pos++, pn.widget_ptr->handle()); - } - } - } } - void add_factory(factory && fn) + void add_pane(factory & fn) { - panels_.emplace_back(std::move(fn)); + rectangle r{ point(), this->size()}; + + //get a rectangle excluding caption + r.y = 20; + if (r.height > 20) + r.height -= 20; + else + r.height = 0; + + if (!tabbar_ && panels_.size() > 0) + { + tabbar_.reset(new tabbar_lite(*this)); + tabbar_->move({ 0, r.bottom() - 20, r.width, 20 }); + r.height -= 20; + + std::size_t pos = 0; + for (auto & pn : panels_) + { + tabbar_->push_back(::nana::charset(pn.widget_ptr->caption())); + tabbar_->attach(pos++, *pn.widget_ptr); + } + } + + auto wdg = fn(*this); + + if (tabbar_) + { + tabbar_->push_back(::nana::charset(wdg->caption())); + tabbar_->attach(panels_.size(), *wdg); + } + + panels_.emplace_back(); + panels_.back().widget_ptr.swap(wdg); + + for (auto & pn : panels_) + { + if (pn.widget_ptr) + pn.widget_ptr->move(r); + } } void float_away(const ::nana::point& move_pos) From 460490040e903d96979133626989ef9652f2fb7a Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 20 Sep 2015 23:21:44 +0800 Subject: [PATCH 19/65] improve dockable place add a new API::at_safe_place() --- include/nana/gui/detail/window_manager.hpp | 3 + include/nana/gui/programming_interface.hpp | 2 + include/nana/gui/widgets/tabbar.hpp | 3 + source/gui/detail/linux_X11/bedrock.cpp | 5 +- source/gui/detail/win32/bedrock.cpp | 2 + source/gui/detail/window_manager.cpp | 32 +++++++++++ source/gui/place.cpp | 16 +++++- source/gui/place_parts.hpp | 67 +++++++++++++++++++++- source/gui/programming_interface.cpp | 5 ++ source/gui/widgets/tabbar.cpp | 59 ++++++++++++++++--- 10 files changed, 181 insertions(+), 13 deletions(-) diff --git a/include/nana/gui/detail/window_manager.hpp b/include/nana/gui/detail/window_manager.hpp index ec91fe1f..857d69e7 100644 --- a/include/nana/gui/detail/window_manager.hpp +++ b/include/nana/gui/detail/window_manager.hpp @@ -161,6 +161,9 @@ namespace detail std::vector> shortkeys(core_window_t*, bool with_children); core_window_t* find_shortkey(native_window_type, unsigned long key); + + void set_safe_place(core_window_t* wd, std::function&& fn); + void call_safe_place(unsigned thread_id); private: void _m_disengage(core_window_t*, core_window_t* for_new); void _m_destroy(core_window_t*); diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index bfbcd138..932e35c8 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -298,6 +298,8 @@ namespace API bool ignore_mouse_focus(window, bool ignore); ///< Enables/disables the mouse focus, it returns the previous state bool ignore_mouse_focus(window); ///< Determines whether the mouse focus is enabled + + void at_safe_place(window, std::function); }//end namespace API }//end namespace nana diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index a788dc29..86556cec 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -379,6 +379,9 @@ namespace nana void push_back(std::string text, ::nana::any par = {}); void push_front(std::string text, ::nana::any par = {}); + + std::size_t selected() const; + void erase(std::size_t pos, bool close_attached = true); }; } diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 3cba6d2b..1260067b 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -1207,8 +1207,11 @@ namespace detail if(context) context->event_window = pre_event_window; } + auto thread_id = ::nana::system::this_thread_id() + brock.wd_manager.call_safe_place(thread_id); + if(msgwnd) - brock.wd_manager.remove_trash_handle(::nana::system::this_thread_id()); + brock.wd_manager.remove_trash_handle(thread_id); } } diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index d8ac543c..e1095345 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -413,6 +413,7 @@ namespace detail ::DispatchMessage(&msg); } + wd_manager.call_safe_place(tid); wd_manager.remove_trash_handle(tid); if (msg.message == WM_DESTROY && msg.hwnd == native_handle) break; @@ -432,6 +433,7 @@ namespace detail ::DispatchMessage(&msg); } + wd_manager.call_safe_place(tid); wd_manager.remove_trash_handle(tid); }//end while diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index e9581fd1..e272801b 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -44,6 +44,8 @@ namespace detail handle_manager wd_register; paint::image default_icon_big; paint::image default_icon_small; + + std::map>> safe_place; }; //end struct wdm_private_impl @@ -1192,6 +1194,36 @@ namespace detail return nullptr; } + void window_manager::set_safe_place(core_window_t* wd, std::function&& fn) + { + if (fn) + { + std::lock_guard lock(mutex_); + if (!available(wd)) + return; + + impl_->safe_place[wd].emplace_back(std::move(fn)); + } + } + + void window_manager::call_safe_place(unsigned thread_id) + { + std::lock_guard lock(mutex_); + + for (auto i = impl_->safe_place.begin(); i != impl_->safe_place.end();) + { + if (i->first->thread_id == thread_id) + { + for (auto & fn : i->second) + fn(); + + i = impl_->safe_place.erase(i); + } + else + ++i; + } + } + bool check_tree(basic_window* wd, basic_window* const cond) { if (wd == cond) return true; diff --git a/source/gui/place.cpp b/source/gui/place.cpp index ce0351c3..9d9e9698 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1717,13 +1717,27 @@ namespace nana } - void notify_move_stopped() + void notify_move_stopped() override { if (_m_dockable() && dockable_field && dockable_field->dockarea) dockable_field->dockarea->dock(); indicator_.docker.reset(); } + + void request_close() override + { + auto window_handle = dockable_field->dockarea->handle(); + + //a workaround for capture + auto ptr = dockable_field->dockarea.release(); + API::at_safe_place(window_handle, [this, ptr] + { + decltype(dockable_field->dockarea) del(ptr); + }); + + API::close_window(window_handle); + } private: bool _m_indicator() const { diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 621b93aa..62bd8753 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -57,12 +57,19 @@ namespace nana virtual void notify_dock() = 0; virtual void notify_move() = 0; virtual void notify_move_stopped() = 0; + + //a dockarea requests to close the dockpane + virtual void request_close() = 0; }; class dockcaption_dtrigger : public drawer_trigger { public: + void on_close(std::function&& fn) + { + close_fn_ = std::move(fn); + } private: virtual void attached(widget_reference wdg, graph_reference graph) override { @@ -84,10 +91,18 @@ namespace nana //draw x button auto r = _m_button_area(); if (x_pointed_) - graph.rectangle(r, true, colors::red); + { + color xclr = colors::red; + + if(x_state_ == ::nana::mouse_action::pressed) + xclr = xclr.blend(colors::white, 0.8); + + graph.rectangle(r, true, xclr); + } r.x += (r.width - 16) / 2; r.y = (r.height - 16) / 2; + x_icon_.draw(graph, colors::red, colors::white, r, element_state::normal); } @@ -105,6 +120,29 @@ namespace nana refresh(graph); API::lazy_refresh(); } + + void mouse_down(graph_reference graph, const arg_mouse&) override + { + if (!x_pointed_) + return; + + x_state_ = ::nana::mouse_action::pressed; + + refresh(graph); + API::lazy_refresh(); + } + + void mouse_up(graph_reference graph, const arg_mouse&) override + { + if (!x_pointed_) + return; + + x_state_ = ::nana::mouse_action::over; + refresh(graph); + API::lazy_refresh(); + + close_fn_(); + } private: ::nana::rectangle _m_button_area() const { @@ -118,12 +156,21 @@ namespace nana window window_handle_; std::unique_ptr text_rd_; bool x_pointed_{ false }; + ::nana::mouse_action x_state_{ ::nana::mouse_action::normal }; facade x_icon_; + + std::function close_fn_; }; class dockarea_caption : public widget_object < category::widget_tag, dockcaption_dtrigger > - {}; + { + public: + void on_close(std::function fn) + { + get_drawer_trigger().on_close(std::move(fn)); + } + }; class dock_page : public form @@ -158,6 +205,22 @@ namespace nana base_type::create(parent, true); this->caption("dockarea"); caption_.create(*this, true); + caption_.on_close([this] + { + bool destroy_dockarea = false; + try + { + tabbar_->erase(tabbar_->selected()); + destroy_dockarea = (0 == tabbar_->length()); + } + catch (std::out_of_range&) + { + destroy_dockarea = true; + } + + if (destroy_dockarea) + notifier_->request_close(); + }); this->events().resized([this](const arg_resized& arg) { diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 94ca4fe4..5d4901b7 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -1314,5 +1314,10 @@ namespace API internal_scope_guard lock; return (restrict::window_manager.available(iwd) ? iwd->flags.ignore_mouse_focus : false); } + + void at_safe_place(window wd, std::function fn) + { + restrict::window_manager.set_safe_place(reinterpret_cast(wd), std::move(fn)); + } }//end namespace API }//end namespace nana diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 3796a1ac..cb6eb878 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1555,15 +1555,7 @@ namespace nana { auto& items = get_drawer_trigger().get_model()->items(); internal_scope_guard lock; - - std::size_t off = 0; - auto i = items.cbegin(), end = items.cend(); - while (i != end) - { - ++i; - ++off; - } - return off; + return static_cast(std::distance(items.cbegin(), items.cend())); } //modifiers @@ -1613,5 +1605,54 @@ namespace nana items.emplace_front(std::move(text), std::move(any)); API::refresh_window(handle()); } + + std::size_t tabbar_lite::selected() const + { + auto model = get_drawer_trigger().get_model(); + internal_scope_guard lock; + + return model->get_indexes().active_pos; + } + + void tabbar_lite::erase(std::size_t pos, bool close_attached) + { + auto model = get_drawer_trigger().get_model(); + internal_scope_guard lock; + + const auto len = length(); + + if (len <= pos) + throw std::out_of_range("tabbar_lite: out of range"); + + auto active_pos = model->get_indexes().active_pos; + + if (pos == active_pos) + { + if (active_pos + 1 == len) + { + if (active_pos) + --active_pos; + else + active_pos = npos; + } + } + else if (pos < active_pos) + --active_pos; + + model->get_indexes().active_pos = active_pos; + + auto i = model->items().cbefore_begin(); + std::advance(i, pos); + + auto attached_wd = std::next(i)->attached_window; + + model->items().erase_after(i); + + model->show_attached_window(); + API::refresh_window(handle()); + + if (close_attached && attached_wd) + API::close_window(attached_wd); + } //end class tabbar }//end namespace nana From c04751ac1acdd617f45c582b10c5007b408ee7ff Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 20 Sep 2015 23:34:57 +0800 Subject: [PATCH 20/65] remove some compiler warning --- source/gui/place.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 9d9e9698..598bd962 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1980,6 +1980,7 @@ namespace nana } ::nana::rectangle child_r; + double split_range_begin = -1, split_range_end; switch (child->dir) { default: @@ -1992,7 +1993,8 @@ namespace nana if (split) { split->move(rectangle{ child_r.right(), child_r.y, splitter_px, child_r.height }); - split->range(left - weight, right - static_cast(splitter_px)); + split_range_begin = left - weight; + split_range_end = right - static_cast(splitter_px); left += splitter_px; } break; @@ -2005,7 +2007,8 @@ namespace nana if (split) { split->move(rectangle{ child_r.x - static_cast(splitter_px), child_r.y, splitter_px, child_r.height }); - split->range(left, right - static_cast(splitter_px)+weight); + split_range_begin = left; + split_range_end = right - static_cast(splitter_px)+weight; right -= splitter_px; } break; @@ -2018,7 +2021,8 @@ namespace nana if (split) { split->move(rectangle{ child_r.x, child_r.bottom(), child_r.width, splitter_px }); - split->range(top - weight, bottom - static_cast(splitter_px)); + split_range_begin = top - weight; + split_range_end = bottom - static_cast(splitter_px); top += splitter_px; } break; @@ -2032,11 +2036,16 @@ namespace nana { bottom -= splitter_px; split->move(rectangle{ child_r.x, child_r.y - static_cast(splitter_px), child_r.width, splitter_px }); - split->range(top, bottom + weight); + split_range_begin = top; + split_range_end = bottom + weight; } break; } + if (split_range_begin > -0.5) + split->range(static_cast(split_range_begin), static_cast(split_range_end)); + + if (is_vert) { room.height -= child_r.height; From 8dcd7307155a11b3b5ba2719d9912d6a8a23e3b5 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 21 Sep 2015 23:43:00 +0800 Subject: [PATCH 21/65] improve dockpane caption --- include/nana/gui/programming_interface.hpp | 7 +++ include/nana/gui/widgets/combox.hpp | 4 +- include/nana/gui/widgets/listbox.hpp | 4 +- include/nana/gui/widgets/spinbox.hpp | 4 +- include/nana/gui/widgets/tabbar.hpp | 56 +++++++++++++------- include/nana/gui/widgets/textbox.hpp | 4 +- include/nana/gui/widgets/widget.hpp | 14 +++-- source/gui/place.cpp | 2 +- source/gui/place_parts.hpp | 19 ++++++- source/gui/widgets/tabbar.cpp | 60 +++++++++++++++++----- 10 files changed, 132 insertions(+), 42 deletions(-) diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 932e35c8..6de9ba97 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -29,6 +29,13 @@ namespace nana /// Traits for widget classes template struct widget_traits + { + using event_type = typename Widget::event_type; + using scheme_type = typename Widget::scheme_type; + }; + + template<> + struct widget_traits { using event_type = ::nana::general_events; using scheme_type = ::nana::widget_colors; diff --git a/include/nana/gui/widgets/combox.hpp b/include/nana/gui/widgets/combox.hpp index beb1cece..17bb7cfe 100644 --- a/include/nana/gui/widgets/combox.hpp +++ b/include/nana/gui/widgets/combox.hpp @@ -229,7 +229,8 @@ namespace nana nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override; }; - namespace dev + /* + namespace dev //deprecated { template<> struct widget_traits @@ -238,5 +239,6 @@ namespace nana using scheme_type = ::nana::widgets::skeletons::text_editor_scheme; }; } + */ } #endif diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 140d6dd2..652171a4 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -664,14 +664,16 @@ By \a clicking on one header the list get \a reordered, first up, and then down void _m_erase_key(nana::detail::key_interface*); }; + /* namespace dev { template<> - struct widget_traits + struct widget_traits //deprecated { using event_type = drawerbase::listbox::listbox_events; using scheme_type = drawerbase::listbox::scheme; }; } + */ }//end namespace nana #endif diff --git a/include/nana/gui/widgets/spinbox.hpp b/include/nana/gui/widgets/spinbox.hpp index 22b780e4..09e64faf 100644 --- a/include/nana/gui/widgets/spinbox.hpp +++ b/include/nana/gui/widgets/spinbox.hpp @@ -110,15 +110,17 @@ namespace nana void _m_caption(::nana::string&&); }; //end class spinbox + /* namespace dev { template<> - struct widget_traits + struct widget_traits //deprecated { using event_type = drawerbase::spinbox::spinbox_events; using scheme_type = ::nana::widgets::skeletons::text_editor_scheme; }; } + */ }//end namespace nana #endif //NANA_GUI_WIDGET_SPINBOX_HPP diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 86556cec..3f412f9b 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -336,13 +336,19 @@ namespace nana namespace nana -{ +{ namespace drawerbase { namespace tabbar_lite { class model; + struct events + : public general_events + { + basic_event selected; + }; + class driver : public drawer_trigger { @@ -364,25 +370,39 @@ namespace nana } }//end namespace drawerbase - class tabbar_lite - : public widget_object + class tabbar_lite + : public widget_object + { + public: + tabbar_lite() = default; + tabbar_lite(window, bool visible = true, const::nana::rectangle& = {}); + + public: //capacity + std::size_t length() const; + + public: //modifiers + void attach(std::size_t pos, window); + window attach(std::size_t pos) const; + + void push_back(std::string text, ::nana::any par = {}); + void push_front(std::string text, ::nana::any par = {}); + + std::size_t selected() const; + void erase(std::size_t pos, bool close_attached = true); + }; + + /* + namespace dev + { + /// Traits for widget classes + template<> + struct widget_traits //deprecated { - public: - tabbar_lite() = default; - tabbar_lite(window, bool visible = true, const::nana::rectangle& = {}); - - public: //capacity - std::size_t length() const; - - public: //modifiers - void attach(std::size_t pos, window); - - void push_back(std::string text, ::nana::any par = {}); - void push_front(std::string text, ::nana::any par = {}); - - std::size_t selected() const; - void erase(std::size_t pos, bool close_attached = true); + using event_type = drawerbase::tabbar_lite::events; + using scheme_type = ::nana::widget_colors; }; + } + */ } #endif diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index 85bac2a6..4360cd74 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -195,15 +195,17 @@ namespace nana void _m_typeface(const paint::font&) override; }; + /* namespace dev { /// Traits for widget classes template<> - struct widget_traits + struct widget_traits //deprecated { using event_type = drawerbase::textbox::textbox_events; using scheme_type = ::nana::widgets::skeletons::text_editor_scheme; }; } + */ }//end namespace nana #endif diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index 0288388e..2da63cda 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -134,7 +134,8 @@ namespace nana protected: typedef DrawerTrigger drawer_trigger_t; public: - using scheme_type = Scheme; + using scheme_type = Scheme; + using event_type = Events; widget_object() : events_{ std::make_shared() }, @@ -147,7 +148,7 @@ namespace nana API::close_window(handle_); } - Events& events() const + event_type& events() const { return *events_; } @@ -228,6 +229,7 @@ namespace nana typedef DrawerTrigger drawer_trigger_t; public: using scheme_type = Scheme; + using event_type = Events; widget_object() : events_{ std::make_shared() }, scheme_{ API::dev::make_scheme() } @@ -239,7 +241,7 @@ namespace nana API::close_window(handle_); } - Events& events() const + event_type& events() const { return *events_; } @@ -297,6 +299,7 @@ namespace nana typedef DrawerTrigger drawer_trigger_t; public: using scheme_type = Scheme; + using event_type = Events; widget_object() { @@ -322,7 +325,7 @@ namespace nana API::close_window(handle_); } - Events& events() const + event_type& events() const { return *events_; } @@ -451,6 +454,7 @@ namespace nana typedef int drawer_trigger_t; public: using scheme_type = Scheme; + using event_type = Events; widget_object() : events_{ std::make_shared() }, scheme_{ API::dev::make_scheme() } @@ -462,7 +466,7 @@ namespace nana API::close_window(handle_); } - Events& events() const + event_type& events() const { return *events_; } diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 598bd962..1e8d96ac 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -2829,7 +2829,7 @@ namespace nana { auto i = impl_->dock_factoris.find(factory); if (i == impl_->dock_factoris.end()) - throw std::invalid_argument("nana::place - invalid factory name(" + factory + ")"); + throw std::invalid_argument("invalid factory name(" + factory + ") of dockpane"); auto dock_ptr = i->second; dock_ptr->attached->set_display(true); diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 62bd8753..accb35c9 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -85,7 +85,6 @@ namespace nana //draw caption auto text = API::window_caption(window_handle_); - text = L"dockarea-caption"; text_rd_->render({ 3, 1 }, text.data(), text.size(), graph.size().width - 20, true); //draw x button @@ -303,6 +302,17 @@ namespace nana if (!tabbar_ && panels_.size() > 0) { tabbar_.reset(new tabbar_lite(*this)); + + tabbar_->events().selected.clear(); + tabbar_->events().selected([this] + { + auto handle = tabbar_->attach(tabbar_->selected()); + if (handle) + caption_.caption(API::window_caption(handle)); + else + caption_.caption(::nana::string()); + }); + tabbar_->move({ 0, r.bottom() - 20, r.width, 20 }); r.height -= 20; @@ -319,7 +329,12 @@ namespace nana if (tabbar_) { tabbar_->push_back(::nana::charset(wdg->caption())); - tabbar_->attach(panels_.size(), *wdg); + tabbar_->attach(panels_.size(), wdg->handle()); + } + + if (panels_.empty()) + { + caption_.caption(wdg->caption()); } panels_.emplace_back(); diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index cb6eb878..959d5ff7 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -344,7 +344,7 @@ namespace nana { if(i < list_.size()) return at_no_bound_check(i); - throw std::out_of_range("Nana.GUI.tabbar::at() is out of range"); + throw std::out_of_range("invalid position of tabbar"); } iterator iterator_at(std::size_t pos) @@ -370,7 +370,7 @@ namespace nana { if(pos < list_.size()) return at_no_bound_check(pos); - throw std::out_of_range("Nana.GUI.tabbar::at() const is out of range"); + throw std::out_of_range("invalid position of tabbar"); } const nana::any& at_no_bound_check(std::size_t pos) const @@ -1345,15 +1345,21 @@ namespace nana using graph_reference = ::nana::paint::graphics&; static const std::size_t npos = static_cast(-1); - void set_widget(widget& wdg) + void set_widget(::nana::tabbar_lite& wdg) { widget_ = &wdg; } - ::nana::dev::widget_traits::scheme_type & scheme() + ::nana::tabbar_lite* widget_ptr() const + { + return widget_; + } + /* + ::nana::dev::widget_traits::scheme_type & scheme() //deprecated { return API::scheme(*widget_); } + */ std::forward_list& items() { @@ -1407,7 +1413,7 @@ namespace nana return indexes_; } private: - widget * widget_{ nullptr }; + ::nana::tabbar_lite * widget_{ nullptr }; std::forward_list items_; indexes indexes_; }; @@ -1421,7 +1427,7 @@ namespace nana { _m_calc_metrics(graph, model.items()); - auto & scheme = model.scheme(); + auto & scheme = model.widget_ptr()->scheme(); //draw background graph.rectangle(true, scheme.background); @@ -1499,7 +1505,7 @@ namespace nana void driver::attached(widget_reference wdg, graph_reference) { - model_->set_widget(wdg); + model_->set_widget(dynamic_cast(wdg)); } //Overrides drawer_trigger's method @@ -1533,11 +1539,17 @@ namespace nana if ((indexes.hovered_pos == model_->npos) || (indexes.active_pos == indexes.hovered_pos)) return; - indexes.active_pos = indexes.hovered_pos; - model_->show_attached_window(); + if (indexes.active_pos != indexes.hovered_pos) + { + indexes.active_pos = indexes.hovered_pos; + model_->show_attached_window(); - refresh(graph); - API::lazy_refresh(); + refresh(graph); + API::lazy_refresh(); + + event_arg arg; + model_->widget_ptr()->events().selected.emit(arg); + } } //end class driver } @@ -1577,6 +1589,20 @@ namespace nana throw std::out_of_range("invalid position of tabbar_lite"); } + window tabbar_lite::attach(std::size_t pos_set) const + { + auto model = get_drawer_trigger().get_model(); + internal_scope_guard lock; + + for (auto & m : model->items()) + { + if (0 == pos_set--) + return m.attached_window; + } + + throw std::out_of_range("invalid position of tabbar_lite"); + } + void tabbar_lite::push_back(std::string text, ::nana::any any) { auto & items = get_drawer_trigger().get_model()->items(); @@ -1622,10 +1648,12 @@ namespace nana const auto len = length(); if (len <= pos) - throw std::out_of_range("tabbar_lite: out of range"); + throw std::out_of_range("invalid position of tabbar_lite"); auto active_pos = model->get_indexes().active_pos; + //selection_changed is used to determine whether the title will be updated + bool selection_changed = true; if (pos == active_pos) { if (active_pos + 1 == len) @@ -1638,6 +1666,8 @@ namespace nana } else if (pos < active_pos) --active_pos; + else + selection_changed = false; model->get_indexes().active_pos = active_pos; @@ -1653,6 +1683,12 @@ namespace nana if (close_attached && attached_wd) API::close_window(attached_wd); + + if (selection_changed) + { + event_arg arg; + events().selected.emit(arg); + } } //end class tabbar }//end namespace nana From ccb334a907d3f8388d5e326cba08779c085bbc59 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 22 Sep 2015 21:05:50 +0800 Subject: [PATCH 22/65] fix an crash that caused by accessing an non-existing tabbar --- source/gui/place_parts.hpp | 11 +++++------ source/gui/widgets/tabbar.cpp | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index accb35c9..f82c043e 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -206,16 +206,15 @@ namespace nana caption_.create(*this, true); caption_.on_close([this] { - bool destroy_dockarea = false; - try + bool destroy_dockarea = true; + + if (tabbar_) { tabbar_->erase(tabbar_->selected()); + destroy_dockarea = (0 == tabbar_->length()); } - catch (std::out_of_range&) - { - destroy_dockarea = true; - } + if (destroy_dockarea) notifier_->request_close(); diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 959d5ff7..bbaabeeb 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -1684,7 +1684,7 @@ namespace nana if (close_attached && attached_wd) API::close_window(attached_wd); - if (selection_changed) + if (selection_changed && (active_pos != npos)) { event_arg arg; events().selected.emit(arg); From 8d4ffa068d086bc885c3e5b6c4b3c5ea8a1ff57c Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 22 Sep 2015 23:41:55 +0800 Subject: [PATCH 23/65] improve re-div of a dock place --- source/gui/place.cpp | 51 ++++++++++++++++++++++++++------------ source/gui/place_parts.hpp | 5 +++- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 1e8d96ac..39a72f60 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -468,6 +468,7 @@ namespace nana //connect the field/dock with div object void connect(division* start); + void disconnect(); }; //end struct implement class place::implement::field_gather @@ -2490,15 +2491,7 @@ namespace nana if (!start) return; - //disconnect - for (auto & fd : fields) - { - if (fd.second->attached) - { - fd.second->attached->field = nullptr; - fd.second->attached = nullptr; - } - } + this->disconnect(); std::map docks_to_be_closed; //disconnect @@ -2508,12 +2501,12 @@ namespace nana docks_to_be_closed[dk.first] = dk.second; } - std::function check_fn; - check_fn = [&check_fn, this, &docks_to_be_closed](division* div) + std::function connect_fn; + connect_fn = [&connect_fn, this, &docks_to_be_closed](division* div) { if (div->name.size()) { - if (division::kind::dock == div->kind_of_division) + if (division::kind::dock == div->kind_of_division || division::kind::dockpane == div->kind_of_division) { auto i = docks.find(div->name); if (i != docks.end()) @@ -2521,7 +2514,18 @@ namespace nana docks_to_be_closed.erase(div->name); auto pane = dynamic_cast(div); pane->dockable_field = i->second; + + auto old_pane = pane->dockable_field->attached; + if (old_pane) + { + //old div_dockpane will be deleted + old_pane->dockable_field = nullptr; + div->display = old_pane->display; + } pane->dockable_field->attached = pane; + + if (pane->dockable_field->dockarea) + pane->dockable_field->dockarea->set_notifier(pane); } } else @@ -2538,11 +2542,11 @@ namespace nana for (auto & child : div->children) { - check_fn(child.get()); + connect_fn(child.get()); } }; - check_fn(start); + connect_fn(start); for (auto& e : docks_to_be_closed) { @@ -2552,6 +2556,18 @@ namespace nana } } + void place::implement::disconnect() + { + for (auto & fd : fields) + { + if (fd.second->attached) + { + fd.second->attached->field = nullptr; + fd.second->attached = nullptr; + } + } + } + //class place place::place() : impl_(new implement) @@ -2592,6 +2608,7 @@ namespace nana void place::div(const char* s) { place_parts::tokenizer tknizer(s); + impl_->disconnect(); auto div = impl_->scan_div(tknizer); try { @@ -2816,7 +2833,8 @@ namespace nana if (!dock_ptr->dockarea) { dock_ptr->dockarea.reset(new ::nana::place_parts::dockarea); - dock_ptr->dockarea->create(impl_->window_handle, dock_ptr->attached); + dock_ptr->dockarea->create(impl_->window_handle); + dock_ptr->dockarea->set_notifier(dock_ptr->attached); dock_ptr->dockarea->move(dock_ptr->attached->field_area); } dock_ptr->dockarea->add_pane(factory); @@ -2838,7 +2856,8 @@ namespace nana if (!dock_ptr->dockarea) { dock_ptr->dockarea.reset(new ::nana::place_parts::dockarea); - dock_ptr->dockarea->create(impl_->window_handle, dock_ptr->attached); + dock_ptr->dockarea->create(impl_->window_handle); + dock_ptr->dockarea->set_notifier(dock_ptr->attached); dock_ptr->dockarea->move(dock_ptr->attached->field_area); } diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index f82c043e..686fc4c3 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -197,9 +197,12 @@ namespace nana std::unique_ptr widget_ptr; }; public: - void create(window parent, place_parts::dock_notifier_interface* notifier) + void set_notifier(place_parts::dock_notifier_interface* notifier) { notifier_ = notifier; + } + void create(window parent) + { host_window_ = parent; base_type::create(parent, true); this->caption("dockarea"); From b6dd03e2d5c1944ab4f90d6c4ffe611570145684 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 23 Sep 2015 23:59:31 +0800 Subject: [PATCH 24/65] some small place fixes --- source/gui/place.cpp | 3 +++ source/gui/place_parts.hpp | 41 +++++++++++++++++++++----------------- 2 files changed, 26 insertions(+), 18 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 39a72f60..8654f3aa 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1737,6 +1737,9 @@ namespace nana decltype(dockable_field->dockarea) del(ptr); }); + this->set_display(false); + impl_ptr_->collocate(); + API::close_window(window_handle); } private: diff --git a/source/gui/place_parts.hpp b/source/gui/place_parts.hpp index 686fc4c3..946d03ac 100644 --- a/source/gui/place_parts.hpp +++ b/source/gui/place_parts.hpp @@ -301,30 +301,35 @@ namespace nana else r.height = 0; - if (!tabbar_ && panels_.size() > 0) + if (!tabbar_) { - tabbar_.reset(new tabbar_lite(*this)); - - tabbar_->events().selected.clear(); - tabbar_->events().selected([this] + if (panels_.size() > 0) { - auto handle = tabbar_->attach(tabbar_->selected()); - if (handle) - caption_.caption(API::window_caption(handle)); - else - caption_.caption(::nana::string()); - }); + tabbar_.reset(new tabbar_lite(*this)); - tabbar_->move({ 0, r.bottom() - 20, r.width, 20 }); - r.height -= 20; + tabbar_->events().selected.clear(); + tabbar_->events().selected([this] + { + auto handle = tabbar_->attach(tabbar_->selected()); + if (handle) + caption_.caption(API::window_caption(handle)); + else + caption_.caption(::nana::string()); + }); - std::size_t pos = 0; - for (auto & pn : panels_) - { - tabbar_->push_back(::nana::charset(pn.widget_ptr->caption())); - tabbar_->attach(pos++, *pn.widget_ptr); + tabbar_->move({ 0, r.bottom() - 20, r.width, 20 }); + r.height -= 20; + + std::size_t pos = 0; + for (auto & pn : panels_) + { + tabbar_->push_back(::nana::charset(pn.widget_ptr->caption())); + tabbar_->attach(pos++, *pn.widget_ptr); + } } } + else + r.height -= 20; auto wdg = fn(*this); From 90533b3a831a9719de4e4ef263ab0b1f6a47346d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 27 Sep 2015 04:56:08 +0800 Subject: [PATCH 25/65] update solutions --- build/codeblocks/nana.layout | 158 +++++++++++++++++------------------ 1 file changed, 79 insertions(+), 79 deletions(-) diff --git a/build/codeblocks/nana.layout b/build/codeblocks/nana.layout index 587b86f1..e961df8c 100644 --- a/build/codeblocks/nana.layout +++ b/build/codeblocks/nana.layout @@ -1,9 +1,34 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -11,9 +36,9 @@ - + - + @@ -26,89 +51,34 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - + - + - + @@ -116,9 +86,19 @@ - + - + + + + + + + + + + + @@ -126,29 +106,24 @@ - - - - - + + + + + - + - - - - - - + @@ -156,4 +131,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + From 2f47e89af1d2c5f1ee6d45e3d71bca96e1bca521 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 27 Sep 2015 05:31:42 +0800 Subject: [PATCH 26/65] use lambda instead of std::bind --- include/nana/gui/widgets/checkbox.hpp | 4 +- include/nana/gui/widgets/treebox.hpp | 2 +- source/gui/dragger.cpp | 67 +++++++++++++++++++++++++-- source/gui/tooltip.cpp | 25 +++++++--- source/gui/widgets/checkbox.cpp | 40 ++++++++++++++-- source/gui/widgets/combox.cpp | 29 ++++++++++-- source/gui/widgets/tabbar.cpp | 14 ++++-- source/gui/widgets/treebox.cpp | 59 ++++++++++++++++++++++- 8 files changed, 212 insertions(+), 28 deletions(-) diff --git a/include/nana/gui/widgets/checkbox.hpp b/include/nana/gui/widgets/checkbox.hpp index c0ebee4f..21b63cbd 100644 --- a/include/nana/gui/widgets/checkbox.hpp +++ b/include/nana/gui/widgets/checkbox.hpp @@ -88,8 +88,8 @@ namespace drawerbase std::size_t checked() const; ///< Retrieves the index of the checkbox which is checked. std::size_t size() const; private: - void _m_checked(const arg_click&); - void _m_destroy(const arg_destroy&); + //void _m_checked(const arg_click&); //deprecated + //void _m_destroy(const arg_destroy&); //deprecated private: std::vector ui_container_; }; diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index 5e317781..1878365a 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -167,7 +167,7 @@ namespace nana void key_press(graph_reference, const arg_keyboard&) override; void key_char(graph_reference, const arg_keyboard&) override; private: - void _m_deal_adjust(); + //void _m_deal_adjust(); //deprecated private: implement * const impl_; }; //end class trigger diff --git a/source/gui/dragger.cpp b/source/gui/dragger.cpp index 5bb82baf..58233afc 100644 --- a/source/gui/dragger.cpp +++ b/source/gui/dragger.cpp @@ -65,7 +65,66 @@ namespace nana { trigger_t tg; tg.wd = wd; - auto fn = std::bind(&dragger_impl_t::_m_trace, this, std::placeholders::_1); + //auto fn = std::bind(&dragger_impl_t::_m_trace, this, std::placeholders::_1); //deprecated + auto fn = [this](const arg_mouse& arg) + { + switch (arg.evt_code) + { + case event_code::mouse_down: + dragging_ = true; + API::capture_window(arg.window_handle, true); + origin_ = API::cursor_position(); + for (auto & t : targets_) + { + t.origin = API::window_position(t.wd); + window owner = API::get_owner_window(t.wd); + if (owner) + API::calc_screen_point(owner, t.origin); + } + break; + case event_code::mouse_move: + if (dragging_ && arg.left_button) + { + auto pos = API::cursor_position(); + pos -= origin_; + + for (auto & t : targets_) + { + if (API::is_window_zoomed(t.wd, true) == false) + { + auto owner = API::get_owner_window(t.wd); + auto wdps = t.origin; + if (owner) + API::calc_window_point(owner, wdps); + + switch (t.move_direction) + { + case nana::arrange::horizontal: + wdps.x += pos.x; + break; + case nana::arrange::vertical: + wdps.y += pos.y; + break; + default: + wdps += pos; + } + + if (!t.restrict_area.empty()) + _m_check_restrict_area(wdps, API::window_size(t.wd), t.restrict_area); + + API::move_window(t.wd, wdps); + } + } + } + break; + case event_code::mouse_up: + API::capture_window(arg.window_handle, false); + dragging_ = false; + break; + default: + break; + } + }; auto & events = API::events(wd); tg.press = events.mouse_down.connect(fn); tg.over = events.mouse_move.connect(fn); @@ -117,8 +176,8 @@ namespace nana if (pos.y < restr_area.y) pos.y = restr_area.y; } - - void _m_trace(const arg_mouse& arg) + /* + void _m_trace(const arg_mouse& arg) //deprecated { switch(arg.evt_code) { @@ -177,7 +236,7 @@ namespace nana break; } } - + */ private: bool dragging_; nana::point origin_; diff --git a/source/gui/tooltip.cpp b/source/gui/tooltip.cpp index 04e6f258..17104556 100644 --- a/source/gui/tooltip.cpp +++ b/source/gui/tooltip.cpp @@ -147,7 +147,6 @@ namespace nana timer_.reset(); this->close(); } - private: timer timer_; nana::label label_; @@ -256,7 +255,8 @@ namespace nana instance(true); } private: - void _m_enter(const arg_mouse& arg) + /* + void _m_enter(const arg_mouse& arg) //deprecated { pair_t & pr = _m_get(arg.window_handle); if(pr.second.size()) @@ -264,16 +264,21 @@ namespace nana this->show(pr.second); } } + */ - void _m_leave(const arg_mouse&) + /* + void _m_leave(const arg_mouse&) //deprecated { close(); } + */ - void _m_destroy(const arg_destroy& arg) + /* + void _m_destroy(const arg_destroy& arg) //deprecated { _m_untip(arg.window_handle); } + */ void _m_untip(window wd) { @@ -303,15 +308,21 @@ namespace nana auto & events = API::events(wd); events.mouse_enter.connect([this](const arg_mouse& arg){ - _m_enter(arg); + auto & pr = _m_get(arg.window_handle); + if (pr.second.size()) + this->show(pr.second); }); - auto leave_fn = std::bind(&controller::_m_leave, this, std::placeholders::_1); + //auto leave_fn = std::bind(&controller::_m_leave, this, std::placeholders::_1); //deprecated + + auto leave_fn = [this]{ + this->close(); + }; events.mouse_leave.connect(leave_fn); events.mouse_down.connect(leave_fn); events.destroy.connect([this](const arg_destroy& arg){ - _m_destroy(arg); + _m_untip(arg.window_handle); }); cont_.emplace_back(wd, nana::string()); diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index 582803cc..46fb8d63 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -213,8 +213,35 @@ namespace checkbox element_tag el; el.uiobj = &uiobj; - el.eh_checked = uiobj.events().click.connect_unignorable(std::bind(&radio_group::_m_checked, this, std::placeholders::_1), true); - el.eh_destroy = uiobj.events().destroy.connect_unignorable(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1)); + //el.eh_checked = uiobj.events().click.connect_unignorable(std::bind(&radio_group::_m_checked, this, std::placeholders::_1), true); //deprecated + el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg) + { + for (auto & i : ui_container_) + i.uiobj->check(arg.window_handle == i.uiobj->handle()); + }, true); + + //el.eh_destroy = uiobj.events().destroy.connect_unignorable(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1)); //deprecated + el.eh_destroy = uiobj.events().destroy.connect_unignorable([this](const arg_destroy& arg) + { + /* + auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [&arg](decltype(*ui_container_.begin()) & x) + { + return (arg.window_handle == x.uiobj->handle()); + }); + if (i != ui_container_.end()) + ui_container_.erase(i); + */ + + for (auto i = ui_container_.begin(); i != ui_container_.end(); ++i) + { + if (arg.window_handle == i->uiobj->handle()) + { + ui_container_.erase(i); + return; + } + } + }); + ui_container_.push_back(el); } @@ -231,14 +258,16 @@ namespace checkbox { return ui_container_.size(); } - - void radio_group::_m_checked(const arg_click& arg) + /* + void radio_group::_m_checked(const arg_click& arg) //deprecated { for (auto & i : ui_container_) i.uiobj->check(arg.window_handle == i.uiobj->handle()); } + */ - void radio_group::_m_destroy(const arg_destroy& arg) + /* + void radio_group::_m_destroy(const arg_destroy& arg) //deprecated { auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [&arg](decltype(*ui_container_.begin()) & x) { @@ -247,5 +276,6 @@ namespace checkbox if(i != ui_container_.end()) ui_container_.erase(i); } + */ //end class radio_group }//end namespace nana diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index c6f3a32f..d89e36ef 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -172,10 +172,31 @@ namespace nana { editor_->editable(enb); + /* if(enb) editor_->ext_renderer().background = nullptr; else - editor_->ext_renderer().background = std::bind(&drawer_impl::_m_draw_background, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); + editor_->ext_renderer().background = std::bind(&drawer_impl::_m_draw_background, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); //deprecated + */ + if (!enb) + { + editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&) + { + auto clr_from = colors::button_face_shadow_start; + auto clr_to = colors::button_face_shadow_end; + + int pare_off_px = 1; + if (element_state::pressed == state_.button_state) + { + pare_off_px = 2; + std::swap(clr_from, clr_to); + } + + graph.gradual_rectangle(::nana::rectangle(graph.size()).pare_off(pare_off_px), clr_from, clr_to, true); + }; + } + else + editor_->ext_renderer().background = nullptr; editor_->enable_background(enb); editor_->enable_background_counterpart(!enb); @@ -433,8 +454,8 @@ namespace nana API::refresh_window(*widget_); } } - - void _m_draw_background(graph_reference graph, const rectangle&, const ::nana::color&) + /* + void _m_draw_background(graph_reference graph, const rectangle&, const ::nana::color&) //deprecated { auto clr_from = colors::button_face_shadow_start; auto clr_to = colors::button_face_shadow_end; @@ -448,7 +469,7 @@ namespace nana graph.gradual_rectangle(::nana::rectangle(graph.size()).pare_off(pare_off_px), clr_from, clr_to, true); } - + */ void _m_draw_push_button(bool enabled) { ::nana::rectangle r{graph_->size()}; diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index bbaabeeb..f66b9ca4 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -767,20 +767,28 @@ namespace nana { menulister_.clear(); - auto f = std::bind(&layouter::_m_click_menulister, this, std::placeholders::_1); + //auto f = std::bind(&layouter::_m_click_menulister, this, std::placeholders::_1); //deprecated + auto fn = [this](::nana::menu::item_proxy& ipx) + { + if (this->activate(ipx.index())) + API::refresh_window(basis_.wd); + }; + for(auto & m : list_) - menulister_.append(m.text, f); + menulister_.append(m.text, fn); auto r = toolbox_.area(toolbox_.ButtonList, basis_.graph->height()); r.x += _m_toolbox_pos(); menulister_.popup(basis_.wd, r.x, r.bottom()); } - void _m_click_menulister(nana::menu::item_proxy& ip) + /* + void _m_click_menulister(nana::menu::item_proxy& ip) //deprecated { if(this->activate(ip.index())) API::refresh_window(basis_.wd); } + */ //the begin pos of toolbox int _m_toolbox_pos() const diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index 9362b243..d995a2fa 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -1491,7 +1491,60 @@ namespace nana impl_->data.trigger_ptr = this; impl_->data.renderer = nana::pat::cloneable(internal_renderer()); impl_->data.comp_placer = nana::pat::cloneable(internal_placer()); - impl_->adjust.timer.elapse(std::bind(&trigger::_m_deal_adjust, this)); + //impl_->adjust.timer.elapse(std::bind(&trigger::_m_deal_adjust, this)); //deprecated + impl_->adjust.timer.elapse([this] + { + auto & adjust = impl_->adjust; + if (adjust.scroll_timestamp && (nana::system::timestamp() - adjust.scroll_timestamp >= 500)) + { + if (0 == adjust.offset_x_adjust) + { + if (!impl_->make_adjust(adjust.node ? adjust.node : impl_->shape.first, 1)) + { + adjust.offset_x_adjust = 0; + adjust.node = nullptr; + adjust.scroll_timestamp = 0; + adjust.timer.stop(); + return; + } + } + + auto & shape = impl_->shape; + const int delta = 5; + int old = shape.offset_x; + + if (shape.offset_x < adjust.offset_x_adjust) + { + shape.offset_x += delta; + if (shape.offset_x > adjust.offset_x_adjust) + shape.offset_x = adjust.offset_x_adjust; + } + else if (shape.offset_x > adjust.offset_x_adjust) + { + shape.offset_x -= delta; + if (shape.offset_x < adjust.offset_x_adjust) + shape.offset_x = adjust.offset_x_adjust; + } + + impl_->draw(false); + API::update_window(impl_->data.widget_ptr->handle()); + + if (impl_->node_state.tooltip) + { + nana::point pos = impl_->node_state.tooltip->pos(); + impl_->node_state.tooltip->move(pos.x - shape.offset_x + old, pos.y); + } + + if (shape.offset_x == adjust.offset_x_adjust) + { + adjust.offset_x_adjust = 0; + adjust.node = nullptr; + adjust.scroll_timestamp = 0; + adjust.timer.stop(); + } + } + }); + impl_->adjust.timer.interval(16); impl_->adjust.timer.start(); } @@ -2099,7 +2152,8 @@ namespace nana } } - void trigger::_m_deal_adjust() + /* + void trigger::_m_deal_adjust() //deprecated { auto & adjust = impl_->adjust; if(adjust.scroll_timestamp && (nana::system::timestamp() - adjust.scroll_timestamp >= 500)) @@ -2151,6 +2205,7 @@ namespace nana } } } + //*/ //end class trigger }//end namespace treebox }//end namespace drawerbase From 3c13cec4b7d32ab167f500258956fa034fa9ff34 Mon Sep 17 00:00:00 2001 From: Haitao Zhang Date: Sat, 26 Sep 2015 18:32:53 -0700 Subject: [PATCH 27/65] Change cmake MinGW build default to include thread support. --- CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 242a1ea2..e05c03be 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,11 @@ if(WIN32) if(MINGW) add_definitions(-DNANA_MINGW) add_definitions(-DSTD_CODECVT_NOT_SUPPORTED) - option(NANA_THREAD_NOT_SUPPORTED "Use this flag if MinGW version is older than 4.8.1" ON) + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.8.1") + option(NANA_THREAD_NOT_SUPPORTED "Use this flag if MinGW version is older than 4.8.1" ON) + endif() + endif() if(NANA_THREAD_NOT_SUPPORTED) add_definitions(-DSTD_THREAD_NOT_SUPPORTED) endif() From 43372225494e81373b37d063e805155a08d3b7d6 Mon Sep 17 00:00:00 2001 From: Haitao Zhang Date: Sat, 26 Sep 2015 18:33:54 -0700 Subject: [PATCH 28/65] Fix return char * when path is expected by explicit cast to nana::string first. --- source/filesystem/filesystem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/filesystem/filesystem.cpp b/source/filesystem/filesystem.cpp index 51d70ff4..215a587e 100644 --- a/source/filesystem/filesystem.cpp +++ b/source/filesystem/filesystem.cpp @@ -430,7 +430,7 @@ namespace nana { delete[] p; return s; } - return buf; + return (nana::string) buf; } #elif defined(NANA_LINUX) const char * s = ::getenv("PWD"); From 7e493155113e956804644c1089c889515fcdfbdc Mon Sep 17 00:00:00 2001 From: Haitao Zhang Date: Sat, 26 Sep 2015 18:43:01 -0700 Subject: [PATCH 29/65] Add autogenerated files by CMake and ninja to .gitignore. --- .gitignore | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.gitignore b/.gitignore index a8f12de9..7e623b17 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,7 @@ _ReSharper*/ *.suo *.sdf lib/ +*.ninja* +CMakeCache.txt +CMakeFiles/ +cmake_install.cmake From 6ca50a7cb4ede30a134cba066798e9bb7e96a13d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 30 Sep 2015 17:03:49 +0800 Subject: [PATCH 30/65] fix a division by zero of scrollbar --- source/gui/widgets/scroll.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/gui/widgets/scroll.cpp b/source/gui/widgets/scroll.cpp index 6c85a2ad..bfac622f 100644 --- a/source/gui/widgets/scroll.cpp +++ b/source/gui/widgets/scroll.cpp @@ -90,7 +90,11 @@ namespace nana metrics_.scroll_pos = pos; auto value_max = metrics_.peak - metrics_.range; - metrics_.value = pos * value_max / scroll_area; + + //Check scroll_area to avoiding division by zero. + if (scroll_area) + metrics_.value = pos * value_max / scroll_area; + if(metrics_.value < value_max) { int selfpos = static_cast(metrics_.value * scroll_area / value_max); From 7cb27951e0fd2829c18b11e7e6ca22c5be4db87f Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 30 Sep 2015 17:09:55 +0800 Subject: [PATCH 31/65] fix 2 listbox issues inline widget modifies a wrong item when the listbox is sorted a crash issue when erasing the last item if the listbox is sorted --- source/gui/widgets/listbox.cpp | 203 ++++++++++++--------------------- 1 file changed, 75 insertions(+), 128 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index c9402b8c..422f778a 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -438,14 +438,6 @@ namespace nana return pixels; } - /* - /// return the original order or index previous to any list reorganization of the current column "n". - size_type index(size_type n) const //deprecated - { - return (n < cont_.size() ? cont_[n].index : npos); - } - */ - const container& cont() const { return cont_; @@ -565,19 +557,6 @@ namespace nana return; } } - /* - auto i = std::find_if(cont_.begin(), cont_.end(), [index](container::value_type& m){return (index == m.index);}); //deprecated - - if (i == cont_.end()) - return; - - column_t from = std::move(*i); //move - cont_.erase(i); - - i = std::find_if(cont_.begin(), cont_.end(), [to](const container::value_type& m)->bool{ return (to == m.index); } ); - if(i != cont_.end()) - cont_.insert((front ? i : ++i), from); - */ } private: bool visible_{true}; @@ -961,6 +940,11 @@ namespace nana return *(_m_at(cat_pos)); } + category_t::container::value_type& at_abs(const index_pair& pos) + { + return _m_at(pos.cat)->items.at(pos.item); + } + /// return a ref to the real item object at display!!! position pos using current sorting only if it is active, and at absolute position if no sorting is currently active. category_t::container::value_type& at(const index_pair& pos) { @@ -1142,16 +1126,7 @@ namespace nana } } - void erase(const index_pair& pos) - { - auto & catobj = *_m_at(pos.cat); - if(pos.item < catobj.items.size()) - { - catobj.items.erase(catobj.items.begin() + pos.item); - catobj.sorted.erase(std::find(catobj.sorted.begin(), catobj.sorted.end(), catobj.items.size())); - sort(); - } - } + void erase(const index_pair& pos); void erase(size_type cat) { @@ -1709,37 +1684,40 @@ namespace nana auto & catobj = *_m_at(display_pos.cat); - if(catobj.items.size()==0) + if(catobj.items.empty()) return (display_pos == index_pair{0,0} ? 0 : npos); - return catobj.sorted[display_pos.item] ; + return (display_pos.item < catobj.sorted.size() ? catobj.sorted[display_pos.item] : npos); } index_pair absolute_pair(const index_pair& display_pos) const { - return {display_pos.cat, absolute( display_pos )}; + //Returns an empty pos if item pos npos + auto item_pos = absolute(display_pos); + return {item_pos != npos ? display_pos.cat : npos, item_pos}; } ///Translate absolute position (original data order) into relative position (position in display) size_type relative(const index_pair& pos) const { if (sorted_index_ == npos) - return pos.item ; + return pos.item ; - auto & catobj = *_m_at(pos.cat); + auto & catobj = *_m_at(pos.cat); - for (size_type i=0; i 0 ? npos : 0); - scroll.offset_y_dpl = scroll.offset_y_abs ; - return ; - } - scroll_y_dpl_refresh() ; + { + scroll.offset_y_abs.item = (pos_abs.cat > 0 ? npos : 0); + scroll.offset_y_dpl = scroll.offset_y_abs ; + return ; + } + scroll_y_dpl_refresh() ; } void scroll_y_rel(const index_pair& pos_rel) { - scroll_y_abs(lister.relative_pair(pos_rel) ); + scroll_y_abs(lister.relative_pair(pos_rel) ); } - void set_scroll_y_abs(const index_pair& pos_abs) - { - scroll.offset_y_abs=pos_abs; - scroll_y_dpl_refresh() ; - } - /// directly set a tested relative display pos + /// directly set a tested relative display pos void set_scroll_y_dpl(const index_pair& pos_dpl) - { - scroll.offset_y_dpl=pos_dpl; - scroll.offset_y_abs = lister.absolute_pair(pos_dpl); - } + { + scroll.offset_y_dpl = pos_dpl; + scroll.offset_y_abs = lister.absolute_pair(pos_dpl); + + if (scroll.offset_y_abs.empty()) + throw std::invalid_argument("nana.listbox.set_scroll_y_dpl's exception is due to invalid item, please report a bug"); + } //number_of_lister_item @@ -2038,15 +2014,6 @@ namespace nana trace_item_abs(lister.last_selected_abs); } - /* - void trace_first_selected_item() //deprecated - { - auto fs=lister.find_first_selected(); - if( ! fs.empty() ) - trace_item_abs( fs ); - } - */ - void update() { if(auto_draw && lister.wd_ptr()) @@ -2374,6 +2341,7 @@ namespace nana auto ptr = pane_ptr.get(); inline_table[factory].emplace_back(std::move(pane_ptr)); + ptr->inline_ptr->whether_to_draw(); return ptr; } }; @@ -2396,12 +2364,15 @@ namespace nana void modify(index_type pos, const value_type& value) const override { - auto & cells = ess_->lister.at(pos).cells; + auto & cells = ess_->lister.at_abs(pos).cells; if (cells.size() <= column_pos_) cells.resize(column_pos_ + 1); - cells[column_pos_].text = value; - ess_->update(); + if (cells[column_pos_].text != value) + { + cells[column_pos_].text = value; + ess_->update(); + } } void selected(index_type pos) override @@ -2428,6 +2399,18 @@ namespace nana const std::size_t column_pos_; }; + void es_lister::erase(const index_pair& pos) + { + auto & catobj = *_m_at(pos.cat); + if (pos.item < catobj.items.size()) + { + catobj.items.erase(catobj.items.begin() + pos.item); + catobj.sorted.erase(std::find(catobj.sorted.begin(), catobj.sorted.end(), catobj.items.size())); + + sort(); + } + } + void es_lister::scroll_refresh() { ess_->scroll_y_dpl_refresh(); @@ -2639,8 +2622,6 @@ namespace nana void draw(const nana::rectangle& r) { - //_m_draw(essence_->header.cont(), r); //deprecated - graph_reference graph = *(essence_->graph); int text_top = (r.height - essence_->text_height) / 2 + r.y; @@ -2716,44 +2697,6 @@ namespace nana } return npos; } - /* - template - void _m_draw(const Container& cont, const nana::rectangle& rect) //deprecated - { - graph_reference graph = *(essence_->graph); - - int txtop = (rect.height - essence_->text_height) / 2 + rect.y; - auto txtcolor = essence_->lister.wd_ptr()->fgcolor(); - - auto state = item_state::normal; - //check whether grabing an item, if item_spliter_ != npos, that indicates the grab item is a spliter. - if(essence_->pointer_where.first == parts::header && (item_spliter_ == npos)) - state = essence_->ptr_state; - - const unsigned height = rect.height - 1; - const int bottom_y = rect.bottom() - 2; - int x = rect.x - essence_->scroll.offset_x; - for(auto & i: cont) - { - if(i.visible) - { - int next_x = x + static_cast(i.pixels); - if(next_x > rect.x) - { - _m_draw_header_item(graph, x, rect.y, height, txtop, txtcolor, i, (i.index == essence_->pointer_where.second ? state : item_state::normal)); - graph.line({ next_x - 1, rect.y }, { next_x - 1, bottom_y }, _m_border_color()); - } - - x = next_x; - if (x > rect.right()) - break; - } - } - - if (x < rect.right()) - graph.rectangle({ x, rect.y, static_cast(rect.right() - x), height }, true, essence_->scheme_ptr->header_bgcolor); - } - */ template void _m_draw_header_item(graph_reference graph, int x, int y, unsigned height, int txtop, const ::nana::color& fgcolor, const Item& item, item_state state) @@ -3226,13 +3169,6 @@ namespace nana delete essence_; } - /* - essence_t& trigger::essence() //deprecated - { - return *essence_; - } - */ - essence_t& trigger::essence() const { return *essence_; @@ -4411,18 +4347,29 @@ namespace nana auto * ess = ip._m_ess(); auto _where = ip.pos(); + + auto pos_before = ess->scroll_y_dpl(); ess->lister.erase(_where); auto pos = ess->scroll_y_dpl(); - if((pos.cat == _where.cat) && (_where.item <= pos.item)) + if (!pos.empty()) { - if(pos.item == 0) + if ((pos.cat == _where.cat) && (_where.item <= pos.item)) { - if(ess->lister.size_item(_where.cat) == 0) - pos.item = (pos.cat > 0 ? npos : 0); + if (pos.item == 0) + { + if (ess->lister.size_item(_where.cat) == 0) + pos.item = (pos.cat > 0 ? npos : 0); + } + else + --pos.item; + ess->set_scroll_y_dpl(pos); } - else - --pos.item; - ess->set_scroll_y_dpl(pos); + } + else + { + if (pos_before.item) + --pos_before.item; + ess->set_scroll_y_dpl(pos_before); } ess->update(); if(_where.item < ess->lister.size_item(_where.cat)) From 1d949488878785e1563474a07189fc380f4b79ea Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 30 Sep 2015 18:26:31 +0800 Subject: [PATCH 32/65] fix an listbox updating vert scrollbar issue --- source/gui/widgets/listbox.cpp | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 422f778a..85646f3e 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -1945,10 +1945,7 @@ namespace nana } scroll_y_dpl_refresh() ; } - void scroll_y_rel(const index_pair& pos_rel) - { - scroll_y_abs(lister.relative_pair(pos_rel) ); - } + /// directly set a tested relative display pos void set_scroll_y_dpl(const index_pair& pos_dpl) { @@ -2037,7 +2034,7 @@ namespace nana if(scroll.v.empty() == false) { unsigned height = 2 + (scroll.h.empty() ? 0 : scroll.scale); - if(height >= graph->width()) return; + if(height >= graph->height()) return; scroll.v.amount(lister.the_number_of_expanded()); scroll.v.range(number_of_lister_items(false)); size_type off = lister.distance({0,0}, scroll.offset_y_dpl ); From 4cfe366758c9126eb7e246df8f87e76bad049080 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 1 Oct 2015 02:51:30 +0800 Subject: [PATCH 33/65] code review of listbox --- include/nana/gui/widgets/listbox.hpp | 2 - source/gui/widgets/listbox.cpp | 267 ++++++++++++--------------- 2 files changed, 122 insertions(+), 147 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 140d6dd2..e2a6482c 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -185,9 +185,7 @@ namespace nana public: trigger(); ~trigger(); - //essence_t& essence(); //deprecated essence_t& essence() const; - void draw(); private: void _m_draw_border(); private: diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 85646f3e..b9e0df55 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -388,15 +388,14 @@ namespace nana sortable_ = enable; } - std::function fetch_comp(std::size_t index) const + std::function fetch_comp(std::size_t pos) const { - if(index < cont_.size()) + try + { + return column_ref(pos).weak_ordering; + } + catch (...) { - for(auto & m : cont_) - { - if(m.index == index) - return m.weak_ordering; - } } return{}; } @@ -409,20 +408,17 @@ namespace nana void item_width(size_type pos, unsigned width) { - for(auto & m : cont_) - if(m.index == pos) - { - m.pixels = width; - return; - } + column(pos).pixels = width; } - unsigned item_width(size_type pos) const + unsigned item_width(size_type pos) const throw() { - for (auto & m : cont_) + try + { + return column_ref(pos).pixels; + } + catch (...) { - if (m.index == pos) - return m.pixels; } return 0; } @@ -535,9 +531,8 @@ namespace nana /// move the col originaly at index to the position currently in front (or after) the col originaly at index "to" invalidating some current index void move(size_type index, size_type to, bool front) throw() { - if(index == to) return; - if(index >= cont_.size()) return; - if(to >= cont_.size()) return; + if ((index == to) || (index >= cont_.size()) || (to >= cont_.size())) + return; for (auto i = cont_.begin(); i != cont_.end(); ++i) { @@ -711,7 +706,7 @@ namespace nana nana::any * anyobj(const index_pair& id, bool allocate_if_empty) const { - auto& catobj = *_m_at(id.cat); + auto& catobj = *get(id.cat); if(id.item < catobj.items.size()) { auto& item = catobj.items[id.item]; @@ -880,22 +875,13 @@ namespace nana /// add a new cat created at "pos" and return a ref to it category_t* create_cat(std::size_t pos, nana::string&& text) { -#if defined(NANA_LINUX) || defined(NANA_MINGW) - //Call begin instead of cbegin, because the first parameter - //of emplace is not const_iterator in GCC's C++ standard - //library implementation. - auto i = list_.begin(); -#else - auto i = list_.cbegin(); -#endif - std::advance(i, pos); - return &(*list_.emplace(i, std::move(text))); + return &(*list_.emplace(this->get(pos), std::move(text))); } /// Insert before item in absolute "pos" a new item with "text" in column 0, and place it in last display position of this cat bool insert(const index_pair& pos, nana::string&& text) { - auto & catobj = *_m_at(pos.cat); + auto & catobj = *get(pos.cat); const auto n = catobj.items.size(); if (pos.item > n) @@ -914,7 +900,7 @@ namespace nana /// convert from display order to absolute (find the real item in that display pos) but without check from current active sorting, in fact using just the last sorting !!! size_type index_by_display_order(size_type cat, size_type display_order_pos) const { - auto & catobj = *_m_at(cat); + auto & catobj = *get(cat); if (display_order_pos >= catobj.sorted.size()) throw std::out_of_range("listbox: Invalid item position."); @@ -924,7 +910,7 @@ namespace nana /// find display order for the real item but without check from current active sorting, in fact using just the last sorting !!! size_type display_order(size_type cat, size_type pos) const { - auto & catobj = *_m_at(cat); + auto& catobj = *get(cat); if (pos >= catobj.sorted.size()) throw std::out_of_range("listbox: Invalid item position."); @@ -934,15 +920,16 @@ namespace nana return npos ; } - + /* category_t& at(std::size_t cat_pos) { return *(_m_at(cat_pos)); } + */ category_t::container::value_type& at_abs(const index_pair& pos) { - return _m_at(pos.cat)->items.at(pos.item); + return get(pos.cat)->items.at(pos.item); } /// return a ref to the real item object at display!!! position pos using current sorting only if it is active, and at absolute position if no sorting is currently active. @@ -953,7 +940,7 @@ namespace nana if (sorted_index_ != npos) index = absolute(pos); - return _m_at(pos.cat)->items.at(index); + return get(pos.cat)->items.at(index); } const category_t::container::value_type& at(const index_pair& pos) const @@ -963,12 +950,12 @@ namespace nana if (sorted_index_ != npos) index = absolute(pos); - return _m_at(pos.cat)->items.at(index); + return get(pos.cat)->items.at(index); } void clear(size_type cat) { - auto& catobj = *_m_at(cat); + auto& catobj = *get(cat); catobj.items.clear(); catobj.sorted.clear(); } @@ -1051,7 +1038,7 @@ namespace nana std::swap(from, to); size_type n = 0; - auto i = _m_at(from.cat); + auto i = get(from.cat); if(from.item == npos) { if(i->expand) @@ -1130,7 +1117,7 @@ namespace nana void erase(size_type cat) { - auto i = _m_at(cat); + auto i = get(cat); //If the category is the first one, it just clears the items instead of removing whole category. if(0 == cat) @@ -1156,7 +1143,7 @@ namespace nana { if(good(cat)) { - auto & expanded = _m_at(cat)->expand; + auto & expanded = get(cat)->expand; if(expanded != exp) { expanded = exp; @@ -1168,7 +1155,7 @@ namespace nana bool expand(size_type cat) const { - return (good(cat) ? _m_at(cat)->expand : false); + return (good(cat) ? get(cat)->expand : false); } container& cat_container() @@ -1394,8 +1381,7 @@ namespace nana if (for_selection ? single_selection_category_limited_ : single_check_category_limited_) { - auto i = list_.begin(); - std::advance(i, except.cat); + auto i = this->get(except.cat); std::size_t item_pos = 0; for (auto & m : i->items) @@ -1541,12 +1527,12 @@ namespace nana size_type size_item(size_type cat) const { - return _m_at(cat)->items.size(); + return get(cat)->items.size(); } bool categ_checked(size_type cat) const { - auto & items = _m_at(cat)->items; + auto& items = get(cat)->items; for(auto & m : items) { if(m.flags.checked == false) @@ -1558,7 +1544,7 @@ namespace nana bool categ_checked(size_type cat, bool ck) { bool changed = false; - auto & items = _m_at(cat)->items; + auto & items = get(cat)->items; size_type index = 0; for(auto & m : items) { @@ -1585,7 +1571,7 @@ namespace nana bool categ_selected(size_type cat) const { - auto & items = _m_at(cat)->items; + auto & items = get(cat)->items; for(auto & m : items) if(m.flags.selected == false) return false; @@ -1661,7 +1647,7 @@ namespace nana return true; } - auto i = _m_at(pos.cat); // pos is not a cat and i point to it cat + auto i = get(pos.cat); // pos is not a cat and i point to it cat if (pos.item < i->items.size()) { item = pos; // good item, return it @@ -1682,8 +1668,7 @@ namespace nana if(sorted_index_ == npos || display_pos.item == npos) return display_pos.item ; - auto & catobj = *_m_at(display_pos.cat); - + auto & catobj = *get(display_pos.cat); if(catobj.items.empty()) return (display_pos == index_pair{0,0} ? 0 : npos); @@ -1702,7 +1687,7 @@ namespace nana if (sorted_index_ == npos) return pos.item ; - auto & catobj = *_m_at(pos.cat); + auto& catobj = *get(pos.cat); for (size_type i=0; iexpand ? cat->items.size() : 0); @@ -1768,7 +1753,7 @@ namespace nana if(good(from.cat)) { - auto i = _m_at(from.cat); + auto i = get(from.cat); size_type n = (from.is_category() ? 1 : from.item + 2); // ?? if(n <= offs) { @@ -1802,25 +1787,25 @@ namespace nana } return false; } - private: + /// categories iterator - container::iterator _m_at(size_type index) + container::iterator get(size_type pos) { - if(index >= list_.size()) + if (pos >= list_.size()) throw std::out_of_range("nana::listbox: invalid category index"); auto i = list_.begin(); - std::advance(i, index); + std::advance(i, pos); return i; } - - container::const_iterator _m_at(size_type index) const + + container::const_iterator get(size_type pos) const { - if(index >= list_.size()) + if (pos >= list_.size()) throw std::out_of_range("nana::listbox: invalid category index"); auto i = list_.cbegin(); - std::advance(i, index); + std::advance(i, pos); return i; } public: @@ -2065,6 +2050,25 @@ namespace nana unsigned width = sz.width - 2 - (v ? scroll.scale : 0); unsigned height = sz.height - 2 - (h ? scroll.scale : 0); + //event hander for scrollbars + auto evt_fn = [this](const arg_scroll& arg) + { + if (scroll.h.empty() || (scroll.h.handle() != arg.window_handle)) + { + index_pair item; + if (!lister.forward(item, scroll.v.value(), item)) return; + + if (item == scroll.offset_y_dpl) + return; + + set_scroll_y_dpl(item); + } + else + scroll.offset_x = static_cast(scroll.h.value()); + + API::refresh_window(this->lister.wd_ptr()->handle()); + }; + if(h) { rectangle r(1, sz.height - scroll.scale - 1, width, scroll.scale); @@ -2072,12 +2076,7 @@ namespace nana { scroll.h.create(wd, r); API::take_active(scroll.h.handle(), false, wd); - - scroll.h.events().value_changed.connect_unignorable([this](const ::nana::arg_scroll& arg) - { - scroll.offset_x = static_cast(scroll.h.value()); - API::refresh_window(this->lister.wd_ptr()->handle()); - }); + scroll.h.events().value_changed.connect_unignorable(evt_fn); } else scroll.h.move(r); @@ -2092,19 +2091,7 @@ namespace nana { scroll.v.create(wd, r); API::take_active(scroll.v.handle(), false, wd); - - scroll.v.events().value_changed([this](const ::nana::arg_scroll& arg) - { - index_pair item; - if (!lister.forward(item, scroll.v.value(), item)) return; - - if (item == scroll.offset_y_dpl) - return; - - set_scroll_y_dpl(item); - - API::refresh_window(this->lister.wd_ptr()->handle()); - }); + scroll.v.events().value_changed.connect_unignorable(evt_fn); } else scroll.v.move(r); @@ -2150,8 +2137,7 @@ namespace nana int item_xpos(const nana::rectangle& r) const { - std::vector seq; - header_seq(seq, r.width); + auto seq = header_seq(r.width); return (seq.size() ? (header.item_pos(seq[0], nullptr) - scroll.offset_x + r.x) : 0); } @@ -2277,18 +2263,21 @@ namespace nana return true; } - void header_seq(std::vector &seqs, unsigned lister_w)const + std::vector header_seq(unsigned lister_w)const { - int x = - (scroll.offset_x); - for(const auto& hd : header.cont()) + std::vector seqs; + int x = -(scroll.offset_x); + for (const auto& hd : header.cont()) { - if(false == hd.visible) continue; + if (false == hd.visible) continue; x += static_cast(hd.pixels); - if(x > 0) + if (x > 0) seqs.push_back(hd.index); - if(x >= static_cast(lister_w)) + if (x >= static_cast(lister_w)) break; } + + return seqs; } unsigned auto_width(size_type pos, unsigned max = 3000) /// \todo introduce parametr max_header_width @@ -2398,7 +2387,7 @@ namespace nana void es_lister::erase(const index_pair& pos) { - auto & catobj = *_m_at(pos.cat); + auto & catobj = *get(pos.cat); if (pos.item < catobj.items.size()) { catobj.items.erase(catobj.items.begin() + pos.item); @@ -2782,8 +2771,7 @@ namespace nana if((ptr_where.first == parts::lister || ptr_where.first == parts::checker) && ptr_where.second != npos) lister.forward(essence_->scroll.offset_y_dpl, ptr_where.second, tracker); - std::vector subitems; - essence_->header_seq(subitems, rect.width); + auto subitems = essence_->header_seq(rect.width); if(subitems.empty()) return; @@ -2792,8 +2780,7 @@ namespace nana int y = rect.y; int txtoff = (essence_->item_size - essence_->text_height) / 2; - auto i_categ = lister.cat_container().cbegin(); - std::advance(i_categ, essence_->scroll.offset_y_dpl.cat); + auto i_categ = lister.get(essence_->scroll.offset_y_dpl.cat); auto idx = essence_->scroll.offset_y_dpl; @@ -2859,17 +2846,14 @@ namespace nana essence_->inline_buffered_table.clear(); - if (y < rect.y + static_cast(rect.height)) - { - essence_->graph->set_color(bgcolor); - essence_->graph->rectangle(rectangle{ rect.x, y, rect.width, rect.y + rect.height - y }, true); - } + if (y < rect.bottom()) + essence_->graph->rectangle(rectangle{ rect.x, y, rect.width, static_cast(rect.bottom() - y) }, true, bgcolor); } private: void _m_draw_categ(const category_t& categ, int x, int y, int txtoff, unsigned width, const nana::rectangle& r, nana::color bgcolor, item_state state) const { - bool sel = categ.selected(); - if(sel && (categ.expand == false)) + const bool sel = categ.selected(); + if (sel && (categ.expand == false)) bgcolor = static_cast(0xD5EFFC); if (state == item_state::highlighted) @@ -2889,18 +2873,19 @@ namespace nana ::nana::string str = L'(' + std::to_wstring(categ.items.size()) + L')'; - unsigned str_w = graph->text_extent_size(str).width; + auto text_s = graph->text_extent_size(categ.text).width; + auto extend_text_w = text_s + graph->text_extent_size(str).width; - auto text_s = graph->text_extent_size(categ.text); - graph->string({ x + 25 + static_cast(text_s.width), y + txtoff }, str); + graph->string({ x + 25 + static_cast(text_s), y + txtoff }, str); - if (x + 35 + text_s.width + str_w < x + width) + if (x + 35 + extend_text_w < x + width) { - ::nana::point pos{ x + 30 + static_cast(text_s.width + str_w), y + static_cast(essence_->item_size) / 2 }; + ::nana::point pos{ x + 30 + static_cast(extend_text_w), y + static_cast(essence_->item_size) / 2 }; graph->line(pos, { x + static_cast(width)-5, pos.y }, txt_color); } + //Draw selecting inner rectangle - if(sel && categ.expand == false) + if (sel && (categ.expand == false)) { width -= essence_->scroll.offset_x; _m_draw_border(r.x, y, (r.width < width ? r.width : width)); @@ -2934,8 +2919,7 @@ namespace nana auto graph = essence_->graph; //draw the background - graph->set_color(bgcolor); - graph->rectangle(rectangle{ content_r.x, y, show_w, essence_->item_size }, true); + graph->rectangle(rectangle{ content_r.x, y, show_w, essence_->item_size }, true, bgcolor); int item_xpos = x; unsigned extreme_text = x; @@ -3113,7 +3097,7 @@ namespace nana essence_t::inline_pane* _m_find_inline_pane(const index_pair& pos, std::size_t column_pos) const { - auto & cat = essence_->lister.at(pos.cat); + auto & cat = *essence_->lister.get(pos.cat); if (column_pos >= cat.factories.size()) return nullptr; @@ -3138,10 +3122,9 @@ namespace nana { //Draw selecting inner rectangle auto graph = essence_->graph; - graph->rectangle({ x, y, width, essence_->item_size }, false, { 0x99, 0xDE, 0xFD }); + graph->rectangle({ x, y, width, essence_->item_size }, false, static_cast(0x99defd)); - graph->set_color(colors::white); - graph->rectangle({ x + 1, y + 1, width - 2, essence_->item_size - 2 }, false); + graph->rectangle({ x + 1, y + 1, width - 2, essence_->item_size - 2 }, false, colors::white); graph->set_pixel(x, y); graph->set_pixel(x, y + essence_->item_size - 1); graph->set_pixel(x + width - 1, y); @@ -3171,20 +3154,6 @@ namespace nana return *essence_; } - void trigger::draw() - { - if (API::is_destroying(essence_->lister.wd_ptr()->handle())) - return; - - nana::rectangle r; - - if(essence_->header.visible() && essence_->rect_header(r)) - drawer_header_->draw(r); - if(essence_->rect_lister(r)) - drawer_lister_->draw(r); - _m_draw_border(); - } - void trigger::_m_draw_border() { if (API::widget_borderless(*essence_->lister.wd_ptr())) @@ -3229,7 +3198,16 @@ namespace nana void trigger::refresh(graph_reference) { - draw(); + if (API::is_destroying(essence_->lister.wd_ptr()->handle())) + return; + + nana::rectangle r; + + if (essence_->header.visible() && essence_->rect_header(r)) + drawer_header_->draw(r); + if (essence_->rect_lister(r)) + drawer_lister_->draw(r); + _m_draw_border(); } void trigger::mouse_move(graph_reference graph, const arg_mouse& arg) @@ -3291,7 +3269,7 @@ namespace nana if (update) { if (2 == update) - draw(); + refresh(graph); API::lazy_refresh(); } @@ -3309,7 +3287,7 @@ namespace nana essence_->ptr_state = item_state::normal; } - draw(); + refresh(graph); API::lazy_refresh(); } } @@ -3425,7 +3403,7 @@ namespace nana if(essence_->lister.sort_index(essence_->pointer_where.second)) { essence_->trace_item_dpl({0,0}); - draw(); + refresh(graph); API::lazy_refresh(); } } @@ -3435,7 +3413,7 @@ namespace nana nana::point pos = arg.pos; essence_->widget_to_header(pos); drawer_header_->grab(pos, false); - draw(); + refresh(graph); API::lazy_refresh(); API::capture_window(essence_->lister.wd_ptr()->handle(), false); } @@ -3445,7 +3423,7 @@ namespace nana { if(essence_->wheel(arg.upwards)) { - draw(); + refresh(graph); essence_->adjust_scroll_value(); API::lazy_refresh(); } @@ -3484,7 +3462,7 @@ namespace nana offset_y = last; } essence_->adjust_scroll_life(); - draw(); + refresh(graph); API::lazy_refresh(); } } @@ -3492,7 +3470,7 @@ namespace nana void trigger::resized(graph_reference graph, const arg_resized&) { essence_->adjust_scroll_life(); - draw(); + refresh(graph); API::lazy_refresh(); } @@ -3565,7 +3543,7 @@ namespace nana default: return; } - draw(); + refresh(graph); API::lazy_refresh(); } @@ -3578,12 +3556,12 @@ namespace nana export_options exp_opt {essence_->def_export_options()}; exp_opt.columns_order = essence_->header.all_headers(true); exp_opt.only_selected_items = true; - nana::system::dataexch().set(essence_->to_string(exp_opt)); + ::nana::system::dataexch().set(essence_->to_string(exp_opt)); return; } case keyboard::select_all : essence_->lister.select_for_all(true); - draw(); + refresh(graph); API::lazy_refresh(); break; @@ -3605,8 +3583,9 @@ namespace nana { if (ess) { - auto i = ess_->lister.cat_container().begin(); - std::advance(i, pos.cat); + //auto i = ess_->lister.cat_container().begin(); + //std::advance(i, pos.cat); + auto i = ess_->lister.get(pos.cat); cat_ = &(*i); // what is pos is a cat? } } @@ -3949,8 +3928,7 @@ namespace nana //Behavior of a container item_proxy cat_proxy::begin() const { - auto i = ess_->lister.cat_container().begin(); - std::advance(i, pos_); + auto i = ess_->lister.get(pos_); if (i->items.empty()) return end(); @@ -4137,8 +4115,7 @@ namespace nana return; } - auto i = ess_->lister.cat_container().begin(); - std::advance(i, pos_); + auto i = ess_->lister.get(pos_); cat_ = &(*i); } //class cat_proxy From 1ea202823341b6c93c2a10e3c35da02ddbdb6890 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 1 Oct 2015 03:34:24 +0800 Subject: [PATCH 34/65] code review of listbox --- source/gui/widgets/listbox.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index b9e0df55..314c863b 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2668,12 +2668,10 @@ namespace nana { unsigned item_pixels = 0; auto item_x = essence_->header.item_pos(i, &item_pixels); - - int midpos = item_x + static_cast(item_pixels / 2); //Get the item pos //if mouse pos is at left of an item middle, the pos of itself otherwise the pos of the next. - place_front = (x <= midpos); + place_front = (x <= (item_x + static_cast(item_pixels / 2))); x = (place_front ? item_x : essence_->header.item_pos(essence_->header.neighbor(i, false), nullptr)); if(i != npos) @@ -2687,7 +2685,6 @@ namespace nana template void _m_draw_header_item(graph_reference graph, int x, int y, unsigned height, int txtop, const ::nana::color& fgcolor, const Item& item, item_state state) { - essence_->scheme_ptr->header_bgcolor.get_color(); ::nana::color bgcolor; switch(state) { @@ -2866,8 +2863,9 @@ namespace nana facade arrow("double"); arrow.direction(categ.expand ? ::nana::direction::north : ::nana::direction::south); - ::nana::rectangle arrow_r{ x + 5, y + static_cast(essence_->item_size - 16) / 2, 16, 16 }; - arrow.draw(*graph, {}, txt_color, arrow_r, element_state::normal); + arrow.draw( *graph, {}, txt_color, + { x + 5, y + static_cast(essence_->item_size - 16) / 2, 16, 16 }, + element_state::normal); graph->string({ x + 20, y + txtoff }, categ.text, txt_color); @@ -3583,8 +3581,6 @@ namespace nana { if (ess) { - //auto i = ess_->lister.cat_container().begin(); - //std::advance(i, pos.cat); auto i = ess_->lister.get(pos.cat); cat_ = &(*i); // what is pos is a cat? } From 573a5bee863a2365d099e4d91977ffbbc5e4435c Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 7 Oct 2015 18:01:46 +0800 Subject: [PATCH 35/65] code review --- include/nana/gui/detail/drawer.hpp | 1 - include/nana/gui/widgets/checkbox.hpp | 3 - include/nana/gui/widgets/combox.hpp | 12 ---- include/nana/gui/widgets/listbox.hpp | 12 ---- include/nana/gui/widgets/spinbox.hpp | 12 ---- include/nana/gui/widgets/tabbar.hpp | 13 ---- include/nana/gui/widgets/textbox.hpp | 13 ---- include/nana/gui/widgets/treebox.hpp | 2 - source/gui/dragger.cpp | 62 -------------------- source/gui/tooltip.cpp | 27 --------- source/gui/widgets/checkbox.cpp | 42 +++---------- source/gui/widgets/combox.cpp | 21 ------- source/gui/widgets/listbox.cpp | 6 -- source/gui/widgets/skeletons/text_editor.cpp | 24 ++++---- source/gui/widgets/spinbox.cpp | 9 ++- source/gui/widgets/tabbar.cpp | 38 ++++-------- source/gui/widgets/treebox.cpp | 57 +----------------- source/paint/text_renderer.cpp | 15 +---- 18 files changed, 36 insertions(+), 333 deletions(-) diff --git a/include/nana/gui/detail/drawer.hpp b/include/nana/gui/detail/drawer.hpp index ddd770e3..b680ec6a 100644 --- a/include/nana/gui/detail/drawer.hpp +++ b/include/nana/gui/detail/drawer.hpp @@ -16,7 +16,6 @@ #include #include "general_events.hpp" #include -//#include //deprecated #include namespace nana diff --git a/include/nana/gui/widgets/checkbox.hpp b/include/nana/gui/widgets/checkbox.hpp index 21b63cbd..7af58e72 100644 --- a/include/nana/gui/widgets/checkbox.hpp +++ b/include/nana/gui/widgets/checkbox.hpp @@ -87,9 +87,6 @@ namespace drawerbase void add(checkbox&); std::size_t checked() const; ///< Retrieves the index of the checkbox which is checked. std::size_t size() const; - private: - //void _m_checked(const arg_click&); //deprecated - //void _m_destroy(const arg_destroy&); //deprecated private: std::vector ui_container_; }; diff --git a/include/nana/gui/widgets/combox.hpp b/include/nana/gui/widgets/combox.hpp index 17bb7cfe..3d1698d0 100644 --- a/include/nana/gui/widgets/combox.hpp +++ b/include/nana/gui/widgets/combox.hpp @@ -228,17 +228,5 @@ namespace nana void _m_caption(nana::string&&) override; nana::any * _m_anyobj(std::size_t pos, bool alloc_if_empty) const override; }; - - /* - namespace dev //deprecated - { - template<> - struct widget_traits - { - using event_type = drawerbase::combox::combox_events; - using scheme_type = ::nana::widgets::skeletons::text_editor_scheme; - }; - } - */ } #endif diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 3b23db30..41a294fb 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -661,17 +661,5 @@ By \a clicking on one header the list get \a reordered, first up, and then down drawerbase::listbox::category_t* _m_at_key(std::shared_ptr); void _m_erase_key(nana::detail::key_interface*); }; - - /* - namespace dev - { - template<> - struct widget_traits //deprecated - { - using event_type = drawerbase::listbox::listbox_events; - using scheme_type = drawerbase::listbox::scheme; - }; - } - */ }//end namespace nana #endif diff --git a/include/nana/gui/widgets/spinbox.hpp b/include/nana/gui/widgets/spinbox.hpp index 09e64faf..5e283872 100644 --- a/include/nana/gui/widgets/spinbox.hpp +++ b/include/nana/gui/widgets/spinbox.hpp @@ -109,18 +109,6 @@ namespace nana ::nana::string _m_caption() const throw(); void _m_caption(::nana::string&&); }; //end class spinbox - - /* - namespace dev - { - template<> - struct widget_traits //deprecated - { - using event_type = drawerbase::spinbox::spinbox_events; - using scheme_type = ::nana::widgets::skeletons::text_editor_scheme; - }; - } - */ }//end namespace nana #endif //NANA_GUI_WIDGET_SPINBOX_HPP diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 3f412f9b..206f3e4e 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -390,19 +390,6 @@ namespace nana std::size_t selected() const; void erase(std::size_t pos, bool close_attached = true); }; - - /* - namespace dev - { - /// Traits for widget classes - template<> - struct widget_traits //deprecated - { - using event_type = drawerbase::tabbar_lite::events; - using scheme_type = ::nana::widget_colors; - }; - } - */ } #endif diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index 4360cd74..f8759e05 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -194,18 +194,5 @@ namespace nana void _m_caption(::nana::string&&) override; void _m_typeface(const paint::font&) override; }; - - /* - namespace dev - { - /// Traits for widget classes - template<> - struct widget_traits //deprecated - { - using event_type = drawerbase::textbox::textbox_events; - using scheme_type = ::nana::widgets::skeletons::text_editor_scheme; - }; - } - */ }//end namespace nana #endif diff --git a/include/nana/gui/widgets/treebox.hpp b/include/nana/gui/widgets/treebox.hpp index 1878365a..db445daf 100644 --- a/include/nana/gui/widgets/treebox.hpp +++ b/include/nana/gui/widgets/treebox.hpp @@ -166,8 +166,6 @@ namespace nana void resized(graph_reference, const arg_resized&) override; void key_press(graph_reference, const arg_keyboard&) override; void key_char(graph_reference, const arg_keyboard&) override; - private: - //void _m_deal_adjust(); //deprecated private: implement * const impl_; }; //end class trigger diff --git a/source/gui/dragger.cpp b/source/gui/dragger.cpp index 58233afc..9aeb8b0b 100644 --- a/source/gui/dragger.cpp +++ b/source/gui/dragger.cpp @@ -65,7 +65,6 @@ namespace nana { trigger_t tg; tg.wd = wd; - //auto fn = std::bind(&dragger_impl_t::_m_trace, this, std::placeholders::_1); //deprecated auto fn = [this](const arg_mouse& arg) { switch (arg.evt_code) @@ -176,67 +175,6 @@ namespace nana if (pos.y < restr_area.y) pos.y = restr_area.y; } - /* - void _m_trace(const arg_mouse& arg) //deprecated - { - switch(arg.evt_code) - { - case event_code::mouse_down: - dragging_ = true; - API::capture_window(arg.window_handle, true); - origin_ = API::cursor_position(); - for(auto & t : targets_) - { - t.origin = API::window_position(t.wd); - window owner = API::get_owner_window(t.wd); - if(owner) - API::calc_screen_point(owner, t.origin); - } - break; - case event_code::mouse_move: - if(dragging_ && arg.left_button) - { - auto pos = API::cursor_position(); - pos -= origin_; - - for(auto & t : targets_) - { - if(API::is_window_zoomed(t.wd, true) == false) - { - auto owner = API::get_owner_window(t.wd); - auto wdps = t.origin; - if (owner) - API::calc_window_point(owner, wdps); - - switch (t.move_direction) - { - case nana::arrange::horizontal: - wdps.x += pos.x; - break; - case nana::arrange::vertical: - wdps.y += pos.y; - break; - default: - wdps += pos; - } - - if (!t.restrict_area.empty()) - _m_check_restrict_area(wdps, API::window_size(t.wd), t.restrict_area); - - API::move_window(t.wd, wdps); - } - } - } - break; - case event_code::mouse_up: - API::capture_window(arg.window_handle, false); - dragging_ = false; - break; - default: - break; - } - } - */ private: bool dragging_; nana::point origin_; diff --git a/source/gui/tooltip.cpp b/source/gui/tooltip.cpp index 17104556..b5b115c4 100644 --- a/source/gui/tooltip.cpp +++ b/source/gui/tooltip.cpp @@ -255,31 +255,6 @@ namespace nana instance(true); } private: - /* - void _m_enter(const arg_mouse& arg) //deprecated - { - pair_t & pr = _m_get(arg.window_handle); - if(pr.second.size()) - { - this->show(pr.second); - } - } - */ - - /* - void _m_leave(const arg_mouse&) //deprecated - { - close(); - } - */ - - /* - void _m_destroy(const arg_destroy& arg) //deprecated - { - _m_untip(arg.window_handle); - } - */ - void _m_untip(window wd) { for (auto i = cont_.begin(); i != cont_.end(); ++i) @@ -313,8 +288,6 @@ namespace nana this->show(pr.second); }); - //auto leave_fn = std::bind(&controller::_m_leave, this, std::placeholders::_1); //deprecated - auto leave_fn = [this]{ this->close(); }; diff --git a/source/gui/widgets/checkbox.cpp b/source/gui/widgets/checkbox.cpp index 46fb8d63..d6c9a343 100644 --- a/source/gui/widgets/checkbox.cpp +++ b/source/gui/widgets/checkbox.cpp @@ -213,25 +213,14 @@ namespace checkbox element_tag el; el.uiobj = &uiobj; - //el.eh_checked = uiobj.events().click.connect_unignorable(std::bind(&radio_group::_m_checked, this, std::placeholders::_1), true); //deprecated el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg) { for (auto & i : ui_container_) i.uiobj->check(arg.window_handle == i.uiobj->handle()); }, true); - //el.eh_destroy = uiobj.events().destroy.connect_unignorable(std::bind(&radio_group::_m_destroy, this, std::placeholders::_1)); //deprecated el.eh_destroy = uiobj.events().destroy.connect_unignorable([this](const arg_destroy& arg) { - /* - auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [&arg](decltype(*ui_container_.begin()) & x) - { - return (arg.window_handle == x.uiobj->handle()); - }); - if (i != ui_container_.end()) - ui_container_.erase(i); - */ - for (auto i = ui_container_.begin(); i != ui_container_.end(); ++i) { if (arg.window_handle == i->uiobj->handle()) @@ -247,35 +236,18 @@ namespace checkbox std::size_t radio_group::checked() const { - auto i = std::find_if(ui_container_.cbegin(), ui_container_.cend(), [](decltype(*ui_container_.cbegin())& x) - { - return (x.uiobj->checked()); - }); - return static_cast(i - ui_container_.cbegin()); + for (auto i = ui_container_.cbegin(); i != ui_container_.cend(); ++i) + { + if (i->uiobj->checked()) + return static_cast(i - ui_container_.cbegin()); + } + + return ui_container_.size(); } std::size_t radio_group::size() const { return ui_container_.size(); } - /* - void radio_group::_m_checked(const arg_click& arg) //deprecated - { - for (auto & i : ui_container_) - i.uiobj->check(arg.window_handle == i.uiobj->handle()); - } - */ - - /* - void radio_group::_m_destroy(const arg_destroy& arg) //deprecated - { - auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [&arg](decltype(*ui_container_.begin()) & x) - { - return (arg.window_handle == x.uiobj->handle()); - }); - if(i != ui_container_.end()) - ui_container_.erase(i); - } - */ //end class radio_group }//end namespace nana diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index d89e36ef..45718364 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -172,12 +172,6 @@ namespace nana { editor_->editable(enb); - /* - if(enb) - editor_->ext_renderer().background = nullptr; - else - editor_->ext_renderer().background = std::bind(&drawer_impl::_m_draw_background, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3); //deprecated - */ if (!enb) { editor_->ext_renderer().background = [this](graph_reference graph, const ::nana::rectangle&, const ::nana::color&) @@ -454,22 +448,7 @@ namespace nana API::refresh_window(*widget_); } } - /* - void _m_draw_background(graph_reference graph, const rectangle&, const ::nana::color&) //deprecated - { - auto clr_from = colors::button_face_shadow_start; - auto clr_to = colors::button_face_shadow_end; - int pare_off_px = 1; - if (element_state::pressed == state_.button_state) - { - pare_off_px = 2; - std::swap(clr_from, clr_to); - } - - graph.gradual_rectangle(::nana::rectangle(graph.size()).pare_off(pare_off_px), clr_from, clr_to, true); - } - */ void _m_draw_push_button(bool enabled) { ::nana::rectangle r{graph_->size()}; diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 314c863b..c0ccfa27 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -920,12 +920,6 @@ namespace nana return npos ; } - /* - category_t& at(std::size_t cat_pos) - { - return *(_m_at(cat_pos)); - } - */ category_t::container::value_type& at_abs(const index_pair& pos) { diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 29e5a181..b17a6a45 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -217,13 +217,13 @@ namespace nana{ namespace widgets editor_.select_.a = sel_a_; editor_.select_.b = sel_b_; editor_.points_.caret = pos_; - editor_._m_move_select(false); - return; } - - editor_.select_.a = dest_a_; - editor_.select_.b = dest_b_; - editor_.points_.caret = sel_a_; + else + { + editor_.select_.a = dest_a_; + editor_.select_.b = dest_b_; + editor_.points_.caret = sel_a_; + } editor_._m_move_select(false); } @@ -1331,12 +1331,12 @@ namespace nana{ namespace widgets void text_editor::erase_keyword(const ::nana::string& kw) { - auto i = std::find_if(keywords_->kwbase.begin(), keywords_->kwbase.end(), [&kw](keyword_desc& kd){ - return (kd.text == kw); - }); - - if (i != keywords_->kwbase.end()) - keywords_->kwbase.erase(i); + for (auto i = keywords_->kwbase.begin(); i != keywords_->kwbase.end(); ++i) + if (i->text == kw) + { + keywords_->kwbase.erase(i); + return; + } } void text_editor::set_accept(std::function pred) diff --git a/source/gui/widgets/spinbox.cpp b/source/gui/widgets/spinbox.cpp index 39083fd9..e75b0031 100644 --- a/source/gui/widgets/spinbox.cpp +++ b/source/gui/widgets/spinbox.cpp @@ -193,12 +193,11 @@ namespace nana if (str.empty()) return true; - auto i = std::find_if(texts_.cbegin(), texts_.cend(), [&str](const std::wstring& value) - { - return (value.find(str) != value.npos); - }); + for (auto i = texts_.cbegin(); i != texts_.cend(); ++i) + if (i->find(str) != str.npos) + return false; - return (i != texts_.cend()); + return true; } void spin(bool increase) override diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index f66b9ca4..3fde24cc 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -103,13 +103,13 @@ namespace nana switch(sta) { case item_renderer::highlight: - clr = { colors::white }; break; + clr = colors::white; break; case item_renderer::press: - clr = { 0xA0, 0xA0, 0xA0 }; break; + clr = static_cast(0xA0A0A0); break; case item_renderer::disable: - clr = { 0x80, 0x80, 0x80 }; break; + clr = static_cast(0x808080); break; default: - clr = { 0xF0, 0xF0, 0xF0 }; + clr = static_cast(0xF0F0F0); } graph.rectangle(r, true, bgcolor_); facade cross; @@ -121,7 +121,7 @@ namespace nana facade x_icon; x_icon.draw(graph, {}, colors::black, { r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); if(item_renderer::highlight == sta) - graph.rectangle(r, false, {0xa0, 0xa0, 0xa0}); + graph.rectangle(r, false, static_cast(0xa0a0a0)); } virtual void close_fly(graph_reference graph, const nana::rectangle& r, bool active, state_t sta) @@ -131,8 +131,8 @@ namespace nana if (sta == item_renderer::highlight) { - ::nana::color bgcolor{ 0xCC, 0xD2, 0xDD }; - ::nana::color rect_clr{0x9d, 0xa3, 0xab}; + ::nana::color bgcolor{ static_cast(0xCCD2DD) }; + ::nana::color rect_clr{ static_cast(0x9da3ab) }; graph.round_rectangle(r, 1, 1, rect_clr, false, {}); nana::rectangle draw_r(r); graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.8)); @@ -140,7 +140,7 @@ namespace nana graph.rectangle(draw_r.pare_off(1), false, rect_clr.blend(bgcolor, 0.2)); } else if (!active) - clr = ::nana::color{ 0x92, 0x99, 0xA4 }; + clr = static_cast(0x9299a4); facade x_icon; x_icon.draw(graph, {}, colors::black, { r.x + static_cast(r.width - 16) / 2, r.y + static_cast(r.height - 16) / 2, 16, 16 }, element_state::normal); @@ -766,8 +766,6 @@ namespace nana void _m_open_menulister() { menulister_.clear(); - - //auto f = std::bind(&layouter::_m_click_menulister, this, std::placeholders::_1); //deprecated auto fn = [this](::nana::menu::item_proxy& ipx) { if (this->activate(ipx.index())) @@ -782,14 +780,6 @@ namespace nana menulister_.popup(basis_.wd, r.x, r.bottom()); } - /* - void _m_click_menulister(nana::menu::item_proxy& ip) //deprecated - { - if(this->activate(ip.index())) - API::refresh_window(basis_.wd); - } - */ - //the begin pos of toolbox int _m_toolbox_pos() const { @@ -1018,12 +1008,12 @@ namespace nana int x = _m_itembar_right(); if (x > 0) { - basis_.graph->line({ x - 2, 0 }, { x - 2, bottom }, { 0x80, 0x80, 0x80 }); - basis_.graph->line({ x - 1, 0 }, { x - 1, bottom }, {0xf0, 0xf0, 0xf0}); + basis_.graph->line({ x - 2, 0 }, { x - 2, bottom }, static_cast(0x808080)); + basis_.graph->line({ x - 1, 0 }, { x - 1, bottom }, static_cast(0xf0f0f0)); } } - basis_.graph->set_color({ 0x80, 0x80, 0x80 }); + basis_.graph->set_color(static_cast(0x808080)); int right = static_cast(basis_.graph->width()); int end = active_m.r.x + static_cast(active_m.r.width); @@ -1362,12 +1352,6 @@ namespace nana { return widget_; } - /* - ::nana::dev::widget_traits::scheme_type & scheme() //deprecated - { - return API::scheme(*widget_); - } - */ std::forward_list& items() { diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index d995a2fa..a55b812d 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -1491,7 +1491,7 @@ namespace nana impl_->data.trigger_ptr = this; impl_->data.renderer = nana::pat::cloneable(internal_renderer()); impl_->data.comp_placer = nana::pat::cloneable(internal_placer()); - //impl_->adjust.timer.elapse(std::bind(&trigger::_m_deal_adjust, this)); //deprecated + impl_->adjust.timer.elapse([this] { auto & adjust = impl_->adjust; @@ -2151,61 +2151,6 @@ namespace nana API::lazy_refresh(); } } - - /* - void trigger::_m_deal_adjust() //deprecated - { - auto & adjust = impl_->adjust; - if(adjust.scroll_timestamp && (nana::system::timestamp() - adjust.scroll_timestamp >= 500)) - { - if(adjust.offset_x_adjust == 0) - { - if(!impl_->make_adjust(adjust.node ? adjust.node : impl_->shape.first, 1)) - { - adjust.offset_x_adjust = 0; - adjust.node = nullptr; - adjust.scroll_timestamp = 0; - adjust.timer.stop(); - return; - } - } - - auto & shape = impl_->shape; - const int delta = 5; - int old = shape.offset_x; - - if(shape.offset_x < adjust.offset_x_adjust) - { - shape.offset_x += delta; - if(shape.offset_x > adjust.offset_x_adjust) - shape.offset_x = adjust.offset_x_adjust; - } - else if(shape.offset_x > adjust.offset_x_adjust) - { - shape.offset_x -= delta; - if(shape.offset_x < adjust.offset_x_adjust) - shape.offset_x = adjust.offset_x_adjust; - } - - impl_->draw(false); - API::update_window(impl_->data.widget_ptr->handle()); - - if(impl_->node_state.tooltip) - { - nana::point pos = impl_->node_state.tooltip->pos(); - impl_->node_state.tooltip->move(pos.x - shape.offset_x + old, pos.y); - } - - if(shape.offset_x == adjust.offset_x_adjust) - { - adjust.offset_x_adjust = 0; - adjust.node = nullptr; - adjust.scroll_timestamp = 0; - adjust.timer.stop(); - } - } - } - //*/ //end class trigger }//end namespace treebox }//end namespace drawerbase diff --git a/source/paint/text_renderer.cpp b/source/paint/text_renderer.cpp index eaa87349..10d3cd6d 100644 --- a/source/paint/text_renderer.cpp +++ b/source/paint/text_renderer.cpp @@ -118,23 +118,10 @@ namespace nana { graphics & graph; int x, endpos; - //::nana::color fgcolor; //deprecated unsigned omitted_pixels; nana::unicode_bidi bidi; std::vector reordered; - /* //deprecated - draw_string_omitted(graphics& graph, int x, int endpos, const ::nana::color& fgcolor, bool omitted) - : graph(graph), x(x), endpos(endpos), fgcolor(fgcolor) - { - omitted_pixels = (omitted ? graph.text_extent_size(STR("..."), 3).width : 0); - if(endpos - x > static_cast(omitted_pixels)) - this->endpos -= omitted_pixels; - else - this->endpos = x; - } - */ - draw_string_omitted(graphics& graph, int x, int endpos, bool omitted) : graph(graph), x(x), endpos(endpos) { @@ -171,7 +158,7 @@ namespace nana nana::paint::graphics dum_graph({ r.width, r.height }); dum_graph.bitblt(r, graph, pos); - //dum_graph.set_text_color(fgcolor); //deprecated + dum_graph.set_text_color(graph.palette(true)); dum_graph.string({}, i.begin, len); From e2ce6d81fddf1ad778d3a5084a7ba09759798409 Mon Sep 17 00:00:00 2001 From: Keith Hammond Date: Thu, 8 Oct 2015 21:03:23 +1300 Subject: [PATCH 36/65] Fixed the faulty CMakeLists.txt for linux/gcc builds that aren't biicode --- CMakeLists.txt | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 242a1ea2..3b84b09b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,9 +27,9 @@ if(BIICODE) endif() # set compile flags - if(CMAKE_COMPILER_IS_GNUCXX) + if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") - endif(CMAKE_COMPILER_IS_GNUCXX) + endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") # we'll use the default config file so we can iliminate the following macro definitions if(MSVC) @@ -123,7 +123,7 @@ execute_process(COMMAND ${CMAKE_COMMAND} ${CMAKE_CURRENT_SOURCE_DIR}/include/nana/) if(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall") endif(CMAKE_COMPILER_IS_GNUCXX OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") set(NANA_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source) From 500aa030ae8b5b456c041d5f98a2878d11e42118 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 9 Oct 2015 00:18:27 +0800 Subject: [PATCH 37/65] fix an issue that weight is ignored by dockpane --- source/gui/place.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 8654f3aa..9ef4986b 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -2436,9 +2436,9 @@ namespace nana std::vector> adjusted_children; for (auto & child : children) { - //ignores weight if it is a dockpane auto dockpn = new div_dockpane(std::move(child->name), this, child->dir); dockpn->div_owner = child->div_owner; + dockpn->weight = child->weight; adjusted_children.emplace_back(dockpn); } From 1b5aed2e5f0341b1baea73bdaf2848543640e153 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 13 Oct 2015 01:38:53 +0800 Subject: [PATCH 38/65] code reviews --- build/codeblocks/nana.cbp | 1 - build/codeblocks/nana.depend | 67 ++- build/codeblocks/nana.layout | 160 +++--- build/vc2013/nana.vcxproj | 2 - build/vc2013/nana.vcxproj.filters | 6 - build/vc2015/nana.vcxproj | 1 - build/vc2015/nana.vcxproj.filters | 3 - include/nana/exceptions.hpp | 95 ---- include/nana/gui/detail/bedrock.hpp | 27 +- include/nana/gui/detail/bedrock_pi_data.hpp | 9 +- include/nana/gui/detail/color_schemes.hpp | 15 +- include/nana/gui/detail/effects_renderer.hpp | 3 +- include/nana/gui/detail/events_operation.hpp | 8 +- include/nana/gui/detail/runtime_manager.hpp | 100 ---- include/nana/gui/detail/window_manager.hpp | 1 - include/nana/gui/effects.hpp | 4 +- include/nana/gui/programming_interface.hpp | 79 ++- include/nana/gui/widgets/listbox.hpp | 32 +- include/nana/gui/wvl.hpp | 43 +- include/nana/paint/detail/image_processor.hpp | 8 +- include/nana/pat/abstract_factory.hpp | 1 + include/nana/system/shared_wrapper.hpp | 10 +- source/detail/linux_X11/platform_spec.cpp | 5 +- source/exceptions.cpp | 71 --- source/gui/animation.cpp | 1 + source/gui/detail/bedrock_pi.cpp | 55 +- source/gui/detail/color_schemes.cpp | 4 +- source/gui/detail/events_operation.cpp | 10 +- source/gui/detail/linux_X11/bedrock.cpp | 125 ++--- source/gui/detail/native_window_interface.cpp | 11 +- source/gui/detail/win32/bedrock.cpp | 137 ++--- source/gui/detail/window_manager.cpp | 10 +- source/gui/drawing.cpp | 2 +- source/gui/notifier.cpp | 9 +- source/gui/place.cpp | 26 +- source/gui/programming_interface.cpp | 530 ++++++++++-------- source/gui/state_cursor.cpp | 7 +- source/gui/widgets/listbox.cpp | 127 ++--- source/gui/widgets/skeletons/text_editor.cpp | 12 +- source/gui/wvl.cpp | 12 +- source/internationalization.cpp | 2 + 41 files changed, 830 insertions(+), 1001 deletions(-) delete mode 100644 include/nana/exceptions.hpp delete mode 100644 include/nana/gui/detail/runtime_manager.hpp delete mode 100644 source/exceptions.cpp diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp index 9302ebd6..bf4b1d0b 100644 --- a/build/codeblocks/nana.cbp +++ b/build/codeblocks/nana.cbp @@ -44,7 +44,6 @@ - diff --git a/build/codeblocks/nana.depend b/build/codeblocks/nana.depend index f7f24eaa..bc77979b 100644 --- a/build/codeblocks/nana.depend +++ b/build/codeblocks/nana.depend @@ -598,13 +598,13 @@ "win32/platform_spec.cpp" "linux_X11/platform_spec.cpp" -1439496157 d:\git.repo\nana\source\detail\win32\platform_spec.cpp +1443581342 d:\git.repo\nana\source\detail\win32\platform_spec.cpp -1439496157 d:\git.repo\nana\source\detail\linux_x11\platform_spec.cpp +1443581342 d:\git.repo\nana\source\detail\linux_x11\platform_spec.cpp @@ -653,13 +653,14 @@ -1439496157 source:d:\git.repo\nana\source\gui\animation.cpp +1444647306 source:d:\git.repo\nana\source\gui\animation.cpp + @@ -675,7 +676,7 @@ -1439496157 source:d:\git.repo\nana\source\gui\detail\bedrock_pi.cpp +1444585389 source:d:\git.repo\nana\source\gui\detail\bedrock_pi.cpp @@ -694,7 +695,7 @@ "win32/bedrock.cpp" "linux_X11/bedrock.cpp" -1439496157 d:\git.repo\nana\source\gui\detail\win32\bedrock.cpp +1444657608 d:\git.repo\nana\source\gui\detail\win32\bedrock.cpp @@ -709,7 +710,7 @@ -1439496157 d:\git.repo\nana\source\gui\detail\linux_x11\bedrock.cpp +1444647171 d:\git.repo\nana\source\gui\detail\linux_x11\bedrock.cpp @@ -720,7 +721,7 @@ -1423350892 source:d:\git.repo\nana\source\gui\detail\color_schemes.cpp +1444567878 source:d:\git.repo\nana\source\gui\detail\color_schemes.cpp @@ -736,10 +737,10 @@ 1408986718 source:d:\git.repo\nana\source\gui\detail\element_store.cpp -1439496157 source:d:\git.repo\nana\source\gui\detail\events_operation.cpp +1444470665 source:d:\git.repo\nana\source\gui\detail\events_operation.cpp -1439828940 source:d:\git.repo\nana\source\gui\detail\native_window_interface.cpp +1444647213 source:d:\git.repo\nana\source\gui\detail\native_window_interface.cpp @@ -760,9 +761,10 @@ -1439496157 source:d:\git.repo\nana\source\gui\detail\window_manager.cpp +1444657627 source:d:\git.repo\nana\source\gui\detail\window_manager.cpp + @@ -772,10 +774,10 @@ -1439746409 source:d:\git.repo\nana\source\gui\dragger.cpp +1444585885 source:d:\git.repo\nana\source\gui\dragger.cpp -1423350892 source:d:\git.repo\nana\source\gui\drawing.cpp +1444647322 source:d:\git.repo\nana\source\gui\drawing.cpp @@ -784,7 +786,7 @@ -1439829040 source:d:\git.repo\nana\source\gui\element.cpp +1444585885 source:d:\git.repo\nana\source\gui\element.cpp @@ -814,7 +816,7 @@ 1439496157 source:d:\git.repo\nana\source\gui\layout_utility.cpp -1439496157 source:d:\git.repo\nana\source\gui\msgbox.cpp +1444585885 source:d:\git.repo\nana\source\gui\msgbox.cpp @@ -833,7 +835,7 @@ -1439496157 source:d:\git.repo\nana\source\gui\notifier.cpp +1444647352 source:d:\git.repo\nana\source\gui\notifier.cpp @@ -846,12 +848,15 @@ -1439746410 source:d:\git.repo\nana\source\gui\programming_interface.cpp +1444657299 source:d:\git.repo\nana\source\gui\programming_interface.cpp + + + 1439496158 source:d:\git.repo\nana\source\gui\screen.cpp @@ -861,10 +866,11 @@ -1415011766 source:d:\git.repo\nana\source\gui\state_cursor.cpp +1444647437 source:d:\git.repo\nana\source\gui\state_cursor.cpp + 1439496158 source:d:\git.repo\nana\source\gui\timer.cpp @@ -876,7 +882,7 @@ -1439496158 source:d:\git.repo\nana\source\gui\tooltip.cpp +1444585886 source:d:\git.repo\nana\source\gui\tooltip.cpp @@ -1167,3 +1173,28 @@ +1444658359 source:d:\git.repo\nana\source\gui\place.cpp + + + + + + + + + + + + + + + "place_parts.hpp" + +1444585885 d:\git.repo\nana\source\gui\place_parts.hpp + + + + + + + diff --git a/build/codeblocks/nana.layout b/build/codeblocks/nana.layout index e961df8c..f540b83b 100644 --- a/build/codeblocks/nana.layout +++ b/build/codeblocks/nana.layout @@ -1,74 +1,39 @@ - - - - - + + + + + - + - + - + - + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -76,11 +41,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -91,29 +86,14 @@ - - - - - - - - - - - - - - - - + - + @@ -121,34 +101,29 @@ - + - + - + - + - + - + - + - + - + - - - - - - + @@ -156,4 +131,29 @@ + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/build/vc2013/nana.vcxproj b/build/vc2013/nana.vcxproj index 7ed1c2f9..25218628 100644 --- a/build/vc2013/nana.vcxproj +++ b/build/vc2013/nana.vcxproj @@ -184,7 +184,6 @@ - @@ -272,7 +271,6 @@ - diff --git a/build/vc2013/nana.vcxproj.filters b/build/vc2013/nana.vcxproj.filters index e58eb56b..2edd3515 100644 --- a/build/vc2013/nana.vcxproj.filters +++ b/build/vc2013/nana.vcxproj.filters @@ -306,9 +306,6 @@ Source Files\nana - - Source Files\nana - Source Files\nana @@ -577,9 +574,6 @@ Header Files - - Header Files - Header Files diff --git a/build/vc2015/nana.vcxproj b/build/vc2015/nana.vcxproj index 9b0433bd..8b8281a7 100644 --- a/build/vc2015/nana.vcxproj +++ b/build/vc2015/nana.vcxproj @@ -156,7 +156,6 @@ - diff --git a/build/vc2015/nana.vcxproj.filters b/build/vc2015/nana.vcxproj.filters index 42482ba2..fab8ae53 100644 --- a/build/vc2015/nana.vcxproj.filters +++ b/build/vc2015/nana.vcxproj.filters @@ -72,9 +72,6 @@ Source Files - - Source Files - Source Files diff --git a/include/nana/exceptions.hpp b/include/nana/exceptions.hpp deleted file mode 100644 index c1f709f4..00000000 --- a/include/nana/exceptions.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Exception Definition - * Copyright(C) 2003-2013 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/exceptions.hpp - */ - -#ifndef NANA_EXCEPTIONS_H -#define NANA_EXCEPTIONS_H -#include -#include - -namespace nana -{ - - /** - * nana::threads::thread::exit throws this exception to exit thread - * this exception is not allowed to be catch by programmer, - * otherwise the thread may not exit - */ - class thrd_exit: public std::exception - { - public: - thrd_exit(unsigned retval); - ~thrd_exit() throw(); - const char* what() const throw(); - unsigned retval() const; - private: - unsigned retval_; - }; - - /** - * nana::text::settings_t throws this exception if it dose not found a given member - * in a scope - */ - class bad_member: public std::exception - { - public: - bad_member(const std::string& what); - ~bad_member() throw(); - const char* what() const throw(); - private: - std::string what_; - }; - - /** - * nana::text::settings_t throws this exception if there is a syntax error - */ - class bad_syntax: public std::exception - { - public: - bad_syntax(const std::string& what); - ~bad_syntax() throw(); - const char* what() const throw(); - private: - std::string what_; - }; - - class bad_error: public std::exception - { - public: - bad_error(const std::string& what); - ~bad_error() throw(); - const char* what() const throw(); - private: - std::string what_; - }; - - class bad_handle: public std::exception - { - public: - bad_handle(const std::string& what); - ~bad_handle() throw(); - const char* what() const throw(); - private: - std::string what_; - }; - - class bad_window - :public std::exception - { - public: - bad_window(const char* what); - ~bad_window() throw(); - const char* what() const throw(); - private: - std::string what_; - }; -}// end namespace nana - -#endif diff --git a/include/nana/gui/detail/bedrock.hpp b/include/nana/gui/detail/bedrock.hpp index 91bc71ed..e4872711 100644 --- a/include/nana/gui/detail/bedrock.hpp +++ b/include/nana/gui/detail/bedrock.hpp @@ -12,9 +12,6 @@ #ifndef NANA_GUI_DETAIL_BEDROCK_HPP #define NANA_GUI_DETAIL_BEDROCK_HPP -#include "window_manager.hpp" -#include "events_operation.hpp" -#include "runtime_manager.hpp" #include "general_events.hpp" #include "color_schemes.hpp" #include "internal_scope_guard.hpp" @@ -23,9 +20,11 @@ namespace nana { namespace detail { - struct native_interface; + class element_store; - class element_store; + class events_operation; + struct basic_window; + class window_manager; //class bedrock //@brief: bedrock is a fundamental core component, it provides a abstract to the OS platform @@ -34,9 +33,7 @@ namespace detail { bedrock(); public: - typedef native_interface interface_type; - typedef window_manager window_manager_t; - typedef window_manager_t::core_window_t core_window_t; + using core_window_t = basic_window; struct thread_context; @@ -53,7 +50,6 @@ namespace detail ::nana::category::flags category(core_window_t*); core_window_t* focus(); - native_window_type root(core_window_t*); void set_menubar_taken(core_window_t*); @@ -83,14 +79,13 @@ namespace detail void undefine_state_cursor(core_window_t*, thread_context*); widget_colors& get_scheme_template(scheme_factory_base&&); - std::unique_ptr make_scheme(scheme_factory_base&&); + widget_colors* make_scheme(scheme_factory_base&&); + + events_operation& evt_operation(); + window_manager& wd_manager(); + + void manage_form_loader(core_window_t*, bool insert_or_remove); public: - events_operation evt_operation; - window_manager_t wd_manager; - - runtime_manager rt_manager; - - bool emit(event_code, core_window_t*, const arg_mouse&, bool ask_update, thread_context*); bool emit(event_code, core_window_t*, const event_arg&, bool ask_update, thread_context*); bool emit_drawer(event_code, core_window_t*, const event_arg&, thread_context*); private: diff --git a/include/nana/gui/detail/bedrock_pi_data.hpp b/include/nana/gui/detail/bedrock_pi_data.hpp index b54e658f..3154a6b3 100644 --- a/include/nana/gui/detail/bedrock_pi_data.hpp +++ b/include/nana/gui/detail/bedrock_pi_data.hpp @@ -3,6 +3,9 @@ #include #include "color_schemes.hpp" +#include "events_operation.hpp" +#include "window_manager.hpp" +#include namespace nana { @@ -10,8 +13,10 @@ namespace nana { struct bedrock::pi_data { - color_schemes scheme; - + color_schemes scheme; + events_operation evt_operation; + window_manager wd_manager; + std::set auto_form_set; }; } } diff --git a/include/nana/gui/detail/color_schemes.hpp b/include/nana/gui/detail/color_schemes.hpp index 25f75079..9482f084 100644 --- a/include/nana/gui/detail/color_schemes.hpp +++ b/include/nana/gui/detail/color_schemes.hpp @@ -14,7 +14,6 @@ #define NANA_DETAIL_COLOR_SCHEMES_HPP #include "widget_colors.hpp" -#include namespace nana { @@ -27,8 +26,8 @@ namespace nana virtual ~scheme_factory_base() = default; virtual factory_identifier* get_id() const = 0; - virtual std::unique_ptr create() = 0; - virtual std::unique_ptr create(widget_colors&) = 0; + virtual widget_colors* create() = 0; + virtual widget_colors* create(widget_colors&) = 0; }; template @@ -41,14 +40,14 @@ namespace nana return &fid_; } - std::unique_ptr create() override + widget_colors* create() override { - return std::unique_ptr(new Scheme); + return (new Scheme); } - std::unique_ptr create(widget_colors& other) override + widget_colors* create(widget_colors& other) override { - return std::unique_ptr{new Scheme(static_cast(other))}; + return (new Scheme(static_cast(other))); } private: static factory_identifier fid_; @@ -71,7 +70,7 @@ namespace nana ~color_schemes(); scheme& scheme_template(scheme_factory_base&&); - std::unique_ptr create(scheme_factory_base&&); + scheme* create(scheme_factory_base&&); private: implement * impl_; }; diff --git a/include/nana/gui/detail/effects_renderer.hpp b/include/nana/gui/detail/effects_renderer.hpp index ea2b810e..0304fcb9 100644 --- a/include/nana/gui/detail/effects_renderer.hpp +++ b/include/nana/gui/detail/effects_renderer.hpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace nana{ namespace detail @@ -14,7 +15,7 @@ namespace nana{ edge_nimbus_renderer() = default; public: using core_window_t = CoreWindow; - using window_layer = window_layout; + using window_layer = ::nana::detail::window_layout; using graph_reference = ::nana::paint::graphics&; static edge_nimbus_renderer& instance() diff --git a/include/nana/gui/detail/events_operation.hpp b/include/nana/gui/detail/events_operation.hpp index 418d2fa2..08a98b48 100644 --- a/include/nana/gui/detail/events_operation.hpp +++ b/include/nana/gui/detail/events_operation.hpp @@ -6,9 +6,9 @@ #include #if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) - #include +#include #else - #include +#include #endif namespace nana @@ -24,8 +24,8 @@ namespace nana void cancel(event_handle); void erase(event_handle); private: - mutable std::recursive_mutex mutex_; - std::unordered_set register_; + std::recursive_mutex mutex_; + std::unordered_set handles_; std::unordered_map> evt_table_; }; }//end namespace detail diff --git a/include/nana/gui/detail/runtime_manager.hpp b/include/nana/gui/detail/runtime_manager.hpp deleted file mode 100644 index 9a2fb3c8..00000000 --- a/include/nana/gui/detail/runtime_manager.hpp +++ /dev/null @@ -1,100 +0,0 @@ -/* - * A Runtime Manager Implementation - * Copyright(C) 2003-2013 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/detail/runtime_manager.hpp - * - */ -#ifndef NANA_GUI_DETAIL_RUNTIME_MANAGER_HPP -#define NANA_GUI_DETAIL_RUNTIME_MANAGER_HPP - -#include - -namespace nana -{ - namespace detail - { - template - class runtime_manager - { - public: - typedef Window window_handle; - - template - Form* create_form(Args&&... args) - { - widget_placer * holder = new widget_placer; - if (holder->create(std::forward(args)...)) - { - holder_[holder->get_handle()] = holder; - return holder->get(); - } - - delete holder; - return nullptr; - } - - void remove_if_exists(window_handle wd) - { - auto i = holder_.find(wd); - if(i != holder_.cend()) - { - delete i->second; - holder_.erase(i); - } - } - private: - class widget_holder - { - public: - virtual ~widget_holder(){} - virtual window_handle get_handle() const = 0; - }; - - template - class widget_placer : public widget_holder - { - public: - widget_placer() - : form_(nullptr) - {} - - ~widget_placer() - { - delete form_; - } - - template - bool create(Args&&... args) - { - if (nullptr == form_) - form_ = new Form(std::forward(args)...); - - return (form_ && !form_->empty()); - } - - Form* get() const - { - return form_; - } - - window_handle get_handle() const override - { - return reinterpret_cast(form_ ? form_->handle() : nullptr); - } - private: - Form * form_; - }; - private: - std::map holder_; - }; //end class runtime_manager - - }//end namespace detail -}//end namespace nana - - -#endif diff --git a/include/nana/gui/detail/window_manager.hpp b/include/nana/gui/detail/window_manager.hpp index 857d69e7..c8229df6 100644 --- a/include/nana/gui/detail/window_manager.hpp +++ b/include/nana/gui/detail/window_manager.hpp @@ -134,7 +134,6 @@ namespace detail bool get_graphics(core_window_t*, nana::paint::graphics&); bool get_visual_rectangle(core_window_t*, nana::rectangle&); - ::nana::widget* get_widget(core_window_t*) const; std::vector get_children(core_window_t*) const; bool set_parent(core_window_t* wd, core_window_t* new_parent); core_window_t* set_focus(core_window_t*, bool root_has_been_focused); diff --git a/include/nana/gui/effects.hpp b/include/nana/gui/effects.hpp index dcc31db0..3825c07a 100644 --- a/include/nana/gui/effects.hpp +++ b/include/nana/gui/effects.hpp @@ -47,7 +47,7 @@ namespace nana public: bground_transparent(std::size_t percent); private: - virtual bground_interface* create() const; + bground_interface* create() const override; private: std::size_t percent_; }; @@ -58,7 +58,7 @@ namespace nana public: bground_blur(std::size_t radius); private: - virtual bground_interface * create() const; + bground_interface * create() const override; private: std::size_t radius_; }; diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 6de9ba97..520bc05c 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -13,9 +13,9 @@ #ifndef NANA_GUI_PROGRAMMING_INTERFACE_HPP #define NANA_GUI_PROGRAMMING_INTERFACE_HPP #include -#include "detail/bedrock.hpp" #include "effects.hpp" #include "detail/general_events.hpp" +#include "detail/color_schemes.hpp" #include #include @@ -44,6 +44,11 @@ namespace nana namespace API { + namespace detail + { + ::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_base&&); + } + void effects_edge_nimbus(window, effects::edge_nimbus); effects::edge_nimbus effects_edge_nimbus(window); @@ -60,8 +65,7 @@ namespace API template std::unique_ptr make_scheme() { - return std::unique_ptr( - static_cast(::nana::detail::bedrock::instance().make_scheme(::nana::detail::scheme_factory()).release())); + return std::unique_ptr{static_cast(API::detail::make_scheme(::nana::detail::scheme_factory()))}; } void set_scheme(window, widget_colors*); @@ -82,9 +86,56 @@ namespace API }//end namespace dev + widget* get_widget(window); + namespace detail { general_events* get_general_events(window); + bool emit_event(event_code, window, const ::nana::event_arg&); + + class enum_widgets_function_base + { + public: + virtual ~enum_widgets_function_base() = default; + void enum_widgets(window, bool recursive); + private: + virtual bool _m_enum_fn(::nana::widget*) = 0; + }; + + template + class enum_widgets_function + : public enum_widgets_function_base + { + public: + enum_widgets_function(EnumFunction && enum_fn) + : enum_fn_(static_cast(enum_fn)) + {} + private: + bool _m_enum_fn(::nana::widget* wd) override + { + return _m_enum_call(wd, nullptr); + } + + template::value>::type* = nullptr> + bool _m_enum_call(::nana::widget* wd) + { + enum_fn_(*wd); + return true; + } + + template::value>::type* = nullptr> + bool _m_enum_call(::nana::widget* wd) + { + auto ptr = dynamic_cast(wd); + if (nullptr == ptr) + return false; + + enum_fn_(*ptr); + return true; + } + private: + EnumFunction && enum_fn_; + }; }//end namespace detail void exit(); @@ -98,25 +149,12 @@ namespace API rectangle make_center(window, unsigned width, unsigned height); ///< Retrieves a rectangle which is in the center of the window template - void enum_widgets(window wd, bool recursive, EnumFunction && ef) + void enum_widgets(window wd, bool recursive, EnumFunction && fn) { static_assert(std::is_convertible::value, "enum_widgets: The specified Widget is not a widget type."); - typedef ::nana::detail::basic_window core_window_t; - auto & brock = ::nana::detail::bedrock::instance(); - internal_scope_guard lock; - - auto children = brock.wd_manager.get_children(reinterpret_cast(wd)); - for (auto child : children) - { - auto wgt = dynamic_cast(brock.wd_manager.get_widget(child)); - if (nullptr == wgt) - continue; - - ef(*wgt); - if (recursive) - enum_widgets(wd, recursive, std::forward(ef)); - } + detail::enum_widgets_function enum_fn(static_cast(fn)); + enum_fn.enum_widgets(wd, recursive); } void window_icon_default(const paint::image& small_icon, const paint::image& big_icon = {}); @@ -172,8 +210,7 @@ namespace API template::value>::type* = nullptr> bool emit_event(event_code evt_code, window wd, const EventArg& arg) { - auto & brock = ::nana::detail::bedrock::instance(); - return brock.emit(evt_code, reinterpret_cast< ::nana::detail::bedrock::core_window_t*>(wd), arg, true, brock.get_thread_context()); + return detail::emit_event(evt_code, wd, arg); } void umake_event(event_handle); diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 41a294fb..be509a12 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -166,9 +166,7 @@ namespace nana std::size_t pos_{0}; }; - - - typedef std::vector selection; + using selection = std::vector; /// struct essence_t ///@brief: this struct gives many data for listbox, @@ -180,7 +178,7 @@ namespace nana class drawer_lister_impl; /// mostly works on display positions - class trigger: public drawer_trigger + class trigger: public drawer_trigger { public: trigger(); @@ -208,9 +206,9 @@ namespace nana drawer_lister_impl *drawer_lister_; };//end class trigger - /// operate with absolute positions and contain only the position but montain pointers to parts of the real items + /// operate with absolute positions and contain only the position but montain pointers to parts of the real items /// item_proxy self, it references and iterators are not invalidated by sort() - class item_proxy + class item_proxy : public std::iterator { public: @@ -445,18 +443,18 @@ namespace nana size_type pos_{0}; ///< Absolute position, not relative to display, and dont change during sort() }; - struct export_options - { - nana::string sep = nana::string {STR("\t" )}, - endl= nana::string {STR("\n")} ; - bool only_selected_items{true}, - only_checked_items {false}, - only_visible_columns{true}; + struct export_options + { + nana::string sep = nana::string {STR("\t" )}, + endl= nana::string {STR("\n")}; + bool only_selected_items{true}, + only_checked_items {false}, + only_visible_columns{true}; - using columns_indexs = std::vector; - columns_indexs columns_order; - }; - } + using columns_indexs = std::vector; + columns_indexs columns_order; + }; + } }//end namespace drawerbase struct arg_listbox diff --git a/include/nana/gui/wvl.hpp b/include/nana/gui/wvl.hpp index e9855208..4959e852 100644 --- a/include/nana/gui/wvl.hpp +++ b/include/nana/gui/wvl.hpp @@ -1,7 +1,7 @@ /* * Nana GUI Library Definition * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -20,27 +20,42 @@ #include "widgets/form.hpp" #include "drawing.hpp" #include "msgbox.hpp" -#include "../exceptions.hpp" namespace nana { - template - class form_loader + namespace detail { - public: - template - Form & operator()(Args &&... args) const + struct form_loader_private { - Form* res = detail::bedrock::instance().rt_manager.create_form(std::forward(args)...); - if (nullptr == res) - throw nana::bad_window("form_loader.operator(): failed to create a window"); + template friend class form_loader; + private: + static void insert_form(::nana::widget*); + }; - if (IsMakeVisible) res->show(); + template + class form_loader + { + public: + template + Form & operator()(Args &&... args) const + { + auto p = new Form(std::forward(args)...); - return *res; - } + if (p->empty()) + throw std::logic_error("form_loader failed to create the form"); - }; + detail::form_loader_private::insert_form(p); + if (IsVisible) + p->show(); + + return *p; + } + + }; + } + + template + using form_loader = detail::form_loader; void exec(); }//end namespace nana diff --git a/include/nana/paint/detail/image_processor.hpp b/include/nana/paint/detail/image_processor.hpp index 13d1d6ab..da3b8fb8 100644 --- a/include/nana/paint/detail/image_processor.hpp +++ b/include/nana/paint/detail/image_processor.hpp @@ -1,7 +1,7 @@ /* * Image Processor Algorithm Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -233,9 +233,9 @@ namespace detail std::size_t coef2 = el.iu * iv_minus_coef; std::size_t coef3 = el.iu * iv; - i->element.red = static_cast((coef0 * col0.element.red + coef1 * col1.element.red + (coef2 * col2.element.red + coef3 * col3.element.red)) >> double_shift_size); - i->element.green = static_cast((coef0 * col0.element.green + coef1 * col1.element.green + (coef2 * col2.element.green + coef3 * col3.element.green)) >> double_shift_size); - i->element.blue = static_cast((coef0 * col0.element.blue + coef1 * col1.element.blue + (coef2 * col2.element.blue + coef3 * col3.element.blue)) >> double_shift_size); + i->element.red = static_cast((coef0 * col0.element.red + coef1 * col1.element.red + (coef2 * col2.element.red + coef3 * col3.element.red)) >> double_shift_size); + i->element.green = static_cast((coef0 * col0.element.green + coef1 * col1.element.green + (coef2 * col2.element.green + coef3 * col3.element.green)) >> double_shift_size); + i->element.blue = static_cast((coef0 * col0.element.blue + coef1 * col1.element.blue + (coef2 * col2.element.blue + coef3 * col3.element.blue)) >> double_shift_size); } } } diff --git a/include/nana/pat/abstract_factory.hpp b/include/nana/pat/abstract_factory.hpp index cfdc7dfb..9a4b3bfe 100644 --- a/include/nana/pat/abstract_factory.hpp +++ b/include/nana/pat/abstract_factory.hpp @@ -13,6 +13,7 @@ #ifndef NANA_PAT_ABSFACTORY_HPP #define NANA_PAT_ABSFACTORY_HPP +#include "cloneable.hpp" #include namespace nana diff --git a/include/nana/system/shared_wrapper.hpp b/include/nana/system/shared_wrapper.hpp index 78b99618..57754a6b 100644 --- a/include/nana/system/shared_wrapper.hpp +++ b/include/nana/system/shared_wrapper.hpp @@ -14,7 +14,7 @@ #include #include -#include +#include namespace nana @@ -70,19 +70,19 @@ namespace system typedef typename function_ptr::type fptr_type; if(nana::traits::is_function_pointer::value == false) - throw nana::bad_error("shared_wrapper::symbols, template<_Function> is not a function type or a function pointer type"); + throw std::invalid_argument("shared_wrapper::symbols, template<_Function> is not a function type or a function pointer type"); if(symbol == 0) - throw nana::bad_handle("shared_wrapper::symbols, symbol is null string"); + throw std::invalid_argument("shared_wrapper::symbols, symbol is null string"); if(impl_.handle == 0) - throw nana::bad_handle("shared_wrapper::symbols, empty handle"); + throw std::logic_error("shared_wrapper::symbols, empty handle"); if(impl_.symbol != symbol) { void *result = detail::shared_helper::symbols(impl_.handle, symbol); if(result == 0) - throw nana::bad_handle("shared_wrapper::symbols, empty proc address"); + throw std::logic_error("shared_wrapper::symbols, empty proc address"); impl_.proc_address = result; impl_.symbol = symbol; diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index 8d4ff735..bdab0cf0 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -24,6 +24,7 @@ #include #include #include +#include #include #include #include @@ -696,7 +697,7 @@ namespace detail if(vec) { set_error_handler(); - auto & wd_manager = detail::bedrock::instance().wd_manager; + auto & wd_manager = detail::bedrock::instance().wd_manager(); for(auto u = vec->rbegin(); u != vec->rend(); ++u) wd_manager.close(wd_manager.root(*u)); @@ -1362,7 +1363,7 @@ namespace detail ::XTranslateCoordinates(self.display_, self.root_window(), evt.xclient.window, x, y, &self.xdnd_.pos.x, &self.xdnd_.pos.y, &child); typedef detail::bedrock bedrock; - auto wd = bedrock::instance().wd_manager.find_window(reinterpret_cast(evt.xclient.window), self.xdnd_.pos.x, self.xdnd_.pos.y); + auto wd = bedrock::instance().wd_manager().find_window(reinterpret_cast(evt.xclient.window), self.xdnd_.pos.x, self.xdnd_.pos.y); if(wd && wd->flags.dropable) { accepted = true; diff --git a/source/exceptions.cpp b/source/exceptions.cpp deleted file mode 100644 index 31c0a0b5..00000000 --- a/source/exceptions.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Exception Definition - * Copyright(C) 2003-2013 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/exceptions.cpp - */ -#include - -namespace nana -{ - - //class thrd_exit - thrd_exit::thrd_exit(unsigned retval):retval_(retval){} - thrd_exit::~thrd_exit() throw(){} - const char* thrd_exit::what() const throw(){ return "Exit-Threading Exception"; } - unsigned thrd_exit::retval() const { return retval_; } - //end class thrd_exit - - //class bad_member - bad_member::bad_member(const std::string& what):what_(what){} - bad_member::~bad_member() throw(){} - const char* bad_member::what() const throw() - { - return what_.c_str(); - } - //end class bad_member - - //class bad_syntax - bad_syntax::bad_syntax(const std::string& what):what_(what){} - bad_syntax::~bad_syntax() throw(){} - const char* bad_syntax::what() const throw() - { - return what_.c_str(); - } - //end class bad_syntax - - //class bad_error - bad_error::bad_error(const std::string& what):what_(what){} - bad_error::~bad_error() throw(){} - const char* bad_error::what() const throw() - { - return what_.c_str(); - } - //end class bad_error - - //class bad_handle: public std::exception - bad_handle::bad_handle(const std::string& what):what_(what){} - bad_handle::~bad_handle() throw(){} - const char* bad_handle::what() const throw() - { - return what_.c_str(); - } - //end class bad_handle - - //class bad_window - bad_window::bad_window(const char* what) - :what_(what) - {} - - bad_window::~bad_window() throw(){} - - const char* bad_window::what() const throw() - { - return what_.c_str(); - } - //end class bad_window -} //end namespace nana diff --git a/source/gui/animation.cpp b/source/gui/animation.cpp index 782b7c19..5f252e8c 100644 --- a/source/gui/animation.cpp +++ b/source/gui/animation.cpp @@ -18,6 +18,7 @@ #include #include +#include #include #if defined(NANA_MINGW) && defined(STD_THREAD_NOT_SUPPORTED) diff --git a/source/gui/detail/bedrock_pi.cpp b/source/gui/detail/bedrock_pi.cpp index 8f2cff1c..4ca34572 100644 --- a/source/gui/detail/bedrock_pi.cpp +++ b/source/gui/detail/bedrock_pi.cpp @@ -29,12 +29,12 @@ namespace nana //class internal_scope_guard internal_scope_guard::internal_scope_guard() { - detail::bedrock::instance().wd_manager.internal_lock().lock(); + detail::bedrock::instance().wd_manager().internal_lock().lock(); } internal_scope_guard::~internal_scope_guard() { - detail::bedrock::instance().wd_manager.internal_lock().unlock(); + detail::bedrock::instance().wd_manager().internal_lock().unlock(); } //end class internal_scope_guard @@ -54,12 +54,12 @@ namespace nana { void events_operation_register(event_handle evt) { - bedrock::instance().evt_operation.register_evt(evt); + bedrock::instance().evt_operation().register_evt(evt); } void events_operation_cancel(event_handle evt) { - bedrock::instance().evt_operation.cancel(evt); + bedrock::instance().evt_operation().cancel(evt); } class bedrock::flag_guard @@ -73,7 +73,7 @@ namespace nana ~flag_guard() { - if (brock_->wd_manager.available((wd_))) + if (brock_->wd_manager().available((wd_))) wd_->flags.refreshing = false; } private: @@ -82,6 +82,31 @@ namespace nana }; + events_operation& bedrock::evt_operation() + { + return pi_data_->evt_operation; + } + + window_manager& bedrock::wd_manager() + { + return pi_data_->wd_manager; + } + + void bedrock::manage_form_loader(core_window_t* wd, bool insert_or_remove) + { + if (insert_or_remove) + { + pi_data_->auto_form_set.insert(wd); + return; + } + + if (pi_data_->auto_form_set.erase(wd)) + { + auto p = wd->widget_notifier->widget_ptr(); + delete p; + } + } + void bedrock::event_expose(core_window_t * wd, bool exposed) { if (nullptr == wd) return; @@ -113,11 +138,11 @@ namespace nana wd = wd->seek_non_lite_widget_ancestor(); } else if (category::flags::frame == wd->other.category) - wd = wd_manager.find_window(wd->root, wd->pos_root.x, wd->pos_root.y); + wd = wd_manager().find_window(wd->root, wd->pos_root.x, wd->pos_root.y); } - wd_manager.refresh_tree(wd); - wd_manager.map(wd, false); + wd_manager().refresh_tree(wd); + wd_manager().map(wd, false); } } @@ -130,13 +155,13 @@ namespace nana arg.x = x; arg.y = y; if (emit(event_code::move, wd, arg, false, get_thread_context())) - wd_manager.update(wd, false, true); + wd_manager().update(wd, false, true); } } bool bedrock::event_msleave(core_window_t* hovered) { - if (wd_manager.available(hovered) && hovered->flags.enabled) + if (wd_manager().available(hovered) && hovered->flags.enabled) { hovered->flags.action = mouse_action::normal; @@ -155,7 +180,7 @@ namespace nana void bedrock::update_cursor(core_window_t * wd) { internal_scope_guard isg; - if (wd_manager.available(wd)) + if (wd_manager().available(wd)) { auto * thrd = get_thread_context(wd->thread_id); if (nullptr == thrd) @@ -167,7 +192,7 @@ namespace nana return; native_interface::calc_window_point(native_handle, pos); - if (wd != wd_manager.find_window(native_handle, pos.x, pos.y)) + if (wd != wd_manager().find_window(native_handle, pos.x, pos.y)) return; set_cursor(wd, wd->predef_cursor, thrd); @@ -179,7 +204,7 @@ namespace nana return pi_data_->scheme.scheme_template(std::move(factory)); } - std::unique_ptr bedrock::make_scheme(scheme_factory_base&& factory) + widget_colors* bedrock::make_scheme(scheme_factory_base&& factory) { return pi_data_->scheme.create(std::move(factory)); } @@ -415,7 +440,7 @@ namespace nana void bedrock::_m_except_handler() { std::vector v; - wd_manager.all_handles(v); + wd_manager().all_handles(v); if (v.size()) { std::vector roots; @@ -432,7 +457,7 @@ namespace nana } for (auto i : roots) - interface_type::close_window(i); + native_interface::close_window(i); } } }//end namespace detail diff --git a/source/gui/detail/color_schemes.cpp b/source/gui/detail/color_schemes.cpp index 527b4644..c7fcd530 100644 --- a/source/gui/detail/color_schemes.cpp +++ b/source/gui/detail/color_schemes.cpp @@ -76,12 +76,12 @@ namespace nana //Creates a scheme template if no template if (!tmpl_scheme) - factory.create().swap(tmpl_scheme); + tmpl_scheme.reset(factory.create()); return *tmpl_scheme.get(); } - std::unique_ptr color_schemes::create(scheme_factory_base&& factory) + widget_colors* color_schemes::create(scheme_factory_base&& factory) { return factory.create(scheme_template(std::move(factory))); } diff --git a/source/gui/detail/events_operation.cpp b/source/gui/detail/events_operation.cpp index cb99accd..8877ebd1 100644 --- a/source/gui/detail/events_operation.cpp +++ b/source/gui/detail/events_operation.cpp @@ -5,7 +5,7 @@ namespace nana namespace detail { //class events_operation - typedef std::lock_guard lock_guard; + using lock_guard = std::lock_guard; void events_operation::make(window wd, const std::shared_ptr& sp) { @@ -22,21 +22,21 @@ namespace nana void events_operation::register_evt(event_handle evt) { lock_guard lock(mutex_); - register_.insert(evt); + handles_.insert(evt); } void events_operation::cancel(event_handle evt) { lock_guard lock(mutex_); - register_.erase(evt); + handles_.erase(evt); } void events_operation::erase(event_handle evt) { lock_guard lock(mutex_); - auto i = register_.find(evt); - if (i != register_.end()) + auto i = handles_.find(evt); + if (i != handles_.end()) { reinterpret_cast(evt)->get_event()->remove(evt); } diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 1260067b..a66a205e 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -233,7 +233,7 @@ namespace detail if(wd) { internal_scope_guard isg; - if(wd_manager.available(wd)) + if(wd_manager().available(wd)) return wd->other.category; } return category::flags::super; @@ -241,21 +241,10 @@ namespace detail bedrock::core_window_t* bedrock::focus() { - core_window_t* wd = wd_manager.root(native_interface::get_focus_window()); + core_window_t* wd = wd_manager().root(native_interface::get_focus_window()); return (wd ? wd->other.attribute.root->focus : 0); } - native_window_type bedrock::root(core_window_t* wd) - { - if(wd) - { - internal_scope_guard isg; - if(wd_manager.available(wd)) - return wd->root; - } - return nullptr; - } - void bedrock::set_menubar_taken(core_window_t* wd) { auto pre = impl_->menu.taken_window; @@ -265,8 +254,8 @@ namespace detail if ((!wd) && pre) { internal_scope_guard lock; - wd_manager.set_focus(pre, false); - wd_manager.update(pre, true, false); + wd_manager().set_focus(pre, false); + wd_manager().update(pre, true, false); } } @@ -381,17 +370,9 @@ namespace detail //No implementation for Linux } - - bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd) - { - if(evt_code != arg.evt_code) - throw std::runtime_error("Nana.bedrock: Invalid event arg."); - return emit(evt_code, wd, static_cast(arg), ask_update, thrd); - } - bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, bool ask_update, thread_context* thrd) { - if(wd_manager.available(wd) == false) + if(wd_manager().available(wd) == false) return false; core_window_t * prev_wd; @@ -408,7 +389,7 @@ namespace detail _m_emit_core(evt_code, wd, false, arg); if(ask_update) - wd_manager.do_lazy_refresh(wd, false); + wd_manager().do_lazy_refresh(wd, false); else wd->other.upd_state = core_window_t::update_state::none; @@ -418,7 +399,7 @@ namespace detail bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, thread_context* thrd) { - if(wd_manager.available(wd) == false) + if(wd_manager().available(wd) == false) return false; core_window_t * prev_wd; @@ -541,7 +522,7 @@ namespace detail static auto& brock = detail::bedrock::instance(); auto native_window = reinterpret_cast(msg.u.packet_window); - auto root_runtime = brock.wd_manager.root_runtime(native_window); + auto root_runtime = brock.wd_manager().root_runtime(native_window); if(root_runtime) { @@ -550,7 +531,7 @@ namespace detail switch(msg.kind) { case nana::detail::msg_packet_tag::kind_mouse_drop: - msgwd = brock.wd_manager.find_window(native_window, msg.u.mouse_drop.x, msg.u.mouse_drop.y); + msgwd = brock.wd_manager().find_window(native_window, msg.u.mouse_drop.x, msg.u.mouse_drop.y); if(msgwd) { arg_dropfiles arg; @@ -560,7 +541,7 @@ namespace detail arg.pos.x = msg.u.mouse_drop.x - msgwd->pos_root.x; arg.pos.y = msg.u.mouse_drop.y - msgwd->pos_root.y; msgwd->together.events_ptr->mouse_dropfiles.emit(arg); - brock.wd_manager.do_lazy_refresh(msgwd, false); + brock.wd_manager().do_lazy_refresh(msgwd, false); } break; default: @@ -572,7 +553,7 @@ namespace detail template void emit_drawer(void(::nana::detail::drawer::*event_ptr)(const Arg&), basic_window* wd, const Arg& arg, bedrock::thread_context* thrd) { - if(bedrock::instance().wd_manager.available(wd) == false) + if(bedrock::instance().wd_manager().available(wd) == false) return; basic_window * pre_wd; if(thrd) @@ -597,7 +578,7 @@ namespace detail static core_window_t* last_mouse_down_window; auto native_window = reinterpret_cast(event_window(xevent)); - auto root_runtime = brock.wd_manager.root_runtime(native_window); + auto root_runtime = brock.wd_manager().root_runtime(native_window); if(root_runtime) { @@ -612,7 +593,7 @@ namespace detail switch(xevent.type) { case EnterNotify: - msgwnd = brock.wd_manager.find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y); + msgwnd = brock.wd_manager().find_window(native_window, xevent.xcrossing.x, xevent.xcrossing.y); if(msgwnd) { if (mouse_action::pressed != msgwnd->flags.action) @@ -626,7 +607,7 @@ namespace detail arg.evt_code = event_code::mouse_move; brock.emit(event_code::mouse_move, msgwnd, arg, true, &context); - if (!brock.wd_manager.available(hovered_wd)) + if (!brock.wd_manager().available(hovered_wd)) hovered_wd = nullptr; } break; @@ -646,7 +627,7 @@ namespace detail arg.receiver = native_window; arg.getting = true; if(!brock.emit(event_code::focus, focus, arg, true, &context)) - brock.wd_manager.set_focus(msgwnd, true); + brock.wd_manager().set_focus(msgwnd, true); } break; case FocusOut: @@ -672,7 +653,7 @@ namespace detail if(msgwnd->dimension.width != static_cast(xevent.xconfigure.width) || msgwnd->dimension.height != static_cast(xevent.xconfigure.height)) { auto & cf = xevent.xconfigure; - brock.wd_manager.size(msgwnd, nana::size{static_cast(cf.width), static_cast(cf.height)}, true, true); + brock.wd_manager().size(msgwnd, nana::size{static_cast(cf.width), static_cast(cf.height)}, true, true); } if(msgwnd->pos_native.x != xevent.xconfigure.x || msgwnd->pos_native.y != xevent.xconfigure.y) @@ -686,7 +667,7 @@ namespace detail if(xevent.xbutton.button == Button4 || xevent.xbutton.button == Button5) break; - msgwnd = brock.wd_manager.find_window(native_window, xevent.xbutton.x, xevent.xbutton.y); + msgwnd = brock.wd_manager().find_window(native_window, xevent.xbutton.x, xevent.xbutton.y); if(nullptr == msgwnd) break; if ((msgwnd == msgwnd->root_widget->other.attribute.root->menubar) && brock.get_menu(msgwnd->root, true)) @@ -706,9 +687,9 @@ namespace detail if (new_focus && !new_focus->flags.ignore_mouse_focus) { context.event_window = new_focus; - auto kill_focus = brock.wd_manager.set_focus(new_focus, false); + auto kill_focus = brock.wd_manager().set_focus(new_focus, false); if (kill_focus != new_focus) - brock.wd_manager.do_lazy_refresh(kill_focus, false); + brock.wd_manager().do_lazy_refresh(kill_focus, false); } } @@ -722,7 +703,7 @@ namespace detail arg.evt_code = dbl_click ? event_code::dbl_click : event_code::mouse_down; if(brock.emit(arg.evt_code, msgwnd, arg, true, &context)) { - if (brock.wd_manager.available(msgwnd)) + if (brock.wd_manager().available(msgwnd)) { pressed_wd = msgwnd; //If a root window is created during the mouse_down event, Nana.GUI will ignore the mouse_up event. @@ -731,7 +712,7 @@ namespace detail //call the drawer mouse up event for restoring the surface graphics msgwnd->flags.action = mouse_action::normal; emit_drawer(&drawer::mouse_up, msgwnd, arg, &context); - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); } } } @@ -758,7 +739,7 @@ namespace detail } else { - msgwnd = brock.wd_manager.find_window(native_window, xevent.xbutton.x, xevent.xbutton.y); + msgwnd = brock.wd_manager().find_window(native_window, xevent.xbutton.x, xevent.xbutton.y); if(nullptr == msgwnd) break; @@ -786,7 +767,7 @@ namespace detail } //Do mouse_up, this handle may be closed by click handler. - if(brock.wd_manager.available(msgwnd) && msgwnd->flags.enabled) + if(brock.wd_manager().available(msgwnd) && msgwnd->flags.enabled) { if(hit) msgwnd->flags.action = mouse_action::over; @@ -805,7 +786,7 @@ namespace detail evt_ptr->click.emit(arg); } - if (brock.wd_manager.available(msgwnd)) + if (brock.wd_manager().available(msgwnd)) { arg.evt_code = event_code::mouse_up; evt_ptr->mouse_up.emit(arg); @@ -818,7 +799,7 @@ namespace detail arg.by_mouse = true; msgwnd->together.events_ptr->click.emit(arg); } - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); } pressed_wd = nullptr; } @@ -826,7 +807,7 @@ namespace detail case DestroyNotify: { auto & spec = nana::detail::platform_spec::instance(); - if(brock.wd_manager.available(msgwnd)) + if(brock.wd_manager().available(msgwnd)) { //The msgwnd may be destroyed if the window is destroyed by calling native interface of close_window(). if (msgwnd->root == brock.get_menu()) @@ -836,10 +817,10 @@ namespace detail } spec.remove(native_window); - brock.wd_manager.destroy(msgwnd); + brock.wd_manager().destroy(msgwnd); - brock.rt_manager.remove_if_exists(msgwnd); - brock.wd_manager.destroy_handle(msgwnd); + brock.manage_form_loader(msgwnd, false); + brock.wd_manager().destroy_handle(msgwnd); } } break; @@ -854,8 +835,8 @@ namespace detail else break; - msgwnd = brock.wd_manager.find_window(native_window, xevent.xmotion.x, xevent.xmotion.y); - if (brock.wd_manager.available(hovered_wd) && (msgwnd != hovered_wd)) + msgwnd = brock.wd_manager().find_window(native_window, xevent.xmotion.x, xevent.xmotion.y); + if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd)) { brock.event_msleave(hovered_wd); hovered_wd->flags.action = mouse_action::normal; @@ -863,14 +844,14 @@ namespace detail //if msgwnd is neither a captured window nor a child of captured window, //redirect the msgwnd to the captured window. - auto cap_wd = brock.wd_manager.capture_redirect(msgwnd); + auto cap_wd = brock.wd_manager().capture_redirect(msgwnd); if(cap_wd) msgwnd = cap_wd; } else if(msgwnd) { bool prev_captured_inside; - if(brock.wd_manager.capture_window_entered(xevent.xmotion.x, xevent.xmotion.y, prev_captured_inside)) + if(brock.wd_manager().capture_window_entered(xevent.xmotion.x, xevent.xmotion.y, prev_captured_inside)) { event_code evt_code; if(prev_captured_inside) @@ -909,7 +890,7 @@ namespace detail arg.evt_code = event_code::mouse_move; brock.emit(event_code::mouse_move, msgwnd, arg, true, &context); } - if (!brock.wd_manager.available(hovered_wd)) + if (!brock.wd_manager().available(hovered_wd)) hovered_wd = nullptr; break; case MapNotify: @@ -1010,11 +991,11 @@ namespace detail { arg_keyboard argkey; brock.get_key_state(argkey); - auto tstop_wd = brock.wd_manager.tabstop(msgwnd, !argkey.shift); + auto tstop_wd = brock.wd_manager().tabstop(msgwnd, !argkey.shift); if (tstop_wd) { - brock.wd_manager.set_focus(tstop_wd, false); - brock.wd_manager.do_lazy_refresh(tstop_wd, true); + brock.wd_manager().set_focus(tstop_wd, false); + brock.wd_manager().do_lazy_refresh(tstop_wd, true); } } else if(keyboard::alt == keychar) @@ -1050,7 +1031,7 @@ namespace detail arg.window_handle = reinterpret_cast(msgwnd); brock.emit(event_code::key_press, msgwnd, arg, true, &context); - if((XLookupKeySym == status) && (brock.wd_manager.available(msgwnd))) + if((XLookupKeySym == status) && (brock.wd_manager().available(msgwnd))) { //call key_char event if status is XLookupKeySym to avaid calling key_char //twice, because the status would be equal to XLookupChars if the input method is @@ -1069,7 +1050,7 @@ namespace detail if(XLookupKeySym == status) { - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); break; } case XLookupChars: @@ -1099,7 +1080,7 @@ namespace detail arg.ctrl = arg.shift = false; arg.evt_code = event_code::shortkey; brock.set_keyboard_shortkey(true); - auto shr_wd = brock.wd_manager.find_shortkey(native_window, arg.key); + auto shr_wd = brock.wd_manager().find_shortkey(native_window, arg.key); if(shr_wd) { arg.window_handle = reinterpret_cast(shr_wd); @@ -1112,7 +1093,7 @@ namespace detail brock.get_key_state(arg); msgwnd->together.events_ptr->key_char.emit(arg); - if(arg.ignore == false && brock.wd_manager.available(msgwnd)) + if(arg.ignore == false && brock.wd_manager().available(msgwnd)) brock.emit_drawer(event_code::key_char, msgwnd, arg, &context); } @@ -1121,7 +1102,7 @@ namespace detail } break; } - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); if(keybuf != fixbuf) delete [] keybuf; } @@ -1156,7 +1137,7 @@ namespace detail { bool set_focus = (brock.focus() != msgwnd) && (!msgwnd->root_widget->flags.ignore_menubar_focus); if (set_focus) - brock.wd_manager.set_focus(msgwnd, false); + brock.wd_manager().set_focus(msgwnd, false); arg_keyboard arg; arg.evt_code = event_code::key_release; @@ -1194,7 +1175,7 @@ namespace detail } } - root_runtime = brock.wd_manager.root_runtime(native_window); + root_runtime = brock.wd_manager().root_runtime(native_window); if(root_runtime) { context.event_window = pre_event_window; @@ -1207,11 +1188,11 @@ namespace detail if(context) context->event_window = pre_event_window; } - auto thread_id = ::nana::system::this_thread_id() - brock.wd_manager.call_safe_place(thread_id); + auto thread_id = ::nana::system::this_thread_id(); + brock.wd_manager().call_safe_place(thread_id); if(msgwnd) - brock.wd_manager.remove_trash_handle(thread_id); + brock.wd_manager().remove_trash_handle(thread_id); } } @@ -1226,18 +1207,18 @@ namespace detail } ++(context->event_pump_ref_count); - wd_manager.internal_lock().revert(); + wd_manager().internal_lock().revert(); native_window_type owner_native = 0; core_window_t * owner = 0; if(modal_window) { - native_window_type modal = root(reinterpret_cast(modal_window)); + native_window_type modal = reinterpret_cast(modal_window)->root; owner_native = native_interface::get_owner_window(modal); if(owner_native) { native_interface::enable_window(owner_native, false); - owner = wd_manager.root(owner_native); + owner = wd_manager().root(owner_native); if(owner) owner->flags.enabled = false; } @@ -1252,7 +1233,7 @@ namespace detail native_interface::enable_window(owner_native, true); } - wd_manager.internal_lock().forward(); + wd_manager().internal_lock().forward(); if(0 == --(context->event_pump_ref_count)) { if(0 == modal_window || 0 == context->window_count) @@ -1338,7 +1319,7 @@ namespace detail void bedrock::undefine_state_cursor(core_window_t * wd, thread_context* thrd) { - if (!wd_manager.available(wd)) + if (!wd_manager().available(wd)) return; wd->root_widget->other.attribute.root->state_cursor = nana::cursor::arrow; @@ -1350,7 +1331,7 @@ namespace detail return; native_interface::calc_window_point(native_handle, pos); - auto rev_wd = wd_manager.find_window(native_handle, pos.x, pos.y); + auto rev_wd = wd_manager().find_window(native_handle, pos.x, pos.y); if (rev_wd) set_cursor(rev_wd, rev_wd->predef_cursor, thrd); } diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 6dd9a583..8605f6f1 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -1,7 +1,7 @@ /* * Platform Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -25,6 +25,7 @@ #elif defined(NANA_X11) #include #include + #include #endif namespace nana{ @@ -595,7 +596,7 @@ namespace nana{ Display* disp = restrict::spec.open_display(); restrict::spec.remove(wd); - auto iwd = brock.wd_manager.root(wd); + auto iwd = brock.wd_manager().root(wd); if(iwd) { { @@ -607,9 +608,9 @@ namespace nana{ ::XFlush(disp); restrict::spec.rev_error_handler(); } - brock.wd_manager.destroy(iwd); - brock.rt_manager.remove_if_exists(iwd); - brock.wd_manager.destroy_handle(iwd); + brock.wd_manager().destroy(iwd); + brock.manage_form_loader(iwd, false); + brock.wd_manager().destroy_handle(iwd); } nana::detail::platform_scope_guard psg; diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index e1095345..a6c13feb 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -251,10 +251,10 @@ namespace detail bedrock::~bedrock() { - if(wd_manager.number_of_core_window()) + if(wd_manager().number_of_core_window()) { std::stringstream ss; - ss<<"Nana.GUI detects a memory leaks in window_manager, "<(wd_manager.number_of_core_window())<<" window(s) are not uninstalled."; + ss<<"Nana.GUI detects a memory leaks in window_manager, "<(wd_manager().number_of_core_window())<<" window(s) are not uninstalled."; ::MessageBoxA(0, ss.str().c_str(), ("Nana C++ Library"), MB_OK); } @@ -364,7 +364,7 @@ namespace detail ++(context->event_pump_ref_count); - auto & intr_locker = wd_manager.internal_lock(); + auto & intr_locker = wd_manager().internal_lock(); intr_locker.revert(); try @@ -372,8 +372,7 @@ namespace detail MSG msg; if(modal_window) { - HWND native_handle = reinterpret_cast( - root(reinterpret_cast(modal_window))); + HWND native_handle = reinterpret_cast(reinterpret_cast(modal_window)->root); if (is_modal) { HWND owner = ::GetWindow(native_handle, GW_OWNER); @@ -395,7 +394,7 @@ namespace detail ::TranslateMessage(&msg); ::DispatchMessage(&msg); - wd_manager.remove_trash_handle(tid); + wd_manager().remove_trash_handle(tid); } } } @@ -413,8 +412,8 @@ namespace detail ::DispatchMessage(&msg); } - wd_manager.call_safe_place(tid); - wd_manager.remove_trash_handle(tid); + wd_manager().call_safe_place(tid); + wd_manager().remove_trash_handle(tid); if (msg.message == WM_DESTROY && msg.hwnd == native_handle) break; }//end while @@ -433,8 +432,8 @@ namespace detail ::DispatchMessage(&msg); } - wd_manager.call_safe_place(tid); - wd_manager.remove_trash_handle(tid); + wd_manager().call_safe_place(tid); + wd_manager().remove_trash_handle(tid); }//end while //Empty these rest messages, there is not a window to process these messages. @@ -607,7 +606,7 @@ namespace detail case nana::detail::messages::map_thread_root_buffer: { auto stru = reinterpret_cast(lParam); - bedrock.wd_manager.map(reinterpret_cast(wParam), stru->forced, (stru->ignore_update_area ? nullptr : &stru->update_area)); + bedrock.wd_manager().map(reinterpret_cast(wParam), stru->forced, (stru->ignore_update_area ? nullptr : &stru->update_area)); ::UpdateWindow(wd); ::HeapFree(::GetProcessHeap(), 0, stru); } @@ -760,7 +759,7 @@ namespace detail template void emit_drawer(void (::nana::detail::drawer::*event_ptr)(const Arg&), basic_window* wd, const Arg& arg, bedrock::thread_context* thrd) { - if (bedrock::instance().wd_manager.available(wd) == false) + if (bedrock::instance().wd_manager().available(wd) == false) return; basic_window* prev_event_wd; @@ -788,7 +787,7 @@ namespace detail static restrict::TRACKMOUSEEVENT track = {sizeof track, 0x00000002}; auto native_window = reinterpret_cast(root_window); - auto* root_runtime = brock.wd_manager.root_runtime(native_window); + auto* root_runtime = brock.wd_manager().root_runtime(native_window); if(root_runtime) { @@ -884,7 +883,7 @@ namespace detail arg_focus arg; assign_arg(arg, focus, native_window, true); if (!brock.emit(event_code::focus, focus, arg, true, &context)) - brock.wd_manager.set_focus(msgwnd, true); + brock.wd_manager().set_focus(msgwnd, true); } def_window_proc = true; break; @@ -915,21 +914,21 @@ namespace detail break; case WM_LBUTTONDBLCLK: case WM_MBUTTONDBLCLK: case WM_RBUTTONDBLCLK: pressed_wd = nullptr; - msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); + msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); if(msgwnd && msgwnd->flags.enabled) { if (msgwnd->flags.take_active && !msgwnd->flags.ignore_mouse_focus) { - auto killed = brock.wd_manager.set_focus(msgwnd, false); + auto killed = brock.wd_manager().set_focus(msgwnd, false); if (killed != msgwnd) - brock.wd_manager.do_lazy_refresh(killed, false); + brock.wd_manager().do_lazy_refresh(killed, false); } arg_mouse arg; assign_arg(arg, msgwnd, message, pmdec); if (brock.emit(arg.evt_code, msgwnd, arg, true, &context)) { - if (brock.wd_manager.available(msgwnd)) + if (brock.wd_manager().available(msgwnd)) pressed_wd = msgwnd; } } @@ -939,7 +938,7 @@ namespace detail def_window_proc = true; break; case WM_LBUTTONDOWN: case WM_MBUTTONDOWN: case WM_RBUTTONDOWN: - msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); + msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); if(nullptr == msgwnd) break; //if event on the menubar, just remove the menu if it is not associating with the menubar @@ -957,9 +956,9 @@ namespace detail auto new_focus = (msgwnd->flags.take_active ? msgwnd : msgwnd->other.active_window); if (new_focus && (!new_focus->flags.ignore_mouse_focus)) { - auto kill_focus = brock.wd_manager.set_focus(new_focus, false); + auto kill_focus = brock.wd_manager().set_focus(new_focus, false); if (kill_focus != new_focus) - brock.wd_manager.do_lazy_refresh(kill_focus, false); + brock.wd_manager().do_lazy_refresh(kill_focus, false); } } @@ -976,14 +975,14 @@ namespace detail auto pos = native_interface::cursor_position(); auto rootwd = native_interface::find_window(pos.x, pos.y); native_interface::calc_window_point(rootwd, pos); - if(msgwnd != brock.wd_manager.find_window(rootwd, pos.x, pos.y)) + if(msgwnd != brock.wd_manager().find_window(rootwd, pos.x, pos.y)) { //call the drawer mouse up event for restoring the surface graphics msgwnd->flags.action = mouse_action::normal; arg.evt_code = event_code::mouse_up; emit_drawer(&drawer::mouse_up, msgwnd, arg, &context); - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); } } } @@ -995,7 +994,7 @@ namespace detail case WM_LBUTTONUP: case WM_MBUTTONUP: case WM_RBUTTONUP: - msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); + msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); if(nullptr == msgwnd) break; @@ -1022,7 +1021,7 @@ namespace detail } //Do mouse_up, this handle may be closed by click handler. - if(brock.wd_manager.available(msgwnd) && msgwnd->flags.enabled) + if(brock.wd_manager().available(msgwnd) && msgwnd->flags.enabled) { arg.evt_code = event_code::mouse_up; emit_drawer(&drawer::mouse_up, msgwnd, arg, &context); @@ -1035,7 +1034,7 @@ namespace detail retain->click.emit(arg); } - if (brock.wd_manager.available(msgwnd)) + if (brock.wd_manager().available(msgwnd)) { arg.evt_code = event_code::mouse_up; retain->mouse_up.emit(arg); @@ -1048,13 +1047,13 @@ namespace detail arg.by_mouse = true; retain->click.emit(arg); } - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); } pressed_wd = nullptr; break; case WM_MOUSEMOVE: - msgwnd = brock.wd_manager.find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); - if (brock.wd_manager.available(hovered_wd) && (msgwnd != hovered_wd)) + msgwnd = brock.wd_manager().find_window(native_window, pmdec.mouse.x, pmdec.mouse.y); + if (brock.wd_manager().available(hovered_wd) && (msgwnd != hovered_wd)) { brock.event_msleave(hovered_wd); hovered_wd->flags.action = mouse_action::normal; @@ -1062,7 +1061,7 @@ namespace detail //if msgwnd is neither captured window nor the child of captured window, //redirect the msgwnd to the captured window. - auto wd = brock.wd_manager.capture_redirect(msgwnd); + auto wd = brock.wd_manager().capture_redirect(msgwnd); if(wd) msgwnd = wd; } @@ -1070,7 +1069,7 @@ namespace detail else if(msgwnd) { bool prev_captured_inside; - if(brock.wd_manager.capture_window_entered(pmdec.mouse.x, pmdec.mouse.y, prev_captured_inside)) + if(brock.wd_manager().capture_window_entered(pmdec.mouse.x, pmdec.mouse.y, prev_captured_inside)) { event_code evt_code; if(prev_captured_inside) @@ -1115,7 +1114,7 @@ namespace detail track.hwndTrack = native_window; restrict::track_mouse_event(&track); } - if (!brock.wd_manager.available(hovered_wd)) + if (!brock.wd_manager().available(hovered_wd)) hovered_wd = nullptr; break; case WM_MOUSELEAVE: @@ -1131,7 +1130,7 @@ namespace detail if (pointer_wd == root_window) { ::ScreenToClient(pointer_wd, &scr_pos); - auto scrolled_wd = brock.wd_manager.find_window(reinterpret_cast(pointer_wd), scr_pos.x, scr_pos.y); + auto scrolled_wd = brock.wd_manager().find_window(reinterpret_cast(pointer_wd), scr_pos.x, scr_pos.y); def_window_proc = true; auto evt_wd = scrolled_wd; @@ -1141,7 +1140,7 @@ namespace detail { def_window_proc = false; nana::point mspos{ scr_pos.x, scr_pos.y }; - brock.wd_manager.calc_window_point(evt_wd, mspos); + brock.wd_manager().calc_window_point(evt_wd, mspos); arg_wheel arg; arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical); @@ -1155,13 +1154,13 @@ namespace detail if (scrolled_wd && (nullptr == evt_wd)) { nana::point mspos{ scr_pos.x, scr_pos.y }; - brock.wd_manager.calc_window_point(scrolled_wd, mspos); + brock.wd_manager().calc_window_point(scrolled_wd, mspos); arg_wheel arg; arg.which = (WM_MOUSEHWHEEL == message ? arg_wheel::wheel::horizontal : arg_wheel::wheel::vertical); assign_arg(arg, scrolled_wd, pmdec); brock.emit_drawer(event_code::mouse_wheel, scrolled_wd, arg, &context); - brock.wd_manager.do_lazy_refresh(scrolled_wd, false); + brock.wd_manager().do_lazy_refresh(scrolled_wd, false); } } else @@ -1179,7 +1178,7 @@ namespace detail POINT pos; ::DragQueryPoint(drop, &pos); - msgwnd = brock.wd_manager.find_window(native_window, pos.x, pos.y); + msgwnd = brock.wd_manager().find_window(native_window, pos.x, pos.y); if(msgwnd) { arg_dropfiles dropfiles; @@ -1209,11 +1208,11 @@ namespace detail dropfiles.pos.x = pos.x; dropfiles.pos.y = pos.y; - brock.wd_manager.calc_window_point(msgwnd, dropfiles.pos); + brock.wd_manager().calc_window_point(msgwnd, dropfiles.pos); dropfiles.window_handle = reinterpret_cast(msgwnd); msgwnd->together.events_ptr->mouse_dropfiles.emit(dropfiles); - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); } } @@ -1301,7 +1300,7 @@ namespace detail break; case WM_SIZE: if(wParam != SIZE_MINIMIZED) - brock.wd_manager.size(msgwnd, size(pmdec.size.width, pmdec.size.height), true, true); + brock.wd_manager().size(msgwnd, size(pmdec.size.width, pmdec.size.height), true, true); break; case WM_MOVE: brock.event_move(msgwnd, (int)(short) LOWORD(lParam), (int)(short) HIWORD(lParam)); @@ -1327,7 +1326,7 @@ namespace detail case WM_SYSCHAR: def_window_proc = true; brock.set_keyboard_shortkey(true); - msgwnd = brock.wd_manager.find_shortkey(native_window, static_cast(wParam)); + msgwnd = brock.wd_manager().find_shortkey(native_window, static_cast(wParam)); if(msgwnd) { arg_keyboard arg; @@ -1374,7 +1373,7 @@ namespace detail bool set_focus = (brock.focus() != msgwnd) && (!msgwnd->root_widget->flags.ignore_menubar_focus); if (set_focus) - brock.wd_manager.set_focus(msgwnd, false); + brock.wd_manager().set_focus(msgwnd, false); arg_keyboard arg; arg.evt_code = event_code::key_release; @@ -1408,12 +1407,12 @@ namespace detail { bool is_forward = (::GetKeyState(VK_SHIFT) >= 0); - auto tstop_wd = brock.wd_manager.tabstop(msgwnd, is_forward); + auto tstop_wd = brock.wd_manager().tabstop(msgwnd, is_forward); if (tstop_wd) { - brock.wd_manager.set_focus(tstop_wd, false); - brock.wd_manager.do_lazy_refresh(msgwnd, false); - brock.wd_manager.do_lazy_refresh(tstop_wd, true); + brock.wd_manager().set_focus(tstop_wd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(tstop_wd, true); } } else @@ -1455,10 +1454,10 @@ namespace detail arg.ignore = false; msgwnd->together.events_ptr->key_char.emit(arg); - if ((false == arg.ignore) && brock.wd_manager.available(msgwnd)) + if ((false == arg.ignore) && brock.wd_manager().available(msgwnd)) brock.emit_drawer(event_code::key_char, msgwnd, arg, &context); - brock.wd_manager.do_lazy_refresh(msgwnd, false); + brock.wd_manager().do_lazy_refresh(msgwnd, false); } } return 0; @@ -1506,12 +1505,12 @@ namespace detail brock.erase_menu(false); brock.delay_restore(3); //Restores if delay_restore not decleared } - brock.wd_manager.destroy(msgwnd); + brock.wd_manager().destroy(msgwnd); nana::detail::platform_spec::instance().release_window_icon(msgwnd->root); break; case WM_NCDESTROY: - brock.rt_manager.remove_if_exists(msgwnd); - brock.wd_manager.destroy_handle(msgwnd); + brock.manage_form_loader(msgwnd, false); + brock.wd_manager().destroy_handle(msgwnd); if(--context.window_count <= 0) { @@ -1523,7 +1522,7 @@ namespace detail def_window_proc = true; } - root_runtime = brock.wd_manager.root_runtime(native_window); + root_runtime = brock.wd_manager().root_runtime(native_window); if(root_runtime) { root_runtime->condition.pressed = pressed_wd; @@ -1540,21 +1539,15 @@ namespace detail ::nana::category::flags bedrock::category(core_window_t* wd) { internal_scope_guard lock; - return (wd_manager.available(wd) ? wd->other.category : ::nana::category::flags::super); + return (wd_manager().available(wd) ? wd->other.category : ::nana::category::flags::super); } auto bedrock::focus() ->core_window_t* { - core_window_t* wd = wd_manager.root(native_interface::get_focus_window()); + core_window_t* wd = wd_manager().root(native_interface::get_focus_window()); return (wd ? wd->other.attribute.root->focus : nullptr); } - native_window_type bedrock::root(core_window_t* wd) - { - internal_scope_guard lock; - return (wd_manager.available(wd) ? wd->root : nullptr); - } - void bedrock::set_menubar_taken(core_window_t* wd) { auto pre = impl_->menu.taken_window; @@ -1565,8 +1558,8 @@ namespace detail if ((!wd) && pre && (pre->root != get_menu())) { internal_scope_guard lock; - wd_manager.set_focus(pre, false); - wd_manager.update(pre, true, false); + wd_manager().set_focus(pre, false); + wd_manager().update(pre, true, false); } } @@ -1694,17 +1687,9 @@ namespace detail #endif } - bool bedrock::emit(event_code evt_code, core_window_t* wd, const arg_mouse& arg, bool ask_update, thread_context* thrd) - { - if (evt_code != arg.evt_code) - throw std::runtime_error("Nana.bedrock: invalid event arg."); - - return emit(evt_code, wd, static_cast(arg), ask_update, thrd); - } - bool bedrock::emit(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, bool ask_update, thread_context* thrd) { - if (wd_manager.available(wd) == false) + if (wd_manager().available(wd) == false) return false; basic_window* prev_event_wd; @@ -1721,8 +1706,8 @@ namespace detail _m_emit_core(evt_code, wd, false, arg); if (ask_update) - wd_manager.do_lazy_refresh(wd, false); - else if (wd_manager.available(wd)) + wd_manager().do_lazy_refresh(wd, false); + else if (wd_manager().available(wd)) wd->other.upd_state = basic_window::update_state::none; if (thrd) thrd->event_window = prev_event_wd; @@ -1731,7 +1716,7 @@ namespace detail bool bedrock::emit_drawer(event_code evt_code, core_window_t* wd, const ::nana::event_arg& arg, thread_context* thrd) { - if (bedrock_object.wd_manager.available(wd) == false) + if (bedrock_object.wd_manager().available(wd) == false) return false; core_window_t* prev_event_wd; @@ -1856,7 +1841,7 @@ namespace detail thrd = get_thread_context(wd->thread_id); HCURSOR rev_handle = ::LoadCursor(nullptr, IDC_ARROW); - if (!wd_manager.available(wd)) + if (!wd_manager().available(wd)) { ::ShowCursor(FALSE); ::SetCursor(rev_handle); @@ -1877,7 +1862,7 @@ namespace detail } native_interface::calc_window_point(native_handle, pos); - auto rev_wd = wd_manager.find_window(native_handle, pos.x, pos.y); + auto rev_wd = wd_manager().find_window(native_handle, pos.x, pos.y); if (rev_wd) { set_cursor(rev_wd, rev_wd->predef_cursor, thrd); diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index e272801b..3cb72140 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -8,12 +8,12 @@ * http://www.boost.org/LICENSE_1_0.txt) * * @file: nana/gui/detail/window_manager.cpp - * @author: Jinhao * @contributors: Katsuhisa Yuasa */ #include #include +#include #include #include #include @@ -33,7 +33,7 @@ namespace detail { void operator()(basic_window* wd) const { - bedrock::instance().evt_operation.umake(reinterpret_cast(wd)); + bedrock::instance().evt_operation().umake(reinterpret_cast(wd)); delete wd; } }; @@ -788,12 +788,6 @@ namespace detail false); } - ::nana::widget* window_manager::get_widget(core_window_t* wd) const - { - std::lock_guard lock(mutex_); - return (impl_->wd_register.available(wd) ? wd->widget_notifier->widget_ptr() : nullptr); - } - std::vector window_manager::get_children(core_window_t* wd) const { std::lock_guard lock(mutex_); diff --git a/source/gui/drawing.cpp b/source/gui/drawing.cpp index 1a13d18a..50626c76 100644 --- a/source/gui/drawing.cpp +++ b/source/gui/drawing.cpp @@ -22,7 +22,7 @@ namespace nana { namespace { - using core_window_t = detail::bedrock::core_window_t; + using core_window_t = detail::basic_window; inline detail::drawer& get_drawer(window wd) { diff --git a/source/gui/notifier.cpp b/source/gui/notifier.cpp index aec5686f..742a78b9 100644 --- a/source/gui/notifier.cpp +++ b/source/gui/notifier.cpp @@ -241,11 +241,15 @@ namespace nana } #endif - typedef ::nana::detail::bedrock bedrock; //class notifier notifier::notifier(window wd) : impl_(new implement) { + impl_->handle = wd; + impl_->native_handle = API::root(wd); + if (!impl_->native_handle) + throw std::invalid_argument("Invalid window handle"); + impl_->ani_timer.elapse([this] { #if defined(NANA_WINDOWS) @@ -257,9 +261,6 @@ namespace nana #endif }); - auto & brock = bedrock::instance(); - impl_->handle = wd; - impl_->native_handle = brock.root(reinterpret_cast(wd)); impl_->evt_destroy = API::events(wd).destroy([this] { close(); diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 9ef4986b..5c7b6231 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1074,7 +1074,6 @@ namespace nana } block_px = lowest; - if (blocks > min_count) rest_px -= (lowest-level_px) * (blocks - min_count); @@ -1141,7 +1140,6 @@ namespace nana void collocate(window wd) override { - if (!field || !(visible && display)) return; @@ -1797,14 +1795,16 @@ namespace nana if (arg.button != ::nana::mouse::left_button) return; + bool is_vert = _m_is_vert(dir_); + API::capture_window(this->handle(), true); auto basepos = API::cursor_position(); - base_pos_.x = (_m_is_vert(dir_) ? basepos.y : basepos.x); + base_pos_.x = (is_vert ? basepos.y : basepos.x); basepos = this->pos(); - base_pos_.y = (_m_is_vert(dir_) ? basepos.y : basepos.x); + base_pos_.y = (is_vert ? basepos.y : basepos.x); - base_px_ = (_m_is_vert(dir_) ? pane_dv_->field_area.height : pane_dv_->field_area.width); + base_px_ = (is_vert ? pane_dv_->field_area.height : pane_dv_->field_area.width); }); this->events().mouse_up([this] @@ -1855,6 +1855,8 @@ namespace nana else px -= static_cast(delta); break; + default: + break; } auto dock_px = (_m_is_vert(dir_) ? dock_dv_->field_area.height : dock_dv_->field_area.width); @@ -1880,21 +1882,17 @@ namespace nana }; public: - div_dock(std::string && name, implement* impl) : division(kind::dock, std::move(name)), impl_(impl) {} division* front() const { - auto i = children.cbegin(); - for (auto i = children.cbegin(); i != children.cend(); ++i) { if (i->get()->display) return i->get(); } - return nullptr; } @@ -1912,8 +1910,6 @@ namespace nana if (!child->display) continue; - auto child_dv = dynamic_cast(child.get()); - const auto is_vert = _m_is_vert(child->dir); if (is_first) { @@ -1930,16 +1926,13 @@ namespace nana prev_attr = is_vert; } if (0 == vert_count) - ++vert_count; + vert_count = 1; if (0 == horz_count) - ++horz_count; + horz_count = 1; //room indicates the size without splitters ::nana::size room(area.width - splitter_px * (horz_count - 1), area.height - splitter_px * (vert_count - 1)); - //double auto_horz_w = double(area.width - splitter_px * (horz_count - 1))/ horz_count; - //double auto_vert_w = double(area.height - splitter_px * (vert_count - 1)) / vert_count; - double left = area.x; double right = area.right(); double top = area.y; @@ -2049,7 +2042,6 @@ namespace nana if (split_range_begin > -0.5) split->range(static_cast(split_range_begin), static_cast(split_range_end)); - if (is_vert) { room.height -= child_r.height; diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 5d4901b7..f8fb62a4 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -12,10 +12,13 @@ */ #include +#include #include +#include #include #include #include +#include namespace nana { @@ -25,11 +28,12 @@ namespace nana { namespace { - typedef detail::bedrock::core_window_t core_window_t; - typedef detail::bedrock::interface_type interface_type; - auto& bedrock = detail::bedrock::instance(); - detail::bedrock::window_manager_t& window_manager = bedrock.wd_manager; + + inline detail::window_manager& wd_manager() + { + return bedrock.wd_manager(); + } } } @@ -46,29 +50,61 @@ namespace nana } namespace API { + using basic_window = ::nana::detail::basic_window; + using interface_type = ::nana::detail::native_interface; + namespace detail { + ::nana::widget_colors* make_scheme(::nana::detail::scheme_factory_base&& factory) + { + return restrict::bedrock.make_scheme(static_cast<::nana::detail::scheme_factory_base&&>(factory)); + } + + bool emit_event(event_code evt_code, window wd, const ::nana::event_arg& arg) + { + return restrict::bedrock.emit(evt_code, reinterpret_cast<::nana::detail::basic_window*>(wd), arg, true, restrict::bedrock.get_thread_context()); + } + + void enum_widgets_function_base::enum_widgets(window wd, bool recursive) + { + using basic_window = ::nana::detail::basic_window; + + internal_scope_guard lock; + + auto children = restrict::wd_manager().get_children(reinterpret_cast(wd)); + for (auto child : children) + { + auto widget_ptr = API::get_widget(reinterpret_cast(child)); + if (widget_ptr) + { + _m_enum_fn(widget_ptr); + if (recursive) + enum_widgets(reinterpret_cast(child), recursive); + } + } + } + general_events* get_general_events(window wd) { - if (!restrict::window_manager.available(reinterpret_cast(wd))) + if (!restrict::wd_manager().available(reinterpret_cast(wd))) return nullptr; - return reinterpret_cast(wd)->together.events_ptr.get(); + return reinterpret_cast(wd)->together.events_ptr.get(); } }//end namespace detail void effects_edge_nimbus(window wd, effects::edge_nimbus en) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { auto & cont = iwd->root_widget->other.attribute.root->effects_edge_nimbus; if(effects::edge_nimbus::none != en) { if (iwd->effect.edge_nimbus == effects::edge_nimbus::none) { - restrict::core_window_t::edge_nimbus_action ena = { iwd }; + basic_window::edge_nimbus_action ena = { iwd }; cont.push_back(ena); } iwd->effect.edge_nimbus = static_cast(static_cast(en) | static_cast(iwd->effect.edge_nimbus)); @@ -91,18 +127,18 @@ namespace API effects::edge_nimbus effects_edge_nimbus(window wd) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; - return (restrict::window_manager.available(iwd) ? iwd->effect.edge_nimbus : effects::edge_nimbus::none); + return (restrict::wd_manager().available(iwd) ? iwd->effect.edge_nimbus : effects::edge_nimbus::none); } void effects_bground(window wd, const effects::bground_factory_interface& factory, double fade_rate) { if (fade_rate < 0.0 || fade_rate > 1.0) throw std::invalid_argument("effects_bground: value range of fade_rate must be [0, 1]."); - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { auto new_effect_ptr = effects::effects_accessor::create(factory); if(nullptr == new_effect_ptr) @@ -111,7 +147,7 @@ namespace API delete iwd->effect.bground; iwd->effect.bground = new_effect_ptr; iwd->effect.bground_fade_rate = fade_rate; - restrict::window_manager.enable_effects_bground(iwd, true); + restrict::wd_manager().enable_effects_bground(iwd, true); if (fade_rate < 0.01) iwd->flags.make_bground_declared = true; @@ -122,9 +158,9 @@ namespace API bground_mode effects_bground_mode(window wd) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd) && iwd->effect.bground) + if(restrict::wd_manager().available(iwd) && iwd->effect.bground) return (iwd->effect.bground_fade_rate <= 0.009 ? bground_mode::basic : bground_mode::blend); return bground_mode::none; @@ -132,11 +168,11 @@ namespace API void effects_bground_remove(window wd) { - const auto iwd = reinterpret_cast(wd); + const auto iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { - if(restrict::window_manager.enable_effects_bground(iwd, false)) + if(restrict::wd_manager().enable_effects_bground(iwd, false)) API::refresh_window(wd); } } @@ -146,11 +182,11 @@ namespace API bool set_events(window wd, const std::shared_ptr& gep) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd) && iwd->set_events(gep)) + if (restrict::wd_manager().available(iwd) && iwd->set_events(gep)) { - restrict::bedrock.evt_operation.make(wd, gep); + restrict::bedrock.evt_operation().make(wd, gep); return true; } return false; @@ -158,24 +194,24 @@ namespace API void set_scheme(window wd, widget_colors* wdg_colors) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) iwd->scheme = wdg_colors; } widget_colors* get_scheme(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - return (restrict::window_manager.available(iwd) ? iwd->scheme : nullptr); + return (restrict::wd_manager().available(iwd) ? iwd->scheme : nullptr); } void attach_drawer(widget& wd, drawer_trigger& dr) { - const auto iwd = reinterpret_cast(wd.handle()); + const auto iwd = reinterpret_cast(wd.handle()); internal_scope_guard isg; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { iwd->drawer.graphics.make(iwd->dimension); iwd->drawer.graphics.rectangle(true, iwd->scheme->background.get_color()); @@ -186,13 +222,13 @@ namespace API nana::string window_caption(window wd) throw() { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { - if(iwd->other.category == category::flags::root) - return restrict::interface_type::window_caption(iwd->root); + if (category::flags::root == iwd->other.category) + return interface_type::window_caption(iwd->root); return iwd->title; } return {}; @@ -200,43 +236,43 @@ namespace API void window_caption(window wd, nana::string title) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { iwd->title.swap(title); if (iwd->other.category == category::flags::root) - restrict::interface_type::window_caption(iwd->root, iwd->title); + interface_type::window_caption(iwd->root, iwd->title); - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } } window create_window(window owner, bool nested, const rectangle& r, const appearance& ap, widget* wdg) { - return reinterpret_cast(restrict::window_manager.create_root(reinterpret_cast(owner), nested, r, ap, wdg)); + return reinterpret_cast(restrict::wd_manager().create_root(reinterpret_cast(owner), nested, r, ap, wdg)); } window create_widget(window parent, const rectangle& r, widget* wdg) { - return reinterpret_cast(restrict::window_manager.create_widget(reinterpret_cast(parent), r, false, wdg)); + return reinterpret_cast(restrict::wd_manager().create_widget(reinterpret_cast(parent), r, false, wdg)); } window create_lite_widget(window parent, const rectangle& r, widget* wdg) { - return reinterpret_cast(restrict::window_manager.create_widget(reinterpret_cast(parent), r, true, wdg)); + return reinterpret_cast(restrict::wd_manager().create_widget(reinterpret_cast(parent), r, true, wdg)); } window create_frame(window parent, const rectangle& r, widget* wdg) { - return reinterpret_cast(restrict::window_manager.create_frame(reinterpret_cast(parent), r, wdg)); + return reinterpret_cast(restrict::wd_manager().create_frame(reinterpret_cast(parent), r, wdg)); } paint::graphics* window_graphics(window wd) { internal_scope_guard isg; - if(restrict::window_manager.available(reinterpret_cast(wd))) - return &reinterpret_cast(wd)->drawer.graphics; + if(restrict::wd_manager().available(reinterpret_cast(wd))) + return &reinterpret_cast(wd)->drawer.graphics; return nullptr; } @@ -246,14 +282,23 @@ namespace API } }//end namespace dev + + widget* get_widget(window wd) + { + internal_scope_guard lock; + if (restrict::wd_manager().available(reinterpret_cast(wd))) + return reinterpret_cast(wd)->widget_notifier->widget_ptr(); + + return nullptr; + } //exit //close all windows in current thread void exit() { - std::vector v; + std::vector v; internal_scope_guard lock; - restrict::window_manager.all_handles(v); + restrict::wd_manager().all_handles(v); if(v.size()) { std::vector roots; @@ -280,7 +325,7 @@ namespace API } for(auto i : roots) - restrict::interface_type::close_window(i); + interface_type::close_window(i); } } @@ -319,32 +364,30 @@ namespace API bool register_shortkey(window wd, unsigned long key) { - return restrict::window_manager.register_shortkey(reinterpret_cast(wd), key); + return restrict::wd_manager().register_shortkey(reinterpret_cast(wd), key); } void unregister_shortkey(window wd) { - restrict::window_manager.unregister_shortkey(reinterpret_cast(wd), false); + restrict::wd_manager().unregister_shortkey(reinterpret_cast(wd), false); } - nana::point cursor_position() + ::nana::point cursor_position() { - return restrict::interface_type::cursor_position(); + return interface_type::cursor_position(); } - nana::rectangle make_center(unsigned width, unsigned height) + ::nana::rectangle make_center(unsigned width, unsigned height) { - nana::size screen = restrict::interface_type::primary_monitor_size(); - nana::rectangle result( - width > screen.width? 0: (screen.width - width)>>1, - height > screen.height? 0: (screen.height - height)>> 1, + auto screen = interface_type::primary_monitor_size(); + return{ + static_cast(width > screen.width ? 0 : (screen.width - width) >> 1), + static_cast(height > screen.height ? 0 : (screen.height - height) >> 1), width, height - ); - - return result; + }; } - nana::rectangle make_center(window wd, unsigned width, unsigned height) + ::nana::rectangle make_center(window wd, unsigned width, unsigned height) { nana::rectangle r = make_center(width, height); @@ -356,29 +399,29 @@ namespace API void window_icon_default(const paint::image& small_icon, const paint::image& big_icon) { - restrict::window_manager.default_icon(small_icon, big_icon); + restrict::wd_manager().default_icon(small_icon, big_icon); } void window_icon(window wd, const paint::image& small_icon, const paint::image& big_icon) { - restrict::window_manager.icon(reinterpret_cast(wd), small_icon, big_icon); + restrict::wd_manager().icon(reinterpret_cast(wd), small_icon, big_icon); } bool empty_window(window wd) { - return (restrict::window_manager.available(reinterpret_cast(wd)) == false); + return (restrict::wd_manager().available(reinterpret_cast(wd)) == false); } bool is_window(window wd) { - return restrict::window_manager.available(reinterpret_cast(wd)); + return restrict::wd_manager().available(reinterpret_cast(wd)); } bool is_destroying(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (!restrict::window_manager.available(iwd)) + if (!restrict::wd_manager().available(iwd)) return false; return iwd->flags.destroying; @@ -387,59 +430,60 @@ namespace API void enable_dropfiles(window wd, bool enb) { internal_scope_guard lock; - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); auto native_handle = API::root(wd); if (native_handle) { iwd->flags.dropable = enb; - restrict::interface_type::enable_dropfiles(native_handle, enb); + interface_type::enable_dropfiles(native_handle, enb); } } native_window_type root(window wd) { - return restrict::bedrock.root(reinterpret_cast(wd)); + internal_scope_guard lock; + return reinterpret_cast(wd)->root; } window root(native_window_type wd) { - return reinterpret_cast(restrict::window_manager.root(wd)); + return reinterpret_cast(restrict::wd_manager().root(wd)); } void enable_double_click(window wd, bool dbl) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) iwd->flags.dbl_click = dbl; } void fullscreen(window wd, bool v) { internal_scope_guard lock; - if(restrict::window_manager.available(reinterpret_cast(wd))) - reinterpret_cast(wd)->flags.fullscreen = v; + if(restrict::wd_manager().available(reinterpret_cast(wd))) + reinterpret_cast(wd)->flags.fullscreen = v; } bool insert_frame(window frame, native_window_type native_window) { - return restrict::window_manager.insert_frame(reinterpret_cast(frame), native_window); + return restrict::wd_manager().insert_frame(reinterpret_cast(frame), native_window); } native_window_type frame_container(window frame) { - auto frm = reinterpret_cast(frame); + auto frm = reinterpret_cast(frame); internal_scope_guard lock; - if (restrict::window_manager.available(frm) && (frm->other.category == category::flags::frame)) + if (restrict::wd_manager().available(frm) && (frm->other.category == category::flags::frame)) return frm->other.attribute.frame->container; return nullptr; } native_window_type frame_element(window frame, unsigned index) { - auto frm = reinterpret_cast(frame); + auto frm = reinterpret_cast(frame); internal_scope_guard lock; - if (restrict::window_manager.available(frm) && (frm->other.category == category::flags::frame)) + if (restrict::wd_manager().available(frm) && (frm->other.category == category::flags::frame)) { if (index < frm->other.attribute.frame->attach.size()) return frm->other.attribute.frame->attach.at(index); @@ -449,22 +493,22 @@ namespace API void close_window(window wd) { - restrict::window_manager.close(reinterpret_cast(wd)); + restrict::wd_manager().close(reinterpret_cast(wd)); } void show_window(window wd, bool show) { - restrict::window_manager.show(reinterpret_cast(wd), show); + restrict::wd_manager().show(reinterpret_cast(wd), show); } bool visible(window wd) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { if(iwd->other.category == category::flags::root) - return restrict::interface_type::is_window_visible(iwd->root); + return interface_type::is_window_visible(iwd->root); return iwd->visible; } return false; @@ -472,31 +516,31 @@ namespace API void restore_window(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { if(iwd->other.category == category::flags::root) - restrict::interface_type::restore_window(iwd->root); + interface_type::restore_window(iwd->root); } } void zoom_window(window wd, bool ask_for_max) { - auto core_wd = reinterpret_cast(wd); + auto core_wd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(core_wd)) + if(restrict::wd_manager().available(core_wd)) { if(category::flags::root == core_wd->other.category) - restrict::interface_type::zoom_window(core_wd->root, ask_for_max); + interface_type::zoom_window(core_wd->root, ask_for_max); } } window get_parent_window(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) return reinterpret_cast(iwd->other.category == category::flags::root ? iwd->owner : iwd->parent); return nullptr; @@ -504,13 +548,13 @@ namespace API window get_owner_window(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && (iwd->other.category == category::flags::root)) + if(restrict::wd_manager().available(iwd) && (iwd->other.category == category::flags::root)) { - native_window_type owner = restrict::interface_type::get_owner_window(iwd->root); + auto owner = interface_type::get_owner_window(iwd->root); if(owner) - return reinterpret_cast(restrict::window_manager.root(owner)); + return reinterpret_cast(restrict::wd_manager().root(owner)); } return nullptr; @@ -518,77 +562,77 @@ namespace API bool set_parent_window(window wd, window new_parent) { - return restrict::bedrock.wd_manager.set_parent(reinterpret_cast(wd), reinterpret_cast(new_parent)); + return restrict::wd_manager().set_parent(reinterpret_cast(wd), reinterpret_cast(new_parent)); } void umake_event(event_handle eh) { - restrict::bedrock.evt_operation.erase(eh); + restrict::bedrock.evt_operation().erase(eh); } nana::point window_position(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { return ( (iwd->other.category == category::flags::root) ? - restrict::interface_type::window_position(iwd->root) : iwd->pos_owner); + interface_type::window_position(iwd->root) : iwd->pos_owner); } return nana::point{}; } void move_window(window wd, const point& pos) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.move(iwd, pos.x, pos.y, false)) + if(restrict::wd_manager().move(iwd, pos.x, pos.y, false)) { - restrict::core_window_t* update_wd = nullptr; + basic_window* update_wd = nullptr; if (iwd->displayed() && iwd->effect.bground) { update_wd = iwd; - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } - restrict::core_window_t* anc = iwd; + basic_window* anc = iwd; if (category::flags::root != iwd->other.category) anc = iwd->seek_non_lite_widget_ancestor(); if (anc != update_wd) - restrict::window_manager.update(anc, false, false); + restrict::wd_manager().update(anc, false, false); } } void move_window(window wd, const rectangle& r) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.move(iwd, r)) + if(restrict::wd_manager().move(iwd, r)) { if (category::flags::root != iwd->other.category) iwd = iwd->seek_non_lite_widget_ancestor(); - restrict::window_manager.update(iwd, false, false); + restrict::wd_manager().update(iwd, false, false); } } void bring_top(window wd, bool activated) { - restrict::interface_type::bring_top(root(wd), activated); + interface_type::bring_top(root(wd), activated); } bool set_window_z_order(window wd, window wd_after, z_order_action action_if_no_wd_after) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); native_window_type native_after = nullptr; internal_scope_guard lock; - if (restrict::window_manager.available(iwd) && (category::flags::root == iwd->other.category)) + if (restrict::wd_manager().available(iwd) && (category::flags::root == iwd->other.category)) { if(wd_after) { - auto iwd_after = reinterpret_cast(wd_after); - if (restrict::window_manager.available(iwd_after) && (iwd_after->other.category == category::flags::root)) + auto iwd_after = reinterpret_cast(wd_after); + if (restrict::wd_manager().available(iwd_after) && (iwd_after->other.category == category::flags::root)) { native_after = iwd_after->root; action_if_no_wd_after = z_order_action::none; @@ -596,7 +640,7 @@ namespace API else return false; } - restrict::interface_type::set_window_z_order(iwd->root, native_after, action_if_no_wd_after); + interface_type::set_window_z_order(iwd->root, native_after, action_if_no_wd_after); return true; } return false; @@ -604,9 +648,9 @@ namespace API void draw_through(window wd, std::function draw_fn) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (!restrict::bedrock.wd_manager.available(iwd)) + if (!restrict::wd_manager().available(iwd)) throw std::invalid_argument("draw_through: invalid window parameter"); if (::nana::category::flags::root != iwd->other.category) @@ -619,7 +663,7 @@ namespace API { auto iwd = reinterpret_cast<::nana::detail::basic_window*>(wd); internal_scope_guard lock; - if (restrict::bedrock.wd_manager.available(iwd) && iwd->is_draw_through() ) + if (restrict::wd_manager().available(iwd) && iwd->is_draw_through() ) restrict::bedrock.map_through_widgets(iwd, drawable); } @@ -632,22 +676,22 @@ namespace API void window_size(window wd, const size& sz) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.size(iwd, sz, false, false)) + if(restrict::wd_manager().size(iwd, sz, false, false)) { if (category::flags::root != iwd->other.category) iwd = iwd->seek_non_lite_widget_ancestor(); - restrict::window_manager.update(iwd, false, false); + restrict::wd_manager().update(iwd, false, false); } } ::nana::size window_outline_size(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (!restrict::window_manager.available(iwd)) + if (!restrict::wd_manager().available(iwd)) return{}; auto sz = window_size(wd); @@ -658,9 +702,9 @@ namespace API void window_outline_size(window wd, const size& sz) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { if (category::flags::root == iwd->other.category) { @@ -684,9 +728,9 @@ namespace API bool get_window_rectangle(window wd, rectangle& r) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { r = rectangle(iwd->pos_owner, iwd->dimension); return true; @@ -696,9 +740,9 @@ namespace API bool track_window_size(window wd, const nana::size& sz, bool true_for_max) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) == false) + if(restrict::wd_manager().available(iwd) == false) return false; nana::size & ts = (true_for_max ? iwd->max_track_size : iwd->min_track_size); @@ -717,7 +761,7 @@ namespace API return false; } - ts = restrict::interface_type::check_track_size(sz, iwd->extra_width, iwd->extra_height, true_for_max); + ts = interface_type::check_track_size(sz, iwd->extra_width, iwd->extra_height, true_for_max); } else ts.width = ts.height = 0; @@ -726,22 +770,22 @@ namespace API void window_enabled(window wd, bool enabled) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && (iwd->flags.enabled != enabled)) + if(restrict::wd_manager().available(iwd) && (iwd->flags.enabled != enabled)) { iwd->flags.enabled = enabled; - restrict::window_manager.update(iwd, true, true); + restrict::wd_manager().update(iwd, true, true); if(category::flags::root == iwd->other.category) - restrict::interface_type::enable_window(iwd->root, enabled); + interface_type::enable_window(iwd->root, enabled); } } bool window_enabled(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - return (restrict::window_manager.available(iwd) ? iwd->flags.enabled : false); + return (restrict::wd_manager().available(iwd) ? iwd->flags.enabled : false); } //lazy_refresh: @@ -755,19 +799,19 @@ namespace API //@brief: Refresh the window and display it immediately. void refresh_window(window wd) { - restrict::window_manager.update(reinterpret_cast(wd), true, false); + restrict::wd_manager().update(reinterpret_cast(wd), true, false); } void refresh_window_tree(window wd) { - restrict::window_manager.refresh_tree(reinterpret_cast(wd)); + restrict::wd_manager().refresh_tree(reinterpret_cast(wd)); } //update_window //@brief: it displays a window immediately without refreshing. void update_window(window wd) { - restrict::window_manager.update(reinterpret_cast(wd), false, true); + restrict::wd_manager().update(reinterpret_cast(wd), false, true); } @@ -778,17 +822,17 @@ namespace API void window_caption(window wd, const nana::string& title) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) iwd->widget_notifier->caption(title); } nana::string window_caption(window wd) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) return iwd->widget_notifier->caption(); return{}; @@ -796,9 +840,9 @@ namespace API void window_cursor(window wd, cursor cur) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { iwd->predef_cursor = cur; restrict::bedrock.update_cursor(iwd); @@ -807,9 +851,9 @@ namespace API cursor window_cursor(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) return iwd->predef_cursor; return cursor::arrow; @@ -817,9 +861,9 @@ namespace API bool is_focus_ready(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) return (iwd->root_widget->other.attribute.root->focus == iwd); return false; @@ -827,12 +871,12 @@ namespace API void activate_window(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { if(iwd->flags.take_active) - restrict::interface_type::activate_window(iwd->root); + interface_type::activate_window(iwd->root); } } @@ -844,43 +888,43 @@ namespace API void focus_window(window wd) { - restrict::window_manager.set_focus(reinterpret_cast(wd), false); - restrict::window_manager.update(reinterpret_cast(wd), false, false); + restrict::wd_manager().set_focus(reinterpret_cast(wd), false); + restrict::wd_manager().update(reinterpret_cast(wd), false, false); } window capture_window() { - return reinterpret_cast(restrict::window_manager.capture_window()); + return reinterpret_cast(restrict::wd_manager().capture_window()); } window capture_window(window wd, bool value) { return reinterpret_cast( - restrict::window_manager.capture_window(reinterpret_cast(wd), value) + restrict::wd_manager().capture_window(reinterpret_cast(wd), value) ); } void capture_ignore_children(bool ignore) { - restrict::window_manager.capture_ignore_children(ignore); + restrict::wd_manager().capture_ignore_children(ignore); } void modal_window(window wd) { { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard isg; - if (!restrict::window_manager.available(iwd)) + if (!restrict::wd_manager().available(iwd)) return; if ((iwd->other.category == category::flags::root) && (iwd->flags.modal == false)) { iwd->flags.modal = true; #if defined(NANA_X11) - restrict::interface_type::set_modal(iwd->root); + interface_type::set_modal(iwd->root); #endif - restrict::window_manager.show(iwd, true); + restrict::wd_manager().show(iwd, true); } else return; @@ -900,22 +944,22 @@ namespace API color fgcolor(window wd) { internal_scope_guard lock; - if (restrict::window_manager.available(reinterpret_cast(wd))) - return reinterpret_cast(wd)->scheme->foreground.get_color(); + if (restrict::wd_manager().available(reinterpret_cast(wd))) + return reinterpret_cast(wd)->scheme->foreground.get_color(); return{}; } color fgcolor(window wd, const color& clr) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { auto prev = iwd->scheme->foreground.get_color(); if (prev != clr) { iwd->scheme->foreground = clr; - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } return prev; } @@ -925,16 +969,16 @@ namespace API color bgcolor(window wd) { internal_scope_guard lock; - if (restrict::window_manager.available(reinterpret_cast(wd))) - return reinterpret_cast(wd)->scheme->background.get_color(); + if (restrict::wd_manager().available(reinterpret_cast(wd))) + return reinterpret_cast(wd)->scheme->background.get_color(); return{}; } color bgcolor(window wd, const color& clr) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { auto prev = iwd->scheme->background.get_color(); if (prev != clr) @@ -945,7 +989,7 @@ namespace API if (iwd->effect.bground && iwd->effect.bground_fade_rate < 0.01) // fade rate < 0.01 means it is basic mode iwd->flags.make_bground_declared = true; - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } return prev; } @@ -955,22 +999,22 @@ namespace API color activated_color(window wd) { internal_scope_guard lock; - if (restrict::window_manager.available(reinterpret_cast(wd))) - return reinterpret_cast(wd)->scheme->activated.get_color(); + if (restrict::wd_manager().available(reinterpret_cast(wd))) + return reinterpret_cast(wd)->scheme->activated.get_color(); return{}; } color activated_color(window wd, const color& clr) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { auto prev = iwd->scheme->activated.get_color(); if (prev != clr) { iwd->scheme->activated = clr; - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } return prev; } @@ -980,17 +1024,17 @@ namespace API void create_caret(window wd, unsigned width, unsigned height) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && (nullptr == iwd->together.caret)) + if(restrict::wd_manager().available(iwd) && (nullptr == iwd->together.caret)) iwd->together.caret = new ::nana::detail::caret_descriptor(iwd, width, height); } void destroy_caret(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { auto p = iwd->together.caret; iwd->together.caret = nullptr; @@ -1000,17 +1044,17 @@ namespace API void caret_pos(window wd, const point& pos) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) iwd->together.caret->position(pos.x, pos.y); } nana::point caret_pos(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) return iwd->together.caret->position(); return{}; @@ -1018,25 +1062,25 @@ namespace API void caret_effective_range(window wd, const nana::rectangle& rect) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) iwd->together.caret->effective_range(rect); } void caret_size(window wd, const nana::size& sz) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) iwd->together.caret->size(sz); } nana::size caret_size(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) return iwd->together.caret->size(); return{}; @@ -1044,17 +1088,17 @@ namespace API void caret_visible(window wd, bool is_show) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) iwd->together.caret->visible(is_show); } bool caret_visible(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && iwd->together.caret) + if(restrict::wd_manager().available(iwd) && iwd->together.caret) return iwd->together.caret->visible(); return false; @@ -1062,7 +1106,7 @@ namespace API void tabstop(window wd) { - restrict::window_manager.enable_tabstop(reinterpret_cast(wd)); + restrict::wd_manager().enable_tabstop(reinterpret_cast(wd)); } //eat_tabstop @@ -1071,9 +1115,9 @@ namespace API { if(wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard isg; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { if(eat) iwd->flags.tab |= ::nana::detail::tab_type::eating; @@ -1085,9 +1129,9 @@ namespace API window move_tabstop(window wd, bool next) { - restrict::core_window_t* ts_wd = restrict::window_manager.tabstop(reinterpret_cast(wd), next); - restrict::window_manager.set_focus(ts_wd, false); - restrict::window_manager.update(ts_wd, false, false); + basic_window* ts_wd = restrict::wd_manager().tabstop(reinterpret_cast(wd), next); + restrict::wd_manager().set_focus(ts_wd, false); + restrict::wd_manager().update(ts_wd, false, false); return reinterpret_cast(ts_wd); } @@ -1109,13 +1153,13 @@ namespace API void take_active(window wd, bool active, window take_if_active_false) { - auto const iwd = reinterpret_cast(wd); - auto take_if_false = reinterpret_cast(take_if_active_false); + auto const iwd = reinterpret_cast(wd); + auto take_if_false = reinterpret_cast(take_if_active_false); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { - if (active || (take_if_false && (restrict::window_manager.available(take_if_false) == false))) + if (active || (take_if_false && (restrict::wd_manager().available(take_if_false) == false))) take_if_false = 0; iwd->flags.take_active = active; @@ -1125,14 +1169,14 @@ namespace API bool window_graphics(window wd, nana::paint::graphics& graph) { - return restrict::window_manager.get_graphics(reinterpret_cast(wd), graph); + return restrict::wd_manager().get_graphics(reinterpret_cast(wd), graph); } bool root_graphics(window wd, nana::paint::graphics& graph) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { graph = *(iwd->root_graph); return true; @@ -1142,26 +1186,26 @@ namespace API bool get_visual_rectangle(window wd, nana::rectangle& r) { - return restrict::window_manager.get_visual_rectangle(reinterpret_cast(wd), r); + return restrict::wd_manager().get_visual_rectangle(reinterpret_cast(wd), r); } void typeface(window wd, const nana::paint::font& font) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { iwd->drawer.graphics.typeface(font); iwd->drawer.typeface_changed(); - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } } nana::paint::font typeface(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) return iwd->drawer.graphics.typeface(); return{}; @@ -1169,30 +1213,30 @@ namespace API bool calc_screen_point(window wd, nana::point& pos) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { pos += iwd->pos_root; - return restrict::interface_type::calc_screen_point(iwd->root, pos); + return interface_type::calc_screen_point(iwd->root, pos); } return false; } bool calc_window_point(window wd, nana::point& pos) { - return restrict::window_manager.calc_window_point(reinterpret_cast(wd), pos); + return restrict::wd_manager().calc_window_point(reinterpret_cast(wd), pos); } window find_window(const nana::point& pos) { - auto wd = restrict::interface_type::find_window(pos.x, pos.y); + auto wd = interface_type::find_window(pos.x, pos.y); if(wd) { - nana::point clipos(pos.x, pos.y); - restrict::interface_type::calc_window_point(wd, clipos); + ::nana::point clipos{pos}; + interface_type::calc_window_point(wd, clipos); return reinterpret_cast( - restrict::window_manager.find_window(wd, clipos.x, clipos.y)); + restrict::wd_manager().find_window(wd, clipos.x, clipos.y)); } return nullptr; } @@ -1200,15 +1244,15 @@ namespace API void register_menu_window(window wd, bool has_keyboard) { internal_scope_guard lock; - if(restrict::window_manager.available(reinterpret_cast(wd))) - restrict::bedrock.set_menu(reinterpret_cast(wd)->root, has_keyboard); + if(restrict::wd_manager().available(reinterpret_cast(wd))) + restrict::bedrock.set_menu(reinterpret_cast(wd)->root, has_keyboard); } bool attach_menubar(window menubar) { - auto iwd = reinterpret_cast(menubar); + auto iwd = reinterpret_cast(menubar); internal_scope_guard lock; - if(restrict::window_manager.available(iwd) && (nullptr == iwd->root_widget->other.attribute.root->menubar)) + if(restrict::wd_manager().available(iwd) && (nullptr == iwd->root_widget->other.attribute.root->menubar)) { iwd->root_widget->other.attribute.root->menubar = iwd; return true; @@ -1218,9 +1262,9 @@ namespace API void detach_menubar(window menubar) { - auto iwd = reinterpret_cast(menubar); + auto iwd = reinterpret_cast(menubar); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { if (iwd->root_widget->other.attribute.root->menubar == iwd) iwd->root_widget->other.attribute.root->menubar = nullptr; @@ -1229,35 +1273,35 @@ namespace API bool is_window_zoomed(window wd, bool ask_for_max) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { if (iwd->other.category == nana::category::flags::root) - return ::nana::detail::bedrock::interface_type::is_window_zoomed(iwd->root, ask_for_max); + return interface_type::is_window_zoomed(iwd->root, ask_for_max); } return false; } void widget_borderless(window wd, bool enabled) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { if ((category::flags::widget == iwd->other.category) && (iwd->flags.borderless != enabled)) { iwd->flags.borderless = enabled; - restrict::window_manager.update(iwd, true, false); + restrict::wd_manager().update(iwd, true, false); } } } bool widget_borderless(window wd) { - auto const iwd = reinterpret_cast(wd); + auto const iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) return iwd->flags.borderless; return false; @@ -1265,18 +1309,18 @@ namespace API nana::mouse_action mouse_action(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) return iwd->flags.action; return nana::mouse_action::normal; } nana::element_state element_state(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if(restrict::window_manager.available(iwd)) + if(restrict::wd_manager().available(iwd)) { const bool is_focused = (iwd->root_widget->other.attribute.root->focus == iwd); switch(iwd->flags.action) @@ -1297,9 +1341,9 @@ namespace API bool ignore_mouse_focus(window wd, bool ignore) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - if (restrict::window_manager.available(iwd)) + if (restrict::wd_manager().available(iwd)) { auto state = iwd->flags.ignore_mouse_focus; iwd->flags.ignore_mouse_focus = ignore; @@ -1310,14 +1354,14 @@ namespace API bool ignore_mouse_focus(window wd) { - auto iwd = reinterpret_cast(wd); + auto iwd = reinterpret_cast(wd); internal_scope_guard lock; - return (restrict::window_manager.available(iwd) ? iwd->flags.ignore_mouse_focus : false); + return (restrict::wd_manager().available(iwd) ? iwd->flags.ignore_mouse_focus : false); } void at_safe_place(window wd, std::function fn) { - restrict::window_manager.set_safe_place(reinterpret_cast(wd), std::move(fn)); + restrict::wd_manager().set_safe_place(reinterpret_cast(wd), std::move(fn)); } }//end namespace API }//end namespace nana diff --git a/source/gui/state_cursor.cpp b/source/gui/state_cursor.cpp index e50d0df7..5644ed83 100644 --- a/source/gui/state_cursor.cpp +++ b/source/gui/state_cursor.cpp @@ -12,6 +12,7 @@ #include #include #include +#include namespace nana { @@ -20,7 +21,7 @@ namespace nana { auto & brock = detail::bedrock::instance(); auto wd = reinterpret_cast(handle); - if (brock.wd_manager.available(wd)) + if (brock.wd_manager().available(wd)) brock.define_state_cursor(wd, cur, nullptr); else handle_ = nullptr; @@ -40,7 +41,7 @@ namespace nana { auto & brock = detail::bedrock::instance(); auto wd = reinterpret_cast(handle_); - if (brock.wd_manager.available(wd)) + if (brock.wd_manager().available(wd)) brock.undefine_state_cursor(wd, nullptr); } handle_ = rhs.handle_; @@ -55,7 +56,7 @@ namespace nana { auto & brock = detail::bedrock::instance(); auto wd = reinterpret_cast(handle_); - if (brock.wd_manager.available(wd)) + if (brock.wd_manager().available(wd)) brock.undefine_state_cursor(wd, nullptr); } } diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index c0ccfa27..6174c61e 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -297,7 +297,7 @@ namespace nana return *this; } - + iresolver::iresolver(const std::vector& cl) : cells_(cl) {} @@ -317,7 +317,7 @@ namespace nana //end class iresolver/oresolver /// Essence of the columns Header - class es_header + class es_header { public: @@ -339,10 +339,10 @@ namespace nana export_options::columns_indexs all_headers(bool only_visibles) const { - export_options::columns_indexs idx; + export_options::columns_indexs idx; for(const auto &header : cont()) { - if(header.visible || !only_visibles) + if(header.visible || !only_visibles) idx.push_back(header.index); } return idx; @@ -350,13 +350,13 @@ namespace nana nana::string to_string(const export_options& exp_opt) const { - nana::string head_str; + nana::string head_str; bool first{true}; for( size_type idx{}; idxget(pos), std::move(text))); @@ -917,7 +917,7 @@ namespace nana for (size_type i=0; i= size_categ() || (from.item != npos && from.item >= size_item(from.cat))) + if(from.cat >= size_categ() || (from.item != npos && from.item >= size_item(from.cat))) return dpos; dpos = from; @@ -1293,7 +1293,7 @@ namespace nana for(auto & cat : list_) { id.item = 0; - for(auto & m : cat.items) + for(auto & m : cat.items) { if(m.flags.selected) vec.push_back(id); // absolute positions, no relative to display @@ -1302,14 +1302,14 @@ namespace nana ++id.cat; } } - + index_pair find_first_selected() { index_pair id; for(auto & cat : list_) { id.item = 0; - for(auto & m : cat.items) + for(auto & m : cat.items) { if(m.flags.selected) return id; // absolute positions, no relative to display @@ -1659,7 +1659,7 @@ namespace nana ///Translate relative position (position in display) into absolute position (original data order) size_type absolute(const index_pair& display_pos) const { - if(sorted_index_ == npos || display_pos.item == npos) + if(sorted_index_ == npos || display_pos.item == npos) return display_pos.item ; auto & catobj = *get(display_pos.cat); @@ -1674,11 +1674,11 @@ namespace nana auto item_pos = absolute(display_pos); return {item_pos != npos ? display_pos.cat : npos, item_pos}; } - + ///Translate absolute position (original data order) into relative position (position in display) size_type relative(const index_pair& pos) const { - if (sorted_index_ == npos) + if (sorted_index_ == npos) return pos.item ; auto& catobj = *get(pos.cat); @@ -1686,7 +1686,7 @@ namespace nana for (size_type i=0; i= list_.size()) @@ -1841,12 +1841,6 @@ namespace nana ::nana::listbox::export_options def_exp_options; - ::nana::listbox::export_options& def_export_options() - { - return def_exp_options; - } - - es_header header; es_lister lister; // we have at least one emty cat. the #0 @@ -1925,7 +1919,7 @@ namespace nana scroll_y_dpl_refresh() ; } - /// directly set a tested relative display pos + /// directly set a tested relative display pos void set_scroll_y_dpl(const index_pair& pos_dpl) { scroll.offset_y_dpl = pos_dpl; @@ -1950,7 +1944,7 @@ namespace nana { if( dpl_pos.cat < scroll.offset_y_dpl.cat // in prevoious cat ---------------- up ----> we need to move || ((dpl_pos.cat == scroll.offset_y_dpl.cat) && ( scroll.offset_y_dpl.item != npos) // is our cat, where we are an item - && (dpl_pos.item == npos || dpl_pos.item < scroll.offset_y_dpl.item))) + && (dpl_pos.item == npos || dpl_pos.item < scroll.offset_y_dpl.item))) // problem!!!!!! { if(lister.expand(dpl_pos.cat) == false) @@ -1960,7 +1954,7 @@ namespace nana else lister.expand(dpl_pos.cat, true); } - set_scroll_y_dpl(dpl_pos); // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs + set_scroll_y_dpl(dpl_pos); // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs } else { @@ -1969,7 +1963,7 @@ namespace nana if(numbers > off) return; index_pair n_off = lister.advance(scroll.offset_y_dpl, (off - numbers) + 1); - if(n_off.cat != npos) // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs + if(n_off.cat != npos) // <------------------------- set scroll.offset_y_dpl & scroll.offset_y_abs set_scroll_y_dpl(n_off); } @@ -1978,7 +1972,7 @@ namespace nana void trace_item_abs( index_pair abs_pos ) { - if(abs_pos.item == npos && abs_pos.cat == scroll.offset_y_abs.cat + if(abs_pos.item == npos && abs_pos.cat == scroll.offset_y_abs.cat && scroll.offset_y_abs.item == npos ) // if item==off y and is a cat return; @@ -2020,7 +2014,7 @@ namespace nana scroll.v.value(off); } } - + void adjust_scroll_life() // at end call adjust_scroll_value(); { internal_scope_guard lock; @@ -2252,7 +2246,7 @@ namespace nana if (target == scroll.offset_y_dpl) return false; - + set_scroll_y_dpl ( target ); return true; } @@ -2465,10 +2459,10 @@ namespace nana if (good(next_selected_dpl)) { - if (unselect_previous && !single_selection_ ) + if (unselect_previous && !single_selection_ ) select_for_all(false); - /// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected + /// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected item_proxy::from_display(ess_, next_selected_dpl).select(true); if (trace_selected) @@ -2482,7 +2476,7 @@ namespace nana nana::string es_lister::to_string(const export_options& exp_opt) const { - nana::string list_str; + nana::string list_str; bool first{true}; for(auto & cat: cat_container()) { @@ -2509,8 +2503,7 @@ namespace nana if (it.selected() != sel) it.select(sel); } - - last_selected_abs = last_selected_dpl = index_pair {cat, npos}; + last_selected_abs = last_selected_dpl = index_pair{cat, npos}; } class drawer_header_impl @@ -2586,9 +2579,9 @@ namespace nana const auto& item = essence_->header.column(item_spliter_); //Resize the item specified by item_spliter_. auto new_w = orig_item_width_ - (ref_xpos_ - pos.x); - if(static_cast(item.pixels) != new_w) + if(item.pixels != new_w) { - essence_->header.item_width(item_spliter_, (new_w < static_cast(essence_->suspension_width + 20) ? essence_->suspension_width + 20 : new_w)); + essence_->header.item_width(item_spliter_, (new_w < (essence_->suspension_width + 20) ? essence_->suspension_width + 20 : new_w)); new_w = essence_->header.pixels(); if(new_w < (rect.width + essence_->scroll.offset_x)) essence_->scroll.offset_x = (new_w > rect.width ? new_w - rect.width : 0); @@ -2749,8 +2742,8 @@ namespace nana unsigned header_w = essence_->header.pixels(); essence_->graph->set_color(bgcolor); if(header_w - essence_->scroll.offset_x < rect.width) - essence_->graph->rectangle(rectangle{ point(rect.x + static_cast(header_w)-essence_->scroll.offset_x, rect.y), - size(static_cast(rect.width) + essence_->scroll.offset_x - static_cast(header_w), rect.height) }, + essence_->graph->rectangle(rectangle{ point(rect.x + static_cast(header_w)-essence_->scroll.offset_x, rect.y), + size(static_cast(rect.width) + essence_->scroll.offset_x - static_cast(header_w), rect.height) }, true); es_lister & lister = essence_->lister; @@ -2801,7 +2794,7 @@ namespace nana _m_draw_item(*i_categ, item_index, x, y, txtoff, header_w, rect, subitems, bgcolor,fgcolor, state); y += essence_->item_size; } - + ++i_categ; ++idx.cat; } @@ -2857,7 +2850,7 @@ namespace nana facade arrow("double"); arrow.direction(categ.expand ? ::nana::direction::north : ::nana::direction::south); - arrow.draw( *graph, {}, txt_color, + arrow.draw( *graph, {}, txt_color, { x + 5, y + static_cast(essence_->item_size - 16) / 2, 16, 16 }, element_state::normal); @@ -2890,7 +2883,7 @@ namespace nana { auto & item = cat.items[item_pos.item]; - if (item.flags.selected) // fetch the "def" colors + if (item.flags.selected) // fetch the "def" colors bgcolor = essence_->scheme_ptr->item_selected; else if (!item.bgcolor.invisible()) bgcolor = item.bgcolor; @@ -3043,7 +3036,7 @@ namespace nana //The text is painted over the next subitem // here beging the ... int xpos = item_xpos + static_cast(header.pixels) - static_cast(essence_->suspension_width); - graph->set_color(it_bgcolor); // litter rect with the item bg end ... + graph->set_color(it_bgcolor); // litter rect with the item bg end ... graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true); graph->string(point{ xpos, y + 2 }, STR("...")); @@ -3315,7 +3308,7 @@ namespace nana if (arg.shift) lister.select_display_range(lister.last_selected_abs , item_pos, sel); else if (arg.ctrl) - sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected(); + sel = !item_proxy(essence_, index_pair (item_pos.cat, lister.absolute(item_pos))).selected(); else lister.select_for_all(false); //cancel all selections } @@ -3325,7 +3318,7 @@ namespace nana if(item_ptr) { item_ptr->flags.selected = sel; - index_pair last_selected(item_pos.cat, lister.absolute(item_pos)); + index_pair last_selected(item_pos.cat, lister.absolute(item_pos)); arg_listbox arg{item_proxy{essence_, last_selected}, sel}; lister.wd_ptr()->events().selected.emit(arg); @@ -3334,7 +3327,7 @@ namespace nana { lister.cancel_others_if_single_enabled(true, last_selected); essence_->lister.last_selected_abs = last_selected; - + } else if (essence_->lister.last_selected_abs == last_selected) essence_->lister.last_selected_abs.set_both(npos); @@ -3424,7 +3417,7 @@ namespace nana void trigger::dbl_click(graph_reference graph, const arg_mouse&) { if (essence_->pointer_where.first == essence_t::parts::header) - if (cursor::size_we == essence_->lister.wd_ptr()->cursor()) + if (cursor::size_we == essence_->lister.wd_ptr()->cursor()) { if (essence(). auto_width(drawer_header_->item_spliter() )) // ? in order essence().update(); @@ -3471,7 +3464,7 @@ namespace nana bool up = false; if (essence_->lister.size_categ()==1 && essence_->lister.size_item(0)==0) - return ; + return ; switch(arg.key) { @@ -3494,7 +3487,7 @@ namespace nana case keyboard::os_pagedown: { auto& scrl = essence_->scroll.v; - if (! scrl.make_page_scroll(!up)) + if (! scrl.make_page_scroll(!up)) return; essence_->lister.select_for_all(false); @@ -3504,7 +3497,7 @@ namespace nana if (idx.is_item()) item_proxy::from_display(essence_, idx).select(true); - else + else if(!essence_->lister.single_selection()) essence_->lister.categ_selected(idx.cat, true); @@ -3519,7 +3512,7 @@ namespace nana index_pair frst{essence_->lister.first()}; if (frst.is_item()) item_proxy::from_display(essence_, frst).select(true); - else + else if(!essence_->lister.single_selection()) essence_->lister.categ_selected(frst.cat, true); @@ -3545,13 +3538,13 @@ namespace nana { case keyboard::copy: { - export_options exp_opt {essence_->def_export_options()}; + export_options exp_opt {essence_->def_exp_options}; exp_opt.columns_order = essence_->header.all_headers(true); exp_opt.only_selected_items = true; ::nana::system::dataexch().set(essence_->to_string(exp_opt)); return; } - case keyboard::select_all : + case keyboard::select_all : essence_->lister.select_for_all(true); refresh(graph); API::lazy_refresh(); @@ -3581,7 +3574,7 @@ namespace nana } /// the main porpose of this it to make obvious that item_proxy operate with absolute positions, and dont get moved during sort() - item_proxy item_proxy::from_display(essence_t *ess, const index_pair &relative) + item_proxy item_proxy::from_display(essence_t *ess, const index_pair &relative) { return item_proxy{ess, ess->lister.absolute_pair(relative)}; } @@ -3619,7 +3612,7 @@ namespace nana return cat_->items.at(pos_.item).flags.checked; } - /// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected + /// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected item_proxy & item_proxy::select(bool s) { auto & m = cat_->items.at(pos_.item); // a ref to the real item // what is pos is a cat? @@ -3638,7 +3631,7 @@ namespace nana ess_->lister.last_selected_abs.set_both(npos); ess_->update(); - + ess_->update(); return *this; } @@ -3719,7 +3712,7 @@ namespace nana bool item_proxy::operator==(const char * s) const { return (ess_->lister.get_cells(cat_, pos_.item).at(0).text == nana::string(nana::charset(s))); - + } bool item_proxy::operator==(const wchar_t * s) const @@ -4257,8 +4250,8 @@ namespace nana // from current display position // move to the cat self if not in first cat // move to first item ?? if in first cat - ess.scroll_y_abs(ess.scroll_y_abs()); - + ess.scroll_y_abs(ess.scroll_y_abs()); + ess.update(); } @@ -4271,8 +4264,8 @@ namespace nana // from current display position // move to the cat self if not in first cat // move to first item ?? if in first cat - ess.scroll_y_abs(ess.scroll_y_abs()); - + ess.scroll_y_abs(ess.scroll_y_abs()); + ess.update(); } @@ -4300,7 +4293,7 @@ namespace nana { auto & ess = _m_ess(); ess.lister.erase(); - ess.scroll_y_abs(index_pair()); + ess.scroll_y_abs(index_pair()); ess.update(); } @@ -4432,7 +4425,7 @@ namespace nana listbox::export_options& listbox::def_export_options() { - return _m_ess().def_export_options(); + return _m_ess().def_exp_options; } drawerbase::listbox::essence_t & listbox::_m_ess() const diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index b17a6a45..ff44e593 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1222,12 +1222,11 @@ namespace nana{ namespace widgets auto ki = kwptr->schemes.find(ds.scheme); if (ki != kwptr->schemes.end() && ki->second) { - schemes_.emplace(ds.scheme, ki->second); - entities.emplace_back(); - auto & last = entities.back(); - last.begin = text.data() + pos; - last.end = last.begin + ds.text.size(); - last.scheme = ki->second.get(); + entities.emplace_back(); + auto & last = entities.back(); + last.begin = text.data() + pos; + last.end = last.begin + ds.text.size(); + last.scheme = ki->second.get(); } } } @@ -1259,7 +1258,6 @@ namespace nana{ namespace widgets } private: std::vector entities_; - std::map> schemes_; }; //class text_editor diff --git a/source/gui/wvl.cpp b/source/gui/wvl.cpp index 86f17749..cedca916 100644 --- a/source/gui/wvl.cpp +++ b/source/gui/wvl.cpp @@ -1,6 +1,6 @@ /* * Nana GUI Library Definition - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -12,9 +12,17 @@ */ #include - +#include namespace nana { + namespace detail + { + void form_loader_private::insert_form(::nana::widget* p) + { + bedrock::instance().manage_form_loader(reinterpret_cast(p->handle()), true); + } + } + void exec() { detail::bedrock::instance().pump_event(nullptr, false); diff --git a/source/internationalization.cpp b/source/internationalization.cpp index fd8a9b9c..56bc327e 100644 --- a/source/internationalization.cpp +++ b/source/internationalization.cpp @@ -16,6 +16,8 @@ #include #include #include +#include +#include namespace nana { From 1fde1c844b9bb66dfb24ef7994d3dccec5746763 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 13 Oct 2015 23:08:45 +0800 Subject: [PATCH 39/65] fix inverted vertical slider(#82) --- source/gui/widgets/slider.cpp | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index 2e8ef4fc..ebda374e 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -151,6 +151,7 @@ namespace nana if(dir != attr_.dir) { attr_.dir = dir; + _m_mk_slider_pos_by_value(); this->draw(); } } @@ -425,7 +426,7 @@ namespace nana default: break; } - return pos; + return (pos < 0 ? 0 : pos); } int _m_slider_refpos() const @@ -443,7 +444,13 @@ namespace nana if(_m_scale()) { auto cmpvalue = static_cast(attr_.vcur); - attr_.vcur = (attr_.pos * attr_.vmax / _m_scale()); + if (style::vertical == attr_.dir) + { + double scl = _m_scale(); + attr_.vcur = (scl - attr_.pos) * attr_.vmax / scl; + } + else + attr_.vcur = (attr_.pos * attr_.vmax / _m_scale()); if (cmpvalue != static_cast(attr_.vcur)) _m_emit_value_changed(); } @@ -453,6 +460,9 @@ namespace nana { attr_.pos = double(_m_scale()) * attr_.vcur / attr_.vmax; + if (style::vertical == attr_.dir) + attr_.pos = _m_scale() - attr_.pos; + if(slider_state_.trace == slider_state_.TraceNone) attr_.adorn_pos = attr_.pos; } @@ -480,8 +490,16 @@ namespace nana //adorn renderer::adorn_t adorn; adorn.horizontal = bar.horizontal; - adorn.bound.x = (bar.horizontal ? bar.r.x : bar.r.y) + attr_.border; - adorn.bound.y = adorn.bound.x + static_cast(attr_.adorn_pos); + if (adorn.horizontal) + { + adorn.bound.x = bar.r.x + attr_.border; + adorn.bound.y = adorn.bound.x + static_cast(attr_.adorn_pos); + } + else + { + adorn.bound.y = static_cast(other_.graph->height()) - static_cast(attr_.border + bar.r.y); + adorn.bound.x = static_cast(attr_.adorn_pos + attr_.border + bar.r.y); + } adorn.vcur_scale = static_cast(attr_.pos); adorn.block = (bar.horizontal ? bar.r.height : bar.r.width) - attr_.border * 2; adorn.fixedpos = static_cast((bar.horizontal ? bar.r.y : bar.r.x) + attr_.border); From a9983101ab50d506c2fce554650bbc1e915d7e8d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 13 Oct 2015 23:11:57 +0800 Subject: [PATCH 40/65] avoid double-copying a window while its parent is refreshing --- source/gui/detail/window_manager.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 3cb72140..ea26fd02 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -676,6 +676,14 @@ namespace detail std::lock_guard lock(mutex_); if (impl_->wd_register.available(wd) && !wd->is_draw_through()) { + auto parent = wd->parent; + while (parent) + { + if (parent->flags.refreshing) + return; + parent = parent->parent; + } + //Copy the root buffer that wd specified into DeviceContext #if defined(NANA_LINUX) wd->drawer.map(reinterpret_cast(wd), forced, update_area); From 84f071dc950d0bbcd99809a504c04dd5049add36 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 13 Oct 2015 23:16:25 +0800 Subject: [PATCH 41/65] fix some compiler errors(clang) --- source/gui/place.cpp | 36 ++++++++---------------------------- source/paint/graphics.cpp | 2 +- 2 files changed, 9 insertions(+), 29 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index 5c7b6231..aa4692b5 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -1541,7 +1541,6 @@ namespace nana } private: nana::cursor splitter_cursor_; - bool created_{ false }; place_parts::splitter splitter_; nana::point begin_point_; int left_pos_, right_pos_; @@ -1588,18 +1587,6 @@ namespace nana } auto & dockarea = dockable_field->dockarea; - - /* - if (!created_) - { - created_ = true; - dockarea.create(wd, this); - } - - if (!dockarea.empty() && !dockarea.floating()) - dockarea.move(this->field_area); - */ - if (dockarea && !dockarea->floating()) dockarea->move(this->field_area); } @@ -1763,9 +1750,10 @@ namespace nana } public: field_dock * dockable_field{ nullptr }; + + std::unique_ptr splitter; private: implement * impl_ptr_; - bool created_{ false }; // struct indicator_rep @@ -1938,8 +1926,6 @@ namespace nana double top = area.y; double bottom = area.bottom(); - std::map> swp_splitters; - for (auto & child : children) { if (!child->display) @@ -1964,16 +1950,13 @@ namespace nana if (_m_right(child_dv)) { //Creates a splitbar if the 'right' leaf is not empty - - auto & splitter_ptr = swp_splitters[child_dv]; - - auto si = splitters_.find(child_dv); - if (si == splitters_.end()) - splitter_ptr.reset(new splitter(impl_->window_handle, child->dir, this, child_dv)); + if (!child_dv->splitter) + { + split = new splitter(impl_->window_handle, child->dir, this, child_dv); + child_dv->splitter.reset(split); + } else - splitter_ptr.swap(si->second); - - split = splitter_ptr.get(); + split = dynamic_cast(child_dv->splitter.get()); } ::nana::rectangle child_r; @@ -2056,8 +2039,6 @@ namespace nana child->field_area = child_r; child->collocate(wd); } - - splitters_.swap(swp_splitters); } private: static bool _m_is_vert(::nana::direction dir) @@ -2079,7 +2060,6 @@ namespace nana } private: implement * const impl_; - std::map> splitters_; }; place::implement::~implement() diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index c6b71f21..5b489cdf 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -474,7 +474,7 @@ namespace paint ::nana::size graphics::bidi_extent_size(const std::string& str) const { - return bidi_extent_size(std::wstring{ ::nana::charset(str, ::nana::unicode::utf8) }); + return bidi_extent_size(static_cast(::nana::charset(str, ::nana::unicode::utf8))); } bool graphics::text_metrics(unsigned & ascent, unsigned& descent, unsigned& internal_leading) const From b160e5e83325dee9af4c54e45a216fd0a94ec92d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 14 Oct 2015 22:16:07 +0800 Subject: [PATCH 42/65] fix a listbox inline widget issue --- source/gui/widgets/listbox.cpp | 64 ++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 6 deletions(-) diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 6174c61e..9db220c2 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -1869,6 +1869,7 @@ namespace nana inline_indicator * indicator; index_pair item_pos; //The item index of the inline widget std::size_t column_pos; + ::nana::string text; }; std::map>> inline_table, inline_buffered_table; @@ -1923,7 +1924,10 @@ namespace nana void set_scroll_y_dpl(const index_pair& pos_dpl) { scroll.offset_y_dpl = pos_dpl; - scroll.offset_y_abs = lister.absolute_pair(pos_dpl); + if (pos_dpl.is_category()) + scroll.offset_y_abs = pos_dpl; + else + scroll.offset_y_abs = lister.absolute_pair(pos_dpl); if (scroll.offset_y_abs.empty()) throw std::invalid_argument("nana.listbox.set_scroll_y_dpl's exception is due to invalid item, please report a bug"); @@ -2315,7 +2319,6 @@ namespace nana auto ptr = pane_ptr.get(); inline_table[factory].emplace_back(std::move(pane_ptr)); - ptr->inline_ptr->whether_to_draw(); return ptr; } }; @@ -2330,7 +2333,26 @@ namespace nana : ess_{ ess }, column_pos_{column_pos} { } + + void attach(index_type pos, essence_t::inline_pane* pane) + { + for (auto & pn : panes_) + { + if (pn.first == pos) + { + pn.second = pane; + return; + } + } + panes_.emplace_back(std::make_pair(pos, pane)); + } + void detach() + { + panes_.clear(); + } + public: + //Implement inline_widget_indicator ::nana::widget& host() const override { return *ess_->lister.wd_ptr(); @@ -2344,6 +2366,15 @@ namespace nana if (cells[column_pos_].text != value) { + for (auto & pn : panes_) + { + if (pn.first == pos) + { + pn.second->text = value; + break; + } + } + cells[column_pos_].text = value; ess_->update(); } @@ -2371,6 +2402,7 @@ namespace nana private: essence_t * const ess_; const std::size_t column_pos_; + std::vector> panes_; }; void es_lister::erase(const index_pair& pos) @@ -2772,6 +2804,13 @@ namespace nana essence_->inline_buffered_table.swap(essence_->inline_table); + for(auto & cat : lister.cat_container()) + for (auto & ind : cat.indicators) + { + if (ind) + ind->detach(); + } + //Here we draw the root categ (0) or a first item if the first drawing is not a categ.(item!=npos)) if(idx.cat == 0 || !idx.is_category()) { @@ -2989,17 +3028,30 @@ namespace nana ::nana::size sz{ wdg_w, essence_->item_size }; inline_wdg->pane_widget.size(sz); inline_wdg->inline_ptr->resize(sz); - inline_wdg->item_pos = item_pos; - inline_wdg->column_pos = column_pos; - inline_wdg->inline_ptr->activate(*inline_wdg->indicator, item_pos); draw_column = inline_wdg->inline_ptr->whether_to_draw(); + inline_wdg->item_pos = item_pos; + inline_wdg->column_pos = column_pos; + inline_wdg->inline_ptr->activate(*inline_wdg->indicator, item_pos); + + inline_wdg->indicator->attach(item_pos, inline_wdg); + //To reduce the memory usage, the cells may not be allocated if (item.cells.size() > column_pos) - inline_wdg->inline_ptr->set(item.cells[column_pos].text); + { + auto & text = item.cells[column_pos].text; + if (text != inline_wdg->text) + { + inline_wdg->text = text; + inline_wdg->inline_ptr->set(text); + } + } else + { + inline_wdg->text.clear(); inline_wdg->inline_ptr->set({}); + } API::show_window(inline_wdg->pane_bottom, visible_state); } From cb4bb7d60e1d03791f3a753011a9a7d102c61f7f Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 14 Oct 2015 22:20:51 +0800 Subject: [PATCH 43/65] fix a crash of API::root --- source/gui/place.cpp | 2 +- source/gui/programming_interface.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/gui/place.cpp b/source/gui/place.cpp index aa4692b5..84d84ac2 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -8,7 +8,7 @@ * http://www.boost.org/LICENSE_1_0.txt) * * @file: nana/gui/place.cpp - * @contributors: qPCR4vir + * @contributors: Ariel Vina-Rodriguez */ #include diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index f8fb62a4..fdd4522c 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -442,7 +442,9 @@ namespace API native_window_type root(window wd) { internal_scope_guard lock; - return reinterpret_cast(wd)->root; + if(is_window(wd)) + return reinterpret_cast(wd)->root; + return nullptr; } window root(native_window_type wd) From 4ad8cdec8b0e235634779fb16b596bbd29ec0229 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 14 Oct 2015 22:25:07 +0800 Subject: [PATCH 44/65] fix an issue that no respending when double-click the scrollbar --- include/nana/gui/widgets/scroll.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp index 917a5da5..28ac3326 100644 --- a/include/nana/gui/widgets/scroll.hpp +++ b/include/nana/gui/widgets/scroll.hpp @@ -243,6 +243,11 @@ namespace nana } } + void dbl_click(graph_reference graph, const arg_mouse& arg) override + { + mouse_down(graph, arg); + } + void mouse_down(graph_reference graph, const arg_mouse& arg) override { if (arg.left_button) From 8f59ccfbf615dda7fc2565ac91fb2518746ab5ed Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 15 Oct 2015 01:33:53 +0800 Subject: [PATCH 45/65] restructure the extrlib --- build/makefile/makefile | 3 +- build/vc2013/nana.vcxproj | 6 +- build/vc2013/nana.vcxproj.filters | 15 - build/vc2015/nana.vcxproj | 2 +- extrlib/readme.txt | 6 +- include/nana/extrlib/png.h | 2654 ----------------------------- include/nana/extrlib/pngconf.h | 596 ------- include/nana/extrlib/pnglibconf.h | 189 -- include/nana/extrlib/zlib.h | 1732 ------------------- source/paint/detail/image_png.hpp | 2 +- 10 files changed, 9 insertions(+), 5196 deletions(-) delete mode 100644 include/nana/extrlib/png.h delete mode 100644 include/nana/extrlib/pngconf.h delete mode 100644 include/nana/extrlib/pnglibconf.h delete mode 100644 include/nana/extrlib/zlib.h diff --git a/build/makefile/makefile b/build/makefile/makefile index 2a473da7..8b1fbde8 100644 --- a/build/makefile/makefile +++ b/build/makefile/makefile @@ -5,9 +5,10 @@ GCC = g++ INCROOT = ../../include SRCROOT = ../../source +EXTRLIB = ../../extrlib NANA_INC= $(INCROOT)/nana -INCS = -I$(INCROOT) -I/usr/include/freetype2 +INCS = -I$(INCROOT) -I/usr/include/freetype2 -I$(EXTRLIB) BIN = libnana.a diff --git a/build/vc2013/nana.vcxproj b/build/vc2013/nana.vcxproj index 25218628..9739063d 100644 --- a/build/vc2013/nana.vcxproj +++ b/build/vc2013/nana.vcxproj @@ -68,7 +68,7 @@ ../bin/ - ..\..\include;$(IncludePath) + ..\..\include;..\..\extrlib;$(IncludePath) ..\..\source;$(VC_SourcePath); $(ProjectName)_$(PlatformToolset)_$(Configuration)_$(PlatformShortName) ..\..\..\temp\$(ProjectName)\$(PlatformToolset)_$(Configuration)_$(PlatformShortName)\ @@ -271,10 +271,6 @@ - - - - diff --git a/build/vc2013/nana.vcxproj.filters b/build/vc2013/nana.vcxproj.filters index 2edd3515..418bbf46 100644 --- a/build/vc2013/nana.vcxproj.filters +++ b/build/vc2013/nana.vcxproj.filters @@ -82,9 +82,6 @@ {61385c08-f06b-4cf3-8e05-9b47d546164b} - - {e9eadc97-4a14-4a4e-bb52-52d3a20e2693} - {5667eac1-0887-4936-9502-eac4dd8c1c1d} @@ -625,18 +622,6 @@ Header Files\detail\win32 - - Header Files\extrlib - - - Header Files\extrlib - - - Header Files\extrlib - - - Header Files\extrlib - Header Files\filesystem diff --git a/build/vc2015/nana.vcxproj b/build/vc2015/nana.vcxproj index 8b8281a7..fd9219b1 100644 --- a/build/vc2015/nana.vcxproj +++ b/build/vc2015/nana.vcxproj @@ -75,7 +75,7 @@ lib$(ProjectName) - ../../include;$(IncludePath) + ../../include;../../extrlib;$(IncludePath) ..\bin\vc2015\ lib$(ProjectName)d diff --git a/extrlib/readme.txt b/extrlib/readme.txt index c54ee0ad..08aff887 100644 --- a/extrlib/readme.txt +++ b/extrlib/readme.txt @@ -1,3 +1,5 @@ -The libpng.a is for MinGW(Not linux), and other .lib files are for VS2013 +You can download the precompiled external libraries at http://sourceforge.net/projects/nanapro/files/extrlib/ +Extract the ZIP file to the directory nana/extrlib. Then modify the marco switch defined in nana/include/config.hpp header file and rebuild the nana library. -You can download the precompiled external libraries at http://sourceforge.net/projects/nanapro/files/extrlib/ \ No newline at end of file +您可以下载预先编译的外部程序库,下载地址http://sourceforge.net/projects/nanapro/files/extrlib/ +将ZIP文件释放到nana/extrlib目录。然后修改nana/include/config.hpp文件中对应的标志,重新编译Nana库即可。 \ No newline at end of file diff --git a/include/nana/extrlib/png.h b/include/nana/extrlib/png.h deleted file mode 100644 index bebaf549..00000000 --- a/include/nana/extrlib/png.h +++ /dev/null @@ -1,2654 +0,0 @@ - -/* png.h - header file for PNG reference library - * - * libpng version 1.5.8 - February 1, 2012 - * Copyright (c) 1998-2012 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license (See LICENSE, below) - * - * Authors and maintainers: - * libpng versions 0.71, May 1995, through 0.88, January 1996: Guy Schalnat - * libpng versions 0.89c, June 1996, through 0.96, May 1997: Andreas Dilger - * libpng versions 0.97, January 1998, through 1.5.8 - February 1, 2012: Glenn - * See also "Contributing Authors", below. - * - * Note about libpng version numbers: - * - * Due to various miscommunications, unforeseen code incompatibilities - * and occasional factors outside the authors' control, version numbering - * on the library has not always been consistent and straightforward. - * The following table summarizes matters since version 0.89c, which was - * the first widely used release: - * - * source png.h png.h shared-lib - * version string int version - * ------- ------ ----- ---------- - * 0.89c "1.0 beta 3" 0.89 89 1.0.89 - * 0.90 "1.0 beta 4" 0.90 90 0.90 [should have been 2.0.90] - * 0.95 "1.0 beta 5" 0.95 95 0.95 [should have been 2.0.95] - * 0.96 "1.0 beta 6" 0.96 96 0.96 [should have been 2.0.96] - * 0.97b "1.00.97 beta 7" 1.00.97 97 1.0.1 [should have been 2.0.97] - * 0.97c 0.97 97 2.0.97 - * 0.98 0.98 98 2.0.98 - * 0.99 0.99 98 2.0.99 - * 0.99a-m 0.99 99 2.0.99 - * 1.00 1.00 100 2.1.0 [100 should be 10000] - * 1.0.0 (from here on, the 100 2.1.0 [100 should be 10000] - * 1.0.1 png.h string is 10001 2.1.0 - * 1.0.1a-e identical to the 10002 from here on, the shared library - * 1.0.2 source version) 10002 is 2.V where V is the source code - * 1.0.2a-b 10003 version, except as noted. - * 1.0.3 10003 - * 1.0.3a-d 10004 - * 1.0.4 10004 - * 1.0.4a-f 10005 - * 1.0.5 (+ 2 patches) 10005 - * 1.0.5a-d 10006 - * 1.0.5e-r 10100 (not source compatible) - * 1.0.5s-v 10006 (not binary compatible) - * 1.0.6 (+ 3 patches) 10006 (still binary incompatible) - * 1.0.6d-f 10007 (still binary incompatible) - * 1.0.6g 10007 - * 1.0.6h 10007 10.6h (testing xy.z so-numbering) - * 1.0.6i 10007 10.6i - * 1.0.6j 10007 2.1.0.6j (incompatible with 1.0.0) - * 1.0.7beta11-14 DLLNUM 10007 2.1.0.7beta11-14 (binary compatible) - * 1.0.7beta15-18 1 10007 2.1.0.7beta15-18 (binary compatible) - * 1.0.7rc1-2 1 10007 2.1.0.7rc1-2 (binary compatible) - * 1.0.7 1 10007 (still compatible) - * 1.0.8beta1-4 1 10008 2.1.0.8beta1-4 - * 1.0.8rc1 1 10008 2.1.0.8rc1 - * 1.0.8 1 10008 2.1.0.8 - * 1.0.9beta1-6 1 10009 2.1.0.9beta1-6 - * 1.0.9rc1 1 10009 2.1.0.9rc1 - * 1.0.9beta7-10 1 10009 2.1.0.9beta7-10 - * 1.0.9rc2 1 10009 2.1.0.9rc2 - * 1.0.9 1 10009 2.1.0.9 - * 1.0.10beta1 1 10010 2.1.0.10beta1 - * 1.0.10rc1 1 10010 2.1.0.10rc1 - * 1.0.10 1 10010 2.1.0.10 - * 1.0.11beta1-3 1 10011 2.1.0.11beta1-3 - * 1.0.11rc1 1 10011 2.1.0.11rc1 - * 1.0.11 1 10011 2.1.0.11 - * 1.0.12beta1-2 2 10012 2.1.0.12beta1-2 - * 1.0.12rc1 2 10012 2.1.0.12rc1 - * 1.0.12 2 10012 2.1.0.12 - * 1.1.0a-f - 10100 2.1.1.0a-f (branch abandoned) - * 1.2.0beta1-2 2 10200 2.1.2.0beta1-2 - * 1.2.0beta3-5 3 10200 3.1.2.0beta3-5 - * 1.2.0rc1 3 10200 3.1.2.0rc1 - * 1.2.0 3 10200 3.1.2.0 - * 1.2.1beta1-4 3 10201 3.1.2.1beta1-4 - * 1.2.1rc1-2 3 10201 3.1.2.1rc1-2 - * 1.2.1 3 10201 3.1.2.1 - * 1.2.2beta1-6 12 10202 12.so.0.1.2.2beta1-6 - * 1.0.13beta1 10 10013 10.so.0.1.0.13beta1 - * 1.0.13rc1 10 10013 10.so.0.1.0.13rc1 - * 1.2.2rc1 12 10202 12.so.0.1.2.2rc1 - * 1.0.13 10 10013 10.so.0.1.0.13 - * 1.2.2 12 10202 12.so.0.1.2.2 - * 1.2.3rc1-6 12 10203 12.so.0.1.2.3rc1-6 - * 1.2.3 12 10203 12.so.0.1.2.3 - * 1.2.4beta1-3 13 10204 12.so.0.1.2.4beta1-3 - * 1.0.14rc1 13 10014 10.so.0.1.0.14rc1 - * 1.2.4rc1 13 10204 12.so.0.1.2.4rc1 - * 1.0.14 10 10014 10.so.0.1.0.14 - * 1.2.4 13 10204 12.so.0.1.2.4 - * 1.2.5beta1-2 13 10205 12.so.0.1.2.5beta1-2 - * 1.0.15rc1-3 10 10015 10.so.0.1.0.15rc1-3 - * 1.2.5rc1-3 13 10205 12.so.0.1.2.5rc1-3 - * 1.0.15 10 10015 10.so.0.1.0.15 - * 1.2.5 13 10205 12.so.0.1.2.5 - * 1.2.6beta1-4 13 10206 12.so.0.1.2.6beta1-4 - * 1.0.16 10 10016 10.so.0.1.0.16 - * 1.2.6 13 10206 12.so.0.1.2.6 - * 1.2.7beta1-2 13 10207 12.so.0.1.2.7beta1-2 - * 1.0.17rc1 10 10017 12.so.0.1.0.17rc1 - * 1.2.7rc1 13 10207 12.so.0.1.2.7rc1 - * 1.0.17 10 10017 12.so.0.1.0.17 - * 1.2.7 13 10207 12.so.0.1.2.7 - * 1.2.8beta1-5 13 10208 12.so.0.1.2.8beta1-5 - * 1.0.18rc1-5 10 10018 12.so.0.1.0.18rc1-5 - * 1.2.8rc1-5 13 10208 12.so.0.1.2.8rc1-5 - * 1.0.18 10 10018 12.so.0.1.0.18 - * 1.2.8 13 10208 12.so.0.1.2.8 - * 1.2.9beta1-3 13 10209 12.so.0.1.2.9beta1-3 - * 1.2.9beta4-11 13 10209 12.so.0.9[.0] - * 1.2.9rc1 13 10209 12.so.0.9[.0] - * 1.2.9 13 10209 12.so.0.9[.0] - * 1.2.10beta1-7 13 10210 12.so.0.10[.0] - * 1.2.10rc1-2 13 10210 12.so.0.10[.0] - * 1.2.10 13 10210 12.so.0.10[.0] - * 1.4.0beta1-5 14 10400 14.so.0.0[.0] - * 1.2.11beta1-4 13 10211 12.so.0.11[.0] - * 1.4.0beta7-8 14 10400 14.so.0.0[.0] - * 1.2.11 13 10211 12.so.0.11[.0] - * 1.2.12 13 10212 12.so.0.12[.0] - * 1.4.0beta9-14 14 10400 14.so.0.0[.0] - * 1.2.13 13 10213 12.so.0.13[.0] - * 1.4.0beta15-36 14 10400 14.so.0.0[.0] - * 1.4.0beta37-87 14 10400 14.so.14.0[.0] - * 1.4.0rc01 14 10400 14.so.14.0[.0] - * 1.4.0beta88-109 14 10400 14.so.14.0[.0] - * 1.4.0rc02-08 14 10400 14.so.14.0[.0] - * 1.4.0 14 10400 14.so.14.0[.0] - * 1.4.1beta01-03 14 10401 14.so.14.1[.0] - * 1.4.1rc01 14 10401 14.so.14.1[.0] - * 1.4.1beta04-12 14 10401 14.so.14.1[.0] - * 1.4.1 14 10401 14.so.14.1[.0] - * 1.4.2 14 10402 14.so.14.2[.0] - * 1.4.3 14 10403 14.so.14.3[.0] - * 1.4.4 14 10404 14.so.14.4[.0] - * 1.5.0beta01-58 15 10500 15.so.15.0[.0] - * 1.5.0rc01-07 15 10500 15.so.15.0[.0] - * 1.5.0 15 10500 15.so.15.0[.0] - * 1.5.1beta01-11 15 10501 15.so.15.1[.0] - * 1.5.1rc01-02 15 10501 15.so.15.1[.0] - * 1.5.1 15 10501 15.so.15.1[.0] - * 1.5.2beta01-03 15 10502 15.so.15.2[.0] - * 1.5.2rc01-03 15 10502 15.so.15.2[.0] - * 1.5.2 15 10502 15.so.15.2[.0] - * 1.5.3beta01-10 15 10503 15.so.15.3[.0] - * 1.5.3rc01-02 15 10503 15.so.15.3[.0] - * 1.5.3beta11 15 10503 15.so.15.3[.0] - * 1.5.3 [omitted] - * 1.5.4beta01-08 15 10504 15.so.15.4[.0] - * 1.5.4rc01 15 10504 15.so.15.4[.0] - * 1.5.4 15 10504 15.so.15.4[.0] - * 1.5.5beta01-08 15 10505 15.so.15.5[.0] - * 1.5.5rc01 15 10505 15.so.15.5[.0] - * 1.5.5 15 10505 15.so.15.5[.0] - * 1.5.6beta01-07 15 10506 15.so.15.6[.0] - * 1.5.6rc01-03 15 10506 15.so.15.6[.0] - * 1.5.6 15 10506 15.so.15.6[.0] - * 1.5.7beta01-05 15 10507 15.so.15.7[.0] - * 1.5.7rc01-03 15 10507 15.so.15.7[.0] - * 1.5.7 15 10507 15.so.15.7[.0] - * 1.5.8beta01 15 10508 15.so.15.8[.0] - * 1.5.8rc01 15 10508 15.so.15.8[.0] - * - * Henceforth the source version will match the shared-library major - * and minor numbers; the shared-library major version number will be - * used for changes in backward compatibility, as it is intended. The - * PNG_LIBPNG_VER macro, which is not used within libpng but is available - * for applications, is an unsigned integer of the form xyyzz corresponding - * to the source version x.y.z (leading zeros in y and z). Beta versions - * were given the previous public release number plus a letter, until - * version 1.0.6j; from then on they were given the upcoming public - * release number plus "betaNN" or "rcN". - * - * Binary incompatibility exists only when applications make direct access - * to the info_ptr or png_ptr members through png.h, and the compiled - * application is loaded with a different version of the library. - * - * DLLNUM will change each time there are forward or backward changes - * in binary compatibility (e.g., when a new feature is added). - * - * See libpng-manual.txt or libpng.3 for more information. The PNG - * specification is available as a W3C Recommendation and as an ISO - * Specification, -# endif - - /* Need the time information for converting tIME chunks, it - * defines struct tm: - */ -# ifdef PNG_CONVERT_tIME_SUPPORTED - /* "time.h" functions are not supported on all operating systems */ -# include -# endif -# endif - -/* Machine specific configuration. */ -# include "pngconf.h" -#endif - -/* - * Added at libpng-1.2.8 - * - * Ref MSDN: Private as priority over Special - * VS_FF_PRIVATEBUILD File *was not* built using standard release - * procedures. If this value is given, the StringFileInfo block must - * contain a PrivateBuild string. - * - * VS_FF_SPECIALBUILD File *was* built by the original company using - * standard release procedures but is a variation of the standard - * file of the same version number. If this value is given, the - * StringFileInfo block must contain a SpecialBuild string. - */ - -#ifdef PNG_USER_PRIVATEBUILD /* From pnglibconf.h */ -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_PRIVATE) -#else -# ifdef PNG_LIBPNG_SPECIALBUILD -# define PNG_LIBPNG_BUILD_TYPE \ - (PNG_LIBPNG_BUILD_BASE_TYPE | PNG_LIBPNG_BUILD_SPECIAL) -# else -# define PNG_LIBPNG_BUILD_TYPE (PNG_LIBPNG_BUILD_BASE_TYPE) -# endif -#endif - -#ifndef PNG_VERSION_INFO_ONLY - -/* Inhibit C++ name-mangling for libpng functions but not for system calls. */ -#ifdef __cplusplus -extern "C" { -#endif /* __cplusplus */ - -/* Version information for C files, stored in png.c. This had better match - * the version above. - */ -#define png_libpng_ver png_get_header_ver(NULL) - -/* This file is arranged in several sections: - * - * 1. Any configuration options that can be specified by for the application - * code when it is built. (Build time configuration is in pnglibconf.h) - * 2. Type definitions (base types are defined in pngconf.h), structure - * definitions. - * 3. Exported library functions. - * - * The library source code has additional files (principally pngpriv.h) that - * allow configuration of the library. - */ -/* Section 1: run time configuration - * See pnglibconf.h for build time configuration - * - * Run time configuration allows the application to choose between - * implementations of certain arithmetic APIs. The default is set - * at build time and recorded in pnglibconf.h, but it is safe to - * override these (and only these) settings. Note that this won't - * change what the library does, only application code, and the - * settings can (and probably should) be made on a per-file basis - * by setting the #defines before including png.h - * - * Use macros to read integers from PNG data or use the exported - * functions? - * PNG_USE_READ_MACROS: use the macros (see below) Note that - * the macros evaluate their argument multiple times. - * PNG_NO_USE_READ_MACROS: call the relevant library function. - * - * Use the alternative algorithm for compositing alpha samples that - * does not use division? - * PNG_READ_COMPOSITE_NODIV_SUPPORTED: use the 'no division' - * algorithm. - * PNG_NO_READ_COMPOSITE_NODIV: use the 'division' algorithm. - * - * How to handle benign errors if PNG_ALLOW_BENIGN_ERRORS is - * false? - * PNG_ALLOW_BENIGN_ERRORS: map calls to the benign error - * APIs to png_warning. - * Otherwise the calls are mapped to png_error. - */ - -/* Section 2: type definitions, including structures and compile time - * constants. - * See pngconf.h for base types that vary by machine/system - */ - -/* This triggers a compiler error in png.c, if png.c and png.h - * do not agree upon the version number. - */ -typedef char* png_libpng_version_1_5_8; - -/* Three color definitions. The order of the red, green, and blue, (and the - * exact size) is not important, although the size of the fields need to - * be png_byte or png_uint_16 (as defined below). - */ -typedef struct png_color_struct -{ - png_byte red; - png_byte green; - png_byte blue; -} png_color; -typedef png_color FAR * png_colorp; -typedef PNG_CONST png_color FAR * png_const_colorp; -typedef png_color FAR * FAR * png_colorpp; - -typedef struct png_color_16_struct -{ - png_byte index; /* used for palette files */ - png_uint_16 red; /* for use in red green blue files */ - png_uint_16 green; - png_uint_16 blue; - png_uint_16 gray; /* for use in grayscale files */ -} png_color_16; -typedef png_color_16 FAR * png_color_16p; -typedef PNG_CONST png_color_16 FAR * png_const_color_16p; -typedef png_color_16 FAR * FAR * png_color_16pp; - -typedef struct png_color_8_struct -{ - png_byte red; /* for use in red green blue files */ - png_byte green; - png_byte blue; - png_byte gray; /* for use in grayscale files */ - png_byte alpha; /* for alpha channel files */ -} png_color_8; -typedef png_color_8 FAR * png_color_8p; -typedef PNG_CONST png_color_8 FAR * png_const_color_8p; -typedef png_color_8 FAR * FAR * png_color_8pp; - -/* - * The following two structures are used for the in-core representation - * of sPLT chunks. - */ -typedef struct png_sPLT_entry_struct -{ - png_uint_16 red; - png_uint_16 green; - png_uint_16 blue; - png_uint_16 alpha; - png_uint_16 frequency; -} png_sPLT_entry; -typedef png_sPLT_entry FAR * png_sPLT_entryp; -typedef PNG_CONST png_sPLT_entry FAR * png_const_sPLT_entryp; -typedef png_sPLT_entry FAR * FAR * png_sPLT_entrypp; - -/* When the depth of the sPLT palette is 8 bits, the color and alpha samples - * occupy the LSB of their respective members, and the MSB of each member - * is zero-filled. The frequency member always occupies the full 16 bits. - */ - -typedef struct png_sPLT_struct -{ - png_charp name; /* palette name */ - png_byte depth; /* depth of palette samples */ - png_sPLT_entryp entries; /* palette entries */ - png_int_32 nentries; /* number of palette entries */ -} png_sPLT_t; -typedef png_sPLT_t FAR * png_sPLT_tp; -typedef PNG_CONST png_sPLT_t FAR * png_const_sPLT_tp; -typedef png_sPLT_t FAR * FAR * png_sPLT_tpp; - -#ifdef PNG_TEXT_SUPPORTED -/* png_text holds the contents of a text/ztxt/itxt chunk in a PNG file, - * and whether that contents is compressed or not. The "key" field - * points to a regular zero-terminated C string. The "text" fields can be a - * regular C string, an empty string, or a NULL pointer. - * However, the structure returned by png_get_text() will always contain - * the "text" field as a regular zero-terminated C string (possibly - * empty), never a NULL pointer, so it can be safely used in printf() and - * other string-handling functions. Note that the "itxt_length", "lang", and - * "lang_key" members of the structure only exist when the library is built - * with iTXt chunk support. Prior to libpng-1.4.0 the library was built by - * default without iTXt support. Also note that when iTXt *is* supported, - * the "lang" and "lang_key" fields contain NULL pointers when the - * "compression" field contains * PNG_TEXT_COMPRESSION_NONE or - * PNG_TEXT_COMPRESSION_zTXt. Note that the "compression value" is not the - * same as what appears in the PNG tEXt/zTXt/iTXt chunk's "compression flag" - * which is always 0 or 1, or its "compression method" which is always 0. - */ -typedef struct png_text_struct -{ - int compression; /* compression value: - -1: tEXt, none - 0: zTXt, deflate - 1: iTXt, none - 2: iTXt, deflate */ - png_charp key; /* keyword, 1-79 character description of "text" */ - png_charp text; /* comment, may be an empty string (ie "") - or a NULL pointer */ - png_size_t text_length; /* length of the text string */ - png_size_t itxt_length; /* length of the itxt string */ - png_charp lang; /* language code, 0-79 characters - or a NULL pointer */ - png_charp lang_key; /* keyword translated UTF-8 string, 0 or more - chars or a NULL pointer */ -} png_text; -typedef png_text FAR * png_textp; -typedef PNG_CONST png_text FAR * png_const_textp; -typedef png_text FAR * FAR * png_textpp; -#endif - -/* Supported compression types for text in PNG files (tEXt, and zTXt). - * The values of the PNG_TEXT_COMPRESSION_ defines should NOT be changed. */ -#define PNG_TEXT_COMPRESSION_NONE_WR -3 -#define PNG_TEXT_COMPRESSION_zTXt_WR -2 -#define PNG_TEXT_COMPRESSION_NONE -1 -#define PNG_TEXT_COMPRESSION_zTXt 0 -#define PNG_ITXT_COMPRESSION_NONE 1 -#define PNG_ITXT_COMPRESSION_zTXt 2 -#define PNG_TEXT_COMPRESSION_LAST 3 /* Not a valid value */ - -/* png_time is a way to hold the time in an machine independent way. - * Two conversions are provided, both from time_t and struct tm. There - * is no portable way to convert to either of these structures, as far - * as I know. If you know of a portable way, send it to me. As a side - * note - PNG has always been Year 2000 compliant! - */ -typedef struct png_time_struct -{ - png_uint_16 year; /* full year, as in, 1995 */ - png_byte month; /* month of year, 1 - 12 */ - png_byte day; /* day of month, 1 - 31 */ - png_byte hour; /* hour of day, 0 - 23 */ - png_byte minute; /* minute of hour, 0 - 59 */ - png_byte second; /* second of minute, 0 - 60 (for leap seconds) */ -} png_time; -typedef png_time FAR * png_timep; -typedef PNG_CONST png_time FAR * png_const_timep; -typedef png_time FAR * FAR * png_timepp; - -#if defined(PNG_UNKNOWN_CHUNKS_SUPPORTED) || \ - defined(PNG_HANDLE_AS_UNKNOWN_SUPPORTED) -/* png_unknown_chunk is a structure to hold queued chunks for which there is - * no specific support. The idea is that we can use this to queue - * up private chunks for output even though the library doesn't actually - * know about their semantics. - */ -typedef struct png_unknown_chunk_t -{ - png_byte name[5]; - png_byte *data; - png_size_t size; - - /* libpng-using applications should NOT directly modify this byte. */ - png_byte location; /* mode of operation at read time */ -} - - -png_unknown_chunk; -typedef png_unknown_chunk FAR * png_unknown_chunkp; -typedef PNG_CONST png_unknown_chunk FAR * png_const_unknown_chunkp; -typedef png_unknown_chunk FAR * FAR * png_unknown_chunkpp; -#endif - -/* Values for the unknown chunk location byte */ - -#define PNG_HAVE_IHDR 0x01 -#define PNG_HAVE_PLTE 0x02 -#define PNG_AFTER_IDAT 0x08 - -/* The complete definition of png_info has, as of libpng-1.5.0, - * been moved into a separate header file that is not accessible to - * applications. Read libpng-manual.txt or libpng.3 for more info. - */ -typedef struct png_info_def png_info; -typedef png_info FAR * png_infop; -typedef PNG_CONST png_info FAR * png_const_infop; -typedef png_info FAR * FAR * png_infopp; - -/* Maximum positive integer used in PNG is (2^31)-1 */ -#define PNG_UINT_31_MAX ((png_uint_32)0x7fffffffL) -#define PNG_UINT_32_MAX ((png_uint_32)(-1)) -#define PNG_SIZE_MAX ((png_size_t)(-1)) - -/* These are constants for fixed point values encoded in the - * PNG specification manner (x100000) - */ -#define PNG_FP_1 100000 -#define PNG_FP_HALF 50000 -#define PNG_FP_MAX ((png_fixed_point)0x7fffffffL) -#define PNG_FP_MIN (-PNG_FP_MAX) - -/* These describe the color_type field in png_info. */ -/* color type masks */ -#define PNG_COLOR_MASK_PALETTE 1 -#define PNG_COLOR_MASK_COLOR 2 -#define PNG_COLOR_MASK_ALPHA 4 - -/* color types. Note that not all combinations are legal */ -#define PNG_COLOR_TYPE_GRAY 0 -#define PNG_COLOR_TYPE_PALETTE (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_PALETTE) -#define PNG_COLOR_TYPE_RGB (PNG_COLOR_MASK_COLOR) -#define PNG_COLOR_TYPE_RGB_ALPHA (PNG_COLOR_MASK_COLOR | PNG_COLOR_MASK_ALPHA) -#define PNG_COLOR_TYPE_GRAY_ALPHA (PNG_COLOR_MASK_ALPHA) -/* aliases */ -#define PNG_COLOR_TYPE_RGBA PNG_COLOR_TYPE_RGB_ALPHA -#define PNG_COLOR_TYPE_GA PNG_COLOR_TYPE_GRAY_ALPHA - -/* This is for compression type. PNG 1.0-1.2 only define the single type. */ -#define PNG_COMPRESSION_TYPE_BASE 0 /* Deflate method 8, 32K window */ -#define PNG_COMPRESSION_TYPE_DEFAULT PNG_COMPRESSION_TYPE_BASE - -/* This is for filter type. PNG 1.0-1.2 only define the single type. */ -#define PNG_FILTER_TYPE_BASE 0 /* Single row per-byte filtering */ -#define PNG_INTRAPIXEL_DIFFERENCING 64 /* Used only in MNG datastreams */ -#define PNG_FILTER_TYPE_DEFAULT PNG_FILTER_TYPE_BASE - -/* These are for the interlacing type. These values should NOT be changed. */ -#define PNG_INTERLACE_NONE 0 /* Non-interlaced image */ -#define PNG_INTERLACE_ADAM7 1 /* Adam7 interlacing */ -#define PNG_INTERLACE_LAST 2 /* Not a valid value */ - -/* These are for the oFFs chunk. These values should NOT be changed. */ -#define PNG_OFFSET_PIXEL 0 /* Offset in pixels */ -#define PNG_OFFSET_MICROMETER 1 /* Offset in micrometers (1/10^6 meter) */ -#define PNG_OFFSET_LAST 2 /* Not a valid value */ - -/* These are for the pCAL chunk. These values should NOT be changed. */ -#define PNG_EQUATION_LINEAR 0 /* Linear transformation */ -#define PNG_EQUATION_BASE_E 1 /* Exponential base e transform */ -#define PNG_EQUATION_ARBITRARY 2 /* Arbitrary base exponential transform */ -#define PNG_EQUATION_HYPERBOLIC 3 /* Hyperbolic sine transformation */ -#define PNG_EQUATION_LAST 4 /* Not a valid value */ - -/* These are for the sCAL chunk. These values should NOT be changed. */ -#define PNG_SCALE_UNKNOWN 0 /* unknown unit (image scale) */ -#define PNG_SCALE_METER 1 /* meters per pixel */ -#define PNG_SCALE_RADIAN 2 /* radians per pixel */ -#define PNG_SCALE_LAST 3 /* Not a valid value */ - -/* These are for the pHYs chunk. These values should NOT be changed. */ -#define PNG_RESOLUTION_UNKNOWN 0 /* pixels/unknown unit (aspect ratio) */ -#define PNG_RESOLUTION_METER 1 /* pixels/meter */ -#define PNG_RESOLUTION_LAST 2 /* Not a valid value */ - -/* These are for the sRGB chunk. These values should NOT be changed. */ -#define PNG_sRGB_INTENT_PERCEPTUAL 0 -#define PNG_sRGB_INTENT_RELATIVE 1 -#define PNG_sRGB_INTENT_SATURATION 2 -#define PNG_sRGB_INTENT_ABSOLUTE 3 -#define PNG_sRGB_INTENT_LAST 4 /* Not a valid value */ - -/* This is for text chunks */ -#define PNG_KEYWORD_MAX_LENGTH 79 - -/* Maximum number of entries in PLTE/sPLT/tRNS arrays */ -#define PNG_MAX_PALETTE_LENGTH 256 - -/* These determine if an ancillary chunk's data has been successfully read - * from the PNG header, or if the application has filled in the corresponding - * data in the info_struct to be written into the output file. The values - * of the PNG_INFO_ defines should NOT be changed. - */ -#define PNG_INFO_gAMA 0x0001 -#define PNG_INFO_sBIT 0x0002 -#define PNG_INFO_cHRM 0x0004 -#define PNG_INFO_PLTE 0x0008 -#define PNG_INFO_tRNS 0x0010 -#define PNG_INFO_bKGD 0x0020 -#define PNG_INFO_hIST 0x0040 -#define PNG_INFO_pHYs 0x0080 -#define PNG_INFO_oFFs 0x0100 -#define PNG_INFO_tIME 0x0200 -#define PNG_INFO_pCAL 0x0400 -#define PNG_INFO_sRGB 0x0800 /* GR-P, 0.96a */ -#define PNG_INFO_iCCP 0x1000 /* ESR, 1.0.6 */ -#define PNG_INFO_sPLT 0x2000 /* ESR, 1.0.6 */ -#define PNG_INFO_sCAL 0x4000 /* ESR, 1.0.6 */ -#define PNG_INFO_IDAT 0x8000 /* ESR, 1.0.6 */ - -/* This is used for the transformation routines, as some of them - * change these values for the row. It also should enable using - * the routines for other purposes. - */ -typedef struct png_row_info_struct -{ - png_uint_32 width; /* width of row */ - png_size_t rowbytes; /* number of bytes in row */ - png_byte color_type; /* color type of row */ - png_byte bit_depth; /* bit depth of row */ - png_byte channels; /* number of channels (1, 2, 3, or 4) */ - png_byte pixel_depth; /* bits per pixel (depth * channels) */ -} png_row_info; - -typedef png_row_info FAR * png_row_infop; -typedef png_row_info FAR * FAR * png_row_infopp; - -/* The complete definition of png_struct has, as of libpng-1.5.0, - * been moved into a separate header file that is not accessible to - * applications. Read libpng-manual.txt or libpng.3 for more info. - */ -typedef struct png_struct_def png_struct; -typedef PNG_CONST png_struct FAR * png_const_structp; -typedef png_struct FAR * png_structp; - -/* These are the function types for the I/O functions and for the functions - * that allow the user to override the default I/O functions with his or her - * own. The png_error_ptr type should match that of user-supplied warning - * and error functions, while the png_rw_ptr type should match that of the - * user read/write data functions. Note that the 'write' function must not - * modify the buffer it is passed. The 'read' function, on the other hand, is - * expected to return the read data in the buffer. - */ -typedef PNG_CALLBACK(void, *png_error_ptr, (png_structp, png_const_charp)); -typedef PNG_CALLBACK(void, *png_rw_ptr, (png_structp, png_bytep, png_size_t)); -typedef PNG_CALLBACK(void, *png_flush_ptr, (png_structp)); -typedef PNG_CALLBACK(void, *png_read_status_ptr, (png_structp, png_uint_32, - int)); -typedef PNG_CALLBACK(void, *png_write_status_ptr, (png_structp, png_uint_32, - int)); - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -typedef PNG_CALLBACK(void, *png_progressive_info_ptr, (png_structp, png_infop)); -typedef PNG_CALLBACK(void, *png_progressive_end_ptr, (png_structp, png_infop)); - -/* The following callback receives png_uint_32 row_number, int pass for the - * png_bytep data of the row. When transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -typedef PNG_CALLBACK(void, *png_progressive_row_ptr, (png_structp, png_bytep, - png_uint_32, int)); -#endif - -#if defined(PNG_READ_USER_TRANSFORM_SUPPORTED) || \ - defined(PNG_WRITE_USER_TRANSFORM_SUPPORTED) -typedef PNG_CALLBACK(void, *png_user_transform_ptr, (png_structp, png_row_infop, - png_bytep)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -typedef PNG_CALLBACK(int, *png_user_chunk_ptr, (png_structp, - png_unknown_chunkp)); -#endif -#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -typedef PNG_CALLBACK(void, *png_unknown_chunk_ptr, (png_structp)); -#endif - -#ifdef PNG_SETJMP_SUPPORTED -/* This must match the function definition in , and the application - * must include this before png.h to obtain the definition of jmp_buf. The - * function is required to be PNG_NORETURN, but this is not checked. If the - * function does return the application will crash via an abort() or similar - * system level call. - * - * If you get a warning here while building the library you may need to make - * changes to ensure that pnglibconf.h records the calling convention used by - * your compiler. This may be very difficult - try using a different compiler - * to build the library! - */ -PNG_FUNCTION(void, (PNGCAPI *png_longjmp_ptr), PNGARG((jmp_buf, int)), typedef); -#endif - -/* Transform masks for the high-level interface */ -#define PNG_TRANSFORM_IDENTITY 0x0000 /* read and write */ -#define PNG_TRANSFORM_STRIP_16 0x0001 /* read only */ -#define PNG_TRANSFORM_STRIP_ALPHA 0x0002 /* read only */ -#define PNG_TRANSFORM_PACKING 0x0004 /* read and write */ -#define PNG_TRANSFORM_PACKSWAP 0x0008 /* read and write */ -#define PNG_TRANSFORM_EXPAND 0x0010 /* read only */ -#define PNG_TRANSFORM_INVERT_MONO 0x0020 /* read and write */ -#define PNG_TRANSFORM_SHIFT 0x0040 /* read and write */ -#define PNG_TRANSFORM_BGR 0x0080 /* read and write */ -#define PNG_TRANSFORM_SWAP_ALPHA 0x0100 /* read and write */ -#define PNG_TRANSFORM_SWAP_ENDIAN 0x0200 /* read and write */ -#define PNG_TRANSFORM_INVERT_ALPHA 0x0400 /* read and write */ -#define PNG_TRANSFORM_STRIP_FILLER 0x0800 /* write only */ -/* Added to libpng-1.2.34 */ -#define PNG_TRANSFORM_STRIP_FILLER_BEFORE PNG_TRANSFORM_STRIP_FILLER -#define PNG_TRANSFORM_STRIP_FILLER_AFTER 0x1000 /* write only */ -/* Added to libpng-1.4.0 */ -#define PNG_TRANSFORM_GRAY_TO_RGB 0x2000 /* read only */ -/* Added to libpng-1.5.4 */ -#define PNG_TRANSFORM_EXPAND_16 0x4000 /* read only */ -#define PNG_TRANSFORM_SCALE_16 0x8000 /* read only */ - -/* Flags for MNG supported features */ -#define PNG_FLAG_MNG_EMPTY_PLTE 0x01 -#define PNG_FLAG_MNG_FILTER_64 0x04 -#define PNG_ALL_MNG_FEATURES 0x05 - -/* NOTE: prior to 1.5 these functions had no 'API' style declaration, - * this allowed the zlib default functions to be used on Windows - * platforms. In 1.5 the zlib default malloc (which just calls malloc and - * ignores the first argument) should be completely compatible with the - * following. - */ -typedef PNG_CALLBACK(png_voidp, *png_malloc_ptr, (png_structp, - png_alloc_size_t)); -typedef PNG_CALLBACK(void, *png_free_ptr, (png_structp, png_voidp)); - -typedef png_struct FAR * FAR * png_structpp; - -/* Section 3: exported functions - * Here are the function definitions most commonly used. This is not - * the place to find out how to use libpng. See libpng-manual.txt for the - * full explanation, see example.c for the summary. This just provides - * a simple one line description of the use of each function. - * - * The PNG_EXPORT() and PNG_EXPORTA() macros used below are defined in - * pngconf.h and in the *.dfn files in the scripts directory. - * - * PNG_EXPORT(ordinal, type, name, (args)); - * - * ordinal: ordinal that is used while building - * *.def files. The ordinal value is only - * relevant when preprocessing png.h with - * the *.dfn files for building symbol table - * entries, and are removed by pngconf.h. - * type: return type of the function - * name: function name - * args: function arguments, with types - * - * When we wish to append attributes to a function prototype we use - * the PNG_EXPORTA() macro instead. - * - * PNG_EXPORTA(ordinal, type, name, (args), attributes); - * - * ordinal, type, name, and args: same as in PNG_EXPORT(). - * attributes: function attributes - */ - -/* Returns the version number of the library */ -PNG_EXPORT(1, png_uint_32, png_access_version_number, (void)); - -/* Tell lib we have already handled the first magic bytes. - * Handling more than 8 bytes from the beginning of the file is an error. - */ -PNG_EXPORT(2, void, png_set_sig_bytes, (png_structp png_ptr, int num_bytes)); - -/* Check sig[start] through sig[start + num_to_check - 1] to see if it's a - * PNG file. Returns zero if the supplied bytes match the 8-byte PNG - * signature, and non-zero otherwise. Having num_to_check == 0 or - * start > 7 will always fail (ie return non-zero). - */ -PNG_EXPORT(3, int, png_sig_cmp, (png_const_bytep sig, png_size_t start, - png_size_t num_to_check)); - -/* Simple signature checking function. This is the same as calling - * png_check_sig(sig, n) := !png_sig_cmp(sig, 0, n). - */ -#define png_check_sig(sig, n) !png_sig_cmp((sig), 0, (n)) - -/* Allocate and initialize png_ptr struct for reading, and any other memory. */ -PNG_EXPORTA(4, png_structp, png_create_read_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warn_fn), - PNG_ALLOCATED); - -/* Allocate and initialize png_ptr struct for writing, and any other memory */ -PNG_EXPORTA(5, png_structp, png_create_write_struct, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn), - PNG_ALLOCATED); - -PNG_EXPORT(6, png_size_t, png_get_compression_buffer_size, - (png_const_structp png_ptr)); - -PNG_EXPORT(7, void, png_set_compression_buffer_size, (png_structp png_ptr, - png_size_t size)); - -/* Moved from pngconf.h in 1.4.0 and modified to ensure setjmp/longjmp - * match up. - */ -#ifdef PNG_SETJMP_SUPPORTED -/* This function returns the jmp_buf built in to *png_ptr. It must be - * supplied with an appropriate 'longjmp' function to use on that jmp_buf - * unless the default error function is overridden in which case NULL is - * acceptable. The size of the jmp_buf is checked against the actual size - * allocated by the library - the call will return NULL on a mismatch - * indicating an ABI mismatch. - */ -PNG_EXPORT(8, jmp_buf*, png_set_longjmp_fn, (png_structp png_ptr, - png_longjmp_ptr longjmp_fn, size_t jmp_buf_size)); -# define png_jmpbuf(png_ptr) \ - (*png_set_longjmp_fn((png_ptr), longjmp, sizeof (jmp_buf))) -#else -# define png_jmpbuf(png_ptr) \ - (LIBPNG_WAS_COMPILED_WITH__PNG_NO_SETJMP) -#endif -/* This function should be used by libpng applications in place of - * longjmp(png_ptr->jmpbuf, val). If longjmp_fn() has been set, it - * will use it; otherwise it will call PNG_ABORT(). This function was - * added in libpng-1.5.0. - */ -PNG_EXPORTA(9, void, png_longjmp, (png_structp png_ptr, int val), - PNG_NORETURN); - -#ifdef PNG_READ_SUPPORTED -/* Reset the compression stream */ -PNG_EXPORT(10, int, png_reset_zstream, (png_structp png_ptr)); -#endif - -/* New functions added in libpng-1.0.2 (not enabled by default until 1.2.0) */ -#ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(11, png_structp, png_create_read_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -PNG_EXPORTA(12, png_structp, png_create_write_struct_2, - (png_const_charp user_png_ver, png_voidp error_ptr, png_error_ptr error_fn, - png_error_ptr warn_fn, - png_voidp mem_ptr, png_malloc_ptr malloc_fn, png_free_ptr free_fn), - PNG_ALLOCATED); -#endif - -/* Write the PNG file signature. */ -PNG_EXPORT(13, void, png_write_sig, (png_structp png_ptr)); - -/* Write a PNG chunk - size, type, (optional) data, CRC. */ -PNG_EXPORT(14, void, png_write_chunk, (png_structp png_ptr, png_const_bytep - chunk_name, png_const_bytep data, png_size_t length)); - -/* Write the start of a PNG chunk - length and chunk name. */ -PNG_EXPORT(15, void, png_write_chunk_start, (png_structp png_ptr, - png_const_bytep chunk_name, png_uint_32 length)); - -/* Write the data of a PNG chunk started with png_write_chunk_start(). */ -PNG_EXPORT(16, void, png_write_chunk_data, (png_structp png_ptr, - png_const_bytep data, png_size_t length)); - -/* Finish a chunk started with png_write_chunk_start() (includes CRC). */ -PNG_EXPORT(17, void, png_write_chunk_end, (png_structp png_ptr)); - -/* Allocate and initialize the info structure */ -PNG_EXPORTA(18, png_infop, png_create_info_struct, (png_structp png_ptr), - PNG_ALLOCATED); - -PNG_EXPORT(19, void, png_info_init_3, (png_infopp info_ptr, - png_size_t png_info_struct_size)); - -/* Writes all the PNG information before the image. */ -PNG_EXPORT(20, void, png_write_info_before_PLTE, - (png_structp png_ptr, png_infop info_ptr)); -PNG_EXPORT(21, void, png_write_info, - (png_structp png_ptr, png_infop info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the information before the actual image data. */ -PNG_EXPORT(22, void, png_read_info, - (png_structp png_ptr, png_infop info_ptr)); -#endif - -#ifdef PNG_TIME_RFC1123_SUPPORTED -PNG_EXPORT(23, png_const_charp, png_convert_to_rfc1123, - (png_structp png_ptr, - png_const_timep ptime)); -#endif - -#ifdef PNG_CONVERT_tIME_SUPPORTED -/* Convert from a struct tm to png_time */ -PNG_EXPORT(24, void, png_convert_from_struct_tm, (png_timep ptime, - PNG_CONST struct tm FAR * ttime)); - -/* Convert from time_t to png_time. Uses gmtime() */ -PNG_EXPORT(25, void, png_convert_from_time_t, - (png_timep ptime, time_t ttime)); -#endif /* PNG_CONVERT_tIME_SUPPORTED */ - -#ifdef PNG_READ_EXPAND_SUPPORTED -/* Expand data to 24-bit RGB, or 8-bit grayscale, with alpha if available. */ -PNG_EXPORT(26, void, png_set_expand, (png_structp png_ptr)); -PNG_EXPORT(27, void, png_set_expand_gray_1_2_4_to_8, (png_structp png_ptr)); -PNG_EXPORT(28, void, png_set_palette_to_rgb, (png_structp png_ptr)); -PNG_EXPORT(29, void, png_set_tRNS_to_alpha, (png_structp png_ptr)); -#endif - -#ifdef PNG_READ_EXPAND_16_SUPPORTED -/* Expand to 16-bit channels, forces conversion of palette to RGB and expansion - * of a tRNS chunk if present. - */ -PNG_EXPORT(221, void, png_set_expand_16, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_BGR_SUPPORTED) || defined(PNG_WRITE_BGR_SUPPORTED) -/* Use blue, green, red order for pixels. */ -PNG_EXPORT(30, void, png_set_bgr, (png_structp png_ptr)); -#endif - -#ifdef PNG_READ_GRAY_TO_RGB_SUPPORTED -/* Expand the grayscale to 24-bit RGB if necessary. */ -PNG_EXPORT(31, void, png_set_gray_to_rgb, (png_structp png_ptr)); -#endif - -#ifdef PNG_READ_RGB_TO_GRAY_SUPPORTED -/* Reduce RGB to grayscale. */ -#define PNG_ERROR_ACTION_NONE 1 -#define PNG_ERROR_ACTION_WARN 2 -#define PNG_ERROR_ACTION_ERROR 3 -#define PNG_RGB_TO_GRAY_DEFAULT (-1)/*for red/green coefficients*/ - -PNG_FP_EXPORT(32, void, png_set_rgb_to_gray, (png_structp png_ptr, - int error_action, double red, double green)); -PNG_FIXED_EXPORT(33, void, png_set_rgb_to_gray_fixed, (png_structp png_ptr, - int error_action, png_fixed_point red, png_fixed_point green)); - -PNG_EXPORT(34, png_byte, png_get_rgb_to_gray_status, (png_const_structp - png_ptr)); -#endif - -#ifdef PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -PNG_EXPORT(35, void, png_build_grayscale_palette, (int bit_depth, - png_colorp palette)); -#endif - -#ifdef PNG_READ_ALPHA_MODE_SUPPORTED -/* How the alpha channel is interpreted - this affects how the color channels of - * a PNG file are returned when an alpha channel, or tRNS chunk in a palette - * file, is present. - * - * This has no effect on the way pixels are written into a PNG output - * datastream. The color samples in a PNG datastream are never premultiplied - * with the alpha samples. - * - * The default is to return data according to the PNG specification: the alpha - * channel is a linear measure of the contribution of the pixel to the - * corresponding composited pixel. The gamma encoded color channels must be - * scaled according to the contribution and to do this it is necessary to undo - * the encoding, scale the color values, perform the composition and reencode - * the values. This is the 'PNG' mode. - * - * The alternative is to 'associate' the alpha with the color information by - * storing color channel values that have been scaled by the alpha. The - * advantage is that the color channels can be resampled (the image can be - * scaled) in this form. The disadvantage is that normal practice is to store - * linear, not (gamma) encoded, values and this requires 16-bit channels for - * still images rather than the 8-bit channels that are just about sufficient if - * gamma encoding is used. In addition all non-transparent pixel values, - * including completely opaque ones, must be gamma encoded to produce the final - * image. This is the 'STANDARD', 'ASSOCIATED' or 'PREMULTIPLIED' mode (the - * latter being the two common names for associated alpha color channels.) - * - * Since it is not necessary to perform arithmetic on opaque color values so - * long as they are not to be resampled and are in the final color space it is - * possible to optimize the handling of alpha by storing the opaque pixels in - * the PNG format (adjusted for the output color space) while storing partially - * opaque pixels in the standard, linear, format. The accuracy required for - * standard alpha composition is relatively low, because the pixels are - * isolated, therefore typically the accuracy loss in storing 8-bit linear - * values is acceptable. (This is not true if the alpha channel is used to - * simulate transparency over large areas - use 16 bits or the PNG mode in - * this case!) This is the 'OPTIMIZED' mode. For this mode a pixel is - * treated as opaque only if the alpha value is equal to the maximum value. - * - * The final choice is to gamma encode the alpha channel as well. This is - * broken because, in practice, no implementation that uses this choice - * correctly undoes the encoding before handling alpha composition. Use this - * choice only if other serious errors in the software or hardware you use - * mandate it; the typical serious error is for dark halos to appear around - * opaque areas of the composited PNG image because of arithmetic overflow. - * - * The API function png_set_alpha_mode specifies which of these choices to use - * with an enumerated 'mode' value and the gamma of the required output: - */ -#define PNG_ALPHA_PNG 0 /* according to the PNG standard */ -#define PNG_ALPHA_STANDARD 1 /* according to Porter/Duff */ -#define PNG_ALPHA_ASSOCIATED 1 /* as above; this is the normal practice */ -#define PNG_ALPHA_PREMULTIPLIED 1 /* as above */ -#define PNG_ALPHA_OPTIMIZED 2 /* 'PNG' for opaque pixels, else 'STANDARD' */ -#define PNG_ALPHA_BROKEN 3 /* the alpha channel is gamma encoded */ - -PNG_FP_EXPORT(227, void, png_set_alpha_mode, (png_structp png_ptr, int mode, - double output_gamma)); -PNG_FIXED_EXPORT(228, void, png_set_alpha_mode_fixed, (png_structp png_ptr, - int mode, png_fixed_point output_gamma)); -#endif - -#if defined(PNG_READ_GAMMA_SUPPORTED) || defined(PNG_READ_ALPHA_MODE_SUPPORTED) -/* The output_gamma value is a screen gamma in libpng terminology: it expresses - * how to decode the output values, not how they are encoded. The values used - * correspond to the normal numbers used to describe the overall gamma of a - * computer display system; for example 2.2 for an sRGB conformant system. The - * values are scaled by 100000 in the _fixed version of the API (so 220000 for - * sRGB.) - * - * The inverse of the value is always used to provide a default for the PNG file - * encoding if it has no gAMA chunk and if png_set_gamma() has not been called - * to override the PNG gamma information. - * - * When the ALPHA_OPTIMIZED mode is selected the output gamma is used to encode - * opaque pixels however pixels with lower alpha values are not encoded, - * regardless of the output gamma setting. - * - * When the standard Porter Duff handling is requested with mode 1 the output - * encoding is set to be linear and the output_gamma value is only relevant - * as a default for input data that has no gamma information. The linear output - * encoding will be overridden if png_set_gamma() is called - the results may be - * highly unexpected! - * - * The following numbers are derived from the sRGB standard and the research - * behind it. sRGB is defined to be approximated by a PNG gAMA chunk value of - * 0.45455 (1/2.2) for PNG. The value implicitly includes any viewing - * correction required to take account of any differences in the color - * environment of the original scene and the intended display environment; the - * value expresses how to *decode* the image for display, not how the original - * data was *encoded*. - * - * sRGB provides a peg for the PNG standard by defining a viewing environment. - * sRGB itself, and earlier TV standards, actually use a more complex transform - * (a linear portion then a gamma 2.4 power law) than PNG can express. (PNG is - * limited to simple power laws.) By saying that an image for direct display on - * an sRGB conformant system should be stored with a gAMA chunk value of 45455 - * (11.3.3.2 and 11.3.3.5 of the ISO PNG specification) the PNG specification - * makes it possible to derive values for other display systems and - * environments. - * - * The Mac value is deduced from the sRGB based on an assumption that the actual - * extra viewing correction used in early Mac display systems was implemented as - * a power 1.45 lookup table. - * - * Any system where a programmable lookup table is used or where the behavior of - * the final display device characteristics can be changed requires system - * specific code to obtain the current characteristic. However this can be - * difficult and most PNG gamma correction only requires an approximate value. - * - * By default, if png_set_alpha_mode() is not called, libpng assumes that all - * values are unencoded, linear, values and that the output device also has a - * linear characteristic. This is only very rarely correct - it is invariably - * better to call png_set_alpha_mode() with PNG_DEFAULT_sRGB than rely on the - * default if you don't know what the right answer is! - * - * The special value PNG_GAMMA_MAC_18 indicates an older Mac system (pre Mac OS - * 10.6) which used a correction table to implement a somewhat lower gamma on an - * otherwise sRGB system. - * - * Both these values are reserved (not simple gamma values) in order to allow - * more precise correction internally in the future. - * - * NOTE: the following values can be passed to either the fixed or floating - * point APIs, but the floating point API will also accept floating point - * values. - */ -#define PNG_DEFAULT_sRGB -1 /* sRGB gamma and color space */ -#define PNG_GAMMA_MAC_18 -2 /* Old Mac '1.8' gamma and color space */ -#define PNG_GAMMA_sRGB 220000 /* Television standards--matches sRGB gamma */ -#define PNG_GAMMA_LINEAR PNG_FP_1 /* Linear */ -#endif - -/* The following are examples of calls to png_set_alpha_mode to achieve the - * required overall gamma correction and, where necessary, alpha - * premultiplication. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * This is the default libpng handling of the alpha channel - it is not - * pre-multiplied into the color components. In addition the call states - * that the output is for a sRGB system and causes all PNG files without gAMA - * chunks to be assumed to be encoded using sRGB. - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * In this case the output is assumed to be something like an sRGB conformant - * display preceeded by a power-law lookup table of power 1.45. This is how - * early Mac systems behaved. - * - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_GAMMA_LINEAR); - * This is the classic Jim Blinn approach and will work in academic - * environments where everything is done by the book. It has the shortcoming - * of assuming that input PNG data with no gamma information is linear - this - * is unlikely to be correct unless the PNG files where generated locally. - * Most of the time the output precision will be so low as to show - * significant banding in dark areas of the image. - * - * png_set_expand_16(pp); - * png_set_alpha_mode(pp, PNG_ALPHA_STANDARD, PNG_DEFAULT_sRGB); - * This is a somewhat more realistic Jim Blinn inspired approach. PNG files - * are assumed to have the sRGB encoding if not marked with a gamma value and - * the output is always 16 bits per component. This permits accurate scaling - * and processing of the data. If you know that your input PNG files were - * generated locally you might need to replace PNG_DEFAULT_sRGB with the - * correct value for your system. - * - * png_set_alpha_mode(pp, PNG_ALPHA_OPTIMIZED, PNG_DEFAULT_sRGB); - * If you just need to composite the PNG image onto an existing background - * and if you control the code that does this you can use the optimization - * setting. In this case you just copy completely opaque pixels to the - * output. For pixels that are not completely transparent (you just skip - * those) you do the composition math using png_composite or png_composite_16 - * below then encode the resultant 8-bit or 16-bit values to match the output - * encoding. - * - * Other cases - * If neither the PNG nor the standard linear encoding work for you because - * of the software or hardware you use then you have a big problem. The PNG - * case will probably result in halos around the image. The linear encoding - * will probably result in a washed out, too bright, image (it's actually too - * contrasty.) Try the ALPHA_OPTIMIZED mode above - this will probably - * substantially reduce the halos. Alternatively try: - * - * png_set_alpha_mode(pp, PNG_ALPHA_BROKEN, PNG_DEFAULT_sRGB); - * This option will also reduce the halos, but there will be slight dark - * halos round the opaque parts of the image where the background is light. - * In the OPTIMIZED mode the halos will be light halos where the background - * is dark. Take your pick - the halos are unavoidable unless you can get - * your hardware/software fixed! (The OPTIMIZED approach is slightly - * faster.) - * - * When the default gamma of PNG files doesn't match the output gamma. - * If you have PNG files with no gamma information png_set_alpha_mode allows - * you to provide a default gamma, but it also sets the ouput gamma to the - * matching value. If you know your PNG files have a gamma that doesn't - * match the output you can take advantage of the fact that - * png_set_alpha_mode always sets the output gamma but only sets the PNG - * default if it is not already set: - * - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_DEFAULT_sRGB); - * png_set_alpha_mode(pp, PNG_ALPHA_PNG, PNG_GAMMA_MAC); - * The first call sets both the default and the output gamma values, the - * second call overrides the output gamma without changing the default. This - * is easier than achieving the same effect with png_set_gamma. You must use - * PNG_ALPHA_PNG for the first call - internal checking in png_set_alpha will - * fire if more than one call to png_set_alpha_mode and png_set_background is - * made in the same read operation, however multiple calls with PNG_ALPHA_PNG - * are ignored. - */ - -#ifdef PNG_READ_STRIP_ALPHA_SUPPORTED -PNG_EXPORT(36, void, png_set_strip_alpha, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SWAP_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_SWAP_ALPHA_SUPPORTED) -PNG_EXPORT(37, void, png_set_swap_alpha, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_ALPHA_SUPPORTED) || \ - defined(PNG_WRITE_INVERT_ALPHA_SUPPORTED) -PNG_EXPORT(38, void, png_set_invert_alpha, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_FILLER_SUPPORTED) || defined(PNG_WRITE_FILLER_SUPPORTED) -/* Add a filler byte to 8-bit Gray or 24-bit RGB images. */ -PNG_EXPORT(39, void, png_set_filler, (png_structp png_ptr, png_uint_32 filler, - int flags)); -/* The values of the PNG_FILLER_ defines should NOT be changed */ -# define PNG_FILLER_BEFORE 0 -# define PNG_FILLER_AFTER 1 -/* Add an alpha byte to 8-bit Gray or 24-bit RGB images. */ -PNG_EXPORT(40, void, png_set_add_alpha, - (png_structp png_ptr, png_uint_32 filler, - int flags)); -#endif /* PNG_READ_FILLER_SUPPORTED || PNG_WRITE_FILLER_SUPPORTED */ - -#if defined(PNG_READ_SWAP_SUPPORTED) || defined(PNG_WRITE_SWAP_SUPPORTED) -/* Swap bytes in 16-bit depth files. */ -PNG_EXPORT(41, void, png_set_swap, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACK_SUPPORTED) || defined(PNG_WRITE_PACK_SUPPORTED) -/* Use 1 byte per pixel in 1, 2, or 4-bit depth files. */ -PNG_EXPORT(42, void, png_set_packing, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_PACKSWAP_SUPPORTED) || \ - defined(PNG_WRITE_PACKSWAP_SUPPORTED) -/* Swap packing order of pixels in bytes. */ -PNG_EXPORT(43, void, png_set_packswap, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_SHIFT_SUPPORTED) || defined(PNG_WRITE_SHIFT_SUPPORTED) -/* Converts files to legal bit depths. */ -PNG_EXPORT(44, void, png_set_shift, (png_structp png_ptr, png_const_color_8p - true_bits)); -#endif - -#if defined(PNG_READ_INTERLACING_SUPPORTED) || \ - defined(PNG_WRITE_INTERLACING_SUPPORTED) -/* Have the code handle the interlacing. Returns the number of passes. - * MUST be called before png_read_update_info or png_start_read_image, - * otherwise it will not have the desired effect. Note that it is still - * necessary to call png_read_row or png_read_rows png_get_image_height - * times for each pass. -*/ -PNG_EXPORT(45, int, png_set_interlace_handling, (png_structp png_ptr)); -#endif - -#if defined(PNG_READ_INVERT_SUPPORTED) || defined(PNG_WRITE_INVERT_SUPPORTED) -/* Invert monochrome files */ -PNG_EXPORT(46, void, png_set_invert_mono, (png_structp png_ptr)); -#endif - -#ifdef PNG_READ_BACKGROUND_SUPPORTED -/* Handle alpha and tRNS by replacing with a background color. Prior to - * libpng-1.5.4 this API must not be called before the PNG file header has been - * read. Doing so will result in unexpected behavior and possible warnings or - * errors if the PNG file contains a bKGD chunk. - */ -PNG_FP_EXPORT(47, void, png_set_background, (png_structp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, double background_gamma)); -PNG_FIXED_EXPORT(215, void, png_set_background_fixed, (png_structp png_ptr, - png_const_color_16p background_color, int background_gamma_code, - int need_expand, png_fixed_point background_gamma)); -#endif -#ifdef PNG_READ_BACKGROUND_SUPPORTED -# define PNG_BACKGROUND_GAMMA_UNKNOWN 0 -# define PNG_BACKGROUND_GAMMA_SCREEN 1 -# define PNG_BACKGROUND_GAMMA_FILE 2 -# define PNG_BACKGROUND_GAMMA_UNIQUE 3 -#endif - -#ifdef PNG_READ_SCALE_16_TO_8_SUPPORTED -/* Scale a 16-bit depth file down to 8-bit, accurately. */ -PNG_EXPORT(229, void, png_set_scale_16, (png_structp png_ptr)); -#endif - -#ifdef PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_16_TO_8 SUPPORTED /* Name prior to 1.5.4 */ -/* Strip the second byte of information from a 16-bit depth file. */ -PNG_EXPORT(48, void, png_set_strip_16, (png_structp png_ptr)); -#endif - -#ifdef PNG_READ_QUANTIZE_SUPPORTED -/* Turn on quantizing, and reduce the palette to the number of colors - * available. - */ -PNG_EXPORT(49, void, png_set_quantize, - (png_structp png_ptr, png_colorp palette, - int num_palette, int maximum_colors, png_const_uint_16p histogram, - int full_quantize)); -#endif - -#ifdef PNG_READ_GAMMA_SUPPORTED -/* The threshold on gamma processing is configurable but hard-wired into the - * library. The following is the floating point variant. - */ -#define PNG_GAMMA_THRESHOLD (PNG_GAMMA_THRESHOLD_FIXED*.00001) - -/* Handle gamma correction. Screen_gamma=(display_exponent). - * NOTE: this API simply sets the screen and file gamma values. It will - * therefore override the value for gamma in a PNG file if it is called after - * the file header has been read - use with care - call before reading the PNG - * file for best results! - * - * These routines accept the same gamma values as png_set_alpha_mode (described - * above). The PNG_GAMMA_ defines and PNG_DEFAULT_sRGB can be passed to either - * API (floating point or fixed.) Notice, however, that the 'file_gamma' value - * is the inverse of a 'screen gamma' value. - */ -PNG_FP_EXPORT(50, void, png_set_gamma, - (png_structp png_ptr, double screen_gamma, - double override_file_gamma)); -PNG_FIXED_EXPORT(208, void, png_set_gamma_fixed, (png_structp png_ptr, - png_fixed_point screen_gamma, png_fixed_point override_file_gamma)); -#endif - -#ifdef PNG_WRITE_FLUSH_SUPPORTED -/* Set how many lines between output flushes - 0 for no flushing */ -PNG_EXPORT(51, void, png_set_flush, (png_structp png_ptr, int nrows)); -/* Flush the current PNG output buffer */ -PNG_EXPORT(52, void, png_write_flush, (png_structp png_ptr)); -#endif - -/* Optional update palette with requested transformations */ -PNG_EXPORT(53, void, png_start_read_image, (png_structp png_ptr)); - -/* Optional call to update the users info structure */ -PNG_EXPORT(54, void, png_read_update_info, - (png_structp png_ptr, png_infop info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read one or more rows of image data. */ -PNG_EXPORT(55, void, png_read_rows, (png_structp png_ptr, png_bytepp row, - png_bytepp display_row, png_uint_32 num_rows)); -#endif - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read a row of data. */ -PNG_EXPORT(56, void, png_read_row, (png_structp png_ptr, png_bytep row, - png_bytep display_row)); -#endif - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the whole image into memory at once. */ -PNG_EXPORT(57, void, png_read_image, (png_structp png_ptr, png_bytepp image)); -#endif - -/* Write a row of image data */ -PNG_EXPORT(58, void, png_write_row, - (png_structp png_ptr, png_const_bytep row)); - -/* Write a few rows of image data: (*row) is not written; however, the type - * is declared as writeable to maintain compatibility with previous versions - * of libpng and to allow the 'display_row' array from read_rows to be passed - * unchanged to write_rows. - */ -PNG_EXPORT(59, void, png_write_rows, (png_structp png_ptr, png_bytepp row, - png_uint_32 num_rows)); - -/* Write the image data */ -PNG_EXPORT(60, void, png_write_image, - (png_structp png_ptr, png_bytepp image)); - -/* Write the end of the PNG file. */ -PNG_EXPORT(61, void, png_write_end, - (png_structp png_ptr, png_infop info_ptr)); - -#ifdef PNG_SEQUENTIAL_READ_SUPPORTED -/* Read the end of the PNG file. */ -PNG_EXPORT(62, void, png_read_end, (png_structp png_ptr, png_infop info_ptr)); -#endif - -/* Free any memory associated with the png_info_struct */ -PNG_EXPORT(63, void, png_destroy_info_struct, (png_structp png_ptr, - png_infopp info_ptr_ptr)); - -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(64, void, png_destroy_read_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr, png_infopp end_info_ptr_ptr)); - -/* Free any memory associated with the png_struct and the png_info_structs */ -PNG_EXPORT(65, void, png_destroy_write_struct, (png_structpp png_ptr_ptr, - png_infopp info_ptr_ptr)); - -/* Set the libpng method of handling chunk CRC errors */ -PNG_EXPORT(66, void, png_set_crc_action, - (png_structp png_ptr, int crit_action, int ancil_action)); - -/* Values for png_set_crc_action() say how to handle CRC errors in - * ancillary and critical chunks, and whether to use the data contained - * therein. Note that it is impossible to "discard" data in a critical - * chunk. For versions prior to 0.90, the action was always error/quit, - * whereas in version 0.90 and later, the action for CRC errors in ancillary - * chunks is warn/discard. These values should NOT be changed. - * - * value action:critical action:ancillary - */ -#define PNG_CRC_DEFAULT 0 /* error/quit warn/discard data */ -#define PNG_CRC_ERROR_QUIT 1 /* error/quit error/quit */ -#define PNG_CRC_WARN_DISCARD 2 /* (INVALID) warn/discard data */ -#define PNG_CRC_WARN_USE 3 /* warn/use data warn/use data */ -#define PNG_CRC_QUIET_USE 4 /* quiet/use data quiet/use data */ -#define PNG_CRC_NO_CHANGE 5 /* use current value use current value */ - -/* These functions give the user control over the scan-line filtering in - * libpng and the compression methods used by zlib. These functions are - * mainly useful for testing, as the defaults should work with most users. - * Those users who are tight on memory or want faster performance at the - * expense of compression can modify them. See the compression library - * header file (zlib.h) for an explination of the compression functions. - */ - -/* Set the filtering method(s) used by libpng. Currently, the only valid - * value for "method" is 0. - */ -PNG_EXPORT(67, void, png_set_filter, - (png_structp png_ptr, int method, int filters)); - -/* Flags for png_set_filter() to say which filters to use. The flags - * are chosen so that they don't conflict with real filter types - * below, in case they are supplied instead of the #defined constants. - * These values should NOT be changed. - */ -#define PNG_NO_FILTERS 0x00 -#define PNG_FILTER_NONE 0x08 -#define PNG_FILTER_SUB 0x10 -#define PNG_FILTER_UP 0x20 -#define PNG_FILTER_AVG 0x40 -#define PNG_FILTER_PAETH 0x80 -#define PNG_ALL_FILTERS (PNG_FILTER_NONE | PNG_FILTER_SUB | PNG_FILTER_UP | \ - PNG_FILTER_AVG | PNG_FILTER_PAETH) - -/* Filter values (not flags) - used in pngwrite.c, pngwutil.c for now. - * These defines should NOT be changed. - */ -#define PNG_FILTER_VALUE_NONE 0 -#define PNG_FILTER_VALUE_SUB 1 -#define PNG_FILTER_VALUE_UP 2 -#define PNG_FILTER_VALUE_AVG 3 -#define PNG_FILTER_VALUE_PAETH 4 -#define PNG_FILTER_VALUE_LAST 5 - -#ifdef PNG_WRITE_WEIGHTED_FILTER_SUPPORTED /* EXPERIMENTAL */ -/* The "heuristic_method" is given by one of the PNG_FILTER_HEURISTIC_ - * defines, either the default (minimum-sum-of-absolute-differences), or - * the experimental method (weighted-minimum-sum-of-absolute-differences). - * - * Weights are factors >= 1.0, indicating how important it is to keep the - * filter type consistent between rows. Larger numbers mean the current - * filter is that many times as likely to be the same as the "num_weights" - * previous filters. This is cumulative for each previous row with a weight. - * There needs to be "num_weights" values in "filter_weights", or it can be - * NULL if the weights aren't being specified. Weights have no influence on - * the selection of the first row filter. Well chosen weights can (in theory) - * improve the compression for a given image. - * - * Costs are factors >= 1.0 indicating the relative decoding costs of a - * filter type. Higher costs indicate more decoding expense, and are - * therefore less likely to be selected over a filter with lower computational - * costs. There needs to be a value in "filter_costs" for each valid filter - * type (given by PNG_FILTER_VALUE_LAST), or it can be NULL if you aren't - * setting the costs. Costs try to improve the speed of decompression without - * unduly increasing the compressed image size. - * - * A negative weight or cost indicates the default value is to be used, and - * values in the range [0.0, 1.0) indicate the value is to remain unchanged. - * The default values for both weights and costs are currently 1.0, but may - * change if good general weighting/cost heuristics can be found. If both - * the weights and costs are set to 1.0, this degenerates the WEIGHTED method - * to the UNWEIGHTED method, but with added encoding time/computation. - */ -PNG_FP_EXPORT(68, void, png_set_filter_heuristics, (png_structp png_ptr, - int heuristic_method, int num_weights, png_const_doublep filter_weights, - png_const_doublep filter_costs)); -PNG_FIXED_EXPORT(209, void, png_set_filter_heuristics_fixed, - (png_structp png_ptr, - int heuristic_method, int num_weights, png_const_fixed_point_p - filter_weights, png_const_fixed_point_p filter_costs)); -#endif /* PNG_WRITE_WEIGHTED_FILTER_SUPPORTED */ - -/* Heuristic used for row filter selection. These defines should NOT be - * changed. - */ -#define PNG_FILTER_HEURISTIC_DEFAULT 0 /* Currently "UNWEIGHTED" */ -#define PNG_FILTER_HEURISTIC_UNWEIGHTED 1 /* Used by libpng < 0.95 */ -#define PNG_FILTER_HEURISTIC_WEIGHTED 2 /* Experimental feature */ -#define PNG_FILTER_HEURISTIC_LAST 3 /* Not a valid value */ - -#ifdef PNG_WRITE_SUPPORTED -/* Set the library compression level. Currently, valid values range from - * 0 - 9, corresponding directly to the zlib compression levels 0 - 9 - * (0 - no compression, 9 - "maximal" compression). Note that tests have - * shown that zlib compression levels 3-6 usually perform as well as level 9 - * for PNG images, and do considerably fewer caclulations. In the future, - * these values may not correspond directly to the zlib compression levels. - */ -PNG_EXPORT(69, void, png_set_compression_level, - (png_structp png_ptr, int level)); - -PNG_EXPORT(70, void, png_set_compression_mem_level, (png_structp png_ptr, - int mem_level)); - -PNG_EXPORT(71, void, png_set_compression_strategy, (png_structp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(72, void, png_set_compression_window_bits, (png_structp png_ptr, - int window_bits)); - -PNG_EXPORT(73, void, png_set_compression_method, (png_structp png_ptr, - int method)); -#endif - -#ifdef PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -/* Also set zlib parameters for compressing non-IDAT chunks */ -PNG_EXPORT(222, void, png_set_text_compression_level, - (png_structp png_ptr, int level)); - -PNG_EXPORT(223, void, png_set_text_compression_mem_level, (png_structp png_ptr, - int mem_level)); - -PNG_EXPORT(224, void, png_set_text_compression_strategy, (png_structp png_ptr, - int strategy)); - -/* If PNG_WRITE_OPTIMIZE_CMF_SUPPORTED is defined, libpng will use a - * smaller value of window_bits if it can do so safely. - */ -PNG_EXPORT(225, void, png_set_text_compression_window_bits, (png_structp - png_ptr, int window_bits)); - -PNG_EXPORT(226, void, png_set_text_compression_method, (png_structp png_ptr, - int method)); -#endif /* PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED */ - -/* These next functions are called for input/output, memory, and error - * handling. They are in the file pngrio.c, pngwio.c, and pngerror.c, - * and call standard C I/O routines such as fread(), fwrite(), and - * fprintf(). These functions can be made to use other I/O routines - * at run time for those applications that need to handle I/O in a - * different manner by calling png_set_???_fn(). See libpng-manual.txt for - * more information. - */ - -#ifdef PNG_STDIO_SUPPORTED -/* Initialize the input/output for the PNG file to the default functions. */ -PNG_EXPORT(74, void, png_init_io, (png_structp png_ptr, png_FILE_p fp)); -#endif - -/* Replace the (error and abort), and warning functions with user - * supplied functions. If no messages are to be printed you must still - * write and use replacement functions. The replacement error_fn should - * still do a longjmp to the last setjmp location if you are using this - * method of error handling. If error_fn or warning_fn is NULL, the - * default function will be used. - */ - -PNG_EXPORT(75, void, png_set_error_fn, - (png_structp png_ptr, png_voidp error_ptr, - png_error_ptr error_fn, png_error_ptr warning_fn)); - -/* Return the user pointer associated with the error functions */ -PNG_EXPORT(76, png_voidp, png_get_error_ptr, (png_const_structp png_ptr)); - -/* Replace the default data output functions with a user supplied one(s). - * If buffered output is not used, then output_flush_fn can be set to NULL. - * If PNG_WRITE_FLUSH_SUPPORTED is not defined at libpng compile time - * output_flush_fn will be ignored (and thus can be NULL). - * It is probably a mistake to use NULL for output_flush_fn if - * write_data_fn is not also NULL unless you have built libpng with - * PNG_WRITE_FLUSH_SUPPORTED undefined, because in this case libpng's - * default flush function, which uses the standard *FILE structure, will - * be used. - */ -PNG_EXPORT(77, void, png_set_write_fn, (png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr write_data_fn, png_flush_ptr output_flush_fn)); - -/* Replace the default data input function with a user supplied one. */ -PNG_EXPORT(78, void, png_set_read_fn, (png_structp png_ptr, png_voidp io_ptr, - png_rw_ptr read_data_fn)); - -/* Return the user pointer associated with the I/O functions */ -PNG_EXPORT(79, png_voidp, png_get_io_ptr, (png_structp png_ptr)); - -PNG_EXPORT(80, void, png_set_read_status_fn, (png_structp png_ptr, - png_read_status_ptr read_row_fn)); - -PNG_EXPORT(81, void, png_set_write_status_fn, (png_structp png_ptr, - png_write_status_ptr write_row_fn)); - -#ifdef PNG_USER_MEM_SUPPORTED -/* Replace the default memory allocation functions with user supplied one(s). */ -PNG_EXPORT(82, void, png_set_mem_fn, (png_structp png_ptr, png_voidp mem_ptr, - png_malloc_ptr malloc_fn, png_free_ptr free_fn)); -/* Return the user pointer associated with the memory functions */ -PNG_EXPORT(83, png_voidp, png_get_mem_ptr, (png_const_structp png_ptr)); -#endif - -#ifdef PNG_READ_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(84, void, png_set_read_user_transform_fn, (png_structp png_ptr, - png_user_transform_ptr read_user_transform_fn)); -#endif - -#ifdef PNG_WRITE_USER_TRANSFORM_SUPPORTED -PNG_EXPORT(85, void, png_set_write_user_transform_fn, (png_structp png_ptr, - png_user_transform_ptr write_user_transform_fn)); -#endif - -#ifdef PNG_USER_TRANSFORM_PTR_SUPPORTED -PNG_EXPORT(86, void, png_set_user_transform_info, (png_structp png_ptr, - png_voidp user_transform_ptr, int user_transform_depth, - int user_transform_channels)); -/* Return the user pointer associated with the user transform functions */ -PNG_EXPORT(87, png_voidp, png_get_user_transform_ptr, - (png_const_structp png_ptr)); -#endif - -#ifdef PNG_USER_TRANSFORM_INFO_SUPPORTED -/* Return information about the row currently being processed. Note that these - * APIs do not fail but will return unexpected results if called outside a user - * transform callback. Also note that when transforming an interlaced image the - * row number is the row number within the sub-image of the interlace pass, so - * the value will increase to the height of the sub-image (not the full image) - * then reset to 0 for the next pass. - * - * Use PNG_ROW_FROM_PASS_ROW(row, pass) and PNG_COL_FROM_PASS_COL(col, pass) to - * find the output pixel (x,y) given an interlaced sub-image pixel - * (row,col,pass). (See below for these macros.) - */ -PNG_EXPORT(217, png_uint_32, png_get_current_row_number, (png_const_structp)); -PNG_EXPORT(218, png_byte, png_get_current_pass_number, (png_const_structp)); -#endif - -#ifdef PNG_USER_CHUNKS_SUPPORTED -PNG_EXPORT(88, void, png_set_read_user_chunk_fn, (png_structp png_ptr, - png_voidp user_chunk_ptr, png_user_chunk_ptr read_user_chunk_fn)); -PNG_EXPORT(89, png_voidp, png_get_user_chunk_ptr, (png_const_structp png_ptr)); -#endif - -#ifdef PNG_PROGRESSIVE_READ_SUPPORTED -/* Sets the function callbacks for the push reader, and a pointer to a - * user-defined structure available to the callback functions. - */ -PNG_EXPORT(90, void, png_set_progressive_read_fn, (png_structp png_ptr, - png_voidp progressive_ptr, png_progressive_info_ptr info_fn, - png_progressive_row_ptr row_fn, png_progressive_end_ptr end_fn)); - -/* Returns the user pointer associated with the push read functions */ -PNG_EXPORT(91, png_voidp, png_get_progressive_ptr, (png_const_structp png_ptr)); - -/* Function to be called when data becomes available */ -PNG_EXPORT(92, void, png_process_data, - (png_structp png_ptr, png_infop info_ptr, - png_bytep buffer, png_size_t buffer_size)); - -/* A function which may be called *only* within png_process_data to stop the - * processing of any more data. The function returns the number of bytes - * remaining, excluding any that libpng has cached internally. A subsequent - * call to png_process_data must supply these bytes again. If the argument - * 'save' is set to true the routine will first save all the pending data and - * will always return 0. - */ -PNG_EXPORT(219, png_size_t, png_process_data_pause, (png_structp, int save)); - -/* A function which may be called *only* outside (after) a call to - * png_process_data. It returns the number of bytes of data to skip in the - * input. Normally it will return 0, but if it returns a non-zero value the - * application must skip than number of bytes of input data and pass the - * following data to the next call to png_process_data. - */ -PNG_EXPORT(220, png_uint_32, png_process_data_skip, (png_structp)); - -#ifdef PNG_READ_INTERLACING_SUPPORTED -/* Function that combines rows. 'new_row' is a flag that should come from - * the callback and be non-NULL if anything needs to be done; the library - * stores its own version of the new data internally and ignores the passed - * in value. - */ -PNG_EXPORT(93, void, png_progressive_combine_row, (png_structp png_ptr, - png_bytep old_row, png_const_bytep new_row)); -#endif /* PNG_READ_INTERLACING_SUPPORTED */ -#endif /* PNG_PROGRESSIVE_READ_SUPPORTED */ - -PNG_EXPORTA(94, png_voidp, png_malloc, - (png_structp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED); -/* Added at libpng version 1.4.0 */ -PNG_EXPORTA(95, png_voidp, png_calloc, - (png_structp png_ptr, png_alloc_size_t size), - PNG_ALLOCATED); - -/* Added at libpng version 1.2.4 */ -PNG_EXPORTA(96, png_voidp, png_malloc_warn, (png_structp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); - -/* Frees a pointer allocated by png_malloc() */ -PNG_EXPORT(97, void, png_free, (png_structp png_ptr, png_voidp ptr)); - -/* Free data that was allocated internally */ -PNG_EXPORT(98, void, png_free_data, - (png_structp png_ptr, png_infop info_ptr, png_uint_32 free_me, int num)); - -/* Reassign responsibility for freeing existing data, whether allocated - * by libpng or by the application */ -PNG_EXPORT(99, void, png_data_freer, - (png_structp png_ptr, png_infop info_ptr, int freer, png_uint_32 mask)); - -/* Assignments for png_data_freer */ -#define PNG_DESTROY_WILL_FREE_DATA 1 -#define PNG_SET_WILL_FREE_DATA 1 -#define PNG_USER_WILL_FREE_DATA 2 -/* Flags for png_ptr->free_me and info_ptr->free_me */ -#define PNG_FREE_HIST 0x0008 -#define PNG_FREE_ICCP 0x0010 -#define PNG_FREE_SPLT 0x0020 -#define PNG_FREE_ROWS 0x0040 -#define PNG_FREE_PCAL 0x0080 -#define PNG_FREE_SCAL 0x0100 -#define PNG_FREE_UNKN 0x0200 -#define PNG_FREE_LIST 0x0400 -#define PNG_FREE_PLTE 0x1000 -#define PNG_FREE_TRNS 0x2000 -#define PNG_FREE_TEXT 0x4000 -#define PNG_FREE_ALL 0x7fff -#define PNG_FREE_MUL 0x4220 /* PNG_FREE_SPLT|PNG_FREE_TEXT|PNG_FREE_UNKN */ - -#ifdef PNG_USER_MEM_SUPPORTED -PNG_EXPORTA(100, png_voidp, png_malloc_default, (png_structp png_ptr, - png_alloc_size_t size), PNG_ALLOCATED); -PNG_EXPORT(101, void, png_free_default, (png_structp png_ptr, png_voidp ptr)); -#endif - -#ifdef PNG_ERROR_TEXT_SUPPORTED -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(102, void, png_error, - (png_structp png_ptr, png_const_charp error_message), - PNG_NORETURN); - -/* The same, but the chunk name is prepended to the error string. */ -PNG_EXPORTA(103, void, png_chunk_error, (png_structp png_ptr, - png_const_charp error_message), PNG_NORETURN); - -#else -/* Fatal error in PNG image of libpng - can't continue */ -PNG_EXPORTA(104, void, png_err, (png_structp png_ptr), PNG_NORETURN); -#endif - -#ifdef PNG_WARNINGS_SUPPORTED -/* Non-fatal error in libpng. Can continue, but may have a problem. */ -PNG_EXPORT(105, void, png_warning, (png_structp png_ptr, - png_const_charp warning_message)); - -/* Non-fatal error in libpng, chunk name is prepended to message. */ -PNG_EXPORT(106, void, png_chunk_warning, (png_structp png_ptr, - png_const_charp warning_message)); -#endif - -#ifdef PNG_BENIGN_ERRORS_SUPPORTED -/* Benign error in libpng. Can continue, but may have a problem. - * User can choose whether to handle as a fatal error or as a warning. */ -# undef png_benign_error -PNG_EXPORT(107, void, png_benign_error, (png_structp png_ptr, - png_const_charp warning_message)); - -/* Same, chunk name is prepended to message. */ -# undef png_chunk_benign_error -PNG_EXPORT(108, void, png_chunk_benign_error, (png_structp png_ptr, - png_const_charp warning_message)); - -PNG_EXPORT(109, void, png_set_benign_errors, - (png_structp png_ptr, int allowed)); -#else -# ifdef PNG_ALLOW_BENIGN_ERRORS -# define png_benign_error png_warning -# define png_chunk_benign_error png_chunk_warning -# else -# define png_benign_error png_error -# define png_chunk_benign_error png_chunk_error -# endif -#endif - -/* The png_set_ functions are for storing values in the png_info_struct. - * Similarly, the png_get_ calls are used to read values from the - * png_info_struct, either storing the parameters in the passed variables, or - * setting pointers into the png_info_struct where the data is stored. The - * png_get_ functions return a non-zero value if the data was available - * in info_ptr, or return zero and do not change any of the parameters if the - * data was not available. - * - * These functions should be used instead of directly accessing png_info - * to avoid problems with future changes in the size and internal layout of - * png_info_struct. - */ -/* Returns "flag" if chunk data is valid in info_ptr. */ -PNG_EXPORT(110, png_uint_32, png_get_valid, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_uint_32 flag)); - -/* Returns number of bytes needed to hold a transformed row. */ -PNG_EXPORT(111, png_size_t, png_get_rowbytes, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -#ifdef PNG_INFO_IMAGE_SUPPORTED -/* Returns row_pointers, which is an array of pointers to scanlines that was - * returned from png_read_png(). - */ -PNG_EXPORT(112, png_bytepp, png_get_rows, - (png_const_structp png_ptr, png_const_infop info_ptr)); -/* Set row_pointers, which is an array of pointers to scanlines for use - * by png_write_png(). - */ -PNG_EXPORT(113, void, png_set_rows, (png_structp png_ptr, - png_infop info_ptr, png_bytepp row_pointers)); -#endif - -/* Returns number of color channels in image. */ -PNG_EXPORT(114, png_byte, png_get_channels, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -#ifdef PNG_EASY_ACCESS_SUPPORTED -/* Returns image width in pixels. */ -PNG_EXPORT(115, png_uint_32, png_get_image_width, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -/* Returns image height in pixels. */ -PNG_EXPORT(116, png_uint_32, png_get_image_height, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -/* Returns image bit_depth. */ -PNG_EXPORT(117, png_byte, png_get_bit_depth, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -/* Returns image color_type. */ -PNG_EXPORT(118, png_byte, png_get_color_type, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -/* Returns image filter_type. */ -PNG_EXPORT(119, png_byte, png_get_filter_type, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -/* Returns image interlace_type. */ -PNG_EXPORT(120, png_byte, png_get_interlace_type, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -/* Returns image compression_type. */ -PNG_EXPORT(121, png_byte, png_get_compression_type, (png_const_structp png_ptr, - png_const_infop info_ptr)); - -/* Returns image resolution in pixels per meter, from pHYs chunk data. */ -PNG_EXPORT(122, png_uint_32, png_get_pixels_per_meter, - (png_const_structp png_ptr, png_const_infop info_ptr)); -PNG_EXPORT(123, png_uint_32, png_get_x_pixels_per_meter, - (png_const_structp png_ptr, png_const_infop info_ptr)); -PNG_EXPORT(124, png_uint_32, png_get_y_pixels_per_meter, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -/* Returns pixel aspect ratio, computed from pHYs chunk data. */ -PNG_FP_EXPORT(125, float, png_get_pixel_aspect_ratio, - (png_const_structp png_ptr, png_const_infop info_ptr)); -PNG_FIXED_EXPORT(210, png_fixed_point, png_get_pixel_aspect_ratio_fixed, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -/* Returns image x, y offset in pixels or microns, from oFFs chunk data. */ -PNG_EXPORT(126, png_int_32, png_get_x_offset_pixels, - (png_const_structp png_ptr, png_const_infop info_ptr)); -PNG_EXPORT(127, png_int_32, png_get_y_offset_pixels, - (png_const_structp png_ptr, png_const_infop info_ptr)); -PNG_EXPORT(128, png_int_32, png_get_x_offset_microns, - (png_const_structp png_ptr, png_const_infop info_ptr)); -PNG_EXPORT(129, png_int_32, png_get_y_offset_microns, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -#endif /* PNG_EASY_ACCESS_SUPPORTED */ - -/* Returns pointer to signature string read from PNG header */ -PNG_EXPORT(130, png_const_bytep, png_get_signature, - (png_const_structp png_ptr, png_infop info_ptr)); - -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(131, png_uint_32, png_get_bKGD, - (png_const_structp png_ptr, png_infop info_ptr, - png_color_16p *background)); -#endif - -#ifdef PNG_bKGD_SUPPORTED -PNG_EXPORT(132, void, png_set_bKGD, (png_structp png_ptr, png_infop info_ptr, - png_const_color_16p background)); -#endif - -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(133, png_uint_32, png_get_cHRM, (png_const_structp png_ptr, - png_const_infop info_ptr, double *white_x, double *white_y, double *red_x, - double *red_y, double *green_x, double *green_y, double *blue_x, - double *blue_y)); -PNG_FP_EXPORT(230, png_uint_32, png_get_cHRM_XYZ, (png_structp png_ptr, - png_const_infop info_ptr, double *red_X, double *red_Y, double *red_Z, - double *green_X, double *green_Y, double *green_Z, double *blue_X, - double *blue_Y, double *blue_Z)); -#ifdef PNG_FIXED_POINT_SUPPORTED /* Otherwise not implemented */ -PNG_FIXED_EXPORT(134, png_uint_32, png_get_cHRM_fixed, - (png_const_structp png_ptr, - png_const_infop info_ptr, png_fixed_point *int_white_x, - png_fixed_point *int_white_y, png_fixed_point *int_red_x, - png_fixed_point *int_red_y, png_fixed_point *int_green_x, - png_fixed_point *int_green_y, png_fixed_point *int_blue_x, - png_fixed_point *int_blue_y)); -#endif -PNG_FIXED_EXPORT(231, png_uint_32, png_get_cHRM_XYZ_fixed, - (png_structp png_ptr, png_const_infop info_ptr, - png_fixed_point *int_red_X, png_fixed_point *int_red_Y, - png_fixed_point *int_red_Z, png_fixed_point *int_green_X, - png_fixed_point *int_green_Y, png_fixed_point *int_green_Z, - png_fixed_point *int_blue_X, png_fixed_point *int_blue_Y, - png_fixed_point *int_blue_Z)); -#endif - -#ifdef PNG_cHRM_SUPPORTED -PNG_FP_EXPORT(135, void, png_set_cHRM, - (png_structp png_ptr, png_infop info_ptr, - double white_x, double white_y, double red_x, double red_y, double green_x, - double green_y, double blue_x, double blue_y)); -PNG_FP_EXPORT(232, void, png_set_cHRM_XYZ, (png_structp png_ptr, - png_infop info_ptr, double red_X, double red_Y, double red_Z, - double green_X, double green_Y, double green_Z, double blue_X, - double blue_Y, double blue_Z)); -PNG_FIXED_EXPORT(136, void, png_set_cHRM_fixed, (png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_white_x, - png_fixed_point int_white_y, png_fixed_point int_red_x, - png_fixed_point int_red_y, png_fixed_point int_green_x, - png_fixed_point int_green_y, png_fixed_point int_blue_x, - png_fixed_point int_blue_y)); -PNG_FIXED_EXPORT(233, void, png_set_cHRM_XYZ_fixed, (png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_red_X, png_fixed_point int_red_Y, - png_fixed_point int_red_Z, png_fixed_point int_green_X, - png_fixed_point int_green_Y, png_fixed_point int_green_Z, - png_fixed_point int_blue_X, png_fixed_point int_blue_Y, - png_fixed_point int_blue_Z)); -#endif - -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(137, png_uint_32, png_get_gAMA, - (png_const_structp png_ptr, png_const_infop info_ptr, - double *file_gamma)); -PNG_FIXED_EXPORT(138, png_uint_32, png_get_gAMA_fixed, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_fixed_point *int_file_gamma)); -#endif - -#ifdef PNG_gAMA_SUPPORTED -PNG_FP_EXPORT(139, void, png_set_gAMA, (png_structp png_ptr, - png_infop info_ptr, double file_gamma)); -PNG_FIXED_EXPORT(140, void, png_set_gAMA_fixed, (png_structp png_ptr, - png_infop info_ptr, png_fixed_point int_file_gamma)); -#endif - -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(141, png_uint_32, png_get_hIST, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_uint_16p *hist)); -#endif - -#ifdef PNG_hIST_SUPPORTED -PNG_EXPORT(142, void, png_set_hIST, (png_structp png_ptr, - png_infop info_ptr, png_const_uint_16p hist)); -#endif - -PNG_EXPORT(143, png_uint_32, png_get_IHDR, - (png_structp png_ptr, png_infop info_ptr, - png_uint_32 *width, png_uint_32 *height, int *bit_depth, int *color_type, - int *interlace_method, int *compression_method, int *filter_method)); - -PNG_EXPORT(144, void, png_set_IHDR, - (png_structp png_ptr, png_infop info_ptr, - png_uint_32 width, png_uint_32 height, int bit_depth, int color_type, - int interlace_method, int compression_method, int filter_method)); - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(145, png_uint_32, png_get_oFFs, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_int_32 *offset_x, png_int_32 *offset_y, int *unit_type)); -#endif - -#ifdef PNG_oFFs_SUPPORTED -PNG_EXPORT(146, void, png_set_oFFs, - (png_structp png_ptr, png_infop info_ptr, - png_int_32 offset_x, png_int_32 offset_y, int unit_type)); -#endif - -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(147, png_uint_32, png_get_pCAL, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_charp *purpose, png_int_32 *X0, png_int_32 *X1, int *type, - int *nparams, - png_charp *units, png_charpp *params)); -#endif - -#ifdef PNG_pCAL_SUPPORTED -PNG_EXPORT(148, void, png_set_pCAL, (png_structp png_ptr, - png_infop info_ptr, - png_const_charp purpose, png_int_32 X0, png_int_32 X1, int type, - int nparams, png_const_charp units, png_charpp params)); -#endif - -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(149, png_uint_32, png_get_pHYs, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_uint_32 *res_x, png_uint_32 *res_y, int *unit_type)); -#endif - -#ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(150, void, png_set_pHYs, - (png_structp png_ptr, png_infop info_ptr, - png_uint_32 res_x, png_uint_32 res_y, int unit_type)); -#endif - -PNG_EXPORT(151, png_uint_32, png_get_PLTE, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_colorp *palette, int *num_palette)); - -PNG_EXPORT(152, void, png_set_PLTE, - (png_structp png_ptr, png_infop info_ptr, - png_const_colorp palette, int num_palette)); - -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(153, png_uint_32, png_get_sBIT, - (png_const_structp png_ptr, png_infop info_ptr, - png_color_8p *sig_bit)); -#endif - -#ifdef PNG_sBIT_SUPPORTED -PNG_EXPORT(154, void, png_set_sBIT, - (png_structp png_ptr, png_infop info_ptr, png_const_color_8p sig_bit)); -#endif - -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(155, png_uint_32, png_get_sRGB, (png_const_structp png_ptr, - png_const_infop info_ptr, int *file_srgb_intent)); -#endif - -#ifdef PNG_sRGB_SUPPORTED -PNG_EXPORT(156, void, png_set_sRGB, - (png_structp png_ptr, png_infop info_ptr, int srgb_intent)); -PNG_EXPORT(157, void, png_set_sRGB_gAMA_and_cHRM, (png_structp png_ptr, - png_infop info_ptr, int srgb_intent)); -#endif - -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(158, png_uint_32, png_get_iCCP, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_charpp name, int *compression_type, png_bytepp profile, - png_uint_32 *proflen)); -#endif - -#ifdef PNG_iCCP_SUPPORTED -PNG_EXPORT(159, void, png_set_iCCP, - (png_structp png_ptr, png_infop info_ptr, - png_const_charp name, int compression_type, png_const_bytep profile, - png_uint_32 proflen)); -#endif - -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(160, png_uint_32, png_get_sPLT, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_sPLT_tpp entries)); -#endif - -#ifdef PNG_sPLT_SUPPORTED -PNG_EXPORT(161, void, png_set_sPLT, - (png_structp png_ptr, png_infop info_ptr, - png_const_sPLT_tp entries, int nentries)); -#endif - -#ifdef PNG_TEXT_SUPPORTED -/* png_get_text also returns the number of text chunks in *num_text */ -PNG_EXPORT(162, png_uint_32, png_get_text, - (png_const_structp png_ptr, png_const_infop info_ptr, - png_textp *text_ptr, int *num_text)); -#endif - -/* Note while png_set_text() will accept a structure whose text, - * language, and translated keywords are NULL pointers, the structure - * returned by png_get_text will always contain regular - * zero-terminated C strings. They might be empty strings but - * they will never be NULL pointers. - */ - -#ifdef PNG_TEXT_SUPPORTED -PNG_EXPORT(163, void, png_set_text, - (png_structp png_ptr, png_infop info_ptr, - png_const_textp text_ptr, int num_text)); -#endif - -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(164, png_uint_32, png_get_tIME, - (png_const_structp png_ptr, png_infop info_ptr, png_timep *mod_time)); -#endif - -#ifdef PNG_tIME_SUPPORTED -PNG_EXPORT(165, void, png_set_tIME, - (png_structp png_ptr, png_infop info_ptr, png_const_timep mod_time)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(166, png_uint_32, png_get_tRNS, - (png_const_structp png_ptr, png_infop info_ptr, - png_bytep *trans_alpha, int *num_trans, png_color_16p *trans_color)); -#endif - -#ifdef PNG_tRNS_SUPPORTED -PNG_EXPORT(167, void, png_set_tRNS, - (png_structp png_ptr, png_infop info_ptr, - png_const_bytep trans_alpha, int num_trans, - png_const_color_16p trans_color)); -#endif - -#ifdef PNG_sCAL_SUPPORTED -PNG_FP_EXPORT(168, png_uint_32, png_get_sCAL, - (png_const_structp png_ptr, png_const_infop info_ptr, - int *unit, double *width, double *height)); -#ifdef PNG_FLOATING_ARITHMETIC_SUPPORTED -/* NOTE: this API is currently implemented using floating point arithmetic, - * consequently it can only be used on systems with floating point support. - * In any case the range of values supported by png_fixed_point is small and it - * is highly recommended that png_get_sCAL_s be used instead. - */ -PNG_FIXED_EXPORT(214, png_uint_32, png_get_sCAL_fixed, - (png_structp png_ptr, png_const_infop info_ptr, int *unit, - png_fixed_point *width, - png_fixed_point *height)); -#endif -PNG_EXPORT(169, png_uint_32, png_get_sCAL_s, - (png_const_structp png_ptr, png_const_infop info_ptr, - int *unit, png_charpp swidth, png_charpp sheight)); - -PNG_FP_EXPORT(170, void, png_set_sCAL, - (png_structp png_ptr, png_infop info_ptr, - int unit, double width, double height)); -PNG_FIXED_EXPORT(213, void, png_set_sCAL_fixed, (png_structp png_ptr, - png_infop info_ptr, int unit, png_fixed_point width, - png_fixed_point height)); -PNG_EXPORT(171, void, png_set_sCAL_s, - (png_structp png_ptr, png_infop info_ptr, - int unit, png_const_charp swidth, png_const_charp sheight)); -#endif /* PNG_sCAL_SUPPORTED */ - -#ifdef PNG_HANDLE_AS_UNKNOWN_SUPPORTED -/* Provide a list of chunks and how they are to be handled, if the built-in - handling or default unknown chunk handling is not desired. Any chunks not - listed will be handled in the default manner. The IHDR and IEND chunks - must not be listed. Because this turns off the default handling for chunks - that would otherwise be recognized the behavior of libpng transformations may - well become incorrect! - keep = 0: PNG_HANDLE_CHUNK_AS_DEFAULT: follow default behavior - = 1: PNG_HANDLE_CHUNK_NEVER: do not keep - = 2: PNG_HANDLE_CHUNK_IF_SAFE: keep only if safe-to-copy - = 3: PNG_HANDLE_CHUNK_ALWAYS: keep even if unsafe-to-copy -*/ -PNG_EXPORT(172, void, png_set_keep_unknown_chunks, - (png_structp png_ptr, int keep, - png_const_bytep chunk_list, int num_chunks)); - -/* The handling code is returned; the result is therefore true (non-zero) if - * special handling is required, false for the default handling. - */ -PNG_EXPORT(173, int, png_handle_as_unknown, (png_structp png_ptr, - png_const_bytep chunk_name)); -#endif -#ifdef PNG_UNKNOWN_CHUNKS_SUPPORTED -PNG_EXPORT(174, void, png_set_unknown_chunks, (png_structp png_ptr, - png_infop info_ptr, png_const_unknown_chunkp unknowns, - int num_unknowns)); -PNG_EXPORT(175, void, png_set_unknown_chunk_location, - (png_structp png_ptr, png_infop info_ptr, int chunk, int location)); -PNG_EXPORT(176, int, png_get_unknown_chunks, (png_const_structp png_ptr, - png_const_infop info_ptr, png_unknown_chunkpp entries)); -#endif - -/* Png_free_data() will turn off the "valid" flag for anything it frees. - * If you need to turn it off for a chunk that your application has freed, - * you can use png_set_invalid(png_ptr, info_ptr, PNG_INFO_CHNK); - */ -PNG_EXPORT(177, void, png_set_invalid, - (png_structp png_ptr, png_infop info_ptr, int mask)); - -#ifdef PNG_INFO_IMAGE_SUPPORTED -/* The "params" pointer is currently not used and is for future expansion. */ -PNG_EXPORT(178, void, png_read_png, (png_structp png_ptr, png_infop info_ptr, - int transforms, png_voidp params)); -PNG_EXPORT(179, void, png_write_png, (png_structp png_ptr, png_infop info_ptr, - int transforms, png_voidp params)); -#endif - -PNG_EXPORT(180, png_const_charp, png_get_copyright, - (png_const_structp png_ptr)); -PNG_EXPORT(181, png_const_charp, png_get_header_ver, - (png_const_structp png_ptr)); -PNG_EXPORT(182, png_const_charp, png_get_header_version, - (png_const_structp png_ptr)); -PNG_EXPORT(183, png_const_charp, png_get_libpng_ver, - (png_const_structp png_ptr)); - -#ifdef PNG_MNG_FEATURES_SUPPORTED -PNG_EXPORT(184, png_uint_32, png_permit_mng_features, (png_structp png_ptr, - png_uint_32 mng_features_permitted)); -#endif - -/* For use in png_set_keep_unknown, added to version 1.2.6 */ -#define PNG_HANDLE_CHUNK_AS_DEFAULT 0 -#define PNG_HANDLE_CHUNK_NEVER 1 -#define PNG_HANDLE_CHUNK_IF_SAFE 2 -#define PNG_HANDLE_CHUNK_ALWAYS 3 - -/* Strip the prepended error numbers ("#nnn ") from error and warning - * messages before passing them to the error or warning handler. - */ -#ifdef PNG_ERROR_NUMBERS_SUPPORTED -PNG_EXPORT(185, void, png_set_strip_error_numbers, - (png_structp png_ptr, - png_uint_32 strip_mode)); -#endif - -/* Added in libpng-1.2.6 */ -#ifdef PNG_SET_USER_LIMITS_SUPPORTED -PNG_EXPORT(186, void, png_set_user_limits, (png_structp png_ptr, - png_uint_32 user_width_max, png_uint_32 user_height_max)); -PNG_EXPORT(187, png_uint_32, png_get_user_width_max, - (png_const_structp png_ptr)); -PNG_EXPORT(188, png_uint_32, png_get_user_height_max, - (png_const_structp png_ptr)); -/* Added in libpng-1.4.0 */ -PNG_EXPORT(189, void, png_set_chunk_cache_max, (png_structp png_ptr, - png_uint_32 user_chunk_cache_max)); -PNG_EXPORT(190, png_uint_32, png_get_chunk_cache_max, - (png_const_structp png_ptr)); -/* Added in libpng-1.4.1 */ -PNG_EXPORT(191, void, png_set_chunk_malloc_max, (png_structp png_ptr, - png_alloc_size_t user_chunk_cache_max)); -PNG_EXPORT(192, png_alloc_size_t, png_get_chunk_malloc_max, - (png_const_structp png_ptr)); -#endif - -#if defined(PNG_INCH_CONVERSIONS_SUPPORTED) -PNG_EXPORT(193, png_uint_32, png_get_pixels_per_inch, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -PNG_EXPORT(194, png_uint_32, png_get_x_pixels_per_inch, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -PNG_EXPORT(195, png_uint_32, png_get_y_pixels_per_inch, - (png_const_structp png_ptr, png_const_infop info_ptr)); - -PNG_FP_EXPORT(196, float, png_get_x_offset_inches, - (png_const_structp png_ptr, png_const_infop info_ptr)); -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(211, png_fixed_point, png_get_x_offset_inches_fixed, - (png_structp png_ptr, png_const_infop info_ptr)); -#endif - -PNG_FP_EXPORT(197, float, png_get_y_offset_inches, (png_const_structp png_ptr, - png_const_infop info_ptr)); -#ifdef PNG_FIXED_POINT_SUPPORTED /* otherwise not implemented. */ -PNG_FIXED_EXPORT(212, png_fixed_point, png_get_y_offset_inches_fixed, - (png_structp png_ptr, png_const_infop info_ptr)); -#endif - -# ifdef PNG_pHYs_SUPPORTED -PNG_EXPORT(198, png_uint_32, png_get_pHYs_dpi, (png_const_structp png_ptr, - png_const_infop info_ptr, png_uint_32 *res_x, png_uint_32 *res_y, - int *unit_type)); -# endif /* PNG_pHYs_SUPPORTED */ -#endif /* PNG_INCH_CONVERSIONS_SUPPORTED */ - -/* Added in libpng-1.4.0 */ -#ifdef PNG_IO_STATE_SUPPORTED -PNG_EXPORT(199, png_uint_32, png_get_io_state, (png_structp png_ptr)); - -PNG_EXPORTA(200, png_const_bytep, png_get_io_chunk_name, - (png_structp png_ptr), PNG_DEPRECATED); -PNG_EXPORT(216, png_uint_32, png_get_io_chunk_type, - (png_const_structp png_ptr)); - -/* The flags returned by png_get_io_state() are the following: */ -# define PNG_IO_NONE 0x0000 /* no I/O at this moment */ -# define PNG_IO_READING 0x0001 /* currently reading */ -# define PNG_IO_WRITING 0x0002 /* currently writing */ -# define PNG_IO_SIGNATURE 0x0010 /* currently at the file signature */ -# define PNG_IO_CHUNK_HDR 0x0020 /* currently at the chunk header */ -# define PNG_IO_CHUNK_DATA 0x0040 /* currently at the chunk data */ -# define PNG_IO_CHUNK_CRC 0x0080 /* currently at the chunk crc */ -# define PNG_IO_MASK_OP 0x000f /* current operation: reading/writing */ -# define PNG_IO_MASK_LOC 0x00f0 /* current location: sig/hdr/data/crc */ -#endif /* ?PNG_IO_STATE_SUPPORTED */ - -/* Interlace support. The following macros are always defined so that if - * libpng interlace handling is turned off the macros may be used to handle - * interlaced images within the application. - */ -#define PNG_INTERLACE_ADAM7_PASSES 7 - -/* Two macros to return the first row and first column of the original, - * full, image which appears in a given pass. 'pass' is in the range 0 - * to 6 and the result is in the range 0 to 7. - */ -#define PNG_PASS_START_ROW(pass) (((1&~(pass))<<(3-((pass)>>1)))&7) -#define PNG_PASS_START_COL(pass) (((1& (pass))<<(3-(((pass)+1)>>1)))&7) - -/* A macro to return the offset between pixels in the output row for a pair of - * pixels in the input - effectively the inverse of the 'COL_SHIFT' macro that - * follows. Note that ROW_OFFSET is the offset from one row to the next whereas - * COL_OFFSET is from one column to the next, within a row. - */ -#define PNG_PASS_ROW_OFFSET(pass) ((pass)>2?(8>>(((pass)-1)>>1)):8) -#define PNG_PASS_COL_OFFSET(pass) (1<<((7-(pass))>>1)) - -/* Two macros to help evaluate the number of rows or columns in each - * pass. This is expressed as a shift - effectively log2 of the number or - * rows or columns in each 8x8 tile of the original image. - */ -#define PNG_PASS_ROW_SHIFT(pass) ((pass)>2?(8-(pass))>>1:3) -#define PNG_PASS_COL_SHIFT(pass) ((pass)>1?(7-(pass))>>1:3) - -/* Hence two macros to determine the number of rows or columns in a given - * pass of an image given its height or width. In fact these macros may - * return non-zero even though the sub-image is empty, because the other - * dimension may be empty for a small image. - */ -#define PNG_PASS_ROWS(height, pass) (((height)+(((1<>PNG_PASS_ROW_SHIFT(pass)) -#define PNG_PASS_COLS(width, pass) (((width)+(((1<>PNG_PASS_COL_SHIFT(pass)) - -/* For the reader row callbacks (both progressive and sequential) it is - * necessary to find the row in the output image given a row in an interlaced - * image, so two more macros: - */ -#define PNG_ROW_FROM_PASS_ROW(yIn, pass) \ - (((yIn)<>(((7-(off))-(pass))<<2)) & 0xF) | \ - ((0x01145AF0>>(((7-(off))-(pass))<<2)) & 0xF0)) - -#define PNG_ROW_IN_INTERLACE_PASS(y, pass) \ - ((PNG_PASS_MASK(pass,0) >> ((y)&7)) & 1) -#define PNG_COL_IN_INTERLACE_PASS(x, pass) \ - ((PNG_PASS_MASK(pass,1) >> ((x)&7)) & 1) - -#ifdef PNG_READ_COMPOSITE_NODIV_SUPPORTED -/* With these routines we avoid an integer divide, which will be slower on - * most machines. However, it does take more operations than the corresponding - * divide method, so it may be slower on a few RISC systems. There are two - * shifts (by 8 or 16 bits) and an addition, versus a single integer divide. - * - * Note that the rounding factors are NOT supposed to be the same! 128 and - * 32768 are correct for the NODIV code; 127 and 32767 are correct for the - * standard method. - * - * [Optimized code by Greg Roelofs and Mark Adler...blame us for bugs. :-) ] - */ - - /* fg and bg should be in `gamma 1.0' space; alpha is the opacity */ - -# define png_composite(composite, fg, alpha, bg) \ - { png_uint_16 temp = (png_uint_16)((png_uint_16)(fg) \ - * (png_uint_16)(alpha) \ - + (png_uint_16)(bg)*(png_uint_16)(255 \ - - (png_uint_16)(alpha)) + 128); \ - (composite) = (png_byte)((temp + (temp >> 8)) >> 8); } - -# define png_composite_16(composite, fg, alpha, bg) \ - { png_uint_32 temp = (png_uint_32)((png_uint_32)(fg) \ - * (png_uint_32)(alpha) \ - + (png_uint_32)(bg)*(65535 \ - - (png_uint_32)(alpha)) + 32768); \ - (composite) = (png_uint_16)((temp + (temp >> 16)) >> 16); } - -#else /* Standard method using integer division */ - -# define png_composite(composite, fg, alpha, bg) \ - (composite) = (png_byte)(((png_uint_16)(fg) * (png_uint_16)(alpha) + \ - (png_uint_16)(bg) * (png_uint_16)(255 - (png_uint_16)(alpha)) + \ - 127) / 255) - -# define png_composite_16(composite, fg, alpha, bg) \ - (composite) = (png_uint_16)(((png_uint_32)(fg) * (png_uint_32)(alpha) + \ - (png_uint_32)(bg)*(png_uint_32)(65535 - (png_uint_32)(alpha)) + \ - 32767) / 65535) -#endif /* PNG_READ_COMPOSITE_NODIV_SUPPORTED */ - -#ifdef PNG_READ_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(201, png_uint_32, png_get_uint_32, (png_const_bytep buf)); -PNG_EXPORT(202, png_uint_16, png_get_uint_16, (png_const_bytep buf)); -PNG_EXPORT(203, png_int_32, png_get_int_32, (png_const_bytep buf)); -#endif - -PNG_EXPORT(204, png_uint_32, png_get_uint_31, (png_structp png_ptr, - png_const_bytep buf)); -/* No png_get_int_16 -- may be added if there's a real need for it. */ - -/* Place a 32-bit number into a buffer in PNG byte order (big-endian). */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(205, void, png_save_uint_32, (png_bytep buf, png_uint_32 i)); -#endif -#ifdef PNG_SAVE_INT_32_SUPPORTED -PNG_EXPORT(206, void, png_save_int_32, (png_bytep buf, png_int_32 i)); -#endif - -/* Place a 16-bit number into a buffer in PNG byte order. - * The parameter is declared unsigned int, not png_uint_16, - * just to avoid potential problems on pre-ANSI C compilers. - */ -#ifdef PNG_WRITE_INT_FUNCTIONS_SUPPORTED -PNG_EXPORT(207, void, png_save_uint_16, (png_bytep buf, unsigned int i)); -/* No png_save_int_16 -- may be added if there's a real need for it. */ -#endif - -#ifdef PNG_USE_READ_MACROS -/* Inline macros to do direct reads of bytes from the input buffer. - * The png_get_int_32() routine assumes we are using two's complement - * format for negative values, which is almost certainly true. - */ -# define png_get_uint_32(buf) \ - (((png_uint_32)(*(buf)) << 24) + \ - ((png_uint_32)(*((buf) + 1)) << 16) + \ - ((png_uint_32)(*((buf) + 2)) << 8) + \ - ((png_uint_32)(*((buf) + 3)))) - - /* From libpng-1.4.0 until 1.4.4, the png_get_uint_16 macro (but not the - * function) incorrectly returned a value of type png_uint_32. - */ -# define png_get_uint_16(buf) \ - ((png_uint_16) \ - (((unsigned int)(*(buf)) << 8) + \ - ((unsigned int)(*((buf) + 1))))) - -# define png_get_int_32(buf) \ - ((png_int_32)((*(buf) & 0x80) \ - ? -((png_int_32)((png_get_uint_32(buf) ^ 0xffffffffL) + 1)) \ - : (png_int_32)png_get_uint_32(buf))) -#endif - -/* Maintainer: Put new public prototypes here ^, in libpng.3, and project - * defs - */ - -/* The last ordinal number (this is the *last* one already used; the next - * one to use is one more than this.) Maintainer, remember to add an entry to - * scripts/symbols.def as well. - */ -#ifdef PNG_EXPORT_LAST_ORDINAL - PNG_EXPORT_LAST_ORDINAL(233); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* PNG_VERSION_INFO_ONLY */ -/* Do not put anything past this line */ -#endif /* PNG_H */ diff --git a/include/nana/extrlib/pngconf.h b/include/nana/extrlib/pngconf.h deleted file mode 100644 index 6c1db14e..00000000 --- a/include/nana/extrlib/pngconf.h +++ /dev/null @@ -1,596 +0,0 @@ - -/* pngconf.h - machine configurable file for libpng - * - * libpng version 1.5.8 - February 1, 2012 - * - * Copyright (c) 1998-2012 Glenn Randers-Pehrson - * (Version 0.96 Copyright (c) 1996, 1997 Andreas Dilger) - * (Version 0.88 Copyright (c) 1995, 1996 Guy Eric Schalnat, Group 42, Inc.) - * - * This code is released under the libpng license. - * For conditions of distribution and use, see the disclaimer - * and license in png.h - * - */ - -/* Any machine specific code is near the front of this file, so if you - * are configuring libpng for a machine, you may want to read the section - * starting here down to where it starts to typedef png_color, png_text, - * and png_info. - */ - -#ifndef PNGCONF_H -#define PNGCONF_H - -#ifndef PNG_BUILDING_SYMBOL_TABLE -/* PNG_NO_LIMITS_H may be used to turn off the use of the standard C - * definition file for machine specific limits, this may impact the - * correctness of the definitons below (see uses of INT_MAX). - */ -# ifndef PNG_NO_LIMITS_H -# include -# endif - -/* For the memory copy APIs (i.e. the standard definitions of these), - * because this file defines png_memcpy and so on the base APIs must - * be defined here. - */ -# ifdef BSD -# include -# else -# include -# endif - -/* For png_FILE_p - this provides the standard definition of a - * FILE - */ -# ifdef PNG_STDIO_SUPPORTED -# include -# endif -#endif - -/* This controls optimization of the reading of 16 and 32 bit values - * from PNG files. It can be set on a per-app-file basis - it - * just changes whether a macro is used to the function is called. - * The library builder sets the default, if read functions are not - * built into the library the macro implementation is forced on. - */ -#ifndef PNG_READ_INT_FUNCTIONS_SUPPORTED -# define PNG_USE_READ_MACROS -#endif -#if !defined(PNG_NO_USE_READ_MACROS) && !defined(PNG_USE_READ_MACROS) -# if PNG_DEFAULT_READ_MACROS -# define PNG_USE_READ_MACROS -# endif -#endif - -/* COMPILER SPECIFIC OPTIONS. - * - * These options are provided so that a variety of difficult compilers - * can be used. Some are fixed at build time (e.g. PNG_API_RULE - * below) but still have compiler specific implementations, others - * may be changed on a per-file basis when compiling against libpng. - */ - -/* The PNGARG macro protects us against machines that don't have function - * prototypes (ie K&R style headers). If your compiler does not handle - * function prototypes, define this macro and use the included ansi2knr. - * I've always been able to use _NO_PROTO as the indicator, but you may - * need to drag the empty declaration out in front of here, or change the - * ifdef to suit your own needs. - */ -#ifndef PNGARG - -# ifdef OF /* zlib prototype munger */ -# define PNGARG(arglist) OF(arglist) -# else - -# ifdef _NO_PROTO -# define PNGARG(arglist) () -# else -# define PNGARG(arglist) arglist -# endif /* _NO_PROTO */ - -# endif /* OF */ - -#endif /* PNGARG */ - -/* Function calling conventions. - * ============================= - * Normally it is not necessary to specify to the compiler how to call - * a function - it just does it - however on x86 systems derived from - * Microsoft and Borland C compilers ('IBM PC', 'DOS', 'Windows' systems - * and some others) there are multiple ways to call a function and the - * default can be changed on the compiler command line. For this reason - * libpng specifies the calling convention of every exported function and - * every function called via a user supplied function pointer. This is - * done in this file by defining the following macros: - * - * PNGAPI Calling convention for exported functions. - * PNGCBAPI Calling convention for user provided (callback) functions. - * PNGCAPI Calling convention used by the ANSI-C library (required - * for longjmp callbacks and sometimes used internally to - * specify the calling convention for zlib). - * - * These macros should never be overridden. If it is necessary to - * change calling convention in a private build this can be done - * by setting PNG_API_RULE (which defaults to 0) to one of the values - * below to select the correct 'API' variants. - * - * PNG_API_RULE=0 Use PNGCAPI - the 'C' calling convention - throughout. - * This is correct in every known environment. - * PNG_API_RULE=1 Use the operating system convention for PNGAPI and - * the 'C' calling convention (from PNGCAPI) for - * callbacks (PNGCBAPI). This is no longer required - * in any known environment - if it has to be used - * please post an explanation of the problem to the - * libpng mailing list. - * - * These cases only differ if the operating system does not use the C - * calling convention, at present this just means the above cases - * (x86 DOS/Windows sytems) and, even then, this does not apply to - * Cygwin running on those systems. - * - * Note that the value must be defined in pnglibconf.h so that what - * the application uses to call the library matches the conventions - * set when building the library. - */ - -/* Symbol export - * ============= - * When building a shared library it is almost always necessary to tell - * the compiler which symbols to export. The png.h macro 'PNG_EXPORT' - * is used to mark the symbols. On some systems these symbols can be - * extracted at link time and need no special processing by the compiler, - * on other systems the symbols are flagged by the compiler and just - * the declaration requires a special tag applied (unfortunately) in a - * compiler dependent way. Some systems can do either. - * - * A small number of older systems also require a symbol from a DLL to - * be flagged to the program that calls it. This is a problem because - * we do not know in the header file included by application code that - * the symbol will come from a shared library, as opposed to a statically - * linked one. For this reason the application must tell us by setting - * the magic flag PNG_USE_DLL to turn on the special processing before - * it includes png.h. - * - * Four additional macros are used to make this happen: - * - * PNG_IMPEXP The magic (if any) to cause a symbol to be exported from - * the build or imported if PNG_USE_DLL is set - compiler - * and system specific. - * - * PNG_EXPORT_TYPE(type) A macro that pre or appends PNG_IMPEXP to - * 'type', compiler specific. - * - * PNG_DLL_EXPORT Set to the magic to use during a libpng build to - * make a symbol exported from the DLL. Not used in the - * public header files; see pngpriv.h for how it is used - * in the libpng build. - * - * PNG_DLL_IMPORT Set to the magic to force the libpng symbols to come - * from a DLL - used to define PNG_IMPEXP when - * PNG_USE_DLL is set. - */ - -/* System specific discovery. - * ========================== - * This code is used at build time to find PNG_IMPEXP, the API settings - * and PNG_EXPORT_TYPE(), it may also set a macro to indicate the DLL - * import processing is possible. On Windows/x86 systems it also sets - * compiler-specific macros to the values required to change the calling - * conventions of the various functions. - */ -#if ( defined(_Windows) || defined(_WINDOWS) || defined(WIN32) ||\ - defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__) ) &&\ - ( defined(_X86_) || defined(_X64_) || defined(_M_IX86) ||\ - defined(_M_X64) || defined(_M_IA64) ) - /* Windows system (DOS doesn't support DLLs) running on x86/x64. Includes - * builds under Cygwin or MinGW. Also includes Watcom builds but these need - * special treatment because they are not compatible with GCC or Visual C - * because of different calling conventions. - */ -# if PNG_API_RULE == 2 - /* If this line results in an error, either because __watcall is not - * understood or because of a redefine just below you cannot use *this* - * build of the library with the compiler you are using. *This* build was - * build using Watcom and applications must also be built using Watcom! - */ -# define PNGCAPI __watcall -# endif - -# if defined(__GNUC__) || (defined (_MSC_VER) && (_MSC_VER >= 800)) -# define PNGCAPI __cdecl -# if PNG_API_RULE == 1 -# define PNGAPI __stdcall -# endif -# else - /* An older compiler, or one not detected (erroneously) above, - * if necessary override on the command line to get the correct - * variants for the compiler. - */ -# ifndef PNGCAPI -# define PNGCAPI _cdecl -# endif -# if PNG_API_RULE == 1 && !defined(PNGAPI) -# define PNGAPI _stdcall -# endif -# endif /* compiler/api */ - /* NOTE: PNGCBAPI always defaults to PNGCAPI. */ - -# if defined(PNGAPI) && !defined(PNG_USER_PRIVATEBUILD) - ERROR: PNG_USER_PRIVATEBUILD must be defined if PNGAPI is changed -# endif - -# if (defined(_MSC_VER) && _MSC_VER < 800) ||\ - (defined(__BORLANDC__) && __BORLANDC__ < 0x500) - /* older Borland and MSC - * compilers used '__export' and required this to be after - * the type. - */ -# ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) type PNG_IMPEXP -# endif -# define PNG_DLL_EXPORT __export -# else /* newer compiler */ -# define PNG_DLL_EXPORT __declspec(dllexport) -# ifndef PNG_DLL_IMPORT -# define PNG_DLL_IMPORT __declspec(dllimport) -# endif -# endif /* compiler */ - -#else /* !Windows/x86 */ -# if (defined(__IBMC__) || defined(__IBMCPP__)) && defined(__OS2__) -# define PNGAPI _System -# else /* !Windows/x86 && !OS/2 */ - /* Use the defaults, or define PNG*API on the command line (but - * this will have to be done for every compile!) - */ -# endif /* other system, !OS/2 */ -#endif /* !Windows/x86 */ - -/* Now do all the defaulting . */ -#ifndef PNGCAPI -# define PNGCAPI -#endif -#ifndef PNGCBAPI -# define PNGCBAPI PNGCAPI -#endif -#ifndef PNGAPI -# define PNGAPI PNGCAPI -#endif - -/* PNG_IMPEXP may be set on the compilation system command line or (if not set) - * then in an internal header file when building the library, otherwise (when - * using the library) it is set here. - */ -#ifndef PNG_IMPEXP -# if defined(PNG_USE_DLL) && defined(PNG_DLL_IMPORT) - /* This forces use of a DLL, disallowing static linking */ -# define PNG_IMPEXP PNG_DLL_IMPORT -# endif - -# ifndef PNG_IMPEXP -# define PNG_IMPEXP -# endif -#endif - -/* In 1.5.2 the definition of PNG_FUNCTION has been changed to always treat - * 'attributes' as a storage class - the attributes go at the start of the - * function definition, and attributes are always appended regardless of the - * compiler. This considerably simplifies these macros but may cause problems - * if any compilers both need function attributes and fail to handle them as - * a storage class (this is unlikely.) - */ -#ifndef PNG_FUNCTION -# define PNG_FUNCTION(type, name, args, attributes) attributes type name args -#endif - -#ifndef PNG_EXPORT_TYPE -# define PNG_EXPORT_TYPE(type) PNG_IMPEXP type -#endif - - /* The ordinal value is only relevant when preprocessing png.h for symbol - * table entries, so we discard it here. See the .dfn files in the - * scripts directory. - */ -#ifndef PNG_EXPORTA - -# define PNG_EXPORTA(ordinal, type, name, args, attributes)\ - PNG_FUNCTION(PNG_EXPORT_TYPE(type),(PNGAPI name),PNGARG(args), \ - extern attributes) -#endif - -/* ANSI-C (C90) does not permit a macro to be invoked with an empty argument, - * so make something non-empty to satisfy the requirement: - */ -#define PNG_EMPTY /*empty list*/ - -#define PNG_EXPORT(ordinal, type, name, args)\ - PNG_EXPORTA(ordinal, type, name, args, PNG_EMPTY) - -/* Use PNG_REMOVED to comment out a removed interface. */ -#ifndef PNG_REMOVED -# define PNG_REMOVED(ordinal, type, name, args, attributes) -#endif - -#ifndef PNG_CALLBACK -# define PNG_CALLBACK(type, name, args) type (PNGCBAPI name) PNGARG(args) -#endif - -/* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. - * - * Added at libpng-1.2.41. - */ - -#ifndef PNG_NO_PEDANTIC_WARNINGS -# ifndef PNG_PEDANTIC_WARNINGS_SUPPORTED -# define PNG_PEDANTIC_WARNINGS_SUPPORTED -# endif -#endif - -#ifdef PNG_PEDANTIC_WARNINGS_SUPPORTED - /* Support for compiler specific function attributes. These are used - * so that where compiler support is available incorrect use of API - * functions in png.h will generate compiler warnings. Added at libpng - * version 1.2.41. - */ -# if defined(__GNUC__) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT __attribute__((__warn_unused_result__)) -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __attribute__((__noreturn__)) -# endif -# ifndef PNG_ALLOCATED -# define PNG_ALLOCATED __attribute__((__malloc__)) -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __attribute__((__deprecated__)) -# endif -# ifndef PNG_PRIVATE -# if 0 /* Doesn't work so we use deprecated instead*/ -# define PNG_PRIVATE \ - __attribute__((warning("This function is not exported by libpng."))) -# else -# define PNG_PRIVATE \ - __attribute__((__deprecated__)) -# endif -# endif -# endif /* __GNUC__ */ - -# if defined(_MSC_VER) && (_MSC_VER >= 1300) -# ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* not supported */ -# endif -# ifndef PNG_NORETURN -# define PNG_NORETURN __declspec(noreturn) -# endif -# ifndef PNG_ALLOCATED -# if (_MSC_VER >= 1400) -# define PNG_ALLOCATED __declspec(restrict) -# endif -# endif -# ifndef PNG_DEPRECATED -# define PNG_DEPRECATED __declspec(deprecated) -# endif -# ifndef PNG_PRIVATE -# define PNG_PRIVATE __declspec(deprecated) -# endif -# endif /* _MSC_VER */ -#endif /* PNG_PEDANTIC_WARNINGS */ - -#ifndef PNG_DEPRECATED -# define PNG_DEPRECATED /* Use of this function is deprecated */ -#endif -#ifndef PNG_USE_RESULT -# define PNG_USE_RESULT /* The result of this function must be checked */ -#endif -#ifndef PNG_NORETURN -# define PNG_NORETURN /* This function does not return */ -#endif -#ifndef PNG_ALLOCATED -# define PNG_ALLOCATED /* The result of the function is new memory */ -#endif -#ifndef PNG_PRIVATE -# define PNG_PRIVATE /* This is a private libpng function */ -#endif -#ifndef PNG_FP_EXPORT /* A floating point API. */ -# ifdef PNG_FLOATING_POINT_SUPPORTED -# define PNG_FP_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args) -# else /* No floating point APIs */ -# define PNG_FP_EXPORT(ordinal, type, name, args) -# endif -#endif -#ifndef PNG_FIXED_EXPORT /* A fixed point API. */ -# ifdef PNG_FIXED_POINT_SUPPORTED -# define PNG_FIXED_EXPORT(ordinal, type, name, args)\ - PNG_EXPORT(ordinal, type, name, args) -# else /* No fixed point APIs */ -# define PNG_FIXED_EXPORT(ordinal, type, name, args) -# endif -#endif - -/* The following uses const char * instead of char * for error - * and warning message functions, so some compilers won't complain. - * If you do not want to use const, define PNG_NO_CONST here. - * - * This should not change how the APIs are called, so it can be done - * on a per-file basis in the application. - */ -#ifndef PNG_CONST -# ifndef PNG_NO_CONST -# define PNG_CONST const -# else -# define PNG_CONST -# endif -#endif - -/* Some typedefs to get us started. These should be safe on most of the - * common platforms. The typedefs should be at least as large as the - * numbers suggest (a png_uint_32 must be at least 32 bits long), but they - * don't have to be exactly that size. Some compilers dislike passing - * unsigned shorts as function parameters, so you may be better off using - * unsigned int for png_uint_16. - */ - -#if defined(INT_MAX) && (INT_MAX > 0x7ffffffeL) -typedef unsigned int png_uint_32; -typedef int png_int_32; -#else -typedef unsigned long png_uint_32; -typedef long png_int_32; -#endif -typedef unsigned short png_uint_16; -typedef short png_int_16; -typedef unsigned char png_byte; - -#ifdef PNG_NO_SIZE_T -typedef unsigned int png_size_t; -#else -typedef size_t png_size_t; -#endif -#define png_sizeof(x) (sizeof (x)) - -/* The following is needed for medium model support. It cannot be in the - * pngpriv.h header. Needs modification for other compilers besides - * MSC. Model independent support declares all arrays and pointers to be - * large using the far keyword. The zlib version used must also support - * model independent data. As of version zlib 1.0.4, the necessary changes - * have been made in zlib. The USE_FAR_KEYWORD define triggers other - * changes that are needed. (Tim Wegner) - */ - -/* Separate compiler dependencies (problem here is that zlib.h always - * defines FAR. (SJT) - */ -#ifdef __BORLANDC__ -# if defined(__LARGE__) || defined(__HUGE__) || defined(__COMPACT__) -# define LDATA 1 -# else -# define LDATA 0 -# endif - /* GRR: why is Cygwin in here? Cygwin is not Borland C... */ -# if !defined(__WIN32__) && !defined(__FLAT__) && !defined(__CYGWIN__) -# define PNG_MAX_MALLOC_64K /* only used in build */ -# if (LDATA != 1) -# ifndef FAR -# define FAR __far -# endif -# define USE_FAR_KEYWORD -# endif /* LDATA != 1 */ - /* Possibly useful for moving data out of default segment. - * Uncomment it if you want. Could also define FARDATA as - * const if your compiler supports it. (SJT) -# define FARDATA FAR - */ -# endif /* __WIN32__, __FLAT__, __CYGWIN__ */ -#endif /* __BORLANDC__ */ - - -/* Suggest testing for specific compiler first before testing for - * FAR. The Watcom compiler defines both __MEDIUM__ and M_I86MM, - * making reliance oncertain keywords suspect. (SJT) - */ - -/* MSC Medium model */ -#ifdef FAR -# ifdef M_I86MM -# define USE_FAR_KEYWORD -# define FARDATA FAR -# include -# endif -#endif - -/* SJT: default case */ -#ifndef FAR -# define FAR -#endif - -/* At this point FAR is always defined */ -#ifndef FARDATA -# define FARDATA -#endif - -/* Typedef for floating-point numbers that are converted - * to fixed-point with a multiple of 100,000, e.g., gamma - */ -typedef png_int_32 png_fixed_point; - -/* Add typedefs for pointers */ -typedef void FAR * png_voidp; -typedef PNG_CONST void FAR * png_const_voidp; -typedef png_byte FAR * png_bytep; -typedef PNG_CONST png_byte FAR * png_const_bytep; -typedef png_uint_32 FAR * png_uint_32p; -typedef PNG_CONST png_uint_32 FAR * png_const_uint_32p; -typedef png_int_32 FAR * png_int_32p; -typedef PNG_CONST png_int_32 FAR * png_const_int_32p; -typedef png_uint_16 FAR * png_uint_16p; -typedef PNG_CONST png_uint_16 FAR * png_const_uint_16p; -typedef png_int_16 FAR * png_int_16p; -typedef PNG_CONST png_int_16 FAR * png_const_int_16p; -typedef char FAR * png_charp; -typedef PNG_CONST char FAR * png_const_charp; -typedef png_fixed_point FAR * png_fixed_point_p; -typedef PNG_CONST png_fixed_point FAR * png_const_fixed_point_p; -typedef png_size_t FAR * png_size_tp; -typedef PNG_CONST png_size_t FAR * png_const_size_tp; - -#ifdef PNG_STDIO_SUPPORTED -typedef FILE * png_FILE_p; -#endif - -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * png_doublep; -typedef PNG_CONST double FAR * png_const_doublep; -#endif - -/* Pointers to pointers; i.e. arrays */ -typedef png_byte FAR * FAR * png_bytepp; -typedef png_uint_32 FAR * FAR * png_uint_32pp; -typedef png_int_32 FAR * FAR * png_int_32pp; -typedef png_uint_16 FAR * FAR * png_uint_16pp; -typedef png_int_16 FAR * FAR * png_int_16pp; -typedef PNG_CONST char FAR * FAR * png_const_charpp; -typedef char FAR * FAR * png_charpp; -typedef png_fixed_point FAR * FAR * png_fixed_point_pp; -#ifdef PNG_FLOATING_POINT_SUPPORTED -typedef double FAR * FAR * png_doublepp; -#endif - -/* Pointers to pointers to pointers; i.e., pointer to array */ -typedef char FAR * FAR * FAR * png_charppp; - -/* png_alloc_size_t is guaranteed to be no smaller than png_size_t, - * and no smaller than png_uint_32. Casts from png_size_t or png_uint_32 - * to png_alloc_size_t are not necessary; in fact, it is recommended - * not to use them at all so that the compiler can complain when something - * turns out to be problematic. - * Casts in the other direction (from png_alloc_size_t to png_size_t or - * png_uint_32) should be explicitly applied; however, we do not expect - * to encounter practical situations that require such conversions. - */ -#if defined(__TURBOC__) && !defined(__FLAT__) - typedef unsigned long png_alloc_size_t; -#else -# if defined(_MSC_VER) && defined(MAXSEG_64K) - typedef unsigned long png_alloc_size_t; -# else - /* This is an attempt to detect an old Windows system where (int) is - * actually 16 bits, in that case png_malloc must have an argument with a - * bigger size to accomodate the requirements of the library. - */ -# if (defined(_Windows) || defined(_WINDOWS) || defined(_WINDOWS_)) && \ - (!defined(INT_MAX) || INT_MAX <= 0x7ffffffeL) - typedef DWORD png_alloc_size_t; -# else - typedef png_size_t png_alloc_size_t; -# endif -# endif -#endif - -#endif /* PNGCONF_H */ diff --git a/include/nana/extrlib/pnglibconf.h b/include/nana/extrlib/pnglibconf.h deleted file mode 100644 index 3ca1c16f..00000000 --- a/include/nana/extrlib/pnglibconf.h +++ /dev/null @@ -1,189 +0,0 @@ - -/* libpng STANDARD API DEFINITION */ - -/* pnglibconf.h - library build configuration */ - -/* Libpng 1.5.8 - February 1, 2012 */ - -/* Copyright (c) 1998-2011 Glenn Randers-Pehrson */ - -/* This code is released under the libpng license. */ -/* For conditions of distribution and use, see the disclaimer */ -/* and license in png.h */ - -/* pnglibconf.h */ -/* Derived from: scripts/pnglibconf.dfa */ -/* If you edit this file by hand you must obey the rules expressed in */ -/* pnglibconf.dfa with respect to the dependencies between the following */ -/* symbols. It is much better to generate a new file using */ -/* scripts/libpngconf.mak */ - -#ifndef PNGLCONF_H -#define PNGLCONF_H -/* settings */ -#define PNG_API_RULE 0 -#define PNG_CALLOC_SUPPORTED -#define PNG_COST_SHIFT 3 -#define PNG_DEFAULT_READ_MACROS 1 -#define PNG_GAMMA_THRESHOLD_FIXED 5000 -#define PNG_MAX_GAMMA_8 11 -#define PNG_QUANTIZE_BLUE_BITS 5 -#define PNG_QUANTIZE_GREEN_BITS 5 -#define PNG_QUANTIZE_RED_BITS 5 -#define PNG_sCAL_PRECISION 5 -#define PNG_USER_CHUNK_CACHE_MAX 0 -#define PNG_USER_CHUNK_MALLOC_MAX 0 -#define PNG_USER_HEIGHT_MAX 1000000 -#define PNG_USER_WIDTH_MAX 1000000 -#define PNG_WEIGHT_SHIFT 8 -#define PNG_ZBUF_SIZE 8192 -/* end of settings */ -/* options */ -#define PNG_16BIT_SUPPORTED -#define PNG_ALIGN_MEMORY_SUPPORTED -#define PNG_BENIGN_ERRORS_SUPPORTED -#define PNG_bKGD_SUPPORTED -#define PNG_BUILD_GRAYSCALE_PALETTE_SUPPORTED -#define PNG_CHECK_cHRM_SUPPORTED -#define PNG_cHRM_SUPPORTED -#define PNG_CONSOLE_IO_SUPPORTED -#define PNG_CONVERT_tIME_SUPPORTED -#define PNG_EASY_ACCESS_SUPPORTED -/*#undef PNG_ERROR_NUMBERS_SUPPORTED*/ -#define PNG_ERROR_TEXT_SUPPORTED -#define PNG_FIXED_POINT_SUPPORTED -#define PNG_FLOATING_ARITHMETIC_SUPPORTED -#define PNG_FLOATING_POINT_SUPPORTED -#define PNG_FORMAT_AFIRST_SUPPORTED -#define PNG_FORMAT_BGR_SUPPORTED -#define PNG_gAMA_SUPPORTED -#define PNG_HANDLE_AS_UNKNOWN_SUPPORTED -#define PNG_hIST_SUPPORTED -#define PNG_iCCP_SUPPORTED -#define PNG_INCH_CONVERSIONS_SUPPORTED -#define PNG_INFO_IMAGE_SUPPORTED -#define PNG_IO_STATE_SUPPORTED -#define PNG_iTXt_SUPPORTED -#define PNG_MNG_FEATURES_SUPPORTED -#define PNG_oFFs_SUPPORTED -#define PNG_pCAL_SUPPORTED -#define PNG_pHYs_SUPPORTED -#define PNG_POINTER_INDEXING_SUPPORTED -#define PNG_PROGRESSIVE_READ_SUPPORTED -#define PNG_READ_16BIT_SUPPORTED -#define PNG_READ_ALPHA_MODE_SUPPORTED -#define PNG_READ_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_READ_BACKGROUND_SUPPORTED -#define PNG_READ_BGR_SUPPORTED -#define PNG_READ_bKGD_SUPPORTED -#define PNG_READ_cHRM_SUPPORTED -#define PNG_READ_COMPOSITE_NODIV_SUPPORTED -#define PNG_READ_COMPRESSED_TEXT_SUPPORTED -#define PNG_READ_EXPAND_16_SUPPORTED -#define PNG_READ_EXPAND_SUPPORTED -#define PNG_READ_FILLER_SUPPORTED -#define PNG_READ_gAMA_SUPPORTED -#define PNG_READ_GAMMA_SUPPORTED -#define PNG_READ_GRAY_TO_RGB_SUPPORTED -#define PNG_READ_hIST_SUPPORTED -#define PNG_READ_iCCP_SUPPORTED -#define PNG_READ_INTERLACING_SUPPORTED -#define PNG_READ_INT_FUNCTIONS_SUPPORTED -#define PNG_READ_INVERT_ALPHA_SUPPORTED -#define PNG_READ_INVERT_SUPPORTED -#define PNG_READ_iTXt_SUPPORTED -#define PNG_READ_oFFs_SUPPORTED -#define PNG_READ_OPT_PLTE_SUPPORTED -#define PNG_READ_PACK_SUPPORTED -#define PNG_READ_PACKSWAP_SUPPORTED -#define PNG_READ_pCAL_SUPPORTED -#define PNG_READ_pHYs_SUPPORTED -#define PNG_READ_QUANTIZE_SUPPORTED -#define PNG_READ_RGB_TO_GRAY_SUPPORTED -#define PNG_READ_sBIT_SUPPORTED -#define PNG_READ_SCALE_16_TO_8_SUPPORTED -#define PNG_READ_sCAL_SUPPORTED -#define PNG_READ_SHIFT_SUPPORTED -#define PNG_READ_sPLT_SUPPORTED -#define PNG_READ_sRGB_SUPPORTED -#define PNG_READ_STRIP_16_TO_8_SUPPORTED -#define PNG_READ_STRIP_ALPHA_SUPPORTED -#define PNG_READ_SUPPORTED -#define PNG_READ_SWAP_ALPHA_SUPPORTED -#define PNG_READ_SWAP_SUPPORTED -#define PNG_READ_tEXt_SUPPORTED -#define PNG_READ_TEXT_SUPPORTED -#define PNG_READ_tIME_SUPPORTED -#define PNG_READ_TRANSFORMS_SUPPORTED -#define PNG_READ_tRNS_SUPPORTED -#define PNG_READ_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_READ_USER_CHUNKS_SUPPORTED -#define PNG_READ_USER_TRANSFORM_SUPPORTED -#define PNG_READ_zTXt_SUPPORTED -#define PNG_SAVE_INT_32_SUPPORTED -#define PNG_sBIT_SUPPORTED -#define PNG_sCAL_SUPPORTED -#define PNG_SEQUENTIAL_READ_SUPPORTED -#define PNG_SET_CHUNK_CACHE_LIMIT_SUPPORTED -#define PNG_SET_CHUNK_MALLOC_LIMIT_SUPPORTED -#define PNG_SETJMP_SUPPORTED -#define PNG_SET_USER_LIMITS_SUPPORTED -#define PNG_sPLT_SUPPORTED -#define PNG_sRGB_SUPPORTED -#define PNG_STDIO_SUPPORTED -#define PNG_tEXt_SUPPORTED -#define PNG_TEXT_SUPPORTED -#define PNG_TIME_RFC1123_SUPPORTED -#define PNG_tIME_SUPPORTED -#define PNG_tRNS_SUPPORTED -#define PNG_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_USER_CHUNKS_SUPPORTED -#define PNG_USER_LIMITS_SUPPORTED -#define PNG_USER_MEM_SUPPORTED -#define PNG_USER_TRANSFORM_INFO_SUPPORTED -#define PNG_USER_TRANSFORM_PTR_SUPPORTED -#define PNG_WARNINGS_SUPPORTED -#define PNG_WRITE_16BIT_SUPPORTED -#define PNG_WRITE_ANCILLARY_CHUNKS_SUPPORTED -#define PNG_WRITE_BGR_SUPPORTED -#define PNG_WRITE_bKGD_SUPPORTED -#define PNG_WRITE_cHRM_SUPPORTED -#define PNG_WRITE_COMPRESSED_TEXT_SUPPORTED -#define PNG_WRITE_CUSTOMIZE_ZTXT_COMPRESSION_SUPPORTED -#define PNG_WRITE_FILLER_SUPPORTED -#define PNG_WRITE_FILTER_SUPPORTED -#define PNG_WRITE_FLUSH_SUPPORTED -#define PNG_WRITE_gAMA_SUPPORTED -#define PNG_WRITE_hIST_SUPPORTED -#define PNG_WRITE_iCCP_SUPPORTED -#define PNG_WRITE_INTERLACING_SUPPORTED -#define PNG_WRITE_INT_FUNCTIONS_SUPPORTED -#define PNG_WRITE_INVERT_ALPHA_SUPPORTED -#define PNG_WRITE_INVERT_SUPPORTED -#define PNG_WRITE_iTXt_SUPPORTED -#define PNG_WRITE_oFFs_SUPPORTED -#define PNG_WRITE_OPTIMIZE_CMF_SUPPORTED -#define PNG_WRITE_PACK_SUPPORTED -#define PNG_WRITE_PACKSWAP_SUPPORTED -#define PNG_WRITE_pCAL_SUPPORTED -#define PNG_WRITE_pHYs_SUPPORTED -#define PNG_WRITE_sBIT_SUPPORTED -#define PNG_WRITE_sCAL_SUPPORTED -#define PNG_WRITE_SHIFT_SUPPORTED -#define PNG_WRITE_sPLT_SUPPORTED -#define PNG_WRITE_sRGB_SUPPORTED -#define PNG_WRITE_SUPPORTED -#define PNG_WRITE_SWAP_ALPHA_SUPPORTED -#define PNG_WRITE_SWAP_SUPPORTED -#define PNG_WRITE_tEXt_SUPPORTED -#define PNG_WRITE_TEXT_SUPPORTED -#define PNG_WRITE_tIME_SUPPORTED -#define PNG_WRITE_TRANSFORMS_SUPPORTED -#define PNG_WRITE_tRNS_SUPPORTED -#define PNG_WRITE_UNKNOWN_CHUNKS_SUPPORTED -#define PNG_WRITE_USER_TRANSFORM_SUPPORTED -#define PNG_WRITE_WEIGHTED_FILTER_SUPPORTED -#define PNG_WRITE_zTXt_SUPPORTED -#define PNG_zTXt_SUPPORTED -/* end of options */ -#endif /* PNGLCONF_H */ diff --git a/include/nana/extrlib/zlib.h b/include/nana/extrlib/zlib.h deleted file mode 100644 index 79142d11..00000000 --- a/include/nana/extrlib/zlib.h +++ /dev/null @@ -1,1732 +0,0 @@ -/* zlib.h -- interface of the 'zlib' general purpose compression library - version 1.2.6, January 29th, 2012 - - Copyright (C) 1995-2012 Jean-loup Gailly and Mark Adler - - This software is provided 'as-is', without any express or implied - warranty. In no event will the authors be held liable for any damages - arising from the use of this software. - - Permission is granted to anyone to use this software for any purpose, - including commercial applications, and to alter it and redistribute it - freely, subject to the following restrictions: - - 1. The origin of this software must not be misrepresented; you must not - claim that you wrote the original software. If you use this software - in a product, an acknowledgment in the product documentation would be - appreciated but is not required. - 2. Altered source versions must be plainly marked as such, and must not be - misrepresented as being the original software. - 3. This notice may not be removed or altered from any source distribution. - - Jean-loup Gailly Mark Adler - jloup@gzip.org madler@alumni.caltech.edu - - - The data format used by the zlib library is described by RFCs (Request for - Comments) 1950 to 1952 in the files http://tools.ietf.org/html/rfc1950 - (zlib format), rfc1951 (deflate format) and rfc1952 (gzip format). -*/ - -#ifndef ZLIB_H -#define ZLIB_H - -#include "zconf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define ZLIB_VERSION "1.2.6" -#define ZLIB_VERNUM 0x1260 -#define ZLIB_VER_MAJOR 1 -#define ZLIB_VER_MINOR 2 -#define ZLIB_VER_REVISION 6 -#define ZLIB_VER_SUBREVISION 0 - -/* - The 'zlib' compression library provides in-memory compression and - decompression functions, including integrity checks of the uncompressed data. - This version of the library supports only one compression method (deflation) - but other algorithms will be added later and will have the same stream - interface. - - Compression can be done in a single step if the buffers are large enough, - or can be done by repeated calls of the compression function. In the latter - case, the application must provide more input and/or consume the output - (providing more output space) before each call. - - The compressed data format used by default by the in-memory functions is - the zlib format, which is a zlib wrapper documented in RFC 1950, wrapped - around a deflate stream, which is itself documented in RFC 1951. - - The library also supports reading and writing files in gzip (.gz) format - with an interface similar to that of stdio using the functions that start - with "gz". The gzip format is different from the zlib format. gzip is a - gzip wrapper, documented in RFC 1952, wrapped around a deflate stream. - - This library can optionally read and write gzip streams in memory as well. - - The zlib format was designed to be compact and fast for use in memory - and on communications channels. The gzip format was designed for single- - file compression on file systems, has a larger header than zlib to maintain - directory information, and uses a different, slower check method than zlib. - - The library does not install any signal handler. The decoder checks - the consistency of the compressed data, so the library should never crash - even in case of corrupted input. -*/ - -typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); -typedef void (*free_func) OF((voidpf opaque, voidpf address)); - -struct internal_state; - -typedef struct z_stream_s { - z_const Bytef *next_in; /* next input byte */ - uInt avail_in; /* number of bytes available at next_in */ - uLong total_in; /* total number of input bytes read so far */ - - Bytef *next_out; /* next output byte should be put there */ - uInt avail_out; /* remaining free space at next_out */ - uLong total_out; /* total number of bytes output so far */ - - z_const char *msg; /* last error message, NULL if no error */ - struct internal_state FAR *state; /* not visible by applications */ - - alloc_func zalloc; /* used to allocate the internal state */ - free_func zfree; /* used to free the internal state */ - voidpf opaque; /* private data object passed to zalloc and zfree */ - - int data_type; /* best guess about the data type: binary or text */ - uLong adler; /* adler32 value of the uncompressed data */ - uLong reserved; /* reserved for future use */ -} z_stream; - -typedef z_stream FAR *z_streamp; - -/* - gzip header information passed to and from zlib routines. See RFC 1952 - for more details on the meanings of these fields. -*/ -typedef struct gz_header_s { - int text; /* true if compressed data believed to be text */ - uLong time; /* modification time */ - int xflags; /* extra flags (not used when writing a gzip file) */ - int os; /* operating system */ - Bytef *extra; /* pointer to extra field or Z_NULL if none */ - uInt extra_len; /* extra field length (valid if extra != Z_NULL) */ - uInt extra_max; /* space at extra (only when reading header) */ - Bytef *name; /* pointer to zero-terminated file name or Z_NULL */ - uInt name_max; /* space at name (only when reading header) */ - Bytef *comment; /* pointer to zero-terminated comment or Z_NULL */ - uInt comm_max; /* space at comment (only when reading header) */ - int hcrc; /* true if there was or will be a header crc */ - int done; /* true when done reading gzip header (not used - when writing a gzip file) */ -} gz_header; - -typedef gz_header FAR *gz_headerp; - -/* - The application must update next_in and avail_in when avail_in has dropped - to zero. It must update next_out and avail_out when avail_out has dropped - to zero. The application must initialize zalloc, zfree and opaque before - calling the init function. All other fields are set by the compression - library and must not be updated by the application. - - The opaque value provided by the application will be passed as the first - parameter for calls of zalloc and zfree. This can be useful for custom - memory management. The compression library attaches no meaning to the - opaque value. - - zalloc must return Z_NULL if there is not enough memory for the object. - If zlib is used in a multi-threaded application, zalloc and zfree must be - thread safe. - - On 16-bit systems, the functions zalloc and zfree must be able to allocate - exactly 65536 bytes, but will not be required to allocate more than this if - the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, pointers - returned by zalloc for objects of exactly 65536 bytes *must* have their - offset normalized to zero. The default allocation function provided by this - library ensures this (see zutil.c). To reduce memory requirements and avoid - any allocation of 64K objects, at the expense of compression ratio, compile - the library with -DMAX_WBITS=14 (see zconf.h). - - The fields total_in and total_out can be used for statistics or progress - reports. After compression, total_in holds the total size of the - uncompressed data and may be saved for use in the decompressor (particularly - if the decompressor wants to decompress everything in a single step). -*/ - - /* constants */ - -#define Z_NO_FLUSH 0 -#define Z_PARTIAL_FLUSH 1 -#define Z_SYNC_FLUSH 2 -#define Z_FULL_FLUSH 3 -#define Z_FINISH 4 -#define Z_BLOCK 5 -#define Z_TREES 6 -/* Allowed flush values; see deflate() and inflate() below for details */ - -#define Z_OK 0 -#define Z_STREAM_END 1 -#define Z_NEED_DICT 2 -#define Z_ERRNO (-1) -#define Z_STREAM_ERROR (-2) -#define Z_DATA_ERROR (-3) -#define Z_MEM_ERROR (-4) -#define Z_BUF_ERROR (-5) -#define Z_VERSION_ERROR (-6) -/* Return codes for the compression/decompression functions. Negative values - * are errors, positive values are used for special but normal events. - */ - -#define Z_NO_COMPRESSION 0 -#define Z_BEST_SPEED 1 -#define Z_BEST_COMPRESSION 9 -#define Z_DEFAULT_COMPRESSION (-1) -/* compression levels */ - -#define Z_FILTERED 1 -#define Z_HUFFMAN_ONLY 2 -#define Z_RLE 3 -#define Z_FIXED 4 -#define Z_DEFAULT_STRATEGY 0 -/* compression strategy; see deflateInit2() below for details */ - -#define Z_BINARY 0 -#define Z_TEXT 1 -#define Z_ASCII Z_TEXT /* for compatibility with 1.2.2 and earlier */ -#define Z_UNKNOWN 2 -/* Possible values of the data_type field (though see inflate()) */ - -#define Z_DEFLATED 8 -/* The deflate compression method (the only one supported in this version) */ - -#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ - -#define zlib_version zlibVersion() -/* for compatibility with versions < 1.0.2 */ - - - /* basic functions */ - -ZEXTERN const char * ZEXPORT zlibVersion OF((void)); -/* The application can compare zlibVersion and ZLIB_VERSION for consistency. - If the first character differs, the library code actually used is not - compatible with the zlib.h header file used by the application. This check - is automatically made by deflateInit and inflateInit. - */ - -/* -ZEXTERN int ZEXPORT deflateInit OF((z_streamp strm, int level)); - - Initializes the internal stream state for compression. The fields - zalloc, zfree and opaque must be initialized before by the caller. If - zalloc and zfree are set to Z_NULL, deflateInit updates them to use default - allocation functions. - - The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: - 1 gives best speed, 9 gives best compression, 0 gives no compression at all - (the input data is simply copied a block at a time). Z_DEFAULT_COMPRESSION - requests a default compromise between speed and compression (currently - equivalent to level 6). - - deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if level is not a valid compression level, or - Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible - with the version assumed by the caller (ZLIB_VERSION). msg is set to null - if there is no error message. deflateInit does not perform any compression: - this will be done by deflate(). -*/ - - -ZEXTERN int ZEXPORT deflate OF((z_streamp strm, int flush)); -/* - deflate compresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. deflate performs one or both of the - following actions: - - - Compress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in and avail_in are updated and - processing will resume at this point for the next call of deflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. This action is forced if the parameter flush is non zero. - Forcing flush frequently degrades the compression ratio, so this parameter - should be set only when necessary (in interactive applications). Some - output may be provided even if flush is not set. - - Before the call of deflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating avail_in or avail_out accordingly; avail_out should - never be zero before the call. The application can consume the compressed - output when it wants, for example when the output buffer is full (avail_out - == 0), or after each call of deflate(). If deflate returns Z_OK and with - zero avail_out, it must be called again after making room in the output - buffer because there might be more output pending. - - Normally the parameter flush is set to Z_NO_FLUSH, which allows deflate to - decide how much data to accumulate before producing output, in order to - maximize compression. - - If the parameter flush is set to Z_SYNC_FLUSH, all pending output is - flushed to the output buffer and the output is aligned on a byte boundary, so - that the decompressor can get all input data available so far. (In - particular avail_in is zero after the call if enough output space has been - provided before the call.) Flushing may degrade compression for some - compression algorithms and so it should be used only when necessary. This - completes the current deflate block and follows it with an empty stored block - that is three bits plus filler bits to the next byte, followed by four bytes - (00 00 ff ff). - - If flush is set to Z_PARTIAL_FLUSH, all pending output is flushed to the - output buffer, but the output is not aligned to a byte boundary. All of the - input data so far will be available to the decompressor, as for Z_SYNC_FLUSH. - This completes the current deflate block and follows it with an empty fixed - codes block that is 10 bits long. This assures that enough bytes are output - in order for the decompressor to finish the block before the empty fixed code - block. - - If flush is set to Z_BLOCK, a deflate block is completed and emitted, as - for Z_SYNC_FLUSH, but the output is not aligned on a byte boundary, and up to - seven bits of the current block are held to be written as the next byte after - the next deflate block is completed. In this case, the decompressor may not - be provided enough bits at this point in order to complete decompression of - the data provided so far to the compressor. It may need to wait for the next - block to be emitted. This is for advanced applications that need to control - the emission of deflate blocks. - - If flush is set to Z_FULL_FLUSH, all output is flushed as with - Z_SYNC_FLUSH, and the compression state is reset so that decompression can - restart from this point if previous compressed data has been damaged or if - random access is desired. Using Z_FULL_FLUSH too often can seriously degrade - compression. - - If deflate returns with avail_out == 0, this function must be called again - with the same value of the flush parameter and more output space (updated - avail_out), until the flush is complete (deflate returns with non-zero - avail_out). In the case of a Z_FULL_FLUSH or Z_SYNC_FLUSH, make sure that - avail_out is greater than six to avoid repeated flush markers due to - avail_out == 0 on return. - - If the parameter flush is set to Z_FINISH, pending input is processed, - pending output is flushed and deflate returns with Z_STREAM_END if there was - enough output space; if deflate returns with Z_OK, this function must be - called again with Z_FINISH and more output space (updated avail_out) but no - more input data, until it returns with Z_STREAM_END or an error. After - deflate has returned Z_STREAM_END, the only possible operations on the stream - are deflateReset or deflateEnd. - - Z_FINISH can be used immediately after deflateInit if all the compression - is to be done in a single step. In this case, avail_out must be at least the - value returned by deflateBound (see below). Then deflate is guaranteed to - return Z_STREAM_END. If not enough output space is provided, deflate will - not return Z_STREAM_END, and it must be called again as described above. - - deflate() sets strm->adler to the adler32 checksum of all input read - so far (that is, total_in bytes). - - deflate() may update strm->data_type if it can make a good guess about - the input data type (Z_BINARY or Z_TEXT). In doubt, the data is considered - binary. This field is only for information purposes and does not affect the - compression algorithm in any manner. - - deflate() returns Z_OK if some progress has been made (more input - processed or more output produced), Z_STREAM_END if all input has been - consumed and all output has been produced (only when flush is set to - Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example - if next_in or next_out was Z_NULL), Z_BUF_ERROR if no progress is possible - (for example avail_in or avail_out was zero). Note that Z_BUF_ERROR is not - fatal, and deflate() can be called again with more input and more output - space to continue compressing. -*/ - - -ZEXTERN int ZEXPORT deflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the - stream state was inconsistent, Z_DATA_ERROR if the stream was freed - prematurely (some input or output was discarded). In the error case, msg - may be set but then points to a static string (which must not be - deallocated). -*/ - - -/* -ZEXTERN int ZEXPORT inflateInit OF((z_streamp strm)); - - Initializes the internal stream state for decompression. The fields - next_in, avail_in, zalloc, zfree and opaque must be initialized before by - the caller. If next_in is not Z_NULL and avail_in is large enough (the - exact value depends on the compression method), inflateInit determines the - compression method from the zlib header and allocates all data structures - accordingly; otherwise the allocation will be deferred to the first call of - inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to - use default allocation functions. - - inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit() does not process any header information -- that is deferred - until inflate() is called. -*/ - - -ZEXTERN int ZEXPORT inflate OF((z_streamp strm, int flush)); -/* - inflate decompresses as much data as possible, and stops when the input - buffer becomes empty or the output buffer becomes full. It may introduce - some output latency (reading input without producing any output) except when - forced to flush. - - The detailed semantics are as follows. inflate performs one or both of the - following actions: - - - Decompress more input starting at next_in and update next_in and avail_in - accordingly. If not all input can be processed (because there is not - enough room in the output buffer), next_in is updated and processing will - resume at this point for the next call of inflate(). - - - Provide more output starting at next_out and update next_out and avail_out - accordingly. inflate() provides as much output as possible, until there is - no more input data or no more space in the output buffer (see below about - the flush parameter). - - Before the call of inflate(), the application should ensure that at least - one of the actions is possible, by providing more input and/or consuming more - output, and updating the next_* and avail_* values accordingly. The - application can consume the uncompressed output when it wants, for example - when the output buffer is full (avail_out == 0), or after each call of - inflate(). If inflate returns Z_OK and with zero avail_out, it must be - called again after making room in the output buffer because there might be - more output pending. - - The flush parameter of inflate() can be Z_NO_FLUSH, Z_SYNC_FLUSH, Z_FINISH, - Z_BLOCK, or Z_TREES. Z_SYNC_FLUSH requests that inflate() flush as much - output as possible to the output buffer. Z_BLOCK requests that inflate() - stop if and when it gets to the next deflate block boundary. When decoding - the zlib or gzip format, this will cause inflate() to return immediately - after the header and before the first block. When doing a raw inflate, - inflate() will go ahead and process the first block, and will return when it - gets to the end of that block, or when it runs out of data. - - The Z_BLOCK option assists in appending to or combining deflate streams. - Also to assist in this, on return inflate() will set strm->data_type to the - number of unused bits in the last byte taken from strm->next_in, plus 64 if - inflate() is currently decoding the last block in the deflate stream, plus - 128 if inflate() returned immediately after decoding an end-of-block code or - decoding the complete header up to just before the first byte of the deflate - stream. The end-of-block will not be indicated until all of the uncompressed - data from that block has been written to strm->next_out. The number of - unused bits may in general be greater than seven, except when bit 7 of - data_type is set, in which case the number of unused bits will be less than - eight. data_type is set as noted here every time inflate() returns for all - flush options, and so can be used to determine the amount of currently - consumed input in bits. - - The Z_TREES option behaves as Z_BLOCK does, but it also returns when the - end of each deflate block header is reached, before any actual data in that - block is decoded. This allows the caller to determine the length of the - deflate block header for later use in random access within a deflate block. - 256 is added to the value of strm->data_type when inflate() returns - immediately after reaching the end of the deflate block header. - - inflate() should normally be called until it returns Z_STREAM_END or an - error. However if all decompression is to be performed in a single step (a - single call of inflate), the parameter flush should be set to Z_FINISH. In - this case all pending input is processed and all pending output is flushed; - avail_out must be large enough to hold all the uncompressed data. (The size - of the uncompressed data may have been saved by the compressor for this - purpose.) The next operation on this stream must be inflateEnd to deallocate - the decompression state. The use of Z_FINISH is not required to perform an - inflation in one step. However it may be used to inform inflate that a - faster approach can be used for the single inflate() call. Z_FINISH also - informs inflate to not maintain a sliding window if the stream completes, - which reduces inflate's memory footprint. - - In this implementation, inflate() always flushes as much output as - possible to the output buffer, and always uses the faster approach on the - first call. So the effects of the flush parameter in this implementation are - on the return value of inflate() as noted below, when inflate() returns early - when Z_BLOCK or Z_TREES is used, and when inflate() avoids the allocation of - memory for a sliding window when Z_FINISH is used. - - If a preset dictionary is needed after this call (see inflateSetDictionary - below), inflate sets strm->adler to the Adler-32 checksum of the dictionary - chosen by the compressor and returns Z_NEED_DICT; otherwise it sets - strm->adler to the Adler-32 checksum of all output produced so far (that is, - total_out bytes) and returns Z_OK, Z_STREAM_END or an error code as described - below. At the end of the stream, inflate() checks that its computed adler32 - checksum is equal to that saved by the compressor and returns Z_STREAM_END - only if the checksum is correct. - - inflate() can decompress and check either zlib-wrapped or gzip-wrapped - deflate data. The header type is detected automatically, if requested when - initializing with inflateInit2(). Any information contained in the gzip - header is not retained, so applications that need that information should - instead use raw inflate, see inflateInit2() below, or inflateBack() and - perform their own processing of the gzip header and trailer. When processing - gzip-wrapped deflate data, strm->adler32 is set to the CRC-32 of the output - producted so far. The CRC-32 is checked against the gzip trailer. - - inflate() returns Z_OK if some progress has been made (more input processed - or more output produced), Z_STREAM_END if the end of the compressed data has - been reached and all uncompressed output has been produced, Z_NEED_DICT if a - preset dictionary is needed at this point, Z_DATA_ERROR if the input data was - corrupted (input stream not conforming to the zlib format or incorrect check - value), Z_STREAM_ERROR if the stream structure was inconsistent (for example - next_in or next_out was Z_NULL), Z_MEM_ERROR if there was not enough memory, - Z_BUF_ERROR if no progress is possible or if there was not enough room in the - output buffer when Z_FINISH is used. Note that Z_BUF_ERROR is not fatal, and - inflate() can be called again with more input and more output space to - continue decompressing. If Z_DATA_ERROR is returned, the application may - then call inflateSync() to look for a good compression block if a partial - recovery of the data is desired. -*/ - - -ZEXTERN int ZEXPORT inflateEnd OF((z_streamp strm)); -/* - All dynamically allocated data structures for this stream are freed. - This function discards any unprocessed input and does not flush any pending - output. - - inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state - was inconsistent. In the error case, msg may be set but then points to a - static string (which must not be deallocated). -*/ - - - /* Advanced functions */ - -/* - The following functions are needed only in some special applications. -*/ - -/* -ZEXTERN int ZEXPORT deflateInit2 OF((z_streamp strm, - int level, - int method, - int windowBits, - int memLevel, - int strategy)); - - This is another version of deflateInit with more compression options. The - fields next_in, zalloc, zfree and opaque must be initialized before by the - caller. - - The method parameter is the compression method. It must be Z_DEFLATED in - this version of the library. - - The windowBits parameter is the base two logarithm of the window size - (the size of the history buffer). It should be in the range 8..15 for this - version of the library. Larger values of this parameter result in better - compression at the expense of memory usage. The default value is 15 if - deflateInit is used instead. - - windowBits can also be -8..-15 for raw deflate. In this case, -windowBits - determines the window size. deflate() will then generate raw deflate data - with no zlib header or trailer, and will not compute an adler32 check value. - - windowBits can also be greater than 15 for optional gzip encoding. Add - 16 to windowBits to write a simple gzip header and trailer around the - compressed data instead of a zlib wrapper. The gzip header will have no - file name, no extra data, no comment, no modification time (set to zero), no - header crc, and the operating system will be set to 255 (unknown). If a - gzip stream is being written, strm->adler is a crc32 instead of an adler32. - - The memLevel parameter specifies how much memory should be allocated - for the internal compression state. memLevel=1 uses minimum memory but is - slow and reduces compression ratio; memLevel=9 uses maximum memory for - optimal speed. The default value is 8. See zconf.h for total memory usage - as a function of windowBits and memLevel. - - The strategy parameter is used to tune the compression algorithm. Use the - value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a - filter (or predictor), Z_HUFFMAN_ONLY to force Huffman encoding only (no - string match), or Z_RLE to limit match distances to one (run-length - encoding). Filtered data consists mostly of small values with a somewhat - random distribution. In this case, the compression algorithm is tuned to - compress them better. The effect of Z_FILTERED is to force more Huffman - coding and less string matching; it is somewhat intermediate between - Z_DEFAULT_STRATEGY and Z_HUFFMAN_ONLY. Z_RLE is designed to be almost as - fast as Z_HUFFMAN_ONLY, but give better compression for PNG image data. The - strategy parameter only affects the compression ratio but not the - correctness of the compressed output even if it is not set appropriately. - Z_FIXED prevents the use of dynamic Huffman codes, allowing for a simpler - decoder for special applications. - - deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_STREAM_ERROR if any parameter is invalid (such as an invalid - method), or Z_VERSION_ERROR if the zlib library version (zlib_version) is - incompatible with the version assumed by the caller (ZLIB_VERSION). msg is - set to null if there is no error message. deflateInit2 does not perform any - compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the compression dictionary from the given byte sequence - without producing any compressed output. When using the zlib format, this - function must be called immediately after deflateInit, deflateInit2 or - deflateReset, and before any call of deflate. When doing raw deflate, this - function must be called either before any call of deflate, or immediately - after the completion of a deflate block, i.e. after all input has been - consumed and all output has been delivered when using any of the flush - options Z_BLOCK, Z_PARTIAL_FLUSH, Z_SYNC_FLUSH, or Z_FULL_FLUSH. The - compressor and decompressor must use exactly the same dictionary (see - inflateSetDictionary). - - The dictionary should consist of strings (byte sequences) that are likely - to be encountered later in the data to be compressed, with the most commonly - used strings preferably put towards the end of the dictionary. Using a - dictionary is most useful when the data to be compressed is short and can be - predicted with good accuracy; the data can then be compressed better than - with the default empty dictionary. - - Depending on the size of the compression data structures selected by - deflateInit or deflateInit2, a part of the dictionary may in effect be - discarded, for example if the dictionary is larger than the window size - provided in deflateInit or deflateInit2. Thus the strings most likely to be - useful should be put at the end of the dictionary, not at the front. In - addition, the current implementation of deflate will use at most the window - size minus 262 bytes of the provided dictionary. - - Upon return of this function, strm->adler is set to the adler32 value - of the dictionary; the decompressor may later use this value to determine - which dictionary has been used by the compressor. (The adler32 value - applies to the whole dictionary even if only a subset of the dictionary is - actually used by the compressor.) If a raw deflate was requested, then the - adler32 value is not computed and strm->adler is not set. - - deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent (for example if deflate has already been called for this stream - or if not at a block boundary for raw deflate). deflateSetDictionary does - not perform any compression: this will be done by deflate(). -*/ - -ZEXTERN int ZEXPORT deflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when several compression strategies will be - tried, for example when there are several ways of pre-processing the input - data with a filter. The streams that will be discarded should then be freed - by calling deflateEnd. Note that deflateCopy duplicates the internal - compression state which can be quite large, so this strategy is slow and can - consume lots of memory. - - deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT deflateReset OF((z_streamp strm)); -/* - This function is equivalent to deflateEnd followed by deflateInit, - but does not free and reallocate all the internal compression state. The - stream will keep the same compression level and any other attributes that - may have been set by deflateInit2. - - deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT deflateParams OF((z_streamp strm, - int level, - int strategy)); -/* - Dynamically update the compression level and compression strategy. The - interpretation of level and strategy is as in deflateInit2. This can be - used to switch between compression and straight copy of the input data, or - to switch to a different kind of input data requiring a different strategy. - If the compression level is changed, the input available so far is - compressed with the old level (and may be flushed); the new level will take - effect only at the next call of deflate(). - - Before the call of deflateParams, the stream state must be set as for - a call of deflate(), since the currently available input may have to be - compressed and flushed. In particular, strm->avail_out must be non-zero. - - deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source - stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR if - strm->avail_out was zero. -*/ - -ZEXTERN int ZEXPORT deflateTune OF((z_streamp strm, - int good_length, - int max_lazy, - int nice_length, - int max_chain)); -/* - Fine tune deflate's internal compression parameters. This should only be - used by someone who understands the algorithm used by zlib's deflate for - searching for the best matching string, and even then only by the most - fanatic optimizer trying to squeeze out the last compressed bit for their - specific input data. Read the deflate.c source code for the meaning of the - max_lazy, good_length, nice_length, and max_chain parameters. - - deflateTune() can be called after deflateInit() or deflateInit2(), and - returns Z_OK on success, or Z_STREAM_ERROR for an invalid deflate stream. - */ - -ZEXTERN uLong ZEXPORT deflateBound OF((z_streamp strm, - uLong sourceLen)); -/* - deflateBound() returns an upper bound on the compressed size after - deflation of sourceLen bytes. It must be called after deflateInit() or - deflateInit2(), and after deflateSetHeader(), if used. This would be used - to allocate an output buffer for deflation in a single pass, and so would be - called before deflate(). If that first deflate() call is provided the - sourceLen input bytes, an output buffer allocated to the size returned by - deflateBound(), and the flush value Z_FINISH, then deflate() is guaranteed - to return Z_STREAM_END. Note that it is possible for the compressed size to - be larger than the value returned by deflateBound() if flush options other - than Z_FINISH or Z_NO_FLUSH are used. -*/ - -ZEXTERN int ZEXPORT deflatePending OF((z_streamp strm, - unsigned *pending, - int *bits)); -/* - deflatePending() returns the number of bytes and bits of output that have - been generated, but not yet provided in the available output. The bytes not - provided would be due to the available output space having being consumed. - The number of bits of output not provided are between 0 and 7, where they - await more bits to join them in order to fill out a full byte. If pending - or bits are Z_NULL, then those values are not set. - - deflatePending returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. - */ - -ZEXTERN int ZEXPORT deflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - deflatePrime() inserts bits in the deflate output stream. The intent - is that this function is used to start off the deflate output with the bits - leftover from a previous deflate stream when appending to it. As such, this - function can only be used for raw deflate, and must be used before the first - deflate() call after a deflateInit2() or deflateReset(). bits must be less - than or equal to 16, and that many of the least significant bits of value - will be inserted in the output. - - deflatePrime returns Z_OK if success, Z_BUF_ERROR if there was not enough - room in the internal buffer to insert the bits, or Z_STREAM_ERROR if the - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT deflateSetHeader OF((z_streamp strm, - gz_headerp head)); -/* - deflateSetHeader() provides gzip header information for when a gzip - stream is requested by deflateInit2(). deflateSetHeader() may be called - after deflateInit2() or deflateReset() and before the first call of - deflate(). The text, time, os, extra field, name, and comment information - in the provided gz_header structure are written to the gzip header (xflag is - ignored -- the extra flags are set according to the compression level). The - caller must assure that, if not Z_NULL, name and comment are terminated with - a zero byte, and that if extra is not Z_NULL, that extra_len bytes are - available there. If hcrc is true, a gzip header crc is included. Note that - the current versions of the command-line version of gzip (up through version - 1.3.x) do not support header crc's, and will report that it is a "multi-part - gzip file" and give up. - - If deflateSetHeader is not used, the default gzip header has text false, - the time set to zero, and os set to 255, with no extra, name, or comment - fields. The gzip header is returned to the default state by deflateReset(). - - deflateSetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateInit2 OF((z_streamp strm, - int windowBits)); - - This is another version of inflateInit with an extra parameter. The - fields next_in, avail_in, zalloc, zfree and opaque must be initialized - before by the caller. - - The windowBits parameter is the base two logarithm of the maximum window - size (the size of the history buffer). It should be in the range 8..15 for - this version of the library. The default value is 15 if inflateInit is used - instead. windowBits must be greater than or equal to the windowBits value - provided to deflateInit2() while compressing, or it must be equal to 15 if - deflateInit2() was not used. If a compressed stream with a larger window - size is given as input, inflate() will return with the error code - Z_DATA_ERROR instead of trying to allocate a larger window. - - windowBits can also be zero to request that inflate use the window size in - the zlib header of the compressed stream. - - windowBits can also be -8..-15 for raw inflate. In this case, -windowBits - determines the window size. inflate() will then process raw deflate data, - not looking for a zlib or gzip header, not generating a check value, and not - looking for any check values for comparison at the end of the stream. This - is for use with other formats that use the deflate compressed data format - such as zip. Those formats provide their own check values. If a custom - format is developed using the raw deflate format for compressed data, it is - recommended that a check value such as an adler32 or a crc32 be applied to - the uncompressed data as is done in the zlib, gzip, and zip formats. For - most applications, the zlib format should be used as is. Note that comments - above on the use in deflateInit2() applies to the magnitude of windowBits. - - windowBits can also be greater than 15 for optional gzip decoding. Add - 32 to windowBits to enable zlib and gzip decoding with automatic header - detection, or add 16 to decode only the gzip format (the zlib format will - return a Z_DATA_ERROR). If a gzip stream is being decoded, strm->adler is a - crc32 instead of an adler32. - - inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_VERSION_ERROR if the zlib library version is incompatible with the - version assumed by the caller, or Z_STREAM_ERROR if the parameters are - invalid, such as a null pointer to the structure. msg is set to null if - there is no error message. inflateInit2 does not perform any decompression - apart from possibly reading the zlib header if present: actual decompression - will be done by inflate(). (So next_in and avail_in may be modified, but - next_out and avail_out are unused and unchanged.) The current implementation - of inflateInit2() does not process any header information -- that is - deferred until inflate() is called. -*/ - -ZEXTERN int ZEXPORT inflateSetDictionary OF((z_streamp strm, - const Bytef *dictionary, - uInt dictLength)); -/* - Initializes the decompression dictionary from the given uncompressed byte - sequence. This function must be called immediately after a call of inflate, - if that call returned Z_NEED_DICT. The dictionary chosen by the compressor - can be determined from the adler32 value returned by that call of inflate. - The compressor and decompressor must use exactly the same dictionary (see - deflateSetDictionary). For raw inflate, this function can be called at any - time to set the dictionary. If the provided dictionary is smaller than the - window and there is already data in the window, then the provided dictionary - will amend what's there. The application must insure that the dictionary - that was used for compression is provided. - - inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a - parameter is invalid (e.g. dictionary being Z_NULL) or the stream state is - inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the - expected one (incorrect adler32 value). inflateSetDictionary does not - perform any decompression: this will be done by subsequent calls of - inflate(). -*/ - -ZEXTERN int ZEXPORT inflateSync OF((z_streamp strm)); -/* - Skips invalid compressed data until a possible full flush point (see above - for the description of deflate with Z_FULL_FLUSH) can be found, or until all - available input is skipped. No output is provided. - - inflateSync searches for a 00 00 FF FF pattern in the compressed data. - All full flush points have this pattern, but not all occurences of this - pattern are full flush points. - - inflateSync returns Z_OK if a possible full flush point has been found, - Z_BUF_ERROR if no more input was provided, Z_DATA_ERROR if no flush point - has been found, or Z_STREAM_ERROR if the stream structure was inconsistent. - In the success case, the application may save the current current value of - total_in which indicates where valid compressed data was found. In the - error case, the application may repeatedly call inflateSync, providing more - input each time, until success or end of the input data. -*/ - -ZEXTERN int ZEXPORT inflateCopy OF((z_streamp dest, - z_streamp source)); -/* - Sets the destination stream as a complete copy of the source stream. - - This function can be useful when randomly accessing a large stream. The - first pass through the stream can periodically record the inflate state, - allowing restarting inflate at those points when randomly accessing the - stream. - - inflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_STREAM_ERROR if the source stream state was inconsistent - (such as zalloc being Z_NULL). msg is left unchanged in both source and - destination. -*/ - -ZEXTERN int ZEXPORT inflateReset OF((z_streamp strm)); -/* - This function is equivalent to inflateEnd followed by inflateInit, - but does not free and reallocate all the internal decompression state. The - stream will keep attributes that may have been set by inflateInit2. - - inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL). -*/ - -ZEXTERN int ZEXPORT inflateReset2 OF((z_streamp strm, - int windowBits)); -/* - This function is the same as inflateReset, but it also permits changing - the wrap and window size requests. The windowBits parameter is interpreted - the same as it is for inflateInit2. - - inflateReset2 returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent (such as zalloc or state being Z_NULL), or if - the windowBits parameter is invalid. -*/ - -ZEXTERN int ZEXPORT inflatePrime OF((z_streamp strm, - int bits, - int value)); -/* - This function inserts bits in the inflate input stream. The intent is - that this function is used to start inflating at a bit position in the - middle of a byte. The provided bits will be used before any bytes are used - from next_in. This function should only be used with raw inflate, and - should be used before the first inflate() call after inflateInit2() or - inflateReset(). bits must be less than or equal to 16, and that many of the - least significant bits of value will be inserted in the input. - - If bits is negative, then the input stream bit buffer is emptied. Then - inflatePrime() can be called again to put bits in the buffer. This is used - to clear out bits leftover after feeding inflate a block description prior - to feeding inflate codes. - - inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -ZEXTERN long ZEXPORT inflateMark OF((z_streamp strm)); -/* - This function returns two values, one in the lower 16 bits of the return - value, and the other in the remaining upper bits, obtained by shifting the - return value down 16 bits. If the upper value is -1 and the lower value is - zero, then inflate() is currently decoding information outside of a block. - If the upper value is -1 and the lower value is non-zero, then inflate is in - the middle of a stored block, with the lower value equaling the number of - bytes from the input remaining to copy. If the upper value is not -1, then - it is the number of bits back from the current bit position in the input of - the code (literal or length/distance pair) currently being processed. In - that case the lower value is the number of bytes already emitted for that - code. - - A code is being processed if inflate is waiting for more input to complete - decoding of the code, or if it has completed decoding but is waiting for - more output space to write the literal or match data. - - inflateMark() is used to mark locations in the input data for random - access, which may be at bit positions, and to note those cases where the - output of a code may span boundaries of random access blocks. The current - location in the input stream can be determined from avail_in and data_type - as noted in the description for the Z_BLOCK flush parameter for inflate. - - inflateMark returns the value noted above or -1 << 16 if the provided - source stream state was inconsistent. -*/ - -ZEXTERN int ZEXPORT inflateGetHeader OF((z_streamp strm, - gz_headerp head)); -/* - inflateGetHeader() requests that gzip header information be stored in the - provided gz_header structure. inflateGetHeader() may be called after - inflateInit2() or inflateReset(), and before the first call of inflate(). - As inflate() processes the gzip stream, head->done is zero until the header - is completed, at which time head->done is set to one. If a zlib stream is - being decoded, then head->done is set to -1 to indicate that there will be - no gzip header information forthcoming. Note that Z_BLOCK or Z_TREES can be - used to force inflate() to return immediately after header processing is - complete and before any actual data is decompressed. - - The text, time, xflags, and os fields are filled in with the gzip header - contents. hcrc is set to true if there is a header CRC. (The header CRC - was valid if done is set to one.) If extra is not Z_NULL, then extra_max - contains the maximum number of bytes to write to extra. Once done is true, - extra_len contains the actual extra field length, and extra contains the - extra field, or that field truncated if extra_max is less than extra_len. - If name is not Z_NULL, then up to name_max characters are written there, - terminated with a zero unless the length is greater than name_max. If - comment is not Z_NULL, then up to comm_max characters are written there, - terminated with a zero unless the length is greater than comm_max. When any - of extra, name, or comment are not Z_NULL and the respective field is not - present in the header, then that field is set to Z_NULL to signal its - absence. This allows the use of deflateSetHeader() with the returned - structure to duplicate the header. However if those fields are set to - allocated memory, then the application will need to save those pointers - elsewhere so that they can be eventually freed. - - If inflateGetHeader is not used, then the header information is simply - discarded. The header is always checked for validity, including the header - CRC if present. inflateReset() will reset the process to discard the header - information. The application would need to call inflateGetHeader() again to - retrieve the header from the next gzip stream. - - inflateGetHeader returns Z_OK if success, or Z_STREAM_ERROR if the source - stream state was inconsistent. -*/ - -/* -ZEXTERN int ZEXPORT inflateBackInit OF((z_streamp strm, int windowBits, - unsigned char FAR *window)); - - Initialize the internal stream state for decompression using inflateBack() - calls. The fields zalloc, zfree and opaque in strm must be initialized - before the call. If zalloc and zfree are Z_NULL, then the default library- - derived memory allocation routines are used. windowBits is the base two - logarithm of the window size, in the range 8..15. window is a caller - supplied buffer of that size. Except for special applications where it is - assured that deflate was used with small window sizes, windowBits must be 15 - and a 32K byte window must be supplied to be able to decompress general - deflate streams. - - See inflateBack() for the usage of these routines. - - inflateBackInit will return Z_OK on success, Z_STREAM_ERROR if any of - the parameters are invalid, Z_MEM_ERROR if the internal state could not be - allocated, or Z_VERSION_ERROR if the version of the library does not match - the version of the header file. -*/ - -typedef unsigned (*in_func) OF((void FAR *, unsigned char FAR * FAR *)); -typedef int (*out_func) OF((void FAR *, unsigned char FAR *, unsigned)); - -ZEXTERN int ZEXPORT inflateBack OF((z_streamp strm, - in_func in, void FAR *in_desc, - out_func out, void FAR *out_desc)); -/* - inflateBack() does a raw inflate with a single call using a call-back - interface for input and output. This is more efficient than inflate() for - file i/o applications in that it avoids copying between the output and the - sliding window by simply making the window itself the output buffer. This - function trusts the application to not change the output buffer passed by - the output function, at least until inflateBack() returns. - - inflateBackInit() must be called first to allocate the internal state - and to initialize the state with the user-provided window buffer. - inflateBack() may then be used multiple times to inflate a complete, raw - deflate stream with each call. inflateBackEnd() is then called to free the - allocated state. - - A raw deflate stream is one with no zlib or gzip header or trailer. - This routine would normally be used in a utility that reads zip or gzip - files and writes out uncompressed files. The utility would decode the - header and process the trailer on its own, hence this routine expects only - the raw deflate stream to decompress. This is different from the normal - behavior of inflate(), which expects either a zlib or gzip header and - trailer around the deflate stream. - - inflateBack() uses two subroutines supplied by the caller that are then - called by inflateBack() for input and output. inflateBack() calls those - routines until it reads a complete deflate stream and writes out all of the - uncompressed data, or until it encounters an error. The function's - parameters and return types are defined above in the in_func and out_func - typedefs. inflateBack() will call in(in_desc, &buf) which should return the - number of bytes of provided input, and a pointer to that input in buf. If - there is no input available, in() must return zero--buf is ignored in that - case--and inflateBack() will return a buffer error. inflateBack() will call - out(out_desc, buf, len) to write the uncompressed data buf[0..len-1]. out() - should return zero on success, or non-zero on failure. If out() returns - non-zero, inflateBack() will return with an error. Neither in() nor out() - are permitted to change the contents of the window provided to - inflateBackInit(), which is also the buffer that out() uses to write from. - The length written by out() will be at most the window size. Any non-zero - amount of input may be provided by in(). - - For convenience, inflateBack() can be provided input on the first call by - setting strm->next_in and strm->avail_in. If that input is exhausted, then - in() will be called. Therefore strm->next_in must be initialized before - calling inflateBack(). If strm->next_in is Z_NULL, then in() will be called - immediately for input. If strm->next_in is not Z_NULL, then strm->avail_in - must also be initialized, and then if strm->avail_in is not zero, input will - initially be taken from strm->next_in[0 .. strm->avail_in - 1]. - - The in_desc and out_desc parameters of inflateBack() is passed as the - first parameter of in() and out() respectively when they are called. These - descriptors can be optionally used to pass any information that the caller- - supplied in() and out() functions need to do their job. - - On return, inflateBack() will set strm->next_in and strm->avail_in to - pass back any unused input that was provided by the last in() call. The - return values of inflateBack() can be Z_STREAM_END on success, Z_BUF_ERROR - if in() or out() returned an error, Z_DATA_ERROR if there was a format error - in the deflate stream (in which case strm->msg is set to indicate the nature - of the error), or Z_STREAM_ERROR if the stream was not properly initialized. - In the case of Z_BUF_ERROR, an input or output error can be distinguished - using strm->next_in which will be Z_NULL only if in() returned an error. If - strm->next_in is not Z_NULL, then the Z_BUF_ERROR was due to out() returning - non-zero. (in() will always be called before out(), so strm->next_in is - assured to be defined if out() returns non-zero.) Note that inflateBack() - cannot return Z_OK. -*/ - -ZEXTERN int ZEXPORT inflateBackEnd OF((z_streamp strm)); -/* - All memory allocated by inflateBackInit() is freed. - - inflateBackEnd() returns Z_OK on success, or Z_STREAM_ERROR if the stream - state was inconsistent. -*/ - -ZEXTERN uLong ZEXPORT zlibCompileFlags OF((void)); -/* Return flags indicating compile-time options. - - Type sizes, two bits each, 00 = 16 bits, 01 = 32, 10 = 64, 11 = other: - 1.0: size of uInt - 3.2: size of uLong - 5.4: size of voidpf (pointer) - 7.6: size of z_off_t - - Compiler, assembler, and debug options: - 8: DEBUG - 9: ASMV or ASMINF -- use ASM code - 10: ZLIB_WINAPI -- exported functions use the WINAPI calling convention - 11: 0 (reserved) - - One-time table building (smaller code, but not thread-safe if true): - 12: BUILDFIXED -- build static block decoding tables when needed - 13: DYNAMIC_CRC_TABLE -- build CRC calculation tables when needed - 14,15: 0 (reserved) - - Library content (indicates missing functionality): - 16: NO_GZCOMPRESS -- gz* functions cannot compress (to avoid linking - deflate code when not needed) - 17: NO_GZIP -- deflate can't write gzip streams, and inflate can't detect - and decode gzip streams (to avoid linking crc code) - 18-19: 0 (reserved) - - Operation variations (changes in library functionality): - 20: PKZIP_BUG_WORKAROUND -- slightly more permissive inflate - 21: FASTEST -- deflate algorithm with only one, lowest compression level - 22,23: 0 (reserved) - - The sprintf variant used by gzprintf (zero is best): - 24: 0 = vs*, 1 = s* -- 1 means limited to 20 arguments after the format - 25: 0 = *nprintf, 1 = *printf -- 1 means gzprintf() not secure! - 26: 0 = returns value, 1 = void -- 1 means inferred string length returned - - Remainder: - 27-31: 0 (reserved) - */ - -#ifndef Z_SOLO - - /* utility functions */ - -/* - The following utility functions are implemented on top of the basic - stream-oriented functions. To simplify the interface, some default options - are assumed (compression level and memory usage, standard memory allocation - functions). The source code of these utility functions can be modified if - you need special options. -*/ - -ZEXTERN int ZEXPORT compress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Compresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer. -*/ - -ZEXTERN int ZEXPORT compress2 OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen, - int level)); -/* - Compresses the source buffer into the destination buffer. The level - parameter has the same meaning as in deflateInit. sourceLen is the byte - length of the source buffer. Upon entry, destLen is the total size of the - destination buffer, which must be at least the value returned by - compressBound(sourceLen). Upon exit, destLen is the actual size of the - compressed buffer. - - compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough - memory, Z_BUF_ERROR if there was not enough room in the output buffer, - Z_STREAM_ERROR if the level parameter is invalid. -*/ - -ZEXTERN uLong ZEXPORT compressBound OF((uLong sourceLen)); -/* - compressBound() returns an upper bound on the compressed size after - compress() or compress2() on sourceLen bytes. It would be used before a - compress() or compress2() call to allocate the destination buffer. -*/ - -ZEXTERN int ZEXPORT uncompress OF((Bytef *dest, uLongf *destLen, - const Bytef *source, uLong sourceLen)); -/* - Decompresses the source buffer into the destination buffer. sourceLen is - the byte length of the source buffer. Upon entry, destLen is the total size - of the destination buffer, which must be large enough to hold the entire - uncompressed data. (The size of the uncompressed data must have been saved - previously by the compressor and transmitted to the decompressor by some - mechanism outside the scope of this compression library.) Upon exit, destLen - is the actual size of the uncompressed buffer. - - uncompress returns Z_OK if success, Z_MEM_ERROR if there was not - enough memory, Z_BUF_ERROR if there was not enough room in the output - buffer, or Z_DATA_ERROR if the input data was corrupted or incomplete. In - the case where there is not enough room, uncompress() will fill the output - buffer with the uncompressed data up to that point. -*/ - - /* gzip file access functions */ - -/* - This library supports reading and writing files in gzip (.gz) format with - an interface similar to that of stdio, using the functions that start with - "gz". The gzip format is different from the zlib format. gzip is a gzip - wrapper, documented in RFC 1952, wrapped around a deflate stream. -*/ - -typedef struct gzFile_s *gzFile; /* semi-opaque gzip file descriptor */ - -/* -ZEXTERN gzFile ZEXPORT gzopen OF((const char *path, const char *mode)); - - Opens a gzip (.gz) file for reading or writing. The mode parameter is as - in fopen ("rb" or "wb") but can also include a compression level ("wb9") or - a strategy: 'f' for filtered data as in "wb6f", 'h' for Huffman-only - compression as in "wb1h", 'R' for run-length encoding as in "wb1R", or 'F' - for fixed code compression as in "wb9F". (See the description of - deflateInit2 for more information about the strategy parameter.) 'T' will - request transparent writing or appending with no compression and not using - the gzip format. - - "a" can be used instead of "w" to request that the gzip stream that will - be written be appended to the file. "+" will result in an error, since - reading and writing to the same gzip file is not supported. - - These functions, as well as gzip, will read and decode a sequence of gzip - streams in a file. The append function of gzopen() can be used to create - such a file. (Also see gzflush() for another way to do this.) When - appending, gzopen does not test whether the file begins with a gzip stream, - nor does it look for the end of the gzip streams to begin appending. gzopen - will simply append a gzip stream to the existing file. - - gzopen can be used to read a file which is not in gzip format; in this - case gzread will directly read from the file without decompression. When - reading, this will be detected automatically by looking for the magic two- - byte gzip header. - - gzopen returns NULL if the file could not be opened, if there was - insufficient memory to allocate the gzFile state, or if an invalid mode was - specified (an 'r', 'w', or 'a' was not provided, or '+' was provided). - errno can be checked to determine if the reason gzopen failed was that the - file could not be opened. -*/ - -ZEXTERN gzFile ZEXPORT gzdopen OF((int fd, const char *mode)); -/* - gzdopen associates a gzFile with the file descriptor fd. File descriptors - are obtained from calls like open, dup, creat, pipe or fileno (if the file - has been previously opened with fopen). The mode parameter is as in gzopen. - - The next call of gzclose on the returned gzFile will also close the file - descriptor fd, just like fclose(fdopen(fd, mode)) closes the file descriptor - fd. If you want to keep fd open, use fd = dup(fd_keep); gz = gzdopen(fd, - mode);. The duplicated descriptor should be saved to avoid a leak, since - gzdopen does not close fd if it fails. If you are using fileno() to get the - file descriptor from a FILE *, then you will have to use dup() to avoid - double-close()ing the file descriptor. Both gzclose() and fclose() will - close the associated file descriptor, so they need to have different file - descriptors. - - gzdopen returns NULL if there was insufficient memory to allocate the - gzFile state, if an invalid mode was specified (an 'r', 'w', or 'a' was not - provided, or '+' was provided), or if fd is -1. The file descriptor is not - used until the next gz* read, write, seek, or close operation, so gzdopen - will not detect if fd is invalid (unless fd is -1). -*/ - -ZEXTERN int ZEXPORT gzbuffer OF((gzFile file, unsigned size)); -/* - Set the internal buffer size used by this library's functions. The - default buffer size is 8192 bytes. This function must be called after - gzopen() or gzdopen(), and before any other calls that read or write the - file. The buffer memory allocation is always deferred to the first read or - write. Two buffers are allocated, either both of the specified size when - writing, or one of the specified size and the other twice that size when - reading. A larger buffer size of, for example, 64K or 128K bytes will - noticeably increase the speed of decompression (reading). - - The new buffer size also affects the maximum length for gzprintf(). - - gzbuffer() returns 0 on success, or -1 on failure, such as being called - too late. -*/ - -ZEXTERN int ZEXPORT gzsetparams OF((gzFile file, int level, int strategy)); -/* - Dynamically update the compression level or strategy. See the description - of deflateInit2 for the meaning of these parameters. - - gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not - opened for writing. -*/ - -ZEXTERN int ZEXPORT gzread OF((gzFile file, voidp buf, unsigned len)); -/* - Reads the given number of uncompressed bytes from the compressed file. If - the input file is not in gzip format, gzread copies the given number of - bytes into the buffer directly from the file. - - After reaching the end of a gzip stream in the input, gzread will continue - to read, looking for another gzip stream. Any number of gzip streams may be - concatenated in the input file, and will all be decompressed by gzread(). - If something other than a gzip stream is encountered after a gzip stream, - that remaining trailing garbage is ignored (and no error is returned). - - gzread can be used to read a gzip file that is being concurrently written. - Upon reaching the end of the input, gzread will return with the available - data. If the error code returned by gzerror is Z_OK or Z_BUF_ERROR, then - gzclearerr can be used to clear the end of file indicator in order to permit - gzread to be tried again. Z_OK indicates that a gzip stream was completed - on the last gzread. Z_BUF_ERROR indicates that the input file ended in the - middle of a gzip stream. Note that gzread does not return -1 in the event - of an incomplete gzip stream. This error is deferred until gzclose(), which - will return Z_BUF_ERROR if the last gzread ended in the middle of a gzip - stream. Alternatively, gzerror can be used before gzclose to detect this - case. - - gzread returns the number of uncompressed bytes actually read, less than - len for end of file, or -1 for error. -*/ - -ZEXTERN int ZEXPORT gzwrite OF((gzFile file, - voidpc buf, unsigned len)); -/* - Writes the given number of uncompressed bytes into the compressed file. - gzwrite returns the number of uncompressed bytes written or 0 in case of - error. -*/ - -ZEXTERN int ZEXPORTVA gzprintf Z_ARG((gzFile file, const char *format, ...)); -/* - Converts, formats, and writes the arguments to the compressed file under - control of the format string, as in fprintf. gzprintf returns the number of - uncompressed bytes actually written, or 0 in case of error. The number of - uncompressed bytes written is limited to 8191, or one less than the buffer - size given to gzbuffer(). The caller should assure that this limit is not - exceeded. If it is exceeded, then gzprintf() will return an error (0) with - nothing written. In this case, there may also be a buffer overflow with - unpredictable consequences, which is possible only if zlib was compiled with - the insecure functions sprintf() or vsprintf() because the secure snprintf() - or vsnprintf() functions were not available. This can be determined using - zlibCompileFlags(). -*/ - -ZEXTERN int ZEXPORT gzputs OF((gzFile file, const char *s)); -/* - Writes the given null-terminated string to the compressed file, excluding - the terminating null character. - - gzputs returns the number of characters written, or -1 in case of error. -*/ - -ZEXTERN char * ZEXPORT gzgets OF((gzFile file, char *buf, int len)); -/* - Reads bytes from the compressed file until len-1 characters are read, or a - newline character is read and transferred to buf, or an end-of-file - condition is encountered. If any characters are read or if len == 1, the - string is terminated with a null character. If no characters are read due - to an end-of-file or len < 1, then the buffer is left untouched. - - gzgets returns buf which is a null-terminated string, or it returns NULL - for end-of-file or in case of error. If there was an error, the contents at - buf are indeterminate. -*/ - -ZEXTERN int ZEXPORT gzputc OF((gzFile file, int c)); -/* - Writes c, converted to an unsigned char, into the compressed file. gzputc - returns the value that was written, or -1 in case of error. -*/ - -ZEXTERN int ZEXPORT gzgetc OF((gzFile file)); -/* - Reads one byte from the compressed file. gzgetc returns this byte or -1 - in case of end of file or error. This is implemented as a macro for speed. - As such, it does not do all of the checking the other functions do. I.e. - it does not check to see if file is NULL, nor whether the structure file - points to has been clobbered or not. -*/ - -ZEXTERN int ZEXPORT gzungetc OF((int c, gzFile file)); -/* - Push one character back onto the stream to be read as the first character - on the next read. At least one character of push-back is allowed. - gzungetc() returns the character pushed, or -1 on failure. gzungetc() will - fail if c is -1, and may fail if a character has been pushed but not read - yet. If gzungetc is used immediately after gzopen or gzdopen, at least the - output buffer size of pushed characters is allowed. (See gzbuffer above.) - The pushed character will be discarded if the stream is repositioned with - gzseek() or gzrewind(). -*/ - -ZEXTERN int ZEXPORT gzflush OF((gzFile file, int flush)); -/* - Flushes all pending output into the compressed file. The parameter flush - is as in the deflate() function. The return value is the zlib error number - (see function gzerror below). gzflush is only permitted when writing. - - If the flush parameter is Z_FINISH, the remaining data is written and the - gzip stream is completed in the output. If gzwrite() is called again, a new - gzip stream will be started in the output. gzread() is able to read such - concatented gzip streams. - - gzflush should be called only when strictly necessary because it will - degrade compression if called too often. -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile file, - z_off_t offset, int whence)); - - Sets the starting position for the next gzread or gzwrite on the given - compressed file. The offset represents a number of bytes in the - uncompressed data stream. The whence parameter is defined as in lseek(2); - the value SEEK_END is not supported. - - If the file is opened for reading, this function is emulated but can be - extremely slow. If the file is opened for writing, only forward seeks are - supported; gzseek then compresses a sequence of zeroes up to the new - starting position. - - gzseek returns the resulting offset location as measured in bytes from - the beginning of the uncompressed stream, or -1 in case of error, in - particular if the file is opened for writing and the new starting position - would be before the current position. -*/ - -ZEXTERN int ZEXPORT gzrewind OF((gzFile file)); -/* - Rewinds the given file. This function is supported only for reading. - - gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gztell OF((gzFile file)); - - Returns the starting position for the next gzread or gzwrite on the given - compressed file. This position represents a number of bytes in the - uncompressed data stream, and is zero when starting, even if appending or - reading a gzip stream from the middle of a file using gzdopen(). - - gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) -*/ - -/* -ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile file)); - - Returns the current offset in the file being read or written. This offset - includes the count of bytes that precede the gzip stream, for example when - appending or when using gzdopen() for reading. When reading, the offset - does not include as yet unused buffered input. This information can be used - for a progress indicator. On error, gzoffset() returns -1. -*/ - -ZEXTERN int ZEXPORT gzeof OF((gzFile file)); -/* - Returns true (1) if the end-of-file indicator has been set while reading, - false (0) otherwise. Note that the end-of-file indicator is set only if the - read tried to go past the end of the input, but came up short. Therefore, - just like feof(), gzeof() may return false even if there is no more data to - read, in the event that the last read request was for the exact number of - bytes remaining in the input file. This will happen if the input file size - is an exact multiple of the buffer size. - - If gzeof() returns true, then the read functions will return no more data, - unless the end-of-file indicator is reset by gzclearerr() and the input file - has grown since the previous end of file was detected. -*/ - -ZEXTERN int ZEXPORT gzdirect OF((gzFile file)); -/* - Returns true (1) if file is being copied directly while reading, or false - (0) if file is a gzip stream being decompressed. - - If the input file is empty, gzdirect() will return true, since the input - does not contain a gzip stream. - - If gzdirect() is used immediately after gzopen() or gzdopen() it will - cause buffers to be allocated to allow reading the file to determine if it - is a gzip file. Therefore if gzbuffer() is used, it should be called before - gzdirect(). - - When writing, gzdirect() returns true (1) if transparent writing was - requested ("wT" for the gzopen() mode), or false (0) otherwise. (Note: - gzdirect() is not needed when writing. Transparent writing must be - explicitly requested, so the application already knows the answer. When - linking statically, using gzdirect() will include all of the zlib code for - gzip file reading and decompression, which may not be desired.) -*/ - -ZEXTERN int ZEXPORT gzclose OF((gzFile file)); -/* - Flushes all pending output if necessary, closes the compressed file and - deallocates the (de)compression state. Note that once file is closed, you - cannot call gzerror with file, since its structures have been deallocated. - gzclose must not be called more than once on the same file, just as free - must not be called more than once on the same allocation. - - gzclose will return Z_STREAM_ERROR if file is not valid, Z_ERRNO on a - file operation error, Z_MEM_ERROR if out of memory, Z_BUF_ERROR if the - last read ended in the middle of a gzip stream, or Z_OK on success. -*/ - -ZEXTERN int ZEXPORT gzclose_r OF((gzFile file)); -ZEXTERN int ZEXPORT gzclose_w OF((gzFile file)); -/* - Same as gzclose(), but gzclose_r() is only for use when reading, and - gzclose_w() is only for use when writing or appending. The advantage to - using these instead of gzclose() is that they avoid linking in zlib - compression or decompression code that is not used when only reading or only - writing respectively. If gzclose() is used, then both compression and - decompression code will be included the application when linking to a static - zlib library. -*/ - -ZEXTERN const char * ZEXPORT gzerror OF((gzFile file, int *errnum)); -/* - Returns the error message for the last error which occurred on the given - compressed file. errnum is set to zlib error number. If an error occurred - in the file system and not in the compression library, errnum is set to - Z_ERRNO and the application may consult errno to get the exact error code. - - The application must not modify the returned string. Future calls to - this function may invalidate the previously returned string. If file is - closed, then the string previously returned by gzerror will no longer be - available. - - gzerror() should be used to distinguish errors from end-of-file for those - functions above that do not distinguish those cases in their return values. -*/ - -ZEXTERN void ZEXPORT gzclearerr OF((gzFile file)); -/* - Clears the error and end-of-file flags for file. This is analogous to the - clearerr() function in stdio. This is useful for continuing to read a gzip - file that is being written concurrently. -*/ - -#endif /* !Z_SOLO */ - - /* checksum functions */ - -/* - These functions are not related to compression but are exported - anyway because they might be useful in applications using the compression - library. -*/ - -ZEXTERN uLong ZEXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); -/* - Update a running Adler-32 checksum with the bytes buf[0..len-1] and - return the updated checksum. If buf is Z_NULL, this function returns the - required initial value for the checksum. - - An Adler-32 checksum is almost as reliable as a CRC32 but can be computed - much faster. - - Usage example: - - uLong adler = adler32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - adler = adler32(adler, buffer, length); - } - if (adler != original_adler) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT adler32_combine OF((uLong adler1, uLong adler2, - z_off_t len2)); - - Combine two Adler-32 checksums into one. For two sequences of bytes, seq1 - and seq2 with lengths len1 and len2, Adler-32 checksums were calculated for - each, adler1 and adler2. adler32_combine() returns the Adler-32 checksum of - seq1 and seq2 concatenated, requiring only adler1, adler2, and len2. Note - that the z_off_t type (like off_t) is a signed integer. If len2 is - negative, the result has no meaning or utility. -*/ - -ZEXTERN uLong ZEXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); -/* - Update a running CRC-32 with the bytes buf[0..len-1] and return the - updated CRC-32. If buf is Z_NULL, this function returns the required - initial value for the for the crc. Pre- and post-conditioning (one's - complement) is performed within this function so it shouldn't be done by the - application. - - Usage example: - - uLong crc = crc32(0L, Z_NULL, 0); - - while (read_buffer(buffer, length) != EOF) { - crc = crc32(crc, buffer, length); - } - if (crc != original_crc) error(); -*/ - -/* -ZEXTERN uLong ZEXPORT crc32_combine OF((uLong crc1, uLong crc2, z_off_t len2)); - - Combine two CRC-32 check values into one. For two sequences of bytes, - seq1 and seq2 with lengths len1 and len2, CRC-32 check values were - calculated for each, crc1 and crc2. crc32_combine() returns the CRC-32 - check value of seq1 and seq2 concatenated, requiring only crc1, crc2, and - len2. -*/ - - - /* various hacks, don't look :) */ - -/* deflateInit and inflateInit are macros to allow checking the zlib version - * and the compiler's view of z_stream: - */ -ZEXTERN int ZEXPORT deflateInit_ OF((z_streamp strm, int level, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateInit_ OF((z_streamp strm, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT deflateInit2_ OF((z_streamp strm, int level, int method, - int windowBits, int memLevel, - int strategy, const char *version, - int stream_size)); -ZEXTERN int ZEXPORT inflateInit2_ OF((z_streamp strm, int windowBits, - const char *version, int stream_size)); -ZEXTERN int ZEXPORT inflateBackInit_ OF((z_streamp strm, int windowBits, - unsigned char FAR *window, - const char *version, - int stream_size)); -#define deflateInit(strm, level) \ - deflateInit_((strm), (level), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit(strm) \ - inflateInit_((strm), ZLIB_VERSION, (int)sizeof(z_stream)) -#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ - deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ - (strategy), ZLIB_VERSION, (int)sizeof(z_stream)) -#define inflateInit2(strm, windowBits) \ - inflateInit2_((strm), (windowBits), ZLIB_VERSION, \ - (int)sizeof(z_stream)) -#define inflateBackInit(strm, windowBits, window) \ - inflateBackInit_((strm), (windowBits), (window), \ - ZLIB_VERSION, (int)sizeof(z_stream)) - -#ifndef Z_SOLO - -/* gzgetc() macro and its supporting function and exposed data structure. Note - * that the real internal state is much larger than the exposed structure. - * This abbreviated structure exposes just enough for the gzgetc() macro. The - * user should not mess with these exposed elements, since their names or - * behavior could change in the future, perhaps even capriciously. They can - * only be used by the gzgetc() macro. You have been warned. - */ -struct gzFile_s { - unsigned have; - unsigned char *next; - z_off64_t pos; -}; -ZEXTERN int ZEXPORT gzgetc_ OF((gzFile file)); -#define gzgetc(g) \ - ((g)->have ? ((g)->have--, (g)->pos++, *((g)->next)++) : gzgetc_(g)) - -/* provide 64-bit offset functions if _LARGEFILE64_SOURCE defined, and/or - * change the regular functions to 64 bits if _FILE_OFFSET_BITS is 64 (if - * both are true, the application gets the *64 functions, and the regular - * functions are changed to 64 bits) -- in case these are set on systems - * without large file support, _LFS64_LARGEFILE must also be true - */ -#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0 - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off64_t ZEXPORT gzseek64 OF((gzFile, z_off64_t, int)); - ZEXTERN z_off64_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off64_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off64_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off64_t)); -#endif - -#if !defined(ZLIB_INTERNAL) && _FILE_OFFSET_BITS-0 == 64 && _LFS64_LARGEFILE-0 -# ifdef Z_PREFIX_SET -# define z_gzopen z_gzopen64 -# define z_gzseek z_gzseek64 -# define z_gztell z_gztell64 -# define z_gzoffset z_gzoffset64 -# define z_adler32_combine z_adler32_combine64 -# define z_crc32_combine z_crc32_combine64 -# else -# define gzopen gzopen64 -# define gzseek gzseek64 -# define gztell gztell64 -# define gzoffset gzoffset64 -# define adler32_combine adler32_combine64 -# define crc32_combine crc32_combine64 -# endif -# ifndef _LARGEFILE64_SOURCE - ZEXTERN gzFile ZEXPORT gzopen64 OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek64 OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell64 OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset64 OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine64 OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine64 OF((uLong, uLong, z_off_t)); -# endif -#else - ZEXTERN gzFile ZEXPORT gzopen OF((const char *, const char *)); - ZEXTERN z_off_t ZEXPORT gzseek OF((gzFile, z_off_t, int)); - ZEXTERN z_off_t ZEXPORT gztell OF((gzFile)); - ZEXTERN z_off_t ZEXPORT gzoffset OF((gzFile)); - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); -#endif - -#else /* Z_SOLO */ - - ZEXTERN uLong ZEXPORT adler32_combine OF((uLong, uLong, z_off_t)); - ZEXTERN uLong ZEXPORT crc32_combine OF((uLong, uLong, z_off_t)); - -#endif /* !Z_SOLO */ - -/* hack for buggy compilers */ -#if !defined(ZUTIL_H) && !defined(NO_DUMMY_DECL) - struct internal_state {int dummy;}; -#endif - -/* undocumented functions */ -ZEXTERN const char * ZEXPORT zError OF((int)); -ZEXTERN int ZEXPORT inflateSyncPoint OF((z_streamp)); -ZEXTERN const uLongf * ZEXPORT get_crc_table OF((void)); -ZEXTERN int ZEXPORT inflateUndermine OF((z_streamp, int)); -ZEXTERN int ZEXPORT inflateResetKeep OF((z_streamp)); -ZEXTERN int ZEXPORT deflateResetKeep OF((z_streamp)); -#ifndef Z_SOLO - ZEXTERN unsigned long ZEXPORT gzflags OF((void)); -#endif - -#ifdef __cplusplus -} -#endif - -#endif /* ZLIB_H */ diff --git a/source/paint/detail/image_png.hpp b/source/paint/detail/image_png.hpp index 039c7908..9ac776fe 100644 --- a/source/paint/detail/image_png.hpp +++ b/source/paint/detail/image_png.hpp @@ -5,7 +5,7 @@ //Separate the libpng from the package that system provides. #if defined(NANA_LIBPNG) - #include + #include #else #include #endif From 7f4cc3f6d9c75df2ccd59566a6d7eafdb0d657bc Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sat, 17 Oct 2015 14:42:07 +0800 Subject: [PATCH 46/65] improve image and pixel_buffer --- build/codeblocks/nana.cbp | 8 +- build/codeblocks/nana.layout | 159 ------------------ build/makefile/makefile | 2 +- build/vc2013/nana.vcxproj | 14 +- build/vc2015/nana.vcxproj | 14 +- include/nana/config.hpp | 10 +- include/nana/paint/detail/image_processor.hpp | 12 ++ include/nana/paint/pixel_buffer.hpp | 16 +- source/paint/detail/image_bmp.hpp | 34 +--- source/paint/detail/image_pixbuf.hpp | 63 +++++++ source/paint/detail/image_png.hpp | 38 +---- source/paint/image.cpp | 55 ++++-- source/paint/pixel_buffer.cpp | 57 +++++++ 13 files changed, 216 insertions(+), 266 deletions(-) delete mode 100644 build/codeblocks/nana.layout create mode 100644 source/paint/detail/image_pixbuf.hpp diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp index bf4b1d0b..03e6b72f 100644 --- a/build/codeblocks/nana.cbp +++ b/build/codeblocks/nana.cbp @@ -14,8 +14,11 @@ Windows From 8da183cfabee2703662e4f7ebf25c133d265f64d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Fri, 30 Oct 2015 07:43:42 +0800 Subject: [PATCH 57/65] add an abstract class scroll_interface --- include/nana/gui/widgets/scroll.hpp | 136 ++++++++++++++++++--------- include/nana/gui/widgets/textbox.hpp | 6 +- source/gui/widgets/textbox.cpp | 17 +++- 3 files changed, 113 insertions(+), 46 deletions(-) diff --git a/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp index 28ac3326..f09b2046 100644 --- a/include/nana/gui/widgets/scroll.hpp +++ b/include/nana/gui/widgets/scroll.hpp @@ -149,36 +149,35 @@ namespace nana bool make_step(bool forward, unsigned multiple) { - if (graph_) - { - size_type step = (multiple > 1 ? metrics_.step * multiple : metrics_.step); - size_type value = metrics_.value; - if (forward) - { - size_type maxv = metrics_.peak - metrics_.range; - if (metrics_.peak > metrics_.range && value < maxv) - { - if (maxv - value >= step) - value += step; - else - value = maxv; - } - } - else if (value) - { - if (value > step) - value -= step; - else - value = 0; - } - size_type cmpvalue = metrics_.value; - metrics_.value = value; - if (value != cmpvalue) - { - _m_emit_value_changed(); - return true; - } + if (!graph_) return false; + + size_type step = (multiple > 1 ? metrics_.step * multiple : metrics_.step); + size_type value = metrics_.value; + if (forward) + { + size_type maxv = metrics_.peak - metrics_.range; + if (metrics_.peak > metrics_.range && value < maxv) + { + if (maxv - value >= step) + value += step; + else + value = maxv; + } + } + else if (value) + { + if (value > step) + value -= step; + else + value = 0; + } + size_type cmpvalue = metrics_.value; + metrics_.value = value; + if (value != cmpvalue) + { + _m_emit_value_changed(); + return true; } return false; } @@ -334,14 +333,61 @@ namespace nana }//end namespace scroll }//end namespace drawerbase + class scroll_interface + { + public: + using size_type = std::size_t; + + virtual ~scroll_interface() = default; + + /// \brief Determines whether it is scrollable. + /// @param for_less whether it can be scrolled for a less value (backward or "up" if true, forward or "down" if false). + virtual bool scrollable(bool for_less) const = 0; + + /// the whole total (peak) + virtual size_type amount() const = 0; + + virtual void amount(size_type peak) = 0; + + /// Get the range of the widget (how many is shonw on a page, that is, How many to scroll after click on first or second) + virtual size_type range() const = 0; + + /// Set the range of the widget. + virtual void range(size_type r) = 0; + + /// \brief Get the value (current offset calculated from the very beginnig) + /// @return the value. + virtual size_type value() const = 0; + + /// \brief Set the value. + /// @param s a new value. + virtual void value(size_type s) = 0; + + + /// \brief Get the step of the sroll widget. The step indicates a variation of the value. + /// @return the step. + virtual size_type step() const = 0; + + /// \brief Set the step. + /// @param s a value for step. + virtual void step(size_type s) = 0; + + /// \brief Increase/decrease values by a step (alternativelly by some number of steps). + /// @param forward it determines whether increase or decrease. + /// @return true if the value is changed. + virtual bool make_step(bool forward, unsigned steps = 1) = 0; + + virtual window window_handle() const = 0; + }; + /// Provides a way to display an object which is larger than the window's client area. template class scroll // add a widget scheme? - : public widget_object, drawerbase::scroll::scroll_events> + : public widget_object, drawerbase::scroll::scroll_events>, + public scroll_interface { typedef widget_object > base_type; public: - typedef std::size_t size_type; /// \brief The default constructor without creating the widget. scroll(){} @@ -365,59 +411,58 @@ namespace nana /// \brief Determines whether it is scrollable. /// @param for_less whether it can be scrolled for a less value (backward or "up" if true, forward or "down" if false). - bool scrollable(bool for_less) const + bool scrollable(bool for_less) const override { auto & m = this->get_drawer_trigger().metrics(); return (for_less ? (0 != m.value) : (m.value < m.peak - m.range)); } /// the whole total (peak) - size_type amount() const + size_type amount() const override { return this->get_drawer_trigger().metrics().peak; } - void amount(size_type Max) + void amount(size_type peak) override { - return this->get_drawer_trigger().peak(Max); + return this->get_drawer_trigger().peak(peak); } /// Get the range of the widget (how many is shonw on a page, that is, How many to scroll after click on first or second) - size_type range() const + size_type range() const override { return this->get_drawer_trigger().metrics().range; } /// Set the range of the widget. - void range(size_type r) + void range(size_type r) override { return this->get_drawer_trigger().range(r); } /// \brief Get the value (current offset calculated from the very beginnig) /// @return the value. - size_type value() const + size_type value() const override { return this->get_drawer_trigger().metrics().value; } /// \brief Set the value. /// @param s a new value. - void value(size_type s) + void value(size_type s) override { return this->get_drawer_trigger().value(s); } - /// \brief Get the step of the sroll widget. The step indicates a variation of the value. /// @return the step. - size_type step() const + size_type step() const override { return this->get_drawer_trigger().metrics().step; } /// \brief Set the step. /// @param s a value for step. - void step(size_type s) + void step(size_type s) override { return this->get_drawer_trigger().step(s); } @@ -425,7 +470,7 @@ namespace nana /// \brief Increase/decrease values by a step (alternativelly by some number of steps). /// @param forward it determines whether increase or decrease. /// @return true if the value is changed. - bool make_step(bool forward, unsigned steps = 1) + bool make_step(bool forward, unsigned steps = 1) override { if (this->get_drawer_trigger().make_step(forward, steps)) { @@ -435,6 +480,11 @@ namespace nana return false; } + window window_handle() const override + { + return this->handle(); + } + /// \brief Increase/decrease values by steps as if it is scrolled through mouse wheel. /// @param forward it determines whether increase or decrease. /// @return true if the vlaue is changed. diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index 16236081..f0d8ff02 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -132,7 +132,7 @@ namespace nana /// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter. /// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line. - void enable_indent(bool, std::function generator = {}); + textbox& indention(bool, std::function generator = {}); //A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}. textbox& reset(nana::string = nana::string()); ///< discard the old text and set a new text @@ -153,8 +153,12 @@ namespace nana bool getline(std::size_t pos, nana::string&) const; /// Gets the caret position + /// Returns true if the caret is in the area of display, false otherwise. bool caret_pos(point& pos, bool text_coordinate) const; + /// Sets the caret position with a text position + textbox& caret_pos(const upoint&); + /// Appends an string. If `at_caret` is `true`, the string is inserted at the position of caret, otherwise, it is appended at end of the textbox. textbox& append(const nana::string& text, bool at_caret); diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 10e07bd7..31602540 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -249,12 +249,13 @@ namespace drawerbase { /// Enables/disables the textbox to indent a line. Idents a new line when it is created by pressing enter. /// @param generator generates text for identing a line. If it is empty, textbox indents the line according to last line. - void textbox::enable_indent(bool enb, std::function generator) + textbox& textbox::indention(bool enb, std::function generator) { internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); if (editor) editor->indent(enb, generator); + return *this; } textbox& textbox::reset(nana::string str) @@ -314,8 +315,10 @@ namespace drawerbase { /// Gets the caret position bool textbox::caret_pos(point& pos, bool text_coordinate) const { - internal_scope_guard lock; auto editor = get_drawer_trigger().editor(); + internal_scope_guard lock; + if (!editor) + return false; auto scr_pos = editor->caret_screen_pos(); @@ -331,6 +334,16 @@ namespace drawerbase { return editor->hit_text_area(scr_pos); } + textbox& textbox::caret_pos(const upoint& pos) + { + auto editor = get_drawer_trigger().editor(); + internal_scope_guard lock; + if (editor) + editor->move_caret(pos); + + return *this; + } + textbox& textbox::append(const nana::string& text, bool at_caret) { internal_scope_guard lock; From 9fd1a594cb4bd920807d5e863cb28755fec66683 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 2 Nov 2015 00:33:22 +0800 Subject: [PATCH 58/65] add selection of text by using shift+mouse click --- .../gui/widgets/skeletons/text_editor.hpp | 4 +- source/gui/widgets/combox.cpp | 4 +- source/gui/widgets/skeletons/text_editor.cpp | 103 ++++++++++-------- source/gui/widgets/spinbox.cpp | 14 +-- source/gui/widgets/textbox.cpp | 7 +- source/paint/image.cpp | 11 -- 6 files changed, 73 insertions(+), 70 deletions(-) diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp index 62da6ab3..cf1f207a 100644 --- a/include/nana/gui/widgets/skeletons/text_editor.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor.hpp @@ -250,9 +250,8 @@ namespace nana{ namespace widgets point caret_screen_pos() const; bool scroll(bool upwards, bool vertical); bool mouse_enter(bool); - bool mouse_down(::nana::mouse, const point& screen_pos); bool mouse_move(bool left_button, const point& screen_pos); - bool mouse_up(::nana::mouse, const point& screen_pos); + bool mouse_pressed(const arg_mouse& arg); skeletons::textbase& textbase(); const skeletons::textbase& textbase() const; @@ -365,6 +364,7 @@ namespace nana{ namespace widgets { nana::point offset; //x stands for pixels, y for lines nana::upoint caret; //position of caret by text, it specifies the position of a new character + nana::upoint shift_begin_caret; unsigned xpos{0}; //This data is used for move up/down }points_; }; diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index 45718364..af007d50 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -622,7 +622,7 @@ namespace nana if(drawer_->widget_ptr()->enabled()) { auto * editor = drawer_->editor(); - if(false == editor->mouse_down(arg.button, arg.pos)) + if (!editor->mouse_pressed(arg)) drawer_->open_lister_if_push_button_positioned(); drawer_->draw(); @@ -637,7 +637,7 @@ namespace nana { if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister()) { - drawer_->editor()->mouse_up(arg.button, arg.pos); + drawer_->editor()->mouse_pressed(arg); drawer_->set_button_state(element_state::hovered, false); drawer_->draw(); API::lazy_refresh(); diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 654e317c..461a734e 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1646,30 +1646,6 @@ namespace nana{ namespace widgets return true; } - bool text_editor::mouse_down(::nana::mouse button, const point& scrpos) - { - if (!hit_text_area(scrpos)) - return false; - - if(::nana::mouse::left_button == button) - { - API::capture_window(window_, true); - text_area_.captured = true; - - //Set caret pos by screen point and get the caret pos. - mouse_caret(scrpos); - if(!select(false)) - { - select_.a = points_.caret; //Set begin caret - set_end_caret(); - } - select_.mode_selection = selection::mode_mouse_selected; - } - - text_area_.border_renderer(graph_, _m_bgcolor()); - return true; - } - bool text_editor::mouse_move(bool left_button, const point& scrpos) { cursor cur = cursor::iterm; @@ -1694,31 +1670,70 @@ namespace nana{ namespace widgets return false; } - bool text_editor::mouse_up(::nana::mouse button, const point& scrpos) + bool text_editor::mouse_pressed(const arg_mouse& arg) { - auto is_prev_no_selected = (select_.mode_selection == selection::mode_no_selected); - - if(select_.mode_selection == selection::mode_mouse_selected) + if (event_code::mouse_down == arg.evt_code) { - select_.mode_selection = selection::mode_no_selected; - set_end_caret(); + if (!hit_text_area(arg.pos)) + return false; + + if (::nana::mouse::left_button == arg.button) + { + API::capture_window(window_, true); + text_area_.captured = true; + + //Set caret pos by screen point and get the caret pos. + mouse_caret(arg.pos); + if (arg.shift) + { + if (points_.shift_begin_caret != points_.caret) + { + select_.a = points_.shift_begin_caret; + select_.b = points_.caret; + } + } + else + { + if (!select(false)) + { + select_.a = points_.caret; //Set begin caret + set_end_caret(); + } + points_.shift_begin_caret = points_.caret; + } + select_.mode_selection = selection::mode_mouse_selected; + } + + text_area_.border_renderer(graph_, _m_bgcolor()); + return true; } - else if (is_prev_no_selected) + else if (event_code::mouse_up == arg.evt_code) { - if((!select_.dragged) || (!move_select())) - select(false); + auto is_prev_no_selected = (select_.mode_selection == selection::mode_no_selected); + + if (select_.mode_selection == selection::mode_mouse_selected) + { + select_.mode_selection = selection::mode_no_selected; + set_end_caret(); + } + else if (is_prev_no_selected) + { + if ((!select_.dragged) || (!move_select())) + select(false); + } + select_.dragged = false; + + API::capture_window(window_, false); + text_area_.captured = false; + if (hit_text_area(arg.pos) == false) + API::window_cursor(window_, nana::cursor::arrow); + + text_area_.border_renderer(graph_, _m_bgcolor()); + + //Redraw if is_prev_no_selected is true + return is_prev_no_selected; } - select_.dragged = false; - - API::capture_window(window_, false); - text_area_.captured = false; - if (hit_text_area(scrpos) == false) - API::window_cursor(window_, nana::cursor::arrow); - - text_area_.border_renderer(graph_, _m_bgcolor()); - - //Redraw if is_prev_no_selected is true - return is_prev_no_selected; + return false; } textbase & text_editor::textbase() diff --git a/source/gui/widgets/spinbox.cpp b/source/gui/widgets/spinbox.cpp index a5fddd26..a4d6e08d 100644 --- a/source/gui/widgets/spinbox.cpp +++ b/source/gui/widgets/spinbox.cpp @@ -367,17 +367,13 @@ namespace nana return true; } - - bool refreshed = false; - if (pressed) - refreshed = editor_->mouse_down(arg.button, arg.pos); - else - refreshed = editor_->mouse_up(arg.button, arg.pos); - - if (refreshed) + if (editor_->mouse_pressed(arg)) + { _m_draw_spins(buttons::none); + return true; + } - return refreshed; + return false; } bool mouse_move(bool left_button, const ::nana::point& pos) diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index 31602540..c1e402c9 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -111,8 +111,11 @@ namespace drawerbase { void drawer::mouse_down(graph_reference, const arg_mouse& arg) { - if(editor_->mouse_down(arg.button, arg.pos)) + if (editor_->mouse_pressed(arg)) + { + editor_->render(true); API::lazy_refresh(); + } } void drawer::mouse_move(graph_reference, const arg_mouse& arg) @@ -123,7 +126,7 @@ namespace drawerbase { void drawer::mouse_up(graph_reference graph, const arg_mouse& arg) { - if(editor_->mouse_up(arg.button, arg.pos)) + if(editor_->mouse_pressed(arg)) API::lazy_refresh(); } diff --git a/source/paint/image.cpp b/source/paint/image.cpp index c8a4098e..ddbf317b 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -161,17 +161,6 @@ namespace paint image::image_impl_interface::~image_impl_interface() {} - /* - namespace detail - { - int toupper(int c) //deprecated - { - return (('a' <= c && c <= 'z') ? - c - ('a' - 'A') - : c); - } - }//end namespace detail - //*/ //class image image::image() From 67752172a087d2b30440aefb3fbc7453ca846548 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Mon, 2 Nov 2015 23:39:32 +0800 Subject: [PATCH 59/65] fix tabbar flying-close issue --- include/nana/gui/widgets/tabbar.hpp | 41 ++++++++++++++++++++++++----- source/gui/widgets/tabbar.cpp | 23 +++++++++------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/include/nana/gui/widgets/tabbar.hpp b/include/nana/gui/widgets/tabbar.hpp index 206f3e4e..2ed73ab4 100644 --- a/include/nana/gui/widgets/tabbar.hpp +++ b/include/nana/gui/widgets/tabbar.hpp @@ -140,7 +140,16 @@ namespace nana : public drawer_trigger { public: - enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose}; + //enum toolbox_button_t{ButtonAdd, ButtonScroll, ButtonList, ButtonClose}; //deprecated + + enum class kits + { + add, + scroll, + list, + close + }; + trigger(); ~trigger(); void activate(std::size_t); @@ -158,7 +167,7 @@ namespace nana void tab_image(size_t, const nana::paint::image&); void text(std::size_t, const nana::string&); nana::string text(std::size_t) const; - bool toolbox_button(toolbox_button_t, bool); + bool toolbox(kits, bool); private: void attached(widget_reference, graph_reference) override; void detached() override; @@ -182,18 +191,28 @@ namespace nana typedef Type value_type; ///< The type of element data which is stored in the tabbar. typedef drawerbase::tabbar::item_renderer item_renderer; ///< A user-defined item renderer should be derived from this interface. + //These member types is deprecated, they will be removed in Nana 1.3 struct button_add{}; ///< The type identifies the add button of the tabbar's toolbox. struct button_scroll{}; ///< The type identifies the scroll button of the tabbar's toolbox. struct button_list{}; ///< The type identifies the list button of the tabbar's toolbox. struct button_close{}; ///< The type identifies the close button of the tabbar's toolbox. - /// A template class identifies the buttons of the tabbars toolbox. Refer to notes for more details. + //This template class is deprecated, it will be removed in 1.3 + /// A template class identifies the buttons of the tabbar's toolbox. Refer to notes for more details. template struct button_container { typedef meta::fixed_type_set type_set; }; + enum class kits + { + add, ///< The type identifies the add button of the tabbar's toolbox. + scroll, ///< The type identifies the scroll button of the tabbar's toolbox + list, ///< The type identifies the list button of the tabbar's toolbox + close ///< The type identifies the close button of the tabbar's toolbox + }; + tabbar() { evt_agent_.reset(new drawerbase::tabbar::event_agent(*this, this->get_drawer_trigger())); @@ -304,22 +323,30 @@ namespace nana auto & tg = this->get_drawer_trigger(); bool redraw = false; + using inner_kits = drawerbase::tabbar::trigger::kits; + if(type_set::template count::value) - redraw |= tg.toolbox_button(tg.ButtonAdd, enable); + redraw |= tg.toolbox(inner_kits::add, enable); if(type_set::template count::value) - redraw |= tg.toolbox_button(tg.ButtonScroll, enable); + redraw |= tg.toolbox(inner_kits::scroll, enable); if(type_set::template count::value) - redraw |= tg.toolbox_button(tg.ButtonList, enable); + redraw |= tg.toolbox(inner_kits::add, enable); if(type_set::template count::value) - redraw |= tg.toolbox_button(tg.ButtonClose, enable); + redraw |= tg.toolbox(inner_kits::close, enable); if(redraw) API::refresh_window(this->handle()); } + void toolbox(kits kit, bool enable) + { + if (this->get_drawer_trigger().toolbox(kit, enable)) + API::refresh_window(this->handle()); + } + void text(std::size_t pos, const nana::string& str) /// Sets the title of the specified item, If pos is invalid, the method throws an std::out_of_range object. { this->get_drawer_trigger().text(pos, str); diff --git a/source/gui/widgets/tabbar.cpp b/source/gui/widgets/tabbar.cpp index 3fde24cc..c0acd9f3 100644 --- a/source/gui/widgets/tabbar.cpp +++ b/source/gui/widgets/tabbar.cpp @@ -435,6 +435,7 @@ namespace nana { if ((nullptr == evt_agent_) || evt_agent_->removed(pos)) { + API::show_window(iterator_at(pos)->relative, false); list_.erase(iterator_at(pos)); _m_adjust(); @@ -459,6 +460,8 @@ namespace nana basis_.scroll_pixels = 0; } + if (basis_.active != ::nana::npos) + API::show_window(iterator_at(basis_.active)->relative, true); if(evt_agent_) evt_agent_->activated(basis_.active); return true; @@ -1192,23 +1195,23 @@ namespace nana return layouter_->text(i); } - bool trigger::toolbox_button(toolbox_button_t btn, bool enable) + bool trigger::toolbox(kits btn, bool enable) { - toolbox::button_t tb = toolbox::ButtonSize; - toolbox & tbobj = layouter_->toolbox_object(); + auto tb = toolbox::ButtonSize; + auto& tbox = layouter_->toolbox_object(); switch(btn) { - case trigger::ButtonAdd: + case kits::add: tb = toolbox::ButtonAdd; break; - case trigger::ButtonList: + case kits::list: tb = toolbox::ButtonList; break; - case trigger::ButtonClose: + case kits::close: tb = toolbox::ButtonClose; break; - case trigger::ButtonScroll: - tbobj.enable(toolbox::ButtonScrollBack, enable); - return tbobj.enable(tbobj.ButtonScrollNext, enable); + case kits::scroll: + tbox.enable(toolbox::ButtonScrollBack, enable); + return tbox.enable(tbox.ButtonScrollNext, enable); } - return (tb != toolbox::ButtonSize ? tbobj.enable(tb, enable) : false); + return (tb != toolbox::ButtonSize ? tbox.enable(tb, enable) : false); } void trigger::attached(widget_reference widget, graph_reference graph) From 9844792c5423488470fe34b292473d74c0ad2d1e Mon Sep 17 00:00:00 2001 From: Jinhao Date: Wed, 4 Nov 2015 01:21:35 +0800 Subject: [PATCH 60/65] add a listbox::scroll() to scroll the view to the top or bottom --- include/nana/gui/widgets/listbox.hpp | 5 +- source/gui/widgets/listbox.cpp | 83 +++++++++++++++++++++++++++- 2 files changed, 85 insertions(+), 3 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index be509a12..2983d00b 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -554,7 +554,10 @@ By \a clicking on one header the list get \a reordered, first up, and then down listbox(window, bool visible); listbox(window, const rectangle& = {}, bool visible = true); - void auto_draw(bool); ///< Set state: Redraw automatically after an operation? + void auto_draw(bool); ///< Set state: Redraw automatically after an operation + + /// Scrolls the view to the first or last item of a specified category + void scroll(size_type cat_pos, bool to_bottom); /// Appends a new column with a header text and the specified width at the end, and return it position size_type append_header(nana::string header_text, unsigned width = 120); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 9db220c2..0610432e 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -848,6 +848,8 @@ namespace nana return sorted_reverse_; } + void scroll(const index_pair& pos, bool to_bottom); + ///Append a new category with a specified name and return a pointer to it. category_t* create_cat(nana::string&& text) { @@ -2405,6 +2407,54 @@ namespace nana std::vector> panes_; }; + void es_lister::scroll(const index_pair& pos, bool to_bottom) + { + auto& cat = *get(pos.cat); + + if ((pos.item != ::nana::npos) && (pos.item >= cat.items.size())) + throw std::invalid_argument("listbox: invalid pos to scroll"); + + if (!cat.expand) + { + this->expand(pos.cat, true); + ess_->adjust_scroll_life(); + } + + //The number of items can be displayed on screen + auto view_items = ess_->number_of_lister_items(false) - 1; + + index_pair start_pos; + if (to_bottom) + { + //start_pos will be (0,0) if backward fails + backward(pos, view_items, start_pos); + } + else + { + if (forward(pos, view_items, start_pos)) + start_pos = pos; + else + { + index_pair last(list_.size() - 1); + + if (list_.back().expand) + { + if (list_.back().items.empty()) + last.item = npos; + else + last.item = list_.back().items.size() - 1; + } + else + last.item = ::nana::npos; + + backward(last, view_items, start_pos); + } + } + + ess_->set_scroll_y_dpl(start_pos); + ess_->adjust_scroll_value(); + } + void es_lister::erase(const index_pair& pos) { auto & catobj = *get(pos.cat); @@ -4180,12 +4230,41 @@ namespace nana _m_ess().set_auto_draw(ad); } + void listbox::scroll(size_type cat_pos, bool to_bottom) + { + auto & ess = _m_ess(); + auto cats = ess.lister.size_categ(); + + if (::nana::npos != cat_pos) + { + if (cat_pos >= cats) + throw std::invalid_argument("listbox: invalid category"); + } + else + cat_pos = cats - 1; + + index_pair pos(cat_pos); + if (to_bottom) + { + auto items = ess.lister.size_item(cat_pos); + if (0 == items) + pos.item = ::nana::npos; + else + pos.item = items - 1; + } + else + pos.item = ess.lister.size_item(cat_pos) ? 0 : ::nana::npos; + + ess.lister.scroll(pos, to_bottom); + ess.update(); + } + listbox::size_type listbox::append_header(nana::string text, unsigned width) { auto & ess = _m_ess(); - listbox::size_type index = ess.header.create(std::move(text), width); + auto pos = ess.header.create(std::move(text), width); ess.update(); - return index; + return pos; } listbox& listbox::header_width(size_type pos, unsigned pixels) From 0ddee515681192cf4c5aec629978a429976f22af Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 5 Nov 2015 00:43:27 +0800 Subject: [PATCH 61/65] swap the position of listbox::scorll's two parameters --- include/nana/gui/widgets/listbox.hpp | 2 +- source/gui/widgets/listbox.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 2983d00b..b18f1ccc 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -557,7 +557,7 @@ By \a clicking on one header the list get \a reordered, first up, and then down void auto_draw(bool); ///< Set state: Redraw automatically after an operation /// Scrolls the view to the first or last item of a specified category - void scroll(size_type cat_pos, bool to_bottom); + void scroll(bool to_bottom, size_type cat_pos = ::nana::npos); /// Appends a new column with a header text and the specified width at the end, and return it position size_type append_header(nana::string header_text, unsigned width = 120); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 0610432e..557871b4 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -4230,7 +4230,7 @@ namespace nana _m_ess().set_auto_draw(ad); } - void listbox::scroll(size_type cat_pos, bool to_bottom) + void listbox::scroll(bool to_bottom, size_type cat_pos) { auto & ess = _m_ess(); auto cats = ess.lister.size_categ(); From 408b4f408b4c983a21083a89620e1f6fa14a33ce Mon Sep 17 00:00:00 2001 From: Jinhao Date: Thu, 5 Nov 2015 23:47:48 +0800 Subject: [PATCH 62/65] add an overloading function of listbox::scroll clicking horizontal barre moves "one letter" --- include/nana/gui/widgets/listbox.hpp | 1 + source/gui/widgets/listbox.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index b18f1ccc..5ade4c67 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -558,6 +558,7 @@ By \a clicking on one header the list get \a reordered, first up, and then down /// Scrolls the view to the first or last item of a specified category void scroll(bool to_bottom, size_type cat_pos = ::nana::npos); + void scroll(bool to_bottom, const index_pair& pos); /// Appends a new column with a header text and the specified width at the end, and return it position size_type append_header(nana::string header_text, unsigned width = 120); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 557871b4..31f28a13 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -2008,6 +2008,7 @@ namespace nana scroll.h.amount(header.pixels()); scroll.h.range(graph->width() - width); scroll.h.value(scroll.offset_x); + scroll.h.step(graph->text_extent_size(L"W").width); } if(scroll.v.empty() == false) @@ -4259,6 +4260,13 @@ namespace nana ess.update(); } + void listbox::scroll(bool to_bottom, const index_pair& pos) + { + auto & ess = _m_ess(); + ess.lister.scroll(pos, to_bottom); + ess.update(); + } + listbox::size_type listbox::append_header(nana::string text, unsigned width) { auto & ess = _m_ess(); From 1c729f1d9294ba555d09b72689971436bbc816a1 Mon Sep 17 00:00:00 2001 From: Leonardo Backes Vargas Date: Thu, 5 Nov 2015 23:59:27 -0200 Subject: [PATCH 63/65] Fix listbox for auto_draw+inline_factory+item_proxy::value. When calling templated append() overload on a shown listbox, auto_draw caused an early redraw, which issued the inline widget set() member function before the value() and value_ptr() were actually set. --- include/nana/gui/widgets/listbox.hpp | 4 ++++ source/gui/widgets/listbox.cpp | 6 +++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 5ade4c67..06666cd1 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -368,6 +368,9 @@ namespace nana item_proxy iter{ ess_, index_pair(pos_, size() - 1) }; if (set_value) iter.value(std::forward(t)); + + update(); + return iter; } @@ -441,6 +444,7 @@ namespace nana essence_t* ess_{nullptr}; category_t* cat_{nullptr}; size_type pos_{0}; ///< Absolute position, not relative to display, and dont change during sort() + void update(); }; struct export_options diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 31f28a13..fa502292 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -4188,7 +4188,6 @@ namespace nana auto & m = cat_->items.back(); m.bgcolor = wd->bgcolor(); m.fgcolor = wd->fgcolor(); - ess_->update(); } } @@ -4204,6 +4203,11 @@ namespace nana auto i = ess_->lister.get(pos_); cat_ = &(*i); } + + void cat_proxy::update() { + ess_->update(); + } + //class cat_proxy //end class cat_proxy From e3e861eec87aa3a5b291baf90acd62a0a2949a3d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 8 Nov 2015 03:30:17 +0800 Subject: [PATCH 64/65] a modification for leobackes's pull request --- include/nana/gui/widgets/listbox.hpp | 4 ++-- source/gui/widgets/listbox.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 06666cd1..59324ef2 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -369,7 +369,7 @@ namespace nana if (set_value) iter.value(std::forward(t)); - update(); + _m_update(); return iter; } @@ -440,11 +440,11 @@ namespace nana private: void _m_append(std::vector && cells); void _m_cat_by_pos(); + void _m_update(); private: essence_t* ess_{nullptr}; category_t* cat_{nullptr}; size_type pos_{0}; ///< Absolute position, not relative to display, and dont change during sort() - void update(); }; struct export_options diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index fa502292..fe68dcec 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -4204,7 +4204,7 @@ namespace nana cat_ = &(*i); } - void cat_proxy::update() { + void cat_proxy::_m_update() { ess_->update(); } From 4f988a222328382ad31307ffc79a99e6da1064e6 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 8 Nov 2015 23:35:38 +0800 Subject: [PATCH 65/65] remove marco PLATFORM_SPEC_HPP --- include/nana/config.hpp | 2 -- .../nana/detail/platform_spec_selector.hpp | 21 +++++++++++++++++++ include/nana/detail/win32/platform_spec.hpp | 2 +- source/deploy.cpp | 2 +- source/detail/linux_X11/platform_spec.cpp | 4 +--- source/detail/win32/platform_spec.cpp | 4 +--- source/gui/detail/bedrock_pi.cpp | 3 +-- source/gui/detail/linux_X11/bedrock.cpp | 3 +-- source/gui/detail/native_window_interface.cpp | 3 +-- source/gui/detail/win32/bedrock.cpp | 4 +--- source/gui/notifier.cpp | 7 +++---- source/gui/timer.cpp | 2 +- source/gui/widgets/listbox.cpp | 1 + .../paint/detail/native_paint_interface.cpp | 3 +-- source/paint/graphics.cpp | 3 +-- source/paint/image.cpp | 3 +-- source/paint/pixel_buffer.cpp | 3 +-- source/paint/text_renderer.cpp | 3 +-- source/system/dataexch.cpp | 4 ++-- source/system/platform.cpp | 4 ++-- 20 files changed, 43 insertions(+), 38 deletions(-) create mode 100644 include/nana/detail/platform_spec_selector.hpp diff --git a/include/nana/config.hpp b/include/nana/config.hpp index d1dfef77..0cc5aa4f 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -37,7 +37,6 @@ #if defined(_WIN32) || defined(__WIN32__) || defined(WIN32) //Windows: #define NANA_WINDOWS 1 - #define PLATFORM_SPEC_HPP //Test if it is MINGW #if defined(__MINGW32__) || defined(__MINGW64__) @@ -52,7 +51,6 @@ //Linux: #define NANA_LINUX 1 #define NANA_X11 1 - #define PLATFORM_SPEC_HPP #define STD_CODECVT_NOT_SUPPORTED #else # static_assert(false, "Only Windows and Unix are supported now"); diff --git a/include/nana/detail/platform_spec_selector.hpp b/include/nana/detail/platform_spec_selector.hpp new file mode 100644 index 00000000..4531bde5 --- /dev/null +++ b/include/nana/detail/platform_spec_selector.hpp @@ -0,0 +1,21 @@ +/* + * Selector of Platform Specification + * Nana C++ Library(http://www.nanapro.org) + * Copyright(C) 2003-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/detail/platform_spec_selector.hpp + * + * Selects the proper platform_spec header file for the current platform + */ + +#include + +#if defined(NANA_WINDOWS) +#include +#else +#include +#endif \ No newline at end of file diff --git a/include/nana/detail/win32/platform_spec.hpp b/include/nana/detail/win32/platform_spec.hpp index 3afea077..b0b90fad 100644 --- a/include/nana/detail/win32/platform_spec.hpp +++ b/include/nana/detail/win32/platform_spec.hpp @@ -1,7 +1,7 @@ /* * Platform Specification Implementation * Nana C++ Library(http://www.nanapro.org) - * Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at diff --git a/source/deploy.cpp b/source/deploy.cpp index c4d4d3f8..fac8728f 100644 --- a/source/deploy.cpp +++ b/source/deploy.cpp @@ -20,7 +20,7 @@ #include #elif defined(NANA_LINUX) #include - #include PLATFORM_SPEC_HPP + #include #endif //Implement workarounds for GCC/MinGW which version is below 4.8.2 diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index bdab0cf0..29a9411e 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -13,9 +13,7 @@ * * http://standards.freedesktop.org/clipboards-spec/clipboards-0.1.txt */ -#include - -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index 767b843f..ffc6dc28 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -11,9 +11,7 @@ * * This file provides basis class and data structrue that required by nana */ -#include - -#include PLATFORM_SPEC_HPP +#include #include #include diff --git a/source/gui/detail/bedrock_pi.cpp b/source/gui/detail/bedrock_pi.cpp index 4ca34572..830887ea 100644 --- a/source/gui/detail/bedrock_pi.cpp +++ b/source/gui/detail/bedrock_pi.cpp @@ -10,8 +10,7 @@ * @file: nana/gui/detail/bedrock_pi.cpp */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index a66a205e..fa51348b 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -10,8 +10,7 @@ * @file: nana/gui/detail/linux_X11/bedrock.cpp */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 8605f6f1..fa3c2558 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -10,8 +10,7 @@ * @file: nana/gui/detail/native_window_interface.cpp */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #if defined(NANA_WINDOWS) diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index a6c13feb..2a68f95a 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -11,9 +11,7 @@ * @contributors: Ariel Vina-Rodriguez */ -#include - -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/gui/notifier.cpp b/source/gui/notifier.cpp index 742a78b9..de3fc65f 100644 --- a/source/gui/notifier.cpp +++ b/source/gui/notifier.cpp @@ -24,10 +24,9 @@ #include #endif -#if defined(NANA_WINDOWS) -#include -#elif defined(NANA_LINUX) -#include PLATFORM_SPEC_HPP +#include + +#if defined(NANA_LINUX) #include #include #endif diff --git a/source/gui/timer.cpp b/source/gui/timer.cpp index 75181a7f..70713897 100644 --- a/source/gui/timer.cpp +++ b/source/gui/timer.cpp @@ -27,7 +27,7 @@ #if defined(NANA_WINDOWS) #include #elif defined(NANA_LINUX) -#include PLATFORM_SPEC_HPP +#include #include #endif diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index fe68dcec..4c94a7a5 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -9,6 +9,7 @@ * * @file: nana/gui/widgets/listbox.cpp * @contributors: Hiroshi Seki, Ariel Vina-Rodriguez + * leobackes(pr #86) */ #include diff --git a/source/paint/detail/native_paint_interface.cpp b/source/paint/detail/native_paint_interface.cpp index 0222269f..77dd3c7c 100644 --- a/source/paint/detail/native_paint_interface.cpp +++ b/source/paint/detail/native_paint_interface.cpp @@ -11,8 +11,7 @@ * @contributors: dareg */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 5b489cdf..2e0000cd 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -10,8 +10,7 @@ * @file: nana/paint/graphics.cpp */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/paint/image.cpp b/source/paint/image.cpp index ddbf317b..8d75a555 100644 --- a/source/paint/image.cpp +++ b/source/paint/image.cpp @@ -10,8 +10,7 @@ * @file: nana/paint/image.cpp */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/paint/pixel_buffer.cpp b/source/paint/pixel_buffer.cpp index a438412d..c3330c8d 100644 --- a/source/paint/pixel_buffer.cpp +++ b/source/paint/pixel_buffer.cpp @@ -11,8 +11,7 @@ * @note: The format of Xorg 16bits depth is 565 */ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/paint/text_renderer.cpp b/source/paint/text_renderer.cpp index 10d3cd6d..affefba7 100644 --- a/source/paint/text_renderer.cpp +++ b/source/paint/text_renderer.cpp @@ -1,6 +1,5 @@ -#include -#include PLATFORM_SPEC_HPP +#include #include #include #include diff --git a/source/system/dataexch.cpp b/source/system/dataexch.cpp index 8929b240..b3b54686 100644 --- a/source/system/dataexch.cpp +++ b/source/system/dataexch.cpp @@ -1,6 +1,6 @@ /* * Data Exchanger Implementation - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -19,7 +19,7 @@ #if defined(NANA_WINDOWS) #include #elif defined(NANA_X11) - #include PLATFORM_SPEC_HPP + #include #include #include #endif diff --git a/source/system/platform.cpp b/source/system/platform.cpp index 2985e831..7c2fb59a 100644 --- a/source/system/platform.cpp +++ b/source/system/platform.cpp @@ -1,6 +1,6 @@ /* * A platform API implementation - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at @@ -14,7 +14,7 @@ #if defined(NANA_WINDOWS) #include - #include PLATFORM_SPEC_HPP + #include #elif defined(NANA_LINUX) #include #include