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:
commit
4bc00f3517
@ -98,7 +98,7 @@ namespace detail
|
|||||||
unsigned whitespace_pixels;
|
unsigned whitespace_pixels;
|
||||||
}string;
|
}string;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_UNICODE)
|
||||||
XftDraw * xftdraw;
|
XftDraw * xftdraw{nullptr};
|
||||||
XftColor xft_fgcolor;
|
XftColor xft_fgcolor;
|
||||||
const std::string charset(const nana::string& str, const std::string& strcode);
|
const std::string charset(const nana::string& str, const std::string& strcode);
|
||||||
#endif
|
#endif
|
||||||
@ -138,6 +138,7 @@ namespace detail
|
|||||||
Atom net_wm_state_maximized_horz;
|
Atom net_wm_state_maximized_horz;
|
||||||
Atom net_wm_state_maximized_vert;
|
Atom net_wm_state_maximized_vert;
|
||||||
Atom net_wm_state_modal;
|
Atom net_wm_state_modal;
|
||||||
|
Atom net_wm_name;
|
||||||
Atom net_wm_window_type;
|
Atom net_wm_window_type;
|
||||||
Atom net_wm_window_type_normal;
|
Atom net_wm_window_type_normal;
|
||||||
Atom net_wm_window_type_utility;
|
Atom net_wm_window_type_utility;
|
||||||
|
@ -102,12 +102,15 @@ namespace nana
|
|||||||
: public widget_object<category::widget_tag, drawerbase::menubar::trigger>
|
: public widget_object<category::widget_tag, drawerbase::menubar::trigger>
|
||||||
{
|
{
|
||||||
public:
|
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(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.
|
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& push_back(const nana::string&); ///< Appends a new (empty) menu.
|
||||||
menu& at(size_t index) const; ///< Gets the menu specified by index.
|
menu& at(size_t index) const; ///< Gets the menu specified by index.
|
||||||
std::size_t length() const; ///< Number of menus.
|
std::size_t length() const; ///< Number of menus.
|
||||||
|
private:
|
||||||
|
::nana::event_handle evt_resized_{nullptr};
|
||||||
};//end class menubar
|
};//end class menubar
|
||||||
}//end namespace nana
|
}//end namespace nana
|
||||||
#endif
|
#endif
|
||||||
|
@ -130,7 +130,9 @@ namespace nana
|
|||||||
void load(nana::string file);
|
void load(nana::string file);
|
||||||
void store(nana::string file);
|
void store(nana::string file);
|
||||||
void store(nana::string file, nana::unicode encoding);
|
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.
|
/// The file of last store operation.
|
||||||
nana::string filename() const;
|
nana::string filename() const;
|
||||||
|
@ -799,16 +799,31 @@ namespace nana
|
|||||||
switch(utf_x_)
|
switch(utf_x_)
|
||||||
{
|
{
|
||||||
case unicode::utf8:
|
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);
|
strbuf = detail::utf8_to_utf32(data_, true);
|
||||||
detail::put_utf32char(strbuf, 0, true);
|
detail::put_utf32char(strbuf, 0, true);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case unicode::utf16:
|
case unicode::utf16:
|
||||||
|
#if defined(NANA_MINGW)
|
||||||
|
strbuf = data_;
|
||||||
|
detail::put_utf16char(strbuf, 0, true);
|
||||||
|
#else
|
||||||
strbuf = detail::utf16_to_utf32(data_);
|
strbuf = detail::utf16_to_utf32(data_);
|
||||||
detail::put_utf32char(strbuf, 0, true);
|
detail::put_utf32char(strbuf, 0, true);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case unicode::utf32:
|
case unicode::utf32:
|
||||||
|
#if defined(NANA_MINGW)
|
||||||
|
strbuf = detail::utf32_to_utf16(data_);
|
||||||
|
detail::put_utf16char(strbuf, 0, true);
|
||||||
|
#else
|
||||||
strbuf = data_;
|
strbuf = data_;
|
||||||
detail::put_utf32char(strbuf, 0, true);
|
detail::put_utf32char(strbuf, 0, true);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,13 +907,25 @@ namespace nana
|
|||||||
switch(utf_x_)
|
switch(utf_x_)
|
||||||
{
|
{
|
||||||
case unicode::utf8:
|
case unicode::utf8:
|
||||||
|
#if defined(NANA_MINGW)
|
||||||
|
bytes = detail::utf8_to_utf16(data_, true);
|
||||||
|
#else
|
||||||
bytes = detail::utf8_to_utf32(data_, true);
|
bytes = detail::utf8_to_utf32(data_, true);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case unicode::utf16:
|
case unicode::utf16:
|
||||||
|
#if defined(NANA_MINGW)
|
||||||
|
bytes = data_;
|
||||||
|
#else
|
||||||
bytes = detail::utf16_to_utf32(data_);
|
bytes = detail::utf16_to_utf32(data_);
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
case unicode::utf32:
|
case unicode::utf32:
|
||||||
|
#if defined(NANA_MINGW)
|
||||||
|
bytes = detail::utf32_to_utf16(data_);
|
||||||
|
#else
|
||||||
bytes = data_;
|
bytes = data_;
|
||||||
|
#endif
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return std::wstring(reinterpret_cast<const wchar_t*>(bytes.c_str()), bytes.size() / sizeof(wchar_t));
|
return std::wstring(reinterpret_cast<const wchar_t*>(bytes.c_str()), bytes.size() / sizeof(wchar_t));
|
||||||
@ -957,11 +984,23 @@ namespace nana
|
|||||||
switch(encoding)
|
switch(encoding)
|
||||||
{
|
{
|
||||||
case unicode::utf8:
|
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)));
|
return detail::utf32_to_utf8(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
|
||||||
|
#endif
|
||||||
case unicode::utf16:
|
case unicode::utf16:
|
||||||
return detail::utf32_to_utf16(std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t)));
|
#if defined(NANA_MINGW)
|
||||||
case unicode::utf32:
|
|
||||||
return std::string(reinterpret_cast<const char*>(data_.c_str()), data_.size() * sizeof(wchar_t));
|
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 {};
|
return {};
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Platform Specification Implementation
|
* Platform Specification Implementation
|
||||||
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Nana Software License, Version 1.0.
|
* Distributed under the Nana Software License, Version 1.0.
|
||||||
@ -288,7 +289,6 @@ namespace detail
|
|||||||
string.tab_pixels = 0;
|
string.tab_pixels = 0;
|
||||||
string.whitespace_pixels = 0;
|
string.whitespace_pixels = 0;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_UNICODE)
|
||||||
xftdraw = 0;
|
|
||||||
conv_.handle = ::iconv_open("UTF-8", "UTF-32");
|
conv_.handle = ::iconv_open("UTF-8", "UTF-32");
|
||||||
conv_.code = "UTF-32";
|
conv_.code = "UTF-32";
|
||||||
#endif
|
#endif
|
||||||
@ -457,7 +457,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
langstr_dup = "zh_CN.UTF-8";
|
langstr_dup = "en_US.UTF-8";
|
||||||
std::setlocale(LC_CTYPE, langstr_dup.c_str());
|
std::setlocale(LC_CTYPE, langstr_dup.c_str());
|
||||||
if(::XSupportsLocale())
|
if(::XSupportsLocale())
|
||||||
::XSetLocaleModifiers(langstr_dup.c_str());
|
::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_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_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_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 = ::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_normal = ::XInternAtom(display_, "_NET_WM_WINDOW_TYPE_NORMAL", False);
|
||||||
atombase_.net_wm_window_type_utility = ::XInternAtom(display_, "_NET_WM_WINDOW_TYPE_UTILITY", False);
|
atombase_.net_wm_window_type_utility = ::XInternAtom(display_, "_NET_WM_WINDOW_TYPE_UTILITY", False);
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
* Platform Specification Selector
|
* Platform Specification Selector
|
||||||
|
* Nana C++ Library(http://www.nanapro.org)
|
||||||
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
* Copyright(C) 2003-2014 Jinhao(cnjinhao@hotmail.com)
|
||||||
*
|
*
|
||||||
* Distributed under the Nana Software License, Version 1.0.
|
* Distributed under the Nana Software License, Version 1.0.
|
||||||
@ -9,7 +10,7 @@
|
|||||||
* @file: nana/detail/platform_spec_selector.cpp
|
* @file: nana/detail/platform_spec_selector.cpp
|
||||||
*
|
*
|
||||||
* This file is used to support the Nana project of some cross-platform IDE,
|
* This file is used to support the Nana project of some cross-platform IDE,
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <nana/config.hpp>
|
#include <nana/config.hpp>
|
||||||
|
@ -955,7 +955,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
|
|
||||||
keybuf[len] = 0;
|
keybuf[len] = 0;
|
||||||
nana::char_t keychar;
|
nana::char_t keychar = 0;
|
||||||
switch(status)
|
switch(status)
|
||||||
{
|
{
|
||||||
case XLookupKeySym:
|
case XLookupKeySym:
|
||||||
@ -984,8 +984,6 @@ namespace detail
|
|||||||
keychar = keyboard::os_insert; break;
|
keychar = keyboard::os_insert; break;
|
||||||
case XK_Delete:
|
case XK_Delete:
|
||||||
keychar = keyboard::os_del; break;
|
keychar = keyboard::os_del; break;
|
||||||
default:
|
|
||||||
keychar = keysym;
|
|
||||||
}
|
}
|
||||||
context.platform.keychar = keychar;
|
context.platform.keychar = keychar;
|
||||||
if(keychar == keyboard::tab && (false == (msgwnd->flags.tab & detail::tab_type::eating))) //Tab
|
if(keychar == keyboard::tab && (false == (msgwnd->flags.tab & detail::tab_type::eating))) //Tab
|
||||||
@ -1002,7 +1000,7 @@ namespace detail
|
|||||||
{
|
{
|
||||||
context.is_alt_pressed = true;
|
context.is_alt_pressed = true;
|
||||||
}
|
}
|
||||||
else
|
else if(keychar)
|
||||||
{
|
{
|
||||||
arg_keyboard arg;
|
arg_keyboard arg;
|
||||||
arg.ignore = false;
|
arg.ignore = false;
|
||||||
@ -1020,7 +1018,7 @@ namespace detail
|
|||||||
}
|
}
|
||||||
case XLookupChars:
|
case XLookupChars:
|
||||||
{
|
{
|
||||||
const nana::char_t * charbuf;
|
const ::nana::char_t* charbuf;
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_UNICODE)
|
||||||
nana::detail::charset_conv charset("UTF-32", "UTF-8");
|
nana::detail::charset_conv charset("UTF-32", "UTF-8");
|
||||||
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
|
const std::string& str = charset.charset(std::string(keybuf, keybuf + len));
|
||||||
|
@ -1096,6 +1096,9 @@ namespace nana{
|
|||||||
nana::detail::platform_scope_guard psg;
|
nana::detail::platform_scope_guard psg;
|
||||||
::XStringListToTextProperty(&text, 1, &name);
|
::XStringListToTextProperty(&text, 1, &name);
|
||||||
::XSetWMName(restrict::spec.open_display(), reinterpret_cast<Window>(wd), &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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -575,17 +575,27 @@ namespace nana
|
|||||||
|
|
||||||
|
|
||||||
//class menubar
|
//class menubar
|
||||||
menubar::menubar(){}
|
|
||||||
menubar::menubar(window wd)
|
menubar::menubar(window wd)
|
||||||
{
|
{
|
||||||
create(wd);
|
create(wd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
menubar::~menubar()
|
||||||
|
{
|
||||||
|
API::umake_event(evt_resized_);
|
||||||
|
}
|
||||||
|
|
||||||
void menubar::create(window wd)
|
void menubar::create(window wd)
|
||||||
{
|
{
|
||||||
widget_object<category::widget_tag, drawerbase::menubar::trigger>
|
widget_object<category::widget_tag, drawerbase::menubar::trigger>
|
||||||
::create(wd, rectangle(nana::size(API::window_size(wd).width, 28)));
|
::create(wd, rectangle(nana::size(API::window_size(wd).width, 28)));
|
||||||
API::attach_menubar(handle());
|
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)
|
menu& menubar::push_back(const nana::string& text)
|
||||||
|
@ -1196,7 +1196,7 @@ namespace nana{ namespace widgets
|
|||||||
undo(false);
|
undo(false);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if (key >= 0xFF || (32 <= key && key <= 126))
|
if (key > 0x7F || (32 <= key && key <= 126))
|
||||||
put(key);
|
put(key);
|
||||||
else if (sizeof(nana::char_t) == sizeof(char))
|
else if (sizeof(nana::char_t) == sizeof(char))
|
||||||
{ //Non-Unicode Version for Non-English characters
|
{ //Non-Unicode Version for Non-English characters
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* Platform Implementation
|
* 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.
|
* 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
|
||||||
@ -174,11 +175,23 @@ namespace detail
|
|||||||
#if defined(NANA_WINDOWS)
|
#if defined(NANA_WINDOWS)
|
||||||
::TextOut(dw->context, pos.x, pos.y, str, static_cast<int>(len));
|
::TextOut(dw->context, pos.x, pos.y, str, static_cast<int>(len));
|
||||||
#elif defined(NANA_X11)
|
#elif defined(NANA_X11)
|
||||||
|
auto disp = ::nana::detail::platform_spec::instance().open_display();
|
||||||
#if defined(NANA_UNICODE)
|
#if defined(NANA_UNICODE)
|
||||||
|
/*
|
||||||
std::string utf8str = nana::charset(nana::string(str, len));
|
std::string utf8str = nana::charset(nana::string(str, len));
|
||||||
XftFont * fs = reinterpret_cast<XftFont*>(dw->font->handle);
|
XftFont * fs = reinterpret_cast<XftFont*>(dw->font->handle);
|
||||||
::XftDrawStringUtf8(dw->xftdraw, &(dw->xft_fgcolor), fs, pos.x, pos.y + fs->ascent,
|
::XftDrawStringUtf8(dw->xftdraw, &(dw->xft_fgcolor), fs, pos.x, pos.y + fs->ascent,
|
||||||
reinterpret_cast<XftChar8*>(const_cast<char*>(utf8str.c_str())), utf8str.size());
|
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
|
#else
|
||||||
XFontSet fs = reinterpret_cast<XFontSet>(dw->font->handle);
|
XFontSet fs = reinterpret_cast<XFontSet>(dw->font->handle);
|
||||||
XFontSetExtents * ext = ::XExtentsOfFontSet(fs);
|
XFontSetExtents * ext = ::XExtentsOfFontSet(fs);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user