Fixed some syntax errors and clang compiling warnings

GCC/VS2013/Clang is tested
This commit is contained in:
cnjinhao 2015-01-03 22:04:06 +08:00
parent 1f559964f9
commit 0a5c85d21b
14 changed files with 150 additions and 161 deletions

View File

@ -44,7 +44,6 @@ namespace drawerbase
private: private:
static const int interval = 4; static const int interval = 4;
widget* widget_; widget* widget_;
unsigned state_;
std::unique_ptr<implement> imptr_; std::unique_ptr<implement> imptr_;
implement * impl_; implement * impl_;
}; };

View File

@ -58,7 +58,7 @@ namespace nana
bool _m_get_trace(point, int & res); bool _m_get_trace(point, int & res);
void _m_perf_transform(transform_action tfid, graph_reference, graph_reference dirtybuf, graph_reference newbuf, const nana::point& refpos); void _m_perf_transform(transform_action tfid, graph_reference, graph_reference dirtybuf, graph_reference newbuf, const nana::point& refpos);
private: private:
void refresh(graph_reference); void refresh(graph_reference) override;
void attached(widget_reference, graph_reference) override; void attached(widget_reference, graph_reference) override;
void mouse_move(graph_reference, const arg_mouse&) override; void mouse_move(graph_reference, const arg_mouse&) override;
void mouse_leave(graph_reference, const arg_mouse&) override; void mouse_leave(graph_reference, const arg_mouse&) override;

View File

@ -44,7 +44,6 @@ namespace nana
widget * widget_; widget * widget_;
nana::paint::graphics* graph_; nana::paint::graphics* graph_;
unsigned draw_width_; unsigned draw_width_;
bool has_value_;
bool unknown_; bool unknown_;
unsigned max_; unsigned max_;
unsigned value_; unsigned value_;

View File

@ -180,7 +180,7 @@ namespace nana
return false; return false;
} }
private: private:
void attached(widget_reference widget, graph_reference graph) void attached(widget_reference widget, graph_reference graph) override
{ {
graph_ = &graph; graph_ = &graph;
widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget); widget_ = static_cast< ::nana::scroll<Vertical>*>(&widget);
@ -190,12 +190,12 @@ namespace nana
timer_.elapse(std::bind(&trigger::_m_tick, this)); timer_.elapse(std::bind(&trigger::_m_tick, this));
} }
void detached() void detached() override
{ {
graph_ = nullptr; graph_ = nullptr;
} }
void refresh(graph_reference graph) void refresh(graph_reference graph) override
{ {
drawer_.draw(graph, metrics_.what); drawer_.draw(graph, metrics_.what);
} }
@ -213,7 +213,7 @@ namespace nana
API::lazy_refresh(); API::lazy_refresh();
} }
void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) void mouse_move(graph_reference graph, const ::nana::arg_mouse& arg) override
{ {
bool redraw = false; bool redraw = false;
if(metrics_.pressed && (metrics_.what == buttons::scroll)) if(metrics_.pressed && (metrics_.what == buttons::scroll))
@ -240,7 +240,7 @@ namespace nana
} }
} }
void mouse_down(graph_reference graph, const arg_mouse& arg) void mouse_down(graph_reference graph, const arg_mouse& arg) override
{ {
if(arg.left_button) if(arg.left_button)
{ {
@ -275,7 +275,7 @@ namespace nana
} }
} }
void mouse_up(graph_reference graph, const arg_mouse& arg) void mouse_up(graph_reference graph, const arg_mouse& arg) override
{ {
timer_.stop(); timer_.stop();
@ -287,7 +287,7 @@ namespace nana
API::lazy_refresh(); API::lazy_refresh();
} }
void mouse_leave(graph_reference graph, const arg_mouse&) void mouse_leave(graph_reference graph, const arg_mouse&) override
{ {
if(metrics_.pressed) return; if(metrics_.pressed) return;
@ -296,7 +296,7 @@ namespace nana
API::lazy_refresh(); API::lazy_refresh();
} }
void mouse_wheel(graph_reference graph, const arg_wheel& arg) void mouse_wheel(graph_reference graph, const arg_wheel& arg) override
{ {
if(make_step(arg.upwards == false, 3)) if(make_step(arg.upwards == false, 3))
{ {

View File

@ -45,9 +45,7 @@ namespace nana{ namespace widgets{ namespace skeletons
tokenizer(const nana::string& s, bool format_enabled) tokenizer(const nana::string& s, bool format_enabled)
: iptr_(s.data()), : iptr_(s.data()),
endptr_(s.data() + s.size()), endptr_(s.data() + s.size()),
format_enabled_(format_enabled), format_enabled_(format_enabled)
format_state_(false),
revert_token_(token::eof)
{ {
} }
@ -414,17 +412,14 @@ namespace nana{ namespace widgets{ namespace skeletons
} }
} }
private: private:
const nana::char_t * iptr_; const ::nana::char_t * iptr_;
const nana::char_t * endptr_; const ::nana::char_t * endptr_;
const bool format_enabled_; const bool format_enabled_;
bool format_state_; bool format_state_{false};
nana::string idstr_; ::nana::string idstr_;
std::pair<nana::string, nana::string> binary_; std::pair<nana::string, nana::string> binary_;
token revert_token_{token::eof};
std::size_t whspace_size_;
token revert_token_;
}; };
//The fblock states a format, and a format from which it is inherted //The fblock states a format, and a format from which it is inherted
@ -528,7 +523,7 @@ namespace nana{ namespace widgets{ namespace skeletons
{ {
public: public:
data_image(const nana::string& imgpath, const nana::size & sz, std::size_t limited) data_image(const nana::string& imgpath, const nana::size & sz, std::size_t limited)
: image_(imgpath), limited_(limited) : image_(imgpath)//, limited_(limited)
{ {
size_ = image_.size(); size_ = image_.size();
@ -597,7 +592,6 @@ namespace nana{ namespace widgets{ namespace skeletons
nana::string str_; nana::string str_;
nana::paint::image image_; nana::paint::image image_;
nana::size size_; nana::size size_;
std::size_t limited_;
}; };
class dstream class dstream
@ -928,7 +922,6 @@ namespace nana{ namespace widgets{ namespace skeletons
} }
private: private:
bool format_enabled_;
std::vector<fblock*> fblocks_; std::vector<fblock*> fblocks_;
std::list<std::deque<value> > lines_; std::list<std::deque<value> > lines_;

View File

@ -200,7 +200,7 @@ namespace nana
} }
} }
general_events& _m_get_general_events() const general_events& _m_get_general_events() const override
{ {
return *events_; return *events_;
} }
@ -275,7 +275,7 @@ namespace nana
} }
} }
general_events& _m_get_general_events() const general_events& _m_get_general_events() const override
{ {
return *events_; return *events_;
} }
@ -404,7 +404,7 @@ namespace nana
API::dev::attach_drawer(*this, trigger_); API::dev::attach_drawer(*this, trigger_);
} }
general_events& _m_get_general_events() const general_events& _m_get_general_events() const override
{ {
return *events_; return *events_;
} }
@ -487,7 +487,7 @@ namespace nana
} }
} }
general_events& _m_get_general_events() const general_events& _m_get_general_events() const override
{ {
return *events_; return *events_;
} }

