From fd5ff571a7d6ec2d4427012a00ab527ff2770c6b Mon Sep 17 00:00:00 2001 From: cnjinhao Date: Wed, 4 Feb 2015 10:26:08 +0800 Subject: [PATCH] get ready for Linux --- include/nana/basic_types.hpp | 2 +- include/nana/gui/detail/drawer.hpp | 8 +- include/nana/gui/programming_interface.hpp | 2 +- include/nana/gui/screen.hpp | 4 +- include/nana/gui/widgets/combox.hpp | 7 +- include/nana/gui/widgets/listbox.hpp | 2 +- include/nana/gui/widgets/progress.hpp | 2 +- include/nana/gui/widgets/scroll.hpp | 4 +- include/nana/gui/widgets/spinbox.hpp | 9 +- source/basic_types.cpp | 3 +- source/detail/linux_X11/platform_spec.cpp | 14 +- source/detail/win32/platform_spec.cpp | 3 +- source/gui/detail/linux_X11/bedrock.cpp | 8 +- source/gui/detail/win32/bedrock.cpp | 2 +- source/gui/detail/window_manager.cpp | 2 +- source/gui/element.cpp | 4 +- source/gui/msgbox.cpp | 39 ++-- source/gui/screen.cpp | 7 +- source/gui/widgets/combox.cpp | 5 +- source/gui/widgets/listbox.cpp | 2 +- source/gui/widgets/slider.cpp | 2 +- source/gui/widgets/spinbox.cpp | 9 +- source/gui/widgets/textbox.cpp | 2 +- source/gui/widgets/toolbar.cpp | 2 +- source/gui/widgets/treebox.cpp | 177 +++++++++--------- .../paint/detail/native_paint_interface.cpp | 2 +- source/paint/graphics.cpp | 33 ++-- 27 files changed, 180 insertions(+), 176 deletions(-) diff --git a/include/nana/basic_types.hpp b/include/nana/basic_types.hpp index c0765ae5..3fb77594 100644 --- a/include/nana/basic_types.hpp +++ b/include/nana/basic_types.hpp @@ -1,7 +1,7 @@ /* * Basic Types 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 diff --git a/include/nana/gui/detail/drawer.hpp b/include/nana/gui/detail/drawer.hpp index dd0c4192..f6948a45 100644 --- a/include/nana/gui/detail/drawer.hpp +++ b/include/nana/gui/detail/drawer.hpp @@ -1,7 +1,7 @@ /* * A Drawer 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 @@ -139,7 +139,11 @@ namespace nana { realizer_->_m_reset_overrided(); (realizer_->*mfptr)(graphics, arg); - mth_state_[pos] = (realizer_->_m_overrided() ? method_state::overrided : method_state::not_overrided); + + //Check realizer, when the window is closed in that event handler, the drawer will be + //detached and realizer will be a nullptr + if(realizer_) + mth_state_[pos] = (realizer_->_m_overrided() ? method_state::overrided : method_state::not_overrided); } else (realizer_->*mfptr)(graphics, arg); diff --git a/include/nana/gui/programming_interface.hpp b/include/nana/gui/programming_interface.hpp index adec058c..b65a15fc 100644 --- a/include/nana/gui/programming_interface.hpp +++ b/include/nana/gui/programming_interface.hpp @@ -180,7 +180,7 @@ namespace API using scheme_type = typename ::nana::dev::widget_traits::scheme_type; internal_scope_guard lock; - auto * wdg_colors = ::nana::dev::get_scheme(wd); + auto * wdg_colors = dev::get_scheme(wd); if (nullptr == wdg_colors) throw std::invalid_argument("API::scheme(): bad parameter window handle, no events object or invalid window handle."); diff --git a/include/nana/gui/screen.hpp b/include/nana/gui/screen.hpp index 679c5501..ef2aaac1 100644 --- a/include/nana/gui/screen.hpp +++ b/include/nana/gui/screen.hpp @@ -25,7 +25,7 @@ namespace nana virtual ~display() = default; /// The index of monitor. - virtual std::size_t index() const = 0; + virtual std::size_t get_index() const = 0; /// Returns the positional coordinates and size of the display device in reference to the desktop area virtual const ::nana::rectangle& area() const = 0; @@ -49,4 +49,4 @@ namespace nana }; }//end namespace nana -#endif \ No newline at end of file +#endif diff --git a/include/nana/gui/widgets/combox.hpp b/include/nana/gui/widgets/combox.hpp index c3cbc921..5a1f7e84 100644 --- a/include/nana/gui/widgets/combox.hpp +++ b/include/nana/gui/widgets/combox.hpp @@ -22,16 +22,13 @@ namespace nana { /// A list box combined with a textbox - the list box should drop down when the user selects the arrow next to the control - class combox; + class combox; struct arg_combox : public event_arg { combox & widget; - - arg_combox(combox& wdg) - : widget{ wdg } - {} + arg_combox(combox&); }; namespace drawerbase diff --git a/include/nana/gui/widgets/listbox.hpp b/include/nana/gui/widgets/listbox.hpp index 46decad1..8274d3e3 100644 --- a/include/nana/gui/widgets/listbox.hpp +++ b/include/nana/gui/widgets/listbox.hpp @@ -421,7 +421,7 @@ namespace nana mutable drawerbase::listbox::item_proxy item; bool selected; - arg_listbox(drawerbase::listbox::item_proxy&, bool selected); + arg_listbox(const drawerbase::listbox::item_proxy&, bool selected); }; namespace drawerbase diff --git a/include/nana/gui/widgets/progress.hpp b/include/nana/gui/widgets/progress.hpp index 083523b2..352069df 100644 --- a/include/nana/gui/widgets/progress.hpp +++ b/include/nana/gui/widgets/progress.hpp @@ -44,7 +44,7 @@ namespace nana widget * widget_{nullptr}; nana::paint::graphics* graph_{nullptr}; unsigned draw_width_{static_cast(-1)}; - bool has_value_{true}; + //bool has_value_{true}; //deprecated bool unknown_{false}; unsigned max_{100}; unsigned value_{0}; diff --git a/include/nana/gui/widgets/scroll.hpp b/include/nana/gui/widgets/scroll.hpp index 7c09b74b..4b165313 100644 --- a/include/nana/gui/widgets/scroll.hpp +++ b/include/nana/gui/widgets/scroll.hpp @@ -27,7 +27,7 @@ namespace nana scroll & widget; arg_scroll(scroll & wdg) - : widget{ wdg } + : widget(wdg) {} }; @@ -312,7 +312,7 @@ namespace nana private: void _m_emit_value_changed() { - widget_->events().value_changed.emit(::nana::arg_scroll({*widget_})); + widget_->events().value_changed.emit(::nana::arg_scroll(*widget_)); } void _m_tick() diff --git a/include/nana/gui/widgets/spinbox.hpp b/include/nana/gui/widgets/spinbox.hpp index f0deb3f6..f752c880 100644 --- a/include/nana/gui/widgets/spinbox.hpp +++ b/include/nana/gui/widgets/spinbox.hpp @@ -7,7 +7,7 @@ * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/widgets/spanbox.hpp + * @file: nana/gui/widgets/spinbox.hpp */ #ifndef NANA_GUI_WIDGET_SPINBOX_HPP @@ -23,10 +23,7 @@ namespace nana : public event_arg { spinbox & widget; - - arg_spinbox(spinbox& wdg) - : widget{ wdg } - {} + arg_spinbox(spinbox&); }; namespace drawerbase @@ -137,4 +134,4 @@ namespace nana } }//end namespace nana -#endif //NANA_GUI_WIDGET_SPINBOX_HPP \ No newline at end of file +#endif //NANA_GUI_WIDGET_SPINBOX_HPP diff --git a/source/basic_types.cpp b/source/basic_types.cpp index fe4aa215..dcafa12f 100644 --- a/source/basic_types.cpp +++ b/source/basic_types.cpp @@ -1,6 +1,7 @@ /* * Basic Types definition - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Nana C++ Library(http://www.nanapro.org) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index 69f518ac..103ce221 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -376,9 +376,9 @@ namespace detail switch(spec.screen_depth()) { case 16: - rgb = ((((color >> 16) & 0xFF) * 31 / 255) << 11) | - ((((color >> 8) & 0xFF) * 63 / 255) << 5) | - (color & 0xFF) * 31 / 255; + rgb = ((((rgb >> 16) & 0xFF) * 31 / 255) << 11) | + ((((rgb >> 8) & 0xFF) * 63 / 255) << 5) | + (rgb & 0xFF) * 31 / 255; break; } ::XSetForeground(spec.open_display(), context, rgb); @@ -795,9 +795,9 @@ namespace detail } addr->visible = false; - addr->graph.make(caret_sz.width, caret_sz.height); - addr->graph.rectangle(0x0, true); - addr->rev_graph.make(caret_sz.width, caret_sz.height); + addr->graph.make(caret_sz); + addr->graph.rectangle(true, colors::black); + addr->rev_graph.make(caret_sz); addr->size = caret_sz; @@ -1128,7 +1128,7 @@ namespace detail const nana::paint::graphics& platform_spec::keep_window_icon(native_window_type wd, const nana::paint::image& img) { nana::paint::graphics & graph = iconbase_[wd]; - graph.make(img.size().width, img.size().height); + graph.make(img.size()); img.paste(graph, 0, 0); return graph; } diff --git a/source/detail/win32/platform_spec.cpp b/source/detail/win32/platform_spec.cpp index f5b94840..aff569d2 100644 --- a/source/detail/win32/platform_spec.cpp +++ b/source/detail/win32/platform_spec.cpp @@ -1,6 +1,7 @@ /* * Platform Specification Implementation - * Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) + * Nana C++ Library(http://www.nanapro.org) + * Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com) * * Distributed under the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or copy at diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 96008bbc..d6546f08 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -1,7 +1,7 @@ /* * A Bedrock 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 @@ -377,6 +377,12 @@ namespace detail return impl_->estore; } + void bedrock::map_through_widgets(core_window_t* wd, native_drawable_type drawable) + { + //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) diff --git a/source/gui/detail/win32/bedrock.cpp b/source/gui/detail/win32/bedrock.cpp index ef954c57..36c50e69 100644 --- a/source/gui/detail/win32/bedrock.cpp +++ b/source/gui/detail/win32/bedrock.cpp @@ -1008,7 +1008,7 @@ namespace detail arg.evt_code = event_code::mouse_up; emit_drawer(&drawer::mouse_up, msgwnd, arg, &context); - auto evt_ptr = msgwnd->together.events_ptr; + //auto evt_ptr = msgwnd->together.events_ptr; //deprecated if (fire_click) { diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index 6faf9bfb..27806ee4 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -679,7 +679,7 @@ namespace detail { //Copy the root buffer that wd specified into DeviceContext #if defined(NANA_LINUX) - wd->drawer.map(reinterpret_cast(wd)); + wd->drawer.map(reinterpret_cast(wd), forced); #elif defined(NANA_WINDOWS) if(nana::system::this_thread_id() == wd->thread_id) wd->drawer.map(reinterpret_cast(wd), forced); diff --git a/source/gui/element.cpp b/source/gui/element.cpp index b8e83508..71d70f8b 100644 --- a/source/gui/element.cpp +++ b/source/gui/element.cpp @@ -1,7 +1,7 @@ /* * Elements of GUI Gadgets * 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 @@ -411,7 +411,7 @@ namespace nana pixels -= 2; } } - break; + default:break; } return true; } diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index de3aff59..e74a0b33 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -34,17 +34,17 @@ namespace nana : public form { public: - msgbox_window(window wd, const nana::string& title, msgbox::button_t btn, msgbox::icon_t ico) - : form(wd, nana::rectangle(1, 1, 1, 1), appear::decorate<>()), + msgbox_window(window wd, const ::nana::string& title, msgbox::button_t btn, msgbox::icon_t ico) + : form(wd, rectangle(1, 1, 1, 1), appear::decorate<>()), owner_(wd), pick_(msgbox::pick_yes) { this->caption(title); drawing dw(*this); - dw.draw([this](::nana::paint::graphics& graph) + dw.draw([this](paint::graphics& graph) { - graph.rectangle(nana::rectangle{0, 0, graph.width(), graph.height() - 50}, 0xFFFFFF, true); + graph.rectangle(rectangle{0, 0, graph.width(), graph.height() - 50}, true, colors::white); if(ico_.empty() == false) - ico_.stretch(ico_.size(), graph, ::nana::rectangle{12, 25, 32, 32}); + ico_.stretch(ico_.size(), graph, rectangle{12, 25, 32, 32}); }); unsigned width_pixel = 45; @@ -298,7 +298,7 @@ namespace nana { nana::paint::pixel_buffer pxbuf(32, 32); pxbuf.put(reinterpret_cast(rawpx), 32, 32, 32, 4*32, true); - ico_.make(32, 32); + ico_.make({32, 32}); pxbuf.paste(ico_.handle(), 0, 0); } } @@ -869,6 +869,8 @@ namespace nana window inputbox::date::create(window parent, unsigned label_px) { + auto today = ::nana::date().read(); + auto impl = impl_.get(); impl->dock.create(parent); @@ -887,7 +889,7 @@ namespace nana left += 104; impl->wdg_day.create(impl->dock, rectangle{ left, 0, 38, 0 }); - impl->wdg_day.range(1, 31, 1); + impl->wdg_day.range(1, ::nana::date::month_days(today.year, today.month), 1); impl->wdg_day.set_accept_integer(); left += 48; @@ -895,15 +897,14 @@ namespace nana impl->wdg_year.range(1601, 9999, 1); impl->wdg_year.set_accept_integer(); - auto date = ::nana::date().read(); - impl->wdg_month.option(date.month - 1); + impl->wdg_month.option(today.month - 1); std::wstringstream ss; - ss << date.day; + ss << today.day; impl->wdg_day.value(ss.str()); ss.str(L""); ss.clear(); - ss << date.year; + ss << today.year; impl->wdg_year.value(ss.str()); impl->dock.events().resized.connect_unignorable([impl, label_px](const ::nana::arg_resized& arg) @@ -935,21 +936,15 @@ namespace nana auto make_days = [impl] { - int days[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; auto month = impl->wdg_month.option() + 1; - - if (2 == month) - { - auto year = impl->wdg_year.to_int(); - if (((0 == year % 4) && (year % 100)) || (0 == (year % 400))) - days[1] = 29; - } + auto year = impl->wdg_year.to_int(); + int days = ::nana::date::month_days(year, month); auto day = impl->wdg_day.to_int(); - impl->wdg_day.range(1, days[month - 1], 1); //It resets the current value of wdg_day + impl->wdg_day.range(1, days, 1); //It resets the current value of wdg_day - if (day > days[month - 1]) - day = days[month - 1]; + if (day > days) + day = days; std::wstringstream ss; ss << day; diff --git a/source/gui/screen.cpp b/source/gui/screen.cpp index a7dca4c5..ef6c8fec 100644 --- a/source/gui/screen.cpp +++ b/source/gui/screen.cpp @@ -47,8 +47,7 @@ namespace nana #else if (0 == index_) { - position_.x = position_.y = 0; - size_ = detail::native_interface::primary_monitor_size(); + area_ = detail::native_interface::primary_monitor_size(); return; } #endif @@ -61,7 +60,7 @@ namespace nana } public: //Implementation of display - std::size_t index() const override + std::size_t get_index() const override { return index_; } @@ -72,7 +71,7 @@ namespace nana } private: const std::size_t index_; - ::nana::rectangle area_; + ::nana::rectangle area_; }; //class screen diff --git a/source/gui/widgets/combox.cpp b/source/gui/widgets/combox.cpp index c3c92cd9..c39c7a83 100644 --- a/source/gui/widgets/combox.cpp +++ b/source/gui/widgets/combox.cpp @@ -20,6 +20,9 @@ namespace nana { + arg_combox::arg_combox(combox& wdg): widget(wdg) + {} + namespace drawerbase { namespace combox @@ -29,7 +32,7 @@ namespace nana { public: event_agent(::nana::combox& wdg) - : widget_{wdg} + : widget_(wdg) {} void first_change() override{} //empty, because combox does not have this event. diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index 7a85c33d..6d9b2650 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -3663,7 +3663,7 @@ namespace nana } }//end namespace drawerbase - arg_listbox::arg_listbox(drawerbase::listbox::item_proxy& m, bool selected) + arg_listbox::arg_listbox(const drawerbase::listbox::item_proxy& m, bool selected) : item(m), selected(selected) { diff --git a/source/gui/widgets/slider.cpp b/source/gui/widgets/slider.cpp index a7700752..e0ca0442 100644 --- a/source/gui/widgets/slider.cpp +++ b/source/gui/widgets/slider.cpp @@ -4,7 +4,7 @@ namespace nana { arg_slider::arg_slider(slider& wdg) - : widget{ wdg } + : widget(wdg) {} namespace drawerbase diff --git a/source/gui/widgets/spinbox.cpp b/source/gui/widgets/spinbox.cpp index 648fec07..262765de 100644 --- a/source/gui/widgets/spinbox.cpp +++ b/source/gui/widgets/spinbox.cpp @@ -7,7 +7,7 @@ * (See accompanying file LICENSE_1_0.txt or copy at * http://www.boost.org/LICENSE_1_0.txt) * - * @file: nana/gui/widgets/spanbox.cpp + * @file: nana/gui/widgets/spinbox.cpp */ #include @@ -17,6 +17,9 @@ namespace nana { + arg_spinbox::arg_spinbox(spinbox& wdg): widget(wdg) + {} + namespace drawerbase { namespace spinbox @@ -26,7 +29,7 @@ namespace nana { public: event_agent(::nana::spinbox& wdg) - : widget_{ wdg } + : widget_(wdg) {} void first_change() override{} //empty, because spinbox does not have this event. @@ -685,4 +688,4 @@ namespace nana API::refresh_window(*this); } } -}//end namespace nana \ No newline at end of file +}//end namespace nana diff --git a/source/gui/widgets/textbox.cpp b/source/gui/widgets/textbox.cpp index cb4f9cf6..fc4a7d1b 100644 --- a/source/gui/widgets/textbox.cpp +++ b/source/gui/widgets/textbox.cpp @@ -18,7 +18,7 @@ namespace nana { arg_textbox::arg_textbox(textbox& wdg) - : widget{wdg} + : widget(wdg) {} namespace drawerbase { diff --git a/source/gui/widgets/toolbar.cpp b/source/gui/widgets/toolbar.cpp index 86baf33e..3936cfce 100644 --- a/source/gui/widgets/toolbar.cpp +++ b/source/gui/widgets/toolbar.cpp @@ -18,7 +18,7 @@ namespace nana { arg_toolbar::arg_toolbar(toolbar& tbar, std::size_t btn) - : widget{ tbar }, button{btn} + : widget(tbar), button{btn} {} namespace drawerbase diff --git a/source/gui/widgets/treebox.cpp b/source/gui/widgets/treebox.cpp index aad33dd3..a4e51a0b 100644 --- a/source/gui/widgets/treebox.cpp +++ b/source/gui/widgets/treebox.cpp @@ -19,7 +19,7 @@ namespace nana { arg_treebox::arg_treebox(treebox& wdg, drawerbase::treebox::item_proxy& m, bool op) - : widget{ wdg }, item{ m }, operated{op} + : widget(wdg), item(m), operated{op} {} namespace drawerbase @@ -74,7 +74,92 @@ namespace nana return nullptr; } - class tooltip_window; + class tlwnd_drawer + : public drawer_trigger, public compset_interface + { + public: + typedef drawer_trigger::graph_reference graph_reference; + + void assign(const item_attribute_t & item_attr, const pat::cloneable* renderer, const pat::cloneable * compset_placer) + { + if(renderer && compset_placer) + { + renderer_ = *renderer; + placer_ = *compset_placer; + + item_attr_ = item_attr; + + _m_draw(); + } + } + private: + void _m_draw() + { + item_r_.x = item_r_.y = 0; + item_r_.width = placer_->item_width(*this->graph_, item_attr_); + item_r_.height = placer_->item_height(*this->graph_); + + comp_attribute_t attr; + if(comp_attribute(component::text, attr)) + { + nana::paint::graphics item_graph({ item_r_.width, item_r_.height }); + item_graph.typeface(graph_->typeface()); + + renderer_->set_color(widget_->bgcolor(), widget_->fgcolor()); + renderer_->bground(item_graph, this); + renderer_->expander(item_graph, this); + renderer_->crook(item_graph, this); + renderer_->icon(item_graph, this); + renderer_->text(item_graph, this); + + item_graph.paste(attr.area, *graph_, 1, 1); + graph_->rectangle(false, colors::black); + } + } + private: + // Implementation of drawer_trigger + void attached(widget_reference wd, graph_reference graph) override + { + widget_ = &wd; + graph_ = &graph; + graph.typeface(widget_->typeface()); + } + private: + // Implementation of compset_interface + virtual const item_attribute_t& item_attribute() const override + { + return item_attr_; + } + + virtual bool comp_attribute(component_t comp, comp_attribute_t& comp_attr) const override + { + comp_attr.area = item_r_; + return placer_->locate(comp, item_attr_, &comp_attr.area); + } + private: + ::nana::paint::graphics * graph_; + ::nana::pat::cloneable renderer_; + ::nana::pat::cloneable placer_; + widget *widget_; + item_attribute_t item_attr_; + nana::rectangle item_r_; + };//end class tlwnd_drawer + + class tooltip_window + : public widget_object + { + public: + tooltip_window(window wd, const rectangle& r) + : widget_object(wd, false, rectangle(r).pare_off(-1), appear::bald()) + { + API::take_active(handle(), false, nullptr); + } + + drawer_trigger_t & impl() + { + return get_drawer_trigger(); + } + };//end class tooltip_window //item_locator should be defined before the definition of basic_implement class trigger::item_locator @@ -1368,94 +1453,6 @@ namespace nana //Treebox Implementation namespace treebox { - class tlwnd_drawer - : public drawer_trigger, public compset_interface - { - public: - typedef drawer_trigger::graph_reference graph_reference; - - void assign(const item_attribute_t & item_attr, const pat::cloneable* renderer, const pat::cloneable * compset_placer) - { - if(renderer && compset_placer) - { - renderer_ = *renderer; - placer_ = *compset_placer; - - item_attr_ = item_attr; - - _m_draw(); - } - } - private: - void _m_draw() - { - item_r_.x = item_r_.y = 0; - item_r_.width = placer_->item_width(*this->graph_, item_attr_); - item_r_.height = placer_->item_height(*this->graph_); - - comp_attribute_t attr; - if(comp_attribute(component::text, attr)) - { - nana::paint::graphics item_graph({ item_r_.width, item_r_.height }); - item_graph.typeface(graph_->typeface()); - - renderer_->set_color(widget_->bgcolor(), widget_->fgcolor()); - renderer_->bground(item_graph, this); - renderer_->expander(item_graph, this); - renderer_->crook(item_graph, this); - renderer_->icon(item_graph, this); - renderer_->text(item_graph, this); - - item_graph.paste(attr.area, *graph_, 1, 1); - graph_->rectangle(false, colors::black); - } - } - private: - // Implementation of drawer_trigger - void attached(widget_reference wd, graph_reference graph) override - { - widget_ = &wd; - graph_ = &graph; - graph.typeface(widget_->typeface()); - } - private: - // Implementation of compset_interface - virtual const item_attribute_t& item_attribute() const override - { - return item_attr_; - } - - virtual bool comp_attribute(component_t comp, comp_attribute_t& comp_attr) const override - { - comp_attr.area = item_r_; - return placer_->locate(comp, item_attr_, &comp_attr.area); - } - private: - ::nana::paint::graphics * graph_; - ::nana::pat::cloneable renderer_; - ::nana::pat::cloneable placer_; - widget *widget_; - item_attribute_t item_attr_; - nana::rectangle item_r_; - };//end class tlwnd_drawer - - class tooltip_window - : public widget_object - { - public: - tooltip_window(window wd, const rectangle& r) - : widget_object(wd, false, rectangle(r).pare_off(-1), appear::bald()) - { - API::take_active(handle(), false, nullptr); - } - - drawer_trigger_t & impl() - { - return get_drawer_trigger(); - } - };//end class tooltip_window - - //class trigger //struct treebox_node_type trigger::treebox_node_type::treebox_node_type() diff --git a/source/paint/detail/native_paint_interface.cpp b/source/paint/detail/native_paint_interface.cpp index d4e72106..7c96f7b6 100644 --- a/source/paint/detail/native_paint_interface.cpp +++ b/source/paint/detail/native_paint_interface.cpp @@ -191,7 +191,7 @@ namespace detail { (*glyphs++) = XftCharIndex(disp, fs, *chr); } - XftDrawGlyphs(dw->xftdraw, &(dw->xft_fgcolor), fs, x, y + fs->ascent, glyphs_ptr.get(), len); + XftDrawGlyphs(dw->xftdraw, &(dw->xft_fgcolor), fs, pos.x, pos.y + fs->ascent, glyphs_ptr.get(), len); #else XFontSet fs = reinterpret_cast(dw->font->handle); XFontSetExtents * ext = ::XExtentsOfFontSet(fs); diff --git a/source/paint/graphics.cpp b/source/paint/graphics.cpp index 4f558723..f8649ca5 100644 --- a/source/paint/graphics.cpp +++ b/source/paint/graphics.cpp @@ -1009,9 +1009,8 @@ namespace paint handle_->update_color(); ::XDrawLine(disp, handle_->pixmap, handle_->context, handle_->line_begin_pos.x, handle_->line_begin_pos.y, - x, y); - handle_->line_begin_pos.x = x; - handle_->line_begin_pos.y = y; + pos.x, pos.y); + handle_->line_begin_pos = pos; #endif if (changed_ == false) changed_ = true; } @@ -1064,18 +1063,18 @@ namespace paint line_to({ r.x, r.y }, left_clr); } - void graphics::gradual_rectangle(const ::nana::rectangle& r, const ::nana::color& from, const ::nana::color& to, bool vertical) + void graphics::gradual_rectangle(const ::nana::rectangle& rct, const ::nana::color& from, const ::nana::color& to, bool vertical) { #if defined(NANA_WINDOWS) if (pxbuf_.open(handle_)) { - pxbuf_.gradual_rectangle(r, from, to, 0.0, vertical); + pxbuf_.gradual_rectangle(rct, from, to, 0.0, vertical); pxbuf_.paste(handle_, 0, 0); } #elif defined(NANA_X11) if (nullptr == handle_) return; - double deltapx = double(vertical ? height : width); + double deltapx = double(vertical ? rct.height : rct.width); double r, g, b; const double delta_r = (to.r() - (r = from.r())) / deltapx; const double delta_g = (to.g() - (g = from.g())) / deltapx; @@ -1084,13 +1083,14 @@ namespace paint unsigned last_color = (int(r) << 16) | (int(g) << 8) | int(b); Display * disp = nana::detail::platform_spec::instance().open_display(); - handle_->fgcolor(last_color); - const int endpos = deltapx + (vertical ? y : x); + handle_->fgcolor(static_cast(last_color)); + const int endpos = deltapx + (vertical ? rct.y : rct.x); if (endpos > 0) { if (vertical) { - int x1 = x, x2 = x + static_cast(width); + int x1 = rct.x, x2 = rct.right(); + auto y = rct.y; for (; y < endpos; ++y) { ::XDrawLine(disp, handle_->pixmap, handle_->context, x1, y, x2, y); @@ -1098,13 +1098,14 @@ namespace paint if (new_color != last_color) { last_color = new_color; - handle_->fgcolor(last_color); + handle_->fgcolor(static_cast(last_color)); } } } else { - int y1 = y, y2 = y + static_cast(height); + int y1 = rct.y, y2 = rct.bottom(); + auto x = rct.x; for (; x < endpos; ++x) { ::XDrawLine(disp, handle_->pixmap, handle_->context, x, y1, x, y2); @@ -1112,7 +1113,7 @@ namespace paint if (new_color != last_color) { last_color = new_color; - handle_->fgcolor(last_color); + handle_->fgcolor(static_cast(last_color)); } } } @@ -1141,15 +1142,15 @@ namespace paint } if(changed_ == false) changed_ = true; #elif defined(NANA_X11) - if(solid && (color == solid_clr)) + if(solid && (clr == solid_clr)) { - rectangle(r, true, color); + rectangle(r, true, clr); } else { - rectangle(r, false, color); + rectangle(r, false, clr); if(solid) - rectangle(rectangle(r).pare_off(1), true, solid_clr); + rectangle(::nana::rectangle(r).pare_off(1), true, solid_clr); } #endif }