From b79c28020db0331afdaaad7c9e0e115a1f63da84 Mon Sep 17 00:00:00 2001 From: Grandma Bates Date: Fri, 26 Nov 2010 05:33:50 -0500 Subject: [PATCH 1/4] Changed the png wrapper files so that it would compile under lib png 1.4 --- linden/indra/llimage/llpngwrapper.cpp | 6 ++++-- linden/indra/llimage/llpngwrapper.h | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/linden/indra/llimage/llpngwrapper.cpp b/linden/indra/llimage/llpngwrapper.cpp index 0dd991a63..627d0d7e7 100644 --- a/linden/indra/llimage/llpngwrapper.cpp +++ b/linden/indra/llimage/llpngwrapper.cpp @@ -216,7 +216,8 @@ void LLPngWrapper::normalizeImage() } if (mColorType == PNG_COLOR_TYPE_GRAY && mBitDepth < 8) { - png_set_gray_1_2_4_to_8(mReadPngPtr); + /*png_set_gray_1_2_4_to_8(mReadPngPtr);*/ + png_set_expand_gray_1_2_4_to_8(mReadPngPtr); } if (mColorType == PNG_COLOR_TYPE_GRAY || mColorType == PNG_COLOR_TYPE_GRAY_ALPHA) @@ -364,7 +365,8 @@ void LLPngWrapper::releaseResources() { if (mReadPngPtr || mReadInfoPtr) { - png_destroy_read_struct(&mReadPngPtr, &mReadInfoPtr, png_infopp_NULL); + png_destroy_read_struct(&mReadPngPtr, &mReadInfoPtr, NULL); + /*png_destroy_read_struct(&mReadPngPtr, &mReadInfoPtr, png_infopp_NULL);*/ mReadPngPtr = NULL; mReadInfoPtr = NULL; } diff --git a/linden/indra/llimage/llpngwrapper.h b/linden/indra/llimage/llpngwrapper.h index 2e6c1dc22..2c33592bb 100644 --- a/linden/indra/llimage/llpngwrapper.h +++ b/linden/indra/llimage/llpngwrapper.h @@ -32,7 +32,8 @@ #ifndef LL_LLPNGWRAPPER_H #define LL_LLPNGWRAPPER_H -#include "libpng12/png.h" +#include "libpng14/png.h" +/*#include "libpng12/png.h"*/ #include "llimage.h" class LLPngWrapper From 2a5d361b2f2ed59c59630098509ccafce6588611 Mon Sep 17 00:00:00 2001 From: Grandma Bates Date: Fri, 26 Nov 2010 16:30:22 -0500 Subject: [PATCH 2/4] updated the menu classes to handle a list of menu items without callback functions defined. --- linden/indra/llui/llmenugl.cpp | 219 +++++++++++++++++++++++++++++++-- linden/indra/llui/llmenugl.h | 104 +++++++++++++++- 2 files changed, 313 insertions(+), 10 deletions(-) diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp index 91bb58120..ed1cedd74 100644 --- a/linden/indra/llui/llmenugl.cpp +++ b/linden/indra/llui/llmenugl.cpp @@ -149,6 +149,18 @@ LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, K setLabel( label ); } +LLMenuItemGL::~LLMenuItemGL() { + + // Delete all the entries in the mFutureCallbackRequests vector + for(std::vector::iterator iter= mFutureCallbackRequests.begin(); + iter!=mFutureCallbackRequests.end(); + ++iter) { + delete (*iter); + } + +} + + // virtual LLXMLNodePtr LLMenuItemGL::getXML(bool save_children) const { @@ -517,6 +529,19 @@ BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& return TRUE; } + +void LLMenuItemGL::addCallbackType(U8 theType, + const std::string& name, + const std::string& userdata) { + + // Add the new callback information to the list of callbacks that are being tracked. + mFutureCallbackRequests.push_back(new LLCallbackInformation(theType,name,userdata)); + +} + + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemSeparatorGL // @@ -541,6 +566,12 @@ class LLMenuItemSeparatorGL : public LLMenuItemGL virtual BOOL handleHover(S32 x, S32 y, MASK mask); virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } + + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + }; LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const std::string &name ) : @@ -726,6 +757,11 @@ class LLMenuItemBlankGL : public LLMenuItemGL } virtual void doIt( void ) {} virtual void draw( void ) {} + + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; }; @@ -921,6 +957,52 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) return LLMenuItemGL::handleAcceleratorKey(key, mask); } +// Method to add a callback function for the given type and name. +BOOL LLMenuItemCallGL::setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { + + // Loop through all of the menu items and check to see which ones + // match the name and callback type given. + BOOL result = FALSE; + std::vector::iterator item_iter; + for (item_iter = mFutureCallbackRequests.begin(); + item_iter != mFutureCallbackRequests.end(); + ++item_iter) + { + if( ((*item_iter)->getTypeOfCallback()==llMenuItemCallType) && + ((*item_iter)->getCallbackName()==name)) + { + + // Found a match. Set the user data and then determine what type it is. + setUserData(user_data); + + if(llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK) + { + setMenuCallback((menu_callback)callback_fcn,user_data); + } + + else if (llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE) + { + setEnabledCallback((enabled_callback)callback_fcn); + } + + else if (llMenuItemCallType == LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE) + { + setName((*item_iter)->getCallbackUserData()); + setMenuCallback((menu_callback)callback_fcn,user_data); + } + + } + } + + + return result; + +} + + ///============================================================================ /// Class LLMenuItemCheckGL ///============================================================================ @@ -1378,6 +1460,16 @@ void LLMenuItemBranchGL::openMenu() } } +BOOL LLMenuItemBranchGL::setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { + + // Get the menu branch and set the callback functions on all its children. + return(getBranch()->setCtrlResponse(llMenuItemCallType,name,user_data,callback_fcn)); + +} + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemBranchDownGL @@ -1982,13 +2074,33 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory LLSimpleListener* callback = parent->getListenerByName(callback_name); - if (!callback) + if (callback) { - lldebugs << "Ignoring \"on_click\" \"" << item_name << "\" because \"" << callback_name << "\" is not registered" << llendl; - continue; + new_item->addListener(callback, "on_click", callback_data); + } + else + { + + // A callback for this item has not yet been + // specified. Add it to the list of options + // that do not yet have callbacks. + if (call_child->hasAttribute("translate")) + { + new_item->addCallbackType + (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, + item_name, + callback_data); + } + + else + { + new_item->addCallbackType + (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + item_name, + callback_data); + } } - new_item->addListener(callback, "on_click", callback_data); } if (call_child->hasName("on_enable")) { @@ -2016,13 +2128,23 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory LLSimpleListener* callback = parent->getListenerByName(callback_name); - if (!callback) + if (callback) { - lldebugs << "Ignoring \"on_enable\" \"" << item_name << "\" because \"" << callback_name << "\" is not registered" << llendl; - continue; + new_item->addListener(callback, "on_build", userdata); + } + else + { + + // A callback for this item has not yet been + // specified. Add it to the list of options + // that do not yet have callbacks. + + new_item->addCallbackType + (LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + item_name, + callback_data); } - new_item->addListener(callback, "on_build", userdata); } else if (call_child->hasAttribute("control")) { @@ -2977,6 +3099,7 @@ void LLMenuGL::draw( void ) if( mBgVisible ) { + gl_rect_2d( -1, getRect().getHeight()+1, getRect().getWidth()+1, -1, mBorderColor,FALSE); gl_rect_2d( 0, getRect().getHeight(), getRect().getWidth(), 0, mBackgroundColor ); } LLView::draw(); @@ -3033,6 +3156,42 @@ LLMenuGL* LLMenuGL::getChildMenuByName(const std::string& name, BOOL recurse) co return NULL; } + +void LLMenuGL::setBackgroundColor( const LLColor4& color ) { + + mBackgroundColor = color; + item_list_t::iterator item_iter; + for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) + { + if((*item_iter)->getType()=="menu") + { + LLMenuItemBranchGL *menuBranchItem = (LLMenuItemBranchGL*)(*item_iter); + menuBranchItem->getBranch()->setBackgroundColor(color); + } + } + + +} + + +void LLMenuGL::setBorderColor( const LLColor4& color ) { + + mBorderColor = color; + item_list_t::iterator item_iter; + for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) + { + if((*item_iter)->getType()=="menu") + { + LLMenuItemBranchGL *menuBranchItem = (LLMenuItemBranchGL*)(*item_iter); + menuBranchItem->getBranch()->setBorderColor(color); + } + } + + +} + + + BOOL LLMenuGL::clearHoverItem() { for ( child_list_const_iter_t child_it = getChildList()->begin(); child_it != getChildList()->end(); ++child_it) @@ -3098,6 +3257,27 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) menu->getParent()->sendChildToFront(menu); } + +BOOL LLMenuGL::setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) +{ + + // Go through all of the children on this menu and set the callback function. + BOOL result = FALSE; + item_list_t::iterator item_iter; + for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) + { + result |= (*item_iter)->setCtrlResponse(llMenuItemCallType,name,user_data,callback_fcn); + } + + return result; +} + + + + //----------------------------------------------------------------------------- // class LLPieMenuBranch // A branch to another pie menu @@ -3117,6 +3297,14 @@ class LLPieMenuBranch : public LLMenuItemGL LLPieMenu* getBranch() { return mBranch; } + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + + + + protected: LLPieMenu* mBranch; }; @@ -4581,3 +4769,18 @@ void LLTearOffMenu::onClose(bool app_quitting) destroy(); } + + + +///============================================================================ +/// Class LLCallbackInformation +///============================================================================ + +LLCallbackInformation::LLCallbackInformation(U8 theType, + const std::string& theName, + const std::string& userData) + : callbackName(theName), + callbackUserData(userData) +{ + setTypeOfCallback(theType); +} diff --git a/linden/indra/llui/llmenugl.h b/linden/indra/llui/llmenugl.h index 63f9d555d..d9ecadb90 100644 --- a/linden/indra/llui/llmenugl.h +++ b/linden/indra/llui/llmenugl.h @@ -70,6 +70,55 @@ typedef BOOL (*check_callback)(void*); // contents. Put the contents of the label in the provided parameter. typedef void (*label_callback)(std::string&,void*); + + +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +// Class LLCallbackInformation +// +// The LLCallbackInformation class is used to keep track of callback +// information for menus that might be requested at a future time. +//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +class LLCallbackInformation +{ + +public : + + // Constants used for keeping track of what type of callback is required. + static const U8 LL_MENU_ITEM_CALL_GL_NONE = 0; + static const U8 LL_MENU_ITEM_CALL_GL_ON_CLICK = 1; + static const U8 LL_MENU_ITEM_CALL_GL_ON_ENABLE = 2; + static const U8 LL_MENU_ITEM_CALL_GL_TRANSLATE = 3; + + + LLCallbackInformation(U8 theType=LLCallbackInformation::LL_MENU_ITEM_CALL_GL_NONE, + const std::string& theName = LLStringUtil::null, + const std::string& userData = LLStringUtil::null); + ~LLCallbackInformation() {}; + + void setTypeOfCallback(U8 theType) {typeOfCallback = theType; } + void setCallbackName(const std::string& name) {callbackName = name; } + void setCallbackUserData(const std::string& userdata) {callbackUserData = userdata; } + + U8 getTypeOfCallback() {return(typeOfCallback); } + const std::string& getCallbackName() {return(callbackName); } + const std::string& getCallbackUserData() {return(callbackUserData); } + + BOOL isTypeMatch(U8 type) { return(type == typeOfCallback);} + BOOL isNameMatch(const std::string& name) { return(name == callbackName);} + +protected: + +private: + + U8 typeOfCallback; + std::string callbackName; + std::string callbackUserData; + +}; + + + //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ // Class LLMenuItemGL // @@ -90,7 +139,7 @@ class LLMenuItemGL : public LLView static const LLColor4& getHighlightFGColor() { return sHighlightForeground; } LLMenuItemGL( const std::string& name, const std::string& label, KEY key = KEY_NONE, MASK = MASK_NONE ); - virtual ~LLMenuItemGL() {}; + virtual ~LLMenuItemGL(); virtual void setValue(const LLSD& value) { setLabel(value.asString()); } @@ -174,6 +223,15 @@ class LLMenuItemGL : public LLView void setDrawTextDisabled(BOOL disabled) { mDrawTextDisabled = disabled; } BOOL getDrawTextDisabled() const { return mDrawTextDisabled; } + // functionality for adding callbacks after the menu is constucted + void addCallbackType(U8 theType,const std::string& name,const std::string& userdata); + + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) = 0; + + protected: void setHover(BOOL hover) { mGotHover = hover; } @@ -194,6 +252,11 @@ class LLMenuItemGL : public LLView LLUIString mDrawBranchLabel; BOOL mHighlight; + + // variables used for tracking callback types that will be + // requested after the widget is in place. + std::vector mFutureCallbackRequests; + private: static LLColor4 sEnabledColor; static LLColor4 sDisabledColor; @@ -288,6 +351,12 @@ class LLMenuItemCallGL : public LLMenuItemGL, public LLObservable //virtual void draw(); + // Functionality for tracking callback types for setting after widget is in place. + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn); + private: menu_callback mCallback; @@ -382,6 +451,12 @@ class LLMenuItemToggleGL : public LLMenuItemGL // LLView Functionality //virtual void draw( void ); + // Functionality for tracking callback types for setting after widget is in place. + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; }; + private: BOOL* mToggle; }; @@ -434,8 +509,10 @@ class LLMenuGL // background colors static void setDefaultBackgroundColor( const LLColor4& color ) { sDefaultBackgroundColor = color; } - void setBackgroundColor( const LLColor4& color ) { mBackgroundColor = color; } + void setBackgroundColor( const LLColor4& color ); + void setBorderColor( const LLColor4& color ); const LLColor4& getBackgroundColor() const { return mBackgroundColor; } + const LLColor4& getBorderColor() const { return mBorderColor; } void setBackgroundVisible( BOOL b ) { mBgVisible = b; } void setCanTearOff(BOOL tear_off, LLHandle parent_floater_handle = LLHandle()); @@ -525,6 +602,8 @@ class LLMenuGL static BOOL getKeyboardMode() { return sKeyboardMode; } static class LLMenuHolderGL* sMenuContainer; + + BOOL setCtrlResponse(U8 llMenuItemCallType,const std::string& name,void* user_data,void *callback_fcn); protected: void createSpilloverBranch(); @@ -547,6 +626,7 @@ class LLMenuGL static BOOL sKeyboardMode; LLColor4 mBackgroundColor; + LLColor4 mBorderColor; BOOL mBgVisible; LLMenuItemGL* mParentMenuItem; LLUIString mLabel; @@ -623,6 +703,11 @@ class LLMenuItemBranchGL : public LLMenuItemGL virtual LLView* getChildView(const std::string& name, BOOL recurse = TRUE, BOOL create_if_missing = TRUE) const; + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn); + private: LLHandle mBranch; }; // end class LLMenuItemBranchGL @@ -668,6 +753,11 @@ class LLPieMenu void show(S32 x, S32 y, BOOL mouse_down); void hide(BOOL item_selected); + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + private: LLMenuItemGL *pieItemFromXY(S32 x, S32 y); S32 pieItemIndexFromXY(S32 x, S32 y); @@ -729,6 +819,11 @@ class LLMenuBarGL : public LLMenuGL void resetMenuTrigger() { mAltKeyTrigger = FALSE; } + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + private: void checkMenuTrigger(); @@ -814,6 +909,11 @@ class LLMenuItemTearOffGL : public LLMenuItemGL virtual void draw(void); virtual U32 getNominalHeight() const; + virtual BOOL setCtrlResponse(U8 llMenuItemCallType, + const std::string& name, + void* user_data, + void *callback_fcn) { return FALSE; } ; + private: LLHandle mParentHandle; }; From c33b0efb456f2b9ffd4135d426eb43373b033fb5 Mon Sep 17 00:00:00 2001 From: Grandma Bates Date: Fri, 26 Nov 2010 16:48:34 -0500 Subject: [PATCH 3/4] Switched the line editor widget to use the text menu from the xml file. Also added the necessary xml files for the interface. --- linden/indra/llui/lllineeditor.cpp | 112 +++++++++++------ linden/indra/llui/lllineeditor.h | 4 +- .../default/xui/da/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/de/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../xui/en-us/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/es/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/fr/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/hu/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/it/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/ja/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/ko/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/pl/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/pt/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/ru/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/tr/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/uk/menu_rightclick_text.xml | 115 ++++++++++++++++++ .../default/xui/zh/menu_rightclick_text.xml | 115 ++++++++++++++++++ 17 files changed, 1801 insertions(+), 40 deletions(-) create mode 100644 linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml create mode 100644 linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index a3785e46d..608fa9eee 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp @@ -216,44 +216,16 @@ LLLineEditor::LLLineEditor(const std::string& name, const LLRect& rect, // make the popup menu available //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); - LLMenuGL* menu = new LLMenuGL("wot"); - /*if (!menu) - { - menu = new LLMenuGL(LLStringUtil::null); - }*/ - - menu->append(new LLMenuItemCallGL("Cut", context_cut, context_enable_cut, this)); - menu->append(new LLMenuItemCallGL("Copy", context_copy, context_enable_copy, this)); - menu->append(new LLMenuItemCallGL("Paste", context_paste, context_enable_paste, this)); - menu->append(new LLMenuItemCallGL("Delete", context_delete, context_enable_delete, this)); - menu->append(new LLMenuItemCallGL("Select All", context_selectall, context_enable_selectall, this)); - - menu->appendSeparator("Transep"); - LLMenuGL* translatemenu = new LLMenuGL("Translate To"); - translatemenu->setCanTearOff(FALSE); - translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); - - menu->appendMenu(translatemenu); - menu->appendSeparator("Spelsep"); - //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); - menu->setCanTearOff(FALSE); - menu->setVisible(FALSE); - mPopupMenuHandle = menu->getHandle(); + LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_rightclick_text.xml",this); + if (!menu) + { + menu = new LLMenuGL(LLStringUtil::null); + } + + defineMenuCallbacks(menu); + mPopupMenuHandle = menu->getHandle(); + menu->setBorderColor(gColors.getColor("MenuItemDisabledColor")); + menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); } @@ -556,7 +528,7 @@ void LLLineEditor::context_translate(void * data) { LLLineEditor* line = (LLLineEditor*)data; LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; - LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; + LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translation Options", TRUE) : NULL; if (!translate_menu) { return; @@ -1313,6 +1285,68 @@ BOOL LLLineEditor::canCut() const return !mReadOnly && !mDrawAsterixes && hasSelection(); } + +// method to define the associated callbacks +void LLLineEditor::defineMenuCallbacks(LLMenuGL* menu) { + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Cut Text", + this, + (void*)context_enable_cut); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Cut Text", + this, + (void*)context_cut); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Copy Text", + this, + (void*)context_enable_copy); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Copy Text", + this, + (void*)context_copy); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Paste Text", + this, + (void*)context_enable_paste); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Paste Text", + this, + (void*)context_paste); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Delete Text", + this, + (void*)context_enable_delete); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Delete Text", + this, + (void*)context_delete); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Select All Text", + this, + (void*)context_enable_selectall); + menu->setCtrlResponse(1+LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Select All Text", + this, + (void*)context_selectall); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Translate Text", + this, + (void*)context_enable_translate); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, + "Translate Text", + this, + (void*)context_translate); + +} + + + // cut selection to clipboard void LLLineEditor::cut() { diff --git a/linden/indra/llui/lllineeditor.h b/linden/indra/llui/lllineeditor.h index f9e06210f..38ad56f9e 100644 --- a/linden/indra/llui/lllineeditor.h +++ b/linden/indra/llui/lllineeditor.h @@ -55,6 +55,7 @@ class LLFontGL; class LLLineEditorRollback; class LLButton; +class LLMenuGL; typedef BOOL (*LLLinePrevalidateFunc)(const LLWString &wstr); @@ -111,7 +112,8 @@ class LLLineEditor virtual BOOL canTranslate() const; virtual void insert(std::string what,S32 wher); - // LLEditMenuHandler overrides + // LLEditMenuHandler overrides and menu set up methods + void defineMenuCallbacks(LLMenuGL* menu); virtual void cut(); virtual BOOL canCut() const; diff --git a/linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/da/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/de/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/en-us/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/es/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/fr/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/hu/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/it/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/ja/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/ko/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/pl/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/pt/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/ru/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/tr/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/uk/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml b/linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml new file mode 100644 index 000000000..36231da16 --- /dev/null +++ b/linden/indra/newview/skins/default/xui/zh/menu_rightclick_text.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From 6516fc2f33742bfc10ab094aa9a6faf6687749bd Mon Sep 17 00:00:00 2001 From: Grandma Bates Date: Fri, 26 Nov 2010 17:05:00 -0500 Subject: [PATCH 4/4] Set the text editor widget to use the edit menu from the xml file. --- linden/indra/llui/lltexteditor.cpp | 111 +++++++++++++++++++---------- linden/indra/llui/lltexteditor.h | 1 + 2 files changed, 75 insertions(+), 37 deletions(-) diff --git a/linden/indra/llui/lltexteditor.cpp b/linden/indra/llui/lltexteditor.cpp index 004d06398..42bbf662b 100644 --- a/linden/indra/llui/lltexteditor.cpp +++ b/linden/indra/llui/lltexteditor.cpp @@ -386,42 +386,17 @@ LLTextEditor::LLTextEditor( // make the popup menu available //LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_texteditor.xml", parent_view); - LLMenuGL* menu = new LLMenuGL("wot"); - /*if (!menu) - { - menu = new LLMenuGL(LLStringUtil::null); - }*/ - menu->append(new LLMenuItemCallGL("Cut", context_cut, context_enable_cut, this)); - menu->append(new LLMenuItemCallGL("Copy", context_copy, context_enable_copy, this)); - menu->append(new LLMenuItemCallGL("Paste", context_paste, context_enable_paste, this)); - menu->append(new LLMenuItemCallGL("Delete", context_delete, context_enable_delete, this)); - menu->append(new LLMenuItemCallGL("Select All", context_selectall, context_enable_selectall, this)); - menu->appendSeparator("Transep"); - LLMenuGL* translatemenu = new LLMenuGL("Translate To"); - translatemenu->setCanTearOff(FALSE); - translatemenu->append(new LLMenuItemCallGL("en", "English", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("da", "Danish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("de", "Deutsch(German)", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("es", "Spanish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("fr", "French", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("it", "Italian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("hu", "Hungarian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("nl", "Dutch", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pl", "Polish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("pt", "Portugese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ru", "Russian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("tr", "Turkish", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("uk", "Ukrainian", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("zh", "Chinese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ja", "Japanese", context_translate, context_enable_translate, this)); - translatemenu->append(new LLMenuItemCallGL("ko", "Korean", context_translate, context_enable_translate, this)); - - menu->appendMenu(translatemenu); - menu->appendSeparator("Spelsep"); - //menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); - menu->setCanTearOff(FALSE); - menu->setVisible(FALSE); - mPopupMenuHandle = menu->getHandle(); + LLMenuGL* menu = LLUICtrlFactory::getInstance()->buildMenu("menu_rightclick_text.xml",this); + if (!menu) + { + menu = new LLMenuGL(LLStringUtil::null); + } + + defineMenuCallbacks(menu); + mPopupMenuHandle = menu->getHandle(); + menu->setBorderColor(gColors.getColor("MenuItemDisabledColor")); + menu->setBackgroundColor(gColors.getColor("MenuPopupBgColor")); + } LLTextEditor::~LLTextEditor() @@ -476,7 +451,7 @@ void LLTextEditor::context_translate(void * data) { LLTextEditor* line = (LLTextEditor*)data; LLMenuGL* menu = line ? (LLMenuGL*)(line->mPopupMenuHandle.get()) : NULL; - LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate To", TRUE) : NULL; + LLMenuGL* translate_menu = menu ? menu->getChildMenuByName("Translate Options", TRUE) : NULL; if (!translate_menu) { return; @@ -615,6 +590,68 @@ void LLTextEditor::context_selectall(void* data) if(line)line->selectAll(); } + +// method to define the associated callbacks +void LLTextEditor::defineMenuCallbacks(LLMenuGL* menu) { + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Cut Text", + this, + (void*)context_enable_cut); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Cut Text", + this, + (void*)context_cut); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Copy Text", + this, + (void*)context_enable_copy); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Copy Text", + this, + (void*)context_copy); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Paste Text", + this, + (void*)context_enable_paste); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Paste Text", + this, + (void*)context_paste); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Delete Text", + this, + (void*)context_enable_delete); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Delete Text", + this, + (void*)context_delete); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Select All Text", + this, + (void*)context_enable_selectall); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_CLICK, + "Select All Text", + this, + (void*)context_selectall); + + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_ON_ENABLE, + "Translate Text", + this, + (void*)context_enable_translate); + menu->setCtrlResponse(LLCallbackInformation::LL_MENU_ITEM_CALL_GL_TRANSLATE, + "Translate Text", + this, + (void*)context_translate); + + +} + + void LLTextEditor::setTrackColor( const LLColor4& color ) { mScrollbar->setTrackColor(color); diff --git a/linden/indra/llui/lltexteditor.h b/linden/indra/llui/lltexteditor.h index f2a831b77..2997c1837 100644 --- a/linden/indra/llui/lltexteditor.h +++ b/linden/indra/llui/lltexteditor.h @@ -167,6 +167,7 @@ class LLTextEditor : public LLUICtrl, LLEditMenuHandler, protected LLPreeditor static void spell_add(void* data); static void spell_show(void* data); std::vector getMisspelledWordsPositions(); + void defineMenuCallbacks(LLMenuGL* menu); void selectNext(const std::string& search_text_in, BOOL case_insensitive, BOOL wrap = TRUE); BOOL replaceText(const std::string& search_text, const std::string& replace_text, BOOL case_insensitive, BOOL wrap = TRUE);