diff options
Diffstat (limited to 'indra/llui/llviewmodel.h')
-rw-r--r-- | indra/llui/llviewmodel.h | 140 |
1 files changed, 73 insertions, 67 deletions
diff --git a/indra/llui/llviewmodel.h b/indra/llui/llviewmodel.h index e7dceb6c31..6cf2200a81 100644 --- a/indra/llui/llviewmodel.h +++ b/indra/llui/llviewmodel.h @@ -8,25 +8,25 @@ * underlying a specific widget object -- as in our case -- rather * than the business "model" object underlying the overall "view" * presented by the collection of widgets. - * + * * $LicenseInfo:firstyear=2008&license=viewerlgpl$ * Second Life Viewer Source Code * Copyright (C) 2010, Linden Research, Inc. - * + * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; * version 2.1 of the License only. - * + * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. - * + * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * + * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ */ @@ -61,8 +61,8 @@ typedef LLPointer<LLListViewModel> LLListViewModelPtr; * LLViewModel data. This way, the LLViewModel is quietly deleted when the * last referencing widget is destroyed. */ -class LLViewModel -: public LLRefCount +class LLViewModel +: public LLRefCount { public: LLViewModel(); @@ -79,7 +79,7 @@ public: /// Once the value has been saved to a file, or otherwise consumed by the /// app, we no longer need to enable the Save button void resetDirty() { mDirty = false; } - // + // void setDirty() { mDirty = true; } protected: @@ -88,7 +88,7 @@ protected: }; /** - * LLTextViewModel stores a value displayed as text. + * LLTextViewModel stores a value displayed as text. */ class LLTextViewModel: public LLViewModel { @@ -96,15 +96,16 @@ public: LLTextViewModel(); /// Instantiate an LLViewModel with an existing data value LLTextViewModel(const LLSD& value); - - // LLViewModel functions + + // LLViewModel functions virtual void setValue(const LLSD& value); virtual LLSD getValue() const; + const std::string& getStringValue() const; - // New functions + // New functions /// Get the stored value in string form const LLWString& getDisplay() const { return mDisplay; } - LLWString& getEditableDisplay() { mDirty = true; mUpdateFromDisplay = true; return mDisplay; } + LLWString& getEditableDisplay() { mDirty = true; mUpdateFromDisplay = true; return mDisplay; } /** * Set the display string directly (see LLTextEditor). What the user is @@ -112,14 +113,19 @@ public: * UTF-8 value. */ void setDisplay(const LLWString& value); - + private: + std::string mStringValue; + /// To avoid converting every widget's stored value from LLSD to LLWString /// every frame, cache the converted value LLWString mDisplay; + /// As the user edits individual characters (setDisplay()), defer /// LLWString-to-UTF8 conversions until s/he's done. bool mUpdateFromDisplay; + + friend void updateFromDisplayIfNeeded(const LLTextViewModel* model); }; /** @@ -145,73 +151,73 @@ public: //namespace LLViewModel //{ -// class Value -// { -// public: -// Value(const LLSD& value = LLSD()); +// class Value +// { +// public: +// Value(const LLSD& value = LLSD()); // -// LLSD getValue() const { return mValue; } -// void setValue(const LLSD& value) { mValue = value; } +// LLSD getValue() const { return mValue; } +// void setValue(const LLSD& value) { mValue = value; } // -// bool isAvailable() const { return false; } -// bool isReadOnly() const { return false; } +// bool isAvailable() const { return false; } +// bool isReadOnly() const { return false; } // -// bool undo() { return false; } -// bool redo() { return false; } +// bool undo() { return false; } +// bool redo() { return false; } // -// /// Has the value been changed since last time we checked? -// bool isDirty() const { return mDirty; } -// /// Once the value has been saved to a file, or otherwise consumed by the -// /// app, we no longer need to enable the Save button -// void resetDirty() { mDirty = false; } -// // -// void setDirty() { mDirty = true; } +// /// Has the value been changed since last time we checked? +// bool isDirty() const { return mDirty; } +// /// Once the value has been saved to a file, or otherwise consumed by the +// /// app, we no longer need to enable the Save button +// void resetDirty() { mDirty = false; } +// // +// void setDirty() { mDirty = true; } // -// protected: -// LLSD mValue; -// bool mDirty; -// }; +// protected: +// LLSD mValue; +// bool mDirty; +// }; // -// class Numeric : public Value -// { -// public: -// Numeric(S32 value = 0); -// Numeric(F32 value); +// class Numeric : public Value +// { +// public: +// Numeric(S32 value = 0); +// Numeric(F32 value); // -// F32 getPrecision(); -// F32 getMin(); -// F32 getMax(); +// F32 getPrecision(); +// F32 getMin(); +// F32 getMax(); // -// void increment(); -// void decrement(); -// }; +// void increment(); +// void decrement(); +// }; // -// class MultipleValues : public Value -// { -// class Selector -// {}; +// class MultipleValues : public Value +// { +// class Selector +// {}; // -// MultipleValues(); -// virtual S32 numElements(); -// }; +// MultipleValues(); +// virtual S32 numElements(); +// }; // -// class Tuple : public MultipleValues -// { -// Tuple(S32 size); -// LLSD getValue(S32 which) const; -// void setValue(S32 which, const LLSD& value); -// }; +// class Tuple : public MultipleValues +// { +// Tuple(S32 size); +// LLSD getValue(S32 which) const; +// void setValue(S32 which, const LLSD& value); +// }; // -// class List : public MultipleValues -// { -// List(); +// class List : public MultipleValues +// { +// List(); // -// void add(const ValueModel& value); -// bool remove(const Selector& item); +// void add(const ValueModel& value); +// bool remove(const Selector& item); // -// void setSortElement(const Selector& element); -// void sort(); -// }; +// void setSortElement(const Selector& element); +// void sort(); +// }; // //}; #endif /* ! defined(LL_LLVIEWMODEL_H) */ |