remove deprecated code and debug code

This commit is contained in:
Jinhao
2019-02-15 06:27:17 +08:00
parent 9f1d015355
commit bbc39906c0
16 changed files with 28 additions and 614 deletions

View File

@@ -21,7 +21,6 @@
#include "inner_fwd_implement.hpp"
#include <errno.h>
#include <algorithm>
#include <iostream> //debug
namespace nana
{
@@ -445,7 +444,6 @@ namespace detail
case nana::detail::msg_packet_tag::pkt_family::mouse_drop:
msgwd = brock.wd_manager().find_window(native_window, {msg.u.mouse_drop.x, msg.u.mouse_drop.y});
std::cout<<" MouseDrop msgwd="<<msgwd<<", ("<<msg.u.mouse_drop.x<<","<<msg.u.mouse_drop.y<<")"<<std::endl;
if(msgwd)
{
arg_dropfiles arg;

View File

@@ -138,7 +138,7 @@ namespace nana
void drawer_trigger::filter_event(const std::vector<event_code>& evt_codes, const bool bDisabled)
{
for (const auto& evt_code : evt_codes)
for (auto evt_code : evt_codes)
{
filter_event(evt_code, bDisabled);
}

View File

@@ -955,14 +955,6 @@ namespace nana{
auto fm_extents = window_frame_extents(wd);
origin.x = -fm_extents.left;
origin.y = -fm_extents.top;
#if 0 //deprecated
if(reinterpret_cast<Window>(coord_wd) != restrict::spec.root_window())
{
fm_extents = window_frame_extents(coord_wd);
origin.x += fm_extents.left;
origin.y += fm_extents.top;
}
#endif
}
else
coord_wd = get_window(wd, window_relationship::parent);
@@ -1601,10 +1593,6 @@ namespace nana{
if(True == ::XTranslateCoordinates(restrict::spec.open_display(),
reinterpret_cast<Window>(wd), restrict::spec.root_window(), x, y, &pos.x, &pos.y, &child))
{
//deprecated
//auto fm_extents = window_frame_extents(wd);
//pos.x += fm_extents.left;
//pos.y += fm_extents.top;
return true;
}
#endif
@@ -1627,11 +1615,6 @@ namespace nana{
Window child;
if(True == ::XTranslateCoordinates(restrict::spec.open_display(), restrict::spec.root_window(), reinterpret_cast<Window>(wd), x, y, &pos.x, &pos.y, &child))
{
//deprecated
//Now the origin of pos is the left-top corner of the window(including titlebar and border)
//auto fm_extents = window_frame_extents(wd);
//pos.x += fm_extents.left;
//pos.y += fm_extents.top;
return true;
}
#endif

View File

@@ -308,66 +308,6 @@ namespace nana
class win32_dropdata : public win32com_iunknown<IDataObject, IID_IDataObject>
{
#if 0 //deprecated
class enumer : public win32com_iunknown<IEnumFORMATETC, IID_IEnumFORMATETC>
{
public:
enumer(drop_data& data) :
data_(data)
{}
enumer(const enumer& rhs):
data_(rhs.data_),
cursor_(rhs.cursor_)
{
}
private:
// Implement IEnumFORMATETC
HRESULT Clone(IEnumFORMATETC **ppenum) override
{
*ppenum = new enumer{ *this };
return S_OK;
}
HRESULT Next(ULONG celt, FORMATETC *rgelt, ULONG *pceltFetched) override
{
HRESULT result = (cursor_ + celt <= data_.entries_.size() ? S_OK : S_FALSE);
auto const fetched = (std::min)(std::size_t(celt), data_.entries_.size() - cursor_);
for (std::size_t i = 0; i < fetched; ++i)
*rgelt++ = data_.entries_[cursor_++]->format;
if (pceltFetched)
*pceltFetched = static_cast<ULONG>(fetched);
else if (celt > 1)
return S_FALSE;
return (celt == fetched ? S_OK : S_FALSE);
}
HRESULT Reset() override
{
cursor_ = 0;
return S_OK;
}
HRESULT Skip(ULONG celt) override
{
if (cursor_ + celt < data_.entries_.size())
{
cursor_ += celt;
return S_OK;
}
cursor_ = data_.entries_.size();
return S_FALSE;
}
private:
drop_data & data_;
std::size_t cursor_;
};
#endif
public:
struct data_entry
{
@@ -625,8 +565,6 @@ namespace nana
#elif defined(NANA_X11)
constexpr int xdnd_version = 5;
class x11_dropdata
{
public:
@@ -839,17 +777,13 @@ namespace nana
auto cur_wd = API::find_window(API::cursor_position());
std::cout<<" Hovered="<<cur_wd;
if(hovered_.window_handle != cur_wd)
{
hovered_.window_handle = cur_wd;
icon = (((drag_wd == cur_wd) || ddrop->has(drag_wd, cur_wd)) ? "dnd-move" : "dnd-none");
std::cout<<" ICON="<<icon;
}
std::cout<<std::endl;
if(icon)
{
_m_free_cursor();
@@ -880,10 +814,9 @@ namespace nana
nana::detail::xdnd_protocol xdnd_proto{native_source};
//Not simple mode
_m_spec().msg_dispatch([this, ddrop, &data, drag_wd, &xdnd_proto, native_source, &atombase](const detail::msg_packet_tag& msg_pkt) mutable{
_m_spec().msg_dispatch([this, &data, drag_wd, &xdnd_proto](const detail::msg_packet_tag& msg_pkt) mutable{
if(detail::msg_packet_tag::pkt_family::xevent == msg_pkt.kind)
{
auto const disp = _m_spec().open_display();
if (MotionNotify == msg_pkt.u.xevent.type)
{
auto pos = API::cursor_position();
@@ -906,10 +839,7 @@ namespace nana
}
else if(msg_pkt.u.xevent.type == ButtonRelease)
{
std::cout<<"ButtonRelease"<<std::endl;
API::release_capture(drag_wd);
std::cout<<"mouse_release"<<std::endl;
_m_free_cursor();
//Exits the msg loop if xdnd_proto doesn't send the XdndDrop because of refusal of the DND
@@ -1031,8 +961,7 @@ namespace nana
if (API::is_window(window_handle))
{
dragging = true;
using basic_window = ::nana::detail::basic_window;
auto real_wd = reinterpret_cast<::nana::detail::basic_window*>(window_handle);
auto real_wd = reinterpret_cast<detail::basic_window*>(window_handle);
real_wd->other.dnd_state = dragdrop_status::not_ready;
}
@@ -1072,8 +1001,7 @@ namespace nana
{
impl_->dragging = ((!impl_->predicate) || impl_->predicate());
using basic_window = ::nana::detail::basic_window;
auto real_wd = reinterpret_cast<::nana::detail::basic_window*>(impl_->window_handle);
auto real_wd = reinterpret_cast<detail::basic_window*>(impl_->window_handle);
real_wd->other.dnd_state = dragdrop_status::ready;
}
});
@@ -1082,8 +1010,7 @@ namespace nana
if (!(arg.is_left_button() && impl_->dragging && API::is_window(arg.window_handle)))
return;
using basic_window = ::nana::detail::basic_window;
auto real_wd = reinterpret_cast<::nana::detail::basic_window*>(arg.window_handle);
auto real_wd = reinterpret_cast<detail::basic_window*>(arg.window_handle);
real_wd->other.dnd_state = dragdrop_status::in_progress;
std::unique_ptr<dragdrop_service::dropdata_type> dropdata{new dragdrop_service::dropdata_type};
@@ -1190,8 +1117,7 @@ namespace nana
{
impl_->dragging = ((!impl_->predicate) || impl_->predicate());
using basic_window = ::nana::detail::basic_window;
auto real_wd = reinterpret_cast<::nana::detail::basic_window*>(impl_->source_handle);
auto real_wd = reinterpret_cast<detail::basic_window*>(impl_->source_handle);
real_wd->other.dnd_state = dragdrop_status::ready;
}
});
@@ -1200,27 +1126,14 @@ namespace nana
if (!(arg.is_left_button() && impl_->dragging && API::is_window(arg.window_handle)))
return;
using basic_window = ::nana::detail::basic_window;
auto real_wd = reinterpret_cast<::nana::detail::basic_window*>(arg.window_handle);
auto real_wd = reinterpret_cast<detail::basic_window*>(arg.window_handle);
real_wd->other.dnd_state = dragdrop_status::in_progress;
impl_->make_drop();
//deprecated
//auto has_dropped = dragdrop_service::instance().dragdrop(arg.window_handle);
real_wd->other.dnd_state = dragdrop_status::not_ready;
impl_->dragging = false;
/* //deprecated
if (has_dropped)
{
auto drop_wd = API::find_window(API::cursor_position());
//auto i = impl_->targets.find(drop_wd);
//if ((impl_->targets.end() != i) && i->second)
// i->second();
}
*/
});
}

View File

@@ -250,19 +250,14 @@ namespace nana
else if(event_code::mouse_up == arg.evt_code)
{
selection_.is_deselect_delayed = false;
#if 0
this->_m_delay_deselect(true);
#endif
if(_m_sync_with_selection())
_m_display_target_filenames();
}
else if(event_code::mouse_move == arg.evt_code)
{
if(arg.left_button)
{
selection_.is_deselect_delayed = false;
std::cout<<"MouseMove set is_deselect_delayed = true"<<std::endl;
}
}
else if(event_code::dbl_click == arg.evt_code)
_m_click_select_file(arg);
@@ -487,22 +482,6 @@ namespace nana
cb_types_.anyobj(i, v);
}
#if 0
bool file(std::string& fs) const
{
if(selection_.type == kind::none)
return false;
auto pos = selection_.target.find_last_of("\\/");
if(pos != selection_.target.npos)
saved_selected_path = selection_.target.substr(0, pos);
else
saved_selected_path.clear();
fs = selection_.target;
return true;
}
#endif
std::vector<std::string> files() const
{
if(kind::none == selection_.type)
@@ -1005,53 +984,8 @@ namespace nana
else
_m_load_cat_path(addr_.filesystem + m.name + "/");
}
#if 0
else
{
if((mode::open_directory == mode_) || (false == m.directory))
{
if(ls_file_.is_single_enabled(true) || !arg.ctrl)
{
std::cout<<"assign by click select "<<m.name<<std::endl;
selection_.targets = {m.name};
}
else
{
std::cout<<"insert by click select "<<m.name<<std::endl;
_m_insert_filename(m.name);
}
_m_display_target_filenames();
}
}
#endif
}
#if 0
void _m_delay_deselect(bool only_clear_register)
{
if(!only_clear_register)
{
std::string filename_string;
for(auto i = selection_.targets.cbegin(); i != selection_.targets.cend();)
{
std::filesystem::path p{*i};
auto u = std::find(selection_.delay_deselect.cbegin(), selection_.delay_deselect.cend(), p.filename().u8string());
if(u == selection_.delay_deselect.cend())
{
++i;
continue;
}
i = selection_.targets.erase(i);
}
_m_display_target_filenames();
}
selection_.delay_deselect.clear();
}
#endif
void _m_select_file(const listbox::item_proxy& item)
{
item_fs mfs;
@@ -1064,7 +998,6 @@ namespace nana
if(ls_file_.selected().size() < 2)
selection_.targets.clear();
std::cout<<"insert by select file:"<<mfs.name<<std::endl;
_m_insert_filename(mfs.name);
}
}
@@ -1075,16 +1008,11 @@ namespace nana
std::filesystem::path p{*i};
if(p.filename().u8string() == mfs.name)
{
std::cout<<"_m_select_file delay deselect = "<<selection_.is_deselect_delayed<<std::endl;
if(!selection_.is_deselect_delayed)
{
i = selection_.targets.erase(i);
continue;
}
#if 0
selection_.delay_deselect.push_back(mfs.name);
#endif
}
++i;
}
@@ -1156,11 +1084,7 @@ namespace nana
selection_.targets.clear();
//auto file = tb_file_.caption();
auto targets = _m_strip_files(files_text);
#if 1 //debug
std::cout<<"filebox OK: file="<<files_text<<std::endl;
for(auto t : targets)
std::cout<<"filebox OK stripped:"<<t<<std::endl;
#endif
if(targets.empty())
{
//No file is selected
@@ -1252,179 +1176,6 @@ namespace nana
_m_finish(kind::filesystem);
}
#if 0
void _m_ok()
{
selection_.targets.clear();
auto file = tb_file_.caption();
auto targets = _m_strip_files(file);
#if 1 //debug
std::cout<<"filebox OK: file="<<file<<std::endl;
for(auto t : targets)
std::cout<<"filebox OK stripped:"<<t<<std::endl;
#endif
//No file is selected
if(targets.empty())
return;
#if 0
std::string tar;
if(selection_.targets.empty())
{
if(file.size())
{
internationalization i18n;
if(file[0] == '.')
{
msgbox mb(*this, caption());
mb.icon(msgbox::icon_warning);
mb<<file<<std::endl<<i18n("NANA_FILEBOX_ERROR_INVALID_FILENAME");
mb();
return;
}
if(file[0] == '/')
tar = file;
else
tar = addr_.filesystem + file;
auto fattr = fs::status(tar);
auto ftype = static_cast<fs::file_type>(fattr.type());
//Check if the selected name is a directory
auto is_dir = fs::is_directory(fattr);
if(!is_dir && _m_append_def_extension(tar))
{
//Add the extension, then check if it is a directory again.
fattr = fs::status(tar);
ftype = static_cast<fs::file_type>(fattr.type());
is_dir = fs::is_directory(fattr);
}
if(is_dir)
{
_m_load_cat_path(tar);
tb_file_.caption(std::string{});
return;
}
if(mode::write_file != mode_)
{
if(fs::file_type::not_found == ftype)
{
msgbox mb(*this, caption());
mb.icon(msgbox::icon_information);
if(mode::open_file == mode_)
mb << i18n("NANA_FILEBOX_ERROR_NOT_EXISTING_AND_RETRY", tar);
else
mb << i18n("NANA_FILEBOX_ERROR_DIRECTORY_NOT_EXISTING_AND_RETRY", tar);
mb();
return;
}
}
else
{
if(fs::file_type::not_found != ftype)
{
msgbox mb(*this, caption(), msgbox::yes_no);
mb.icon(msgbox::icon_question);
mb<<i18n("NANA_FILEBOX_ERROR_QUERY_REWRITE_BECAUSE_OF_EXISTING");
if(msgbox::pick_no == mb())
return;
}
}
selection_.targets = {tar};
}
}
#else
internationalization i18n;
//the position of tar in targets
int tar_idx = -1;
//Check whether the selected files are valid.
for(auto tar : targets)
{
++tar_idx;
if(tar[0] == '.')
{
msgbox mb(*this, caption());
mb.icon(msgbox::icon_warning);
mb<<file<<std::endl<<i18n("NANA_FILEBOX_ERROR_INVALID_FILENAME");
mb();
return;
}
if(tar[0] != '/')
tar = addr_.filesystem + tar;
auto fattr = fs::status(tar);
auto ftype = static_cast<fs::file_type>(fattr.type());
//Check if the selected name is a directory
auto is_dir = fs::is_directory(fattr);
if(!is_dir && _m_append_def_extension(tar))
{
//Add the extension, then check if it is a directory again.
fattr = fs::status(tar);
ftype = static_cast<fs::file_type>(fattr.type());
is_dir = fs::is_directory(fattr);
}
if(is_dir)
{
//Enter the directory if this is the first tar.
if(0 == tar_idx)
{
_m_load_cat_path(tar);
tb_file_.caption(std::string{});
return;
}
//Other folders are ignored
continue;
}
if(mode::write_file != mode_)
{
if(fs::file_type::not_found == ftype)
{
msgbox mb(*this, caption());
mb.icon(msgbox::icon_information);
if(mode::open_file == mode_)
mb << i18n("NANA_FILEBOX_ERROR_NOT_EXISTING_AND_RETRY", tar);
else
mb << i18n("NANA_FILEBOX_ERROR_DIRECTORY_NOT_EXISTING_AND_RETRY", tar);
mb();
return;
}
}
else
{
if(fs::file_type::not_found != ftype)
{
msgbox mb(*this, caption(), msgbox::yes_no);
mb.icon(msgbox::icon_question);
mb<<i18n("NANA_FILEBOX_ERROR_QUERY_REWRITE_BECAUSE_OF_EXISTING");
if(msgbox::pick_no == mb())
return;
}
}
selection_.targets.push_back(tar);
}
#endif
_m_finish(kind::filesystem);
}
#endif
void _m_tr_expand(item_proxy node, bool exp)
{
if(false == exp) return;
@@ -1505,9 +1256,6 @@ namespace nana
{
kind::t type;
std::vector<std::string> targets;
#if 0
std::vector<std::string> delay_deselect;
#endif
bool is_deselect_delayed{ false };
}selection_;

View File

@@ -144,8 +144,6 @@ namespace nana
const std::string&, nana::any*, bool reverse)> weak_ordering;
std::shared_ptr<paint::font> font; ///< The exclusive column font
column() = default;
column(const column&) = default;
@@ -6186,10 +6184,9 @@ namespace nana
const nana::any *rowval,
bool reverse)> comp)
{
if (first_col<0 || last_col<=first_col)
return;
if (last_col >= column_size())
if (last_col <= first_col || last_col >= column_size())
return;
std::vector<size_type> new_idx;
for(size_type i=first_col; i<=last_col; ++i) new_idx.push_back(i);
@@ -6207,7 +6204,7 @@ namespace nana
//Only change the view position of columns
for(size_t i=0; i<new_idx.size(); ++i)
{
move_column(new_idx[i],i+first_col);
_m_ess().header.move_to_view_pos(new_idx[i], i + first_col, true);
}
_m_ess().update();
}

View File

@@ -3382,7 +3382,6 @@ namespace nana {
::nana::paint::graphics canvas;
canvas.make({ px_w, px_h });
canvas.typeface(graph_.typeface());
::nana::point canvas_text_pos;
auto ent_pos = pos;
const auto str_end = str + len;

View File

@@ -1370,17 +1370,9 @@ namespace nana
{
auto m = std::max((enable_crook_ ? scheme_.crook_size : 0), (enable_icon_ ? scheme_.icon_size : 0));
#if 1
unsigned as = 0, ds = 0, il;
graph.text_metrics(as, ds, il);
return std::max(as + ds + 8, m);
#else
#ifdef _nana_std_has_string_view
return std::max(m, graph.text_extent_size(std::wstring_view{ L"jH{", 3 }).height + 8);
#else
return std::max(m, graph.text_extent_size(L"jH{", 3).height + 8);
#endif
#endif
}
virtual unsigned item_width(graph_reference graph, const item_attribute_t& attr) const override
@@ -1586,8 +1578,6 @@ namespace nana
int trigger::item_locator::operator()(node_type &node, int affect)
{
auto & node_desc = impl_->shape;
switch(affect)
{
case 0: break;
@@ -1692,7 +1682,6 @@ namespace nana
{
impl_->data.trigger_ptr = this;
impl_->data.renderer = nana::pat::cloneable<renderer_interface>(internal_renderer());
//impl_->data.comp_placer = nana::pat::cloneable<compset_placer_interface>(internal_placer()); //deprecated
impl_->adjust.timer.elapse([this]
{
@@ -1827,18 +1816,6 @@ namespace nana
}
}
/* //deprecated
void trigger::renderer(::nana::pat::cloneable<renderer_interface>&& r)
{
impl_->data.renderer = std::move(r);
}
const ::nana::pat::cloneable<renderer_interface>& trigger::renderer() const
{
return impl_->data.renderer;
}
*/
::nana::pat::cloneable<renderer_interface>& trigger::renderer() const
{
return impl_->data.renderer;
@@ -1876,21 +1853,6 @@ namespace nana
return x;
}
/*
trigger::node_type* trigger::selected() const //deprecated
{
return impl_->node_state.selected;
}
*/
/*
void trigger::selected(node_type* node) //deprecated
{
if(impl_->attr.tree_cont.verify(node) && impl_->set_selected(node))
impl_->draw(true);
}
*/
node_image_tag& trigger::icon(const std::string& id)
{
auto i = impl_->shape.image_table.find(id);
@@ -1958,7 +1920,6 @@ namespace nana
widget.bgcolor(colors::white);
impl_->data.widget_ptr = static_cast<::nana::treebox*>(&widget);
impl_->data.scheme_ptr = static_cast<::nana::treebox::scheme_type*>(API::dev::get_scheme(widget));
//impl_->data.comp_placer->init_scheme(impl_->data.scheme_ptr); //deprecated
impl_->data.comp_placer = nana::pat::cloneable<compset_placer_interface>(internal_placer{ *impl_->data.scheme_ptr });
widget.caption("nana treebox");
@@ -2386,7 +2347,6 @@ namespace nana
treebox::item_proxy treebox::selected() const
{
//return item_proxy(const_cast<drawer_trigger_t*>(&get_drawer_trigger()), get_drawer_trigger().selected()); //deprecated
auto dw = &get_drawer_trigger();
return item_proxy(const_cast<drawer_trigger_t*>(dw), dw->impl()->node_state.selected);
}