eliminate -Wextra and -pedantic warnings

This commit is contained in:
Jinhao 2016-03-15 15:46:28 +08:00
parent 8f995ee2cf
commit 6b6b527007
38 changed files with 246 additions and 197 deletions

View File

@ -337,9 +337,9 @@ namespace nana
bool operator==(const color& other) const; bool operator==(const color& other) const;
bool operator!=(const color& other) const; bool operator!=(const color& other) const;
private: private:
double r_; double r_{ 0.0 };
double g_; double g_{ 0.0 };
double b_; double b_{ 0.0 };
double a_{ 0.0 }; //invisible double a_{ 0.0 }; //invisible
}; };

View File

@ -60,6 +60,8 @@ namespace detail
class charset_conv class charset_conv
{ {
charset_conv(const charset_conv&) = delete;
charset_conv& operator=(const charset_conv*) = delete;
public: public:
charset_conv(const char* tocode, const char* fromcode); charset_conv(const char* tocode, const char* fromcode);
~charset_conv(); ~charset_conv();
@ -118,6 +120,9 @@ namespace detail
void update_color(); void update_color();
void update_text_color(); void update_text_color();
private: private:
drawable_impl_type(const drawable_impl_type&) = delete;
drawable_impl_type& operator=(const drawable_impl_type&) = delete;
unsigned current_color_{ 0xFFFFFF }; unsigned current_color_{ 0xFFFFFF };
unsigned color_{ 0xFFFFFFFF }; unsigned color_{ 0xFFFFFFFF };
unsigned text_color_{ 0xFFFFFFFF }; unsigned text_color_{ 0xFFFFFFFF };

View File

@ -429,7 +429,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<detail::docker_interface>>> dockers_; std::unique_ptr<std::vector<std::unique_ptr<detail::docker_interface>>> dockers_{ nullptr };
}; };
struct arg_mouse struct arg_mouse

View File

@ -68,7 +68,7 @@ namespace nana
private: private:
implementation * const impl_; implementation * const impl_;
}; };
}; }
}//end namespace drawerbase }//end namespace drawerbase
/// Spinbox Widget /// Spinbox Widget

View File

@ -307,14 +307,14 @@ namespace nana
{ {
_m_value() = t; _m_value() = t;
return *this; return *this;
}; }
template<typename T> template<typename T>
item_proxy & value(T&& t) item_proxy & value(T&& t)
{ {
_m_value() = std::move(t); _m_value() = std::move(t);
return *this; return *this;
}; }
// Undocumentated methods for internal use // Undocumentated methods for internal use
trigger::node_type * _m_node() const; trigger::node_type * _m_node() const;

View File

@ -30,7 +30,7 @@ namespace system
typedef void* module_t; typedef void* module_t;
void* symbols(module_t handle, const char* symbol); void* symbols(module_t handle, const char* symbol);
}; //end struct shared_helper } //end namespace shared_helper
}//end namespace detail }//end namespace detail
class shared_wrapper class shared_wrapper

View File

@ -60,7 +60,7 @@ namespace nana
void _m_resolve_weak_types(); void _m_resolve_weak_types();
void _m_resolve_neutral_types(); void _m_resolve_neutral_types();
void _m_resolve_implicit_levels(); void _m_resolve_implicit_levels();
void _m_reordering_resolved_levels(const char_type*, std::vector<entity> & reordered); void _m_reordering_resolved_levels(std::vector<entity> & reordered);
static bidi_category _m_bidi_category(bidi_char); static bidi_category _m_bidi_category(bidi_char);
static bidi_char _m_char_dir(char_type); static bidi_char _m_char_dir(char_type);
private: private:

View File

@ -264,6 +264,7 @@ namespace nana
} }
time::time() time::time()
: value_{}
{ {
struct tm t; struct tm t;
localtime(t); localtime(t);

View File

@ -432,13 +432,13 @@ namespace detail
platform_spec::instance().unlock_xlib(); platform_spec::instance().unlock_xlib();
} }
int X11_error_handler(Display* disp, XErrorEvent* err) int X11_error_handler(Display*, XErrorEvent* err)
{ {
platform_spec::instance().error_code = err->error_code; platform_spec::instance().error_code = err->error_code;
return 0; return 0;
} }
int X11_fatal_handler(Display* disp) int X11_fatal_handler(Display*)
{ {
return 0; return 0;
} }

View File

