diff options
Diffstat (limited to 'linden/indra/llui/lllineeditor.cpp')
-rw-r--r-- | linden/indra/llui/lllineeditor.cpp | 50 |
1 files changed, 35 insertions, 15 deletions
diff --git a/linden/indra/llui/lllineeditor.cpp b/linden/indra/llui/lllineeditor.cpp index dca62d7..9671065 100644 --- a/linden/indra/llui/lllineeditor.cpp +++ b/linden/indra/llui/lllineeditor.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | * @file lllineeditor.cpp | 2 | * @file lllineeditor.cpp |
3 | * @brief LLLineEditor base class | 3 | * @brief LLLineEditor base class |
4 | * | 4 | * |
5 | * $LicenseInfo:firstyear=2001&license=viewergpl$ | ||
6 | * | ||
5 | * Copyright (c) 2001-2007, Linden Research, Inc. | 7 | * Copyright (c) 2001-2007, Linden Research, Inc. |
6 | * | 8 | * |
7 | * Second Life Viewer Source Code | 9 | * Second Life Viewer Source Code |
@@ -24,6 +26,7 @@ | |||
24 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO | 26 | * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO |
25 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, | 27 | * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY, |
26 | * COMPLETENESS OR PERFORMANCE. | 28 | * COMPLETENESS OR PERFORMANCE. |
29 | * $/LicenseInfo$ | ||
27 | */ | 30 | */ |
28 | 31 | ||
29 | // Text editor widget to let users enter a single line. | 32 | // Text editor widget to let users enter a single line. |
@@ -155,7 +158,8 @@ LLLineEditor::LLLineEditor(const LLString& name, const LLRect& rect, | |||
155 | mHandleEditKeysDirectly( FALSE ), | 158 | mHandleEditKeysDirectly( FALSE ), |
156 | mSelectAllonFocusReceived( FALSE ), | 159 | mSelectAllonFocusReceived( FALSE ), |
157 | mPassDelete(FALSE), | 160 | mPassDelete(FALSE), |
158 | mReadOnly(FALSE) | 161 | mReadOnly(FALSE), |
162 | mLastIMEPosition( -1, -1 ) | ||
159 | { | 163 | { |
160 | llassert( max_length_bytes > 0 ); | 164 | llassert( max_length_bytes > 0 ); |
161 | 165 | ||
@@ -316,12 +320,12 @@ void LLLineEditor::setBorderWidth(S32 left, S32 right) | |||
316 | mMaxHPixels = mRect.getWidth() - mMinHPixels - mBorderThickness - mBorderRight; | 320 | mMaxHPixels = mRect.getWidth() - mMinHPixels - mBorderThickness - mBorderRight; |
317 | } | 321 | } |
318 | 322 | ||
319 | void LLLineEditor::setLabel(const LLString &new_label) | 323 | void LLLineEditor::setLabel(const LLStringExplicit &new_label) |
320 | { | 324 | { |
321 | mLabel = new_label; | 325 | mLabel = new_label; |
322 | } | 326 | } |
323 | 327 | ||
324 | void LLLineEditor::setText(const LLString &new_text) | 328 | void LLLineEditor::setText(const LLStringExplicit &new_text) |
325 | { | 329 | { |
326 | // If new text is identical, don't copy and don't move insertion point | 330 | // If new text is identical, don't copy and don't move insertion point |
327 | if (mText.getString() == new_text) | 331 | if (mText.getString() == new_text) |
@@ -1629,6 +1633,17 @@ void LLLineEditor::draw() | |||
1629 | LLFontGL::NORMAL, | 1633 | LLFontGL::NORMAL, |
1630 | 1); | 1634 | 1); |
1631 | } | 1635 | } |
1636 | |||
1637 | // Make sure the IME is in the right place | ||
1638 | S32 pixels_after_scroll = findPixelNearestPos(); // RCalculcate for IME position | ||
1639 | LLRect screen_pos = getScreenRect(); | ||
1640 | LLCoordGL ime_pos( screen_pos.mLeft + pixels_after_scroll, screen_pos.mTop - UI_LINEEDITOR_V_PAD ); | ||
1641 | if ( ime_pos.mX != mLastIMEPosition.mX || ime_pos.mY != mLastIMEPosition.mY ) | ||
1642 | { | ||
1643 | mLastIMEPosition.mX = ime_pos.mX; | ||
1644 | mLastIMEPosition.mY = ime_pos.mY; | ||
1645 | getWindow()->setLanguageTextInput( ime_pos ); | ||
1646 | } | ||
1632 | } | 1647 | } |
1633 | } | 1648 | } |
1634 | 1649 | ||
@@ -1792,7 +1807,7 @@ BOOL LLLineEditor::prevalidateFloat(const LLWString &str) | |||
1792 | 1807 | ||
1793 | for( ; i < len; i++ ) | 1808 | for( ; i < len; i++ ) |
1794 | { | 1809 | { |
1795 | if( (decimal_point != trimmed[i] ) && !isdigit( trimmed[i] ) ) | 1810 | if( (decimal_point != trimmed[i] ) && !LLStringOps::isDigit( trimmed[i] ) ) |
1796 | { | 1811 | { |
1797 | success = FALSE; | 1812 | success = FALSE; |
1798 | break; | 1813 | break; |
@@ -1847,7 +1862,7 @@ BOOL LLLineEditor::postvalidateFloat(const LLString &str) | |||
1847 | } | 1862 | } |
1848 | } | 1863 | } |
1849 | else | 1864 | else |
1850 | if( isdigit( trimmed[i] ) ) | 1865 | if( LLStringOps::isDigit( trimmed[i] ) ) |
1851 | { | 1866 | { |
1852 | has_digit = TRUE; | 1867 | has_digit = TRUE; |
1853 | } | 1868 | } |
@@ -1890,7 +1905,7 @@ BOOL LLLineEditor::prevalidateInt(const LLWString &str) | |||
1890 | 1905 | ||
1891 | for( ; i < len; i++ ) | 1906 | for( ; i < len; i++ ) |
1892 | { | 1907 | { |
1893 | if( !isdigit( trimmed[i] ) ) | 1908 | if( !LLStringOps::isDigit( trimmed[i] ) ) |
1894 | { | 1909 | { |
1895 | success = FALSE; | 1910 | success = FALSE; |
1896 | break; | 1911 | break; |
@@ -1919,7 +1934,7 @@ BOOL LLLineEditor::prevalidatePositiveS32(const LLWString &str) | |||
1919 | S32 i = 0; | 1934 | S32 i = 0; |
1920 | while(success && (i < len)) | 1935 | while(success && (i < len)) |
1921 | { | 1936 | { |
1922 | if(!isdigit(trimmed[i++])) | 1937 | if(!LLStringOps::isDigit(trimmed[i++])) |
1923 | { | 1938 | { |
1924 | success = FALSE; | 1939 | success = FALSE; |
1925 | } | 1940 | } |
@@ -1953,7 +1968,7 @@ BOOL LLLineEditor::prevalidateNonNegativeS32(const LLWString &str) | |||
1953 | S32 i = 0; | 1968 | S32 i = 0; |
1954 | while(success && (i < len)) | 1969 | while(success && (i < len)) |
1955 | { | 1970 | { |
1956 | if(!isdigit(trimmed[i++])) | 1971 | if(!LLStringOps::isDigit(trimmed[i++])) |
1957 | { | 1972 | { |
1958 | success = FALSE; | 1973 | success = FALSE; |
1959 | } | 1974 | } |
@@ -2307,13 +2322,13 @@ LLSD LLLineEditor::getValue() const | |||
2307 | return ret; | 2322 | return ret; |
2308 | } | 2323 | } |
2309 | 2324 | ||
2310 | BOOL LLLineEditor::setTextArg( const LLString& key, const LLString& text ) | 2325 | BOOL LLLineEditor::setTextArg( const LLString& key, const LLStringExplicit& text ) |
2311 | { | 2326 | { |
2312 | mText.setArg(key, text); | 2327 | mText.setArg(key, text); |
2313 | return TRUE; | 2328 | return TRUE; |
2314 | } | 2329 | } |
2315 | 2330 | ||
2316 | BOOL LLLineEditor::setLabelArg( const LLString& key, const LLString& text ) | 2331 | BOOL LLLineEditor::setLabelArg( const LLString& key, const LLStringExplicit& text ) |
2317 | { | 2332 | { |
2318 | mLabel.setArg(key, text); | 2333 | mLabel.setArg(key, text); |
2319 | return TRUE; | 2334 | return TRUE; |
@@ -2338,8 +2353,7 @@ LLSearchEditor::LLSearchEditor(const LLString& name, | |||
2338 | onSearchEdit, | 2353 | onSearchEdit, |
2339 | NULL, | 2354 | NULL, |
2340 | this); | 2355 | this); |
2341 | // TODO: this should be translatable | 2356 | |
2342 | mSearchEdit->setLabel("Type here to search"); | ||
2343 | mSearchEdit->setFollowsAll(); | 2357 | mSearchEdit->setFollowsAll(); |
2344 | mSearchEdit->setSelectAllonFocusReceived(TRUE); | 2358 | mSearchEdit->setSelectAllonFocusReceived(TRUE); |
2345 | 2359 | ||
@@ -2394,13 +2408,13 @@ LLSD LLSearchEditor::getValue() const | |||
2394 | } | 2408 | } |
2395 | 2409 | ||
2396 | //virtual | 2410 | //virtual |
2397 | BOOL LLSearchEditor::setTextArg( const LLString& key, const LLString& text ) | 2411 | BOOL LLSearchEditor::setTextArg( const LLString& key, const LLStringExplicit& text ) |
2398 | { | 2412 | { |
2399 | return mSearchEdit->setTextArg(key, text); | 2413 | return mSearchEdit->setTextArg(key, text); |
2400 | } | 2414 | } |
2401 | 2415 | ||
2402 | //virtual | 2416 | //virtual |
2403 | BOOL LLSearchEditor::setLabelArg( const LLString& key, const LLString& text ) | 2417 | BOOL LLSearchEditor::setLabelArg( const LLString& key, const LLStringExplicit& text ) |
2404 | { | 2418 | { |
2405 | return mSearchEdit->setLabelArg(key, text); | 2419 | return mSearchEdit->setLabelArg(key, text); |
2406 | } | 2420 | } |
@@ -2422,7 +2436,7 @@ void LLSearchEditor::draw() | |||
2422 | LLUICtrl::draw(); | 2436 | LLUICtrl::draw(); |
2423 | } | 2437 | } |
2424 | 2438 | ||
2425 | void LLSearchEditor::setText(const LLString &new_text) | 2439 | void LLSearchEditor::setText(const LLStringExplicit &new_text) |
2426 | { | 2440 | { |
2427 | mSearchEdit->setText(new_text); | 2441 | mSearchEdit->setText(new_text); |
2428 | } | 2442 | } |
@@ -2468,6 +2482,12 @@ LLView* LLSearchEditor::fromXML(LLXMLNodePtr node, LLView *parent, LLUICtrlFacto | |||
2468 | max_text_length, | 2482 | max_text_length, |
2469 | NULL, NULL); | 2483 | NULL, NULL); |
2470 | 2484 | ||
2485 | LLString label; | ||
2486 | if(node->getAttributeString("label", label)) | ||
2487 | { | ||
2488 | search_editor->mSearchEdit->setLabel(label); | ||
2489 | } | ||
2490 | |||
2471 | search_editor->setText(text); | 2491 | search_editor->setText(text); |
2472 | 2492 | ||
2473 | search_editor->initFromXML(node, parent); | 2493 | search_editor->initFromXML(node, parent); |