Merge branch 'hotfixes' into develop

Conflicts:
	include/nana/detail/linux_X11/platform_spec.hpp
	source/detail/linux_X11/platform_spec.cpp
	source/paint/detail/native_paint_interface.cpp
This commit is contained in:
cnjinhao 2015-01-02 23:54:55 +08:00
commit 4bc00f3517
11 changed files with 87 additions and 16 deletions

View File

@ -98,7 +98,7 @@ namespace detail
unsigned whitespace_pixels;
}string;
#if defined(NANA_UNICODE)
XftDraw * xftdraw;
XftDraw * xftdraw{nullptr};
XftColor xft_fgcolor;
const std::string charset(const nana::string& str, const std::string& strcode);
#endif
@ -138,6 +138,7 @@ namespace detail
Atom net_wm_state_maximized_horz;
Atom net_wm_state_maximized_vert;
Atom net_wm_state_modal;
Atom net_wm_name;
Atom net_wm_window_type;
Atom net_wm_window_type_normal;
Atom net_wm_window_type_utility;

View File

@ -102,12 +102,15 @@ namespace nana
: public widget_object<category::widget_tag, drawerbase::menubar::trigger>
{
public:
menubar(); ///< The default constructor delay creation.
menubar() = default; ///< The default constructor delay creation.
menubar(window); ///< Create a menubar at the top of the specified window.
~menubar();
void create(window); ///< Create a menubar at the top of the specified window.
menu& push_back(const nana::string&); ///< Appends a new (empty) menu.
menu& at(size_t index) const; ///< Gets the menu specified by index.
std::size_t length() const; ///< Number of menus.
private:
::nana::event_handle evt_resized_{nullptr};
};//end class menubar
}//end namespace nana
#endif

View File

@ -130,7 +130,9 @@ namespace nana
void load(nana::string file);
void store(nana::string file);
void store(nana::string file, nana::unicode encoding);
textbox& reset(nana::string = {}); ///< discard the old text and set a newtext
//A workaround for reset, explicit default constructor syntax, because VC2013 incorrectly treats {} as {0}.
textbox& reset(nana::string = nana::string()); ///< discard the old text and set a newtext
/// The file of last store operation.
nana::string filename() const;

View File

@ -799,16 +799,31 @@ namespace nana
switch(utf_x_)
{
case unicode::utf8:
#if defined(NANA_MINGW)
strbuf = detail::utf8_to_utf16(data_, true);
detail::put_utf16char(strbuf, 0, true);
#else
strbuf = detail::utf8_to_utf32(data_, true);
detail::put_utf32char(strbuf, 0, true);
#endif
break;
case unicode::utf16:
#if defined(NANA_MINGW)
strbuf = data_;
detail::put_utf16char(strbuf, 0, true);
#else
strbuf = detail::utf16_to_utf32(data_);
detail::put_utf32char(strbuf, 0, true);
#endif
break;
case unicode::utf32:
#if defined(NANA_MINGW)
strbuf = detail::utf32_to_utf16(data_);
detail::put_utf16char(strbuf, 0, true);
#else
strbuf = data_;
detail::put_utf32char(strbuf, 0, true);
#endif
break;
}
@ -892,13 +907,25 @@ namespace nana
switch(utf_x_)
{
case unicode::utf8:
#if defined(NANA_MINGW)
bytes = detail::utf8_to_utf16(data_, true);
#else
bytes = detail::utf8_to_utf32(data_, true);
#endif
break;
case unicode::utf16:
#if defined(NANA_MINGW)
bytes = data_;
#else
bytes = detail::utf16_to_utf32(data_);
#endif
break;
case unicode::utf32:
#if defined(NANA_MINGW)
bytes = detail::utf32_to_utf16(data_);
#else
bytes = data_;
#endif
break;
}
return std::wstring(reinterpret_cast<const wchar_t*>(bytes.c_str()), bytes.size() / sizeof(wchar_t));
@ -957,11 +984,23 @@ namespace nana
switch(encoding)
{
case unicode::utf8:
#if defined(NANA_MINGW)
return detail::utf16_to_utf8(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
#else
return detail::utf32_to_utf8(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
#endif
case unicode::utf16:
return detail::utf32_to_utf16(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
case unicode::utf32:
#if defined(NANA_MINGW)
return std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t));
#else
return detail::utf32_to_utf16(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
#endif
case unicode::utf32:
#if defined(NANA_MINGW)
return detail::utf16_to_utf32(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
#else
return std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t));
#endif
}
return {};
}

View File

