fix a weird behavior of textbox(#52)

and some other GCC compiling errors
This commit is contained in:
Jinhao 2015-05-03 16:59:22 +08:00
parent e03adc2a34
commit e449cd5a24
6 changed files with 43 additions and 35 deletions

View File

@ -22,6 +22,7 @@
#include <nana/gui/detail/native_window_interface.hpp>
#include <nana/gui/layout_utility.hpp>
#include <nana/gui/detail/element_store.hpp>
#include <algorithm>
namespace nana
{

View File

@ -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<window>(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<nana::char_t>(arg.key)) ? 1 : 0 );
brock.delay_restore(cmd);
}
}
if(XLookupKeySym == status)

View File

@ -21,6 +21,7 @@
#include <nana/gui/layout_utility.hpp>
#include <nana/gui/detail/effects_renderer.hpp>
#include <stdexcept>
#include <algorithm>
namespace nana
{

View File

@ -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<int>(impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(static_cast<int>(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<int>(impl->begin < 0 ? impl->begin * 10 : impl->begin)) < std::abs(static_cast<int>(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]

View File

@ -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();

View File

@ -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