@ -813,6 +813,7 @@ namespace nana { namespace experimental { namespace filesystem
bool remove(const path& p, std::error_code & ec) bool remove(const path& p, std::error_code & ec)
{ {
ec.clear();
auto stat = status(p); auto stat = status(p);
if (stat.type() == file_type::directory) if (stat.type() == file_type::directory)
return detail::rm_dir(p); return detail::rm_dir(p);

View File

@ -153,7 +153,7 @@ namespace detail
delete impl_; delete impl_;
} }
void bedrock::map_thread_root_buffer(core_window_t*, bool forced, const rectangle*) void bedrock::map_thread_root_buffer(core_window_t*, bool /*forced*/, const rectangle*)
{ {
//GUI in X11 is thread-independent, so no implementation. //GUI in X11 is thread-independent, so no implementation.
} }
@ -366,7 +366,7 @@ namespace detail
return impl_->estore; return impl_->estore;
} }
void bedrock::map_through_widgets(core_window_t* wd, native_drawable_type drawable) void bedrock::map_through_widgets(core_window_t*, native_drawable_type)
{ {
//No implementation for Linux //No implementation for Linux
} }
@ -523,7 +523,7 @@ namespace detail
} }
} }
void window_proc_for_packet(Display * display, nana::detail::msg_packet_tag& msg) void window_proc_for_packet(Display * /*display*/, nana::detail::msg_packet_tag& msg)
{ {
static auto& brock = detail::bedrock::instance(); static auto& brock = detail::bedrock::instance();
@ -642,7 +642,7 @@ namespace detail
return wchar_t(keysym); return wchar_t(keysym);
} }
void window_proc_for_xevent(Display* display, XEvent& xevent) void window_proc_for_xevent(Display* /*display*/, XEvent& xevent)
{ {
typedef detail::bedrock::core_window_t core_window_t; typedef detail::bedrock::core_window_t core_window_t;
@ -1308,7 +1308,7 @@ namespace detail
} }
} }
void bedrock::pump_event(window modal_window, bool is_modal) void bedrock::pump_event(window modal_window, bool /*is_modal*/)
{ {
thread_context * context = open_thread_context(); thread_context * context = open_thread_context();
if(0 == context->window_count) if(0 == context->window_count)

View File

@ -173,6 +173,8 @@ namespace nana{
mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top); mi.rcWork.right - mi.rcWork.left, mi.rcWork.bottom - mi.rcWork.top);
} }
} }
#else
static_cast<void>(pos); //eliminate unused parameter compiler warning.
#endif #endif
return rectangle{ primary_monitor_size() }; return rectangle{ primary_monitor_size() };
} }
@ -547,6 +549,8 @@ namespace nana{
activate_window(reinterpret_cast<native_window_type>( activate_window(reinterpret_cast<native_window_type>(
::GetWindow(reinterpret_cast<HWND>(wd), GW_OWNER) ::GetWindow(reinterpret_cast<HWND>(wd), GW_OWNER)
)); ));
#else
static_cast<void>(wd); //eliminate unused parameter compiler warning.
#endif #endif
} }
@ -565,6 +569,8 @@ namespace nana{
else else
::PostMessage(native_wd, nana::detail::messages::async_activate, 0, 0); ::PostMessage(native_wd, nana::detail::messages::async_activate, 0, 0);
} }
#else
static_cast<void>(wd); //eliminate unused parameter compiler warning.
#endif #endif
} }
@ -640,6 +646,7 @@ namespace nana{
::XFlush(disp); ::XFlush(disp);
} }
static_cast<void>(active); //eliminate unused parameter compiler warning.
#endif #endif
} }
@ -715,6 +722,7 @@ namespace nana{
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
::InvalidateRect(reinterpret_cast<HWND>(wd), nullptr, true); ::InvalidateRect(reinterpret_cast<HWND>(wd), nullptr, true);
#elif defined(NANA_X11) #elif defined(NANA_X11)
static_cast<void>(wd); //eliminate unused parameter compiler warning.
#endif #endif
} }
@ -963,6 +971,7 @@ namespace nana{
::SetWindowPos(native_wd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE); ::SetWindowPos(native_wd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE);
::AttachThreadInput(::GetCurrentThreadId(), fg_tid, FALSE); ::AttachThreadInput(::GetCurrentThreadId(), fg_tid, FALSE);
#else #else
static_cast<void>(activated); //eliminate unused parameter compiler warning.
set_window_z_order(wd, nullptr, z_order_action::top); set_window_z_order(wd, nullptr, z_order_action::top);
#endif #endif
} }
@ -1414,6 +1423,11 @@ namespace nana{
if(static_cast<unsigned>(y) > sz.height + ext_height) if(static_cast<unsigned>(y) > sz.height + ext_height)
sz.height = static_cast<unsigned>(y); sz.height = static_cast<unsigned>(y);
} }
#else
//eliminate unused parameter compiler warning.
static_cast<void>(ext_width);
static_cast<void>(ext_height);
static_cast<void>(true_for_max);
#endif #endif
return sz; return sz;
} }

View File

