merge beru's changes
This commit is contained in:
@@ -172,6 +172,12 @@ namespace detail
|
|||||||
HMODULE ole32_;
|
HMODULE ole32_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct window_icons
|
||||||
|
{
|
||||||
|
::nana::paint::image sml_icon;
|
||||||
|
::nana::paint::image big_icon;
|
||||||
|
};
|
||||||
|
|
||||||
platform_spec();
|
platform_spec();
|
||||||
|
|
||||||
const font_ptr_t& default_native_font() const;
|
const font_ptr_t& default_native_font() const;
|
||||||
@@ -182,11 +188,11 @@ namespace detail
|
|||||||
|
|
||||||
static platform_spec& instance();
|
static platform_spec& instance();
|
||||||
|
|
||||||
void keep_window_icon(native_window_type, const nana::paint::image&);
|
void keep_window_icon(native_window_type, const paint::image&sml_icon, const paint::image& big_icon);
|
||||||
void release_window_icon(native_window_type);
|
void release_window_icon(native_window_type);
|
||||||
private:
|
private:
|
||||||
font_ptr_t def_font_ptr_;
|
font_ptr_t def_font_ptr_;
|
||||||
std::map<native_window_type, nana::paint::image> iconbase_;
|
std::map<native_window_type, window_icons> iconbase_;
|
||||||
};
|
};
|
||||||
|
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|||||||
@@ -44,7 +44,6 @@ namespace detail
|
|||||||
#endif
|
#endif
|
||||||
static void enable_dropfiles(native_window_type, bool);
|
static void enable_dropfiles(native_window_type, bool);
|
||||||
static void enable_window(native_window_type, bool);
|
static void enable_window(native_window_type, bool);
|
||||||
static bool window_icon(native_window_type, const paint::image&);
|
|
||||||
// (On Windows) The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.
|
// (On Windows) The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption.
|
||||||
static bool window_icon(native_window_type, const paint::image& big_icon, const paint::image& small_icon);
|
static bool window_icon(native_window_type, const paint::image& big_icon, const paint::image& small_icon);
|
||||||
static void activate_owner(native_window_type);
|
static void activate_owner(native_window_type);
|
||||||
|
|||||||
@@ -106,10 +106,8 @@ namespace detail
|
|||||||
//@brief: Delete window handle, the handle type must be a root and a frame.
|
//@brief: Delete window handle, the handle type must be a root and a frame.
|
||||||
void destroy_handle(core_window_t*);
|
void destroy_handle(core_window_t*);
|
||||||
|
|
||||||
void default_icon(const paint::image&);
|
void default_icon(const paint::image& small_icon, const paint::image& big_icon);
|
||||||
void default_icon(const paint::image& big_icon, const paint::image& small_icon);
|
void icon(core_window_t*, const paint::image& small_icon, const paint::image& big_icon);
|
||||||
void icon(core_window_t*, const paint::image&);
|
|
||||||
void icon(core_window_t*, const paint::image& big_icon, const paint::image& small_icon);
|
|
||||||
|
|
||||||
//show
|
//show
|
||||||
//@brief: show or hide a window
|
//@brief: show or hide a window
|
||||||
|
|||||||
@@ -112,10 +112,8 @@ namespace API
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_icon_default(const paint::image&);
|
void window_icon_default(const paint::image& small_icon, const paint::image& big_icon = {});
|
||||||
void window_icon_default(const paint::image& big_icon, const paint::image& small_icon);
|
void window_icon(window, const paint::image& small_icon, const paint::image& big_icon = {});
|
||||||
void window_icon(window, const paint::image&);
|
|
||||||
void window_icon(window, const paint::image& big_icon, const paint::image& small_icon);
|
|
||||||
|
|
||||||
bool empty_window(window); ///< Determines whether a window is existing.
|
bool empty_window(window); ///< Determines whether a window is existing.
|
||||||
bool is_window(window); ///< Determines whether a window is existing, equal to !empty_window.
|
bool is_window(window); ///< Determines whether a window is existing, equal to !empty_window.
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ namespace nana
|
|||||||
label& format(bool); ///< Switches the format mode of the widget.
|
label& format(bool); ///< Switches the format mode of the widget.
|
||||||
label& add_format_listener(std::function<void(command, const nana::string&)>);
|
label& add_format_listener(std::function<void(command, const nana::string&)>);
|
||||||
|
|
||||||
void relate(widget& w); // as same as the "for" attribute of a label
|
void click_for(window associated_window); // as same as the "for" attribute of a label
|
||||||
|
|
||||||
/// \briefReturn the size of the text. If *allowed_width_in_pixel* is not zero, returns a
|
/// \briefReturn the size of the text. If *allowed_width_in_pixel* is not zero, returns a
|
||||||
/// "corrected" size that changes lines to fit the text into the specified width
|
/// "corrected" size that changes lines to fit the text into the specified width
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ namespace nana{ namespace paint{
|
|||||||
typedef nana::paint::graphics& graph_reference;
|
typedef nana::paint::graphics& graph_reference;
|
||||||
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
|
virtual ~image_impl_interface() = 0; //The destructor is defined in ../image.cpp
|
||||||
virtual bool open(const nana::char_t* filename) = 0;
|
virtual bool open(const nana::char_t* filename) = 0;
|
||||||
virtual bool open(void* buff, size_t sz) = 0; // reads image from memory
|
virtual bool open(const void* data, std::size_t bytes) = 0; // reads image from memory
|
||||||
virtual bool alpha_channel() const = 0;
|
virtual bool alpha_channel() const = 0;
|
||||||
virtual bool empty() const = 0;
|
virtual bool empty() const = 0;
|
||||||
virtual void close() = 0;
|
virtual void close() = 0;
|
||||||
|
|||||||
@@ -37,7 +37,9 @@ namespace paint
|
|||||||
image& operator=(const image& rhs);
|
image& operator=(const image& rhs);
|
||||||
image& operator=(image&&);
|
image& operator=(image&&);
|
||||||
bool open(const nana::string& filename);
|
bool open(const nana::string& filename);
|
||||||
bool open_icon(void* buff, size_t sz); // opens a icon from memory
|
|
||||||
|
/// Opens an icon from a specified buffer
|
||||||
|
bool open_icon(const void* data, std::size_t bytes);
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
operator unspecified_bool_t() const;
|
operator unspecified_bool_t() const;
|
||||||
void close();
|
void close();
|
||||||
|
|||||||
@@ -273,9 +273,11 @@ namespace detail
|
|||||||
return object;
|
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)
|
void platform_spec::release_window_icon(native_window_type wd)
|
||||||
|
|||||||
@@ -509,20 +509,25 @@ namespace nana{
|
|||||||
#endif
|
#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)
|
#if defined(NANA_WINDOWS)
|
||||||
HICON ico = paint::image_accessor::icon(img);
|
HICON sml_handle = paint::image_accessor::icon(sml_icon);
|
||||||
if(ico)
|
HICON big_handle = paint::image_accessor::icon(big_icon);
|
||||||
|
if(sml_handle || big_handle)
|
||||||
{
|
{
|
||||||
nana::detail::platform_spec::instance().keep_window_icon(wd, img);
|
nana::detail::platform_spec::instance().keep_window_icon(wd, sml_icon, big_icon);
|
||||||
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(ico));
|
if (sml_handle)
|
||||||
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_SMALL, reinterpret_cast<WPARAM>(ico));
|
::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;
|
return true;
|
||||||
}
|
}
|
||||||
#elif defined(NANA_X11)
|
#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);
|
const nana::paint::graphics & graph = restrict::spec.keep_window_icon(wd, img);
|
||||||
XWMHints hints;
|
XWMHints hints;
|
||||||
@@ -537,7 +542,8 @@ namespace nana{
|
|||||||
return false;
|
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)
|
#if defined(NANA_WINDOWS)
|
||||||
HICON h_big_icon = paint::image_accessor::icon(big_icon);
|
HICON h_big_icon = paint::image_accessor::icon(big_icon);
|
||||||
@@ -558,6 +564,7 @@ namespace nana{
|
|||||||
#endif
|
#endif
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1413,7 +1413,6 @@ namespace detail
|
|||||||
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, is_forward);
|
auto tstop_wd = brock.wd_manager.tabstop(msgwnd, is_forward);
|
||||||
if (tstop_wd)
|
if (tstop_wd)
|
||||||
{
|
{
|
||||||
root_runtime->condition.tabstop_focus_changed = true;
|
|
||||||
brock.wd_manager.set_focus(tstop_wd, false);
|
brock.wd_manager.set_focus(tstop_wd, false);
|
||||||
brock.wd_manager.do_lazy_refresh(msgwnd, false);
|
brock.wd_manager.do_lazy_refresh(msgwnd, false);
|
||||||
brock.wd_manager.do_lazy_refresh(tstop_wd, true);
|
brock.wd_manager.do_lazy_refresh(tstop_wd, true);
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ namespace detail
|
|||||||
insert_frame(owner, wd);
|
insert_frame(owner, wd);
|
||||||
|
|
||||||
bedrock::inc_window(wd->thread_id);
|
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 wd;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@@ -390,32 +390,13 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_manager::default_icon(const paint::image& img)
|
void window_manager::default_icon(const nana::paint::image& small, const nana::paint::image& big)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
impl_->default_icon_big = big;
|
impl_->default_icon_big = big;
|
||||||
impl_->default_icon_small = small;
|
impl_->default_icon_small = small;
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_manager::icon(core_window_t* wd, const paint::image& img)
|
void window_manager::icon(core_window_t* wd, const paint::image& small_icon, const paint::image& big_icon)
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
{
|
||||||
if(!big_icon.empty() || !small_icon.empty())
|
if(!big_icon.empty() || !small_icon.empty())
|
||||||
{
|
{
|
||||||
@@ -423,7 +404,7 @@ namespace detail
|
|||||||
if (impl_->wd_register.available(wd))
|
if (impl_->wd_register.available(wd))
|
||||||
{
|
{
|
||||||
if(wd->other.category == category::root_tag::value)
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -354,24 +354,14 @@ namespace API
|
|||||||
return r;
|
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);
|
restrict::window_manager.icon(reinterpret_cast<restrict::core_window_t*>(wd), small_icon, big_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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty_window(window wd)
|
bool empty_window(window wd)
|
||||||
|
|||||||
@@ -628,7 +628,7 @@ namespace nana
|
|||||||
nana::string target; //It indicates which target is tracing.
|
nana::string target; //It indicates which target is tracing.
|
||||||
nana::string url;
|
nana::string url;
|
||||||
|
|
||||||
widget * buddy {nullptr};
|
window for_associated_wd{ nullptr };
|
||||||
|
|
||||||
void add_listener(std::function<void(command, const nana::string&)>&& fn)
|
void add_listener(std::function<void(command, const nana::string&)>&& fn)
|
||||||
{
|
{
|
||||||
@@ -743,9 +743,7 @@ namespace nana
|
|||||||
|
|
||||||
system::open_url(url);
|
system::open_url(url);
|
||||||
|
|
||||||
if (impl_->buddy) {
|
API::focus_window(impl_->for_associated_wd);
|
||||||
impl_->buddy->focus();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void trigger::refresh(graph_reference graph)
|
void trigger::refresh(graph_reference graph)
|
||||||
@@ -827,9 +825,9 @@ namespace nana
|
|||||||
return *this;
|
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
|
nana::size label::measure(unsigned limited) const
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ namespace nana{ namespace widgets
|
|||||||
|
|
||||||
virtual bool merge(const undoable_command_interface<EnumCommand>& rhs) override
|
virtual bool merge(const undoable_command_interface<EnumCommand>& rhs) override
|
||||||
{
|
{
|
||||||
//Implement later
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
protected:
|
protected:
|
||||||
@@ -1620,7 +1619,7 @@ namespace nana{ namespace widgets
|
|||||||
text_area_.captured = true;
|
text_area_.captured = true;
|
||||||
|
|
||||||
//Set caret pos by screen point and get the caret pos.
|
//Set caret pos by screen point and get the caret pos.
|
||||||
auto pos = mouse_caret(scrpos);
|
mouse_caret(scrpos);
|
||||||
if(!select(false))
|
if(!select(false))
|
||||||
{
|
{
|
||||||
select_.a = points_.caret; //Set begin caret
|
select_.a = points_.caret; //Set begin caret
|
||||||
@@ -2315,7 +2314,7 @@ namespace nana{ namespace widgets
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case keyboard::os_pageup:
|
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();
|
points_.offset.y -= screen_lines();
|
||||||
caret.y -= screen_lines();
|
caret.y -= screen_lines();
|
||||||
changed = true;
|
changed = true;
|
||||||
@@ -2967,7 +2966,7 @@ namespace nana{ namespace widgets
|
|||||||
if (if_mask && mask_char_)
|
if (if_mask && mask_char_)
|
||||||
mask_str.reset(new nana::string(str.size(), 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);
|
auto & linestr = (if_mask && mask_char_ ? *mask_str : str);
|
||||||
|
|
||||||
|
|||||||
@@ -94,14 +94,8 @@ namespace drawerbase {
|
|||||||
refresh(graph);
|
refresh(graph);
|
||||||
if (!editor_->attr().multi_lines && arg.getting)
|
if (!editor_->attr().multi_lines && arg.getting)
|
||||||
{
|
{
|
||||||
static auto& brock = detail::bedrock::instance();
|
editor_->select(true);
|
||||||
auto native_window = reinterpret_cast<native_window_type>(arg.receiver);
|
editor_->move_caret_end();
|
||||||
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_->show_caret(arg.getting);
|
editor_->show_caret(arg.getting);
|
||||||
editor_->reset_caret();
|
editor_->reset_caret();
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ namespace nana{ namespace paint
|
|||||||
this->close();
|
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
|
// TODO: read a BMP file from memory
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ namespace nana{ namespace paint
|
|||||||
|
|
||||||
|
|
||||||
bool open(const nana::char_t* filename) override;
|
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 alpha_channel() const override;
|
||||||
bool empty() const override;
|
bool empty() const override;
|
||||||
void close() override;
|
void close() override;
|
||||||
|
|||||||
@@ -70,11 +70,11 @@ namespace paint
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool image_ico::open(void* buff, size_t sz)
|
bool image_ico::open(const void* data, std::size_t bytes)
|
||||||
{
|
{
|
||||||
close();
|
close();
|
||||||
#if defined(NANA_WINDOWS)
|
#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)
|
if(handle)
|
||||||
{
|
{
|
||||||
ICONINFO info;
|
ICONINFO info;
|
||||||
@@ -261,11 +261,11 @@ namespace paint
|
|||||||
return false;
|
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::image_impl_interface * helper = new detail::image_ico(true);
|
||||||
image_ptr_ = std::shared_ptr<image_impl_interface>(helper);
|
image_ptr_ = std::shared_ptr<image_impl_interface>(helper);
|
||||||
return helper->open(buff, sz);
|
return helper->open(data, bytes);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool image::empty() const
|
bool image::empty() const
|
||||||
|
|||||||
Reference in New Issue
Block a user