/// <summary>
        /// helper to draw the base imagery (container and what have you)
        /// </summary>
        /// <param name="wlf"></param>
        protected void RenderBaseImagery(WidgetLookFeel wlf)
        {
            var w = (Editbox)Window;

            var imagery = wlf.GetStateImagery(w.IsEffectiveDisabled()
                                                  ? "Disabled"
                                                  : (w.IsReadOnly() ? "ReadOnly" : "Enabled"));

            imagery.Render(w);
        }
        protected void CreateRenderGeometryForTextWithBidi(WidgetLookFeel wlf, string text, Rectf textArea, float textOffset)
        {
            var font = Window.GetFont();

            // setup initial rect for text formatting
            var textPartRect = textArea;

            // allow for scroll position
            textPartRect.d_min.X += textOffset;
            // centre text vertically within the defined text area
            textPartRect.d_min.Y += (textArea.Height - font.GetFontHeight()) * 0.5f;

            var colours   = new ColourRect();
            var alphaComp = Window.GetEffectiveAlpha();
            // get unhighlighted text colour (saves accessing property twice)
            var unselectedColour = new ColourRect();

            SetColourRectToUnselectedTextColour(ref unselectedColour);
            // see if the editbox is active or inactive.
            var w      = (Editbox)Window;
            var active = EditboxIsFocussed();

            if (w.GetSelectionLength() == 0)
            {
                // no highlighted text - we can draw the whole thing
                colours = unselectedColour;
                w.AppendGeometryBuffers(font.CreateRenderGeometryForText(text, out textPartRect.d_min.X, textPartRect.Position, textArea, true, colours));
            }
            else
            {
                // there is highlighted text - because of the Bidi support - the
                // highlighted area can be in some cases nonconsecutive.
                // So - we need to draw it char by char (I guess we can optimize it more
                // but this is not that big performance hit because it only happens if
                // we have highlighted text - not that common...)
                for (var i = 0; i < text.Length; i++)
                {
                    // get the char
                    var currChar = text[i];
                    var realPos  = 0;

                    // get he visual pos of the char
                    if (w.GetBidiVisualMapping().GetV2lMapping().Count > i)
                    {
                        realPos = w.GetBidiVisualMapping().GetV2lMapping()[i];
                    }

                    // check if it is in the highlighted region
                    var highlighted = realPos >= w.GetSelectionStart() &&
                                      realPos < w.GetSelectionStart() + w.GetSelectionLength();

                    var charAdvance = font.GetGlyphData(currChar).GetAdvance();

                    if (highlighted)
                    {
                        SetColourRectToSelectedTextColour(ref colours);
                        colours.ModulateAlpha(alphaComp);

                        {
                            // calculate area for selection imagery.
                            var hlarea = textArea;
                            hlarea.d_min.X = textPartRect.d_min.X;
                            hlarea.d_max.X = textPartRect.d_min.X + charAdvance;

                            // render the selection imagery.
                            wlf.GetStateImagery(active ? "ActiveSelection" :"InactiveSelection").Render(w, hlarea, null, textArea);
                        }
                    }
                    else
                    {
                        colours = unselectedColour;
                        colours.ModulateAlpha(alphaComp);
                    }

                    w.AppendGeometryBuffers(font.CreateRenderGeometryForText(currChar.ToString(CultureInfo.InvariantCulture), textPartRect.Position, textArea, true, colours));

                    // adjust rect for next section
                    textPartRect.d_min.X += charAdvance;
                }
            }
        }
        protected void CreateRenderGeometryForTextWithoutBidi(WidgetLookFeel wlf, string text, Rectf textArea, float textOffset)
        {
            var font = Window.GetFont();

            // setup initial rect for text formatting
            var textPartRect = textArea;

            // allow for scroll position
            textPartRect.d_min.X += textOffset;

            // centre text vertically within the defined text area
            textPartRect.d_min.Y += (textArea.Height - font.GetFontHeight()) * 0.5f;

            var alphaComp = Window.GetEffectiveAlpha();

            // get unhighlighted text colour (saves accessing property twice)
            var unselectedColours = new ColourRect();

            SetColourRectToUnselectedTextColour(ref unselectedColours);

            // see if the editbox is active or inactive.
            var w      = (Editbox)Window;
            var active = EditboxIsFocussed();

            if (w.GetSelectionLength() != 0)
            {
                // calculate required start and end offsets of selection imagery.
                var selStartOffset = font.GetTextAdvance(text.CEGuiSubstring(0, w.GetSelectionStart()));
                var selEndOffset   = font.GetTextAdvance(text.CEGuiSubstring(0, w.GetSelectionEnd()));

                // calculate area for selection imagery.
                Rectf hlarea = textArea;
                hlarea.d_min.X += textOffset + selStartOffset;
                hlarea.d_max.X  = hlarea.d_min.X + (selEndOffset - selStartOffset);

                // create render geometry for the selection imagery.
                wlf.GetStateImagery(active ? "ActiveSelection" : "InactiveSelection").Render(w, hlarea, null, textArea);
            }

            // create render geometry for pre-highlight text
            var sect    = text.CEGuiSubstring(0, w.GetSelectionStart());
            var colours = unselectedColours;

            colours.ModulateAlpha(alphaComp);
            var preHighlightTextGeomBuffers = font.CreateRenderGeometryForText(sect, out textPartRect.d_min.X, textPartRect.Position, textArea, true, colours);

            w.AppendGeometryBuffers(preHighlightTextGeomBuffers);

            // create render geometry for highlight text
            sect = text.CEGuiSubstring(w.GetSelectionStart(), w.GetSelectionLength());
            SetColourRectToSelectedTextColour(ref colours);
            colours.ModulateAlpha(alphaComp);
            var highlitTextGeomBuffers = font.CreateRenderGeometryForText(sect, out textPartRect.d_min.X, textPartRect.Position, textArea, true, colours);

            w.AppendGeometryBuffers(highlitTextGeomBuffers);

            // create render geometry for post-highlight text
            sect    = text.Substring(w.GetSelectionEnd());
            colours = unselectedColours;
            colours.ModulateAlpha(alphaComp);
            var postHighlitTextGeomBuffers = font.CreateRenderGeometryForText(sect, out textPartRect.d_min.X, textPartRect.Position, textArea, true, colours);

            w.AppendGeometryBuffers(postHighlitTextGeomBuffers);
        }