@ -357,7 +357,7 @@ namespace nana
//_m_notify_glasses //_m_notify_glasses
//@brief: Notify the glass windows that are overlapped with the specified vis_rect //@brief: Notify the glass windows that are overlapped with the specified vis_rect
void window_layout::_m_notify_glasses(core_window_t* const sigwd, const nana::rectangle& r_visual) void window_layout::_m_notify_glasses(core_window_t* const sigwd, const nana::rectangle& /*r_visual*/)
{ {
typedef category::flags cat_flags; typedef category::flags cat_flags;

View File

@ -212,7 +212,7 @@ namespace nana
class menu_crook class menu_crook
: public crook_interface : public crook_interface
{ {
bool draw(graph_reference graph, const ::nana::color&, const ::nana::color& fgcolor, const nana::rectangle& r, element_state es, const data& crook_data) override bool draw(graph_reference graph, const ::nana::color&, const ::nana::color& fgcolor, const nana::rectangle& r, element_state, const data& crook_data) override
{ {
if(crook_data.check_state == state::unchecked) if(crook_data.check_state == state::unchecked)
return true; return true;
@ -266,7 +266,7 @@ namespace nana
class border_depressed class border_depressed
: public border_interface : public border_interface
{ {
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, unsigned weight) bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color&, const ::nana::rectangle& r, element_state estate, unsigned)
{ {
graph.rectangle(r, false, static_cast<color_rgb>((element_state::focus_hovered == estate || element_state::focus_normal == estate) ? 0x0595E2 : 0x999A9E)); graph.rectangle(r, false, static_cast<color_rgb>((element_state::focus_hovered == estate || element_state::focus_normal == estate) ? 0x0595E2 : 0x999A9E));
graph.rectangle(::nana::rectangle(r).pare_off(1), false, bgcolor); graph.rectangle(::nana::rectangle(r).pare_off(1), false, bgcolor);
@ -277,7 +277,7 @@ namespace nana
class arrow_solid_triangle class arrow_solid_triangle
: public arrow_interface : public arrow_interface
{ {
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, direction dir) override bool draw(graph_reference graph, const ::nana::color&, const ::nana::color&, const ::nana::rectangle& r, element_state, direction dir) override
{ {
::nana::point pos{ r.x + 3, r.y + 3 }; ::nana::point pos{ r.x + 3, r.y + 3 };
switch (dir) switch (dir)
@ -318,7 +318,7 @@ namespace nana
class arrow_hollow_triangle class arrow_hollow_triangle
: public arrow_interface : public arrow_interface
{ {
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override bool draw(graph_reference graph, const ::nana::color&, const ::nana::color&, const ::nana::rectangle& r, element_state, ::nana::direction dir) override
{ {
int x = r.x + 3; int x = r.x + 3;
int y = r.y + 3; int y = r.y + 3;
@ -364,7 +364,7 @@ namespace nana
class arrowhead class arrowhead
: public arrow_interface : public arrow_interface
{ {
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override bool draw(graph_reference graph, const ::nana::color&, const ::nana::color&, const ::nana::rectangle& r, element_state, ::nana::direction dir) override
{ {
int x = r.x; int x = r.x;
int y = r.y + 5; int y = r.y + 5;
@ -425,7 +425,7 @@ namespace nana
class arrow_double class arrow_double
: public arrow_interface : public arrow_interface
{ {
bool draw(graph_reference graph, const ::nana::color& bgcolor, const ::nana::color& fgcolor, const ::nana::rectangle& r, element_state estate, ::nana::direction dir) override bool draw(graph_reference graph, const ::nana::color&, const ::nana::color&, const ::nana::rectangle& r, element_state, ::nana::direction dir) override
{ {
int x = r.x; int x = r.x;
int y = r.y; int y = r.y;
@ -486,7 +486,7 @@ namespace nana
class annex_button class annex_button
: public element_interface : public element_interface
{ {
bool draw(graph_reference graph, const ::nana::color& arg_bgcolor, const ::nana::color& fgcolor, const rectangle& r, element_state estate) override bool draw(graph_reference graph, const ::nana::color& arg_bgcolor, const ::nana::color&, const rectangle& r, element_state estate) override
{ {
auto bgcolor = arg_bgcolor; auto bgcolor = arg_bgcolor;

View File

@ -702,7 +702,7 @@ namespace nana
impl->spinbox.value(std::to_string(impl->value)); impl->spinbox.value(std::to_string(impl->value));
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg) impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized&)
{ {
impl->label.size({ label_px, 24 }); impl->label.size({ label_px, 24 });
impl->spinbox.size({ value_px, 24 }); impl->spinbox.size({ value_px, 24 });
@ -780,7 +780,7 @@ namespace nana
impl->spinbox.value(std::to_string(impl->value)); impl->spinbox.value(std::to_string(impl->value));
impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized& arg) impl->dock.events().resized.connect_unignorable([impl, label_px, value_px](const ::nana::arg_resized&)
{ {
impl->label.size(::nana::size{ label_px, 24 }); impl->label.size(::nana::size{ label_px, 24 });
impl->spinbox.size(::nana::size{ value_px, 24 }); impl->spinbox.size(::nana::size{ value_px, 24 });

View File

@ -314,6 +314,8 @@ namespace nana
::Shell_NotifyIcon(impl_->icon_added ? NIM_MODIFY : NIM_ADD, &icon_data); ::Shell_NotifyIcon(impl_->icon_added ? NIM_MODIFY : NIM_ADD, &icon_data);
impl_->icon_added = true; impl_->icon_added = true;
#else
static_cast<void>(str); //to eliminate unused parameter compiler warning.
#endif #endif
} }
@ -330,6 +332,8 @@ namespace nana
impl_->set_icon(impl_->icon_handle); impl_->set_icon(impl_->icon_handle);
::DestroyIcon(pre_icon); ::DestroyIcon(pre_icon);
} }
#else
static_cast<void>(icon_file); //to eliminate unused parameter compiler warning
#endif #endif
} }
@ -338,6 +342,8 @@ namespace nana
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
auto icon = (HICON)::LoadImage(0, to_wstring(icon_file).data(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); auto icon = (HICON)::LoadImage(0, to_wstring(icon_file).data(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE);
impl_->icons.push_back(icon); impl_->icons.push_back(icon);
#else
static_cast<void>(icon_file); //to eliminate unused parameter compiler warning.
#endif #endif
} }
@ -352,6 +358,8 @@ namespace nana
} }
else else
impl_->ani_timer.stop(); impl_->ani_timer.stop();
#else
static_cast<void>(ms); //to eliminate unused parameter compiler warning.
#endif #endif
} }

View File

@ -524,7 +524,7 @@ namespace nana
//It will delete the element and recollocate when the window destroyed. //It will delete the element and recollocate when the window destroyed.
event_handle _m_make_destroy(window wd) event_handle _m_make_destroy(window wd)
{ {
return API::events(wd).destroy.connect([this, wd](const arg_destroy& arg) return API::events(wd).destroy.connect([this, wd](const arg_destroy&)
{ {
for (auto i = elements.begin(), end = elements.end(); i != end; ++i) for (auto i = elements.begin(), end = elements.end(); i != end; ++i)
{ {
@ -1127,7 +1127,7 @@ namespace nana
} }
} }
void collocate(window wd) override void collocate(window) override
{ {
if (!field || !(visible && display)) if (!field || !(visible && display))
return; return;
@ -1563,7 +1563,7 @@ namespace nana
} }
} }
void collocate(window wd) override void collocate(window) override
{ {
if (!dockable_field) if (!dockable_field)
{ {

View File

@ -104,8 +104,7 @@ namespace API
{ {
if (iwd->effect.edge_nimbus == effects::edge_nimbus::none) if (iwd->effect.edge_nimbus == effects::edge_nimbus::none)
{ {
basic_window::edge_nimbus_action ena = { iwd }; cont.push_back(basic_window::edge_nimbus_action{ iwd, false});
cont.push_back(ena);
} }
iwd->effect.edge_nimbus = static_cast<effects::edge_nimbus>(static_cast<unsigned>(en) | static_cast<unsigned>(iwd->effect.edge_nimbus)); iwd->effect.edge_nimbus = static_cast<effects::edge_nimbus>(static_cast<unsigned>(en) | static_cast<unsigned>(iwd->effect.edge_nimbus));
} }

View File

@ -167,6 +167,8 @@ namespace nana
} }
} }
} }
#else
static_cast<void>(pos); //to eliminate unused parameter compiler warning.
#endif #endif
return get_primary(); return get_primary();
} }

View File

@ -227,7 +227,7 @@ namespace nana
window_->tooltip_move(API::cursor_position(), true); window_->tooltip_move(API::cursor_position(), true);
} }
void show_duration(window wd, point pos, const std::string& text, std::size_t duration) void show_duration(window /*wd*/, point pos, const std::string& text, std::size_t duration)
{ {
if (nullptr == window_ || window_->tooltip_empty()) if (nullptr == window_ || window_->tooltip_empty())
{ {

View File

@ -163,7 +163,7 @@ namespace nana{ namespace drawerbase
_m_press(graph, false); _m_press(graph, false);
} }
void trigger::key_press(graph_reference graph, const arg_keyboard& arg) void trigger::key_press(graph_reference, const arg_keyboard& arg)
{ {
bool ch_tabstop_next; bool ch_tabstop_next;
switch(arg.key) switch(arg.key)

View File

@ -216,7 +216,7 @@ namespace nana{ namespace drawerbase
uiobj.check(false); uiobj.check(false);
uiobj.react(false); uiobj.react(false);
element_tag el = {}; element_tag el;
el.uiobj = &uiobj; el.uiobj = &uiobj;

View File

@ -615,7 +615,7 @@ namespace nana
} }
} }
void trigger::mouse_down(graph_reference graph, const arg_mouse& arg) void trigger::mouse_down(graph_reference, const arg_mouse& arg)
{ {
//drawer_->set_mouse_press(true); //drawer_->set_mouse_press(true);
drawer_->set_button_state(element_state::pressed, false); drawer_->set_button_state(element_state::pressed, false);
@ -633,7 +633,7 @@ namespace nana
} }
} }
void trigger::mouse_up(graph_reference graph, const arg_mouse& arg) void trigger::mouse_up(graph_reference, const arg_mouse& arg)
{ {
if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister()) if (drawer_->widget_ptr()->enabled() && !drawer_->has_lister())
{ {
@ -660,7 +660,7 @@ namespace nana
} }
} }
void trigger::mouse_wheel(graph_reference graph, const arg_wheel& arg) void trigger::mouse_wheel(graph_reference, const arg_wheel& arg)
{ {
if(drawer_->widget_ptr()->enabled()) if(drawer_->widget_ptr()->enabled())
{ {
@ -718,7 +718,7 @@ namespace nana
API::lazy_refresh(); API::lazy_refresh();
} }
void trigger::key_char(graph_reference graph, const arg_keyboard& arg) void trigger::key_char(graph_reference, const arg_keyboard& arg)
{ {
if (drawer_->editor()->respond_char(arg)) if (drawer_->editor()->respond_char(arg))
API::lazy_refresh(); API::lazy_refresh();

View File

@ -18,7 +18,7 @@ namespace nana
namespace form namespace form
{ {
//class trigger //class trigger
void trigger::attached(widget_reference wdg, graph_reference graph) void trigger::attached(widget_reference wdg, graph_reference)
{ {
wd_ = &wdg; wd_ = &wdg;
API::ignore_mouse_focus(wdg, true); API::ignore_mouse_focus(wdg, true);

View File

@ -437,7 +437,7 @@ namespace nana
return total_w; return total_w;
} }
bool _m_each_line(graph_reference graph, dstream::linecontainer& line, render_status& rs) bool _m_each_line(graph_reference graph, dstream::linecontainer&, render_status& rs)
{ {
std::wstring text; std::wstring text;
iterator block_start; iterator block_start;

View File

@ -2614,15 +2614,15 @@ namespace nana
return list_str ; return list_str ;
} }
void es_lister::categ_selected(size_type cat, bool sel) void es_lister::categ_selected(size_type cat, bool sel)
{ {
cat_proxy cpx{ess_,cat}; cat_proxy cpx{ess_,cat};
for (item_proxy &it : cpx ) for (item_proxy &it : cpx )
{ {
if (it.selected() != sel) if (it.selected() != sel)
it.select(sel); it.select(sel);
} }
last_selected_abs = last_selected_dpl = index_pair{cat, npos}; last_selected_abs = last_selected_dpl = index_pair{cat, npos};
} }
class drawer_header_impl class drawer_header_impl
@ -3549,15 +3549,16 @@ namespace nana
} }
} }
void trigger::dbl_click(graph_reference graph, const arg_mouse& arg) void trigger::dbl_click(graph_reference graph, const arg_mouse&)
{ {
if (essence_->pointer_where.first == essence_t::parts::header) if (essence_->pointer_where.first == essence_t::parts::header)
if (cursor::size_we == essence_->lister.wd_ptr()->cursor()) if (cursor::size_we == essence_->lister.wd_ptr()->cursor())
{ {
if (essence(). auto_width(drawer_header_->item_spliter() )) // ? in order //adjust the width of column to its content.
essence().update(); if (essence_->auto_width(drawer_header_->item_spliter() ))
return; essence_->update();
} return;
}
if (essence_->pointer_where.first != essence_t::parts::lister) if (essence_->pointer_where.first != essence_t::parts::lister)
return; return;
@ -3571,24 +3572,25 @@ namespace nana
if (!item_pos.is_category()) //being the npos of item.second is a category if (!item_pos.is_category()) //being the npos of item.second is a category
return; return;
arg_category ai(cat_proxy(essence_, item_pos.cat)); arg_category ai(cat_proxy(essence_, item_pos.cat));
lister.wd_ptr()->events().category_dbl_click.emit(ai); lister.wd_ptr()->events().category_dbl_click.emit(ai);
if(!ai.category_change_blocked()){ if(!ai.category_change_blocked())
bool do_expand = (lister.expand(item_pos.cat) == false); {
lister.expand(item_pos.cat, do_expand); bool do_expand = (lister.expand(item_pos.cat) == false);
lister.expand(item_pos.cat, do_expand);
if(false == do_expand) if(false == do_expand)
{ {
auto last = lister.last(); auto last = lister.last();
size_type n = essence_->number_of_lister_items(false); size_type n = essence_->number_of_lister_items(false);
if (lister.backward(last, n, last)) if (lister.backward(last, n, last))
offset_y = last; offset_y = last;
} }
essence_->adjust_scroll_life(); essence_->adjust_scroll_life();
refresh(graph); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
} }
} }
} }
@ -3603,8 +3605,8 @@ namespace nana
{ {
bool up = false; bool up = false;
if (essence_->lister.size_categ()==1 && essence_->lister.size_item(0)==0) if (essence_->lister.size_categ()==1 && essence_->lister.size_item(0)==0)
return ; return ;
switch(arg.key) switch(arg.key)
{ {
@ -3622,49 +3624,46 @@ namespace nana
} }
break; break;
case keyboard::os_pageup : case keyboard::os_pageup :
up = true; up = true;
case keyboard::os_pagedown: case keyboard::os_pagedown:
{ {
auto& scrl = essence_->scroll.v; auto& scrl = essence_->scroll.v;
if (! scrl.make_page_scroll(!up)) if (! scrl.make_page_scroll(!up))
return; return;
essence_->lister.select_for_all(false); essence_->lister.select_for_all(false);
index_pair idx{essence_->scroll_y_dpl()}; index_pair idx{essence_->scroll_y_dpl()};
if (!up) if (!up)
essence_->lister.forward(idx, scrl.range()-1, idx); essence_->lister.forward(idx, scrl.range()-1, idx);
if (idx.is_item()) if (idx.is_item())
item_proxy::from_display(essence_, idx).select(true); item_proxy::from_display(essence_, idx).select(true);
else else if(!essence_->lister.single_selection())
if(!essence_->lister.single_selection())
essence_->lister.categ_selected(idx.cat, true); essence_->lister.categ_selected(idx.cat, true);
essence_->trace_last_selected_item (); essence_->trace_last_selected_item ();
break; break;
} }
case keyboard::os_home: case keyboard::os_home:
{ {
essence_->lister.select_for_all(false); essence_->lister.select_for_all(false);
index_pair frst{essence_->lister.first()}; index_pair frst{essence_->lister.first()};
if (frst.is_item()) if (frst.is_item())
item_proxy::from_display(essence_, frst).select(true); item_proxy::from_display(essence_, frst).select(true);
else else if(!essence_->lister.single_selection())
if(!essence_->lister.single_selection())
essence_->lister.categ_selected(frst.cat, true); essence_->lister.categ_selected(frst.cat, true);
essence_->trace_last_selected_item (); essence_->trace_last_selected_item ();
break; break;
} }
case keyboard::os_end: case keyboard::os_end:
essence_->lister.select_for_all(false); essence_->lister.select_for_all(false);
item_proxy::from_display(essence_, essence_->lister.last()).select(true); item_proxy::from_display(essence_, essence_->lister.last()).select(true);
essence_->trace_last_selected_item (); essence_->trace_last_selected_item ();
break; break;
default: default:
return; return;
} }
@ -3676,20 +3675,19 @@ namespace nana
{ {
switch(arg.key) switch(arg.key)
{ {
case keyboard::copy: case keyboard::copy:
{ {
export_options exp_opt {essence_->def_exp_options}; export_options exp_opt {essence_->def_exp_options};
exp_opt.columns_order = essence_->header.all_headers(true); exp_opt.columns_order = essence_->header.all_headers(true);
exp_opt.only_selected_items = true; exp_opt.only_selected_items = true;
::nana::system::dataexch().set(essence_->to_string(exp_opt)); ::nana::system::dataexch().set(essence_->to_string(exp_opt));
return; return;
} }
case keyboard::select_all : case keyboard::select_all :
essence_->lister.select_for_all(true); essence_->lister.select_for_all(true);
refresh(graph); refresh(graph);
API::lazy_refresh(); API::lazy_refresh();
break; break;
default: default:
return; return;
} }
@ -3713,23 +3711,24 @@ namespace nana
} }
} }
/// the main porpose of this it to make obvious that item_proxy operate with absolute positions, and dont get moved during sort() /// the main porpose of this it to make obvious that item_proxy operate with absolute positions, and dont get moved during sort()
item_proxy item_proxy::from_display(essence_t *ess, const index_pair &relative) item_proxy item_proxy::from_display(essence_t *ess, const index_pair &relative)
{ {
return item_proxy{ess, ess->lister.absolute_pair(relative)}; return item_proxy{ess, ess->lister.absolute_pair(relative)};
} }
item_proxy item_proxy::from_display(const index_pair &relative) const
{
return item_proxy{ess_, ess_->lister.absolute_pair(relative)};
}
/// posible use: last_selected_display = last_selected.to_display().item; use with caution, it get invalidated after a sort() item_proxy item_proxy::from_display(const index_pair &relative) const
index_pair item_proxy::to_display() const {
{ return item_proxy{ess_, ess_->lister.absolute_pair(relative)};
return ess_->lister.relative_pair(pos_); }
}
bool item_proxy::empty() const /// posible use: last_selected_display = last_selected.to_display().item; use with caution, it get invalidated after a sort()
index_pair item_proxy::to_display() const
{
return ess_->lister.relative_pair(pos_);
}
bool item_proxy::empty() const
{ {
return !ess_; return !ess_;
} }
@ -3752,14 +3751,14 @@ namespace nana
return cat_->items.at(pos_.item).flags.checked; return cat_->items.at(pos_.item).flags.checked;
} }
/// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected /// is ignored if no change (maybe set last_selected anyway??), but if change emit event, deselect others if need ans set/unset last_selected
item_proxy & item_proxy::select(bool s) item_proxy & item_proxy::select(bool s)
{ {
auto & m = cat_->items.at(pos_.item); // a ref to the real item // what is pos is a cat? auto & m = cat_->items.at(pos_.item); // a ref to the real item // what is pos is a cat?
if(m.flags.selected == s) return *this; // ignore if no change if(m.flags.selected == s) return *this; // ignore if no change
m.flags.selected = s; // actually change selection m.flags.selected = s; // actually change selection
arg_listbox arg{*this, s}; arg_listbox arg{*this, s};
ess_->lister.wd_ptr()->events().selected.emit(arg); ess_->lister.wd_ptr()->events().selected.emit(arg);
if (m.flags.selected) if (m.flags.selected)
@ -4394,7 +4393,7 @@ namespace nana
} }
unsigned listbox::auto_width(size_type pos, unsigned max) unsigned listbox::auto_width(size_type pos, unsigned max)
{ {
auto & ess = _m_ess(); auto & ess = _m_ess();
unsigned max_w = ess.auto_width(pos, max); unsigned max_w = ess.auto_width(pos, max);
ess.update(); ess.update();
return max_w; return max_w;
@ -4480,34 +4479,33 @@ namespace nana
return *this; return *this;
} }
listbox::item_proxy listbox::at(const index_pair& pos_abs) const listbox::item_proxy listbox::at(const index_pair& pos_abs) const
{ {
return at(pos_abs.cat).at(pos_abs.item); return at(pos_abs.cat).at(pos_abs.item);
} }
// Contributed by leobackes(pr#97) // Contributed by leobackes(pr#97)
listbox::index_pair listbox::at ( const point& pos ) const listbox::index_pair listbox::at ( const point& pos ) const
{ {
auto & ess=_m_ess(); auto & ess=_m_ess();
auto _where=ess.where(pos.x, pos.y); auto _where=ess.where(pos.x, pos.y);
index_pair item_pos{npos,npos}; index_pair item_pos{npos,npos};
if(_where.first==drawerbase::listbox::essence_t::parts::lister){ if(_where.first==drawerbase::listbox::essence_t::parts::lister)
auto & offset_y = ess.scroll.offset_y_dpl; {
ess.lister.forward(offset_y, _where.second, item_pos); auto & offset_y = ess.scroll.offset_y_dpl;
} ess.lister.forward(offset_y, _where.second, item_pos);
return item_pos; }
} return item_pos;
}
//Contributed by leobackes(pr#97) //Contributed by leobackes(pr#97)
listbox::columns_indexs listbox::column_from_pos ( const point& pos ) listbox::columns_indexs listbox::column_from_pos ( const point& pos )
{ {
auto & ess=_m_ess(); auto & ess=_m_ess();
columns_indexs col=ess.header.item_by_x(pos.x - 2 - ess.scroll.offset_x); columns_indexs col=ess.header.item_by_x(pos.x - 2 - ess.scroll.offset_x);
return col; return col;
} }
void listbox::insert(const index_pair& pos, std::string text) void listbox::insert(const index_pair& pos, std::string text)
{ {

View File

@ -53,7 +53,7 @@ namespace nana{ namespace widgets
return cmd_; return cmd_;
} }
virtual bool merge(const undoable_command_interface<EnumCommand>& rhs) override virtual bool merge(const undoable_command_interface<EnumCommand>&) override
{ {
return false; return false;
} }
@ -273,8 +273,8 @@ namespace nana{ namespace widgets
: editor_(editor) : editor_(editor)
{} {}
void merge_lines(std::size_t first, std::size_t second) override{} void merge_lines(std::size_t, std::size_t) override{}
void add_lines(std::size_t pos, std::size_t lines) override{} void add_lines(std::size_t, std::size_t) override{}
void pre_calc_line(std::size_t, unsigned) override{} void pre_calc_line(std::size_t, unsigned) override{}
void pre_calc_lines(unsigned) override{} void pre_calc_lines(unsigned) override{}
@ -283,12 +283,12 @@ namespace nana{ namespace widgets
return editor_.textbase_.lines(); return editor_.textbase_.lines();
} }
std::size_t take_lines(std::size_t pos) const override std::size_t take_lines(std::size_t) const override
{ {
return 1; return 1;
} }
void update_line(std::size_t textline, std::size_t secondary_before) override void update_line(std::size_t textline, std::size_t) override
{ {
int top = editor_._m_text_top_base() + static_cast<int>(editor_.line_height() * (textline - editor_.points_.offset.y)); int top = editor_._m_text_top_base() + static_cast<int>(editor_.line_height() * (textline - editor_.points_.offset.y));
editor_.graph_.rectangle({ editor_.text_area_.area.x, top, editor_.text_area_.area.width, editor_.line_height() }, true, API::bgcolor(editor_.window_)); editor_.graph_.rectangle({ editor_.text_area_.area.x, top, editor_.text_area_.area.width, editor_.line_height() }, true, API::bgcolor(editor_.window_));

View File

@ -518,7 +518,7 @@ namespace nana
impl_->render(); impl_->render();
} }
void drawer::focus(graph_reference, const arg_focus& arg) void drawer::focus(graph_reference, const arg_focus&)
{ {
impl_->reset_text(); impl_->reset_text();
impl_->render(); impl_->render();
@ -578,7 +578,7 @@ namespace nana
} }
} }
void drawer::resized(graph_reference graph, const arg_resized& arg) void drawer::resized(graph_reference, const arg_resized&)
{ {
impl_->reset_text_area(); impl_->reset_text_area();
impl_->render(); impl_->render();

View File

@ -43,7 +43,7 @@ namespace nana
: public item_renderer : public item_renderer
{ {
private: private:
virtual void background(graph_reference graph, const nana::rectangle& r, const ::nana::color& bgcolor) virtual void background(graph_reference graph, const nana::rectangle&, const ::nana::color& bgcolor)
{ {
if(bgcolor_ != bgcolor) if(bgcolor_ != bgcolor)
{ {
@ -59,7 +59,6 @@ namespace nana
virtual void item(graph_reference graph, const item_t& m, bool active, state_t sta) virtual void item(graph_reference graph, const item_t& m, bool active, state_t sta)
{ {
//*
const nana::rectangle & r = m.r; const nana::rectangle & r = m.r;
color bgcolor; color bgcolor;
color blcolor; color blcolor;
@ -961,7 +960,8 @@ namespace nana
auto bgcolor = API::bgcolor(basis_.wd); auto bgcolor = API::bgcolor(basis_.wd);
auto fgcolor = API::fgcolor(basis_.wd); auto fgcolor = API::fgcolor(basis_.wd);
item_renderer::item_t m{ ::nana::rectangle{ basis_.graph->size() } }; item_renderer::item_t m;
m.r = ::nana::rectangle{ basis_.graph->size() };
basis_.renderer->background(*basis_.graph, m.r, bgcolor); basis_.renderer->background(*basis_.graph, m.r, bgcolor);

View File

@ -88,7 +88,7 @@ namespace drawerbase {
editor_ = nullptr; editor_ = nullptr;
} }
void drawer::refresh(graph_reference graph) void drawer::refresh(graph_reference)
{ {
editor_->render(API::is_focus_ready(*widget_)); editor_->render(API::is_focus_ready(*widget_));
} }
@ -121,7 +121,7 @@ namespace drawerbase {
API::lazy_refresh(); API::lazy_refresh();
} }
void drawer::mouse_up(graph_reference graph, const arg_mouse& arg) void drawer::mouse_up(graph_reference, const arg_mouse& arg)
{ {
if(editor_->mouse_pressed(arg)) if(editor_->mouse_pressed(arg))
API::lazy_refresh(); API::lazy_refresh();

View File

@ -82,8 +82,12 @@ namespace nana
if (t.joinable()) if (t.joinable())
t.join(); t.join();
#else #else
pump(); static_cast<void>(wait);
static_cast<void>(wait_end);
static_cast<void>(f); //to eliminte unused parameter compiler warning.
pump();
#endif #endif
} }
}//end namespace nana }//end namespace nana

View File

@ -867,7 +867,7 @@ namespace paint
::DeleteObject(hBmp); ::DeleteObject(hBmp);
::DeleteDC(hdcMem); ::DeleteDC(hdcMem);
#elif defined(NANA_X11) #elif defined(NANA_X11)
static_cast<void>(file_utf8); //eliminate unused parameter compil warning.
#endif #endif
} }
} }
@ -1201,6 +1201,10 @@ namespace paint
if(solid) if(solid)
rectangle(::nana::rectangle(r).pare_off(1), true, solid_clr); rectangle(::nana::rectangle(r).pare_off(1), true, solid_clr);
} }
//eliminate unused parameter compiler warning.
static_cast<void>(radius_x);
static_cast<void>(radius_y);
#endif #endif
} }
} }

View File

@ -73,7 +73,8 @@ namespace paint
return true; return true;
} }
#else #else
if(is_ico_){} //kill the unused compiler warning in Linux. static_cast<void>(is_ico_); //eliminate the unused compiler warning in Linux.
static_cast<void>(file); //to eliminate the unused parameter compiler warning.
#endif #endif
return false; return false;
} }
@ -98,7 +99,9 @@ namespace paint
} }
} }
#else #else
if(is_ico_){} //kill the unused compiler warning in Linux. static_cast<void>(is_ico_); //kill the unused compiler warning in Linux.
static_cast<void>(data); //to eliminate unused parameter compiler warning.
static_cast<void>(bytes);
#endif #endif
return false; return false;
} }
@ -129,6 +132,9 @@ namespace paint
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
::DrawIconEx(graph.handle()->context, p_dst.x, p_dst.y, *ptr_, src_r.width, src_r.height, 0, 0, DI_NORMAL); ::DrawIconEx(graph.handle()->context, p_dst.x, p_dst.y, *ptr_, src_r.width, src_r.height, 0, 0, DI_NORMAL);
#else
static_cast<void>(src_r); //eliminate unused parameter compiler warning.
static_cast<void>(p_dst);
#endif #endif
} }
} }
@ -139,6 +145,8 @@ namespace paint
{ {
#if defined(NANA_WINDOWS) #if defined(NANA_WINDOWS)
::DrawIconEx(graph.handle()->context, r.x, r.y, *ptr_, r.width, r.height, 0, 0, DI_NORMAL); ::DrawIconEx(graph.handle()->context, r.x, r.y, *ptr_, r.width, r.height, 0, 0, DI_NORMAL);
#else
static_cast<void>(r); //eliminate unused parameter compiler warning.
#endif #endif
} }
} }