View File

@ -127,7 +127,7 @@ namespace nana
class arg_eval; class arg_eval;
template<typename Return> template<typename Return>
class arg_function class arg_function: public eval_arg
{ {
public: public:
arg_function(std::function<Return()> fn) arg_function(std::function<Return()> fn)
@ -208,4 +208,4 @@ namespace nana
};//end class i18n_eval; };//end class i18n_eval;
} }
#endif//NANA_I18N_HPP #endif//NANA_I18N_HPP

View File

@ -49,13 +49,13 @@ namespace nana
void trigger::week_name(unsigned index, const nana::string& str) void trigger::week_name(unsigned index, const nana::string& str)
{ {
if(0 <= index && index < 7) if(index < 7)
this->weekstr_[index] = str; this->weekstr_[index] = str;
} }
void trigger::month_name(unsigned index, const nana::string& str) void trigger::month_name(unsigned index, const nana::string& str)
{ {
if(0 <= index && index < 12) if(index < 12)
this->monthstr_[index] = str; this->monthstr_[index] = str;
} }

View File

@ -3023,7 +3023,7 @@ namespace nana
item_proxy & item_proxy::bgcolor(nana::color_t col) item_proxy & item_proxy::bgcolor(nana::color_t col)
{ {
cat_->items.at(pos_.item).flags.selected; cat_->items.at(pos_.item).bgcolor = col;
ess_->update(); ess_->update();
return *this; return *this;
} }

View File

