From 1b5aed2e5f0341b1baea73bdaf2848543640e153 Mon Sep 17 00:00:00 2001 From: Jinhao Date: Tue, 13 Oct 2015 01:38:53 +0800 Subject: [PATCH] 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 {