diff --git a/include/nana/detail/linux_X11/platform_spec.hpp b/include/nana/detail/linux_X11/platform_spec.hpp index 1af715fa..ae4a1830 100644 --- a/include/nana/detail/linux_X11/platform_spec.hpp +++ b/include/nana/detail/linux_X11/platform_spec.hpp @@ -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; diff --git a/include/nana/gui/widgets/menubar.hpp b/include/nana/gui/widgets/menubar.hpp index ef9c8ce5..bec4dd5d 100644 --- a/include/nana/gui/widgets/menubar.hpp +++ b/include/nana/gui/widgets/menubar.hpp @@ -102,12 +102,15 @@ namespace nana : public widget_object { 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 diff --git a/include/nana/gui/widgets/textbox.hpp b/include/nana/gui/widgets/textbox.hpp index 5c3a060e..6d2378c9 100644 --- a/include/nana/gui/widgets/textbox.hpp +++ b/include/nana/gui/widgets/textbox.hpp @@ -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; diff --git a/source/charset.cpp b/source/charset.cpp index 6a28b774..f73a5161 100644 --- a/source/charset.cpp +++ b/source/charset.cpp @@ -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(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(data_.c_str()), data_.size() * sizeof(wchar_t))); +#else return detail::utf32_to_utf8(std::string(reinterpret_cast(data_.c_str()), data_.size() * sizeof(wchar_t))); +#endif case unicode::utf16: - return detail::utf32_to_utf16(std::string(reinterpret_cast(data_.c_str()), data_.size() * sizeof(wchar_t))); - case unicode::utf32: +#if defined(NANA_MINGW) return std::string(reinterpret_cast(data_.c_str()), data_.size() * sizeof(wchar_t)); +#else + return detail::utf32_to_utf16(std::string(reinterpret_cast(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(data_.c_str()), data_.size() * sizeof(wchar_t))); +#else + return std::string(reinterpret_cast(data_.c_str()), data_.size() * sizeof(wchar_t)); +#endif } return {}; } diff --git a/source/detail/linux_X11/platform_spec.cpp b/source/detail/linux_X11/platform_spec.cpp index 32e0ba17..69f518ac 100644 --- a/source/detail/linux_X11/platform_spec.cpp +++ b/source/detail/linux_X11/platform_spec.cpp @@ -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); diff --git a/source/detail/platform_spec_selector.cpp b/source/detail/platform_spec_selector.cpp index f3eeab01..1bf8a3c5 100644 --- a/source/detail/platform_spec_selector.cpp +++ b/source/detail/platform_spec_selector.cpp @@ -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 diff --git a/source/gui/detail/linux_X11/bedrock.cpp b/source/gui/detail/linux_X11/bedrock.cpp index dd20610d..c9e1ae78 100644 --- a/source/gui/detail/linux_X11/bedrock.cpp +++ b/source/gui/detail/linux_X11/bedrock.cpp @@ -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)); diff --git a/source/gui/detail/native_window_interface.cpp b/source/gui/detail/native_window_interface.cpp index 2a20fd78..a862af75 100644 --- a/source/gui/detail/native_window_interface.cpp +++ b/source/gui/detail/native_window_interface.cpp @@ -1096,6 +1096,9 @@ namespace nana{ nana::detail::platform_scope_guard psg; ::XStringListToTextProperty(&text, 1, &name); ::XSetWMName(restrict::spec.open_display(), reinterpret_cast(wd), &name); + ::XChangeProperty(restrict::spec.open_display(), reinterpret_cast(wd), + restrict::spec.atombase().net_wm_name, restrict::spec.atombase().utf8_string, 8, + PropModeReplace, reinterpret_cast(text), mbstr.size()); #endif } diff --git a/source/gui/widgets/menubar.cpp b/source/gui/widgets/menubar.cpp index 4c053306..3c584a9e 100644 --- a/source/gui/widgets/menubar.cpp +++ b/source/gui/widgets/menubar.cpp @@ -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 ::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) diff --git a/source/gui/widgets/skeletons/text_editor.cpp b/source/gui/widgets/skeletons/text_editor.cpp index 654c2c6c..ce0c75f8 100644 --- a/source/gui/widgets/skeletons/text_editor.cpp +++ b/source/gui/widgets/skeletons/text_editor.cpp @@ -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 diff --git a/source/paint/detail/native_paint_interface.cpp b/source/paint/detail/native_paint_interface.cpp index 25f897eb..d4e72106 100644 --- a/source/paint/detail/native_paint_interface.cpp +++ b/source/paint/detail/native_paint_interface.cpp @@ -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(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(dw->font->handle); ::XftDrawStringUtf8(dw->xftdraw, &(dw->xft_fgcolor), fs, pos.x, pos.y + fs->ascent, reinterpret_cast(const_cast(utf8str.c_str())), utf8str.size()); + */ + auto fs = reinterpret_cast(dw->font->handle); + std::unique_ptr 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(dw->font->handle); XFontSetExtents * ext = ::XExtentsOfFontSet(fs);