@ -1,5 +1,6 @@
/*
* Platform Specification Implementation
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Nana Software License, Version 1.0.
@ -288,7 +289,6 @@ namespace detail
string.tab_pixels = 0;
string.whitespace_pixels = 0;
#if defined(NANA_UNICODE)
xftdraw = 0;
conv_.handle = ::iconv_open("UTF-8", "UTF-32");
conv_.code = "UTF-32";
#endif
@ -457,7 +457,7 @@ namespace detail
}
}
else
langstr_dup = "zh_CN.UTF-8";
langstr_dup = "en_US.UTF-8";
std::setlocale(LC_CTYPE, langstr_dup.c_str());
if(::XSupportsLocale())
::XSetLocaleModifiers(langstr_dup.c_str());
@ -479,6 +479,7 @@ namespace detail
atombase_.net_wm_state_maximized_horz = ::XInternAtom(display_, "_NET_WM_STATE_MAXIMIZED_HORZ", False);
atombase_.net_wm_state_maximized_vert = ::XInternAtom(display_, "_NET_WM_STATE_MAXIMIZED_VERT", False);
atombase_.net_wm_state_modal = ::XInternAtom(display_, "_NET_WM_STATE_MODAL", False);
atombase_.net_wm_name = ::XInternAtom(display_, "_NET_WM_NAME", False);
atombase_.net_wm_window_type = ::XInternAtom(display_, "_NET_WM_WINDOW_TYPE", False);
atombase_.net_wm_window_type_normal = ::XInternAtom(display_, "_NET_WM_WINDOW_TYPE_NORMAL", False);
atombase_.net_wm_window_type_utility = ::XInternAtom(display_, "_NET_WM_WINDOW_TYPE_UTILITY", False);

View File

@ -1,5 +1,6 @@
/*
* Platform Specification Selector
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Nana Software License, Version 1.0.
@ -9,7 +10,7 @@
* @file: nana/detail/platform_spec_selector.cpp
*
* This file is used to support the Nana project of some cross-platform IDE,
*
*
*/
#include <nana/config.hpp>

View File

@ -955,7 +955,7 @@ namespace detail
}
keybuf[len] = 0;
nana::char_t keychar;
nana::char_t keychar = 0;
switch(status)
{
case XLookupKeySym:
@ -984,8 +984,6 @@ namespace detail
keychar = keyboard::os_insert; break;
case XK_Delete:
keychar = keyboard::os_del; break;
default:
keychar = keysym;
}
context.platform.keychar = keychar;
if(keychar == keyboard::tab && (false == (msgwnd->flags.tab & detail::tab_type::eating))) //Tab
@ -1002,7 +1000,7 @@ namespace detail
{
context.is_alt_pressed = true;
}
else
else if(keychar)
{
arg_keyboard arg;
arg.ignore = false;
@ -1020,7 +1018,7 @@ namespace detail
}
case XLookupChars:
{
const nana::char_t * charbuf;
const ::nana::char_t* charbuf;
#if defined(NANA_UNICODE)
nana::detail::charset_conv charset("UTF-32", "UTF-8");
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));

View File

@ -1096,6 +1096,9 @@ namespace nana{
nana::detail::platform_scope_guard psg;
::XStringListToTextProperty(&text, 1, &name);
::XSetWMName(restrict::spec.open_display(), reinterpret_cast<Window>(wd), &name);
::XChangeProperty(restrict::spec.open_display(), reinterpret_cast<Window>(wd),
restrict::spec.atombase().net_wm_name, restrict::spec.atombase().utf8_string, 8,
PropModeReplace, reinterpret_cast<unsigned char*>(text), mbstr.size());
#endif
}

View File

@ -575,17 +575,27 @@ namespace nana
//class menubar
menubar::menubar(){}
menubar::menubar(window wd)
{
create(wd);
}
menubar::~menubar()
{
API::umake_event(evt_resized_);
}
void menubar::create(window wd)
{
widget_object<category::widget_tag, drawerbase::menubar::trigger>
::create(wd, rectangle(nana::size(API::window_size(wd).width, 28)));
API::attach_menubar(handle());
evt_resized_ = API::events(wd).resized([this](const ::nana::arg_resized& arg)
{
auto sz = this->size();
sz.width = arg.width;
this->size(sz);
});
}
menu& menubar::push_back(const nana::string& text)

View File

@ -1196,7 +1196,7 @@ namespace nana{ namespace widgets
undo(false);
break;
default:
if (key >= 0xFF || (32 <= key && key <= 126))
if (key > 0x7F || (32 <= key && key <= 126))
put(key);
else if (sizeof(nana::char_t) == sizeof(char))
{ //Non-Unicode Version for Non-English characters

View File

@ -1,6 +1,7 @@
/*
* Platform Implementation
* Copyright(C) 2003-2013 Jinhao(cnjinhao@hotmail.com)
* Nana C++ Library(http://www.nanapro.org)
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
@ -174,11 +175,23 @@ namespace detail
#if defined(NANA_WINDOWS)
::TextOut(dw->context, pos.x, pos.y, str, static_cast<int>(len));
#elif defined(NANA_X11)
auto disp = ::nana::detail::platform_spec::instance().open_display();
#if defined(NANA_UNICODE)
/*
std::string utf8str = nana::charset(nana::string(str, len));
XftFont * fs = reinterpret_cast<XftFont*>(dw->font->handle);
::XftDrawStringUtf8(dw->xftdraw, &(dw->xft_fgcolor), fs, pos.x, pos.y + fs->ascent,
reinterpret_cast<XftChar8*>(const_cast<char*>(utf8str.c_str())), utf8str.size());
*/
auto fs = reinterpret_cast<XftFont*>(dw->font->handle);
std::unique_ptr<FT_UInt> glyphs_ptr(new FT_UInt[len]);
auto glyphs = glyphs_ptr.get();
const auto endstr = str + len;
for(auto chr = str; chr != endstr; ++chr)
{
(*glyphs++) = XftCharIndex(disp, fs, *chr);
}
XftDrawGlyphs(dw->xftdraw, &(dw->xft_fgcolor), fs, x, y + fs->ascent, glyphs_ptr.get(), len);
#else
XFontSet fs = reinterpret_cast<XFontSet>(dw->font->handle);
XFontSetExtents * ext = ::XExtentsOfFontSet(fs);