@ -19,7 +19,7 @@ namespace nana
{ {
//class trigger //class trigger
trigger::trigger() trigger::trigger()
: graph_(nullptr), draw_width_(static_cast<unsigned>(-1)), has_value_(true), : graph_(nullptr), draw_width_(static_cast<unsigned>(-1)),
unknown_(false), max_(100), value_(0) unknown_(false), max_(100), value_(0)
{} {}

View File

@ -664,7 +664,7 @@ namespace nana{ namespace widgets
pre_calc_line(i, pixels); pre_calc_line(i, pixels);
} }
std::size_t take_lines() const std::size_t take_lines() const override
{ {
std::size_t lines = 0; std::size_t lines = 0;
for (auto & mtr : linemtr_) for (auto & mtr : linemtr_)
@ -673,7 +673,7 @@ namespace nana{ namespace widgets
return lines; return lines;
} }
std::size_t take_lines(std::size_t pos) const std::size_t take_lines(std::size_t pos) const override
{ {
return (pos < linemtr_.size() ? linemtr_[pos].take_lines : 0); return (pos < linemtr_.size() ? linemtr_[pos].take_lines : 0);
} }

View File

@ -25,53 +25,138 @@ namespace nana
{ {
typedef trigger::node_type node_type; typedef trigger::node_type node_type;
bool no_sensitive_compare(const nana::string& text, const nana::char_t *pattern, std::size_t len) bool no_sensitive_compare(const nana::string& text, const nana::char_t *pattern, std::size_t len)
{
if(len <= text.length())
{ {
if(len <= text.length()) const nana::char_t * s = text.c_str();
for(std::size_t i = 0; i < len; ++i)
{ {
const nana::char_t * s = text.c_str(); if('a' <= s[i] && s[i] <= 'z')
for(std::size_t i = 0; i < len; ++i)
{ {
if('a' <= s[i] && s[i] <= 'z') if(pattern[i] != s[i] - ('a' - 'A'))
{ return false;
if(pattern[i] != s[i] - ('a' - 'A'))
return false;
}
else
if(pattern[i] != s[i]) return false;
} }
return true; else
if(pattern[i] != s[i]) return false;
}
return true;
}
return false;
}
const node_type* find_track_child_node(const node_type* node, const node_type * end, const nana::char_t* pattern, std::size_t len, bool &finish)
{
if(node->value.second.expanded)
{
node = node->child;
while(node)
{
if(no_sensitive_compare(node->value.second.text, pattern, len)) return node;
if(node == end) break;
if(node->value.second.expanded)
{
auto t = find_track_child_node(node, end, pattern, len, finish);
if(t || finish)
return t;
}
node = node->next;
} }
return false;
} }
const node_type* find_track_child_node(const node_type* node, const node_type * end, const nana::char_t* pattern, std::size_t len, bool &finish) finish = (node && (node == end));
return nullptr;
}
class tlwnd_drawer
: public drawer_trigger, public compset_interface
{
public:
typedef drawer_trigger::graph_reference graph_reference;
void assign(const item_attribute_t & item_attr, const pat::cloneable<renderer_interface>* renderer, const pat::cloneable<compset_placer_interface> * compset_placer)
{ {
if(node->value.second.expanded) if(renderer && compset_placer)
{ {
node = node->child; renderer_ = *renderer;
placer_ = *compset_placer;
while(node) item_attr_ = item_attr;
{
if(no_sensitive_compare(node->value.second.text, pattern, len)) return node;
if(node == end) break; _m_draw();
if(node->value.second.expanded)
{
auto t = find_track_child_node(node, end, pattern, len, finish);
if(t || finish)
return t;
}
node = node->next;
}
} }
}
private:
void _m_draw()
{
item_r_.x = item_r_.y = 0;
item_r_.width = placer_->item_width(*this->graph_, item_attr_);
item_r_.height = placer_->item_height(*this->graph_);
finish = (node && (node == end)); comp_attribute_t attr;
return nullptr; if(comp_attribute(component::text, attr))
{
nana::paint::graphics item_graph(item_r_.width, item_r_.height);
item_graph.typeface(graph_->typeface());
auto bgcolor = widget_->background();
auto fgcolor = widget_->foreground();
renderer_->bground(item_graph, bgcolor, fgcolor, this);
renderer_->expander(item_graph, bgcolor, fgcolor, this);
renderer_->crook(item_graph, bgcolor, fgcolor, this);
renderer_->icon(item_graph, bgcolor, fgcolor, this);
renderer_->text(item_graph, bgcolor, fgcolor, this);
item_graph.paste(attr.area, *graph_, 1, 1);
graph_->rectangle(0x0, false);
}
}
private:
// Implementation of drawer_trigger
void attached(widget_reference wd, graph_reference graph) override
{
widget_ = &wd;
graph_ = &graph;
graph.typeface(widget_->typeface());
}
private:
// Implementation of compset_interface
virtual const item_attribute_t& item_attribute() const override
{
return item_attr_;
} }
class tooltip_window; virtual bool comp_attribute(component_t comp, comp_attribute_t& comp_attr) const override
{
comp_attr.area = item_r_;
return placer_->locate(comp, item_attr_, &comp_attr.area);
}
private:
::nana::paint::graphics * graph_;
::nana::pat::cloneable<renderer_interface> renderer_;
::nana::pat::cloneable<compset_placer_interface> placer_;
widget *widget_;
item_attribute_t item_attr_;
nana::rectangle item_r_;
};//end class tlwnd_drawer
class tooltip_window
: public widget_object<category::root_tag, tlwnd_drawer>
{
public:
tooltip_window(window wd, const rectangle& r)
: widget_object<category::root_tag, tlwnd_drawer>(wd, false, rectangle(r).pare_off(-1), appear::bald<appear::floating>())
{
API::take_active(handle(), false, nullptr);
}
drawer_trigger_t & impl()
{
return get_drawer_trigger();
}
};//end class tooltip_window
//item_locator should be defined before the definition of basic_implement //item_locator should be defined before the definition of basic_implement
class trigger::item_locator class trigger::item_locator
@ -1355,95 +1440,6 @@ namespace nana
//Treebox Implementation //Treebox Implementation
namespace treebox namespace treebox
{ {
class tlwnd_drawer
: public drawer_trigger, public compset_interface
{
public:
typedef drawer_trigger::graph_reference graph_reference;
void assign(const item_attribute_t & item_attr, const pat::cloneable<renderer_interface>* renderer, const pat::cloneable<compset_placer_interface> * compset_placer)
{
if(renderer && compset_placer)
{
renderer_ = *renderer;
placer_ = *compset_placer;
item_attr_ = item_attr;
_m_draw();
}
}
private:
void _m_draw()
{
item_r_.x = item_r_.y = 0;
item_r_.width = placer_->item_width(*this->graph_, item_attr_);
item_r_.height = placer_->item_height(*this->graph_);
comp_attribute_t attr;
if(comp_attribute(component::text, attr))
{
nana::paint::graphics item_graph(item_r_.width, item_r_.height);
item_graph.typeface(graph_->typeface());
auto bgcolor = widget_->background();
auto fgcolor = widget_->foreground();
renderer_->bground(item_graph, bgcolor, fgcolor, this);
renderer_->expander(item_graph, bgcolor, fgcolor, this);
renderer_->crook(item_graph, bgcolor, fgcolor, this);
renderer_->icon(item_graph, bgcolor, fgcolor, this);
renderer_->text(item_graph, bgcolor, fgcolor, this);
item_graph.paste(attr.area, *graph_, 1, 1);
graph_->rectangle(0x0, false);
}
}
private:
// Implementation of drawer_trigger
void attached(widget_reference wd, graph_reference graph) override
{
widget_ = &wd;
graph_ = &graph;
graph.typeface(widget_->typeface());
}
private:
// Implementation of compset_interface
virtual const item_attribute_t& item_attribute() const override
{
return item_attr_;
}
virtual bool comp_attribute(component_t comp, comp_attribute_t& comp_attr) const override
{
comp_attr.area = item_r_;
return placer_->locate(comp, item_attr_, &comp_attr.area);
}
private:
::nana::paint::graphics * graph_;
::nana::pat::cloneable<renderer_interface> renderer_;
::nana::pat::cloneable<compset_placer_interface> placer_;
widget *widget_;
item_attribute_t item_attr_;
nana::rectangle item_r_;
};//end class tlwnd_drawer
class tooltip_window
: public widget_object<category::root_tag, tlwnd_drawer>
{
public:
tooltip_window(window wd, const rectangle& r)
: widget_object<category::root_tag, tlwnd_drawer>(wd, false, rectangle(r).pare_off(-1), appear::bald<appear::floating>())
{
API::take_active(handle(), false, nullptr);
}
drawer_trigger_t & impl()
{
return get_drawer_trigger();
}
};//end class tooltip_window
//class trigger //class trigger
//struct treebox_node_type //struct treebox_node_type
trigger::treebox_node_type::treebox_node_type() trigger::treebox_node_type::treebox_node_type()

View File

@ -1,6 +1,7 @@
/* /*
* Paint Image Implementation * Paint Image Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com) * Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2015 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
@ -62,6 +63,8 @@ namespace paint
::DeleteObject(info.hbmMask); ::DeleteObject(info.hbmMask);
return true; return true;
} }
#else
if(is_ico_){} //kill the unused compiler warning in Linux.
#endif #endif
return false; return false;
} }

View File

@ -958,8 +958,7 @@ namespace nana
unsigned level_of_run = begin_character->level; unsigned level_of_run = begin_character->level;
bool head_of_run = true; bool head_of_run = true;
std::vector<entity>::iterator last = end - 1; auto begin_neutral = end;
std::vector<entity>::iterator begin_neutral = end;
//N1. A sequence of neutrals takes the direction of the surrounding strong text if the text on both sides has the same direction. //N1. A sequence of neutrals takes the direction of the surrounding strong text if the text on both sides has the same direction.
//European and Arabic numbers act as if they were R in terms of their influence on neutrals. //European and Arabic numbers act as if they were R in terms of their influence on neutrals.