update experimental::filesystem and remove file_iterator

This commit is contained in:
Jinhao
2016-01-19 01:34:07 +08:00
parent 13669f7591
commit 8d2ec2fbd1
22 changed files with 1255 additions and 788 deletions

View File

@@ -158,7 +158,7 @@ namespace nana{
{
#if defined(NANA_WINDOWS)
typedef HMONITOR (__stdcall * MonitorFromPointT)(POINT,DWORD);
MonitorFromPointT mfp = reinterpret_cast<MonitorFromPointT>(::GetProcAddress(::GetModuleHandleA("User32.DLL"), "MonitorFromPoint"));
if(mfp)
{
@@ -473,13 +473,13 @@ namespace nana{
auto & atombase = restrict::spec.atombase();
::XSetTransientForHint(disp, reinterpret_cast<Window>(wd), owner);
::XChangeProperty(disp, reinterpret_cast<Window>(wd),
atombase.net_wm_state, XA_ATOM, sizeof(int) * 8,
atombase.net_wm_state, XA_ATOM, sizeof(int) * 8,
PropModeReplace,
reinterpret_cast<const unsigned char*>(&atombase.net_wm_state_modal), 1);
}
}
#endif
void native_interface::enable_dropfiles(native_window_type wd, bool enb)
{
#if defined(NANA_WINDOWS)
@@ -505,7 +505,7 @@ namespace nana{
}
::XSelectInput(restrict::spec.open_display(), reinterpret_cast<Window>(wd), mask);
#endif
#endif
}
bool native_interface::window_icon(native_window_type wd, const nana::paint::image& sml_icon, const ::nana::paint::image& big_icon)
@@ -1117,9 +1117,9 @@ namespace nana{
native_string_type str;
//One for NULL terminator which GetWindowText will write.
str.resize(length+1);
::GetWindowText(reinterpret_cast<HWND>(wd), &(str[0]), static_cast<int>(str.size()));
//Remove the null terminator writtien by GetWindowText
str.resize(length);
@@ -1207,9 +1207,9 @@ namespace nana{
Window parent;
Window * children;
unsigned size;
platform_scope_guard lock;
if(0 != ::XQueryTree(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
&root, &parent, &children, &size))
{
@@ -1226,7 +1226,7 @@ namespace nana{
auto prev = ::SetParent(reinterpret_cast<HWND>(child), reinterpret_cast<HWND>(new_parent));
if (prev)
::PostMessage(prev, WM_CHANGEUISTATE, UIS_INITIALIZE, NULL);
::PostMessage(prev, /*WM_CHANGEUISTATE*/0x0127, /*UIS_INITIALIZE*/ 3, 0);
::SetWindowPos(reinterpret_cast<HWND>(child), NULL, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_FRAMECHANGED);
@@ -1239,7 +1239,7 @@ namespace nana{
if(returns_previous)
prev = parent_window(child);
::XReparentWindow(restrict::spec.open_display(),
::XReparentWindow(restrict::spec.open_display(),
reinterpret_cast<Window>(child), reinterpret_cast<Window>(new_parent),
0, 0);
return prev;

View File

@@ -1,7 +1,7 @@
/*
* Filebox
* 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.
* (See accompanying file LICENSE_1_0.txt or copy at
@@ -17,7 +17,7 @@
#if defined(NANA_WINDOWS)
#include <windows.h>
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
#elif defined(NANA_POSIX)
#include <nana/gui/widgets/label.hpp>
#include <nana/gui/widgets/button.hpp>
#include <nana/gui/widgets/listbox.hpp>
@@ -25,7 +25,7 @@
#include <nana/gui/widgets/textbox.hpp>
#include <nana/gui/widgets/treebox.hpp>
#include <nana/gui/widgets/combox.hpp>
#include <nana/filesystem/file_iterator.hpp>
#include <nana/filesystem/filesystem.hpp>
#include <nana/gui/place.hpp>
#include <stdexcept>
#include <algorithm>
@@ -33,7 +33,7 @@
namespace nana
{
#if defined(NANA_LINUX) || defined(NANA_MACOS)
#if defined(NANA_POSIX)
class filebox_implement
: public form
{
@@ -421,8 +421,6 @@ namespace nana
void _m_init_tree()
{
using namespace nana::filesystem;
//The path in linux is starting with the character '/', the name of root key should be
//"FS.HOME", "FS.ROOT". Because a key of the tree widget should not be '/'
nodes_.home = tree_.insert("FS.HOME", "Home");
@@ -430,28 +428,27 @@ namespace nana
nodes_.filesystem = tree_.insert("FS.ROOT", "Filesystem");
nodes_.filesystem.value(kind::filesystem);
file_iterator end;
for(file_iterator i(to_nstring(path_user())); i != end; ++i)
namespace fs = ::nana::experimental::filesystem;
std::vector<std::string> paths;
paths.emplace_back(nana::filesystem::path_user());
paths.emplace_back("/");
fs::directory_iterator end;
for (auto & p : paths)
{
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
item_proxy node = tree_.insert(nodes_.home, i->name, i->name);
if(false == node.empty())
for (fs::directory_iterator i(p); i != end; ++i)
{
node.value(kind::filesystem);
break;
}
}
auto name = i->path().filename().native();
if (!is_directory(i->status()) || (name.size() && name[0] == '.'))
continue;
for(file_iterator i("/"); i != end; ++i)
{
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
item_proxy node = tree_.insert(nodes_.filesystem, i->name, i->name);
if(false == node.empty())
{
node.value(kind::filesystem);
break;
item_proxy node = tree_.insert(nodes_.filesystem, name, name);
if (false == node.empty())
{
node.value(kind::filesystem);
break;
}
}
}
@@ -494,29 +491,31 @@ namespace nana
file_container_.clear();
using namespace nana::filesystem;
file_iterator end;
for(file_iterator i(path); i != end; ++i)
{
if((i->name.size() == 0) || (i->name[0] == '.'))
continue;
item_fs m;
m.name = i->name;
namespace fs = ::nana::experimental::filesystem;
fs::directory_iterator end;
for(fs::directory_iterator i(path); i != end; ++i)
{
auto name = i->path().filename().native();
if(name.empty() || (name.front() == '.'))
continue;
item_fs m;
m.name = name;
namespace fs = ::nana::experimental::filesystem;
auto fattr = fs::status(path + m.name);
if(fattr.type() != fs::file_type::not_found && fattr.type() != fs::file_type::unknown)
{
m.bytes = fs::file_size(path + m.name);
m.directory = fs::is_directory(fattr);
modified_file_time(path + m.name, m.modified_time);
::nana::filesystem::modified_file_time(path + m.name, m.modified_time);
}
else
{
m.bytes = 0;
m.directory = i->directory;
modified_file_time(path + i->name, m.modified_time);
m.directory = fs::is_directory(*i);
::nana::filesystem::modified_file_time(path + i->path().filename().native(), m.modified_time);
}
file_container_.push_back(m);
@@ -554,11 +553,13 @@ namespace nana
if(head.size() == 0 || head[head.size() - 1] != '/')
head += '/';
nana::filesystem::file_iterator end;
for(nana::filesystem::file_iterator i(head); i != end; ++i)
namespace fs = ::nana::experimental::filesystem;
fs::directory_iterator end;
for(fs::directory_iterator i(head); i != end; ++i)
{
if(i->directory)
path_.childset(i->name, 0);
if(is_directory(*i))
path_.childset(i->path().filename().native(), 0);
}
auto cat_path = path_.caption();
if(cat_path.size() && cat_path[cat_path.size() - 1] != '/')
@@ -574,10 +575,10 @@ namespace nana
(head += folder) += '/';
path_.caption(cat_path);
for(nana::filesystem::file_iterator i(head); i != end; ++i)
for(fs::directory_iterator i(head); i != end; ++i)
{
if(i->directory)
path_.childset(i->name, 0);
if (is_directory(*i))
path_.childset(i->path().filename().native(), 0);
}
if(pos == path.npos)
@@ -809,18 +810,25 @@ namespace nana
auto path = tree_.make_key_path(node, "/") + "/";
_m_resolute_path(path);
nana::filesystem::file_iterator end;
for(nana::filesystem::file_iterator i(path); i != end; ++i)
namespace fs = ::nana::experimental::filesystem;
fs::directory_iterator end;
for (fs::directory_iterator i{path}; i != end; ++i)
{
if((false == i->directory) || (i->name.size() && i->name[0] == '.')) continue;
auto child = node.append(i->name, i->name, kind::filesystem);
auto name = i->path().filename().native();
if((!is_directory(*i)) || (name.size() && name[0] == '.'))
continue;
auto child = node.append(name, name, kind::filesystem);
if(!child.empty())
{
for(nana::filesystem::file_iterator u(path + i->name); u != end; ++u)
for(fs::directory_iterator u(i->path()); u != end; ++u)
{
if(false == u->directory || (u->name.size() && u->name[0] == '.')) continue;
auto uname = i->path().filename().native();
if ((!is_directory(*i)) || (uname.size() && uname[0] == '.'))
continue;
child.append(u->name, u->name, kind::filesystem);
child.append(uname, uname, kind::filesystem);
break;
}
}
@@ -1047,7 +1055,7 @@ namespace nana
wfile.resize(std::wcslen(wfile.data()));
impl_->file = utf8_cast(wfile);
#elif defined(NANA_LINUX) || defined(NANA_MACOS)
#elif defined(NANA_POSIX)
filebox_implement fb(impl_->owner, impl_->open_or_save, impl_->title);
if(impl_->filters.size())

View File

@@ -1168,24 +1168,6 @@ namespace API
return reinterpret_cast<window>(ts_wd);
}
/*
//glass_window deprecated
//@brief: Test a window whether it is a glass attribute.
bool glass_window(window wd)
{
return (bground_mode::basic == effects_bground_mode(wd));
}
bool glass_window(window wd, bool isglass) //deprecated
{
if(isglass)
effects_bground(wd, effects::bground_transparent(0), 0);
else
effects_bground_remove(wd);
return true;
}
*/
void take_active(window wd, bool active, window take_if_active_false)
{
auto const iwd = reinterpret_cast<basic_window*>(wd);