+void Controller::SetDefaultUnderlineProperties( const std::string& underlineProperties )
+{
+ if( NULL == mImpl->mUnderlineDefaults )
+ {
+ mImpl->mUnderlineDefaults = new UnderlineDefaults();
+ }
+
+ mImpl->mUnderlineDefaults->properties = underlineProperties;
+}
+
+const std::string& Controller::GetDefaultUnderlineProperties() const
+{
+ if( NULL != mImpl->mUnderlineDefaults )
+ {
+ return mImpl->mUnderlineDefaults->properties;
+ }
+
+ return EMPTY_STRING;
+}
+
+void Controller::SetDefaultEmbossProperties( const std::string& embossProperties )
+{
+ if( NULL == mImpl->mEmbossDefaults )
+ {
+ mImpl->mEmbossDefaults = new EmbossDefaults();
+ }
+
+ mImpl->mEmbossDefaults->properties = embossProperties;
+}
+
+const std::string& Controller::GetDefaultEmbossProperties() const
+{
+ if( NULL != mImpl->mEmbossDefaults )
+ {
+ return mImpl->mEmbossDefaults->properties;
+ }
+
+ return EMPTY_STRING;
+}
+
+void Controller::SetDefaultOutlineProperties( const std::string& outlineProperties )
+{
+ if( NULL == mImpl->mOutlineDefaults )
+ {
+ mImpl->mOutlineDefaults = new OutlineDefaults();
+ }
+
+ mImpl->mOutlineDefaults->properties = outlineProperties;
+}
+
+const std::string& Controller::GetDefaultOutlineProperties() const
+{
+ if( NULL != mImpl->mOutlineDefaults )
+ {
+ return mImpl->mOutlineDefaults->properties;
+ }
+
+ return EMPTY_STRING;
+}
+
+void Controller::SetDefaultLineSpacing( float lineSpacing )
+{
+ //TODO finish implementation
+ mImpl->mLayoutEngine.SetDefaultLineSpacing( lineSpacing );
+}
+
+float Controller::GetDefaultLineSpacing() const
+{
+ return mImpl->mLayoutEngine.GetDefaultLineSpacing();
+}
+
+void Controller::SetInputColor( const Vector4& color )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.textColor = color;
+ mImpl->mEventData->mInputStyle.isDefaultColor = false;
+
+ if( EventData::SELECTING == mImpl->mEventData->mState )
+ {
+ const bool handlesCrossed = mImpl->mEventData->mLeftSelectionPosition > mImpl->mEventData->mRightSelectionPosition;
+
+ // Get start and end position of selection
+ const CharacterIndex startOfSelectedText = handlesCrossed ? mImpl->mEventData->mRightSelectionPosition : mImpl->mEventData->mLeftSelectionPosition;
+ const Length lengthOfSelectedText = ( handlesCrossed ? mImpl->mEventData->mLeftSelectionPosition : mImpl->mEventData->mRightSelectionPosition ) - startOfSelectedText;
+
+ // Add the color run.
+ const VectorBase::SizeType numberOfRuns = mImpl->mLogicalModel->mColorRuns.Count();
+ mImpl->mLogicalModel->mColorRuns.Resize( numberOfRuns + 1u );
+
+ ColorRun& colorRun = *( mImpl->mLogicalModel->mColorRuns.Begin() + numberOfRuns );
+ colorRun.color = color;
+ colorRun.characterRun.characterIndex = startOfSelectedText;
+ colorRun.characterRun.numberOfCharacters = lengthOfSelectedText;
+
+ // Request to relayout.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending | COLOR );
+ mImpl->RequestRelayout();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+ }
+ }
+}
+
+const Vector4& Controller::GetInputColor() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.textColor;
+ }
+
+ // Return the default text's color if there is no EventData.
+ return mImpl->mTextColor;
+
+}
+
+void Controller::SetInputFontFamily( const std::string& fontFamily )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.familyName = fontFamily;
+ mImpl->mEventData->mInputStyle.familyDefined = true;
+
+ if( EventData::SELECTING == mImpl->mEventData->mState )
+ {
+ CharacterIndex startOfSelectedText = 0u;
+ Length lengthOfSelectedText = 0u;
+ FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
+ mImpl->mLogicalModel,
+ startOfSelectedText,
+ lengthOfSelectedText );
+
+ fontDescriptionRun.familyLength = fontFamily.size();
+ fontDescriptionRun.familyName = new char[fontDescriptionRun.familyLength];
+ memcpy( fontDescriptionRun.familyName, fontFamily.c_str(), fontDescriptionRun.familyLength );
+ fontDescriptionRun.familyDefined = true;
+
+ // The memory allocated for the font family name is freed when the font description is removed from the logical model.
+
+ // Request to relayout.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ VALIDATE_FONTS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER |
+ ALIGN );
+ mImpl->mRecalculateNaturalSize = true;
+ mImpl->RequestRelayout();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
+ // As the font changes, recalculate the handle positions is needed.
+ mImpl->mEventData->mUpdateLeftSelectionPosition = true;
+ mImpl->mEventData->mUpdateRightSelectionPosition = true;
+ mImpl->mEventData->mUpdateHighlightBox = true;
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
+ }
+}
+
+const std::string& Controller::GetInputFontFamily() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.familyName;
+ }
+
+ // Return the default font's family if there is no EventData.
+ return GetDefaultFontFamily();
+}
+
+void Controller::SetInputFontStyle( const std::string& fontStyle )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.fontStyle = fontStyle;
+ }
+}
+
+const std::string& Controller::GetInputFontStyle() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.fontStyle;
+ }
+
+ // Return the default font's style if there is no EventData.
+ return GetDefaultFontStyle();
+}
+
+void Controller::SetInputFontWeight( FontWeight weight )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.weight = weight;
+ mImpl->mEventData->mInputStyle.weightDefined = true;
+
+ if( EventData::SELECTING == mImpl->mEventData->mState )
+ {
+ CharacterIndex startOfSelectedText = 0u;
+ Length lengthOfSelectedText = 0u;
+ FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
+ mImpl->mLogicalModel,
+ startOfSelectedText,
+ lengthOfSelectedText );
+
+ fontDescriptionRun.weight = weight;
+ fontDescriptionRun.weightDefined = true;
+
+ // Request to relayout.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ VALIDATE_FONTS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER |
+ ALIGN );
+ mImpl->mRecalculateNaturalSize = true;
+ mImpl->RequestRelayout();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
+ // As the font might change, recalculate the handle positions is needed.
+ mImpl->mEventData->mUpdateLeftSelectionPosition = true;
+ mImpl->mEventData->mUpdateRightSelectionPosition = true;
+ mImpl->mEventData->mUpdateHighlightBox = true;
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
+ }
+}
+
+FontWeight Controller::GetInputFontWeight() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.weight;
+ }
+
+ return GetDefaultFontWeight();
+}
+
+void Controller::SetInputFontWidth( FontWidth width )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.width = width;
+ mImpl->mEventData->mInputStyle.widthDefined = true;
+
+ if( EventData::SELECTING == mImpl->mEventData->mState )
+ {
+ CharacterIndex startOfSelectedText = 0u;
+ Length lengthOfSelectedText = 0u;
+ FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
+ mImpl->mLogicalModel,
+ startOfSelectedText,
+ lengthOfSelectedText );
+
+ fontDescriptionRun.width = width;
+ fontDescriptionRun.widthDefined = true;
+
+ // Request to relayout.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ VALIDATE_FONTS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER |
+ ALIGN );
+ mImpl->mRecalculateNaturalSize = true;
+ mImpl->RequestRelayout();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
+ // As the font might change, recalculate the handle positions is needed.
+ mImpl->mEventData->mUpdateLeftSelectionPosition = true;
+ mImpl->mEventData->mUpdateRightSelectionPosition = true;
+ mImpl->mEventData->mUpdateHighlightBox = true;
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
+ }
+}
+
+FontWidth Controller::GetInputFontWidth() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.width;
+ }
+
+ return GetDefaultFontWidth();
+}
+
+void Controller::SetInputFontSlant( FontSlant slant )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.slant = slant;
+ mImpl->mEventData->mInputStyle.slantDefined = true;
+
+ if( EventData::SELECTING == mImpl->mEventData->mState )
+ {
+ CharacterIndex startOfSelectedText = 0u;
+ Length lengthOfSelectedText = 0u;
+ FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
+ mImpl->mLogicalModel,
+ startOfSelectedText,
+ lengthOfSelectedText );
+
+ fontDescriptionRun.slant = slant;
+ fontDescriptionRun.slantDefined = true;
+
+ // Request to relayout.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ VALIDATE_FONTS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER |
+ ALIGN );
+ mImpl->mRecalculateNaturalSize = true;
+ mImpl->RequestRelayout();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
+ // As the font might change, recalculate the handle positions is needed.
+ mImpl->mEventData->mUpdateLeftSelectionPosition = true;
+ mImpl->mEventData->mUpdateRightSelectionPosition = true;
+ mImpl->mEventData->mUpdateHighlightBox = true;
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
+ }
+}
+
+FontSlant Controller::GetInputFontSlant() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.slant;
+ }
+
+ return GetDefaultFontSlant();
+}
+
+void Controller::SetInputFontPointSize( float size )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.size = size;
+
+ if( EventData::SELECTING == mImpl->mEventData->mState )
+ {
+ CharacterIndex startOfSelectedText = 0u;
+ Length lengthOfSelectedText = 0u;
+ FontDescriptionRun& fontDescriptionRun = UpdateSelectionFontStyleRun( mImpl->mEventData,
+ mImpl->mLogicalModel,
+ startOfSelectedText,
+ lengthOfSelectedText );
+
+ fontDescriptionRun.size = static_cast<PointSize26Dot6>( size * 64.f );
+ fontDescriptionRun.sizeDefined = true;
+
+ // Request to relayout.
+ mImpl->mOperationsPending = static_cast<OperationsMask>( mImpl->mOperationsPending |
+ VALIDATE_FONTS |
+ SHAPE_TEXT |
+ GET_GLYPH_METRICS |
+ LAYOUT |
+ UPDATE_LAYOUT_SIZE |
+ REORDER |
+ ALIGN );
+ mImpl->mRecalculateNaturalSize = true;
+ mImpl->RequestRelayout();
+
+ mImpl->mTextUpdateInfo.mCharacterIndex = startOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToRemove = lengthOfSelectedText;
+ mImpl->mTextUpdateInfo.mNumberOfCharactersToAdd = lengthOfSelectedText;
+
+ // As the font might change, recalculate the handle positions is needed.
+ mImpl->mEventData->mUpdateLeftSelectionPosition = true;
+ mImpl->mEventData->mUpdateRightSelectionPosition = true;
+ mImpl->mEventData->mUpdateHighlightBox = true;
+ mImpl->mEventData->mScrollAfterUpdatePosition = true;
+ }
+ }
+}
+
+float Controller::GetInputFontPointSize() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.size;
+ }
+
+ // Return the default font's point size if there is no EventData.
+ return GetDefaultPointSize();
+}
+
+void Controller::SetInputLineSpacing( float lineSpacing )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.lineSpacing = lineSpacing;
+ }
+}
+
+float Controller::GetInputLineSpacing() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.lineSpacing;
+ }
+
+ return 0.f;
+}
+
+void Controller::SetInputShadowProperties( const std::string& shadowProperties )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.shadowProperties = shadowProperties;
+ }
+}
+
+const std::string& Controller::GetInputShadowProperties() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.shadowProperties;
+ }
+
+ return GetDefaultShadowProperties();
+}
+
+void Controller::SetInputUnderlineProperties( const std::string& underlineProperties )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.underlineProperties = underlineProperties;
+ }
+}
+
+const std::string& Controller::GetInputUnderlineProperties() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.underlineProperties;
+ }
+
+ return GetDefaultUnderlineProperties();
+}
+
+void Controller::SetInputEmbossProperties( const std::string& embossProperties )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.embossProperties = embossProperties;
+ }
+}
+
+const std::string& Controller::GetInputEmbossProperties() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.embossProperties;
+ }
+
+ return GetDefaultEmbossProperties();
+}
+
+void Controller::SetInputOutlineProperties( const std::string& outlineProperties )
+{
+ if( NULL != mImpl->mEventData )
+ {
+ mImpl->mEventData->mInputStyle.outlineProperties = outlineProperties;
+ }
+}
+
+const std::string& Controller::GetInputOutlineProperties() const
+{
+ if( NULL != mImpl->mEventData )
+ {
+ return mImpl->mEventData->mInputStyle.outlineProperties;
+ }
+
+ return GetDefaultOutlineProperties();
+}
+