add OFN_NOCHANGEDIR flag to OPENFILENAME::Flags in nana::filebox::show
http://blogs.msdn.com/b/oldnewthing/archive/2010/11/12/10089878.aspx setting OFN_NOCHANGEDIR flag to OPENFILENAME::Flags is effective for GetOpenFileName API on Windows7. add const qualifier to nana::paint::graphics::save_as_file add support for small icon on Windows. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption. https://msdn.microsoft.com/en-us/library/windows/desktop/ms632643%28v=vs.85%29.aspx
This commit is contained in:
parent
2da65827a0
commit
990de7867b
@ -45,6 +45,8 @@ namespace detail
|
|||||||
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&);
|
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.
|
||||||
|
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);
|
||||||
static void activate_window(native_window_type);
|
static void activate_window(native_window_type);
|
||||||
static void close_window(native_window_type);
|
static void close_window(native_window_type);
|
||||||
|
|||||||
@ -112,7 +112,6 @@ namespace detail
|
|||||||
void signal_fire_caption(core_window_t*, const nana::char_t*);
|
void signal_fire_caption(core_window_t*, const nana::char_t*);
|
||||||
nana::string signal_fire_caption(core_window_t*);
|
nana::string signal_fire_caption(core_window_t*);
|
||||||
void event_filter(core_window_t*, bool is_make, event_code);
|
void event_filter(core_window_t*, bool is_make, event_code);
|
||||||
void default_icon(const nana::paint::image&);
|
|
||||||
|
|
||||||
bool available(core_window_t*);
|
bool available(core_window_t*);
|
||||||
bool available(core_window_t *, core_window_t*);
|
bool available(core_window_t *, core_window_t*);
|
||||||
@ -133,7 +132,10 @@ 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& big_icon, const paint::image& small_icon);
|
||||||
void icon(core_window_t*, const paint::image&);
|
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
|
||||||
|
|||||||
@ -120,7 +120,10 @@ namespace API
|
|||||||
}
|
}
|
||||||
|
|
||||||
void window_icon_default(const paint::image&);
|
void window_icon_default(const paint::image&);
|
||||||
|
void window_icon_default(const paint::image& big_icon, const paint::image& small_icon);
|
||||||
void window_icon(window, const paint::image&);
|
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.
|
||||||
void enable_dropfiles(window, bool);
|
void enable_dropfiles(window, bool);
|
||||||
|
|||||||
@ -75,6 +75,12 @@ namespace nana{ namespace paint
|
|||||||
this->close();
|
this->close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool open(void* buff, size_t sz)
|
||||||
|
{
|
||||||
|
// TODO: read a BMP file from memory
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool open(const nana::char_t* filename)
|
bool open(const nana::char_t* filename)
|
||||||
{
|
{
|
||||||
if(nullptr == filename) return false;
|
if(nullptr == filename) return false;
|
||||||
|
|||||||
@ -23,6 +23,7 @@ namespace nana{ namespace paint
|
|||||||
image_ico(bool is_ico);
|
image_ico(bool is_ico);
|
||||||
|
|
||||||
bool open(const nana::char_t* filename);
|
bool open(const nana::char_t* filename);
|
||||||
|
bool open(void* buff, size_t sz);
|
||||||
bool alpha_channel() const;
|
bool alpha_channel() const;
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
void close();
|
void close();
|
||||||
|
|||||||
@ -16,6 +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 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;
|
||||||
|
|||||||
@ -130,7 +130,7 @@ namespace nana
|
|||||||
void setsta(); ///< Clears the status if the graphics object had been changed
|
void setsta(); ///< Clears the status if the graphics object had been changed
|
||||||
void set_changed();
|
void set_changed();
|
||||||
void release();
|
void release();
|
||||||
void save_as_file(const char*);
|
void save_as_file(const char*) const; // saves image as a bitmap file
|
||||||
|
|
||||||
void set_color(const ::nana::color&);
|
void set_color(const ::nana::color&);
|
||||||
void set_text_color(const ::nana::color&);
|
void set_text_color(const ::nana::color&);
|
||||||
|
|||||||
@ -37,6 +37,7 @@ 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
|
||||||
bool empty() const;
|
bool empty() const;
|
||||||
operator unspecified_bool_t() const;
|
operator unspecified_bool_t() const;
|
||||||
void close();
|
void close();
|
||||||
|
|||||||
@ -537,6 +537,30 @@ 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)
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
HICON h_big_icon = paint::image_accessor::icon(big_icon);
|
||||||
|
HICON h_small_icon = paint::image_accessor::icon(small_icon);
|
||||||
|
if (h_big_icon || h_small_icon)
|
||||||
|
{
|
||||||
|
nana::detail::platform_spec::instance().keep_window_icon(wd, (!big_icon.empty() ? big_icon : small_icon));
|
||||||
|
if (h_big_icon) {
|
||||||
|
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_BIG, reinterpret_cast<LPARAM>(h_big_icon));
|
||||||
|
}
|
||||||
|
if (h_small_icon) {
|
||||||
|
::SendMessage(reinterpret_cast<HWND>(wd), WM_SETICON, ICON_SMALL, reinterpret_cast<WPARAM>(h_small_icon));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
#elif defined(NANA_X11)
|
||||||
|
return window_icon(wd, big_icon);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void native_interface::activate_owner(native_window_type wd)
|
void native_interface::activate_owner(native_window_type wd)
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
|
|||||||
@ -43,7 +43,8 @@ namespace detail
|
|||||||
root_register misc_register;
|
root_register misc_register;
|
||||||
handle_manager<core_window_t*, window_manager, window_handle_deleter> wd_register;
|
handle_manager<core_window_t*, window_manager, window_handle_deleter> wd_register;
|
||||||
signal_manager signal;
|
signal_manager signal;
|
||||||
paint::image default_icon;
|
paint::image default_icon_big;
|
||||||
|
paint::image default_icon_small;
|
||||||
};
|
};
|
||||||
//end struct wdm_private_impl
|
//end struct wdm_private_impl
|
||||||
|
|
||||||
@ -199,11 +200,6 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void window_manager::default_icon(const paint::image& img)
|
|
||||||
{
|
|
||||||
impl_->default_icon = img;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool window_manager::available(core_window_t* wd)
|
bool window_manager::available(core_window_t* wd)
|
||||||
{
|
{
|
||||||
return impl_->wd_register.available(wd);
|
return impl_->wd_register.available(wd);
|
||||||
@ -264,7 +260,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);
|
this->icon(wd, impl_->default_icon_big, impl_->default_icon_small);
|
||||||
return wd;
|
return wd;
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -404,6 +400,18 @@ 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)
|
||||||
|
{
|
||||||
|
impl_->default_icon_big = big;
|
||||||
|
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& img)
|
||||||
{
|
{
|
||||||
if(false == img.empty())
|
if(false == img.empty())
|
||||||
@ -417,6 +425,19 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
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, big_icon, small_icon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//show
|
//show
|
||||||
//@brief: show or hide a window
|
//@brief: show or hide a window
|
||||||
bool window_manager::show(core_window_t* wd, bool visible)
|
bool window_manager::show(core_window_t* wd, bool visible)
|
||||||
|
|||||||
@ -1021,6 +1021,7 @@ namespace nana
|
|||||||
|
|
||||||
if (!impl_->open_or_save)
|
if (!impl_->open_or_save)
|
||||||
ofn.Flags = OFN_OVERWRITEPROMPT; //Overwrite prompt if it is save mode
|
ofn.Flags = OFN_OVERWRITEPROMPT; //Overwrite prompt if it is save mode
|
||||||
|
ofn.Flags |= OFN_NOCHANGEDIR;
|
||||||
|
|
||||||
if(FALSE == (impl_->open_or_save ? ::GetOpenFileName(&ofn) : ::GetSaveFileName(&ofn)))
|
if(FALSE == (impl_->open_or_save ? ::GetOpenFileName(&ofn) : ::GetSaveFileName(&ofn)))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@ -359,11 +359,21 @@ namespace API
|
|||||||
restrict::window_manager.default_icon(img);
|
restrict::window_manager.default_icon(img);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void window_icon_default(const paint::image& big_icon, const paint::image& small_icon)
|
||||||
|
{
|
||||||
|
restrict::window_manager.default_icon(big_icon, small_icon);
|
||||||
|
}
|
||||||
|
|
||||||
void window_icon(window wd, const paint::image& img)
|
void window_icon(window wd, const paint::image& img)
|
||||||
{
|
{
|
||||||
restrict::window_manager.icon(reinterpret_cast<restrict::core_window_t*>(wd), 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)
|
||||||
{
|
{
|
||||||
return (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)) == false);
|
return (restrict::window_manager.available(reinterpret_cast<restrict::core_window_t*>(wd)) == false);
|
||||||
|
|||||||
@ -812,7 +812,7 @@ namespace paint
|
|||||||
size_.width = size_.height = 0;
|
size_.width = size_.height = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void graphics::save_as_file(const char* file)
|
void graphics::save_as_file(const char* file) const
|
||||||
{
|
{
|
||||||
if(handle_)
|
if(handle_)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -69,6 +69,31 @@ namespace paint
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool image_ico::open(void* buff, size_t sz)
|
||||||
|
{
|
||||||
|
close();
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
HICON handle = CreateIconFromResource((PBYTE)buff, sz, TRUE, 0x00030000);
|
||||||
|
if(handle)
|
||||||
|
{
|
||||||
|
ICONINFO info;
|
||||||
|
if (::GetIconInfo(handle, &info) != 0)
|
||||||
|
{
|
||||||
|
HICON * p = new HICON(handle);
|
||||||
|
ptr_ = std::shared_ptr<HICON>(p, handle_deleter());
|
||||||
|
size_.width = (info.xHotspot << 1);
|
||||||
|
size_.height = (info.yHotspot << 1);
|
||||||
|
::DeleteObject(info.hbmColor);
|
||||||
|
::DeleteObject(info.hbmMask);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
if(is_ico_){} //kill the unused compiler warning in Linux.
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool image_ico::alpha_channel() const
|
bool image_ico::alpha_channel() const
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -235,6 +260,13 @@ namespace paint
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool image::open_icon(void* buff, size_t sz)
|
||||||
|
{
|
||||||
|
image::image_impl_interface * helper = new detail::image_ico(true);
|
||||||
|
image_ptr_ = std::shared_ptr<image_impl_interface>(helper);
|
||||||
|
return helper->open(buff, sz);
|
||||||
|
}
|
||||||
|
|
||||||
bool image::empty() const
|
bool image::empty() const
|
||||||
{
|
{
|
||||||
return ((nullptr == image_ptr_) || image_ptr_->empty());
|
return ((nullptr == image_ptr_) || image_ptr_->empty());
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user