update filesystem and remove fs_utility
This commit is contained in:
parent
8d2ec2fbd1
commit
ece696c3b5
@ -52,7 +52,6 @@
|
|||||||
<Unit filename="../../source/detail/platform_spec_posix.cpp" />
|
<Unit filename="../../source/detail/platform_spec_posix.cpp" />
|
||||||
<Unit filename="../../source/detail/platform_spec_windows.cpp" />
|
<Unit filename="../../source/detail/platform_spec_windows.cpp" />
|
||||||
<Unit filename="../../source/filesystem/filesystem.cpp" />
|
<Unit filename="../../source/filesystem/filesystem.cpp" />
|
||||||
<Unit filename="../../source/filesystem/fs_utility.cpp" />
|
|
||||||
<Unit filename="../../source/gui/animation.cpp" />
|
<Unit filename="../../source/gui/animation.cpp" />
|
||||||
<Unit filename="../../source/gui/basis.cpp" />
|
<Unit filename="../../source/gui/basis.cpp" />
|
||||||
<Unit filename="../../source/gui/detail/basic_window.cpp" />
|
<Unit filename="../../source/gui/detail/basic_window.cpp" />
|
||||||
|
|||||||
@ -745,8 +745,8 @@
|
|||||||
1447167067 source:d:\git.repo\nana\source\gui\detail\events_operation.cpp
|
1447167067 source:d:\git.repo\nana\source\gui\detail\events_operation.cpp
|
||||||
<nana/gui/detail/events_operation.hpp>
|
<nana/gui/detail/events_operation.hpp>
|
||||||
|
|
||||||
1444647213 source:d:\git.repo\nana\source\gui\detail\native_window_interface.cpp
|
1453137865 source:d:\git.repo\nana\source\gui\detail\native_window_interface.cpp
|
||||||
<nana/config.hpp>
|
<nana/detail/platform_spec_selector.hpp>
|
||||||
<nana/gui/detail/native_window_interface.hpp>
|
<nana/gui/detail/native_window_interface.hpp>
|
||||||
<nana/gui/screen.hpp>
|
<nana/gui/screen.hpp>
|
||||||
<nana/std_mutex.hpp>
|
<nana/std_mutex.hpp>
|
||||||
@ -755,9 +755,11 @@
|
|||||||
"../../paint/detail/image_ico.hpp"
|
"../../paint/detail/image_ico.hpp"
|
||||||
<nana/system/platform.hpp>
|
<nana/system/platform.hpp>
|
||||||
<nana/gui/detail/bedrock.hpp>
|
<nana/gui/detail/bedrock.hpp>
|
||||||
|
<nana/gui/detail/window_manager.hpp>
|
||||||
|
|
||||||
1452100459 d:\git.repo\nana\source\paint\detail\image_ico.hpp
|
1453189013 d:\git.repo\nana\source\paint\detail\image_ico.hpp
|
||||||
<nana/paint/detail/image_impl_interface.hpp>
|
<nana/paint/detail/image_impl_interface.hpp>
|
||||||
|
<nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
1451801884 source:d:\git.repo\nana\source\gui\detail\window_layout.cpp
|
1451801884 source:d:\git.repo\nana\source\gui\detail\window_layout.cpp
|
||||||
<nana/gui/detail/window_layout.hpp>
|
<nana/gui/detail/window_layout.hpp>
|
||||||
@ -802,10 +804,9 @@
|
|||||||
<nana/std_mutex.hpp>
|
<nana/std_mutex.hpp>
|
||||||
<mutex>
|
<mutex>
|
||||||
|
|
||||||
1453128893 source:d:\git.repo\nana\source\gui\filebox.cpp
|
1453222083 source:d:\git.repo\nana\source\gui\filebox.cpp
|
||||||
<nana/gui.hpp>
|
<nana/gui.hpp>
|
||||||
<nana/gui/filebox.hpp>
|
<nana/gui/filebox.hpp>
|
||||||
<nana/filesystem/fs_utility.hpp>
|
|
||||||
<nana/filesystem/filesystem.hpp>
|
<nana/filesystem/filesystem.hpp>
|
||||||
<windows.h>
|
<windows.h>
|
||||||
<nana/gui/widgets/label.hpp>
|
<nana/gui/widgets/label.hpp>
|
||||||
@ -909,7 +910,7 @@
|
|||||||
<nana/gui/widgets/detail/tree_cont.hpp>
|
<nana/gui/widgets/detail/tree_cont.hpp>
|
||||||
<stdexcept>
|
<stdexcept>
|
||||||
|
|
||||||
1452100459 source:d:\git.repo\nana\source\gui\widgets\checkbox.cpp
|
1453214888 source:d:\git.repo\nana\source\gui\widgets\checkbox.cpp
|
||||||
<nana/gui/widgets/checkbox.hpp>
|
<nana/gui/widgets/checkbox.hpp>
|
||||||
<nana/paint/text_renderer.hpp>
|
<nana/paint/text_renderer.hpp>
|
||||||
<nana/gui/element.hpp>
|
<nana/gui/element.hpp>
|
||||||
@ -1319,9 +1320,8 @@
|
|||||||
"../basic_types.hpp"
|
"../basic_types.hpp"
|
||||||
"../traits.hpp"
|
"../traits.hpp"
|
||||||
|
|
||||||
1453125056 d:\git.repo\nana\include\nana\paint\image.hpp
|
1453215024 d:\git.repo\nana\include\nana\paint\image.hpp
|
||||||
"graphics.hpp"
|
"graphics.hpp"
|
||||||
<nana/filesystem/filesystem.hpp>
|
|
||||||
|
|
||||||
1452100458 d:\git.repo\nana\include\nana\paint\graphics.hpp
|
1452100458 d:\git.repo\nana\include\nana\paint\graphics.hpp
|
||||||
"../basic_types.hpp"
|
"../basic_types.hpp"
|
||||||
@ -1333,7 +1333,7 @@
|
|||||||
<nana/gui/basis.hpp>
|
<nana/gui/basis.hpp>
|
||||||
<memory>
|
<memory>
|
||||||
|
|
||||||
1453129811 d:\git.repo\nana\include\nana\filesystem\filesystem.hpp
|
1453221913 d:\git.repo\nana\include\nana\filesystem\filesystem.hpp
|
||||||
<string>
|
<string>
|
||||||
<system_error>
|
<system_error>
|
||||||
<iterator>
|
<iterator>
|
||||||
@ -1391,7 +1391,7 @@
|
|||||||
"color_schemes.hpp"
|
"color_schemes.hpp"
|
||||||
"internal_scope_guard.hpp"
|
"internal_scope_guard.hpp"
|
||||||
|
|
||||||
1452100458 d:\git.repo\nana\include\nana\gui\detail\general_events.hpp
|
1453221339 d:\git.repo\nana\include\nana\gui\detail\general_events.hpp
|
||||||
<nana/gui/basis.hpp>
|
<nana/gui/basis.hpp>
|
||||||
"event_code.hpp"
|
"event_code.hpp"
|
||||||
"internal_scope_guard.hpp"
|
"internal_scope_guard.hpp"
|
||||||
@ -1615,7 +1615,7 @@
|
|||||||
<nana/gui/layout_utility.hpp>
|
<nana/gui/layout_utility.hpp>
|
||||||
<nana/gui/detail/window_layout.hpp>
|
<nana/gui/detail/window_layout.hpp>
|
||||||
|
|
||||||
1453130060 source:d:\git.repo\nana\source\filesystem\filesystem.cpp
|
1453221942 source:d:\git.repo\nana\source\filesystem\filesystem.cpp
|
||||||
<nana/filesystem/filesystem.hpp>
|
<nana/filesystem/filesystem.hpp>
|
||||||
<vector>
|
<vector>
|
||||||
<windows.h>
|
<windows.h>
|
||||||
@ -1753,7 +1753,7 @@
|
|||||||
1452100757 d:\git.repo\nana\include\nana\gui\tooltip.hpp
|
1452100757 d:\git.repo\nana\include\nana\gui\tooltip.hpp
|
||||||
"widgets/widget.hpp"
|
"widgets/widget.hpp"
|
||||||
|
|
||||||
1452100458 d:\git.repo\nana\include\nana\gui\widgets\checkbox.hpp
|
1453214821 d:\git.repo\nana\include\nana\gui\widgets\checkbox.hpp
|
||||||
"widget.hpp"
|
"widget.hpp"
|
||||||
<vector>
|
<vector>
|
||||||
<memory>
|
<memory>
|
||||||
@ -1843,8 +1843,9 @@
|
|||||||
1452100458 d:\git.repo\nana\include\nana\paint\detail\native_paint_interface.hpp
|
1452100458 d:\git.repo\nana\include\nana\paint\detail\native_paint_interface.hpp
|
||||||
<nana/basic_types.hpp>
|
<nana/basic_types.hpp>
|
||||||
|
|
||||||
1452100458 d:\git.repo\nana\include\nana\paint\detail\image_impl_interface.hpp
|
1453189097 d:\git.repo\nana\include\nana\paint\detail\image_impl_interface.hpp
|
||||||
"../image.hpp"
|
"../image.hpp"
|
||||||
|
<nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
1447167068 d:\git.repo\nana\source\paint\detail\image_jpeg.hpp
|
1447167068 d:\git.repo\nana\source\paint\detail\image_jpeg.hpp
|
||||||
"image_pixbuf.hpp"
|
"image_pixbuf.hpp"
|
||||||
|
|||||||
@ -189,7 +189,6 @@
|
|||||||
<ClCompile Include="..\..\source\deploy.cpp" />
|
<ClCompile Include="..\..\source\deploy.cpp" />
|
||||||
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
||||||
@ -274,7 +273,6 @@
|
|||||||
<ClInclude Include="..\..\include\nana\detail\linux_X11\platform_spec.hpp" />
|
<ClInclude Include="..\..\include\nana\detail\linux_X11\platform_spec.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\detail\win32\platform_spec.hpp" />
|
<ClInclude Include="..\..\include\nana\detail\win32\platform_spec.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp" />
|
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\fs_utility.hpp" />
|
|
||||||
<ClInclude Include="..\..\include\nana\fwd.hpp" />
|
<ClInclude Include="..\..\include\nana\fwd.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\gui.hpp" />
|
<ClInclude Include="..\..\include\nana\gui.hpp" />
|
||||||
<ClInclude Include="..\..\include\nana\gui\animation.hpp" />
|
<ClInclude Include="..\..\include\nana\gui\animation.hpp" />
|
||||||
|
|||||||
@ -111,9 +111,6 @@
|
|||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
||||||
<Filter>Source Files\nana\filesystem</Filter>
|
<Filter>Source Files\nana\filesystem</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp">
|
|
||||||
<Filter>Source Files\nana\filesystem</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
||||||
<Filter>Source Files\nana\gui\detail</Filter>
|
<Filter>Source Files\nana\gui\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
@ -613,9 +610,6 @@
|
|||||||
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp">
|
<ClInclude Include="..\..\include\nana\filesystem\filesystem.hpp">
|
||||||
<Filter>Header Files\filesystem</Filter>
|
<Filter>Header Files\filesystem</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
<ClInclude Include="..\..\include\nana\filesystem\fs_utility.hpp">
|
|
||||||
<Filter>Header Files\filesystem</Filter>
|
|
||||||
</ClInclude>
|
|
||||||
<ClInclude Include="..\..\include\nana\paint\gadget.hpp">
|
<ClInclude Include="..\..\include\nana\paint\gadget.hpp">
|
||||||
<Filter>Header Files\paint</Filter>
|
<Filter>Header Files\paint</Filter>
|
||||||
</ClInclude>
|
</ClInclude>
|
||||||
|
|||||||
@ -183,7 +183,6 @@
|
|||||||
<ClCompile Include="..\..\source\deploy.cpp" />
|
<ClCompile Include="..\..\source\deploy.cpp" />
|
||||||
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
<ClCompile Include="..\..\source\detail\platform_spec_windows.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp" />
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp" />
|
|
||||||
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
<ClCompile Include="..\..\source\gui\animation.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
<ClCompile Include="..\..\source\gui\basis.cpp" />
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp" />
|
||||||
|
|||||||
@ -87,9 +87,6 @@
|
|||||||
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
<ClCompile Include="..\..\source\filesystem\filesystem.cpp">
|
||||||
<Filter>Source Files\filesystem</Filter>
|
<Filter>Source Files\filesystem</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ClCompile Include="..\..\source\filesystem\fs_utility.cpp">
|
|
||||||
<Filter>Source Files\filesystem</Filter>
|
|
||||||
</ClCompile>
|
|
||||||
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
<ClCompile Include="..\..\source\gui\detail\basic_window.cpp">
|
||||||
<Filter>Source Files\gui\detail</Filter>
|
<Filter>Source Files\gui\detail</Filter>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
|
|||||||
@ -282,6 +282,7 @@ namespace filesystem
|
|||||||
|
|
||||||
|
|
||||||
file_status status(const path& p);
|
file_status status(const path& p);
|
||||||
|
file_status status(const path& p, std::error_code&);
|
||||||
|
|
||||||
std::uintmax_t file_size(const path& p);
|
std::uintmax_t file_size(const path& p);
|
||||||
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
//uintmax_t file_size(const path& p, error_code& ec) noexcept;
|
||||||
@ -315,7 +316,8 @@ namespace filesystem
|
|||||||
bool create_directory(const path& p, const path& attributes);
|
bool create_directory(const path& p, const path& attributes);
|
||||||
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
//bool create_directory(const path& p, const path& attributes, error_code& ec) noexcept;
|
||||||
|
|
||||||
bool modified_file_time(const std::wstring& file, struct tm&);
|
bool modified_file_time(const path& p, struct tm&);
|
||||||
|
|
||||||
path path_user();
|
path path_user();
|
||||||
|
|
||||||
path current_path();
|
path current_path();
|
||||||
@ -324,14 +326,13 @@ namespace filesystem
|
|||||||
//void current_path(const path& p, error_code& ec) noexcept;
|
//void current_path(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
|
|
||||||
//bool remove(const path& p);
|
bool remove(const path& p);
|
||||||
//bool remove(const path& p, error_code& ec) noexcept;
|
bool remove(const path& p, std::error_code& ec); // noexcept;
|
||||||
bool rmfile(const path& p);
|
|
||||||
|
|
||||||
//uintmax_t remove_all(const path& p);
|
//uintmax_t remove_all(const path& p);
|
||||||
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
//uintmax_t remove_all(const path& p, error_code& ec) noexcept;
|
||||||
|
|
||||||
bool rmdir(const path& p, bool fails_if_not_empty);
|
//bool rmdir(const path& p, bool fails_if_not_empty); //deprecated
|
||||||
|
|
||||||
template<typename CharType>
|
template<typename CharType>
|
||||||
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
|
std::basic_string<CharType> parent_path(const std::basic_string<CharType>& path)
|
||||||
|
|||||||
@ -1,35 +0,0 @@
|
|||||||
|
|
||||||
#ifndef NANA_FILESYSTEM_FS_UTILITY_HPP
|
|
||||||
#define NANA_FILESYSTEM_FS_UTILITY_HPP
|
|
||||||
|
|
||||||
#include <nana/deploy.hpp>
|
|
||||||
#include <ctime>
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
struct error
|
|
||||||
{
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
none = 0
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
struct attribute
|
|
||||||
{
|
|
||||||
long long bytes;
|
|
||||||
bool is_directory;
|
|
||||||
tm modified;
|
|
||||||
};
|
|
||||||
|
|
||||||
bool modified_file_time(const ::std::string& file, struct tm&);
|
|
||||||
|
|
||||||
std::string path_user();
|
|
||||||
|
|
||||||
bool rmfile(const char* file_utf8);
|
|
||||||
}//end namespace filesystem
|
|
||||||
}//end namespace nana
|
|
||||||
|
|
||||||
#endif
|
|
||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* Definition of General Events
|
* Definition of General Events
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -111,7 +111,7 @@ namespace nana
|
|||||||
evt_->deleted_flags_ = false;
|
evt_->deleted_flags_ = false;
|
||||||
for (auto i = evt_->dockers_->begin(); i != evt_->dockers_->end();)
|
for (auto i = evt_->dockers_->begin(); i != evt_->dockers_->end();)
|
||||||
{
|
{
|
||||||
if (i->get()->flag_deleted)
|
if (static_cast<docker*>(i->get())->flag_deleted)
|
||||||
i = evt_->dockers_->erase(i);
|
i = evt_->dockers_->erase(i);
|
||||||
else
|
else
|
||||||
++i;
|
++i;
|
||||||
@ -128,11 +128,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
|
||||||
|
|
||||||
using prototype = typename std::remove_reference<Function>::type;
|
using prototype = typename std::remove_reference<Function>::type;
|
||||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
||||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
auto evt = reinterpret_cast<event_handle>(dck.get());
|
||||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
dockers_->emplace(dockers_->begin(), std::move(dck));
|
||||||
detail::events_operation_register(evt);
|
detail::events_operation_register(evt);
|
||||||
return evt;
|
return evt;
|
||||||
@ -151,11 +151,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
|
||||||
|
|
||||||
using prototype = typename std::remove_reference<Function>::type;
|
using prototype = typename std::remove_reference<Function>::type;
|
||||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), false));
|
||||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
auto evt = reinterpret_cast<event_handle>(dck.get());
|
||||||
dockers_->emplace_back(std::move(dck));
|
dockers_->emplace_back(std::move(dck));
|
||||||
detail::events_operation_register(evt);
|
detail::events_operation_register(evt);
|
||||||
return evt;
|
return evt;
|
||||||
@ -174,11 +174,11 @@ namespace nana
|
|||||||
{
|
{
|
||||||
internal_scope_guard lock;
|
internal_scope_guard lock;
|
||||||
if (nullptr == dockers_)
|
if (nullptr == dockers_)
|
||||||
dockers_.reset(new std::vector<std::unique_ptr<docker>>);
|
dockers_.reset(new std::vector<std::unique_ptr<detail::docker_interface>>);
|
||||||
|
|
||||||
using prototype = typename std::remove_reference<Function>::type;
|
using prototype = typename std::remove_reference<Function>::type;
|
||||||
std::unique_ptr<docker> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
|
std::unique_ptr<detail::docker_interface> dck(new docker(this, factory<prototype, std::is_bind_expression<prototype>::value>::build(std::forward<Function>(fn)), true));
|
||||||
auto evt = reinterpret_cast<event_handle>(static_cast<detail::docker_interface*>(dck.get()));
|
auto evt = reinterpret_cast<event_handle>(dck.get());
|
||||||
if (in_front)
|
if (in_front)
|
||||||
dockers_->emplace(dockers_->begin(), std::move(dck));
|
dockers_->emplace(dockers_->begin(), std::move(dck));
|
||||||
else
|
else
|
||||||
@ -208,7 +208,7 @@ namespace nana
|
|||||||
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
|
//Traverses with position can avaid crash error which caused by a iterator which becomes invalid.
|
||||||
for (std::size_t pos = 0; pos < dockers_len; ++pos)
|
for (std::size_t pos = 0; pos < dockers_len; ++pos)
|
||||||
{
|
{
|
||||||
auto docker_ptr = dockers[pos].get();
|
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
||||||
if (docker_ptr->flag_deleted)
|
if (docker_ptr->flag_deleted)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -217,7 +217,7 @@ namespace nana
|
|||||||
{
|
{
|
||||||
for (++pos; pos < dockers_len; ++pos)
|
for (++pos; pos < dockers_len; ++pos)
|
||||||
{
|
{
|
||||||
auto docker_ptr = dockers[pos].get();
|
auto docker_ptr = static_cast<docker*>(dockers[pos].get());
|
||||||
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
if (!docker_ptr->unignorable || docker_ptr->flag_deleted)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
@ -247,7 +247,7 @@ namespace nana
|
|||||||
//Checks whether this event is working now.
|
//Checks whether this event is working now.
|
||||||
if (emitting_count_ > 1)
|
if (emitting_count_ > 1)
|
||||||
{
|
{
|
||||||
i->get()->flag_deleted = true;
|
static_cast<docker*>(i->get())->flag_deleted = true;
|
||||||
deleted_flags_ = true;
|
deleted_flags_ = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -416,7 +416,7 @@ namespace nana
|
|||||||
private:
|
private:
|
||||||
unsigned emitting_count_{ 0 };
|
unsigned emitting_count_{ 0 };
|
||||||
bool deleted_flags_{ false };
|
bool deleted_flags_{ false };
|
||||||
std::unique_ptr<std::vector<std::unique_ptr<docker>>> dockers_;
|
std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct arg_mouse
|
struct arg_mouse
|
||||||
@ -528,7 +528,7 @@ namespace nana
|
|||||||
/// provides some fundamental events that every widget owns.
|
/// provides some fundamental events that every widget owns.
|
||||||
struct general_events
|
struct general_events
|
||||||
{
|
{
|
||||||
virtual ~general_events(){}
|
virtual ~general_events() = default;
|
||||||
basic_event<arg_mouse> mouse_enter; ///< the cursor enters the window
|
basic_event<arg_mouse> mouse_enter; ///< the cursor enters the window
|
||||||
basic_event<arg_mouse> mouse_move; ///< the cursor moves on the window
|
basic_event<arg_mouse> mouse_move; ///< the cursor moves on the window
|
||||||
basic_event<arg_mouse> mouse_leave; ///< the cursor leaves the window
|
basic_event<arg_mouse> mouse_leave; ///< the cursor leaves the window
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/**
|
/**
|
||||||
* A CheckBox Implementation
|
* A CheckBox Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -17,10 +17,30 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
namespace nana {
|
namespace nana {
|
||||||
|
|
||||||
|
//forward-declaration
|
||||||
|
class checkbox;
|
||||||
|
|
||||||
|
struct arg_checkbox
|
||||||
|
: public event_arg
|
||||||
|
{
|
||||||
|
checkbox * const widget;
|
||||||
|
|
||||||
|
arg_checkbox(checkbox* wdg)
|
||||||
|
: widget(wdg)
|
||||||
|
{}
|
||||||
|
};
|
||||||
|
|
||||||
namespace drawerbase
|
namespace drawerbase
|
||||||
{
|
{
|
||||||
namespace checkbox
|
namespace checkbox
|
||||||
{
|
{
|
||||||
|
struct events_type
|
||||||
|
: public general_events
|
||||||
|
{
|
||||||
|
basic_event<arg_checkbox> checked;
|
||||||
|
};
|
||||||
|
|
||||||
class drawer
|
class drawer
|
||||||
: public drawer_trigger
|
: public drawer_trigger
|
||||||
{
|
{
|
||||||
@ -51,7 +71,7 @@ namespace drawerbase
|
|||||||
|
|
||||||
|
|
||||||
class checkbox
|
class checkbox
|
||||||
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer>
|
: public widget_object<category::widget_tag, drawerbase::checkbox::drawer, drawerbase::checkbox::events_type>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
checkbox();
|
checkbox();
|
||||||
@ -81,6 +101,7 @@ namespace drawerbase
|
|||||||
checkbox * uiobj;
|
checkbox * uiobj;
|
||||||
event_handle eh_checked;
|
event_handle eh_checked;
|
||||||
event_handle eh_destroy;
|
event_handle eh_destroy;
|
||||||
|
event_handle eh_keyboard;
|
||||||
};
|
};
|
||||||
public:
|
public:
|
||||||
~radio_group();
|
~radio_group();
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP
|
#define NANA_PAINT_DETAIL_IMAGE_IMPL_INTERFACE_HPP
|
||||||
|
|
||||||
#include "../image.hpp"
|
#include "../image.hpp"
|
||||||
|
#include <nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
namespace nana{ namespace paint{
|
namespace nana{ namespace paint{
|
||||||
|
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Paint Image Implementation
|
* Paint Image Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -16,8 +16,6 @@
|
|||||||
|
|
||||||
#include "graphics.hpp"
|
#include "graphics.hpp"
|
||||||
|
|
||||||
#include <nana/filesystem/filesystem.hpp>
|
|
||||||
|
|
||||||
namespace nana
|
namespace nana
|
||||||
{
|
{
|
||||||
namespace paint
|
namespace paint
|
||||||
@ -33,18 +31,14 @@ namespace paint
|
|||||||
image();
|
image();
|
||||||
image(const image&);
|
image(const image&);
|
||||||
image(image&&);
|
image(image&&);
|
||||||
image(const ::nana::experimental::filesystem::path& file);
|
explicit image(const ::std::string& file);
|
||||||
|
explicit image(const ::std::wstring& file);
|
||||||
template<typename Source>
|
|
||||||
image(const Source& source)
|
|
||||||
{
|
|
||||||
open(source);
|
|
||||||
}
|
|
||||||
|
|
||||||
~image();
|
~image();
|
||||||
image& operator=(const image& rhs);
|
image& operator=(const image& rhs);
|
||||||
image& operator=(image&&);
|
image& operator=(image&&);
|
||||||
bool open(const ::nana::experimental::filesystem::path& file);
|
bool open(const ::std::string& file);
|
||||||
|
bool open(const ::std::wstring& file);
|
||||||
|
|
||||||
/// Opens an icon from a specified buffer
|
/// Opens an icon from a specified buffer
|
||||||
bool open_icon(const void* data, std::size_t bytes);
|
bool open_icon(const void* data, std::size_t bytes);
|
||||||
|
|||||||
@ -518,8 +518,53 @@ namespace nana { namespace experimental {
|
|||||||
}
|
}
|
||||||
//end class directory_iterator
|
//end class directory_iterator
|
||||||
|
|
||||||
|
bool not_found_error(int errval)
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
switch (errval)
|
||||||
|
{
|
||||||
|
case ERROR_FILE_NOT_FOUND:
|
||||||
|
case ERROR_PATH_NOT_FOUND:
|
||||||
|
case ERROR_INVALID_NAME:
|
||||||
|
case ERROR_INVALID_DRIVE:
|
||||||
|
case ERROR_NOT_READY:
|
||||||
|
case ERROR_INVALID_PARAMETER:
|
||||||
|
case ERROR_BAD_PATHNAME:
|
||||||
|
case ERROR_BAD_NETPATH:
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
#elif defined(NANA_POSIX)
|
||||||
|
return (errval == ENOENT || errval == ENOTDIR);
|
||||||
|
#else
|
||||||
|
static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
|
bool rm_file(const path& p)
|
||||||
|
{
|
||||||
|
if (p.empty())
|
||||||
|
return false;
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
return (FALSE != ::DeleteFileW(p.c_str()));
|
||||||
|
#elif defined(NANA_POSIX)
|
||||||
|
return (!std::remove(p.c_str()));
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rm_dir(const path& p)
|
||||||
|
{
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
return (FALSE != ::RemoveDirectoryW(p.c_str())) || not_found_error(static_cast<int>(::GetLastError()));
|
||||||
|
#elif defined(NANA_POSIX)
|
||||||
|
return (!::rmdir(p.c_str())) || not_found_error(errno);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rm_dir(const path& p, bool fails_if_not_empty);
|
||||||
|
|
||||||
//rm_dir_recursive
|
//rm_dir_recursive
|
||||||
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
|
//@brief: remove a directory, if it is not empty, recursively remove it's subfiles and sub directories
|
||||||
template<typename CharT>
|
template<typename CharT>
|
||||||
@ -538,9 +583,34 @@ namespace nana { namespace experimental {
|
|||||||
if (is_directory(f))
|
if (is_directory(f))
|
||||||
rm_dir_recursive(subpath.c_str());
|
rm_dir_recursive(subpath.c_str());
|
||||||
else
|
else
|
||||||
rmfile(subpath.c_str());
|
rm_file(subpath.c_str());
|
||||||
}
|
}
|
||||||
return rmdir(dir, true);
|
return rm_dir(dir, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool rm_dir(const path& p, bool fails_if_not_empty)
|
||||||
|
{
|
||||||
|
if (p.empty())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
#if defined(NANA_WINDOWS)
|
||||||
|
if (FALSE != ::RemoveDirectoryW(p.c_str()))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (!fails_if_not_empty && (ERROR_DIR_NOT_EMPTY == ::GetLastError()))
|
||||||
|
return detail::rm_dir_recursive(p.c_str());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
#elif defined(NANA_POSIX)
|
||||||
|
if (::rmdir(p.c_str()))
|
||||||
|
{
|
||||||
|
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
||||||
|
return detail::rm_dir_recursive(p.c_str());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
@ -565,31 +635,21 @@ namespace nana { namespace experimental {
|
|||||||
#endif
|
#endif
|
||||||
}//end namespace detail
|
}//end namespace detail
|
||||||
|
|
||||||
bool not_found_error(int errval)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
switch (errval)
|
|
||||||
{
|
|
||||||
case ERROR_FILE_NOT_FOUND:
|
|
||||||
case ERROR_PATH_NOT_FOUND:
|
|
||||||
case ERROR_INVALID_NAME:
|
|
||||||
case ERROR_INVALID_DRIVE:
|
|
||||||
case ERROR_NOT_READY:
|
|
||||||
case ERROR_INVALID_PARAMETER:
|
|
||||||
case ERROR_BAD_PATHNAME:
|
|
||||||
case ERROR_BAD_NETPATH:
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
#elif defined(NANA_POSIX)
|
|
||||||
return (errval == ENOENT || errval == ENOTDIR);
|
|
||||||
#else
|
|
||||||
static_assert(false, "Only Windows and Unix are supported now (Mac OS is experimental)");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
file_status status(const path& p)
|
file_status status(const path& p)
|
||||||
{
|
{
|
||||||
|
std::error_code err;
|
||||||
|
auto stat = status(p, err);
|
||||||
|
|
||||||
|
if (err != std::error_code())
|
||||||
|
throw filesystem_error("nana::filesystem::status", p, err);
|
||||||
|
|
||||||
|
return stat;
|
||||||
|
}
|
||||||
|
|
||||||
|
file_status status(const path& p, std::error_code& ec)
|
||||||
|
{
|
||||||
|
ec = std::error_code();
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
auto attr = ::GetFileAttributesW(p.c_str());
|
auto attr = ::GetFileAttributesW(p.c_str());
|
||||||
if (INVALID_FILE_ATTRIBUTES == attr)
|
if (INVALID_FILE_ATTRIBUTES == attr)
|
||||||
@ -679,12 +739,11 @@ namespace nana { namespace experimental {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool modified_file_time(const path& p, struct tm& t)
|
||||||
bool modified_file_time(const std::wstring& file, struct tm& t)
|
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
WIN32_FILE_ATTRIBUTE_DATA attr;
|
||||||
if (::GetFileAttributesEx(file.c_str(), GetFileExInfoStandard, &attr))
|
if (::GetFileAttributesEx(p.c_str(), GetFileExInfoStandard, &attr))
|
||||||
{
|
{
|
||||||
FILETIME local_file_time;
|
FILETIME local_file_time;
|
||||||
if (::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
if (::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
||||||
@ -703,9 +762,9 @@ namespace nana { namespace experimental {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
#elif defined(NANA_POSIX)
|
||||||
struct stat attr;
|
struct stat attr;
|
||||||
if (0 == ::stat(static_cast<std::string>(nana::charset(file)).c_str(), &attr))
|
if (0 == ::stat(p.c_str(), &attr))
|
||||||
{
|
{
|
||||||
t = *(::localtime(&attr.st_ctime));
|
t = *(::localtime(&attr.st_ctime));
|
||||||
return true;
|
return true;
|
||||||
@ -724,46 +783,22 @@ namespace nana { namespace experimental {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
bool rmfile(const path& p)
|
bool remove(const path& p)
|
||||||
{
|
{
|
||||||
if(p.empty())
|
auto stat = status(p);
|
||||||
return false;
|
if (stat.type() == file_type::directory)
|
||||||
#if defined(NANA_WINDOWS)
|
return detail::rm_dir(p);
|
||||||
if (FALSE == ::DeleteFileW(p.c_str()))
|
|
||||||
return (ERROR_FILE_NOT_FOUND == ::GetLastError());
|
|
||||||
|
|
||||||
return true;
|
return detail::rm_file(p);
|
||||||
#elif defined(NANA_POSIX)
|
|
||||||
if (std::remove(p.c_str()))
|
|
||||||
return (errno == ENOENT);
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool remove(const path& p, std::error_code & ec)
|
||||||
bool rmdir(const path& p, bool fails_if_not_empty)
|
|
||||||
{
|
{
|
||||||
if(p.empty())
|
auto stat = status(p);
|
||||||
return false;
|
if (stat.type() == file_type::directory)
|
||||||
|
return detail::rm_dir(p);
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
return detail::rm_file(p);
|
||||||
if(FALSE != ::RemoveDirectoryW(p.c_str()))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
if(!fails_if_not_empty && (ERROR_DIR_NOT_EMPTY == ::GetLastError()))
|
|
||||||
return detail::rm_dir_recursive(p.c_str());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
#elif defined(NANA_POSIX)
|
|
||||||
if(::rmdir(p.c_str()))
|
|
||||||
{
|
|
||||||
if (!fails_if_not_empty && (errno == EEXIST || errno == ENOTEMPTY))
|
|
||||||
return detail::rm_dir_recursive(p.c_str());
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
path path_user()
|
path path_user()
|
||||||
|
|||||||
@ -1,145 +0,0 @@
|
|||||||
/*
|
|
||||||
* A FileSystem Utility Implementation
|
|
||||||
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
|
||||||
*
|
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
|
||||||
* http://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
*
|
|
||||||
* @file: nana/filesystem/fs_utility.cpp
|
|
||||||
* @description:
|
|
||||||
* provide some interface for file managment
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <nana/filesystem/fs_utility.hpp>
|
|
||||||
#include <nana/deploy.hpp>
|
|
||||||
#include <vector>
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
#include <windows.h>
|
|
||||||
|
|
||||||
#if defined(NANA_MINGW)
|
|
||||||
#ifndef _WIN32_IE
|
|
||||||
#define _WIN32_IE 0x0500
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <shlobj.h>
|
|
||||||
#include <nana/datetime.hpp>
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
#include <nana/charset.hpp>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <dirent.h>
|
|
||||||
#include <cstdio>
|
|
||||||
#include <cstring>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace nana
|
|
||||||
{
|
|
||||||
namespace filesystem
|
|
||||||
{
|
|
||||||
//Because of No wide character version of POSIX
|
|
||||||
#if defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
typedef std::string string_t;
|
|
||||||
const char* splstr = "/\\";
|
|
||||||
#else
|
|
||||||
typedef std::wstring string_t;
|
|
||||||
const wchar_t* splstr = L"/\\";
|
|
||||||
#endif
|
|
||||||
|
|
||||||
namespace detail
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
void filetime_to_c_tm(FILETIME& ft, struct tm& t)
|
|
||||||
{
|
|
||||||
FILETIME local_file_time;
|
|
||||||
if(::FileTimeToLocalFileTime(&ft, &local_file_time))
|
|
||||||
{
|
|
||||||
SYSTEMTIME st;
|
|
||||||
::FileTimeToSystemTime(&local_file_time, &st);
|
|
||||||
t.tm_year = st.wYear - 1900;
|
|
||||||
t.tm_mon = st.wMonth - 1;
|
|
||||||
t.tm_mday = st.wDay;
|
|
||||||
t.tm_wday = st.wDayOfWeek - 1;
|
|
||||||
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
|
|
||||||
|
|
||||||
t.tm_hour = st.wHour;
|
|
||||||
t.tm_min = st.wMinute;
|
|
||||||
t.tm_sec = st.wSecond;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}//end namespace detail
|
|
||||||
|
|
||||||
|
|
||||||
bool modified_file_time(const ::std::string& file, struct tm& t)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
WIN32_FILE_ATTRIBUTE_DATA attr;
|
|
||||||
if(::GetFileAttributesExW(to_nstring(file).c_str(), GetFileExInfoStandard, &attr))
|
|
||||||
{
|
|
||||||
FILETIME local_file_time;
|
|
||||||
if(::FileTimeToLocalFileTime(&attr.ftLastWriteTime, &local_file_time))
|
|
||||||
{
|
|
||||||
SYSTEMTIME st;
|
|
||||||
::FileTimeToSystemTime(&local_file_time, &st);
|
|
||||||
t.tm_year = st.wYear - 1900;
|
|
||||||
t.tm_mon = st.wMonth - 1;
|
|
||||||
t.tm_mday = st.wDay;
|
|
||||||
t.tm_wday = st.wDayOfWeek - 1;
|
|
||||||
t.tm_yday = nana::date::day_in_year(st.wYear, st.wMonth, st.wDay);
|
|
||||||
|
|
||||||
t.tm_hour = st.wHour;
|
|
||||||
t.tm_min = st.wMinute;
|
|
||||||
t.tm_sec = st.wSecond;
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
struct stat attr;
|
|
||||||
if(0 == ::stat(file.c_str(), &attr))
|
|
||||||
{
|
|
||||||
t = *(::localtime(&attr.st_ctime));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rmfile(const char* file)
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
bool ret = false;
|
|
||||||
if(file)
|
|
||||||
{
|
|
||||||
ret = (::DeleteFile(utf8_cast(file).c_str()) == TRUE);
|
|
||||||
if(!ret)
|
|
||||||
ret = (ERROR_FILE_NOT_FOUND == ::GetLastError());
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
if(std::remove(file))
|
|
||||||
return (errno == ENOENT);
|
|
||||||
return true;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string path_user()
|
|
||||||
{
|
|
||||||
#if defined(NANA_WINDOWS)
|
|
||||||
wchar_t path[MAX_PATH];
|
|
||||||
if(SUCCEEDED(SHGetFolderPath(0, CSIDL_PROFILE, 0, SHGFP_TYPE_CURRENT, path)))
|
|
||||||
return to_utf8(path);
|
|
||||||
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
|
|
||||||
const char * s = ::getenv("HOME");
|
|
||||||
if(s)
|
|
||||||
return s;
|
|
||||||
#endif
|
|
||||||
return std::string();
|
|
||||||
}
|
|
||||||
}//end namespace filesystem
|
|
||||||
}//end namespace nana
|
|
||||||
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
#include <nana/gui.hpp>
|
#include <nana/gui.hpp>
|
||||||
#include <nana/gui/filebox.hpp>
|
#include <nana/gui/filebox.hpp>
|
||||||
#include <nana/filesystem/fs_utility.hpp>
|
|
||||||
#include <nana/filesystem/filesystem.hpp>
|
#include <nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* A CheckBox Implementation
|
* A CheckBox Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -61,7 +61,11 @@ namespace checkbox
|
|||||||
void drawer::mouse_up(graph_reference graph, const arg_mouse&)
|
void drawer::mouse_up(graph_reference graph, const arg_mouse&)
|
||||||
{
|
{
|
||||||
if (impl_->react)
|
if (impl_->react)
|
||||||
|
{
|
||||||
impl_->crook.reverse();
|
impl_->crook.reverse();
|
||||||
|
arg_checkbox arg{ static_cast<nana::checkbox*>(widget_) };
|
||||||
|
API::events<nana::checkbox>(widget_->handle()).checked.emit(arg);
|
||||||
|
}
|
||||||
refresh(graph);
|
refresh(graph);
|
||||||
API::lazy_refresh();
|
API::lazy_refresh();
|
||||||
}
|
}
|
||||||
@ -164,9 +168,15 @@ namespace checkbox
|
|||||||
|
|
||||||
void checkbox::check(bool chk)
|
void checkbox::check(bool chk)
|
||||||
{
|
{
|
||||||
typedef drawerbase::checkbox::crook_state crook_state;
|
using crook_state = drawerbase::checkbox::crook_state;
|
||||||
|
if (checked() != chk)
|
||||||
|
{
|
||||||
get_drawer_trigger().impl()->crook.check(chk ? crook_state::checked : crook_state::unchecked);
|
get_drawer_trigger().impl()->crook.check(chk ? crook_state::checked : crook_state::unchecked);
|
||||||
API::refresh_window(handle());
|
API::refresh_window(handle());
|
||||||
|
|
||||||
|
arg_checkbox arg(this);
|
||||||
|
this->events().checked.emit(arg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void checkbox::radio(bool is_radio)
|
void checkbox::radio(bool is_radio)
|
||||||
@ -208,9 +218,22 @@ namespace checkbox
|
|||||||
uiobj.check(false);
|
uiobj.check(false);
|
||||||
uiobj.react(false);
|
uiobj.react(false);
|
||||||
|
|
||||||
element_tag el;
|
element_tag el = {};
|
||||||
|
|
||||||
el.uiobj = &uiobj;
|
el.uiobj = &uiobj;
|
||||||
|
|
||||||
|
uiobj.events().checked.connect_unignorable([this](const arg_checkbox& arg)
|
||||||
|
{
|
||||||
|
if (arg.widget->checked())
|
||||||
|
{
|
||||||
|
for (auto & ck : ui_container_)
|
||||||
|
{
|
||||||
|
if (ck.uiobj->handle() != arg.widget->handle())
|
||||||
|
ck.uiobj->check(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, true);
|
||||||
|
|
||||||
el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
|
el.eh_checked = uiobj.events().click.connect_unignorable([this](const arg_click& arg)
|
||||||
{
|
{
|
||||||
for (auto & i : ui_container_)
|
for (auto & i : ui_container_)
|
||||||
@ -229,6 +252,39 @@ namespace checkbox
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
el.eh_keyboard = uiobj.events().key_press.connect_unignorable([this](const arg_keyboard& arg)
|
||||||
|
{
|
||||||
|
auto window_handle = arg.window_handle;
|
||||||
|
|
||||||
|
auto i = std::find_if(ui_container_.begin(), ui_container_.end(), [window_handle](const element_tag& e){
|
||||||
|
return (e.uiobj->handle() == window_handle);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ui_container_.end() == i)
|
||||||
|
return;
|
||||||
|
|
||||||
|
checkbox * target;
|
||||||
|
|
||||||
|
if (keyboard::os_arrow_up == arg.key)
|
||||||
|
{
|
||||||
|
if (ui_container_.begin() != i)
|
||||||
|
target = (i - 1)->uiobj;
|
||||||
|
else
|
||||||
|
target = ui_container_.back().uiobj;
|
||||||
|
}
|
||||||
|
else if (keyboard::os_arrow_down == arg.key)
|
||||||
|
{
|
||||||
|
if (ui_container_.end() - 1 != i)
|
||||||
|
target = (i + 1)->uiobj;
|
||||||
|
else
|
||||||
|
target = ui_container_.front().uiobj;
|
||||||
|
}
|
||||||
|
|
||||||
|
target->check(true);
|
||||||
|
target->focus();
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
ui_container_.push_back(el);
|
ui_container_.push_back(el);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
#define NANA_PAINT_DETAIL_IMAGE_ICO_HPP
|
#define NANA_PAINT_DETAIL_IMAGE_ICO_HPP
|
||||||
|
|
||||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||||
|
#include <nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
namespace nana{ namespace paint
|
namespace nana{ namespace paint
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Paint Image Implementation
|
* Paint Image Implementation
|
||||||
* Nana C++ Library(http://www.nanapro.org)
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2015 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2016 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Boost Software License, Version 1.0.
|
* Distributed under the Boost Software License, Version 1.0.
|
||||||
* (See accompanying file LICENSE_1_0.txt or copy at
|
* (See accompanying file LICENSE_1_0.txt or copy at
|
||||||
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include <nana/paint/detail/image_impl_interface.hpp>
|
#include <nana/paint/detail/image_impl_interface.hpp>
|
||||||
#include <nana/paint/pixel_buffer.hpp>
|
#include <nana/paint/pixel_buffer.hpp>
|
||||||
|
#include <nana/filesystem/filesystem.hpp>
|
||||||
|
|
||||||
#if defined(NANA_ENABLE_JPEG)
|
#if defined(NANA_ENABLE_JPEG)
|
||||||
#include "detail/image_jpeg.hpp"
|
#include "detail/image_jpeg.hpp"
|
||||||
@ -173,7 +174,12 @@ namespace paint
|
|||||||
: image_ptr_(std::move(r.image_ptr_))
|
: image_ptr_(std::move(r.image_ptr_))
|
||||||
{}
|
{}
|
||||||
|
|
||||||
image::image(const ::nana::experimental::filesystem::path& file)
|
image::image(const std::string& file)
|
||||||
|
{
|
||||||
|
open(file);
|
||||||
|
}
|
||||||
|
|
||||||
|
image::image(const std::wstring& file)
|
||||||
{
|
{
|
||||||
open(file);
|
open(file);
|
||||||
}
|
}
|
||||||
@ -198,18 +204,15 @@ namespace paint
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool image::open(const ::nana::experimental::filesystem::path& file)
|
std::shared_ptr<image::image_impl_interface> create_image(const ::nana::experimental::filesystem::path & p)
|
||||||
{
|
{
|
||||||
image_ptr_.reset();
|
std::shared_ptr<image::image_impl_interface> ptr;
|
||||||
|
|
||||||
auto extension = file.extension().native();
|
auto ext = p.extension().native();
|
||||||
if (extension.empty())
|
if (ext.empty())
|
||||||
return false;
|
return ptr;
|
||||||
|
|
||||||
image::image_impl_interface * helper = nullptr;
|
std::transform(ext.begin(), ext.end(), ext.begin(), [](int ch)
|
||||||
|
|
||||||
{
|
|
||||||
std::transform(extension.begin(), extension.end(), extension.begin(), [](int ch)
|
|
||||||
{
|
{
|
||||||
if ('A' <= ch && ch <= 'Z')
|
if ('A' <= ch && ch <= 'Z')
|
||||||
ch -= ('A' - 'a');
|
ch -= ('A' - 'a');
|
||||||
@ -229,30 +232,30 @@ namespace paint
|
|||||||
#endif
|
#endif
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (ext_ico == extension)
|
if (ext_ico == ext)
|
||||||
{
|
{
|
||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
helper = new detail::image_ico(true);
|
ptr = std::make_shared<detail::image_ico>(true);
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext_png == extension)
|
if (ext_png == ext)
|
||||||
{
|
{
|
||||||
#if defined(NANA_ENABLE_PNG)
|
#if defined(NANA_ENABLE_PNG)
|
||||||
helper = new detail::image_png;
|
ptr = std::make_shared<detail::image_png>;
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ext_jpg == extension || ext_jpeg == extension)
|
if (ext_jpg == ext || ext_jpeg == ext)
|
||||||
{
|
{
|
||||||
#if defined(NANA_ENABLE_JPEG)
|
#if defined(NANA_ENABLE_JPEG)
|
||||||
helper = new detail::image_jpeg;
|
ptr = std::make_shared<detail::image_jpeg>();
|
||||||
#else
|
#else
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
@ -261,27 +264,39 @@ namespace paint
|
|||||||
} while (false);
|
} while (false);
|
||||||
|
|
||||||
//Check for BMP
|
//Check for BMP
|
||||||
if (!helper)
|
if (!ptr)
|
||||||
{
|
{
|
||||||
std::ifstream ifs(file.string(), std::ios::binary);
|
#ifndef NANA_MINGW
|
||||||
|
std::ifstream ifs(p.c_str(), std::ios::binary);
|
||||||
|
#else
|
||||||
|
std::ifstream ifs(to_osmbstr(to_utf8(p.native())).c_str(), std::ios::binary);
|
||||||
|
#endif
|
||||||
if (ifs)
|
if (ifs)
|
||||||
{
|
{
|
||||||
unsigned short meta = 0;
|
unsigned short meta = 0;
|
||||||
ifs.read(reinterpret_cast<char*>(&meta), 2);
|
ifs.read(reinterpret_cast<char*>(&meta), 2);
|
||||||
if (*reinterpret_cast<const short*>("BM") == meta)
|
if (*reinterpret_cast<const short*>("BM") == meta)
|
||||||
helper = new detail::image_bmp;
|
ptr = std::make_shared<detail::image_bmp>();
|
||||||
else if (*reinterpret_cast<const short*>("MZ") == meta)
|
else if (*reinterpret_cast<const short*>("MZ") == meta)
|
||||||
helper = new detail::image_ico(false);
|
ptr = std::make_shared<detail::image_ico>(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (helper)
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool image::open(const ::std::string& file)
|
||||||
{
|
{
|
||||||
image_ptr_ = std::shared_ptr<image_impl_interface>(helper);
|
::nana::experimental::filesystem::path path(file);
|
||||||
return helper->open(file.c_str());
|
image_ptr_ = create_image(path);
|
||||||
|
return (image_ptr_ ? image_ptr_->open(path) : false);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return false;
|
bool image::open(const std::wstring& file)
|
||||||
|
{
|
||||||
|
::nana::experimental::filesystem::path path(file);
|
||||||
|
image_ptr_ = create_image(path);
|
||||||
|
return (image_ptr_ ? image_ptr_->open(path) : false);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool image::open_icon(const void* data, std::size_t bytes)
|
bool image::open_icon(const void* data, std::size_t bytes)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user