merge beru's changes

This commit is contained in:
Jinhao
2015-08-02 03:33:43 +08:00
parent 66c1e1ad98
commit e0ee42d184
18 changed files with 59 additions and 86 deletions

View File

@@ -273,9 +273,11 @@ namespace detail
return object;
}
void platform_spec::keep_window_icon(native_window_type wd, const paint::image& img)
void platform_spec::keep_window_icon(native_window_type wd, const paint::image& sml_icon, const paint::image& big_icon)
{
iconbase_[wd] = img;
auto & icons = iconbase_[wd];
icons.sml_icon = sml_icon;
icons.big_icon = big_icon;
}
void platform_spec::release_window_icon(native_window_type wd)

View File

@@ -509,20 +509,25 @@ namespace nana{
#endif
}
bool native_interface::window_icon(native_window_type wd, const nana::paint::image& img)
bool native_interface::window_icon(native_window_type wd, const nana::paint::image& sml_icon, const ::nana::paint::image& big_icon)
{
#if defined(NANA_WINDOWS)
HICON ico = paint::image_accessor::icon(img);
if(ico)
HICON sml_handle = paint::image_accessor::icon(sml_icon);
HICON big_handle = paint::image_accessor::icon(big_icon);
if(sml_handle || big_handle)
{
nana::detail::platform_spec::instance().keep_window_icon(wd, img);
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(ico));
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_SMALL, reinterpret_cast<WPARAM>(ico));
nana::detail::platform_spec::instance().keep_window_icon(wd, sml_icon, big_icon);
if (sml_handle)
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_SMALL, reinterpret_cast<WPARAM>(sml_handle));
if (big_handle)
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(big_handle));
return true;
}
#elif defined(NANA_X11)
if(wd && (false == img.empty()))
if(wd && (!sml_icon.empty() || !big_icon.empty()))
{
auto & img = (sml_icon.empty() ? big_icon : sml_icon);
const nana::paint::graphics & graph = restrict::spec.keep_window_icon(wd, img);
XWMHints hints;
@@ -537,7 +542,8 @@ namespace nana{
return false;
}
bool native_interface::window_icon(native_window_type wd, const paint::image& big_icon, const paint::image& small_icon)
/*
bool native_interface::window_icon(native_window_type wd, const paint::image& big_icon, const paint::image& small_icon) //deprecated
{
#if defined(NANA_WINDOWS)
HICON h_big_icon = paint::image_accessor::icon(big_icon);
@@ -558,6 +564,7 @@ namespace nana{
#endif
return false;
}
*/

View File

@@ -1413,7 +1413,6 @@ namespace detail
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, is_forward);
if (tstop_wd)
{
root_runtime->condition.tabstop_focus_changed = 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);

View File

@@ -243,7 +243,7 @@ namespace detail
insert_frame(owner, wd);
bedrock::inc_window(wd->thread_id);
this->icon(wd, impl_->default_icon_big, impl_->default_icon_small);
this->icon(wd, impl_->default_icon_small, impl_->default_icon_big);
return wd;
}
return nullptr;
@@ -390,32 +390,13 @@ namespace detail
}
}
void window_manager::default_icon(const paint::image& img)
{
impl_->default_icon_big = img;
impl_->default_icon_small = img;
}
void window_manager::default_icon(const nana::paint::image& big, const nana::paint::image& small)
void window_manager::default_icon(const nana::paint::image& small, const nana::paint::image& big)
{
impl_->default_icon_big = big;
impl_->default_icon_small = small;
}
void window_manager::icon(core_window_t* wd, const paint::image& img)
{
if(false == img.empty())
{
std::lock_guard<decltype(mutex_)> lock(mutex_);
if (impl_->wd_register.available(wd))
{
if(wd->other.category == category::root_tag::value)
native_interface::window_icon(wd->root, img);
}
}
}
void window_manager::icon(core_window_t* wd, const paint::image& big_icon, const paint::image& small_icon)
void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon)
{
if(!big_icon.empty() || !small_icon.empty())
{
@@ -423,7 +404,7 @@ namespace detail
if (impl_->wd_register.available(wd))
{
if(wd->other.category == category::root_tag::value)
native_interface::window_icon(wd->root, big_icon, small_icon);
native_interface::window_icon(wd->root, small_icon, big_icon);
}
}
}

View File

