diff --git a/build/codeblocks/nana.cbp b/build/codeblocks/nana.cbp index b2021965..b2a80a96 100644 --- a/build/codeblocks/nana.cbp +++ b/build/codeblocks/nana.cbp @@ -52,6 +52,7 @@ + diff --git a/build/codeblocks/nana.layout b/build/codeblocks/nana.layout index 469d6a54..f332844d 100644 --- a/build/codeblocks/nana.layout +++ b/build/codeblocks/nana.layout @@ -1,51 +1,26 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + @@ -56,14 +31,9 @@ - + - - - - - - + @@ -71,14 +41,29 @@ + + + + + + + + + + + + + + + - + - + @@ -86,34 +71,24 @@ - - - - - - + - + - + - + - + - - - - - - + @@ -121,11 +96,41 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -136,19 +141,14 @@ - - - - - - + - + diff --git a/build/vc2013/nana.v12.suo b/build/vc2013/nana.v12.suo index d9bff60c..55c501ac 100644 Binary files a/build/vc2013/nana.v12.suo and b/build/vc2013/nana.v12.suo differ diff --git a/build/vc2013/nana.vcxproj b/build/vc2013/nana.vcxproj index 292712b0..c5c19e78 100644 --- a/build/vc2013/nana.vcxproj +++ b/build/vc2013/nana.vcxproj @@ -99,6 +99,7 @@ + diff --git a/build/vc2013/nana.vcxproj.filters b/build/vc2013/nana.vcxproj.filters index 3309f037..5d2bb2ae 100644 --- a/build/vc2013/nana.vcxproj.filters +++ b/build/vc2013/nana.vcxproj.filters @@ -291,5 +291,8 @@ Source Files\nana + + Source Files\nana\gui\detail + \ No newline at end of file diff --git a/include/nana/config.hpp b/include/nana/config.hpp index 8c25d372..418871f1 100644 --- a/include/nana/config.hpp +++ b/include/nana/config.hpp @@ -18,7 +18,6 @@ //Windows: #define NANA_WINDOWS 1 #define PLATFORM_SPEC_HPP - #define GUI_BEDROCK_HPP //Test if it is MINGW #if defined(__MINGW32__) @@ -31,8 +30,6 @@ #define NANA_LINUX 1 #define NANA_X11 1 #define PLATFORM_SPEC_HPP - #define GUI_BEDROCK_HPP - #define STD_CODECVT_NOT_SUPPORTED #endif diff --git a/include/nana/gui/detail/basic_window.hpp b/include/nana/gui/detail/basic_window.hpp index 2c70bd56..f1b54021 100644 --- a/include/nana/gui/detail/basic_window.hpp +++ b/include/nana/gui/detail/basic_window.hpp @@ -14,7 +14,7 @@ #define NANA_GUI_DETAIL_BASIC_WINDOW_HPP #include "drawer.hpp" #include "events_holder.hpp" -#include "../basis.hpp" +#include "widget_colors.hpp" #include #include #include @@ -181,6 +181,8 @@ namespace detail color bgcolor; color activated; }colors; + + widget_colors* expr_colors{ nullptr }; struct { diff --git a/include/nana/gui/detail/bedrock.hpp b/include/nana/gui/detail/bedrock.hpp index d58cc680..b91c728f 100644 --- a/include/nana/gui/detail/bedrock.hpp +++ b/include/nana/gui/detail/bedrock.hpp @@ -16,6 +16,7 @@ #include "events_operation.hpp" #include "runtime_manager.hpp" #include "general_events.hpp" +#include "color_schemes.hpp" #include "internal_scope_guard.hpp" namespace nana @@ -76,6 +77,9 @@ namespace detail void set_cursor(core_window_t*, nana::cursor, thread_context*); void define_state_cursor(core_window_t*, nana::cursor, thread_context*); 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&&); public: window_manager_t wd_manager; events_operation evt_operation; @@ -92,6 +96,8 @@ namespace detail private: static bedrock bedrock_object; + struct pi_data; + pi_data* pi_data_; struct private_impl; private_impl *impl_; };//end class bedrock diff --git a/include/nana/gui/detail/bedrock_pi_data.hpp b/include/nana/gui/detail/bedrock_pi_data.hpp new file mode 100644 index 00000000..b54e658f --- /dev/null +++ b/include/nana/gui/detail/bedrock_pi_data.hpp @@ -0,0 +1,18 @@ +#ifndef NANA_DETAIL_BEDROCK_PI_DATA_HPP +#define NANA_DETAIL_BEDROCK_PI_DATA_HPP + +#include +#include "color_schemes.hpp" + +namespace nana +{ + namespace detail + { + struct bedrock::pi_data + { + color_schemes scheme; + + }; + } +} +#endif diff --git a/include/nana/gui/detail/color_schemes.hpp b/include/nana/gui/detail/color_schemes.hpp new file mode 100644 index 00000000..25f75079 --- /dev/null +++ b/include/nana/gui/detail/color_schemes.hpp @@ -0,0 +1,80 @@ +/* +* Color Schemes +* Nana C++ Library(http://www.nanapro.org) +* Copyright(C) 2003-2014 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/color_schemes.hpp +* @description: +*/ +#ifndef NANA_DETAIL_COLOR_SCHEMES_HPP +#define NANA_DETAIL_COLOR_SCHEMES_HPP + +#include "widget_colors.hpp" +#include + +namespace nana +{ + namespace detail + { + class scheme_factory_base + { + public: + struct factory_identifier{}; + 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; + }; + + template + class scheme_factory + : public scheme_factory_base + { + private: + factory_identifier* get_id() const override + { + return &fid_; + } + + std::unique_ptr create() override + { + return std::unique_ptr(new Scheme); + } + + std::unique_ptr create(widget_colors& other) override + { + return std::unique_ptr{new Scheme(static_cast(other))}; + } + private: + static factory_identifier fid_; + }; + + template + scheme_factory_base::factory_identifier scheme_factory::fid_; + + class color_schemes + { + struct implement; + color_schemes(const color_schemes&) = delete; + color_schemes(color_schemes&&) = delete; + color_schemes& operator=(const color_schemes&) = delete; + color_schemes& operator=(color_schemes&&) = delete; + public: + using scheme = widget_colors; + + color_schemes(); + ~color_schemes(); + + scheme& scheme_template(scheme_factory_base&&); + std::unique_ptr create(scheme_factory_base&&); + private: + implement * impl_; + }; + }//end namespace detail; +}//end namespace nana +#endif \ No newline at end of file diff --git a/include/nana/gui/detail/general_events.hpp b/include/nana/gui/detail/general_events.hpp index 486373d8..2d802b86 100644 --- a/include/nana/gui/detail/general_events.hpp +++ b/include/nana/gui/detail/general_events.hpp @@ -28,21 +28,21 @@ namespace nana class event_interface { public: - virtual ~event_interface(){} + virtual ~event_interface() = default; virtual void remove(event_handle) = 0; }; class docker_interface { public: - virtual ~docker_interface(){} + virtual ~docker_interface() = default; virtual event_interface* get_event() const = 0; }; class event_arg_interface { public: - virtual ~event_arg_interface(){} + virtual ~event_arg_interface() = default; }; void events_operation_register(event_handle); @@ -471,6 +471,7 @@ namespace nana basic_event move; basic_event resizing; basic_event resized; + basic_event destroy; }; diff --git a/include/nana/gui/detail/widget_colors.hpp b/include/nana/gui/detail/widget_colors.hpp new file mode 100644 index 00000000..90bd25b5 --- /dev/null +++ b/include/nana/gui/detail/widget_colors.hpp @@ -0,0 +1,44 @@ +/* +* Color Schemes +* Nana C++ Library(http://www.nanapro.org) +* Copyright(C) 2003-2014 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/color_schemes.hpp +* @description: +*/ +#ifndef NANA_DETAIL_WIDGET_COLORS_HPP +#define NANA_DETAIL_WIDGET_COLORS_HPP + +#include +#include +namespace nana +{ + class color_proxy + { + public: + color_proxy(const color_proxy&); + color_proxy(color_rgb); + color_proxy(colors); + color_proxy& operator=(const color_proxy&); + color_proxy& operator=(const ::nana::color&); + color get_color() const; + operator color() const; + private: + std::shared_ptr color_; + };//end namespace color_proxy + + struct widget_colors + { + virtual ~widget_colors() = default; + + color_proxy activated{ static_cast(0x60C8FD) }; + color_proxy background{colors::button_face}; + color_proxy foreground{colors::black}; + }; +} + +#endif \ No newline at end of file diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index 0c85d589..91a46cf0 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -13,7 +13,7 @@ #ifndef NANA_GUI_PROGRAMMING_INTERFACE_HPP #define NANA_GUI_PROGRAMMING_INTERFACE_HPP #include -#include GUI_BEDROCK_HPP +#include "detail/bedrock.hpp" #include "effects.hpp" #include "detail/general_events.hpp" #include @@ -45,6 +45,16 @@ namespace API } bool set_events(window, const std::shared_ptr&); + + template + std::unique_ptr make_scheme() + { + return std::unique_ptr( + static_cast(::nana::detail::bedrock::instance().make_scheme(::nana::detail::scheme_factory()).release())); + } + + void set_scheme(window, widget_colors*); + widget_colors* get_scheme(window); void attach_drawer(widget&, drawer_trigger&); nana::string window_caption(window); @@ -66,6 +76,13 @@ namespace API void exit(); + template + Scheme& get_scheme() + { + auto & brock = ::nana::detail::bedrock::instance(); + return static_cast(brock.get_scheme_template(::nana::detail::scheme_factory{})); + } + nana::string transform_shortkey_text(nana::string text, nana::string::value_type &shortkey, nana::string::size_type *skpos); bool register_shortkey(window, unsigned long); void unregister_shortkey(window); diff --git a/include/nana/gui/widgets/combox.hpp b/include/nana/gui/widgets/combox.hpp index 0a46eed1..03f319d9 100644 --- a/include/nana/gui/widgets/combox.hpp +++ b/include/nana/gui/widgets/combox.hpp @@ -14,6 +14,7 @@ #define NANA_GUI_WIDGETS_COMBOX_HPP #include "widget.hpp" #include "float_listbox.hpp" +#include "skeletons/text_editor_scheme.hpp" #include #include #include @@ -160,7 +161,7 @@ namespace nana }//end namespace drawerbase class combox - : public widget_object, + : public widget_object, public nana::concepts::any_objective { public: diff --git a/include/nana/gui/widgets/form.hpp b/include/nana/gui/widgets/form.hpp index 9f4d1e2a..0f64c54a 100644 --- a/include/nana/gui/widgets/form.hpp +++ b/include/nana/gui/widgets/form.hpp @@ -47,6 +47,7 @@ namespace nana form(window, const rectangle&, const appearance& = {}); void modality() const; + void wait_for_this(); }; class nested_form : public widget_object diff --git a/include/nana/gui/widgets/skeletons/text_editor.hpp b/include/nana/gui/widgets/skeletons/text_editor.hpp index ca011a0b..d24d04d8 100644 --- a/include/nana/gui/widgets/skeletons/text_editor.hpp +++ b/include/nana/gui/widgets/skeletons/text_editor.hpp @@ -14,9 +14,9 @@ #ifndef NANA_GUI_SKELETONS_TEXT_EDITOR_HPP #define NANA_GUI_SKELETONS_TEXT_EDITOR_HPP #include "textbase.hpp" +#include "text_editor_scheme.hpp" #include #include -#include namespace nana{ namespace widgets { @@ -128,18 +128,18 @@ namespace nana{ namespace widgets class undo_input_text; class undo_move_text; public: - typedef nana::char_t char_type; + typedef ::nana::char_t char_type; typedef textbase::size_type size_type; typedef textbase::string_type string_type; - typedef nana::paint::graphics & graph_reference; + typedef ::nana::paint::graphics & graph_reference; struct ext_renderer_tag { std::function background; }; - text_editor(window, graph_reference); + text_editor(window, graph_reference, const text_editor_scheme*); ~text_editor(); bool respone_keyboard(nana::char_t, bool enterable); @@ -263,10 +263,10 @@ namespace nana{ namespace widgets //_m_draw_string //@brief: Draw a line of string void _m_draw_string(int top, const ::nana::color&, const nana::upoint& str_pos, const nana::string&, bool if_mask) const; - //_m_draw - //@brief: Draw a character at a position specified by caret pos. - //@return: true if beyond the border - bool _m_draw(nana::char_t, std::size_t secondary_before); + //_m_update_caret_line + //@brief: redraw whole line specified by caret pos. + //@return: true if caret overs the border + bool _m_update_caret_line(std::size_t secondary_before); bool _m_get_sort_select_points(nana::upoint&, nana::upoint&) const; void _m_offset_y(int y); @@ -279,6 +279,8 @@ namespace nana{ namespace widgets undoable undo_; nana::window window_; graph_reference graph_; + const text_editor_scheme* scheme_; + skeletons::textbase textbase_; nana::char_t mask_char_{0}; diff --git a/include/nana/gui/widgets/skeletons/text_editor_scheme.hpp b/include/nana/gui/widgets/skeletons/text_editor_scheme.hpp new file mode 100644 index 00000000..00806b3b --- /dev/null +++ b/include/nana/gui/widgets/skeletons/text_editor_scheme.hpp @@ -0,0 +1,22 @@ + +#ifndef NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP +#define NANA_WIDGETS_SKELETONS_TEXT_EDITOR_SCHEME_HPP + +#include "../../detail/widget_colors.hpp" + +namespace nana +{ + namespace widgets + { + namespace skeletons + { + struct text_editor_scheme + : public ::nana::widget_colors + { + color_proxy selection{static_cast(0x3399FF)}; + color_proxy selection_text{colors::white}; + }; + } + } +} +#endif \ No newline at end of file diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index d4ba85f3..5c3a060e 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -13,6 +13,7 @@ #define NANA_GUI_WIDGET_TEXTBOX_HPP #include #include "skeletons/textbase_export_interface.hpp" +#include "skeletons/text_editor_scheme.hpp" namespace nana { @@ -96,7 +97,7 @@ namespace nana /// Allow users to enter and edit text by typing on the keyboard. class textbox - :public widget_object + :public widget_object { public: /// The default constructor without creating the widget. diff --git a/include/nana/gui/widgets/widget.hpp b/include/nana/gui/widgets/widget.hpp index 02455c00..234da335 100644 --- a/include/nana/gui/widgets/widget.hpp +++ b/include/nana/gui/widgets/widget.hpp @@ -117,14 +117,17 @@ namespace nana }; /// Base class of all the classes defined as a widget window. Defaultly a widget_tag - template + template class widget_object: public widget { protected: typedef DrawerTrigger drawer_trigger_t; public: + using scheme_type = Scheme; + widget_object() - : events_(std::make_shared()) + : events_{ std::make_shared() }, + scheme_{ API::dev::make_scheme() } {} ~widget_object() @@ -143,12 +146,13 @@ namespace nana return create(parent_wd, rectangle(), visible); } - bool create(window parent_wd, const rectangle & r = rectangle(), bool visible = true) ///< in a widget/root window specified by parent_wd. + bool create(window parent_wd, const rectangle & r = {}, bool visible = true) ///< in a widget/root window specified by parent_wd. { if(parent_wd && this->empty()) { handle_ = API::dev::create_widget(parent_wd, r, this); API::dev::set_events(handle_, events_); + API::dev::set_scheme(handle_, scheme_.get()); API::dev::attach_signal(handle_, *this, &widget_object::signal); API::dev::attach_drawer(*this, trigger_); if(visible) @@ -174,6 +178,11 @@ namespace nana { return API::widget_borderless(handle_); } + + scheme_type& scheme() const + { + return *scheme_; + } protected: DrawerTrigger& get_drawer_trigger() { @@ -212,18 +221,20 @@ namespace nana window handle_{nullptr}; DrawerTrigger trigger_; std::shared_ptr events_; + std::unique_ptr scheme_; };//end class widget_object /// Base class of all the classes defined as a non-graphics-buffer widget window. The second template parameter DrawerTrigger is always ignored.\see nana::panel - template - class widget_object: public widget + template + class widget_object: public widget { protected: typedef DrawerTrigger drawer_trigger_t; public: + using scheme_type = Scheme; widget_object() - : events_(std::make_shared()) + : events_{ std::make_shared() }, scheme_{ API::dev::make_scheme() } {} ~widget_object() @@ -248,6 +259,7 @@ namespace nana { handle_ = API::dev::create_lite_widget(parent_wd, r, this); API::dev::set_events(handle_, events_); + API::dev::set_scheme(handle_, scheme_.get()); if(visible) API::show_window(handle_, true); this->_m_complete_creation(); @@ -259,6 +271,11 @@ namespace nana { return handle_; } + + scheme_type& scheme() const + { + return *scheme_; + } private: void signal(detail::signals::code code, const detail::signals& sig) { @@ -286,16 +303,18 @@ namespace nana private: window handle_{nullptr}; std::shared_ptr events_; + std::unique_ptr scheme_; };//end class widget_object /// Base class of all the classes defined as a root window. \see nana::form - template - class widget_object: public widget + template + class widget_object: public widget { protected: typedef DrawerTrigger drawer_trigger_t; public: + using scheme_type = Scheme; widget_object() { @@ -303,13 +322,13 @@ namespace nana _m_bind_and_attach(); } - widget_object(const rectangle& r, const appearance& apr = appearance()) + widget_object(const rectangle& r, const appearance& apr = {}) { handle_ = API::dev::create_window(nullptr, false, r, apr, this); _m_bind_and_attach(); } - widget_object(window owner, bool nested, const rectangle& r = rectangle(), const appearance& apr = appearance()) + widget_object(window owner, bool nested, const rectangle& r = {}, const appearance& apr = {}) { handle_ = API::dev::create_window(owner, nested, r, apr, this); _m_bind_and_attach(); @@ -376,6 +395,11 @@ namespace nana API::set_window_z_order(handle_, wd_after, action_if_no_wd_after); return *this; } + + scheme_type& scheme() const + { + return *scheme_; + } protected: DrawerTrigger& get_drawer_trigger() { @@ -410,6 +434,9 @@ namespace nana { events_ = std::make_shared(); API::dev::set_events(handle_, events_); + + scheme_ = API::dev::make_scheme(); + API::dev::set_scheme(handle_, scheme_.get()); API::dev::attach_signal(handle_, *this, &widget_object::signal); API::dev::attach_drawer(*this, trigger_); } @@ -422,21 +449,24 @@ namespace nana window handle_; DrawerTrigger trigger_; std::shared_ptr events_; + std::unique_ptr scheme_; };//end class widget_object /// Base class of all the classes defined as a frame window. \see nana::frame - template - class widget_object: public widget{}; + template + class widget_object: public widget{}; /// Especialization. Base class of all the classes defined as a frame window. \see nana::frame - template - class widget_object: public widget + template + class widget_object: public widget { protected: typedef int drawer_trigger_t; public: + using scheme_type = Scheme; + widget_object() - : events_(std::make_shared()) + : events_{ std::make_shared() }, scheme_{ API::dev::make_scheme() } {} ~widget_object() @@ -461,6 +491,7 @@ namespace nana { handle_ = API::dev::create_frame(parent_wd, r, this); API::dev::set_events(handle_, events_); + API::dev::set_scheme(handle_, scheme_.get()); API::dev::attach_signal(handle_, *this, &widget_object::signal); API::show_window(handle_, visible); this->_m_complete_creation(); @@ -472,6 +503,11 @@ namespace nana { return handle_; } + + scheme_type& scheme() const + { + return *scheme_; + } private: virtual drawer_trigger* get_drawer_trigger() { @@ -504,6 +540,7 @@ namespace nana private: window handle_{nullptr}; std::shared_ptr events_; + std::unique_ptr scheme_; };//end class widget_object }//end namespace nana #endif diff --git a/include/nana/paint/gadget.hpp b/include/nana/paint/gadget.hpp index fcc77dd1..6a900548 100644 --- a/include/nana/paint/gadget.hpp +++ b/include/nana/paint/gadget.hpp @@ -28,7 +28,6 @@ namespace gadget void arrow_16_pixels(nana::paint::graphics&, int x, int y, const color&, uint32_t style, directions::t direction); void close_16_pixels(nana::paint::graphics&, int x, int y, uint32_t style, const color&); - //void cross(nana::paint::graphics&, int x, int y, uint32_t size, uint32_t thickness, nana::color_t color); //deprecated void cross(nana::paint::graphics&, int x, int y, uint32_t size, uint32_t thickness, const nana::color&); }//end namespace gadget diff --git a/include/nana/paint/text_renderer.hpp b/include/nana/paint/text_renderer.hpp index 7ee77050..28bb4e8f 100644 --- a/include/nana/paint/text_renderer.hpp +++ b/include/nana/paint/text_renderer.hpp @@ -13,11 +13,6 @@ namespace nana text_renderer(graph_reference graph, align = align::left); - //void render(int x, int y, nana::color_t, const nana::char_t*, std::size_t len); //deprecated - //void render(int x, int y, nana::color_t, const nana::char_t*, std::size_t len, unsigned restricted_pixels, bool omitted); //deprecated - - //void render(int x, int y, nana::color_t, const nana::char_t*, std::size_t len, unsigned restricted_pixels); //deprecated - nana::size extent_size(int x, int y, const nana::char_t*, std::size_t len, unsigned restricted_pixels) const; void render(const point&, const char_t*, std::size_t len); diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index d0016e88..1bbbdec5 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -22,7 +22,7 @@ #include #include #include -#include GUI_BEDROCK_HPP +#include #include #include #include diff --git a/source/gui/detail/basic_window.cpp b/source/gui/detail/basic_window.cpp index cf02f1d3..51089f73 100644 --- a/source/gui/detail/basic_window.cpp +++ b/source/gui/detail/basic_window.cpp @@ -49,9 +49,7 @@ namespace nana void caret_descriptor::effective_range(nana::rectangle rect) { //Chech rect - if( (rect.width && rect.height) && - (rect.x + rect.width > 0) && - (rect.y + rect.height > 0)) + if (rect.width && rect.height && rect.right() > 0 && rect.bottom() > 0) { if(rect.x < 0) { @@ -151,9 +149,9 @@ namespace nana size.width -= (rect.x - pos.x); pos.x = rect.x; } - else if(pos.x + size.width > rect.x + rect.width) + else if(pos.x + size.width > rect.right()) { - size.width -= pos.x + size.width - (rect.x + rect.width); + size.width -= pos.x + size.width - rect.right(); } if(pos.y < rect.y) @@ -161,8 +159,8 @@ namespace nana size.width -= (rect.y - pos.y); pos.y = rect.y; } - else if(pos.y + size.height > rect.y + rect.height) - size.height -= pos.y + size.height - (rect.y + rect.height); + else if(pos.y + size.height > rect.bottom()) + size.height -= pos.y + size.height - rect.bottom(); if(out_of_range_) { @@ -228,7 +226,7 @@ namespace nana : widget_ptr(wdg), other(category::root_tag::value) { drawer.bind(this); - _m_init_pos_and_size(0, rectangle()); + _m_init_pos_and_size(nullptr, rectangle()); this->_m_initialize(owner); } diff --git a/source/gui/detail/bedrock_pi.cpp b/source/gui/detail/bedrock_pi.cpp index 66dec171..7fddd857 100644 --- a/source/gui/detail/bedrock_pi.cpp +++ b/source/gui/detail/bedrock_pi.cpp @@ -12,7 +12,7 @@ #include #include PLATFORM_SPEC_HPP -#include GUI_BEDROCK_HPP +#include #include #include #include @@ -120,6 +120,16 @@ namespace nana } } + widget_colors& bedrock::get_scheme_template(scheme_factory_base&& factory) + { + return pi_data_->scheme.scheme_template(std::move(factory)); + } + + std::unique_ptr bedrock::make_scheme(scheme_factory_base&& factory) + { + return pi_data_->scheme.create(std::move(factory)); + } + void bedrock::_m_emit_core(event_code evt_code, core_window_t* wd, bool draw_only, const ::nana::detail::event_arg_interface& event_arg) { switch (evt_code) diff --git a/source/gui/detail/color_schemes.cpp b/source/gui/detail/color_schemes.cpp new file mode 100644 index 00000000..6a7006ff --- /dev/null +++ b/source/gui/detail/color_schemes.cpp @@ -0,0 +1,78 @@ +#include +#include + +namespace nana +{ + //class color_proxy + color_proxy::color_proxy(const color_proxy& other) + : color_(other.color_) + {} + + color_proxy::color_proxy(color_rgb clr) + : color_(std::make_shared(clr)) + {} + + color_proxy::color_proxy(colors clr) + : color_(std::make_shared(clr)) + {} + + color_proxy& color_proxy::operator=(const color_proxy& other) + { + if (this != &other) + color_ = other.color_; + return *this; + } + + color_proxy& color_proxy::operator=(const ::nana::color& clr) + { + color_ = std::make_shared<::nana::color>(clr); + return *this; + } + + color color_proxy::get_color() const + { + return *color_; + } + + color_proxy::operator color() const + { + return *color_; + } + //end class color_proxy + + namespace detail + { + //class color_schemes + struct color_schemes::implement + { + std::map> scheme_template; + }; + + color_schemes::color_schemes() + : impl_(new implement) + { + } + + color_schemes::~color_schemes() + { + delete impl_; + } + + auto color_schemes::scheme_template(scheme_factory_base&& factory) -> scheme& + { + auto & tmpl_scheme = impl_->scheme_template[factory.get_id()]; + + //Creates a scheme template if no template + if (!tmpl_scheme) + factory.create().swap(tmpl_scheme); + + return *tmpl_scheme.get(); + } + + std::unique_ptr color_schemes::create(scheme_factory_base&& factory) + { + return factory.create(scheme_template(std::move(factory))); + } + //end class color_system + }//end namespace detail +}//end namespace nana \ No newline at end of file diff --git a/source/gui/detail/drawer.cpp b/source/gui/detail/drawer.cpp index 42ef8cd8..d62f9921 100644 --- a/source/gui/detail/drawer.cpp +++ b/source/gui/detail/drawer.cpp @@ -11,7 +11,7 @@ */ #include -#include GUI_BEDROCK_HPP +#include #include #include #include diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 2a82d049..dd20610d 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -12,7 +12,7 @@ #include #include PLATFORM_SPEC_HPP -#include GUI_BEDROCK_HPP +#include #include #include #include @@ -165,13 +165,14 @@ namespace detail } bedrock::bedrock() - : impl_(new private_impl) + : pi_data_(new pi_data), impl_(new private_impl) { nana::detail::platform_spec::instance().msg_set(timer_proc, window_proc_dispatcher); } bedrock::~bedrock() { + delete pi_data_; delete impl_; } diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 5c7f015f..e0d45dff 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -23,7 +23,7 @@ #include #elif defined(NANA_X11) #include - #include GUI_BEDROCK_HPP + #include #endif namespace nana{ diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index 4d02ccea..74b8cb30 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -13,16 +13,18 @@ #include #include PLATFORM_SPEC_HPP -#include GUI_BEDROCK_HPP +#include +#include #include #include #include #include -#include +#include #include #include #include #include +#include #ifndef WM_MOUSEWHEEL #define WM_MOUSEWHEEL 0x020A @@ -175,7 +177,8 @@ namespace detail std::recursive_mutex mutex; thr_context_container thr_contexts; - element_store estore; + color_schemes schemes; + element_store estore; struct cache_type { @@ -213,7 +216,8 @@ namespace detail static LRESULT WINAPI Bedrock_WIN32_WindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam); bedrock::bedrock() - :impl_(new private_impl) + : pi_data_(new pi_data), + impl_(new private_impl) { nana::detail::platform_spec::instance(); //to guaranty the platform_spec object is initialized before using. @@ -269,6 +273,7 @@ namespace detail ::MessageBoxA(0, ss.str().c_str(), ("Nana C++ Library"), MB_OK); } delete impl_; + delete pi_data_; } //inc_window diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 2c119d0f..583ab85f 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -12,7 +12,7 @@ */ #include -#include GUI_BEDROCK_HPP +#include #include #include #include diff --git a/source/gui/programming_interface.cpp b/source/gui/programming_interface.cpp index 5d4f2e82..b541c4a7 100644 --- a/source/gui/programming_interface.cpp +++ b/source/gui/programming_interface.cpp @@ -150,6 +150,22 @@ namespace API return false; } + void set_scheme(window wd, widget_colors* wdg_colors) + { + auto iwd = reinterpret_cast(wd); + internal_scope_guard lock; + if (restrict::window_manager.available(iwd)) + iwd->expr_colors = wdg_colors; + } + + + widget_colors* get_scheme(window wd) + { + auto iwd = reinterpret_cast(wd); + internal_scope_guard lock; + return (restrict::window_manager.available(iwd) ? iwd->expr_colors : nullptr); + } + void attach_drawer(widget& wd, drawer_trigger& dr) { const auto iwd = reinterpret_cast(wd.handle()); @@ -794,20 +810,20 @@ namespace API { internal_scope_guard lock; if (restrict::window_manager.available(reinterpret_cast(wd))) - return reinterpret_cast(wd)->colors.fgcolor; + return reinterpret_cast(wd)->expr_colors->foreground.get_color(); return{}; } - color fgcolor(window wd, const color& col) + color fgcolor(window wd, const color& clr) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; if (restrict::window_manager.available(iwd)) { - auto prev = iwd->colors.fgcolor; - if (prev != col) + auto prev = iwd->expr_colors->foreground.get_color(); + if (prev != clr) { - iwd->colors.fgcolor = col; + iwd->expr_colors->foreground = clr; restrict::window_manager.update(iwd, true, false); } return prev; @@ -819,20 +835,20 @@ namespace API { internal_scope_guard lock; if (restrict::window_manager.available(reinterpret_cast(wd))) - return reinterpret_cast(wd)->colors.bgcolor; + return reinterpret_cast(wd)->expr_colors->background.get_color(); return{}; } - color bgcolor(window wd, const color& col) + color bgcolor(window wd, const color& clr) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; if (restrict::window_manager.available(iwd)) { - auto prev = iwd->colors.bgcolor; - if (prev != col) + auto prev = iwd->expr_colors->background.get_color(); + if (prev != clr) { - iwd->colors.bgcolor = col; + iwd->expr_colors->background = clr; restrict::window_manager.update(iwd, true, false); } return prev; @@ -844,20 +860,20 @@ namespace API { internal_scope_guard lock; if (restrict::window_manager.available(reinterpret_cast(wd))) - return reinterpret_cast(wd)->colors.activated; + return reinterpret_cast(wd)->expr_colors->activated.get_color(); return{}; } - color activated_color(window wd, const color& col) + color activated_color(window wd, const color& clr) { auto iwd = reinterpret_cast(wd); internal_scope_guard lock; if (restrict::window_manager.available(iwd)) { - auto prev = iwd->colors.activated; - if (prev != col) + auto prev = iwd->expr_colors->activated.get_color(); + if (prev != clr) { - iwd->colors.activated = col; + iwd->expr_colors->activated = clr; restrict::window_manager.update(iwd, true, false); } return prev; diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index 9cdc9d4b..8e134047 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -84,7 +84,9 @@ namespace nana void attached(widget_reference wd, graph_reference graph) { widget_ = static_cast< ::nana::combox*>(&wd); - editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph); + + auto scheme = dynamic_cast< ::nana::widgets::skeletons::text_editor_scheme*>(API::dev::get_scheme(wd)); + editor_ = new widgets::skeletons::text_editor(widget_->handle(), graph, scheme); editor_->border_renderer([this](graph_reference graph, const ::nana::color& bgcolor){ draw_border(graph, bgcolor); }); diff --git a/source/gui/widgets/form.cpp b/source/gui/widgets/form.cpp index a95a9608..0c8cfc43 100644 --- a/source/gui/widgets/form.cpp +++ b/source/gui/widgets/form.cpp @@ -54,6 +54,11 @@ namespace nana { API::modal_window(handle()); } + + void form::wait_for_this() + { + API::wait_for(handle()); + } //end class form //class nested_form diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 5212ac5a..1dc8b509 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -1140,9 +1140,9 @@ namespace nana{ namespace widgets }; //end class behavior_linewrapped //class text_editor - text_editor::text_editor(window wd, graph_reference graph) + text_editor::text_editor(window wd, graph_reference graph, const text_editor_scheme* schm) : behavior_(new behavior_normal(*this)), - window_(wd), graph_(graph) + window_(wd), graph_(graph), scheme_(schm) { text_area_.area = graph.size(); text_area_.captured = false; @@ -1661,7 +1661,7 @@ namespace nana{ namespace widgets { const auto bgcolor = _m_bgcolor(); - auto fgcolor = API::fgcolor(window_); + auto fgcolor = scheme_->foreground.get_color(); if (!API::window_enabled(window_)) fgcolor.blend(bgcolor, 0.5); @@ -1727,7 +1727,7 @@ namespace nana{ namespace widgets behavior_->pre_calc_line(points_.caret.y, width_pixels()); points_.caret.x ++; - if(refresh || _m_draw(c, secondary_before)) + if (refresh || _m_update_caret_line(secondary_before)) render(true); else draw_scroll_rectangle(); @@ -2524,7 +2524,8 @@ namespace nana{ namespace widgets //The line of text is in the range of selection nana::upoint a, b; graph_.set_text_color(clr); - graph_.set_color({ 0x33, 0x99, 0xFF }); + + graph_.set_color(scheme_->selection.get_color()); //The text is not selected or the whole line text is selected if ((!_m_get_sort_select_points(a, b)) || (select_.a.y != str_pos.y && select_.b.y != str_pos.y)) @@ -2539,7 +2540,7 @@ namespace nana{ namespace widgets { if (selected) { - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph_.rectangle({ text_pos, { str_w, line_h_pixels } }, true); } @@ -2556,11 +2557,11 @@ namespace nana{ namespace widgets graph_.string(strpos, str, len); paint::graphics graph(glyph_selected, line_h_pixels); graph.typeface(this->graph_.typeface()); - graph.rectangle(true, { 0x33, 0x99, 0xFF }); + graph.rectangle(true, scheme_->selection.get_color()); int sel_xpos = static_cast(str_px - (glyph_front + glyph_selected)); - graph.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph.string({-sel_xpos, 0}, str, len); graph_.bitblt(nana::rectangle(strpos.x + sel_xpos, strpos.y, glyph_selected, line_h_pixels), graph); }; @@ -2584,7 +2585,7 @@ namespace nana{ namespace widgets if (a.x <= pos && str_end <= b.x) { graph_.rectangle({ text_pos, { str_w, line_h_pixels } }, true); - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); } else graph_.set_text_color(clr); @@ -2615,7 +2616,7 @@ namespace nana{ namespace widgets graph_.rectangle({ part_pos, { sel_w, line_h_pixels } }, true); - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph_.string(part_pos, ent.begin + (a.x - pos), endpos - a.x); if (static_cast(endpos) < str_end) @@ -2641,7 +2642,7 @@ namespace nana{ namespace widgets { //LTR graph_.rectangle({ text_pos, { sel_w, line_h_pixels } }, true); - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, endpos - pos); graph_.set_text_color(clr); graph_.string(text_pos + ::nana::point(static_cast(sel_w), 0), ent.begin + (endpos - pos), str_end - endpos); @@ -2666,7 +2667,7 @@ namespace nana{ namespace widgets if (a.x < pos) { graph_.rectangle({ text_pos, { str_w, line_h_pixels } }, true, { 0x33, 0x99, 0xFF }); - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); } graph_.string(text_pos, ent.begin, len); } @@ -2684,7 +2685,7 @@ namespace nana{ namespace widgets ::nana::point part_pos{ text_pos.x + static_cast(head_w), text_pos.y }; graph_.rectangle({ part_pos, {str_w - head_w, line_h_pixels } }, true); - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph_.string(part_pos, ent.begin + a.x - pos, len - (a.x - pos)); } } @@ -2708,7 +2709,7 @@ namespace nana{ namespace widgets if (pos + len <= b.x) { graph_.rectangle({ text_pos, { str_w, line_h_pixels } }, true); - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, len); } else if (pos <= b.x && b.x < pos + len) @@ -2721,8 +2722,7 @@ namespace nana{ namespace widgets else { graph_.rectangle({ text_pos, { sel_w, line_h_pixels } }, true); - - graph_.set_text_color(colors::white); + graph_.set_text_color(scheme_->selection_text.get_color()); graph_.string(text_pos, ent.begin, b.x - pos); graph_.set_text_color(clr); graph_.string(text_pos + ::nana::point(static_cast(sel_w), 0), ent.begin + b.x - pos, len - (b.x - pos)); @@ -2737,10 +2737,7 @@ namespace nana{ namespace widgets } } - //_m_draw - //@brief: Draw a character at a position specified by caret pos. - //@return: true if beyond the border - bool text_editor::_m_draw(nana::char_t c, std::size_t secondary_before) + bool text_editor::_m_update_caret_line(std::size_t secondary_before) { if (false == behavior_->adjust_caret_into_screen()) { diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index 7f9423bc..ffab733a 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -71,8 +71,6 @@ namespace nana public: enum class style{horizontal, vertical}; enum class parts{none, bar, slider}; - //enum dir_t{DirHorizontal, DirVertical}; //deprecated - //enum where_t{WhereNone, WhereBar, WhereSlider}; typedef drawer_trigger::graph_reference graph_reference; diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index b8d9e8a0..08155ddc 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -57,7 +57,9 @@ namespace nana{ namespace drawerbase { widget_ = &wdg; evt_agent_.reset(new event_agent(static_cast< ::nana::textbox&>(wdg))); - editor_ = new text_editor(wd, graph); + auto scheme = API::dev::get_scheme(wdg); + + editor_ = new text_editor(wd, graph, dynamic_cast<::nana::widgets::skeletons::text_editor_scheme*>(scheme)); editor_->textbase().set_event_agent(evt_agent_.get()); editor_->border_renderer([this](graph_reference graph, const ::nana::color& clr){ this->_m_draw_border(graph, clr); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index cdaa54df..48992dc0 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -12,7 +12,7 @@ #include #include PLATFORM_SPEC_HPP -#include GUI_BEDROCK_HPP +#include #include #include #include diff --git a/source/system/dataexch.cpp b/source/system/dataexch.cpp index bfd89668..926e6f98 100644 --- a/source/system/dataexch.cpp +++ b/source/system/dataexch.cpp @@ -16,7 +16,7 @@ #include #elif defined(NANA_X11) #include PLATFORM_SPEC_HPP - #include GUI_BEDROCK_HPP + #include #include #endif