diff options
author | Jacek Antonelli | 2008-09-06 18:24:57 -0500 |
---|---|---|
committer | Jacek Antonelli | 2008-09-06 18:25:07 -0500 |
commit | 798d367d54a6c6379ad355bd8345fa40e31e7fe9 (patch) | |
tree | 1921f1708cd0240648c97bc02df2c2ab5f2fc41e /linden/indra/llui/llmenugl.cpp | |
parent | Second Life viewer sources 1.20.15 (diff) | |
download | meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.zip meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.gz meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.bz2 meta-impy-798d367d54a6c6379ad355bd8345fa40e31e7fe9.tar.xz |
Second Life viewer sources 1.21.0-RC
Diffstat (limited to '')
-rw-r--r-- | linden/indra/llui/llmenugl.cpp | 262 |
1 files changed, 151 insertions, 111 deletions
diff --git a/linden/indra/llui/llmenugl.cpp b/linden/indra/llui/llmenugl.cpp index 5e46ab7..24cc47e 100644 --- a/linden/indra/llui/llmenugl.cpp +++ b/linden/indra/llui/llmenugl.cpp | |||
@@ -46,7 +46,6 @@ | |||
46 | #include "llmenugl.h" | 46 | #include "llmenugl.h" |
47 | 47 | ||
48 | #include "llmath.h" | 48 | #include "llmath.h" |
49 | #include "llgl.h" | ||
50 | #include "llrender.h" | 49 | #include "llrender.h" |
51 | #include "llfocusmgr.h" | 50 | #include "llfocusmgr.h" |
52 | #include "llfont.h" | 51 | #include "llfont.h" |
@@ -59,7 +58,6 @@ | |||
59 | #include "llresmgr.h" | 58 | #include "llresmgr.h" |
60 | #include "llui.h" | 59 | #include "llui.h" |
61 | 60 | ||
62 | #include "llglheaders.h" | ||
63 | #include "llstl.h" | 61 | #include "llstl.h" |
64 | 62 | ||
65 | #include "v2math.h" | 63 | #include "v2math.h" |
@@ -76,10 +74,10 @@ S32 MENU_BAR_WIDTH = 0; | |||
76 | /// Local function declarations, constants, enums, and typedefs | 74 | /// Local function declarations, constants, enums, and typedefs |
77 | ///============================================================================ | 75 | ///============================================================================ |
78 | 76 | ||
79 | const LLString SEPARATOR_NAME("separator"); | 77 | const std::string SEPARATOR_NAME("separator"); |
80 | const LLString TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" ); | 78 | const std::string TEAROFF_SEPARATOR_LABEL( "~~~~~~~~~~~" ); |
81 | const LLString SEPARATOR_LABEL( "-----------" ); | 79 | const std::string SEPARATOR_LABEL( "-----------" ); |
82 | const LLString VERTICAL_SEPARATOR_LABEL( "|" ); | 80 | const std::string VERTICAL_SEPARATOR_LABEL( "|" ); |
83 | 81 | ||
84 | const S32 LABEL_BOTTOM_PAD_PIXELS = 2; | 82 | const S32 LABEL_BOTTOM_PAD_PIXELS = 2; |
85 | 83 | ||
@@ -100,10 +98,10 @@ const U32 SEPARATOR_HEIGHT_PIXELS = 8; | |||
100 | const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10; | 98 | const S32 TEAROFF_SEPARATOR_HEIGHT_PIXELS = 10; |
101 | const S32 MENU_ITEM_PADDING = 4; | 99 | const S32 MENU_ITEM_PADDING = 4; |
102 | 100 | ||
103 | const LLString BOOLEAN_TRUE_PREFIX( "X" ); | 101 | const std::string BOOLEAN_TRUE_PREFIX( "X" ); |
104 | const LLString BRANCH_SUFFIX( ">" ); | 102 | const std::string BRANCH_SUFFIX( ">" ); |
105 | const LLString ARROW_UP ("^^^^^^^"); | 103 | const std::string ARROW_UP ("^^^^^^^"); |
106 | const LLString ARROW_DOWN("vvvvvvv"); | 104 | const std::string ARROW_DOWN("vvvvvvv"); |
107 | 105 | ||
108 | const F32 MAX_MOUSE_SLOPE_SUB_MENU = 0.9f; | 106 | const F32 MAX_MOUSE_SLOPE_SUB_MENU = 0.9f; |
109 | 107 | ||
@@ -132,7 +130,7 @@ const F32 ACTIVATE_HIGHLIGHT_TIME = 0.3f; | |||
132 | ///============================================================================ | 130 | ///============================================================================ |
133 | 131 | ||
134 | // Default constructor | 132 | // Default constructor |
135 | LLMenuItemGL::LLMenuItemGL( const LLString& name, const LLString& label, KEY key, MASK mask ) : | 133 | LLMenuItemGL::LLMenuItemGL( const std::string& name, const std::string& label, KEY key, MASK mask ) : |
136 | LLView( name, TRUE ), | 134 | LLView( name, TRUE ), |
137 | mJumpKey(KEY_NONE), | 135 | mJumpKey(KEY_NONE), |
138 | mAcceleratorKey( key ), | 136 | mAcceleratorKey( key ), |
@@ -222,7 +220,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) | |||
222 | 220 | ||
223 | // *NOTE: get calling code to throw up warning or route | 221 | // *NOTE: get calling code to throw up warning or route |
224 | // warning messages back to app-provided output | 222 | // warning messages back to app-provided output |
225 | // LLString warning; | 223 | // std::string warning; |
226 | // warning.append("Duplicate key binding <"); | 224 | // warning.append("Duplicate key binding <"); |
227 | // appendAcceleratorString( warning ); | 225 | // appendAcceleratorString( warning ); |
228 | // warning.append("> for menu items:\n "); | 226 | // warning.append("> for menu items:\n "); |
@@ -252,7 +250,7 @@ BOOL LLMenuItemGL::addToAcceleratorList(std::list <LLKeyBinding*> *listp) | |||
252 | 250 | ||
253 | // This function appends the character string representation of | 251 | // This function appends the character string representation of |
254 | // the current accelerator key and mask to the provided string. | 252 | // the current accelerator key and mask to the provided string. |
255 | void LLMenuItemGL::appendAcceleratorString( LLString& st ) const | 253 | void LLMenuItemGL::appendAcceleratorString( std::string& st ) const |
256 | { | 254 | { |
257 | // break early if this is a silly thing to do. | 255 | // break early if this is a silly thing to do. |
258 | if( KEY_NONE == mAcceleratorKey ) | 256 | if( KEY_NONE == mAcceleratorKey ) |
@@ -288,7 +286,7 @@ void LLMenuItemGL::appendAcceleratorString( LLString& st ) const | |||
288 | st.append( "Shift-" ); | 286 | st.append( "Shift-" ); |
289 | #endif | 287 | #endif |
290 | 288 | ||
291 | LLString keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); | 289 | std::string keystr = LLKeyboard::stringFromKey( mAcceleratorKey ); |
292 | if ((mAcceleratorMask & MASK_NORMALKEYS) && | 290 | if ((mAcceleratorMask & MASK_NORMALKEYS) && |
293 | (keystr[0] == '-' || keystr[0] == '=')) | 291 | (keystr[0] == '-' || keystr[0] == '=')) |
294 | { | 292 | { |
@@ -336,7 +334,7 @@ U32 LLMenuItemGL::getNominalWidth( void ) const | |||
336 | if( KEY_NONE != mAcceleratorKey ) | 334 | if( KEY_NONE != mAcceleratorKey ) |
337 | { | 335 | { |
338 | width += ACCEL_PAD_PIXELS; | 336 | width += ACCEL_PAD_PIXELS; |
339 | LLString temp; | 337 | std::string temp; |
340 | appendAcceleratorString( temp ); | 338 | appendAcceleratorString( temp ); |
341 | width += mFont->getWidth( temp ); | 339 | width += mFont->getWidth( temp ); |
342 | } | 340 | } |
@@ -348,7 +346,7 @@ U32 LLMenuItemGL::getNominalWidth( void ) const | |||
348 | void LLMenuItemGL::buildDrawLabel( void ) | 346 | void LLMenuItemGL::buildDrawLabel( void ) |
349 | { | 347 | { |
350 | mDrawAccelLabel.clear(); | 348 | mDrawAccelLabel.clear(); |
351 | LLString st = mDrawAccelLabel.getString(); | 349 | std::string st = mDrawAccelLabel.getString(); |
352 | appendAcceleratorString( st ); | 350 | appendAcceleratorString( st ); |
353 | mDrawAccelLabel = st; | 351 | mDrawAccelLabel = st; |
354 | } | 352 | } |
@@ -493,8 +491,8 @@ void LLMenuItemGL::draw( void ) | |||
493 | // underline "jump" key only when keyboard navigation has been initiated | 491 | // underline "jump" key only when keyboard navigation has been initiated |
494 | if (getMenu()->jumpKeysActive() && LLMenuGL::getKeyboardMode()) | 492 | if (getMenu()->jumpKeysActive() && LLMenuGL::getKeyboardMode()) |
495 | { | 493 | { |
496 | LLString upper_case_label = mLabel.getString(); | 494 | std::string upper_case_label = mLabel.getString(); |
497 | LLString::toUpper(upper_case_label); | 495 | LLStringUtil::toUpper(upper_case_label); |
498 | std::string::size_type offset = upper_case_label.find(mJumpKey); | 496 | std::string::size_type offset = upper_case_label.find(mJumpKey); |
499 | if (offset != std::string::npos) | 497 | if (offset != std::string::npos) |
500 | { | 498 | { |
@@ -508,7 +506,7 @@ void LLMenuItemGL::draw( void ) | |||
508 | setHover(FALSE); | 506 | setHover(FALSE); |
509 | } | 507 | } |
510 | 508 | ||
511 | BOOL LLMenuItemGL::setLabelArg( const LLString& key, const LLStringExplicit& text ) | 509 | BOOL LLMenuItemGL::setLabelArg( const std::string& key, const LLStringExplicit& text ) |
512 | { | 510 | { |
513 | mLabel.setArg(key, text); | 511 | mLabel.setArg(key, text); |
514 | return TRUE; | 512 | return TRUE; |
@@ -523,9 +521,9 @@ BOOL LLMenuItemGL::setLabelArg( const LLString& key, const LLStringExplicit& tex | |||
523 | class LLMenuItemSeparatorGL : public LLMenuItemGL | 521 | class LLMenuItemSeparatorGL : public LLMenuItemGL |
524 | { | 522 | { |
525 | public: | 523 | public: |
526 | LLMenuItemSeparatorGL( const LLString &name = SEPARATOR_NAME ); | 524 | LLMenuItemSeparatorGL( const std::string &name = SEPARATOR_NAME ); |
527 | 525 | ||
528 | virtual LLString getType() const { return "separator"; } | 526 | virtual std::string getType() const { return "separator"; } |
529 | 527 | ||
530 | // doIt() - do the primary funcationality of the menu item. | 528 | // doIt() - do the primary funcationality of the menu item. |
531 | virtual void doIt( void ) {} | 529 | virtual void doIt( void ) {} |
@@ -538,7 +536,7 @@ public: | |||
538 | virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } | 536 | virtual U32 getNominalHeight( void ) const { return SEPARATOR_HEIGHT_PIXELS; } |
539 | }; | 537 | }; |
540 | 538 | ||
541 | LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const LLString &name ) : | 539 | LLMenuItemSeparatorGL::LLMenuItemSeparatorGL( const std::string &name ) : |
542 | LLMenuItemGL( name, SEPARATOR_LABEL ) | 540 | LLMenuItemGL( name, SEPARATOR_LABEL ) |
543 | { | 541 | { |
544 | } | 542 | } |
@@ -617,7 +615,7 @@ LLMenuItemVerticalSeparatorGL::LLMenuItemVerticalSeparatorGL( void ) | |||
617 | // Class LLMenuItemTearOffGL | 615 | // Class LLMenuItemTearOffGL |
618 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 616 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
619 | LLMenuItemTearOffGL::LLMenuItemTearOffGL(LLHandle<LLFloater> parent_floater_handle) : | 617 | LLMenuItemTearOffGL::LLMenuItemTearOffGL(LLHandle<LLFloater> parent_floater_handle) : |
620 | LLMenuItemGL("tear off", TEAROFF_SEPARATOR_LABEL), | 618 | LLMenuItemGL(std::string("tear off"), TEAROFF_SEPARATOR_LABEL), |
621 | mParentHandle(parent_floater_handle) | 619 | mParentHandle(parent_floater_handle) |
622 | { | 620 | { |
623 | } | 621 | } |
@@ -696,7 +694,7 @@ U32 LLMenuItemTearOffGL::getNominalHeight( void ) const | |||
696 | class LLMenuItemBlankGL : public LLMenuItemGL | 694 | class LLMenuItemBlankGL : public LLMenuItemGL |
697 | { | 695 | { |
698 | public: | 696 | public: |
699 | LLMenuItemBlankGL( void ) : LLMenuItemGL( "", "" ) | 697 | LLMenuItemBlankGL( void ) : LLMenuItemGL( LLStringUtil::null, LLStringUtil::null ) |
700 | { | 698 | { |
701 | setEnabled(FALSE); | 699 | setEnabled(FALSE); |
702 | } | 700 | } |
@@ -709,8 +707,8 @@ public: | |||
709 | /// Class LLMenuItemCallGL | 707 | /// Class LLMenuItemCallGL |
710 | ///============================================================================ | 708 | ///============================================================================ |
711 | 709 | ||
712 | LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, | 710 | LLMenuItemCallGL::LLMenuItemCallGL( const std::string& name, |
713 | const LLString& label, | 711 | const std::string& label, |
714 | menu_callback clicked_cb, | 712 | menu_callback clicked_cb, |
715 | enabled_callback enabled_cb, | 713 | enabled_callback enabled_cb, |
716 | void* user_data, | 714 | void* user_data, |
@@ -727,7 +725,7 @@ LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, | |||
727 | if(!enabled) setEnabled(FALSE); | 725 | if(!enabled) setEnabled(FALSE); |
728 | } | 726 | } |
729 | 727 | ||
730 | LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, | 728 | LLMenuItemCallGL::LLMenuItemCallGL( const std::string& name, |
731 | menu_callback clicked_cb, | 729 | menu_callback clicked_cb, |
732 | enabled_callback enabled_cb, | 730 | enabled_callback enabled_cb, |
733 | void* user_data, | 731 | void* user_data, |
@@ -744,8 +742,8 @@ LLMenuItemCallGL::LLMenuItemCallGL( const LLString& name, | |||
744 | if(!enabled) setEnabled(FALSE); | 742 | if(!enabled) setEnabled(FALSE); |
745 | } | 743 | } |
746 | 744 | ||
747 | LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, | 745 | LLMenuItemCallGL::LLMenuItemCallGL(const std::string& name, |
748 | const LLString& label, | 746 | const std::string& label, |
749 | menu_callback clicked_cb, | 747 | menu_callback clicked_cb, |
750 | enabled_callback enabled_cb, | 748 | enabled_callback enabled_cb, |
751 | label_callback label_cb, | 749 | label_callback label_cb, |
@@ -763,7 +761,7 @@ LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, | |||
763 | if(!enabled) setEnabled(FALSE); | 761 | if(!enabled) setEnabled(FALSE); |
764 | } | 762 | } |
765 | 763 | ||
766 | LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, | 764 | LLMenuItemCallGL::LLMenuItemCallGL(const std::string& name, |
767 | menu_callback clicked_cb, | 765 | menu_callback clicked_cb, |
768 | enabled_callback enabled_cb, | 766 | enabled_callback enabled_cb, |
769 | label_callback label_cb, | 767 | label_callback label_cb, |
@@ -781,7 +779,7 @@ LLMenuItemCallGL::LLMenuItemCallGL(const LLString& name, | |||
781 | if(!enabled) setEnabled(FALSE); | 779 | if(!enabled) setEnabled(FALSE); |
782 | } | 780 | } |
783 | 781 | ||
784 | void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *context) | 782 | void LLMenuItemCallGL::setEnabledControl(std::string enabled_control, LLView *context) |
785 | { | 783 | { |
786 | // Register new listener | 784 | // Register new listener |
787 | if (!enabled_control.empty()) | 785 | if (!enabled_control.empty()) |
@@ -798,7 +796,7 @@ void LLMenuItemCallGL::setEnabledControl(LLString enabled_control, LLView *conte | |||
798 | } | 796 | } |
799 | } | 797 | } |
800 | 798 | ||
801 | void LLMenuItemCallGL::setVisibleControl(LLString visible_control, LLView *context) | 799 | void LLMenuItemCallGL::setVisibleControl(std::string visible_control, LLView *context) |
802 | { | 800 | { |
803 | // Register new listener | 801 | // Register new listener |
804 | if (!visible_control.empty()) | 802 | if (!visible_control.empty()) |
@@ -826,7 +824,7 @@ LLXMLNodePtr LLMenuItemCallGL::getXML(bool save_children) const | |||
826 | std::vector<LLListenerEntry>::iterator itor; | 824 | std::vector<LLListenerEntry>::iterator itor; |
827 | for (itor = listeners.begin(); itor != listeners.end(); ++itor) | 825 | for (itor = listeners.begin(); itor != listeners.end(); ++itor) |
828 | { | 826 | { |
829 | LLString listener_name = findEventListener((LLSimpleListener*)itor->listener); | 827 | std::string listener_name = findEventListener((LLSimpleListener*)itor->listener); |
830 | if (!listener_name.empty()) | 828 | if (!listener_name.empty()) |
831 | { | 829 | { |
832 | LLXMLNodePtr child_node = node->createChild("on_click", FALSE); | 830 | LLXMLNodePtr child_node = node->createChild("on_click", FALSE); |
@@ -864,7 +862,7 @@ void LLMenuItemCallGL::buildDrawLabel( void ) | |||
864 | } | 862 | } |
865 | if(mLabelCallback) | 863 | if(mLabelCallback) |
866 | { | 864 | { |
867 | LLString label; | 865 | std::string label; |
868 | mLabelCallback(label, mUserData); | 866 | mLabelCallback(label, mUserData); |
869 | mLabel = label; | 867 | mLabel = label; |
870 | } | 868 | } |
@@ -896,8 +894,8 @@ BOOL LLMenuItemCallGL::handleAcceleratorKey( KEY key, MASK mask ) | |||
896 | /// Class LLMenuItemCheckGL | 894 | /// Class LLMenuItemCheckGL |
897 | ///============================================================================ | 895 | ///============================================================================ |
898 | 896 | ||
899 | LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, | 897 | LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name, |
900 | const LLString& label, | 898 | const std::string& label, |
901 | menu_callback clicked_cb, | 899 | menu_callback clicked_cb, |
902 | enabled_callback enabled_cb, | 900 | enabled_callback enabled_cb, |
903 | check_callback check_cb, | 901 | check_callback check_cb, |
@@ -909,7 +907,7 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, | |||
909 | { | 907 | { |
910 | } | 908 | } |
911 | 909 | ||
912 | LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, | 910 | LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name, |
913 | menu_callback clicked_cb, | 911 | menu_callback clicked_cb, |
914 | enabled_callback enabled_cb, | 912 | enabled_callback enabled_cb, |
915 | check_callback check_cb, | 913 | check_callback check_cb, |
@@ -921,11 +919,11 @@ LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, | |||
921 | { | 919 | { |
922 | } | 920 | } |
923 | 921 | ||
924 | LLMenuItemCheckGL::LLMenuItemCheckGL ( const LLString& name, | 922 | LLMenuItemCheckGL::LLMenuItemCheckGL ( const std::string& name, |
925 | const LLString& label, | 923 | const std::string& label, |
926 | menu_callback clicked_cb, | 924 | menu_callback clicked_cb, |
927 | enabled_callback enabled_cb, | 925 | enabled_callback enabled_cb, |
928 | LLString control_name, | 926 | std::string control_name, |
929 | LLView *context, | 927 | LLView *context, |
930 | void* user_data, | 928 | void* user_data, |
931 | KEY key, MASK mask ) : | 929 | KEY key, MASK mask ) : |
@@ -949,7 +947,7 @@ void LLMenuItemCheckGL::setValue(const LLSD& value) | |||
949 | } | 947 | } |
950 | } | 948 | } |
951 | 949 | ||
952 | void LLMenuItemCheckGL::setCheckedControl(LLString checked_control, LLView *context) | 950 | void LLMenuItemCheckGL::setCheckedControl(std::string checked_control, LLView *context) |
953 | { | 951 | { |
954 | // Register new listener | 952 | // Register new listener |
955 | if (!checked_control.empty()) | 953 | if (!checked_control.empty()) |
@@ -992,14 +990,14 @@ void LLMenuItemCheckGL::buildDrawLabel( void ) | |||
992 | /// Class LLMenuItemToggleGL | 990 | /// Class LLMenuItemToggleGL |
993 | ///============================================================================ | 991 | ///============================================================================ |
994 | 992 | ||
995 | LLMenuItemToggleGL::LLMenuItemToggleGL( const LLString& name, const LLString& label, BOOL* toggle, | 993 | LLMenuItemToggleGL::LLMenuItemToggleGL( const std::string& name, const std::string& label, BOOL* toggle, |
996 | KEY key, MASK mask ) : | 994 | KEY key, MASK mask ) : |
997 | LLMenuItemGL( name, label, key, mask ), | 995 | LLMenuItemGL( name, label, key, mask ), |
998 | mToggle( toggle ) | 996 | mToggle( toggle ) |
999 | { | 997 | { |
1000 | } | 998 | } |
1001 | 999 | ||
1002 | LLMenuItemToggleGL::LLMenuItemToggleGL( const LLString& name, BOOL* toggle, | 1000 | LLMenuItemToggleGL::LLMenuItemToggleGL( const std::string& name, BOOL* toggle, |
1003 | KEY key, MASK mask ) : | 1001 | KEY key, MASK mask ) : |
1004 | LLMenuItemGL( name, name, key, mask ), | 1002 | LLMenuItemGL( name, name, key, mask ), |
1005 | mToggle( toggle ) | 1003 | mToggle( toggle ) |
@@ -1019,7 +1017,7 @@ void LLMenuItemToggleGL::buildDrawLabel( void ) | |||
1019 | mDrawBoolLabel.clear(); | 1017 | mDrawBoolLabel.clear(); |
1020 | } | 1018 | } |
1021 | mDrawAccelLabel.clear(); | 1019 | mDrawAccelLabel.clear(); |
1022 | LLString st = mDrawAccelLabel; | 1020 | std::string st = mDrawAccelLabel; |
1023 | appendAcceleratorString( st ); | 1021 | appendAcceleratorString( st ); |
1024 | mDrawAccelLabel = st; | 1022 | mDrawAccelLabel = st; |
1025 | } | 1023 | } |
@@ -1035,7 +1033,7 @@ void LLMenuItemToggleGL::doIt( void ) | |||
1035 | } | 1033 | } |
1036 | 1034 | ||
1037 | 1035 | ||
1038 | LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& label, LLMenuGL* branch, | 1036 | LLMenuItemBranchGL::LLMenuItemBranchGL( const std::string& name, const std::string& label, LLMenuGL* branch, |
1039 | KEY key, MASK mask ) : | 1037 | KEY key, MASK mask ) : |
1040 | LLMenuItemGL( name, label, key, mask ), | 1038 | LLMenuItemGL( name, label, key, mask ), |
1041 | mBranch( branch ) | 1039 | mBranch( branch ) |
@@ -1045,7 +1043,7 @@ LLMenuItemBranchGL::LLMenuItemBranchGL( const LLString& name, const LLString& la | |||
1045 | } | 1043 | } |
1046 | 1044 | ||
1047 | // virtual | 1045 | // virtual |
1048 | LLView* LLMenuItemBranchGL::getChildView(const LLString& name, BOOL recurse, BOOL create_if_missing) const | 1046 | LLView* LLMenuItemBranchGL::getChildView(const std::string& name, BOOL recurse, BOOL create_if_missing) const |
1049 | { | 1047 | { |
1050 | // richard: this is redundant with parent, remove | 1048 | // richard: this is redundant with parent, remove |
1051 | if (mBranch->getName() == name) | 1049 | if (mBranch->getName() == name) |
@@ -1111,7 +1109,7 @@ BOOL LLMenuItemBranchGL::addToAcceleratorList(std::list<LLKeyBinding*> *listp) | |||
1111 | void LLMenuItemBranchGL::buildDrawLabel( void ) | 1109 | void LLMenuItemBranchGL::buildDrawLabel( void ) |
1112 | { | 1110 | { |
1113 | mDrawAccelLabel.clear(); | 1111 | mDrawAccelLabel.clear(); |
1114 | LLString st = mDrawAccelLabel; | 1112 | std::string st = mDrawAccelLabel; |
1115 | appendAcceleratorString( st ); | 1113 | appendAcceleratorString( st ); |
1116 | mDrawAccelLabel = st; | 1114 | mDrawAccelLabel = st; |
1117 | mDrawBranchLabel = BRANCH_SUFFIX; | 1115 | mDrawBranchLabel = BRANCH_SUFFIX; |
@@ -1327,10 +1325,10 @@ class LLMenuItemBranchDownGL : public LLMenuItemBranchGL | |||
1327 | protected: | 1325 | protected: |
1328 | 1326 | ||
1329 | public: | 1327 | public: |
1330 | LLMenuItemBranchDownGL( const LLString& name, const LLString& label, LLMenuGL* branch, | 1328 | LLMenuItemBranchDownGL( const std::string& name, const std::string& label, LLMenuGL* branch, |
1331 | KEY key = KEY_NONE, MASK mask = MASK_NONE ); | 1329 | KEY key = KEY_NONE, MASK mask = MASK_NONE ); |
1332 | 1330 | ||
1333 | virtual LLString getType() const { return "menu"; } | 1331 | virtual std::string getType() const { return "menu"; } |
1334 | 1332 | ||
1335 | // returns the normal width of this control in pixels - this is | 1333 | // returns the normal width of this control in pixels - this is |
1336 | // used for calculating the widest item, as well as for horizontal | 1334 | // used for calculating the widest item, as well as for horizontal |
@@ -1358,8 +1356,8 @@ public: | |||
1358 | virtual BOOL handleAcceleratorKey(KEY key, MASK mask); | 1356 | virtual BOOL handleAcceleratorKey(KEY key, MASK mask); |
1359 | }; | 1357 | }; |
1360 | 1358 | ||
1361 | LLMenuItemBranchDownGL::LLMenuItemBranchDownGL( const LLString& name, | 1359 | LLMenuItemBranchDownGL::LLMenuItemBranchDownGL( const std::string& name, |
1362 | const LLString& label, | 1360 | const std::string& label, |
1363 | LLMenuGL* branch, | 1361 | LLMenuGL* branch, |
1364 | KEY key, MASK mask ) : | 1362 | KEY key, MASK mask ) : |
1365 | LLMenuItemBranchGL( name, label, branch, key, mask ) | 1363 | LLMenuItemBranchGL( name, label, branch, key, mask ) |
@@ -1380,7 +1378,7 @@ U32 LLMenuItemBranchDownGL::getNominalWidth( void ) const | |||
1380 | void LLMenuItemBranchDownGL::buildDrawLabel( void ) | 1378 | void LLMenuItemBranchDownGL::buildDrawLabel( void ) |
1381 | { | 1379 | { |
1382 | mDrawAccelLabel.clear(); | 1380 | mDrawAccelLabel.clear(); |
1383 | LLString st = mDrawAccelLabel; | 1381 | std::string st = mDrawAccelLabel; |
1384 | appendAcceleratorString( st ); | 1382 | appendAcceleratorString( st ); |
1385 | mDrawAccelLabel = st; | 1383 | mDrawAccelLabel = st; |
1386 | } | 1384 | } |
@@ -1593,8 +1591,8 @@ void LLMenuItemBranchDownGL::draw( void ) | |||
1593 | // underline navigation key only when keyboard navigation has been initiated | 1591 | // underline navigation key only when keyboard navigation has been initiated |
1594 | if (getMenu()->jumpKeysActive() && LLMenuGL::getKeyboardMode()) | 1592 | if (getMenu()->jumpKeysActive() && LLMenuGL::getKeyboardMode()) |
1595 | { | 1593 | { |
1596 | LLString upper_case_label = mLabel.getString(); | 1594 | std::string upper_case_label = mLabel.getString(); |
1597 | LLString::toUpper(upper_case_label); | 1595 | LLStringUtil::toUpper(upper_case_label); |
1598 | std::string::size_type offset = upper_case_label.find(getJumpKey()); | 1596 | std::string::size_type offset = upper_case_label.find(getJumpKey()); |
1599 | if (offset != std::string::npos) | 1597 | if (offset != std::string::npos) |
1600 | { | 1598 | { |
@@ -1617,7 +1615,7 @@ void LLMenuItemBranchDownGL::draw( void ) | |||
1617 | static LLRegisterWidget<LLMenuGL> r1("menu"); | 1615 | static LLRegisterWidget<LLMenuGL> r1("menu"); |
1618 | 1616 | ||
1619 | // Default constructor | 1617 | // Default constructor |
1620 | LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloater> parent_floater_handle ) | 1618 | LLMenuGL::LLMenuGL( const std::string& name, const std::string& label, LLHandle<LLFloater> parent_floater_handle ) |
1621 | : LLUICtrl( name, LLRect(), FALSE, NULL, NULL ), | 1619 | : LLUICtrl( name, LLRect(), FALSE, NULL, NULL ), |
1622 | mBackgroundColor( sDefaultBackgroundColor ), | 1620 | mBackgroundColor( sDefaultBackgroundColor ), |
1623 | mBgVisible( TRUE ), | 1621 | mBgVisible( TRUE ), |
@@ -1642,7 +1640,7 @@ LLMenuGL::LLMenuGL( const LLString& name, const LLString& label, LLHandle<LLFloa | |||
1642 | setTabStop(FALSE); | 1640 | setTabStop(FALSE); |
1643 | } | 1641 | } |
1644 | 1642 | ||
1645 | LLMenuGL::LLMenuGL( const LLString& label, LLHandle<LLFloater> parent_floater_handle ) | 1643 | LLMenuGL::LLMenuGL( const std::string& label, LLHandle<LLFloater> parent_floater_handle ) |
1646 | : LLUICtrl( label, LLRect(), FALSE, NULL, NULL ), | 1644 | : LLUICtrl( label, LLRect(), FALSE, NULL, NULL ), |
1647 | mBackgroundColor( sDefaultBackgroundColor ), | 1645 | mBackgroundColor( sDefaultBackgroundColor ), |
1648 | mBgVisible( TRUE ), | 1646 | mBgVisible( TRUE ), |
@@ -1751,10 +1749,10 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1751 | { | 1749 | { |
1752 | LLMenuItemGL *item = NULL; | 1750 | LLMenuItemGL *item = NULL; |
1753 | 1751 | ||
1754 | LLString type; | 1752 | std::string type; |
1755 | LLString item_name; | 1753 | std::string item_name; |
1756 | LLString source_label; | 1754 | std::string source_label; |
1757 | LLString item_label; | 1755 | std::string item_label; |
1758 | KEY jump_key = KEY_NONE; | 1756 | KEY jump_key = KEY_NONE; |
1759 | 1757 | ||
1760 | child->getAttributeString("type", type); | 1758 | child->getAttributeString("type", type); |
@@ -1796,7 +1794,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1796 | child->getAttributeBOOL("useMacCtrl", useMacCtrl); | 1794 | child->getAttributeBOOL("useMacCtrl", useMacCtrl); |
1797 | #endif // LL_DARWIN | 1795 | #endif // LL_DARWIN |
1798 | 1796 | ||
1799 | LLString shortcut; | 1797 | std::string shortcut; |
1800 | child->getAttributeString("shortcut", shortcut); | 1798 | child->getAttributeString("shortcut", shortcut); |
1801 | if (shortcut.find("control") != shortcut.npos) | 1799 | if (shortcut.find("control") != shortcut.npos) |
1802 | { | 1800 | { |
@@ -1817,7 +1815,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1817 | mask |= MASK_SHIFT; | 1815 | mask |= MASK_SHIFT; |
1818 | } | 1816 | } |
1819 | S32 pipe_pos = shortcut.rfind("|"); | 1817 | S32 pipe_pos = shortcut.rfind("|"); |
1820 | LLString key_str = shortcut.substr(pipe_pos+1); | 1818 | std::string key_str = shortcut.substr(pipe_pos+1); |
1821 | 1819 | ||
1822 | KEY key = KEY_NONE; | 1820 | KEY key = KEY_NONE; |
1823 | LLKeyboard::keyFromString(key_str, &key); | 1821 | LLKeyboard::keyFromString(key_str, &key); |
@@ -1827,7 +1825,7 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1827 | 1825 | ||
1828 | if (child->hasName(LL_MENU_ITEM_CHECK_GL_TAG)) | 1826 | if (child->hasName(LL_MENU_ITEM_CHECK_GL_TAG)) |
1829 | { | 1827 | { |
1830 | LLString control_name; | 1828 | std::string control_name; |
1831 | child->getAttributeString("control_name", control_name); | 1829 | child->getAttributeString("control_name", control_name); |
1832 | 1830 | ||
1833 | new_item = new LLMenuItemCheckGL(item_name, item_label, 0, 0, control_name, parent, 0, key, mask); | 1831 | new_item = new LLMenuItemCheckGL(item_name, item_label, 0, 0, control_name, parent, 0, key, mask); |
@@ -1836,15 +1834,15 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1836 | { | 1834 | { |
1837 | if (call_child->hasName("on_check")) | 1835 | if (call_child->hasName("on_check")) |
1838 | { | 1836 | { |
1839 | LLString callback_name; | 1837 | std::string callback_name; |
1840 | LLString control_name = ""; | 1838 | std::string control_name; |
1841 | if (call_child->hasAttribute("function")) | 1839 | if (call_child->hasAttribute("function")) |
1842 | { | 1840 | { |
1843 | call_child->getAttributeString("function", callback_name); | 1841 | call_child->getAttributeString("function", callback_name); |
1844 | 1842 | ||
1845 | control_name = callback_name; | 1843 | control_name = callback_name; |
1846 | 1844 | ||
1847 | LLString callback_data = item_name; | 1845 | std::string callback_data = item_name; |
1848 | if (call_child->hasAttribute("userdata")) | 1846 | if (call_child->hasAttribute("userdata")) |
1849 | { | 1847 | { |
1850 | call_child->getAttributeString("userdata", callback_data); | 1848 | call_child->getAttributeString("userdata", callback_data); |
@@ -1890,10 +1888,10 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1890 | { | 1888 | { |
1891 | if (call_child->hasName("on_click")) | 1889 | if (call_child->hasName("on_click")) |
1892 | { | 1890 | { |
1893 | LLString callback_name; | 1891 | std::string callback_name; |
1894 | call_child->getAttributeString("function", callback_name); | 1892 | call_child->getAttributeString("function", callback_name); |
1895 | 1893 | ||
1896 | LLString callback_data = item_name; | 1894 | std::string callback_data = item_name; |
1897 | if (call_child->hasAttribute("userdata")) | 1895 | if (call_child->hasAttribute("userdata")) |
1898 | { | 1896 | { |
1899 | call_child->getAttributeString("userdata", callback_data); | 1897 | call_child->getAttributeString("userdata", callback_data); |
@@ -1907,15 +1905,15 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1907 | } | 1905 | } |
1908 | if (call_child->hasName("on_enable")) | 1906 | if (call_child->hasName("on_enable")) |
1909 | { | 1907 | { |
1910 | LLString callback_name; | 1908 | std::string callback_name; |
1911 | LLString control_name = ""; | 1909 | std::string control_name; |
1912 | if (call_child->hasAttribute("function")) | 1910 | if (call_child->hasAttribute("function")) |
1913 | { | 1911 | { |
1914 | call_child->getAttributeString("function", callback_name); | 1912 | call_child->getAttributeString("function", callback_name); |
1915 | 1913 | ||
1916 | control_name = callback_name; | 1914 | control_name = callback_name; |
1917 | 1915 | ||
1918 | LLString callback_data = ""; | 1916 | std::string callback_data; |
1919 | if (call_child->hasAttribute("userdata")) | 1917 | if (call_child->hasAttribute("userdata")) |
1920 | { | 1918 | { |
1921 | call_child->getAttributeString("userdata", callback_data); | 1919 | call_child->getAttributeString("userdata", callback_data); |
@@ -1947,15 +1945,15 @@ void LLMenuGL::parseChildXML(LLXMLNodePtr child, LLView *parent, LLUICtrlFactory | |||
1947 | } | 1945 | } |
1948 | if (call_child->hasName("on_visible")) | 1946 | if (call_child->hasName("on_visible")) |
1949 | { | 1947 | { |
1950 | LLString callback_name; | 1948 | std::string callback_name; |
1951 | LLString control_name = ""; | 1949 | std::string control_name; |
1952 | if (call_child->hasAttribute("function")) | 1950 | if (call_child->hasAttribute("function")) |
1953 | { | 1951 | { |
1954 | call_child->getAttributeString("function", callback_name); | 1952 | call_child->getAttributeString("function", callback_name); |
1955 | 1953 | ||
1956 | control_name = callback_name; | 1954 | control_name = callback_name; |
1957 | 1955 | ||
1958 | LLString callback_data = ""; | 1956 | std::string callback_data; |
1959 | if (call_child->hasAttribute("userdata")) | 1957 | if (call_child->hasAttribute("userdata")) |
1960 | { | 1958 | { |
1961 | call_child->getAttributeString("userdata", callback_data); | 1959 | call_child->getAttributeString("userdata", callback_data); |
@@ -2047,14 +2045,14 @@ BOOL LLMenuGL::isOpen() | |||
2047 | // static | 2045 | // static |
2048 | LLView* LLMenuGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) | 2046 | LLView* LLMenuGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) |
2049 | { | 2047 | { |
2050 | LLString name("menu"); | 2048 | std::string name("menu"); |
2051 | node->getAttributeString("name", name); | 2049 | node->getAttributeString("name", name); |
2052 | 2050 | ||
2053 | LLString label = name; | 2051 | std::string label = name; |
2054 | node->getAttributeString("label", label); | 2052 | node->getAttributeString("label", label); |
2055 | 2053 | ||
2056 | // parse jump key out of label | 2054 | // parse jump key out of label |
2057 | LLString new_menu_label; | 2055 | std::string new_menu_label; |
2058 | 2056 | ||
2059 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; | 2057 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; |
2060 | boost::char_separator<char> sep("_"); | 2058 | boost::char_separator<char> sep("_"); |
@@ -2134,7 +2132,7 @@ void LLMenuGL::arrange( void ) | |||
2134 | U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth(); | 2132 | U32 max_width = getTornOff() ? U32_MAX : menu_region_rect.getWidth(); |
2135 | U32 max_height = getTornOff() ? U32_MAX : menu_region_rect.getHeight(); | 2133 | U32 max_height = getTornOff() ? U32_MAX : menu_region_rect.getHeight(); |
2136 | // *FIX: create the item first and then ask for its dimensions? | 2134 | // *FIX: create the item first and then ask for its dimensions? |
2137 | S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( "More" ); | 2135 | S32 spillover_item_width = PLAIN_PAD_PIXELS + LLFontGL::sSansSerif->getWidth( std::string("More") ); |
2138 | S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING; | 2136 | S32 spillover_item_height = llround(LLFontGL::sSansSerif->getLineHeight()) + MENU_ITEM_PADDING; |
2139 | 2137 | ||
2140 | if (mHorizontalLayout) | 2138 | if (mHorizontalLayout) |
@@ -2251,13 +2249,13 @@ void LLMenuGL::createSpilloverBranch() | |||
2251 | delete mSpilloverMenu; | 2249 | delete mSpilloverMenu; |
2252 | // technically, you can't tear off spillover menus, but we're passing the handle | 2250 | // technically, you can't tear off spillover menus, but we're passing the handle |
2253 | // along just to be safe | 2251 | // along just to be safe |
2254 | mSpilloverMenu = new LLMenuGL("More", "More", mParentFloaterHandle); | 2252 | mSpilloverMenu = new LLMenuGL(std::string("More"), std::string("More"), mParentFloaterHandle); |
2255 | mSpilloverMenu->updateParent(LLMenuGL::sMenuContainer); | 2253 | mSpilloverMenu->updateParent(LLMenuGL::sMenuContainer); |
2256 | // Inherit colors | 2254 | // Inherit colors |
2257 | mSpilloverMenu->setBackgroundColor( mBackgroundColor ); | 2255 | mSpilloverMenu->setBackgroundColor( mBackgroundColor ); |
2258 | mSpilloverMenu->setCanTearOff(FALSE); | 2256 | mSpilloverMenu->setCanTearOff(FALSE); |
2259 | 2257 | ||
2260 | mSpilloverBranch = new LLMenuItemBranchGL("More", "More", mSpilloverMenu); | 2258 | mSpilloverBranch = new LLMenuItemBranchGL(std::string("More"), std::string("More"), mSpilloverMenu); |
2261 | mSpilloverBranch->setFontStyle(LLFontGL::ITALIC); | 2259 | mSpilloverBranch->setFontStyle(LLFontGL::ITALIC); |
2262 | } | 2260 | } |
2263 | } | 2261 | } |
@@ -2297,8 +2295,8 @@ void LLMenuGL::createJumpKeys() | |||
2297 | { | 2295 | { |
2298 | mJumpKeys.clear(); | 2296 | mJumpKeys.clear(); |
2299 | 2297 | ||
2300 | std::set<LLString> unique_words; | 2298 | std::set<std::string> unique_words; |
2301 | std::set<LLString> shared_words; | 2299 | std::set<std::string> shared_words; |
2302 | 2300 | ||
2303 | item_list_t::iterator item_it; | 2301 | item_list_t::iterator item_it; |
2304 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; | 2302 | typedef boost::tokenizer<boost::char_separator<char> > tokenizer; |
@@ -2306,8 +2304,8 @@ void LLMenuGL::createJumpKeys() | |||
2306 | 2304 | ||
2307 | for(item_it = mItems.begin(); item_it != mItems.end(); ++item_it) | 2305 | for(item_it = mItems.begin(); item_it != mItems.end(); ++item_it) |
2308 | { | 2306 | { |
2309 | LLString uppercase_label = (*item_it)->getLabel(); | 2307 | std::string uppercase_label = (*item_it)->getLabel(); |
2310 | LLString::toUpper(uppercase_label); | 2308 | LLStringUtil::toUpper(uppercase_label); |
2311 | 2309 | ||
2312 | tokenizer tokens(uppercase_label, sep); | 2310 | tokenizer tokens(uppercase_label, sep); |
2313 | tokenizer::iterator token_iter; | 2311 | tokenizer::iterator token_iter; |
@@ -2352,8 +2350,8 @@ void LLMenuGL::createJumpKeys() | |||
2352 | { | 2350 | { |
2353 | continue; | 2351 | continue; |
2354 | } | 2352 | } |
2355 | LLString uppercase_label = (*item_it)->getLabel(); | 2353 | std::string uppercase_label = (*item_it)->getLabel(); |
2356 | LLString::toUpper(uppercase_label); | 2354 | LLStringUtil::toUpper(uppercase_label); |
2357 | 2355 | ||
2358 | tokenizer tokens(uppercase_label, sep); | 2356 | tokenizer tokens(uppercase_label, sep); |
2359 | tokenizer::iterator token_iter; | 2357 | tokenizer::iterator token_iter; |
@@ -2361,7 +2359,7 @@ void LLMenuGL::createJumpKeys() | |||
2361 | BOOL found_key = FALSE; | 2359 | BOOL found_key = FALSE; |
2362 | for( token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) | 2360 | for( token_iter = tokens.begin(); token_iter != tokens.end(); ++token_iter) |
2363 | { | 2361 | { |
2364 | LLString uppercase_word = *token_iter; | 2362 | std::string uppercase_word = *token_iter; |
2365 | 2363 | ||
2366 | // this word is not shared with other menu entries... | 2364 | // this word is not shared with other menu entries... |
2367 | if (shared_words.find(*token_iter) == shared_words.end()) | 2365 | if (shared_words.find(*token_iter) == shared_words.end()) |
@@ -2441,9 +2439,13 @@ BOOL LLMenuGL::append( LLMenuItemGL* item ) | |||
2441 | } | 2439 | } |
2442 | 2440 | ||
2443 | // add a separator to this menu | 2441 | // add a separator to this menu |
2444 | BOOL LLMenuGL::appendSeparator( const LLString &separator_name ) | 2442 | BOOL LLMenuGL::appendSeparator( const std::string &separator_name ) |
2445 | { | 2443 | { |
2446 | LLMenuItemGL* separator = new LLMenuItemSeparatorGL(separator_name); | 2444 | LLMenuItemGL* separator; |
2445 | if (separator_name.empty()) | ||
2446 | separator = new LLMenuItemSeparatorGL(std::string("separator")); | ||
2447 | else | ||
2448 | separator = new LLMenuItemSeparatorGL(separator_name); | ||
2447 | return append( separator ); | 2449 | return append( separator ); |
2448 | } | 2450 | } |
2449 | 2451 | ||
@@ -2480,7 +2482,7 @@ void LLMenuGL::setEnabledSubMenus(BOOL enable) | |||
2480 | 2482 | ||
2481 | // setItemEnabled() - pass the label and the enable flag for a menu | 2483 | // setItemEnabled() - pass the label and the enable flag for a menu |
2482 | // item. TRUE will make sure it's enabled, FALSE will disable it. | 2484 | // item. TRUE will make sure it's enabled, FALSE will disable it. |
2483 | void LLMenuGL::setItemEnabled( const LLString& name, BOOL enable ) | 2485 | void LLMenuGL::setItemEnabled( const std::string& name, BOOL enable ) |
2484 | { | 2486 | { |
2485 | item_list_t::iterator item_iter; | 2487 | item_list_t::iterator item_iter; |
2486 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) | 2488 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) |
@@ -2494,7 +2496,7 @@ void LLMenuGL::setItemEnabled( const LLString& name, BOOL enable ) | |||
2494 | } | 2496 | } |
2495 | } | 2497 | } |
2496 | 2498 | ||
2497 | void LLMenuGL::setItemVisible( const LLString& name, BOOL visible ) | 2499 | void LLMenuGL::setItemVisible( const std::string& name, BOOL visible ) |
2498 | { | 2500 | { |
2499 | item_list_t::iterator item_iter; | 2501 | item_list_t::iterator item_iter; |
2500 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) | 2502 | for (item_iter = mItems.begin(); item_iter != mItems.end(); ++item_iter) |
@@ -2873,7 +2875,7 @@ void LLMenuGL::setVisible(BOOL visible) | |||
2873 | } | 2875 | } |
2874 | } | 2876 | } |
2875 | 2877 | ||
2876 | LLMenuGL* LLMenuGL::getChildMenuByName(const LLString& name, BOOL recurse) const | 2878 | LLMenuGL* LLMenuGL::getChildMenuByName(const std::string& name, BOOL recurse) const |
2877 | { | 2879 | { |
2878 | LLView* view = getChildView(name, recurse, FALSE); | 2880 | LLView* view = getChildView(name, recurse, FALSE); |
2879 | if (view) | 2881 | if (view) |
@@ -2965,7 +2967,7 @@ void LLMenuGL::showPopup(LLView* spawning_view, LLMenuGL* menu, S32 x, S32 y) | |||
2965 | class LLPieMenuBranch : public LLMenuItemGL | 2967 | class LLPieMenuBranch : public LLMenuItemGL |
2966 | { | 2968 | { |
2967 | public: | 2969 | public: |
2968 | LLPieMenuBranch(const LLString& name, const LLString& label, LLPieMenu* branch); | 2970 | LLPieMenuBranch(const std::string& name, const std::string& label, LLPieMenu* branch); |
2969 | 2971 | ||
2970 | // called to rebuild the draw label | 2972 | // called to rebuild the draw label |
2971 | virtual void buildDrawLabel( void ); | 2973 | virtual void buildDrawLabel( void ); |
@@ -2979,8 +2981,8 @@ protected: | |||
2979 | LLPieMenu* mBranch; | 2981 | LLPieMenu* mBranch; |
2980 | }; | 2982 | }; |
2981 | 2983 | ||
2982 | LLPieMenuBranch::LLPieMenuBranch(const LLString& name, | 2984 | LLPieMenuBranch::LLPieMenuBranch(const std::string& name, |
2983 | const LLString& label, | 2985 | const std::string& label, |
2984 | LLPieMenu* branch) | 2986 | LLPieMenu* branch) |
2985 | : LLMenuItemGL( name, label, KEY_NONE, MASK_NONE ), | 2987 | : LLMenuItemGL( name, label, KEY_NONE, MASK_NONE ), |
2986 | mBranch( branch ) | 2988 | mBranch( branch ) |
@@ -3013,7 +3015,7 @@ void LLPieMenuBranch::buildDrawLabel( void ) | |||
3013 | } | 3015 | } |
3014 | 3016 | ||
3015 | mDrawAccelLabel.clear(); | 3017 | mDrawAccelLabel.clear(); |
3016 | LLString st = mDrawAccelLabel; | 3018 | std::string st = mDrawAccelLabel; |
3017 | appendAcceleratorString( st ); | 3019 | appendAcceleratorString( st ); |
3018 | mDrawAccelLabel = st; | 3020 | mDrawAccelLabel = st; |
3019 | 3021 | ||
@@ -3039,7 +3041,7 @@ void LLPieMenuBranch::doIt( void ) | |||
3039 | // class LLPieMenu | 3041 | // class LLPieMenu |
3040 | // A circular menu of items, icons, etc. | 3042 | // A circular menu of items, icons, etc. |
3041 | //----------------------------------------------------------------------------- | 3043 | //----------------------------------------------------------------------------- |
3042 | LLPieMenu::LLPieMenu(const LLString& name, const LLString& label) | 3044 | LLPieMenu::LLPieMenu(const std::string& name, const std::string& label) |
3043 | : LLMenuGL(name, label), | 3045 | : LLMenuGL(name, label), |
3044 | mFirstMouseDown(FALSE), | 3046 | mFirstMouseDown(FALSE), |
3045 | mUseInfiniteRadius(FALSE), | 3047 | mUseInfiniteRadius(FALSE), |
@@ -3054,7 +3056,7 @@ LLPieMenu::LLPieMenu(const LLString& name, const LLString& label) | |||
3054 | setCanTearOff(FALSE); | 3056 | setCanTearOff(FALSE); |
3055 | } | 3057 | } |
3056 | 3058 | ||
3057 | LLPieMenu::LLPieMenu(const LLString& name) | 3059 | LLPieMenu::LLPieMenu(const std::string& name) |
3058 | : LLMenuGL(name, name), | 3060 | : LLMenuGL(name, name), |
3059 | mFirstMouseDown(FALSE), | 3061 | mFirstMouseDown(FALSE), |
3060 | mUseInfiniteRadius(FALSE), | 3062 | mUseInfiniteRadius(FALSE), |
@@ -3078,9 +3080,9 @@ void LLPieMenu::initXML(LLXMLNodePtr node, LLView *context, LLUICtrlFactory *fac | |||
3078 | if (child->hasName(LL_PIE_MENU_TAG)) | 3080 | if (child->hasName(LL_PIE_MENU_TAG)) |
3079 | { | 3081 | { |
3080 | // SUBMENU | 3082 | // SUBMENU |
3081 | LLString name("menu"); | 3083 | std::string name("menu"); |
3082 | child->getAttributeString("name", name); | 3084 | child->getAttributeString("name", name); |
3083 | LLString label(name); | 3085 | std::string label(name); |
3084 | child->getAttributeString("label", label); | 3086 | child->getAttributeString("label", label); |
3085 | 3087 | ||
3086 | LLPieMenu *submenu = new LLPieMenu(name, label); | 3088 | LLPieMenu *submenu = new LLPieMenu(name, label); |
@@ -3458,7 +3460,7 @@ BOOL LLPieMenu::append(LLMenuItemGL *item) | |||
3458 | } | 3460 | } |
3459 | 3461 | ||
3460 | // virtual | 3462 | // virtual |
3461 | BOOL LLPieMenu::appendSeparator(const LLString &separator_name) | 3463 | BOOL LLPieMenu::appendSeparator(const std::string &separator_name) |
3462 | { | 3464 | { |
3463 | LLMenuItemGL* separator = new LLMenuItemBlankGL(); | 3465 | LLMenuItemGL* separator = new LLMenuItemBlankGL(); |
3464 | separator->setFont( LLFontGL::sSansSerifSmall ); | 3466 | separator->setFont( LLFontGL::sSansSerifSmall ); |
@@ -3482,8 +3484,8 @@ BOOL LLPieMenu::appendPieMenu(LLPieMenu *menu) | |||
3482 | // virtual | 3484 | // virtual |
3483 | void LLPieMenu::arrange() | 3485 | void LLPieMenu::arrange() |
3484 | { | 3486 | { |
3485 | const S32 rect_height = 180; | 3487 | const S32 rect_height = 190; |
3486 | const S32 rect_width = 180; | 3488 | const S32 rect_width = 190; |
3487 | 3489 | ||
3488 | // all divide by 6 | 3490 | // all divide by 6 |
3489 | const S32 CARD_X = 60; | 3491 | const S32 CARD_X = 60; |
@@ -3739,7 +3741,7 @@ void LLPieMenu::hide(BOOL item_selected) | |||
3739 | static LLRegisterWidget<LLMenuBarGL> r2("menu_bar"); | 3741 | static LLRegisterWidget<LLMenuBarGL> r2("menu_bar"); |
3740 | 3742 | ||
3741 | // Default constructor | 3743 | // Default constructor |
3742 | LLMenuBarGL::LLMenuBarGL( const LLString& name ) : LLMenuGL ( name, name ) | 3744 | LLMenuBarGL::LLMenuBarGL( const std::string& name ) : LLMenuGL ( name, name ) |
3743 | { | 3745 | { |
3744 | mHorizontalLayout = TRUE; | 3746 | mHorizontalLayout = TRUE; |
3745 | setCanTearOff(FALSE); | 3747 | setCanTearOff(FALSE); |
@@ -3784,7 +3786,7 @@ LLXMLNodePtr LLMenuBarGL::getXML(bool save_children) const | |||
3784 | 3786 | ||
3785 | LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) | 3787 | LLView* LLMenuBarGL::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFactory *factory) |
3786 | { | 3788 | { |
3787 | LLString name("menu"); | 3789 | std::string name("menu"); |
3788 | node->getAttributeString("name", name); | 3790 | node->getAttributeString("name", name); |
3789 | 3791 | ||
3790 | BOOL opaque = FALSE; | 3792 | BOOL opaque = FALSE; |
@@ -3879,6 +3881,8 @@ BOOL LLMenuBarGL::handleAcceleratorKey(KEY key, MASK mask) | |||
3879 | } | 3881 | } |
3880 | else | 3882 | else |
3881 | { | 3883 | { |
3884 | // close menus originating from other menu bars when first opening menu via keyboard | ||
3885 | LLMenuGL::sMenuContainer->hideMenus(); | ||
3882 | highlightNextItem(NULL); | 3886 | highlightNextItem(NULL); |
3883 | LLMenuGL::setKeyboardMode(TRUE); | 3887 | LLMenuGL::setKeyboardMode(TRUE); |
3884 | } | 3888 | } |
@@ -3898,6 +3902,13 @@ BOOL LLMenuBarGL::handleKeyHere(KEY key, MASK mask) | |||
3898 | { | 3902 | { |
3899 | mAltKeyTrigger = FALSE; | 3903 | mAltKeyTrigger = FALSE; |
3900 | } | 3904 | } |
3905 | |||
3906 | if (key == KEY_ESCAPE && mask == MASK_NONE) | ||
3907 | { | ||
3908 | LLMenuGL::setKeyboardMode(FALSE); | ||
3909 | // if any menus are visible, this will return TRUE, stopping further processing of ESCAPE key | ||
3910 | return LLMenuGL::sMenuContainer->hideMenus(); | ||
3911 | } | ||
3901 | 3912 | ||
3902 | // before processing any other key, check to see if ALT key has triggered menu access | 3913 | // before processing any other key, check to see if ALT key has triggered menu access |
3903 | checkMenuTrigger(); | 3914 | checkMenuTrigger(); |
@@ -3921,13 +3932,38 @@ BOOL LLMenuBarGL::handleJumpKey(KEY key) | |||
3921 | return TRUE; | 3932 | return TRUE; |
3922 | } | 3933 | } |
3923 | 3934 | ||
3935 | BOOL LLMenuBarGL::handleMouseDown(S32 x, S32 y, MASK mask) | ||
3936 | { | ||
3937 | // clicks on menu bar closes existing menus from other contexts but leave | ||
3938 | // own menu open so that we get toggle behavior | ||
3939 | if (!getHighlightedItem() || !getHighlightedItem()->isActive()) | ||
3940 | { | ||
3941 | LLMenuGL::sMenuContainer->hideMenus(); | ||
3942 | } | ||
3943 | |||
3944 | return LLMenuGL::handleMouseDown(x, y, mask); | ||
3945 | } | ||
3946 | |||
3947 | BOOL LLMenuBarGL::handleRightMouseDown(S32 x, S32 y, MASK mask) | ||
3948 | { | ||
3949 | // clicks on menu bar closes existing menus from other contexts but leave | ||
3950 | // own menu open so that we get toggle behavior | ||
3951 | if (!getHighlightedItem() || !getHighlightedItem()->isActive()) | ||
3952 | { | ||
3953 | LLMenuGL::sMenuContainer->hideMenus(); | ||
3954 | } | ||
3955 | |||
3956 | return LLMenuGL::handleMouseDown(x, y, mask); | ||
3957 | } | ||
3958 | |||
3959 | |||
3924 | void LLMenuBarGL::draw() | 3960 | void LLMenuBarGL::draw() |
3925 | { | 3961 | { |
3926 | LLMenuItemGL* itemp = getHighlightedItem(); | 3962 | LLMenuItemGL* itemp = getHighlightedItem(); |
3927 | // If we are in mouse-control mode and the mouse cursor is not hovering over | 3963 | // If we are in mouse-control mode and the mouse cursor is not hovering over |
3928 | // the current highlighted menu item and it isn't open, then remove the highlight. | 3964 | // the current highlighted menu item and it isn't open, then remove the |
3929 | // This is done via a polling mechanism here, as we don't receive notifications when | 3965 | // highlight. This is done via a polling mechanism here, as we don't receive |
3930 | // the mouse cursor moves off of us | 3966 | // notifications when the mouse cursor moves off of us |
3931 | if (itemp && !itemp->isOpen() && !itemp->getHover() && !LLMenuGL::getKeyboardMode()) | 3967 | if (itemp && !itemp->isOpen() && !itemp->getHover() && !LLMenuGL::getKeyboardMode()) |
3932 | { | 3968 | { |
3933 | clearHoverItem(); | 3969 | clearHoverItem(); |
@@ -3954,6 +3990,9 @@ void LLMenuBarGL::checkMenuTrigger() | |||
3954 | } | 3990 | } |
3955 | else | 3991 | else |
3956 | { | 3992 | { |
3993 | // close menus originating from other menu bars | ||
3994 | LLMenuGL::sMenuContainer->hideMenus(); | ||
3995 | |||
3957 | highlightNextItem(NULL); | 3996 | highlightNextItem(NULL); |
3958 | LLMenuGL::setKeyboardMode(TRUE); | 3997 | LLMenuGL::setKeyboardMode(TRUE); |
3959 | } | 3998 | } |
@@ -4011,7 +4050,7 @@ S32 LLMenuBarGL::getRightmostMenuEdge() | |||
4011 | } | 4050 | } |
4012 | 4051 | ||
4013 | // add a vertical separator to this menu | 4052 | // add a vertical separator to this menu |
4014 | BOOL LLMenuBarGL::appendSeparator( const LLString &separator_name ) | 4053 | BOOL LLMenuBarGL::appendSeparator( const std::string &separator_name ) |
4015 | { | 4054 | { |
4016 | LLMenuItemGL* separator = new LLMenuItemVerticalSeparatorGL(); | 4055 | LLMenuItemGL* separator = new LLMenuItemVerticalSeparatorGL(); |
4017 | return append( separator ); | 4056 | return append( separator ); |
@@ -4110,14 +4149,14 @@ BOOL LLMenuBarGL::handleHover( S32 x, S32 y, MASK mask ) | |||
4110 | /// Class LLMenuHolderGL | 4149 | /// Class LLMenuHolderGL |
4111 | ///============================================================================ | 4150 | ///============================================================================ |
4112 | LLMenuHolderGL::LLMenuHolderGL() | 4151 | LLMenuHolderGL::LLMenuHolderGL() |
4113 | : LLPanel("Menu Holder") | 4152 | : LLPanel(std::string("Menu Holder")) |
4114 | { | 4153 | { |
4115 | setMouseOpaque(FALSE); | 4154 | setMouseOpaque(FALSE); |
4116 | sItemActivationTimer.stop(); | 4155 | sItemActivationTimer.stop(); |
4117 | mCanHide = TRUE; | 4156 | mCanHide = TRUE; |
4118 | } | 4157 | } |
4119 | 4158 | ||
4120 | LLMenuHolderGL::LLMenuHolderGL(const LLString& name, const LLRect& rect, BOOL mouse_opaque, U32 follows) | 4159 | LLMenuHolderGL::LLMenuHolderGL(const std::string& name, const LLRect& rect, BOOL mouse_opaque, U32 follows) |
4121 | : LLPanel(name, rect, FALSE) | 4160 | : LLPanel(name, rect, FALSE) |
4122 | { | 4161 | { |
4123 | setMouseOpaque(mouse_opaque); | 4162 | setMouseOpaque(mouse_opaque); |
@@ -4362,6 +4401,7 @@ LLTearOffMenu* LLTearOffMenu::create(LLMenuGL* menup) | |||
4362 | // keep onscreen | 4401 | // keep onscreen |
4363 | gFloaterView->adjustToFitScreen(tearoffp, FALSE); | 4402 | gFloaterView->adjustToFitScreen(tearoffp, FALSE); |
4364 | tearoffp->open(); /* Flawfinder: ignore */ | 4403 | tearoffp->open(); /* Flawfinder: ignore */ |
4404 | |||
4365 | return tearoffp; | 4405 | return tearoffp; |
4366 | } | 4406 | } |
4367 | 4407 | ||