diff --git a/nel/include/nel/3d/driver.h b/nel/include/nel/3d/driver.h index 75472df37..0fdae7a58 100644 --- a/nel/include/nel/3d/driver.h +++ b/nel/include/nel/3d/driver.h @@ -262,10 +262,10 @@ public: virtual NLMISC::IEventEmitter *getEventEmitter() = 0; /// Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text) = 0; + virtual bool copyTextToClipboard(const std::string &text) = 0; /// Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text) = 0;/// Return the depth of the driver after init(). + virtual bool pasteTextFromClipboard(std::string &text) = 0;/// Return the depth of the driver after init(). virtual uint8 getBitPerPixel() = 0; diff --git a/nel/include/nel/3d/driver_user.h b/nel/include/nel/3d/driver_user.h index c3564975f..862921f8f 100644 --- a/nel/include/nel/3d/driver_user.h +++ b/nel/include/nel/3d/driver_user.h @@ -558,10 +558,10 @@ public: // @} // Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); // Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool pasteTextFromClipboard(std::string &text); virtual uint64 getSwapBufferCounter(); diff --git a/nel/include/nel/3d/u_driver.h b/nel/include/nel/3d/u_driver.h index f4f78e2cb..ca8a98e02 100644 --- a/nel/include/nel/3d/u_driver.h +++ b/nel/include/nel/3d/u_driver.h @@ -835,10 +835,10 @@ public: /// \name Clipboard management // @{ // Copy a string to system clipboard. - virtual bool copyTextToClipboard(const ucstring &text) =0; + virtual bool copyTextToClipboard(const std::string &text) =0; // Paste a string from system clipboard. - virtual bool pasteTextFromClipboard(ucstring &text) =0; + virtual bool pasteTextFromClipboard(std::string &text) =0; // @} public: diff --git a/nel/include/nel/gui/event_descriptor.h b/nel/include/nel/gui/event_descriptor.h index dd2ae19c4..baa9414fd 100644 --- a/nel/include/nel/gui/event_descriptor.h +++ b/nel/include/nel/gui/event_descriptor.h @@ -60,7 +60,7 @@ public: keydown = 0, // a key has been press down. The key value is stored as a TKey keyup, // a key has been released. The key value is stored as a TKey keychar, // a key has been stroke. The key is a ucchar - keystring, // a string has been sent. The string is a ucstring + keystring, // a string has been sent. The string is a utf-8 string unknown, // uninitialized event }; CEventDescriptorKey() : _KeyEvent(unknown), _CtrlState(false), _ShiftState(false), _AltState(false), _Char(0) diff --git a/nel/include/nel/gui/group_container.h b/nel/include/nel/gui/group_container.h index 361ae70b9..30d91dad6 100644 --- a/nel/include/nel/gui/group_container.h +++ b/nel/include/nel/gui/group_container.h @@ -248,13 +248,6 @@ namespace NLGUI // Get the header color draw. NB: depends if grayed, and if active. NLMISC::CRGBA getDrawnHeaderColor () const; - std::string getTitleRaw () const; - void setTitleRaw (const std::string &title); - std::string getTitleOpenedRaw () const; - void setTitleOpenedRaw (const std::string &title); - std::string getTitleClosedRaw () const; - void setTitleClosedRaw (const std::string &title); - ucstring getUCTitleOpened () const; void setUCTitleOpened (const ucstring &title); ucstring getUCTitleClosed () const; @@ -295,10 +288,6 @@ namespace NLGUI REFLECT_STRING("title_opened", getTitleOpened, setTitleOpened); REFLECT_STRING("title_closed", getTitleClosed, setTitleClosed); - REFLECT_STRING("title_raw", getTitleRaw, setTitleRaw); - REFLECT_STRING("title_opened_raw", getTitleOpenedRaw, setTitleOpenedRaw); - REFLECT_STRING("title_closed_raw", getTitleClosedRaw, setTitleClosedRaw); - REFLECT_UCSTRING("uc_title_opened", getUCTitleOpened, setUCTitleOpened); // FIXME: Lua UTF-8 REFLECT_UCSTRING("uc_title_closed", getUCTitleClosed, setUCTitleClosed); // FIXME: Lua UTF-8 REFLECT_UCSTRING("uc_title", getUCTitle, setUCTitle); // FIXME: Lua UTF-8 @@ -315,6 +304,8 @@ namespace NLGUI REFLECT_BOOL("lockable", isLockable, setLockable); REFLECT_BOOL("locked", isLocked, setLocked); + REFLECT_BOOL("localize", isLocalize, setLocalize); + REFLECT_BOOL("header_active", getHeaderActive, setHeaderActive); REFLECT_BOOL("right_button_enabled", getRightButtonEnabled, setRightButtonEnabled); REFLECT_EXPORT_END @@ -377,7 +368,7 @@ namespace NLGUI bool isActiveSavable() const { return _ActiveSavable; } bool isLocalize() const { return _Localize; } - void setLocalize(bool localize) { _Localize = localize; } + void setLocalize(bool localize); void setPopupX(sint32 x) { _PopupX = x; } void setPopupY(sint32 y) { _PopupY = y; } @@ -649,6 +640,9 @@ namespace NLGUI TTileClass convertTitleClass(const char *ptr); + void setTitledOpenedViewText(); + void setTitledClosedViewText(); + static COptionsContainerMove *getMoveOptions(); COptionsLayer *getContainerOptions(sint32 ls=-1); // Depends if overload by OptionsName or default used diff --git a/nel/include/nel/gui/group_editbox.h b/nel/include/nel/gui/group_editbox.h index 9b2998be0..3263837c1 100644 --- a/nel/include/nel/gui/group_editbox.h +++ b/nel/include/nel/gui/group_editbox.h @@ -140,7 +140,7 @@ namespace NLGUI // Paste the selection into buffer void paste(); // Write the string into buffer - void writeString(const ucstring &str, bool replace = true, bool atEnd = true); // UTF-16 because of Clipboard implementation + void writeString(const std::string &str, bool replace = true, bool atEnd = true); // Expand the expression (true if there was a '/' at the start of the line) bool expand(); @@ -299,9 +299,9 @@ namespace NLGUI void handleEventString(const NLGUI::CEventDescriptorKey &event); void setup(); void triggerOnChangeAH(); - void appendStringFromClipboard(const ucstring &str); // UTF-16 because of Clipboard implementation + void appendStringFromClipboard(const std::string &str); - ucstring getSelection(); // UTF-16 because of Clipboard implementation + std::string getSelection(); static CGroupEditBox *_MenuFather; diff --git a/nel/include/nel/gui/group_html.h b/nel/include/nel/gui/group_html.h index 56605c0cc..a5e1dc4e1 100644 --- a/nel/include/nel/gui/group_html.h +++ b/nel/include/nel/gui/group_html.h @@ -352,7 +352,7 @@ namespace NLGUI // Set the title void setTitle (const std::string &title); std::string getTitle() const; - void setTitleRaw (const std::string &title); + void setContainerTitle (const std::string &title); // Lookup a url in local file system bool lookupLocalFile (std::string &result, const char *url, bool isUrl); diff --git a/nel/include/nel/gui/string_case.h b/nel/include/nel/gui/string_case.h index bd56c7998..446998e1a 100644 --- a/nel/include/nel/gui/string_case.h +++ b/nel/include/nel/gui/string_case.h @@ -21,7 +21,6 @@ #define STRING_CASE_H #include "nel/misc/types_nl.h" -#include "nel/misc/ucstring.h" namespace NLGUI { diff --git a/nel/include/nel/gui/view_text.h b/nel/include/nel/gui/view_text.h index 7c0324f58..2074576c1 100644 --- a/nel/include/nel/gui/view_text.h +++ b/nel/include/nel/gui/view_text.h @@ -84,7 +84,7 @@ namespace NLGUI /// Set - void setText(const std::string &text); + void setText(const std::string &text); //< Not localized. Use setHardText to localize strings starting with "ui". TODO: Add a Localize flag, like title in group container. HardText then simply sets localize to true. void setTextAsUtf16 (const ucstring &text); void setFontName (const std::string &name); void setFontSize (sint nFontSize, bool coef = true); @@ -178,7 +178,7 @@ namespace NLGUI void getLineEndIndex(uint line, sint &index, bool &endOfPreviousLine) const; std::string getHardText() const { return _HardText.empty() ? _Text : _HardText; } - void setHardText (const std::string &ht); + void setHardText (const std::string &ht); //< Localizes strings starting with "ui" void setHardTextAsUtf16(const ucstring &ht); std::string getColorAsString() const; @@ -262,8 +262,8 @@ namespace NLGUI // width of the font in pixel. Just a Hint for tabing format (computed with '_') float _FontWidth; // strings to use when computing font size - ::u32string _FontSizingChars; - ::u32string _FontSizingFallback; + std::string _FontSizingChars; + std::string _FontSizingFallback; // height of the font in pixel. // use getFontHeight float _FontHeight; diff --git a/nel/include/nel/misc/event_emitter_multi.h b/nel/include/nel/misc/event_emitter_multi.h index e41ee2055..9b8d25c64 100644 --- a/nel/include/nel/misc/event_emitter_multi.h +++ b/nel/include/nel/misc/event_emitter_multi.h @@ -48,8 +48,8 @@ public: /// From IEventEmitter. This call submitEvents on all the emitters virtual void submitEvents(CEventServer &server, bool allWindows); - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); private: typedef std::vector > TEmitterCont; diff --git a/nel/include/nel/misc/system_utils.h b/nel/include/nel/misc/system_utils.h index 426e38b73..9093eb90d 100644 --- a/nel/include/nel/misc/system_utils.h +++ b/nel/include/nel/misc/system_utils.h @@ -49,10 +49,10 @@ public: static bool updateProgressBar(uint value, uint total); /// Copy a string to system clipboard. - static bool copyTextToClipboard(const ucstring &text); + static bool copyTextToClipboard(const std::string &text); /// Paste a string from system clipboard. - static bool pasteTextFromClipboard(ucstring &text); + static bool pasteTextFromClipboard(std::string &text); /// Check if system supports unicode. static bool supportUnicode(); diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.cpp b/nel/src/3d/driver/direct3d/driver_direct3d.cpp index f26a37afb..6263de0f8 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d.cpp +++ b/nel/src/3d/driver/direct3d/driver_direct3d.cpp @@ -4018,12 +4018,12 @@ void CDriverD3D::findNearestFullscreenVideoMode() } } } -bool CDriverD3D::copyTextToClipboard(const ucstring &text) +bool CDriverD3D::copyTextToClipboard(const std::string &text) { return _EventEmitter.copyTextToClipboard(text); } -bool CDriverD3D::pasteTextFromClipboard(ucstring &text) +bool CDriverD3D::pasteTextFromClipboard(std::string &text) { return _EventEmitter.pasteTextFromClipboard(text); } diff --git a/nel/src/3d/driver/direct3d/driver_direct3d.h b/nel/src/3d/driver/direct3d/driver_direct3d.h index c021f052d..bc7911df2 100644 --- a/nel/src/3d/driver/direct3d/driver_direct3d.h +++ b/nel/src/3d/driver/direct3d/driver_direct3d.h @@ -2748,8 +2748,8 @@ public: bool convertBitmapToIcon(const NLMISC::CBitmap &bitmap, HICON &icon, uint iconWidth, uint iconHeight, uint iconDepth, const NLMISC::CRGBA &col = NLMISC::CRGBA::White, sint hotSpotX = 0, sint hotSpotY = 0, bool cursor = false); - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); public: #ifdef NL_DEBUG diff --git a/nel/src/3d/driver/opengl/driver_opengl.h b/nel/src/3d/driver/opengl/driver_opengl.h index e1ee968a5..e85d2da05 100644 --- a/nel/src/3d/driver/opengl/driver_opengl.h +++ b/nel/src/3d/driver/opengl/driver_opengl.h @@ -354,8 +354,8 @@ public: return _win; } - virtual bool copyTextToClipboard(const ucstring &text); - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); + virtual bool pasteTextFromClipboard(std::string &text); virtual uint32 getAvailableVertexAGPMemory (); virtual uint32 getAvailableVertexVRAMMemory (); diff --git a/nel/src/3d/driver/opengl/driver_opengl_window.cpp b/nel/src/3d/driver/opengl/driver_opengl_window.cpp index a987b7425..c60ec602e 100644 --- a/nel/src/3d/driver/opengl/driver_opengl_window.cpp +++ b/nel/src/3d/driver/opengl/driver_opengl_window.cpp @@ -3020,12 +3020,12 @@ void CDriverGL::setupApplicationMenu() } #endif -bool CDriverGL::copyTextToClipboard(const ucstring &text) +bool CDriverGL::copyTextToClipboard(const std::string &text) { return _EventEmitter.copyTextToClipboard(text); } -bool CDriverGL::pasteTextFromClipboard(ucstring &text) +bool CDriverGL::pasteTextFromClipboard(std::string &text) { return _EventEmitter.pasteTextFromClipboard(text); } diff --git a/nel/src/3d/driver/opengl/unix_event_emitter.cpp b/nel/src/3d/driver/opengl/unix_event_emitter.cpp index fcb00b20e..594d60183 100644 --- a/nel/src/3d/driver/opengl/unix_event_emitter.cpp +++ b/nel/src/3d/driver/opengl/unix_event_emitter.cpp @@ -547,6 +547,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) server->postEvent (charEvent); #else + // FIXME: Convert locale to UTF-32 for (int i = 0; i < c; i++) { CEventChar *charEvent = new CEventChar ((u32char)(unsigned char)Text[i], getKeyButton(event.xbutton.state), this); @@ -610,14 +611,13 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) else if (req.target == XA_STRING) { respond.xselection.property = req.property; - std::string str = _CopiedString.toString(); + std::string str = _CopiedString; // NLMISC::CUtfStringView(_CopiedString).toAscii(); // FIXME: Convert UTF-8 to local XChangeProperty(req.display, req.requestor, req.property, XA_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); } else if (req.target == XA_UTF8_STRING) { respond.xselection.property = req.property; - std::string str = _CopiedString.toUtf8(); - XChangeProperty(req.display, req.requestor, respond.xselection.property, XA_UTF8_STRING, 8, PropModeReplace, (const unsigned char*)str.c_str(), str.length()); + XChangeProperty(req.display, req.requestor, respond.xselection.property, XA_UTF8_STRING, 8, PropModeReplace, (const unsigned char*)_CopiedString.c_str(), _CopiedString.length()); } else { @@ -710,6 +710,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) else if (target == XA_STRING) { // FIXME: Convert local to UTF-8 + // text = NLMISC::CUtfStringView(text).toAscii(); } else { @@ -767,7 +768,7 @@ bool CUnixEventEmitter::processMessage (XEvent &event, CEventServer *server) return true; } -bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text) +bool CUnixEventEmitter::copyTextToClipboard(const std::string &text) { _CopiedString = text; @@ -786,7 +787,7 @@ bool CUnixEventEmitter::copyTextToClipboard(const ucstring &text) return true; } -bool CUnixEventEmitter::pasteTextFromClipboard(ucstring &text) +bool CUnixEventEmitter::pasteTextFromClipboard(std::string &text) { // check if we own the selection if (_SelectionOwned) diff --git a/nel/src/3d/driver/opengl/unix_event_emitter.h b/nel/src/3d/driver/opengl/unix_event_emitter.h index bbee65e5e..68dc81a48 100644 --- a/nel/src/3d/driver/opengl/unix_event_emitter.h +++ b/nel/src/3d/driver/opengl/unix_event_emitter.h @@ -66,12 +66,12 @@ public: /** * Copy a string to system clipboard. */ - virtual bool copyTextToClipboard(const ucstring &text); + virtual bool copyTextToClipboard(const std::string &text); /* * Paste a string from system clipboard. */ - virtual bool pasteTextFromClipboard(ucstring &text); + virtual bool pasteTextFromClipboard(std::string &text); void createIM(); void closeIM(); @@ -105,7 +105,7 @@ private: XIC _ic; NL3D::IDriver* _driver; CUnixEventServer _InternalServer; - ucstring _CopiedString; + std::string _CopiedString; bool _SelectionOwned; }; diff --git a/nel/src/3d/driver_user.cpp b/nel/src/3d/driver_user.cpp index b44a64737..02e9c4b27 100644 --- a/nel/src/3d/driver_user.cpp +++ b/nel/src/3d/driver_user.cpp @@ -1971,12 +1971,12 @@ bool CDriverUser::setRenderTarget(class UTexture & uTex, uint32 x, uint32 y, uin return result; } -bool CDriverUser::copyTextToClipboard(const ucstring &text) +bool CDriverUser::copyTextToClipboard(const std::string &text) { return _Driver->copyTextToClipboard(text); } -bool CDriverUser::pasteTextFromClipboard(ucstring &text) +bool CDriverUser::pasteTextFromClipboard(std::string &text) { return _Driver->pasteTextFromClipboard(text); } diff --git a/nel/src/gui/action_handler.cpp b/nel/src/gui/action_handler.cpp index 2b8bf890b..b80ce2f5f 100644 --- a/nel/src/gui/action_handler.cpp +++ b/nel/src/gui/action_handler.cpp @@ -751,9 +751,7 @@ namespace NLGUI { virtual void execute (CCtrlBase *pCaller, const std::string ¶ms) { - ucstring s; - s.fromUtf8(params); - if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(s)) + if (!CViewRenderer::getInstance()->getDriver()->copyTextToClipboard(params)) { nlwarning("Copy to clipboard failed: '%s'", params.c_str()); } diff --git a/nel/src/gui/group_container.cpp b/nel/src/gui/group_container.cpp index 141c7ba9b..e201f2eb4 100644 --- a/nel/src/gui/group_container.cpp +++ b/nel/src/gui/group_container.cpp @@ -3744,7 +3744,7 @@ namespace NLGUI _TitleOpened->setY (pLayer->getValSInt32 ("title_offset_y")); } _TitleOpened->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleOpened->setText (_TitleTextOpened); + if (_TitleClass == TitleText) setTitledOpenedViewText(); _TitleOpened->setActive (_Opened); // Title when the container is closed @@ -3796,7 +3796,7 @@ namespace NLGUI _TitleClosed->setY (pLayer->getValSInt32 ("title_offset_y")); } _TitleClosed->setFontSize (pLayer->getValSInt32 ("title_font_size")); - if (_TitleClass==TitleText) _TitleClosed->setText (_TitleTextClosed); + if (_TitleClass == TitleText) setTitledClosedViewText(); _TitleClosed->setActive(!_Opened); @@ -3946,6 +3946,15 @@ namespace NLGUI } } + // *************************************************************************** + void CGroupContainer::setLocalize(bool localize) + { + _Localize = localize; + setTitledOpenedViewText(); + setTitledClosedViewText(); + invalidateCoords(); + } + // *************************************************************************** std::string CGroupContainer::getTitle () const { @@ -3955,8 +3964,8 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setTitle (const std::string &title) { - if (_Localize) setTitleRaw (CI18N::get(title)); - else setTitleRaw (title); + setTitleOpened(title); + setTitleClosed(title); } // *************************************************************************** @@ -3968,8 +3977,9 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setTitleOpened (const std::string &title) { - if (_Localize) setTitleOpenedRaw (CI18N::get(title)); - else setTitleOpenedRaw (title); + _TitleTextOpened = title; + setTitledOpenedViewText(); + invalidateCoords(); } // *************************************************************************** @@ -3980,88 +3990,70 @@ namespace NLGUI // *************************************************************************** void CGroupContainer::setTitleClosed (const std::string &title) - { - if (_Localize) setTitleClosedRaw (CI18N::get(title)); - else setTitleClosedRaw (title); - } - - // *************************************************************************** - void CGroupContainer::setTitleOpenedRaw(const std::string &title) - { - _TitleTextOpened = title; - if (_TitleOpened != NULL) - _TitleOpened->setText (title); - invalidateCoords(); - } - - // *************************************************************************** - void CGroupContainer::setTitleClosedRaw(const std::string &title) { _TitleTextClosed = title; - if (_TitleClosed != NULL) - _TitleClosed->setText (_TitleTextClosed); + setTitledClosedViewText(); invalidateCoords(); } // *************************************************************************** - void CGroupContainer::setTitleRaw(const std::string &title) + void CGroupContainer::setTitledOpenedViewText() { - setTitleOpenedRaw(title); - setTitleClosedRaw(title); - } - - // *************************************************************************** - std::string CGroupContainer::getTitleRaw () const - { - return getTitleOpened(); - } - - // *************************************************************************** - std::string CGroupContainer::getTitleOpenedRaw () const - { - return _TitleTextOpened; + if (_TitleOpened != NULL) + { + if (_Localize && NLMISC::startsWith(_TitleTextOpened, "ui")) + _TitleOpened->setHardText(_TitleTextOpened); + else + _TitleOpened->setText(_TitleTextOpened); + } } // *************************************************************************** - std::string CGroupContainer::getTitleClosedRaw () const + void CGroupContainer::setTitledClosedViewText() { - return _TitleTextClosed; + if (_TitleClosed != NULL) + { + if (_Localize && NLMISC::startsWith(_TitleTextClosed, "ui")) + _TitleClosed->setHardText(_TitleTextClosed); + else + _TitleClosed->setText(_TitleTextClosed); + } } // *************************************************************************** void CGroupContainer::setUCTitleOpened(const ucstring &title) { - setTitleOpenedRaw(title.toUtf8()); + setTitleOpened(title.toUtf8()); } // *************************************************************************** void CGroupContainer::setUCTitleClosed(const ucstring &title) { - setTitleClosedRaw(title.toUtf8()); + setTitleClosed(title.toUtf8()); } // *************************************************************************** void CGroupContainer::setUCTitle(const ucstring &title) { - setTitleRaw(title.toUtf8()); + setTitle(title.toUtf8()); } // *************************************************************************** ucstring CGroupContainer::getUCTitle () const { - return ucstring::makeFromUtf8(getTitleRaw()); + return ucstring::makeFromUtf8(getTitle()); } // *************************************************************************** ucstring CGroupContainer::getUCTitleOpened () const { - return ucstring::makeFromUtf8(getTitleOpenedRaw()); + return ucstring::makeFromUtf8(getTitleOpened()); } // *************************************************************************** ucstring CGroupContainer::getUCTitleClosed () const { - return ucstring::makeFromUtf8(getTitleClosedRaw()); + return ucstring::makeFromUtf8(getTitleClosed()); } // *************************************************************************** diff --git a/nel/src/gui/group_editbox.cpp b/nel/src/gui/group_editbox.cpp index 47a36d0a1..dc7e34e16 100644 --- a/nel/src/gui/group_editbox.cpp +++ b/nel/src/gui/group_editbox.cpp @@ -805,7 +805,7 @@ namespace NLGUI cutSelection(); } - ucstring sString; + string sString; if (CViewRenderer::getInstance()->getDriver()->pasteTextFromClipboard(sString)) { @@ -815,7 +815,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - void CGroupEditBox::appendStringFromClipboard(const ucstring &str) + void CGroupEditBox::appendStringFromClipboard(const std::string &str) { stopParentBlink(); makeTopWindow(); @@ -829,7 +829,7 @@ namespace NLGUI } // ---------------------------------------------------------------------------- - void CGroupEditBox::writeString(const ucstring &str16, bool replace, bool atEnd) + void CGroupEditBox::writeString(const std::string &str16, bool replace, bool atEnd) { ::u32string str = CUtfStringView(str16).toUtf32(); sint length = (sint)str.length(); @@ -1717,12 +1717,12 @@ namespace NLGUI } // *************************************************************************** - ucstring CGroupEditBox::getSelection() + std::string CGroupEditBox::getSelection() { ptrdiff_t minPos= min(_CursorPos, _SelectCursorPos); ptrdiff_t maxPos= max(_CursorPos, _SelectCursorPos); // get the selection - return CUtfStringView(_InputString.substr(minPos, maxPos-minPos)).toUtf16(); + return CUtfStringView(_InputString.substr(minPos, maxPos-minPos)).toUtf8(); } diff --git a/nel/src/gui/group_html.cpp b/nel/src/gui/group_html.cpp index f7a62cc90..b85cb5bfc 100644 --- a/nel/src/gui/group_html.cpp +++ b/nel/src/gui/group_html.cpp @@ -3401,7 +3401,7 @@ namespace NLGUI // *************************************************************************** - void CGroupHTML::setTitleRaw (const std::string &title) + void CGroupHTML::setContainerTitle (const std::string &title) { CInterfaceElement *parent = getParent(); if (parent) @@ -3411,7 +3411,7 @@ namespace NLGUI CGroupContainer *container = dynamic_cast(parent); if (container) { - container->setTitleRaw (title); + container->setTitle(title); } } } @@ -3426,7 +3426,7 @@ namespace NLGUI } _TitleString += title; - setTitleRaw(_TitleString); + setContainerTitle(_TitleString); } std::string CGroupHTML::getTitle() const { diff --git a/nel/src/gui/view_text.cpp b/nel/src/gui/view_text.cpp index c39460c9a..d6534139a 100644 --- a/nel/src/gui/view_text.cpp +++ b/nel/src/gui/view_text.cpp @@ -119,11 +119,9 @@ namespace NLGUI // - "_" that should be the character with the lowest part // - A with an accent for the highest part // https://www.compart.com/en/unicode/U+00C4 - static const u32char chars[] = { (u32char)'_', 0x000000C4, 0 }; - _FontSizingChars = chars; + _FontSizingChars = "_\xC3\x84q"; // fallback if SizingChars are not supported by font - static const u32char fallback[] = { (u32char)'|', 0 }; - _FontSizingFallback = fallback; + _FontSizingFallback = "|XO"; computeFontSize (); } @@ -399,12 +397,12 @@ namespace NLGUI else if ( name == "sizing_chars" ) { - return CUtfStringView(_FontSizingChars).toUtf8(); + return _FontSizingChars; } else if ( name == "sizing_fallback" ) { - return CUtfStringView(_FontSizingFallback).toUtf8(); + return _FontSizingFallback; } else return ""; @@ -691,13 +689,13 @@ namespace NLGUI else if( name == "sizing_chars" ) { - _FontSizingChars = CUtfStringView(value).toUtf32(); + _FontSizingChars = value; return true; } else if( name == "sizing_fallback" ) { - _FontSizingFallback = CUtfStringView(value).toUtf32(); + _FontSizingFallback = value; return true; } else @@ -769,8 +767,8 @@ namespace NLGUI xmlSetProp( node, BAD_CAST "clamp_right", BAD_CAST toString( _ClampRight ).c_str() ); xmlSetProp( node, BAD_CAST "auto_clamp_offset", BAD_CAST toString( _AutoClampOffset ).c_str() ); xmlSetProp( node, BAD_CAST "continuous_update", BAD_CAST toString( _ContinuousUpdate ).c_str() ); - xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST CUtfStringView(_FontSizingChars).toUtf8().c_str() ); - xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST CUtfStringView(_FontSizingFallback).toUtf8().c_str() ); + xmlSetProp( node, BAD_CAST "sizing_chars", BAD_CAST _FontSizingChars.c_str() ); + xmlSetProp( node, BAD_CAST "sizing_fallback", BAD_CAST _FontSizingFallback.c_str() ); return true; } @@ -956,18 +954,18 @@ namespace NLGUI } // "_Ä" lowest/highest chars (underscore, A+diaeresis) - static const u32char chars[] = { (u32char)'_', 0x000000C4, 0 }; - _FontSizingChars = chars; prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_chars" ); if (prop) - _FontSizingChars = CUtfStringView((const char*)prop).toUtf32(); + _FontSizingChars = (const char*)prop; + else + _FontSizingChars = "_\xC3\x84q"; // fallback if SizingChars are not supported by font - static const u32char fallback[] = { (u32char)'|', 0 }; - _FontSizingFallback = fallback; prop = (char*) xmlGetProp( cur, (xmlChar*)"sizing_fallback" ); if (prop) - _FontSizingFallback = CUtfStringView((const char*)prop).toUtf32(); + _FontSizingFallback = (const char *)prop; + else + _FontSizingFallback = "|XO"; computeFontSize (); } @@ -1472,10 +1470,8 @@ namespace NLGUI // *************************************************************************** void CViewText::setFontSizing(const std::string &chars, const std::string &fallback) { - _FontSizingChars.clear(); - _FontSizingChars = CUtfStringView(chars).toUtf32(); - _FontSizingFallback.clear(); - _FontSizingFallback = CUtfStringView(fallback).toUtf32(); + _FontSizingChars = chars; + _FontSizingFallback = fallback; } // *************************************************************************** @@ -3046,6 +3042,44 @@ namespace NLGUI TextContext->setEmbolden (_Embolden); TextContext->setOblique (_Oblique); +#if 1 + + UTextContext::CStringInfo si = TextContext->getStringInfo("XO"); + float xoHeight = si.StringHeight; + + si = TextContext->getStringInfo("XO\xC3\x81\xC3\x83"); + float upHeight = si.StringHeight; + + si = TextContext->getStringInfo("XOgq"); + float downHeight = si.StringHeight; + float legHeight = si.StringLine; + + nlassert(upHeight >= xoHeight); + nlassert(downHeight >= xoHeight); + float diff; + if (downHeight > upHeight) + { + diff = downHeight - xoHeight; + } + else + { + diff = upHeight - xoHeight; + legHeight += upHeight - downHeight; + } + + _FontHeight = xoHeight + diff + diff; + _FontLegHeight = legHeight; + + // Space width + si = TextContext->getStringInfo(" "); + _SpaceWidth = si.StringWidth; + + // Font Width (used for ) + si = TextContext->getStringInfo("O"); + _FontWidth = si.StringWidth; + +#else + // Letter size UTextContext::CStringInfo si = TextContext->getStringInfo(_FontSizingChars); @@ -3066,6 +3100,8 @@ namespace NLGUI // Font Width (used for ) si = TextContext->getStringInfo("_"); _FontWidth = si.StringWidth; + +#endif } diff --git a/nel/src/misc/event_emitter_multi.cpp b/nel/src/misc/event_emitter_multi.cpp index 45559ebc4..a7d133f3c 100644 --- a/nel/src/misc/event_emitter_multi.cpp +++ b/nel/src/misc/event_emitter_multi.cpp @@ -98,13 +98,13 @@ const IEventEmitter *CEventEmitterMulti::getEmitter(uint index) const return _Emitters[index].first; } -bool CEventEmitterMulti::copyTextToClipboard(const ucstring &text) +bool CEventEmitterMulti::copyTextToClipboard(const std::string &text) { // Naush: wrapped to old API to avoid duplicate code return CSystemUtils::copyTextToClipboard(text); } -bool CEventEmitterMulti::pasteTextFromClipboard(ucstring &text) +bool CEventEmitterMulti::pasteTextFromClipboard(std::string &text) { // Naush: wrapped to old API to avoid duplicate code return CSystemUtils::pasteTextFromClipboard(text); diff --git a/nel/src/misc/system_utils.cpp b/nel/src/misc/system_utils.cpp index 63eecbf0d..ba15d5363 100644 --- a/nel/src/misc/system_utils.cpp +++ b/nel/src/misc/system_utils.cpp @@ -19,6 +19,7 @@ #include "stdmisc.h" #include "nel/misc/system_utils.h" +#include "nel/misc/utf_string_view.h" #ifdef NL_OS_WINDOWS #define INITGUID @@ -154,7 +155,7 @@ bool CSystemUtils::updateProgressBar(uint value, uint total) return true; } -bool CSystemUtils::copyTextToClipboard(const ucstring &text) +bool CSystemUtils::copyTextToClipboard(const std::string &text) { if (text.empty()) return false; @@ -167,10 +168,23 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text) bool isUnicode = (IsClipboardFormatAvailable(CF_UNICODETEXT) == TRUE); // allocates a buffer to copy text in global memory - std::string textLocal; - if (!isUnicode) textLocal = NLMISC::wideToMbcs((const wchar_t *)text.c_str(), text.size()); - if (text.size() && !textLocal.size()) textLocal = text.toString(); - HGLOBAL mem = GlobalAlloc(GHND | GMEM_DDESHARE, isUnicode ? ((text.size() + 1) * sizeof(wchar_t)) : textLocal.size()); + std::string textMbcs; + std::wstring textWide; + if (!isUnicode) + { + textMbcs = NLMISC::utf8ToMbcs(text); // Prefer system for API + if (text.size() && !textMbcs.size()) + textMbcs = CUtfStringView(text).toAscii(); // Fallback to 7-bit ASCII + } + else + { + textWide = NLMISC::utf8ToWide(text); // Prefer system for API + if (text.size() && !textWide.size()) + textWide = CUtfStringView(text).toWide(); + } + HGLOBAL mem = GlobalAlloc(GHND | GMEM_DDESHARE, isUnicode + ? ((textWide.size() + 1) * sizeof(wchar_t)) + : (textMbcs.size() + 1)); if (mem) { @@ -180,9 +194,9 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text) { // copy text to this buffer if (isUnicode) - wcscpy((wchar_t *)hLock, (const wchar_t *)text.c_str()); + wcscpy((wchar_t *)hLock, textWide.c_str()); else - strcpy((char *)hLock, textLocal.c_str()); + strcpy((char *)hLock, textMbcs.c_str()); // unlock buffer GlobalUnlock(mem); @@ -204,7 +218,7 @@ bool CSystemUtils::copyTextToClipboard(const ucstring &text) return res; } -bool CSystemUtils::pasteTextFromClipboard(ucstring &text) +bool CSystemUtils::pasteTextFromClipboard(std::string &text) { bool res = false; @@ -228,13 +242,21 @@ bool CSystemUtils::pasteTextFromClipboard(ucstring &text) // retrieve clipboard data if (isUnicode) { - text = (const ucchar *)hLock; + const wchar_t *str = (const wchar_t *)hLock; + text = NLMISC::wideToUtf8(str); // Prefer system for API + if (!text.size() && str[0]) + text = CUtfStringView(str).toUtf8(); + else + text = CUtfStringView(text).toUtf8(true); // Sanitize UTF-8 user input } else { - reinterpret_cast(text) = NLMISC::mbcsToWide((const char *)hLock); - if (!text.size() && ((const char *)hLock)[0]) - text = (const char *)hLock; + const char *str = (const char *)hLock; + text = NLMISC::mbcsToUtf8(str); // Prefer system for API + if (!text.size() && str[0]) + text = CUtfStringView(str).toAscii(); // Fallback to 7-bit ASCII + else + text = CUtfStringView(text).toUtf8(true); // Sanitize UTF-8 user input } // unlock data diff --git a/nel/src/misc/utf_string_view.cpp b/nel/src/misc/utf_string_view.cpp index 070745202..d1239ae43 100644 --- a/nel/src/misc/utf_string_view.cpp +++ b/nel/src/misc/utf_string_view.cpp @@ -125,7 +125,7 @@ std::string CUtfStringView::toAscii() const if (c < 0x80) res += c; else - res += '_'; + res += '?'; } return res; }