/// <summary> /// helper to set up an appropriate FormattedRenderedString /// </summary> /// <param name="window"></param> /// <param name="renderedString"></param> protected void SetupStringFormatter(Window window, RenderedString renderedString) { var horzFormatting = _horzFormatting.Get(window); // no formatting change if (horzFormatting == _lastHorizontalFormatting) { _formattedRenderedString.SetRenderedString(renderedString); return; } _lastHorizontalFormatting = horzFormatting; switch (horzFormatting) { case HorizontalTextFormatting.LeftAligned: _formattedRenderedString = new LeftAlignedRenderedString(renderedString); break; case HorizontalTextFormatting.CentreAligned: _formattedRenderedString = new CentredRenderedString(renderedString); break; case HorizontalTextFormatting.RightAligned: _formattedRenderedString = new RightAlignedRenderedString(renderedString); break; case HorizontalTextFormatting.Justified: _formattedRenderedString = new JustifiedRenderedString(renderedString); break; case HorizontalTextFormatting.WordWrapLeftAligned: _formattedRenderedString = new RenderedStringWordWrapper <LeftAlignedRenderedString>(renderedString); //new RenderedStringWordWrapper<LeftAlignedRenderedString>(rendered_string, rs => new LeftAlignedRenderedString(rs)); break; case HorizontalTextFormatting.WordWrapCentreAligned: _formattedRenderedString = new RenderedStringWordWrapper <CentredRenderedString>(renderedString); //new RenderedStringWordWrapper<CentredRenderedString>(rendered_string, rs => new CentredRenderedString(rs)); break; case HorizontalTextFormatting.WordWrapRightAligned: _formattedRenderedString = new RenderedStringWordWrapper <RightAlignedRenderedString>(renderedString); //new RenderedStringWordWrapper<RightAlignedRenderedString>(rendered_string, rs => new RightAlignedRenderedString(rs)); break; case HorizontalTextFormatting.WordWrapJustified: _formattedRenderedString = new RenderedStringWordWrapper <JustifiedRenderedString>(renderedString); //new RenderedStringWordWrapper<JustifiedRenderedString>(rendered_string, rs => new JustifiedRenderedString(rs)); break; } }
public TextComponent() { #if CEGUI_BIDI_SUPPORT _bidiVisualMapping = new NBidiVisualMapping(); #else _bidiVisualMapping = null; #endif _bidiDataValid = false; _formattedRenderedString = new LeftAlignedRenderedString(_renderedString); _lastHorizontalFormatting = HorizontalTextFormatting.LeftAligned; _vertFormatting = new FormattingSetting <VerticalTextFormatting>(VerticalTextFormatting.TopAligned); _horzFormatting = new FormattingSetting <HorizontalTextFormatting>(HorizontalTextFormatting.LeftAligned); }