@@ -354,24 +354,14 @@ namespace API
return r;
}
void window_icon_default(const paint::image& img)
void window_icon_default(const paint::image& small_icon, const paint::image& big_icon)
{
restrict::window_manager.default_icon(img);
restrict::window_manager.default_icon(small_icon, big_icon);
}
void window_icon_default(const paint::image& big_icon, const paint::image& small_icon)
void window_icon(window wd, const paint::image& small_icon, const paint::image& big_icon)
{
restrict::window_manager.default_icon(big_icon, small_icon);
}
void window_icon(window wd, const paint::image& img)
{
restrict::window_manager.icon(reinterpret_cast<restrict::core_window_t*>(wd), img);
}
void window_icon(window wd, const paint::image& big_icon, const paint::image& small_icon)
{
restrict::window_manager.icon(reinterpret_cast<restrict::core_window_t*>(wd), big_icon, small_icon);
restrict::window_manager.icon(reinterpret_cast<restrict::core_window_t*>(wd), small_icon, big_icon);
}
bool empty_window(window wd)

View File

@@ -628,7 +628,7 @@ namespace nana
nana::string target; //It indicates which target is tracing.
nana::string url;
widget * buddy {nullptr};
window for_associated_wd{ nullptr };
void add_listener(std::function<void(command, const nana::string&)>&& fn)
{
@@ -743,9 +743,7 @@ namespace nana
system::open_url(url);
if (impl_->buddy) {
impl_->buddy->focus();
}
API::focus_window(impl_->for_associated_wd);
}
void trigger::refresh(graph_reference graph)
@@ -827,9 +825,9 @@ namespace nana
return *this;
}
void label::relate(widget& w)
void label::click_for(window associated_window)
{
get_drawer_trigger().impl()->buddy = &w;
get_drawer_trigger().impl()->for_associated_wd = associated_window;
}
nana::size label::measure(unsigned limited) const

View File

@@ -55,7 +55,6 @@ namespace nana{ namespace widgets
virtual bool merge(const undoable_command_interface<EnumCommand>& rhs) override
{
//Implement later
return false;
}
protected:
@@ -1620,7 +1619,7 @@ namespace nana{ namespace widgets
text_area_.captured = true;
//Set caret pos by screen point and get the caret pos.
auto pos = mouse_caret(scrpos);
mouse_caret(scrpos);
if(!select(false))
{
select_.a = points_.caret; //Set begin caret
@@ -2315,7 +2314,7 @@ namespace nana{ namespace widgets
}
break;
case keyboard::os_pageup:
if (caret.y >= (int)screen_lines() && points_.offset.y >= (int)screen_lines()) {
if (caret.y >= screen_lines() && points_.offset.y >= static_cast<int>(screen_lines())) {
points_.offset.y -= screen_lines();
caret.y -= screen_lines();
changed = true;
@@ -2967,7 +2966,7 @@ namespace nana{ namespace widgets
if (if_mask && mask_char_)
mask_str.reset(new nana::string(str.size(), mask_char_));
bool focused = API::is_focus_ready(window_); // do this many times is not efficient...
bool focused = API::is_focus_ready(window_);
auto & linestr = (if_mask && mask_char_ ? *mask_str : str);

View File

@@ -94,14 +94,8 @@ namespace drawerbase {
refresh(graph);
if (!editor_->attr().multi_lines && arg.getting)
{
static auto& brock = detail::bedrock::instance();
auto native_window = reinterpret_cast<native_window_type>(arg.receiver);
auto* root_runtime = brock.wd_manager.root_runtime(native_window);
if (root_runtime && root_runtime->condition.tabstop_focus_changed)
{
editor_->select(true);
editor_->move_caret_end();
}
editor_->select(true);
editor_->move_caret_end();
}
editor_->show_caret(arg.getting);
editor_->reset_caret();

View File

@@ -75,7 +75,7 @@ namespace nana{ namespace paint
this->close();
}
bool open(const void* data, std::size_t bytes)
bool open(const void* data, std::size_t bytes) override
{
// TODO: read a BMP file from memory
return false;

View File

@@ -24,7 +24,7 @@ namespace nana{ namespace paint
bool open(const nana::char_t* filename) override;
bool open(const void* data, std::size_t bytes);
bool open(const void* data, std::size_t bytes) override;
bool alpha_channel() const override;
bool empty() const override;
void close() override;

View File

@@ -70,11 +70,11 @@ namespace paint
return false;
}
bool image_ico::open(void* buff, size_t sz)
bool image_ico::open(const void* data, std::size_t bytes)
{
close();
#if defined(NANA_WINDOWS)
HICON handle = CreateIconFromResource((PBYTE)buff, sz, TRUE, 0x00030000);
HICON handle = ::CreateIconFromResource((PBYTE)data, static_cast<DWORD>(bytes), TRUE, 0x00030000);
if(handle)
{
ICONINFO info;
@@ -261,11 +261,11 @@ namespace paint
return false;
}
bool image::open_icon(void* buff, size_t sz)
bool image::open_icon(const void* data, std::size_t bytes)
{
image::image_impl_interface * helper = new detail::image_ico(true);
image_ptr_ = std::shared_ptr<image_impl_interface>(helper);
return helper->open(buff, sz);
return helper->open(data, bytes);
}
bool image::empty() const