View File

@ -977,7 +977,7 @@ namespace nana{ namespace paint
} }
} }
void pixel_buffer::gradual_rectangle(const ::nana::rectangle& draw_rct, const ::nana::color& from, const ::nana::color& to, double fade_rate, bool vertical) void pixel_buffer::gradual_rectangle(const ::nana::rectangle& draw_rct, const ::nana::color& from, const ::nana::color& to, double /*fade_rate*/, bool vertical)
{ {
auto sp = storage_.get(); auto sp = storage_.get();
if (nullptr == sp) return; if (nullptr == sp) return;

View File

@ -82,31 +82,35 @@ namespace nana{ namespace system{
// Bitmaps are huge, so to avoid unnegligible extra copy, this routine does not use private _m_set method. // Bitmaps are huge, so to avoid unnegligible extra copy, this routine does not use private _m_set method.
HGLOBAL h_gmem = ::GlobalAlloc(GHND | GMEM_SHARE, header_size + bitmap_bytes); HGLOBAL h_gmem = ::GlobalAlloc(GHND | GMEM_SHARE, header_size + bitmap_bytes);
void * gmem = ::GlobalLock(h_gmem); void * gmem = ::GlobalLock(h_gmem);
if (gmem) { if (gmem)
char* p = (char*)gmem; {
// Fix BITMAPINFOHEADER obtained from GetDIBits WinAPI char* p = (char*)gmem;
bmi.bmiHeader.biCompression = BI_RGB; // Fix BITMAPINFOHEADER obtained from GetDIBits WinAPI
bmi.bmiHeader.biHeight = ::abs(bmi.bmiHeader.biHeight); bmi.bmiHeader.biCompression = BI_RGB;
memcpy(p, &bmi, header_size); bmi.bmiHeader.biHeight = ::abs(bmi.bmiHeader.biHeight);
p += header_size; std::memcpy(p, &bmi, header_size);
// many programs do not support bottom-up DIB, so reversing row order is needed. p += header_size;
for (int y=0; y<bmi.bmiHeader.biHeight; ++y) { // many programs do not support bottom-up DIB, so reversing row order is needed.
memcpy(p, pbuffer.raw_ptr(bmi.bmiHeader.biHeight - 1 - y), bytes_per_line); for (int y=0; y<bmi.bmiHeader.biHeight; ++y)
p += bytes_per_line; {
} memcpy(p, pbuffer.raw_ptr(bmi.bmiHeader.biHeight - 1 - y), bytes_per_line);
if (::GlobalUnlock(h_gmem) || GetLastError() == NO_ERROR) p += bytes_per_line;
if (::OpenClipboard(::GetFocus())) }
if (::EmptyClipboard())
if (::SetClipboardData(CF_DIB, h_gmem)) if (::GlobalUnlock(h_gmem) || GetLastError() == NO_ERROR)
if (::CloseClipboard()) if (::OpenClipboard(::GetFocus()))
return true; if (::EmptyClipboard())
if (::SetClipboardData(CF_DIB, h_gmem))
if (::CloseClipboard())
return true;
} }
assert(false); assert(false);
::GlobalFree(h_gmem); ::GlobalFree(h_gmem);
return false; return false;
//#elif defined(NANA_X11) //#elif defined(NANA_X11)
#else #else
static_cast<void>(g); //eliminate unused parameter compiler warning.
throw "not implemented yet."; throw "not implemented yet.";
return false; return false;
#endif #endif

View File

@ -93,6 +93,7 @@ namespace system
return (::GetAsyncKeyState(button) != 0); return (::GetAsyncKeyState(button) != 0);
#elif defined(NANA_LINUX) || defined(NANA_MACOS) #elif defined(NANA_LINUX) || defined(NANA_MACOS)
static_cast<void>(button); //eliminate unused parameter compiler warning.
return false; return false;
#endif #endif
} }

View File

@ -54,7 +54,7 @@ namespace system
::FreeLibrary(reinterpret_cast<HMODULE>(handle)); ::FreeLibrary(reinterpret_cast<HMODULE>(handle));
#endif #endif
} }
}; //end struct shared_helper } //end namespace shared_helper
}//end namespace detail }//end namespace detail

View File

@ -584,7 +584,7 @@ namespace nana
_m_resolve_weak_types(); _m_resolve_weak_types();
_m_resolve_neutral_types(); _m_resolve_neutral_types();
_m_resolve_implicit_levels(); _m_resolve_implicit_levels();
_m_reordering_resolved_levels(str, reordered); _m_reordering_resolved_levels(reordered);
} }
unsigned unicode_bidi::_m_paragraph_level(const char_type * begin, const char_type * end) unsigned unicode_bidi::_m_paragraph_level(const char_type * begin, const char_type * end)
@ -885,7 +885,7 @@ namespace nana
} }
} }
void unicode_bidi::_m_reordering_resolved_levels(const char_type * str, std::vector<entity> & reordered) void unicode_bidi::_m_reordering_resolved_levels(std::vector<entity> & reordered)
{ {
reordered = levels_; reordered = levels_;