summaryrefslogtreecommitdiff
path: root/indra/llui
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2010-02-08 09:50:04 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2010-02-08 09:50:04 -0500
commit5dda2516ad599d3c295930fb3fc0c6cdbe8c2ce5 (patch)
tree06d761559a50b8df3db4dffa32c6ad28ce398c11 /indra/llui
parentf5b82a377256d5806ec101e8a9d90533ea1a3bf9 (diff)
parentbb977a194f42cafdcf3f1245adf3b7f49857e552 (diff)
merge
Diffstat (limited to 'indra/llui')
-rw-r--r--indra/llui/CMakeLists.txt2
-rw-r--r--indra/llui/llbutton.cpp17
-rw-r--r--indra/llui/lllayoutstack.cpp5
-rw-r--r--indra/llui/lllineeditor.cpp313
-rw-r--r--indra/llui/lllineeditor.h38
-rw-r--r--indra/llui/llmenugl.cpp1
-rw-r--r--indra/llui/llmultifloater.cpp8
-rw-r--r--indra/llui/llmultisliderctrl.cpp2
-rw-r--r--indra/llui/llpanel.cpp2
-rw-r--r--indra/llui/llpanel.h2
-rw-r--r--indra/llui/llsliderctrl.cpp2
-rw-r--r--indra/llui/llspinctrl.cpp2
-rw-r--r--indra/llui/lltabcontainer.cpp147
-rw-r--r--indra/llui/lltabcontainer.h18
-rw-r--r--indra/llui/lltextbase.cpp1
-rw-r--r--indra/llui/lltexteditor.cpp54
-rw-r--r--indra/llui/lltexteditor.h10
-rw-r--r--indra/llui/lltextvalidate.cpp302
-rw-r--r--indra/llui/lltextvalidate.h63
-rw-r--r--indra/llui/lltooltip.h3
-rw-r--r--indra/llui/llview.cpp2
21 files changed, 655 insertions, 339 deletions
diff --git a/indra/llui/CMakeLists.txt b/indra/llui/CMakeLists.txt
index ce068618e2..853f6f173d 100644
--- a/indra/llui/CMakeLists.txt
+++ b/indra/llui/CMakeLists.txt
@@ -90,6 +90,7 @@ set(llui_SOURCE_FILES
lltextbox.cpp
lltexteditor.cpp
lltextparser.cpp
+ lltextvalidate.cpp
lltransutil.cpp
lltoggleablemenu.cpp
lltooltip.cpp
@@ -182,6 +183,7 @@ set(llui_HEADER_FILES
lltextbox.h
lltexteditor.h
lltextparser.h
+ lltextvalidate.h
lltoggleablemenu.h
lltooltip.h
lltransutil.h
diff --git a/indra/llui/llbutton.cpp b/indra/llui/llbutton.cpp
index 4944ed4fe7..14b77925f2 100644
--- a/indra/llui/llbutton.cpp
+++ b/indra/llui/llbutton.cpp
@@ -771,12 +771,7 @@ void LLButton::draw()
center_x++;
}
- S32 text_width_delta = overlay_width + 1;
- // if image paddings set, they should participate in scaling process
- S32 image_size_delta = mImageOverlayTopPad + mImageOverlayBottomPad;
- overlay_width = overlay_width - image_size_delta;
- overlay_height = overlay_height - image_size_delta;
-
+ center_y += (mImageOverlayBottomPad - mImageOverlayTopPad);
// fade out overlay images on disabled buttons
LLColor4 overlay_color = mImageOverlayColor.get();
if (!enabled)
@@ -788,10 +783,9 @@ void LLButton::draw()
switch(mImageOverlayAlignment)
{
case LLFontGL::LEFT:
- text_left += overlay_width + mImageOverlayRightPad + 1;
- text_width -= text_width_delta;
+ text_left += overlay_width + 1;
mImageOverlay->draw(
- mLeftHPad,
+ mImageOverlayLeftPad,
center_y - (overlay_height / 2),
overlay_width,
overlay_height,
@@ -806,10 +800,9 @@ void LLButton::draw()
overlay_color);
break;
case LLFontGL::RIGHT:
- text_right -= overlay_width + mImageOverlayLeftPad+ 1;
- text_width -= text_width_delta;
+ text_right -= overlay_width + 1;
mImageOverlay->draw(
- getRect().getWidth() - mRightHPad - overlay_width,
+ getRect().getWidth() - mImageOverlayRightPad - overlay_width,
center_y - (overlay_height / 2),
overlay_width,
overlay_height,
diff --git a/indra/llui/lllayoutstack.cpp b/indra/llui/lllayoutstack.cpp
index 1aaba88c49..dc79550eb4 100644
--- a/indra/llui/lllayoutstack.cpp
+++ b/indra/llui/lllayoutstack.cpp
@@ -816,7 +816,10 @@ void LLLayoutStack::calcMinExtents()
//static
void LLLayoutStack::updateClass()
{
- for (LLLayoutStack::instance_iter it = beginInstances(); it != endInstances(); ++it)
+ LLInstanceTrackerScopedGuard guard;
+ for (LLLayoutStack::instance_iter it = guard.beginInstances();
+ it != guard.endInstances();
+ ++it)
{
it->updateLayout();
}
diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 3e277f47b5..483a394bbd 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -55,6 +55,7 @@
#include "llui.h"
#include "lluictrlfactory.h"
#include "llclipboard.h"
+#include "llmenugl.h"
//
// Imported globals
@@ -82,19 +83,6 @@ template class LLLineEditor* LLView::getChild<class LLLineEditor>(
// Member functions
//
-void LLLineEditor::PrevalidateNamedFuncs::declareValues()
-{
- declare("ascii", LLLineEditor::prevalidateASCII);
- declare("float", LLLineEditor::prevalidateFloat);
- declare("int", LLLineEditor::prevalidateInt);
- declare("positive_s32", LLLineEditor::prevalidatePositiveS32);
- declare("non_negative_s32", LLLineEditor::prevalidateNonNegativeS32);
- declare("alpha_num", LLLineEditor::prevalidateAlphaNum);
- declare("alpha_num_space", LLLineEditor::prevalidateAlphaNumSpace);
- declare("ascii_printable_no_pipe", LLLineEditor::prevalidateASCIIPrintableNoPipe);
- declare("ascii_printable_no_space", LLLineEditor::prevalidateASCIIPrintableNoSpace);
-}
-
LLLineEditor::Params::Params()
: max_length_bytes("max_length", 254),
keystroke_callback("keystroke_callback"),
@@ -164,7 +152,8 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
mTentativeFgColor(p.text_tentative_color()),
mHighlightColor(p.highlight_color()),
mPreeditBgColor(p.preedit_bg_color()),
- mGLFont(p.font)
+ mGLFont(p.font),
+ mContextMenuHandle()
{
llassert( mMaxLengthBytes > 0 );
@@ -191,6 +180,12 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
setCursor(mText.length());
setPrevalidate(p.prevalidate_callback());
+
+ LLContextMenu* menu = LLUICtrlFactory::instance().createFromFile<LLContextMenu>
+ ("menu_text_editor.xml",
+ LLMenuGL::sMenuContainer,
+ LLMenuHolderGL::child_registry_t::instance());
+ setContextMenu(menu);
}
LLLineEditor::~LLLineEditor()
@@ -667,6 +662,16 @@ BOOL LLLineEditor::handleMiddleMouseDown(S32 x, S32 y, MASK mask)
return TRUE;
}
+BOOL LLLineEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
+{
+ setFocus(TRUE);
+ if (!LLUICtrl::handleRightMouseDown(x, y, mask))
+ {
+ showContextMenu(x, y);
+ }
+ return TRUE;
+}
+
BOOL LLLineEditor::handleHover(S32 x, S32 y, MASK mask)
{
BOOL handled = FALSE;
@@ -1966,51 +1971,12 @@ void LLLineEditor::setRect(const LLRect& rect)
}
}
-void LLLineEditor::setPrevalidate(LLLinePrevalidateFunc func)
+void LLLineEditor::setPrevalidate(LLTextValidate::validate_func_t func)
{
mPrevalidateFunc = func;
updateAllowingLanguageInput();
}
-// Limits what characters can be used to [1234567890.-] with [-] only valid in the first position.
-// Does NOT ensure that the string is a well-formed number--that's the job of post-validation--for
-// the simple reasons that intermediate states may be invalid even if the final result is valid.
-//
-// static
-BOOL LLLineEditor::prevalidateFloat(const LLWString &str)
-{
- LLLocale locale(LLLocale::USER_LOCALE);
-
- BOOL success = TRUE;
- LLWString trimmed = str;
- LLWStringUtil::trim(trimmed);
- S32 len = trimmed.length();
- if( 0 < len )
- {
- // May be a comma or period, depending on the locale
- llwchar decimal_point = (llwchar)LLResMgr::getInstance()->getDecimalPoint();
-
- S32 i = 0;
-
- // First character can be a negative sign
- if( '-' == trimmed[0] )
- {
- i++;
- }
-
- for( ; i < len; i++ )
- {
- if( (decimal_point != trimmed[i] ) && !LLStringOps::isDigit( trimmed[i] ) )
- {
- success = FALSE;
- break;
- }
- }
- }
-
- return success;
-}
-
// static
BOOL LLLineEditor::postvalidateFloat(const std::string &str)
{
@@ -2070,223 +2036,6 @@ BOOL LLLineEditor::postvalidateFloat(const std::string &str)
return success;
}
-// Limits what characters can be used to [1234567890-] with [-] only valid in the first position.
-// Does NOT ensure that the string is a well-formed number--that's the job of post-validation--for
-// the simple reasons that intermediate states may be invalid even if the final result is valid.
-//
-// static
-BOOL LLLineEditor::prevalidateInt(const LLWString &str)
-{
- LLLocale locale(LLLocale::USER_LOCALE);
-
- BOOL success = TRUE;
- LLWString trimmed = str;
- LLWStringUtil::trim(trimmed);
- S32 len = trimmed.length();
- if( 0 < len )
- {
- S32 i = 0;
-
- // First character can be a negative sign
- if( '-' == trimmed[0] )
- {
- i++;
- }
-
- for( ; i < len; i++ )
- {
- if( !LLStringOps::isDigit( trimmed[i] ) )
- {
- success = FALSE;
- break;
- }
- }
- }
-
- return success;
-}
-
-// static
-BOOL LLLineEditor::prevalidatePositiveS32(const LLWString &str)
-{
- LLLocale locale(LLLocale::USER_LOCALE);
-
- LLWString trimmed = str;
- LLWStringUtil::trim(trimmed);
- S32 len = trimmed.length();
- BOOL success = TRUE;
- if(0 < len)
- {
- if(('-' == trimmed[0]) || ('0' == trimmed[0]))
- {
- success = FALSE;
- }
- S32 i = 0;
- while(success && (i < len))
- {
- if(!LLStringOps::isDigit(trimmed[i++]))
- {
- success = FALSE;
- }
- }
- }
- if (success)
- {
- S32 val = strtol(wstring_to_utf8str(trimmed).c_str(), NULL, 10);
- if (val <= 0)
- {
- success = FALSE;
- }
- }
- return success;
-}
-
-BOOL LLLineEditor::prevalidateNonNegativeS32(const LLWString &str)
-{
- LLLocale locale(LLLocale::USER_LOCALE);
-
- LLWString trimmed = str;
- LLWStringUtil::trim(trimmed);
- S32 len = trimmed.length();
- BOOL success = TRUE;
- if(0 < len)
- {
- if('-' == trimmed[0])
- {
- success = FALSE;
- }
- S32 i = 0;
- while(success && (i < len))
- {
- if(!LLStringOps::isDigit(trimmed[i++]))
- {
- success = FALSE;
- }
- }
- }
- if (success)
- {
- S32 val = strtol(wstring_to_utf8str(trimmed).c_str(), NULL, 10);
- if (val < 0)
- {
- success = FALSE;
- }
- }
- return success;
-}
-
-BOOL LLLineEditor::prevalidateAlphaNum(const LLWString &str)
-{
- LLLocale locale(LLLocale::USER_LOCALE);
-
- BOOL rv = TRUE;
- S32 len = str.length();
- if(len == 0) return rv;
- while(len--)
- {
- if( !LLStringOps::isAlnum((char)str[len]) )
- {
- rv = FALSE;
- break;
- }
- }
- return rv;
-}
-
-// static
-BOOL LLLineEditor::prevalidateAlphaNumSpace(const LLWString &str)
-{
- LLLocale locale(LLLocale::USER_LOCALE);
-
- BOOL rv = TRUE;
- S32 len = str.length();
- if(len == 0) return rv;
- while(len--)
- {
- if(!(LLStringOps::isAlnum((char)str[len]) || (' ' == str[len])))
- {
- rv = FALSE;
- break;
- }
- }
- return rv;
-}
-
-// Used for most names of things stored on the server, due to old file-formats
-// that used the pipe (|) for multiline text storage. Examples include
-// inventory item names, parcel names, object names, etc.
-// static
-BOOL LLLineEditor::prevalidateASCIIPrintableNoPipe(const LLWString &str)
-{
- BOOL rv = TRUE;
- S32 len = str.length();
- if(len == 0) return rv;
- while(len--)
- {
- llwchar wc = str[len];
- if (wc < 0x20
- || wc > 0x7f
- || wc == '|')
- {
- rv = FALSE;
- break;
- }
- if(!(wc == ' '
- || LLStringOps::isAlnum((char)wc)
- || LLStringOps::isPunct((char)wc) ) )
- {
- rv = FALSE;
- break;
- }
- }
- return rv;
-}
-
-
-// Used for avatar names
-// static
-BOOL LLLineEditor::prevalidateASCIIPrintableNoSpace(const LLWString &str)
-{
- BOOL rv = TRUE;
- S32 len = str.length();
- if(len == 0) return rv;
- while(len--)
- {
- llwchar wc = str[len];
- if (wc < 0x20
- || wc > 0x7f
- || LLStringOps::isSpace(wc))
- {
- rv = FALSE;
- break;
- }
- if( !(LLStringOps::isAlnum((char)str[len]) ||
- LLStringOps::isPunct((char)str[len]) ) )
- {
- rv = FALSE;
- break;
- }
- }
- return rv;
-}
-
-
-// static
-BOOL LLLineEditor::prevalidateASCII(const LLWString &str)
-{
- BOOL rv = TRUE;
- S32 len = str.length();
- while(len--)
- {
- if (str[len] < 0x20 || str[len] > 0x7f)
- {
- rv = FALSE;
- break;
- }
- }
- return rv;
-}
-
void LLLineEditor::onMouseCaptureLost()
{
endSelection();
@@ -2564,3 +2313,25 @@ LLWString LLLineEditor::getConvertedText() const
}
return text;
}
+
+void LLLineEditor::showContextMenu(S32 x, S32 y)
+{
+ LLContextMenu* menu = static_cast<LLContextMenu*>(mContextMenuHandle.get());
+
+ if (menu)
+ {
+ gEditMenuHandler = this;
+
+ S32 screen_x, screen_y;
+ localPointToScreen(x, y, &screen_x, &screen_y);
+ menu->show(screen_x, screen_y);
+ }
+}
+
+void LLLineEditor::setContextMenu(LLContextMenu* new_context_menu)
+{
+ if (new_context_menu)
+ mContextMenuHandle = new_context_menu->getHandle();
+ else
+ mContextMenuHandle.markDead();
+}
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index 49e9539b16..b62138426b 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -51,26 +51,18 @@
#include "llviewborder.h"
#include "llpreeditor.h"
-#include <boost/function.hpp>
+#include "lltextvalidate.h"
class LLFontGL;
class LLLineEditorRollback;
class LLButton;
-
-typedef boost::function<BOOL (const LLWString &wstr)> LLLinePrevalidateFunc;
+class LLContextMenu;
class LLLineEditor
: public LLUICtrl, public LLEditMenuHandler, protected LLPreeditor
{
public:
- struct PrevalidateNamedFuncs
- : public LLInitParam::TypeValuesHelper<LLLinePrevalidateFunc, PrevalidateNamedFuncs>
-
- {
- static void declareValues();
- };
-
typedef boost::function<void (LLLineEditor* caller)> keystroke_callback_t;
struct Params : public LLInitParam::Block<Params, LLUICtrl::Params>
@@ -80,7 +72,7 @@ public:
Optional<keystroke_callback_t> keystroke_callback;
- Optional<LLLinePrevalidateFunc, PrevalidateNamedFuncs> prevalidate_callback;
+ Optional<LLTextValidate::validate_func_t, LLTextValidate::ValidateTextNamedFuncs> prevalidate_callback;
Optional<LLViewBorder::Params> border;
@@ -113,6 +105,7 @@ protected:
LLLineEditor(const Params&);
friend class LLUICtrlFactory;
friend class LLFloaterEditUI;
+ void showContextMenu(S32 x, S32 y);
public:
virtual ~LLLineEditor();
@@ -122,6 +115,7 @@ public:
/*virtual*/ BOOL handleHover(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleDoubleClick(S32 x,S32 y,MASK mask);
/*virtual*/ BOOL handleMiddleMouseDown(S32 x,S32 y,MASK mask);
+ /*virtual*/ BOOL handleRightMouseDown(S32 x, S32 y, MASK mask);
/*virtual*/ BOOL handleKeyHere(KEY key, MASK mask );
/*virtual*/ BOOL handleUnicodeCharHere(llwchar uni_char);
/*virtual*/ void onMouseCaptureLost();
@@ -204,6 +198,8 @@ public:
const LLColor4& getReadOnlyFgColor() const { return mReadOnlyFgColor.get(); }
const LLColor4& getTentativeFgColor() const { return mTentativeFgColor.get(); }
+ const LLFontGL* getFont() const { return mGLFont; }
+
void setIgnoreArrowKeys(BOOL b) { mIgnoreArrowKeys = b; }
void setIgnoreTab(BOOL b) { mIgnoreTab = b; }
void setPassDelete(BOOL b) { mPassDelete = b; }
@@ -231,17 +227,7 @@ public:
void setTextPadding(S32 left, S32 right);
// Prevalidation controls which keystrokes can affect the editor
- void setPrevalidate( LLLinePrevalidateFunc func );
- static BOOL prevalidateFloat(const LLWString &str );
- static BOOL prevalidateInt(const LLWString &str );
- static BOOL prevalidatePositiveS32(const LLWString &str);
- static BOOL prevalidateNonNegativeS32(const LLWString &str);
- static BOOL prevalidateAlphaNum(const LLWString &str );
- static BOOL prevalidateAlphaNumSpace(const LLWString &str );
- static BOOL prevalidateASCIIPrintableNoPipe(const LLWString &str);
- static BOOL prevalidateASCIIPrintableNoSpace(const LLWString &str);
- static BOOL prevalidateASCII(const LLWString &str);
-
+ void setPrevalidate( LLTextValidate::validate_func_t func );
static BOOL postvalidateFloat(const std::string &str);
// line history support:
@@ -249,7 +235,9 @@ public:
void updateHistory(); // stores current line in history
void setReplaceNewlinesWithSpaces(BOOL replace);
-
+
+ void setContextMenu(LLContextMenu* new_context_menu);
+
private:
// private helper methods
@@ -319,7 +307,7 @@ protected:
S32 mLastSelectionStart;
S32 mLastSelectionEnd;
- LLLinePrevalidateFunc mPrevalidateFunc;
+ LLTextValidate::validate_func_t mPrevalidateFunc;
LLFrameTimer mKeystrokeTimer;
LLTimer mTripleClickTimer;
@@ -348,6 +336,8 @@ protected:
std::vector<S32> mPreeditPositions;
LLPreeditor::standouts_t mPreeditStandouts;
+ LLHandle<LLView> mContextMenuHandle;
+
private:
// Instances that by default point to the statics but can be overidden in XML.
LLPointer<LLUIImage> mBgImage;
diff --git a/indra/llui/llmenugl.cpp b/indra/llui/llmenugl.cpp
index 7fa9a88059..d18abbfb2f 100644
--- a/indra/llui/llmenugl.cpp
+++ b/indra/llui/llmenugl.cpp
@@ -3941,7 +3941,6 @@ BOOL LLContextMenu::appendContextSubMenu(LLContextMenu *menu)
item = LLUICtrlFactory::create<LLContextMenuBranch>(p);
LLMenuGL::sMenuContainer->addChild(item->getBranch());
- item->setFont( LLFontGL::getFontSansSerif() );
return append( item );
}
diff --git a/indra/llui/llmultifloater.cpp b/indra/llui/llmultifloater.cpp
index 78738c826d..33d47a3f0e 100644
--- a/indra/llui/llmultifloater.cpp
+++ b/indra/llui/llmultifloater.cpp
@@ -92,14 +92,6 @@ void LLMultiFloater::draw()
}
else
{
- for (S32 i = 0; i < mTabContainer->getTabCount(); i++)
- {
- LLFloater* floaterp = (LLFloater*)mTabContainer->getPanelByIndex(i);
- if (floaterp->getShortTitle() != mTabContainer->getPanelTitle(i))
- {
- mTabContainer->setPanelTitle(i, floaterp->getShortTitle());
- }
- }
LLFloater::draw();
}
}
diff --git a/indra/llui/llmultisliderctrl.cpp b/indra/llui/llmultisliderctrl.cpp
index f4434a0f78..cb81c39103 100644
--- a/indra/llui/llmultisliderctrl.cpp
+++ b/indra/llui/llmultisliderctrl.cpp
@@ -138,7 +138,7 @@ LLMultiSliderCtrl::LLMultiSliderCtrl(const LLMultiSliderCtrl::Params& p)
params.font(p.font);
params.max_length_bytes(MAX_STRING_LENGTH);
params.commit_callback.function(LLMultiSliderCtrl::onEditorCommit);
- params.prevalidate_callback(&LLLineEditor::prevalidateFloat);
+ params.prevalidate_callback(&LLTextValidate::validateFloat);
params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
mEditor = LLUICtrlFactory::create<LLLineEditor> (params);
mEditor->setFocusReceivedCallback( boost::bind(LLMultiSliderCtrl::onEditorGainFocus, _1, this) );
diff --git a/indra/llui/llpanel.cpp b/indra/llui/llpanel.cpp
index 7f23fe2671..7b406e090a 100644
--- a/indra/llui/llpanel.cpp
+++ b/indra/llui/llpanel.cpp
@@ -936,7 +936,7 @@ LLPanel *LLPanel::childGetVisiblePanelWithHelp()
return ::childGetVisiblePanelWithHelp(this);
}
-void LLPanel::childSetPrevalidate(const std::string& id, BOOL (*func)(const LLWString &) )
+void LLPanel::childSetPrevalidate(const std::string& id, bool (*func)(const LLWString &) )
{
LLLineEditor* child = findChild<LLLineEditor>(id);
if (child)
diff --git a/indra/llui/llpanel.h b/indra/llui/llpanel.h
index 6de83fe3a7..4e53fd7ea3 100644
--- a/indra/llui/llpanel.h
+++ b/indra/llui/llpanel.h
@@ -226,7 +226,7 @@ public:
std::string childGetText(const std::string& id) const { return childGetValue(id).asString(); }
// LLLineEditor
- void childSetPrevalidate(const std::string& id, BOOL (*func)(const LLWString &) );
+ void childSetPrevalidate(const std::string& id, bool (*func)(const LLWString &) );
// LLButton
void childSetAction(const std::string& id, boost::function<void(void*)> function, void* value = NULL);
diff --git a/indra/llui/llsliderctrl.cpp b/indra/llui/llsliderctrl.cpp
index 01c274bb4e..80ee5d0984 100644
--- a/indra/llui/llsliderctrl.cpp
+++ b/indra/llui/llsliderctrl.cpp
@@ -141,7 +141,7 @@ LLSliderCtrl::LLSliderCtrl(const LLSliderCtrl::Params& p)
line_p.rect.setIfNotProvided(text_rect);
line_p.font.setIfNotProvided(p.font);
line_p.commit_callback.function(&LLSliderCtrl::onEditorCommit);
- line_p.prevalidate_callback(&LLLineEditor::prevalidateFloat);
+ line_p.prevalidate_callback(&LLTextValidate::validateFloat);
mEditor = LLUICtrlFactory::create<LLLineEditor>(line_p);
mEditor->setFocusReceivedCallback( boost::bind(&LLSliderCtrl::onEditorGainFocus, _1, this ));
diff --git a/indra/llui/llspinctrl.cpp b/indra/llui/llspinctrl.cpp
index 28f3788817..491cd7b6f3 100644
--- a/indra/llui/llspinctrl.cpp
+++ b/indra/llui/llspinctrl.cpp
@@ -127,7 +127,7 @@ LLSpinCtrl::LLSpinCtrl(const LLSpinCtrl::Params& p)
}
params.max_length_bytes(MAX_STRING_LENGTH);
params.commit_callback.function((boost::bind(&LLSpinCtrl::onEditorCommit, this, _2)));
- params.prevalidate_callback(&LLLineEditor::prevalidateFloat);
+ params.prevalidate_callback(&LLTextValidate::validateFloat);
params.follows.flags(FOLLOWS_LEFT | FOLLOWS_BOTTOM);
mEditor = LLUICtrlFactory::create<LLLineEditor> (params);
mEditor->setFocusReceivedCallback( boost::bind(&LLSpinCtrl::onEditorGainFocus, _1, this ));
diff --git a/indra/llui/lltabcontainer.cpp b/indra/llui/lltabcontainer.cpp
index 6be76605fd..19408989a5 100644
--- a/indra/llui/lltabcontainer.cpp
+++ b/indra/llui/lltabcontainer.cpp
@@ -35,7 +35,6 @@
#include "lltabcontainer.h"
#include "llfocusmgr.h"
-#include "llbutton.h"
#include "lllocalcliprect.h"
#include "llrect.h"
#include "llresizehandle.h"
@@ -96,6 +95,90 @@ public:
//----------------------------------------------------------------------------
+//============================================================================
+/*
+ * @file lltabcontainer.cpp
+ * @brief class implements LLButton with LLIconCtrl on it
+ */
+class LLCustomButtonIconCtrl : public LLButton
+{
+public:
+ struct Params
+ : public LLInitParam::Block<Params, LLButton::Params>
+ {
+ // LEFT, RIGHT, TOP, BOTTOM paddings of LLIconCtrl in this class has same value
+ Optional<S32> icon_ctrl_pad;
+
+ Params():
+ icon_ctrl_pad("icon_ctrl_pad", 1)
+ {}
+ };
+
+protected:
+ friend class LLUICtrlFactory;
+ LLCustomButtonIconCtrl(const Params& p):
+ LLButton(p),
+ mIcon(NULL),
+ mIconCtrlPad(p.icon_ctrl_pad)
+ {}
+
+public:
+
+ void updateLayout()
+ {
+ LLRect button_rect = getRect();
+ LLRect icon_rect = mIcon->getRect();
+
+ S32 icon_size = button_rect.getHeight() - 2*mIconCtrlPad;
+
+ switch(mIconAlignment)
+ {
+ case LLFontGL::LEFT:
+ icon_rect.setLeftTopAndSize(button_rect.mLeft + mIconCtrlPad, button_rect.mTop - mIconCtrlPad,
+ icon_size, icon_size);
+ setLeftHPad(icon_size + mIconCtrlPad * 2);
+ break;
+ case LLFontGL::HCENTER:
+ icon_rect.setLeftTopAndSize(button_rect.mRight - (button_rect.getWidth() + mIconCtrlPad - icon_size)/2, button_rect.mTop - mIconCtrlPad,
+ icon_size, icon_size);
+ setRightHPad(icon_size + mIconCtrlPad * 2);
+ break;
+ case LLFontGL::RIGHT:
+ icon_rect.setLeftTopAndSize(button_rect.mRight - mIconCtrlPad - icon_size, button_rect.mTop - mIconCtrlPad,
+ icon_size, icon_size);
+ setRightHPad(icon_size + mIconCtrlPad * 2);
+ break;
+ default:
+ break;
+ }
+ mIcon->setRect(icon_rect);
+ }
+
+ void setIcon(LLIconCtrl* icon, LLFontGL::HAlign alignment = LLFontGL::LEFT)
+ {
+ if(icon)
+ {
+ if(mIcon)
+ {
+ removeChild(mIcon);
+ mIcon->die();
+ }
+ mIcon = icon;
+ mIconAlignment = alignment;
+
+ addChild(mIcon);
+ updateLayout();
+ }
+ }
+
+
+private:
+ LLIconCtrl* mIcon;
+ LLFontGL::HAlign mIconAlignment;
+ S32 mIconCtrlPad;
+};
+//============================================================================
+
struct LLPlaceHolderPanel : public LLPanel
{
// create dummy param block to register with "placeholder" nane
@@ -127,7 +210,9 @@ LLTabContainer::Params::Params()
tab_padding_right("tab_padding_right"),
first_tab("first_tab"),
middle_tab("middle_tab"),
- last_tab("last_tab")
+ last_tab("last_tab"),
+ use_custom_icon_ctrl("use_custom_icon_ctrl", false),
+ tab_icon_ctrl_pad("tab_icon_ctrl_pad", 0)
{
name(std::string("tab_container"));
mouse_opaque = false;
@@ -162,7 +247,9 @@ LLTabContainer::LLTabContainer(const LLTabContainer::Params& p)
mFont(p.font),
mFirstTabParams(p.first_tab),
mMiddleTabParams(p.middle_tab),
- mLastTabParams(p.last_tab)
+ mLastTabParams(p.last_tab),
+ mCustomIconCtrlUsed(p.use_custom_icon_ctrl),
+ mTabIconCtrlPad(p.tab_icon_ctrl_pad)
{
static LLUICachedControl<S32> tabcntr_vert_tab_min_width ("UITabCntrVertTabMinWidth", 0);
@@ -905,6 +992,11 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
LLTextBox* textbox = NULL;
LLButton* btn = NULL;
+ LLCustomButtonIconCtrl::Params custom_btn_params;
+ {
+ custom_btn_params.icon_ctrl_pad(mTabIconCtrlPad);
+ }
+ LLButton::Params normal_btn_params;
if (placeholder)
{
@@ -924,7 +1016,9 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
{
if (mIsVertical)
{
- LLButton::Params p;
+ LLButton::Params& p = (mCustomIconCtrlUsed)?
+ custom_btn_params:normal_btn_params;
+
p.name(std::string("vert tab button"));
p.rect(btn_rect);
p.follows.flags(FOLLOWS_TOP | FOLLOWS_LEFT);
@@ -942,11 +1036,22 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
{
p.pad_left(indent);
}
- btn = LLUICtrlFactory::create<LLButton>(p);
+
+
+ if(mCustomIconCtrlUsed)
+ {
+ btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params);
+
+ }
+ else
+ {
+ btn = LLUICtrlFactory::create<LLButton>(p);
+ }
}
else
{
- LLButton::Params p;
+ LLButton::Params& p = (mCustomIconCtrlUsed)?
+ custom_btn_params:normal_btn_params;
p.name(std::string(child->getName()) + " tab");
p.rect(btn_rect);
p.click_callback.function(boost::bind(&LLTabContainer::onTabBtn, this, _2, child));
@@ -980,7 +1085,14 @@ void LLTabContainer::addTabPanel(const TabPanelParams& panel)
p.follows.flags = p.follows.flags() | FOLLOWS_BOTTOM;
}
-++ btn = LLUICtrlFactory::create<LLButton>(p);
+ if(mCustomIconCtrlUsed)
+ {
+ btn = LLUICtrlFactory::create<LLCustomButtonIconCtrl>(custom_btn_params);
+ }
+ else
+ {
+ btn = LLUICtrlFactory::create<LLButton>(p);
+ }
}
}
@@ -1484,7 +1596,7 @@ void LLTabContainer::setTabImage(LLPanel* child, std::string image_name, const L
if( tuple )
{
tuple->mButton->setImageOverlay(image_name, LLFontGL::LEFT, color);
- reshape_tuple(tuple);
+ reshapeTuple(tuple);
}
}
@@ -1494,11 +1606,26 @@ void LLTabContainer::setTabImage(LLPanel* child, const LLUUID& image_id, const L
if( tuple )
{
tuple->mButton->setImageOverlay(image_id, LLFontGL::LEFT, color);
- reshape_tuple(tuple);
+ reshapeTuple(tuple);
+ }
+}
+
+void LLTabContainer::setTabImage(LLPanel* child, LLIconCtrl* icon)
+{
+ LLTabTuple* tuple = getTabByPanel(child);
+ LLCustomButtonIconCtrl* button;
+
+ if(tuple)
+ {
+ button = dynamic_cast<LLCustomButtonIconCtrl*>(tuple->mButton);
+ if(button)
+ {
+ button->setIcon(icon);
+ }
}
}
-void LLTabContainer::reshape_tuple(LLTabTuple* tuple)
+void LLTabContainer::reshapeTuple(LLTabTuple* tuple)
{
static LLUICachedControl<S32> tab_padding ("UITabPadding", 0);
static LLUICachedControl<S32> image_left_padding ("UIButtonImageLeftPadding", 4);
diff --git a/indra/llui/lltabcontainer.h b/indra/llui/lltabcontainer.h
index 2a55877d3c..4b5d45fb73 100644
--- a/indra/llui/lltabcontainer.h
+++ b/indra/llui/lltabcontainer.h
@@ -36,6 +36,8 @@
#include "llpanel.h"
#include "lltextbox.h"
#include "llframetimer.h"
+#include "lliconctrl.h"
+#include "llbutton.h"
class LLTabTuple;
@@ -90,6 +92,16 @@ public:
middle_tab,
last_tab;
+ /**
+ * Use LLCustomButtonIconCtrl or LLButton in LLTabTuple
+ */
+ Optional<bool> use_custom_icon_ctrl;
+
+ /**
+ * Paddings for LLIconCtrl in case of LLCustomButtonIconCtrl usage(use_custom_icon_ctrl = true)
+ */
+ Optional<S32> tab_icon_ctrl_pad;
+
Params();
};
@@ -173,6 +185,7 @@ public:
void setTabPanelFlashing(LLPanel* child, BOOL state);
void setTabImage(LLPanel* child, std::string img_name, const LLColor4& color = LLColor4::white);
void setTabImage(LLPanel* child, const LLUUID& img_id, const LLColor4& color = LLColor4::white);
+ void setTabImage(LLPanel* child, LLIconCtrl* icon);
void setTitle( const std::string& title );
const std::string getPanelTitle(S32 index);
@@ -228,7 +241,7 @@ private:
// updates tab button images given the tuple, tab position and the corresponding params
void update_images(LLTabTuple* tuple, TabParams params, LLTabContainer::TabPosition pos);
- void reshape_tuple(LLTabTuple* tuple);
+ void reshapeTuple(LLTabTuple* tuple);
// Variables
@@ -278,6 +291,9 @@ private:
TabParams mFirstTabParams;
TabParams mMiddleTabParams;
TabParams mLastTabParams;
+
+ bool mCustomIconCtrlUsed;
+ S32 mTabIconCtrlPad;
};
#endif // LL_TABCONTAINER_H
diff --git a/indra/llui/lltextbase.cpp b/indra/llui/lltextbase.cpp
index 2b1e2b8226..a83cc19d36 100644
--- a/indra/llui/lltextbase.cpp
+++ b/indra/llui/lltextbase.cpp
@@ -1137,6 +1137,7 @@ void LLTextBase::reflow()
line_list_t::iterator iter = std::upper_bound(mLineInfoList.begin(), mLineInfoList.end(), start_index, line_end_compare());
line_start_index = iter->mDocIndexStart;
line_count = iter->mLineNum;
+ cur_top = iter->mRect.mTop;
getSegmentAndOffset(iter->mDocIndexStart, &seg_iter, &seg_offset);
mLineInfoList.erase(iter, mLineInfoList.end());
}
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index 3fdb48b3ca..ad9f066539 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -237,13 +237,17 @@ private:
///////////////////////////////////////////////////////////////////
LLTextEditor::Params::Params()
: default_text("default_text"),
+ prevalidate_callback("prevalidate_callback"),
embedded_items("embedded_items", false),
ignore_tab("ignore_tab", true),
handle_edit_keys_directly("handle_edit_keys_directly", false),
show_line_numbers("show_line_numbers", false),
default_color("default_color"),
- commit_on_focus_lost("commit_on_focus_lost", false)
-{}
+ commit_on_focus_lost("commit_on_focus_lost", false),
+ show_context_menu("show_context_menu")
+{
+ addSynonym(prevalidate_callback, "text_type");
+}
LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
LLTextBase(p),
@@ -258,7 +262,9 @@ LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
mMouseDownX(0),
mMouseDownY(0),
mTabsToNextField(p.ignore_tab),
- mContextMenu(NULL)
+ mPrevalidateFunc(p.prevalidate_callback()),
+ mContextMenu(NULL),
+ mShowContextMenu(p.show_context_menu)
{
mDefaultFont = p.font;
@@ -318,6 +324,17 @@ LLTextEditor::~LLTextEditor()
void LLTextEditor::setText(const LLStringExplicit &utf8str, const LLStyle::Params& input_params)
{
+ // validate incoming text if necessary
+ if (mPrevalidateFunc)
+ {
+ LLWString test_text = utf8str_to_wstring(utf8str);
+ if (!mPrevalidateFunc(test_text))
+ {
+ // not valid text, nothing to do
+ return;
+ }
+ }
+
blockUndo();
deselect();
@@ -720,7 +737,7 @@ BOOL LLTextEditor::handleRightMouseDown(S32 x, S32 y, MASK mask)
}
if (!LLTextBase::handleRightMouseDown(x, y, mask))
{
- if(getMouseOpaque())
+ if(getChowContextMenu())
{
showContextMenu(x, y);
}
@@ -909,6 +926,21 @@ S32 LLTextEditor::execute( TextCmd* cmd )
// Push the new command is now on the top (front) of the undo stack.
mUndoStack.push_front(cmd);
mLastCmd = cmd;
+
+ bool need_to_rollback = mPrevalidateFunc
+ && !mPrevalidateFunc(getViewModel()->getDisplay());
+ if (need_to_rollback)
+ {
+ // get rid of this last command and clean up undo stack
+ undo();
+
+ // remove any evidence of this command from redo history
+ mUndoStack.pop_front();
+ delete cmd;
+
+ // failure, nothing changed
+ delta = 0;
+ }
}
else
{
@@ -1032,7 +1064,21 @@ S32 LLTextEditor::addChar(S32 pos, llwchar wc)
if (mLastCmd && mLastCmd->canExtend(pos))
{
S32 delta = 0;
+ if (mPrevalidateFunc)
+ {
+ // get a copy of current text contents
+ LLWString test_string(getViewModel()->getDisplay());
+
+ // modify text contents as if this addChar succeeded
+ llassert(pos <= (S32)test_string.size());
+ test_string.insert(pos, 1, wc);
+ if (!mPrevalidateFunc( test_string))
+ {
+ return 0;
+ }
+ }
mLastCmd->extendAndExecute(this, pos, wc, &delta);
+
return delta;
}
else
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index a136f9ccce..00c6a8b68a 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -44,6 +44,7 @@
#include "lldarray.h"
#include "llviewborder.h" // for params
#include "lltextbase.h"
+#include "lltextvalidate.h"
#include "llpreeditor.h"
#include "llcontrol.h"
@@ -63,12 +64,14 @@ public:
struct Params : public LLInitParam::Block<Params, LLTextBase::Params>
{
Optional<std::string> default_text;
+ Optional<LLTextValidate::validate_func_t, LLTextValidate::ValidateTextNamedFuncs> prevalidate_callback;
Optional<bool> embedded_items,
ignore_tab,
handle_edit_keys_directly,
show_line_numbers,
- commit_on_focus_lost;
+ commit_on_focus_lost,
+ show_context_menu;
//colors
Optional<LLUIColor> default_color;
@@ -200,6 +203,9 @@ public:
const LLTextSegmentPtr getPreviousSegment() const;
void getSelectedSegments(segment_vec_t& segments) const;
+ void setShowContextMenu(bool show) { mShowContextMenu = show; }
+ bool getChowContextMenu() const { return mShowContextMenu; }
+
protected:
void showContextMenu(S32 x, S32 y);
void drawPreeditMarker();
@@ -319,6 +325,7 @@ private:
BOOL mTakesFocus;
BOOL mAllowEmbeddedItems;
+ bool mShowContextMenu;
LLUUID mSourceID;
@@ -329,6 +336,7 @@ private:
LLCoordGL mLastIMEPosition; // Last position of the IME editor
keystroke_signal_t mKeystrokeSignal;
+ LLTextValidate::validate_func_t mPrevalidateFunc;
LLContextMenu* mContextMenu;
}; // end class LLTextEditor
diff --git a/indra/llui/lltextvalidate.cpp b/indra/llui/lltextvalidate.cpp
new file mode 100644
index 0000000000..8b6bc5bd7d
--- /dev/null
+++ b/indra/llui/lltextvalidate.cpp
@@ -0,0 +1,302 @@
+/**
+ * @file lltextvalidate.cpp
+ * @brief Text validation helper functions
+ *
+ * $LicenseInfo:firstyear=2001&license=viewergpl$
+ *
+ * Copyright (c) 2001-2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+// Text editor widget to let users enter a single line.
+
+#include "linden_common.h"
+
+#include "lltextvalidate.h"
+#include "llresmgr.h" // for LLLocale
+
+namespace LLTextValidate
+{
+ void ValidateTextNamedFuncs::declareValues()
+ {
+ declare("ascii", validateASCII);
+ declare("float", validateFloat);
+ declare("int", validateInt);
+ declare("positive_s32", validatePositiveS32);
+ declare("non_negative_s32", validateNonNegativeS32);
+ declare("alpha_num", validateAlphaNum);
+ declare("alpha_num_space", validateAlphaNumSpace);
+ declare("ascii_printable_no_pipe", validateASCIIPrintableNoPipe);
+ declare("ascii_printable_no_space", validateASCIIPrintableNoSpace);
+ }
+
+ // Limits what characters can be used to [1234567890.-] with [-] only valid in the first position.
+ // Does NOT ensure that the string is a well-formed number--that's the job of post-validation--for
+ // the simple reasons that intermediate states may be invalid even if the final result is valid.
+ //
+ bool validateFloat(const LLWString &str)
+ {
+ LLLocale locale(LLLocale::USER_LOCALE);
+
+ bool success = TRUE;
+ LLWString trimmed = str;
+ LLWStringUtil::trim(trimmed);
+ S32 len = trimmed.length();
+ if( 0 < len )
+ {
+ // May be a comma or period, depending on the locale
+ llwchar decimal_point = (llwchar)LLResMgr::getInstance()->getDecimalPoint();
+
+ S32 i = 0;
+
+ // First character can be a negative sign
+ if( '-' == trimmed[0] )
+ {
+ i++;
+ }
+
+ for( ; i < len; i++ )
+ {
+ if( (decimal_point != trimmed[i] ) && !LLStringOps::isDigit( trimmed[i] ) )
+ {
+ success = FALSE;
+ break;
+ }
+ }
+ }
+
+ return success;
+ }
+
+ // Limits what characters can be used to [1234567890-] with [-] only valid in the first position.
+ // Does NOT ensure that the string is a well-formed number--that's the job of post-validation--for
+ // the simple reasons that intermediate states may be invalid even if the final result is valid.
+ //
+ bool validateInt(const LLWString &str)
+ {
+ LLLocale locale(LLLocale::USER_LOCALE);
+
+ bool success = TRUE;
+ LLWString trimmed = str;
+ LLWStringUtil::trim(trimmed);
+ S32 len = trimmed.length();
+ if( 0 < len )
+ {
+ S32 i = 0;
+
+ // First character can be a negative sign
+ if( '-' == trimmed[0] )
+ {
+ i++;
+ }
+
+ for( ; i < len; i++ )
+ {
+ if( !LLStringOps::isDigit( trimmed[i] ) )
+ {
+ success = FALSE;
+ break;
+ }
+ }
+ }
+
+ return success;
+ }
+
+ bool validatePositiveS32(const LLWString &str)
+ {
+ LLLocale locale(LLLocale::USER_LOCALE);
+
+ LLWString trimmed = str;
+ LLWStringUtil::trim(trimmed);
+ S32 len = trimmed.length();
+ bool success = TRUE;
+ if(0 < len)
+ {
+ if(('-' == trimmed[0]) || ('0' == trimmed[0]))
+ {
+ success = FALSE;
+ }
+ S32 i = 0;
+ while(success && (i < len))
+ {
+ if(!LLStringOps::isDigit(trimmed[i++]))
+ {
+ success = FALSE;
+ }
+ }
+ }
+ if (success)
+ {
+ S32 val = strtol(wstring_to_utf8str(trimmed).c_str(), NULL, 10);
+ if (val <= 0)
+ {
+ success = FALSE;
+ }
+ }
+ return success;
+ }
+
+ bool validateNonNegativeS32(const LLWString &str)
+ {
+ LLLocale locale(LLLocale::USER_LOCALE);
+
+ LLWString trimmed = str;
+ LLWStringUtil::trim(trimmed);
+ S32 len = trimmed.length();
+ bool success = TRUE;
+ if(0 < len)
+ {
+ if('-' == trimmed[0])
+ {
+ success = FALSE;
+ }
+ S32 i = 0;
+ while(success && (i < len))
+ {
+ if(!LLStringOps::isDigit(trimmed[i++]))
+ {
+ success = FALSE;
+ }
+ }
+ }
+ if (success)
+ {
+ S32 val = strtol(wstring_to_utf8str(trimmed).c_str(), NULL, 10);
+ if (val < 0)
+ {
+ success = FALSE;
+ }
+ }
+ return success;
+ }
+
+ bool validateAlphaNum(const LLWString &str)
+ {
+ LLLocale locale(LLLocale::USER_LOCALE);
+
+ bool rv = TRUE;
+ S32 len = str.length();
+ if(len == 0) return rv;
+ while(len--)
+ {
+ if( !LLStringOps::isAlnum((char)str[len]) )
+ {
+ rv = FALSE;
+ break;
+ }
+ }
+ return rv;
+ }
+
+ bool validateAlphaNumSpace(const LLWString &str)
+ {
+ LLLocale locale(LLLocale::USER_LOCALE);
+
+ bool rv = TRUE;
+ S32 len = str.length();
+ if(len == 0) return rv;
+ while(len--)
+ {
+ if(!(LLStringOps::isAlnum((char)str[len]) || (' ' == str[len])))
+ {
+ rv = FALSE;
+ break;
+ }
+ }
+ return rv;
+ }
+
+ // Used for most names of things stored on the server, due to old file-formats
+ // that used the pipe (|) for multiline text storage. Examples include
+ // inventory item names, parcel names, object names, etc.
+ bool validateASCIIPrintableNoPipe(const LLWString &str)
+ {
+ bool rv = TRUE;
+ S32 len = str.length();
+ if(len == 0) return rv;
+ while(len--)
+ {
+ llwchar wc = str[len];
+ if (wc < 0x20
+ || wc > 0x7f
+ || wc == '|')
+ {
+ rv = FALSE;
+ break;
+ }
+ if(!(wc == ' '
+ || LLStringOps::isAlnum((char)wc)
+ || LLStringOps::isPunct((char)wc) ) )
+ {
+ rv = FALSE;
+ break;
+ }
+ }
+ return rv;
+ }
+
+
+ // Used for avatar names
+ bool validateASCIIPrintableNoSpace(const LLWString &str)
+ {
+ bool rv = TRUE;
+ S32 len = str.length();
+ if(len == 0) return rv;
+ while(len--)
+ {
+ llwchar wc = str[len];
+ if (wc < 0x20
+ || wc > 0x7f
+ || LLStringOps::isSpace(wc))
+ {
+ rv = FALSE;
+ break;
+ }
+ if( !(LLStringOps::isAlnum((char)str[len]) ||
+ LLStringOps::isPunct((char)str[len]) ) )
+ {
+ rv = FALSE;
+ break;
+ }
+ }
+ return rv;
+ }
+
+ bool validateASCII(const LLWString &str)
+ {
+ bool rv = TRUE;
+ S32 len = str.length();
+ while(len--)
+ {
+ if (str[len] < 0x20 || str[len] > 0x7f)
+ {
+ rv = FALSE;
+ break;
+ }
+ }
+ return rv;
+ }
+}
diff --git a/indra/llui/lltextvalidate.h b/indra/llui/lltextvalidate.h
new file mode 100644
index 0000000000..ffb4e85e7c
--- /dev/null
+++ b/indra/llui/lltextvalidate.h
@@ -0,0 +1,63 @@
+/**
+ * @file lltextbase.h
+ * @author Martin Reddy
+ * @brief The base class of text box/editor, providing Url handling support
+ *
+ * $LicenseInfo:firstyear=2009&license=viewergpl$
+ *
+ * Copyright (c) 2009, Linden Research, Inc.
+ *
+ * Second Life Viewer Source Code
+ * The source code in this file ("Source Code") is provided by Linden Lab
+ * to you under the terms of the GNU General Public License, version 2.0
+ * ("GPL"), unless you have obtained a separate licensing agreement
+ * ("Other License"), formally executed by you and Linden Lab. Terms of
+ * the GPL can be found in doc/GPL-license.txt in this distribution, or
+ * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
+ *
+ * There are special exceptions to the terms and conditions of the GPL as
+ * it is applied to this Source Code. View the full text of the exception
+ * in the file doc/FLOSS-exception.txt in this software distribution, or
+ * online at
+ * http://secondlifegrid.net/programs/open_source/licensing/flossexception
+ *
+ * By copying, modifying or distributing this software, you acknowledge
+ * that you have read and understood your obligations described above,
+ * and agree to abide by those obligations.
+ *
+ * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
+ * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
+ * COMPLETENESS OR PERFORMANCE.
+ * $/LicenseInfo$
+ */
+
+#ifndef LL_LLTEXTVALIDATE_H
+#define LL_LLTEXTVALIDATE_H
+
+#include "llstring.h"
+#include "llinitparam.h"
+#include <boost/function.hpp>
+
+namespace LLTextValidate
+{
+ typedef boost::function<BOOL (const LLWString &wstr)> validate_func_t;
+
+ struct ValidateTextNamedFuncs
+ : public LLInitParam::TypeValuesHelper<validate_func_t, ValidateTextNamedFuncs>
+ {
+ static void declareValues();
+ };
+
+ bool validateFloat(const LLWString &str );
+ bool validateInt(const LLWString &str );
+ bool validatePositiveS32(const LLWString &str);
+ bool validateNonNegativeS32(const LLWString &str);
+ bool validateAlphaNum(const LLWString &str );
+ bool validateAlphaNumSpace(const LLWString &str );
+ bool validateASCIIPrintableNoPipe(const LLWString &str);
+ bool validateASCIIPrintableNoSpace(const LLWString &str);
+ bool validateASCII(const LLWString &str);
+}
+
+
+#endif
diff --git a/indra/llui/lltooltip.h b/indra/llui/lltooltip.h
index 7978b6a583..c0811c56c3 100644
--- a/indra/llui/lltooltip.h
+++ b/indra/llui/lltooltip.h
@@ -129,7 +129,8 @@ private:
class LLInspector : public LLToolTip
{
public:
- struct Params : public LLInitParam::Block<Params, LLToolTip::Params> {};
+ struct Params : public LLInitParam::Block<Params, LLToolTip::Params>
+ {};
};
class LLToolTipMgr : public LLSingleton<LLToolTipMgr>
diff --git a/indra/llui/llview.cpp b/indra/llui/llview.cpp
index f1b08c380b..63e627ceb5 100644
--- a/indra/llui/llview.cpp
+++ b/indra/llui/llview.cpp
@@ -1720,6 +1720,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
{
LLView* childp = *child_it;
+ llassert(childp);
if (childp->getName() == name)
{
return childp;
@@ -1731,6 +1732,7 @@ LLView* LLView::findChildView(const std::string& name, BOOL recurse) const
for ( child_it = mChildList.begin(); child_it != mChildList.end(); ++child_it)
{
LLView* childp = *child_it;
+ llassert(childp);
LLView* viewp = childp->findChildView(name, recurse);
if ( viewp )
{