remove macro STR

This commit is contained in:
Jinhao
2015-11-29 22:38:22 +08:00
parent 12358a5dc0
commit c86a00bea5
31 changed files with 410 additions and 331 deletions

View File

@@ -202,7 +202,7 @@ namespace nana{
if(owner && (nested == false))
::ClientToScreen(reinterpret_cast<HWND>(owner), &pt);
HWND native_wd = ::CreateWindowEx(style_ex, STR("NanaWindowInternal"), STR("Nana Window"),
HWND native_wd = ::CreateWindowEx(style_ex, L"NanaWindowInternal", L"Nana Window",
style,
pt.x, pt.y, 100, 100,
reinterpret_cast<HWND>(owner), 0, ::GetModuleHandle(0), 0);
@@ -377,8 +377,8 @@ namespace nana{
if(nullptr == parent) return nullptr;
#if defined(NANA_WINDOWS)
HWND handle = ::CreateWindowEx(WS_EX_CONTROLPARENT, // Extended possibilites for variation
STR("NanaWindowInternal"),
STR("Nana Child Window"), // Title Text
L"NanaWindowInternal",
L"Nana Child Window", // Title Text
WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_CLIPSIBLINGS,
r.x, r.y, r.width, r.height,
reinterpret_cast<HWND>(parent), // The window is a child-window to desktop

View File

@@ -214,7 +214,7 @@ namespace detail
WNDCLASSEX wincl;
wincl.hInstance = ::GetModuleHandle(0);
wincl.lpszClassName = STR("NanaWindowInternal");
wincl.lpszClassName = L"NanaWindowInternal";
wincl.lpfnWndProc = &Bedrock_WIN32_WindowProc;
wincl.style = CS_DBLCLKS | CS_OWNDC;
wincl.cbSize = sizeof(wincl);
@@ -1175,7 +1175,7 @@ namespace detail
{
arg_dropfiles dropfiles;
std::unique_ptr<nana::char_t[]> varbuf;
std::unique_ptr<wchar_t[]> varbuf;
std::size_t bufsize = 0;
unsigned size = ::DragQueryFile(drop, 0xFFFFFFFF, 0, 0);
@@ -1189,7 +1189,8 @@ namespace detail
}
::DragQueryFile(drop, i, varbuf.get(), reqlen);
dropfiles.files.emplace_back(varbuf.get());
dropfiles.files.emplace_back(utf8_cast(varbuf.get()));
}
while(msgwnd && (msgwnd->flags.dropable == false))

View File

@@ -105,7 +105,7 @@ namespace nana
arrow.draw(graph, {}, style_.fgcolor, arrow_r, element_state::normal);
}
void item(graph_reference graph, const nana::rectangle& r, std::size_t index, const nana::string& name, unsigned txtheight, bool has_child, mouse_action state)
void item(graph_reference graph, const nana::rectangle& r, std::size_t index, const std::string& name_utf8, unsigned txtheight, bool has_child, mouse_action state)
{
nana::point strpos(r.x + 5, r.y + static_cast<int>(r.height - txtheight) / 2);
@@ -141,7 +141,7 @@ namespace nana
_m_item_bground(graph, r.x + 1, top, width, height, state_name);
graph.rectangle(r, false, clr);
}
graph.string(strpos, name, style_.fgcolor);
graph.string(strpos, name_utf8, style_.fgcolor);
if(has_child)
{
@@ -218,7 +218,7 @@ namespace nana
using node_handle = container::node_type*;
tree_wrapper()
:splitstr_(STR("\\")), cur_(nullptr)
: splitstr_("\\")
{}
bool seq(std::size_t index, std::vector<node_handle> & seqv) const
@@ -234,23 +234,23 @@ namespace nana
return false;
}
void splitstr(const nana::string& ss)
void splitstr(const std::string& ss)
{
if(ss.size())
splitstr_ = ss;
}
const nana::string& splitstr() const
const std::string& splitstr() const
{
return splitstr_;
}
nana::string path() const
std::string path() const
{
std::vector<node_handle> v;
_m_read_node_path(v);
nana::string str;
std::string str;
bool not_head = false;
for(auto i : v)
{
@@ -263,7 +263,7 @@ namespace nana
return str;
}
void path(const nana::string& key)
void path(const std::string& key)
{
cur_ = tree_.ref(key);
}
@@ -292,7 +292,7 @@ namespace nana
cur_ = i;
}
void insert(const nana::string& name, const nana::any& value)
void insert(const std::string& name, const nana::any& value)
{
item_tag m;
m.pixels = 0;
@@ -300,7 +300,7 @@ namespace nana
cur_ = tree_.insert(cur_, name, m);
}
bool childset(const nana::string& name, const nana::any& value)
bool childset(const std::string& name, const nana::any& value)
{
if(cur_)
{
@@ -313,7 +313,7 @@ namespace nana
return false;
}
bool childset_erase(const nana::string& name)
bool childset_erase(const std::string& name)
{
if(cur_)
{
@@ -329,7 +329,7 @@ namespace nana
return false;
}
node_handle find_child(const nana::string& name) const
node_handle find_child(const std::string& name) const
{
if(cur_)
{
@@ -360,8 +360,8 @@ namespace nana
}
private:
container tree_;
nana::string splitstr_;
node_handle cur_;
std::string splitstr_ ;
node_handle cur_{ nullptr };
};
//class scheme
@@ -543,7 +543,7 @@ namespace nana
{
if(node)
{
API::dev::window_caption(window_handle(), utf8_cast(tree().path()));
API::dev::window_caption(window_handle(), tree().path());
if(evt_holder_.selected)
evt_holder_.selected(node->value.second.value);
}
@@ -565,7 +565,7 @@ namespace nana
if(i)
{
for(node_handle child = i->child; child; child = child->next)
style_.module.items.emplace_back(std::make_shared<item>(utf8_cast(child->value.first)));
style_.module.items.emplace_back(std::make_shared<item>(child->value.first));
}
r = style_.active_item_rectangle;
}
@@ -576,7 +576,7 @@ namespace nana
{
auto end = v.cbegin() + head_;
for(auto i = v.cbegin(); i != end; ++i)
style_.module.items.emplace_back(std::make_shared<item>(utf8_cast((*i)->value.first)));
style_.module.items.emplace_back(std::make_shared<item>((*i)->value.first));
}
r = style_.active_item_rectangle;
}
@@ -603,8 +603,7 @@ namespace nana
case ui_element::item_arrow:
{
treebase_.tail(style_.active);
nana::string name = utf8_cast(style_.module.items[style_.module.index]->text());
node_handle node = treebase_.find_child(name);
node_handle node = treebase_.find_child(style_.module.items[style_.module.index]->text());
if(node)
{
treebase_.cur(node);
@@ -769,7 +768,6 @@ namespace nana
private:
window window_{nullptr};
nana::paint::graphics * graph_{nullptr};
nana::string splitstr_;
std::size_t head_;
unsigned item_height_;
std::size_t item_lines_;
@@ -808,14 +806,14 @@ namespace nana
void trigger::insert(const std::string& str, nana::any value)
{
throw_not_utf8(str);
scheme_->tree().insert(utf8_cast(str), value);
API::dev::window_caption(scheme_->window_handle(), utf8_cast(scheme_->tree().path()));
scheme_->tree().insert(str, value);
API::dev::window_caption(scheme_->window_handle(), scheme_->tree().path());
scheme_->draw();
}
bool trigger::childset(const std::string& str, nana::any value)
{
if(scheme_->tree().childset(utf8_cast(str), value))
if(scheme_->tree().childset(str, value))
{
scheme_->draw();
return true;
@@ -825,7 +823,7 @@ namespace nana
bool trigger::childset_erase(const std::string& str)
{
if(scheme_->tree().childset_erase(utf8_cast(str)))
if(scheme_->tree().childset_erase(str))
{
scheme_->draw();
return true;
@@ -843,24 +841,24 @@ namespace nana
return false;
}
void trigger::splitstr(const nana::string& sstr)
void trigger::splitstr(const std::string& sstr)
{
scheme_->tree().splitstr(sstr);
}
const nana::string& trigger::splitstr() const
const std::string& trigger::splitstr() const
{
return scheme_->tree().splitstr();
}
void trigger::path(const std::string& str)
{
scheme_->tree().path(utf8_cast(str));
scheme_->tree().path(str);
}
std::string trigger::path() const
{
return utf8_cast(scheme_->tree().path());
return scheme_->tree().path();
}
nana::any& trigger::value() const

View File

@@ -49,7 +49,7 @@ namespace checkbox
{
_m_draw_background(graph);
_m_draw_title(graph);
_m_draw_checkbox(graph, graph.text_extent_size(STR("jN"), 2).height + 2);
_m_draw_checkbox(graph, graph.text_extent_size(L"jN", 2).height + 2);
}
void drawer::mouse_down(graph_reference graph, const arg_mouse&)

View File

@@ -109,7 +109,7 @@ namespace nana
unsigned item_pixels(graph_reference graph) const
{
return graph.text_extent_size(STR("jHWn/?\\{[(0569")).height + 4;
return graph.text_extent_size(L"jHWn/?\\{[(0569").height + 4;
}
};//end class item_renderer
@@ -325,7 +325,7 @@ namespace nana
_m_open_scrollbar(*widget_, pages);
}
else
graph_->string({ 4, 4 }, STR("Empty Listbox, No Module!"), static_cast<color_rgb>(0x808080));
graph_->string({ 4, 4 }, L"Empty Listbox, No Module!", static_cast<color_rgb>(0x808080));
//Draw border
graph_->rectangle(false, colors::black);

View File

@@ -82,7 +82,7 @@ namespace nana
nana::paint::font ft = graph.typeface(); //used for restoring the font
const unsigned def_line_pixels = graph.text_extent_size(STR(" "), 1).height;
const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
font_ = ft;
fblock_ = nullptr;
@@ -169,7 +169,7 @@ namespace nana
auto ft = graph.typeface(); //used for restoring the font
const unsigned def_line_pixels = graph.text_extent_size(STR(" "), 1).height;
const unsigned def_line_pixels = graph.text_extent_size(L" ", 1).height;
font_ = ft;
fblock_ = nullptr;

View File

@@ -3146,7 +3146,7 @@ namespace nana
graph->set_color(it_bgcolor); // litter rect with the item bg end ...
graph->rectangle(rectangle{ xpos, y + 2, essence_->suspension_width, essence_->item_size - 4 }, true);
graph->string(point{ xpos, y + 2 }, STR("..."));
graph->string(point{ xpos, y + 2 }, L"...");
//Erase the part that over the next subitem.
if (display_order + 1 < seqs.size()) // this is not the last column
@@ -3284,9 +3284,9 @@ namespace nana
void trigger::typeface_changed(graph_reference graph)
{
essence_->text_height = graph.text_extent_size(STR("jHWn0123456789/<?'{[|\\_")).height;
essence_->text_height = graph.text_extent_size(L"jHWn0123456789/<?'{[|\\_").height;
essence_->item_size = essence_->text_height + 6;
essence_->suspension_width = graph.text_extent_size(STR("...")).width;
essence_->suspension_width = graph.text_extent_size(L"...").width;
}
void trigger::refresh(graph_reference)
@@ -3581,7 +3581,7 @@ namespace nana
case keyboard::os_arrow_down:
essence_->lister.move_select(up, !arg.shift, true);
break;
case STR(' ') :
case L' ':
{
selection s;
bool ck = ! essence_->lister.item_selected_all_checked(s);

View File

@@ -363,7 +363,7 @@ namespace nana
unsigned strpixels = item_r.width - 60;
int text_top_off = (item_h_px - graph.text_extent_size(STR("jh({[")).height) / 2;
int text_top_off = (item_h_px - graph.text_extent_size(L"jh({[").height) / 2;
std::size_t pos = 0;
for (auto & m : menu_->items)

View File

@@ -442,7 +442,7 @@ namespace nana{ namespace widgets
bool adjusted_cond = true;
if (static_cast<int>(text_w) < points.offset.x)
{
auto delta_pixels = editor_._m_text_extent_size(STR(" "), 4).width;
auto delta_pixels = editor_._m_text_extent_size(L" ", 4).width;
points.offset.x = (text_w > delta_pixels ? text_w - delta_pixels : 0);
}
else if (area_w && (text_w >= points.offset.x + area_w))
@@ -1614,7 +1614,7 @@ namespace nana{ namespace widgets
unsigned text_editor::line_height() const
{
return (graph_ ? (graph_.text_extent_size(STR("jH{")).height) : 0);
return (graph_ ? (graph_.text_extent_size(L"jH{").height) : 0);
}
unsigned text_editor::screen_lines() const
@@ -1764,7 +1764,7 @@ namespace nana{ namespace widgets
str = textbase_.getline(0);
for(std::size_t i = 1; i < lines; ++i)
{
str += STR("\n\r");
str += L"\n\r";
str += textbase_.getline(i);
}
}
@@ -2756,11 +2756,11 @@ namespace nana{ namespace widgets
if(a.y != b.y)
{
text = textbase_.getline(a.y).substr(a.x);
text += STR("\r\n");
text += L"\r\n";
for(unsigned i = a.y + 1; i < b.y; ++i)
{
text += textbase_.getline(i);
text += STR("\r\n");
text += L"\r\n";
}
text += textbase_.getline(b.y).substr(0, b.x);
}
@@ -2801,7 +2801,7 @@ namespace nana{ namespace widgets
std::size_t begin = 0;
while (true)
{
auto pos = text.find_first_of(STR("\r\n"), begin);
auto pos = text.find_first_of(L"\r\n", begin);
if (text.npos == pos)
{
if (!lines.empty())
@@ -2813,7 +2813,7 @@ namespace nana{ namespace widgets
pos = eat_endl(text_str, pos);
begin = text.find_first_not_of(STR("\r\n"), pos);
begin = text.find_first_not_of(L"\r\n", pos);
//The number of new lines minus one
const auto chp_end = text_str + (begin == text.npos ? text.size() : begin);
@@ -3068,7 +3068,7 @@ namespace nana{ namespace widgets
keyword_parser parser;
parser.parse(linestr, keywords_.get());
auto whitespace_w = graph_.text_extent_size(STR(" "), 1).width;
auto whitespace_w = graph_.text_extent_size(L" ", 1).width;
const auto line_h_pixels = line_height();

View File

@@ -29,11 +29,11 @@ namespace nana
{
using node_type = trigger::node_type;
bool no_sensitive_compare(const nana::string& text, const nana::char_t *pattern, std::size_t len)
bool no_sensitive_compare(const std::string& text, const char *pattern, std::size_t len)
{
if(len <= text.length())
{
const nana::char_t * s = text.c_str();
auto s = text.c_str();
for(std::size_t i = 0; i < len; ++i)
{
if('a' <= s[i] && s[i] <= 'z')
@@ -49,7 +49,7 @@ namespace nana
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)
const node_type* find_track_child_node(const node_type* node, const node_type * end, const char* pattern, std::size_t len, bool &finish)
{
if(node->value.second.expanded)
{
@@ -217,7 +217,7 @@ namespace nana
nana::scroll<true> scroll;
std::size_t prev_first_value;
mutable std::map<nana::string, node_image_tag> image_table;
mutable std::map<std::string, node_image_tag> image_table;
tree_cont_type::node_type * first;
int indent_pixels;
@@ -241,7 +241,7 @@ namespace nana
struct track_node_tag
{
nana::string key_buf;
::std::string key_buf;
std::size_t key_time;
}track_node;
@@ -320,9 +320,9 @@ namespace nana
return false;
}
const trigger::node_type* find_track_node(nana::char_t key)
const trigger::node_type* find_track_node(wchar_t key)
{
nana::string pattern;
std::string pattern;
if('a' <= key && key <= 'z') key -= 'a' - 'A';
@@ -334,8 +334,18 @@ namespace nana
pattern = track_node.key_buf;
track_node.key_time = now;
pattern += key;
track_node.key_buf += key;
if (key <= 0x7f)
{
pattern += static_cast<char>(key);
track_node.key_buf += static_cast<char>(key);
}
else
{
wchar_t wstr[2] = { key, 0 };
pattern += utf8_cast(wstr);
track_node.key_buf += utf8_cast(wstr);
}
const node_type *begin = node_state.selected ? node_state.selected : attr.tree_cont.get_root()->child;
@@ -604,7 +614,7 @@ namespace nana
std::size_t visual_item_size() const
{
return attr.tree_cont.child_size_if(nana::string{}, pred_allow_child{});
return attr.tree_cont.child_size_if(std::string(), pred_allow_child{});
}
int visible_w_pixels() const
@@ -820,7 +830,7 @@ namespace nana
}
}
item_proxy item_proxy::append(const nana::string& key, nana::string name)
item_proxy item_proxy::append(const std::string& key, std::string name)
{
if(nullptr == trigger_ || nullptr == node_)
return item_proxy();
@@ -892,34 +902,34 @@ namespace nana
return *this;
}
const nana::string& item_proxy::icon() const
const std::string& item_proxy::icon() const
{
return node_->value.second.img_idstr;
}
item_proxy& item_proxy::icon(const nana::string& id)
item_proxy& item_proxy::icon(const std::string& id)
{
node_->value.second.img_idstr = id;
return *this;
}
item_proxy& item_proxy::key(const nana::string& kstr)
item_proxy& item_proxy::key(const std::string& kstr)
{
trigger_->rename(node_, kstr.data(), nullptr);
return *this;
}
const nana::string& item_proxy::key() const
const std::string& item_proxy::key() const
{
return node_->value.first;
}
const nana::string& item_proxy::text() const
const std::string& item_proxy::text() const
{
return node_->value.second.text;
}
item_proxy& item_proxy::text(const nana::string& id)
item_proxy& item_proxy::text(const std::string& id)
{
trigger_->rename(node_, nullptr, id.data());
return *this;
@@ -973,27 +983,19 @@ namespace nana
return end();
}
bool item_proxy::operator==(const nana::string& s) const
bool item_proxy::operator==(const std::string& s) const
{
return (node_ && (node_->value.second.text == s));
}
bool item_proxy::operator==(const char* s) const
{
#if defined(NANA_UNICODE)
return (node_ && (node_->value.second.text == nana::string(nana::charset(s))));
#else
return (node_ && s && (node_->value.second.text == s));
#endif
return (node_ && (node_->value.second.text == s));
}
bool item_proxy::operator==(const wchar_t* s) const
{
#if defined(NANA_UNICODE)
return (node_ && s && (node_->value.second.text == s));
#else
return (node_ && (node_->value.second.text == nana::string(nana::charset(s))));
#endif
return (node_ && s && (node_->value.second.text == utf8_cast(s)));
}
// Behavior of Iterator
@@ -1114,7 +1116,7 @@ namespace nana
virtual unsigned item_height(graph_reference graph) const override
{
return graph.text_extent_size(STR("jH{"), 3).height + 8;
return graph.text_extent_size(L"jH{", 3).height + 8;
}
virtual unsigned item_width(graph_reference graph, const item_attribute_t& attr) const override
@@ -1468,7 +1470,7 @@ namespace nana
:expanded(false), checked(checkstate::unchecked)
{}
trigger::treebox_node_type::treebox_node_type(nana::string text)
trigger::treebox_node_type::treebox_node_type(std::string text)
:text(std::move(text)), expanded(false), checked(checkstate::unchecked)
{}
@@ -1702,7 +1704,7 @@ namespace nana
return node->value.second.value;
}
trigger::node_type* trigger::insert(node_type* node, const nana::string& key, nana::string&& title)
trigger::node_type* trigger::insert(node_type* node, const std::string& key, std::string&& title)
{
node_type * p = impl_->attr.tree_cont.node(node, key);
if(p)
@@ -1715,7 +1717,7 @@ namespace nana
return p;
}
trigger::node_type* trigger::insert(const nana::string& path, nana::string&& title)
trigger::node_type* trigger::insert(const std::string& path, std::string&& title)
{
auto x = impl_->attr.tree_cont.insert(path, treebox_node_type(std::move(title)));
if(x && impl_->attr.auto_draw && impl_->draw(true))
@@ -1781,7 +1783,7 @@ namespace nana
}
}
void trigger::set_expand(const nana::string& path, bool exp)
void trigger::set_expand(const std::string& path, bool exp)
{
if(impl_->set_expanded(impl_->attr.tree_cont.find(path), exp))
{
@@ -1790,7 +1792,7 @@ namespace nana
}
}
node_image_tag& trigger::icon(const nana::string& id) const
node_image_tag& trigger::icon(const std::string& id) const
{
auto i = impl_->shape.image_table.find(id);
if(i != impl_->shape.image_table.end())
@@ -1801,14 +1803,14 @@ namespace nana
return impl_->shape.image_table[id];
}
void trigger::icon_erase(const nana::string& id)
void trigger::icon_erase(const std::string& id)
{
impl_->shape.image_table.erase(id);
if(0 == impl_->shape.image_table.size())
impl_->data.comp_placer->enable(component::icon, false);
}
void trigger::node_icon(node_type* node, const nana::string& id)
void trigger::node_icon(node_type* node, const std::string& id)
{
if(tree().verify(node))
{
@@ -1826,7 +1828,7 @@ namespace nana
return impl_->data.comp_placer->item_width(*impl_->data.graph, node_attr);
}
bool trigger::rename(node_type *node, const nana::char_t* key, const nana::char_t* name)
bool trigger::rename(node_type *node, const char* key, const char* name)
{
if((key || name ) && tree().verify(node))
{
@@ -2194,28 +2196,28 @@ namespace nana
return get_drawer_trigger().checkable();
}
treebox::node_image_type& treebox::icon(const nana::string& id) const
treebox::node_image_type& treebox::icon(const std::string& id) const
{
return get_drawer_trigger().icon(id);
}
void treebox::icon_erase(const nana::string& id)
void treebox::icon_erase(const std::string& id)
{
get_drawer_trigger().icon_erase(id);
}
auto treebox::find(const nana::string& keypath) -> item_proxy
auto treebox::find(const std::string& keypath) -> item_proxy
{
auto * trg = &get_drawer_trigger();
return item_proxy(trg, trg->tree().find(keypath));
}
treebox::item_proxy treebox::insert(const nana::string& path_key, nana::string title)
treebox::item_proxy treebox::insert(const std::string& path_key, std::string title)
{
return item_proxy(&get_drawer_trigger(), get_drawer_trigger().insert(path_key, std::move(title)));
}
treebox::item_proxy treebox::insert(item_proxy i, const nana::string& key, nana::string title)
treebox::item_proxy treebox::insert(item_proxy i, const std::string& key, std::string title)
{
return item_proxy(&get_drawer_trigger(), get_drawer_trigger().insert(i._m_node(), key, std::move(title)));
}
@@ -2227,22 +2229,22 @@ namespace nana
return next;
}
void treebox::erase(const nana::string& keypath)
void treebox::erase(const std::string& keypath)
{
auto i = find(keypath);
if(!i.empty())
get_drawer_trigger().remove(i._m_node());
}
nana::string treebox::make_key_path(item_proxy i, const nana::string& splitter) const
std::string treebox::make_key_path(item_proxy i, const std::string& splitter) const
{
auto & tree = get_drawer_trigger().tree();
auto pnode = i._m_node();
if(tree.verify(pnode))
{
auto root = tree.get_root();
nana::string path;
nana::string temp;
std::string path;
std::string temp;
while(pnode->owner != root)
{
temp = splitter;