From e449cd5a242f34e370a80dcc55ef83b33e63a77d Mon Sep 17 00:00:00 2001 From: Jinhao Date: Sun, 3 May 2015 16:59:22 +0800 Subject: [PATCH] fix a weird behavior of textbox(#52) and some other GCC compiling errors --- source/gui/detail/bedrock_pi.cpp | 1 + source/gui/detail/linux_X11/bedrock.cpp | 15 ++++++-- source/gui/detail/window_manager.cpp | 1 + source/gui/msgbox.cpp | 8 ++-- source/gui/place.cpp | 2 +- source/gui/widgets/listbox.cpp | 51 ++++++++++++------------- 6 files changed, 43 insertions(+), 35 deletions(-) diff --git a/source/gui/detail/bedrock_pi.cpp b/source/gui/detail/bedrock_pi.cpp index 76db85ac..7843fbaa 100644 --- a/source/gui/detail/bedrock_pi.cpp +++ b/source/gui/detail/bedrock_pi.cpp @@ -22,6 +22,7 @@ #include #include #include +#include namespace nana { diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index 2e40cc10..44ccef61 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -296,7 +296,7 @@ namespace detail break; case 2: //Restore if key released //restores the focus when menu is closed by pressing keyboard - if (!impl_->menu.window) + if ((!impl_->menu.window) && impl_->menu.delay_restore) set_menubar_taken(nullptr); break; case 3: //Restores if destroying @@ -948,10 +948,11 @@ namespace detail nana::detail::platform_spec::instance().write_keystate(xevent.xkey); if(msgwnd->flags.enabled) { - if (brock.get_menu()) + auto menu_wd = brock.get_menu(); + if (menu_wd) brock.delay_restore(0); //Enable delay restore - if(msgwnd->root != brock.get_menu()) + if(msgwnd->root != menu_wd) msgwnd = brock.focus(); if(msgwnd) @@ -1018,6 +1019,8 @@ namespace detail keychar = keyboard::os_insert; break; case XK_Delete: keychar = keyboard::os_del; break; + default: + keychar = keysym; } context.platform.keychar = keychar; if(keychar == keyboard::tab && (false == (msgwnd->flags.tab & detail::tab_type::eating))) //Tab @@ -1064,6 +1067,12 @@ namespace detail brock.get_key_state(arg); arg.window_handle = reinterpret_cast(msgwnd); brock.emit(event_code::key_press, msgwnd, arg, true, &context); + + if(msgwnd->root_widget->other.attribute.root->menubar == msgwnd) + { + int cmd = (menu_wd && (keyboard::escape == static_cast(arg.key)) ? 1 : 0 ); + brock.delay_restore(cmd); + } } if(XLookupKeySym == status) diff --git a/source/gui/detail/window_manager.cpp b/source/gui/detail/window_manager.cpp index e78da759..b7719985 100644 --- a/source/gui/detail/window_manager.cpp +++ b/source/gui/detail/window_manager.cpp @@ -21,6 +21,7 @@ #include #include #include +#include namespace nana { diff --git a/source/gui/msgbox.cpp b/source/gui/msgbox.cpp index e43a5ee7..97ba9018 100644 --- a/source/gui/msgbox.cpp +++ b/source/gui/msgbox.cpp @@ -699,7 +699,7 @@ namespace nana impl->label.format(true); //get the longest value - int longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin); + int longest = (std::abs(static_cast(impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(static_cast(impl->last < 0 ? impl->last * 10 : impl->last)) ? impl->last : impl->begin); paint::graphics graph{ ::nana::size{ 10, 10 } }; auto value_px = graph.text_extent_size(std::to_wstring(longest)).width + 34; @@ -777,7 +777,7 @@ namespace nana impl->label.format(true); //get the longest value - auto longest = (std::abs((impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(impl->last < 0 ? impl->last * 10 : impl->last) ? impl->last : impl->begin); + auto longest = (std::abs(static_cast(impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(static_cast(impl->last < 0 ? impl->last * 10 : impl->last)) ? impl->last : impl->begin); paint::graphics graph{ ::nana::size{ 10, 10 } }; auto value_px = graph.text_extent_size(std::to_wstring(longest)).width + 34; @@ -788,8 +788,8 @@ namespace nana impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg) { - impl->label.size({ label_px, 24 }); - impl->spinbox.size({ value_px, 24 }); + impl->label.size(::nana::size{ label_px, 24 }); + impl->spinbox.size(::nana::size{ value_px, 24 }); }); impl->spinbox.events().destroy.connect_unignorable([impl] diff --git a/source/gui/place.cpp b/source/gui/place.cpp index e7294ce9..bcac9556 100644 --- a/source/gui/place.cpp +++ b/source/gui/place.cpp @@ -602,7 +602,7 @@ namespace nana if (token::equal != read()) _m_throw_error("an equal sign is required after '" + idstr + "'"); - const char* p = _m_eat_whitespace(sp_); + sp_ = _m_eat_whitespace(sp_); reparray_.reset(); auto tk = read(); diff --git a/source/gui/widgets/listbox.cpp b/source/gui/widgets/listbox.cpp index d5253565..6d42c3c0 100644 --- a/source/gui/widgets/listbox.cpp +++ b/source/gui/widgets/listbox.cpp @@ -1688,16 +1688,13 @@ 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) - return display_pos.item ; + if(sorted_index_ == npos) + return display_pos.item ; - auto & catobj = *_m_at(display_pos.cat); + auto & catobj = *_m_at(display_pos.cat); - if(catobj.items.size()==0) - if (display_pos == index_pair{0,0} ) - return 0; - else - return npos; + if(catobj.items.size()==0) + return (display_pos == index_pair{0,0} ? 0 : npos); return catobj.sorted[display_pos.item] ; } @@ -2451,27 +2448,27 @@ namespace nana else break; } } - nana::string es_lister::to_string(const export_options& exp_opt) const - { - nana::string list_str; - bool first{true}; - for(auto & cat: cat_container()) - { - if(first) - first=false; - else - list_str += (cat.text + exp_opt.endl); - bool first_item{true}; - for (auto i : cat.sorted) - { - auto& it= cat.items[i] ; - if(it.flags.selected || !exp_opt.only_selected_items) - list_str += (it.to_string(exp_opt) + exp_opt.endl); - } + nana::string es_lister::to_string(const export_options& exp_opt) const + { + nana::string list_str; + bool first{true}; + for(auto & cat: cat_container()) + { + if(first) + first=false; + else + list_str += (cat.text + exp_opt.endl); + + for (auto i : cat.sorted) + { + auto& it= cat.items[i] ; + if(it.flags.selected || !exp_opt.only_selected_items) + list_str += (it.to_string(exp_opt) + exp_opt.endl); + } + } + return list_str ; } - return list_str ; - } class drawer_header_impl