Пример #1
0
float FalagardSlider::getValueFromThumb(void) const
{
    Slider* w = (Slider*)d_window;
    // get area the thumb is supposed to use as it's area.
    const WidgetLookFeel& wlf = getLookNFeel();
    const Rectf area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*w));
    // get accesss to the thumb
    Thumb* theThumb = w->getThumb();

    // slider is vertical
    if (d_vertical)
    {
        // pixel extent of total available area the thumb moves in
        float slideExtent = area.getHeight() - theThumb->getPixelSize().d_height;
        // calculate value represented by current thumb position
        float thumbValue = (CoordConverter::asAbsolute(
                                theThumb->getYPosition(), w->getPixelSize().d_height) - area.top()) / (slideExtent / w->getMaxValue());
        // return final thumb value according to slider settings
        return d_reversed ? thumbValue : w->getMaxValue() - thumbValue;
    }
    // slider is horizontal
    else
    {
        // pixel extent of total available area the thumb moves in
        float slideExtent = area.getWidth() - theThumb->getPixelSize().d_width;
        // calculate value represented by current thumb position
        float thumbValue = (CoordConverter::asAbsolute(
                                theThumb->getXPosition(), w->getPixelSize().d_width) - area.left()) / (slideExtent / w->getMaxValue());
        // return final thumb value according to slider settings
        return d_reversed ? w->getMaxValue() - thumbValue : thumbValue;
    }
}
void FalagardMultiLineEditbox::cacheEditboxBaseImagery()
{
    MultiLineEditbox* w = (MultiLineEditbox*)d_window;
    const StateImagery* imagery;

    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();

    String state;

    if (w->isEffectiveDisabled())
        state = "Disabled";
    else
    {
        if (w->isReadOnly())
            state = "ReadOnly";
        else
            state = "Enabled";

        if (w->isFocused())
            state += "Focused";
    }

    // try and get imagery for our current state
    imagery = &wlf.getStateImagery(state);
    // perform the rendering operation.
    imagery->render(*w);
}
Пример #3
0
    void FalagardFrameWindow::render()
    {
        FrameWindow* w = (FrameWindow*)d_window;
        // do not render anything for the rolled-up state.
        if (w->isRolledup())
            return;

        // build state name
        String stateName(w->isDisabled() ? "Disabled" : (w->isActive() ? "Active" : "Inactive"));
        stateName += w->getTitlebar()->isVisible() ? "WithTitle" : "NoTitle";
        stateName += w->isFrameEnabled() ? "WithFrame" : "NoFrame";

        const StateImagery* imagery;

        try
        {
            // get WidgetLookFeel for the assigned look.
            const WidgetLookFeel& wlf = getLookNFeel();
            // try and get imagery for our current state
            imagery = &wlf.getStateImagery(stateName);
        }
        catch (UnknownObjectException&)
        {
            // log error so we know imagery is missing, and then quit.
            return;
        }

        // peform the rendering operation.
        imagery->render(*w);
    }
Пример #4
0
    Rectf FalagardMultiColumnList::getListRenderArea(void) const
    {
        MultiColumnList* w = (MultiColumnList*)d_window;
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();
        bool v_visible = w->getVertScrollbar()->isVisible();
        bool h_visible = w->getHorzScrollbar()->isVisible();

        // if either of the scrollbars are visible, we might want to use another item rendering area
        if (v_visible || h_visible)
        {
            String area_name("ItemRenderingArea");

            if (h_visible)
            {
                area_name += "H";
            }
            if (v_visible)
            {
                area_name += "V";
            }
            area_name += "Scroll";

            if (wlf.isNamedAreaDefined(area_name))
            {
                return wlf.getNamedArea(area_name).getArea().getPixelRect(*w);
            }
        }

        // default to plain ItemRenderingArea
        return wlf.getNamedArea("ItemRenderingArea").getArea().getPixelRect(*w);
    }
Пример #5
0
    void FalagardTabButton::render()
    {
        TabButton* w = (TabButton*)d_window;
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();

		TabControl* tc = static_cast<TabControl*>(w->getParent()->getParent());

        String state;
		String prefix((tc->getTabPanePosition() == TabControl::Top) ? "Top" : "Bottom");

		if (w->isDisabled())
		    state = "Disabled";
		else if (w->isSelected())
		    state = "Selected";
		else if (w->isPushed())
		    state = "Pushed";
		else if (w->isHovering())
		    state = "Hover";
		else
		    state = "Normal";

        if (!wlf.isStateImageryPresent(prefix + state))
        {
            state = "Normal";
			if (!wlf.isStateImageryPresent(prefix + state))
				prefix = "";
        }

        wlf.getStateImagery(prefix + state).render(*w);
    }
Пример #6
0
    void FalagardStatic::render()
    {
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();

		bool is_enabled = !d_window->isDisabled();

        // render frame section
        if (d_frameEnabled)
        {
            wlf.getStateImagery(is_enabled ? "EnabledFrame" : "DisabledFrame").render(*d_window);
        }

        // render background section
        if (d_backgroundEnabled)
        {
            const StateImagery* imagery;
            if (d_frameEnabled)
            {
                imagery = &wlf.getStateImagery(is_enabled ? "WithFrameEnabledBackground" : "WithFrameDisabledBackground");
            }
            else
            {
                imagery = &wlf.getStateImagery(is_enabled ? "NoFrameEnabledBackground" : "NoFrameDisabledBackground");
            }
            // peform the rendering operation.
            imagery->render(*d_window);
        }

        // render basic imagery
        wlf.getStateImagery(is_enabled ? "Enabled" : "Disabled").render(*d_window);
    }
Пример #7
0
    Rect FalagardItemListbox::getItemRenderArea(void) const
    {
        ItemListbox* lb = static_cast<ItemListbox*>(d_window);
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();
        bool v_visible = lb->getVertScrollbar()->isVisible(true);
        bool h_visible = lb->getHorzScrollbar()->isVisible(true);

        // if either of the scrollbars are visible, we might want to use another text rendering area
        if (v_visible || h_visible)
        {
            String area_name("ItemRenderArea");

            if (h_visible)
            {
                area_name.push_back('H');
            }
            if (v_visible)
            {
                area_name.push_back('V');
            }
            area_name += "Scroll";

            if (wlf.isNamedAreaDefined(area_name))
            {
                return wlf.getNamedArea(area_name).getArea().getPixelRect(*lb);
            }
        }

        // default to plain ItemRenderArea
        return wlf.getNamedArea("ItemRenderArea").getArea().getPixelRect(*lb);
    }
Пример #8
0
    void FalagardButton::render()
    {
        ButtonBase* w = (ButtonBase*)d_window;
        const WidgetLookFeel& wlf = getLookNFeel();

        bool norm = false;
        String state;

		if (w->isEffectiveDisabled())
		{
		    state = "Disabled";
		}
		else if (w->isPushed())
		{
            state = w->isHovering() ? "Pushed" : "PushedOff";
		}
        else if (w->isHovering())
		{
		    state = "Hover";
		}
		else
		{
		    state = "Normal";
		    norm = true;
		}

        if (!norm && !wlf.isStateImageryPresent(actualStateName(state)))
        {
            state = "Normal";
        }

        wlf.getStateImagery(actualStateName(state)).render(*w);
    }
Пример #9
0
 void FalagardTooltip::render()
 {
     // get WidgetLookFeel for the assigned look.
     const WidgetLookFeel& wlf = getLookNFeel();
     // try and get imagery for our current state
     const StateImagery* imagery = &wlf.getStateImagery(d_window->isEffectiveDisabled() ? "Disabled" : "Enabled");
     // peform the rendering operation.
     imagery->render(*d_window);
 }
Пример #10
0
 void FalagardListHeader::render()
 {
     const StateImagery* imagery;
     // get WidgetLookFeel for the assigned look.
     const WidgetLookFeel& wlf = getLookNFeel();
     // render basic imagery
     imagery = &wlf.getStateImagery(d_window->isEffectiveDisabled() ? "Disabled" : "Enabled");
     imagery->render(*d_window);
 }
    void FalagardProgressBarEx::render()
    {
        const StateImagery* imagery;

        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();
        // try and get imagery for our current state
        imagery = &wlf.getStateImagery(d_window->isDisabled() ? "Disabled" : "Enabled");
        // peform the rendering operation.
        imagery->render(*d_window);

        // get imagery for actual progress rendering
        imagery = &wlf.getStateImagery(d_window->isDisabled() ? "DisabledProgress" : "EnabledProgress");

        // get target rect for this imagery
        Rect progressRect(wlf.getNamedArea("ProgressArea").getArea().getPixelRect(*d_window));

        // calculate a clipper according to the current progress.
        Rect progressClipper(progressRect);

        ProgressBar* w = (ProgressBar*)d_window;
        if (d_vertical)
        {
            float height = PixelAligned(progressClipper.getHeight() * w->getProgress());

            if (d_reversed)
            {
                progressClipper.setHeight(height);
            }
            else
            {
                progressClipper.d_top = progressClipper.d_bottom - height;
            }
        }
        else
        {
            float width = PixelAligned(progressClipper.getWidth() * w->getProgress());

            if (d_reversed)
            {
                progressClipper.d_left = progressClipper.d_right - width;
            }
            else
            {
                progressClipper.setWidth(width);
            }
        }

        // peform the rendering operation.
        imagery->render(*d_window, progressRect, 0, &progressClipper);

        // perform the text rendering operation
        imagery = &wlf.getStateImagery("Label");
        imagery->render(*d_window);
    }
Пример #12
0
    void FalagardMultiColumnList::cacheListboxBaseImagery()
    {
        const StateImagery* imagery;

        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();
        // try and get imagery for our current state
        imagery = &wlf.getStateImagery(d_window->isEffectiveDisabled() ? "Disabled" : "Enabled");
        // peform the rendering operation.
        imagery->render(*d_window);
    }
Пример #13
0
//----------------------------------------------------------------------------//
void FalagardTreeView::onLookNFeelAssigned()
{
    const WidgetLookFeel& wlf = getLookNFeel();
    d_subtreeExpanderImagery = &wlf.getImagerySection("SubtreeExpander");
    d_subtreeCollapserImagery = &wlf.getImagerySection("SubtreeCollapser");

    Sizef open_size = getImagerySize(*d_subtreeExpanderImagery);
    Sizef close_size = getImagerySize(*d_subtreeCollapserImagery);
    d_subtreeExpanderImagerySize = Sizef(
        (open_size.d_width + close_size.d_width) / 2.0f + getView()->getSubtreeExpanderMargin(),
        (open_size.d_height + close_size.d_height) / 2.0f + getView()->getSubtreeExpanderMargin());
}
Пример #14
0
void FalagardMultiLineEditbox::cacheEditboxBaseImagery()
{
    MultiLineEditbox* w = (MultiLineEditbox*)d_window;
    const StateImagery* imagery;

    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();
    // try and get imagery for our current state
    imagery = &wlf.getStateImagery(w->isEffectiveDisabled() ? "Disabled" : (w->isReadOnly() ? "ReadOnly" : "Enabled"));
    // peform the rendering operation.
    imagery->render(*w);
}
//------------------------------------------------------------------------------//
void InventoryItemRenderer::render()
{
    const WidgetLookFeel& wlf = getLookNFeel();

    InventoryItem* item = dynamic_cast<InventoryItem*>(d_window);

    if (!item)
        // render basic imagery
        wlf.getStateImagery(d_window->isDisabled() ? "Disabled" : "Enabled").render(*d_window);

    if (item->isBeingDragged())
        wlf.getStateImagery(item->currentDropTargetIsValid() ? "DraggingValidTarget" : "DraggingInvalidTarget").render(*item);
    else
        wlf.getStateImagery("Normal").render(*item);
}
Пример #16
0
    Rect FalagardFrameWindow::getUnclippedInnerRect(void) const
    {
        FrameWindow* w = (FrameWindow*)d_window;
        if (w->isRolledup())
            return Rect(0,0,0,0);

        // build name of area to fetch
        String areaName("Client");
        areaName += w->getTitlebar()->isVisible() ? "WithTitle" : "NoTitle";
        areaName += w->isFrameEnabled() ? "WithFrame" : "NoFrame";

        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();
        return wlf.getNamedArea(areaName).getArea().getPixelRect(*w, w->getUnclippedPixelRect());
    }
Пример #17
0
    Sizef FalagardTooltip::getTextSize() const
    {
        Tooltip* w = (Tooltip*)d_window;
        Sizef sz(w->getTextSize_impl());

        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();

        const Rectf textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*w));
        const Rectf wndArea(CoordConverter::asAbsolute(w->getArea(), w->getParentPixelSize()));

        sz.d_width  = CoordConverter::alignToPixels(sz.d_width + wndArea.getWidth() - textArea.getWidth());
        sz.d_height = CoordConverter::alignToPixels(sz.d_height + wndArea.getHeight() - textArea.getHeight());
        return sz;
    }
Пример #18
0
//----------------------------------------------------------------------------//
void FalagardMenuItem::render()
{
    MenuItem* w = (MenuItem*)d_window;
    // build name of state we're in
    String stateName(w->isEffectiveDisabled() ? "Disabled" : "Enabled");

    String suffix;

	// only show opened imagery if the menu items popup window is not closing
	// (otherwise it might look odd)
    if (w->isOpened() && !(w->hasAutoPopup() && w->isPopupClosing()))
        suffix = "PopupOpen";
    else if (w->isPushed())
        suffix = w->isHovering() ? "Pushed" : "PushedOff";
    else if (w->isHovering())
        suffix = "Hover";
    else
        suffix = "Normal";

    const StateImagery* imagery;
    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();

    // try and get imagery for our current state
    if (wlf.isStateImageryPresent(stateName + suffix))
    {
        imagery = &wlf.getStateImagery(stateName + suffix);
    }
    else
    {
        imagery = &wlf.getStateImagery(stateName + "Normal");
    }

    // peform the rendering operation.
    imagery->render(*w);

    // only draw popup-open/closed-icon if we have a popup menu, and parent is not a menubar
    Window* parent_window = w->getParent();
    bool not_menubar = (!parent_window) ? true : !dynamic_cast<Menubar*>(parent_window);

    if (w->getPopupMenu() && not_menubar)
    {
        // get imagery for popup open/closed state
        imagery = &wlf.getStateImagery(w->isOpened() ? "PopupOpenIcon" : "PopupClosedIcon");
        // peform the rendering operation.
        imagery->render(*w);
    }
}
Пример #19
0
//----------------------------------------------------------------------------//
void FalagardListView::render()
{
    const StateImagery* imagery;
    const WidgetLookFeel& wlf = getLookNFeel();
    ListView* list_view = static_cast<ListView*>(d_window);

    list_view->prepareForRender();

    bool has_focused_state =
        list_view->isFocused() && wlf.isStateImageryPresent("EnabledFocused");
    imagery = &wlf.getStateImagery(
        list_view->isEffectiveDisabled() ? "Disabled" :
            (has_focused_state ? "EnabledFocused" : "Enabled"));
    imagery->render(*list_view);

    render(list_view);
}
Пример #20
0
//----------------------------------------------------------------------------//
void FalagardTreeView::render()
{
    const WidgetLookFeel& wlf = getLookNFeel();
    TreeView* tree_view = getView();

    tree_view->prepareForRender();

    bool has_focused_state =
        tree_view->isFocused() && wlf.isStateImageryPresent("EnabledFocused");
    const StateImagery* imagery = &wlf.getStateImagery(
        tree_view->isEffectiveDisabled() ? "Disabled" :
            (has_focused_state ? "EnabledFocused" : "Enabled"));
    imagery->render(*tree_view);

    Rectf items_area(getViewRenderArea());
    glm::vec2 item_pos(getItemRenderStartPosition(tree_view, items_area));
    renderTreeItem(tree_view, items_area, item_pos, &tree_view->getRootItemState(), 0);
}
Пример #21
0
void FalagardMultiLineEditbox::cacheCaretImagery(const Rectf& textArea)
{
    MultiLineEditbox* w = (MultiLineEditbox*)d_window;
    const Font* fnt = w->getFont();

    // require a font so that we can calculate caret position.
    if (fnt)
    {
        // get line that caret is in
        size_t caretLine = w->getLineNumberFromIndex(w->getCaretIndex());

        const MultiLineEditbox::LineList& d_lines = w->getFormattedLines();

        // if caret line is valid.
        if (caretLine < d_lines.size())
        {
            // calculate pixel offsets to where caret should be drawn
            size_t caretLineIdx = w->getCaretIndex() - d_lines[caretLine].d_startIdx;
            float ypos = caretLine * fnt->getLineSpacing();
            float xpos = fnt->getTextAdvance(w->getText().substr(d_lines[caretLine].d_startIdx, caretLineIdx));

//             // get base offset to target layer for cursor.
//             Renderer* renderer = System::getSingleton().getRenderer();
//             float baseZ = renderer->getZLayer(7) - renderer->getCurrentZ();

            // get WidgetLookFeel for the assigned look.
            const WidgetLookFeel& wlf = getLookNFeel();
            // get caret imagery
            const ImagerySection& caretImagery = wlf.getImagerySection("Caret");

            // calculate finat destination area for caret
            Rectf caretArea;
            caretArea.left(textArea.left() + xpos);
            caretArea.top(textArea.top() + ypos);
            caretArea.setWidth(caretImagery.getBoundingRect(*w).getSize().d_width);
            caretArea.setHeight(fnt->getLineSpacing());
            caretArea.offset(Vector2f(-w->getHorzScrollbar()->getScrollPosition(), -w->getVertScrollbar()->getScrollPosition()));

            // cache the caret image for rendering.
            caretImagery.render(*w, caretArea, 0, &textArea);
        }
    }
}
Пример #22
0
    float FalagardScrollbar::getValueFromThumb(void) const
    {
        Scrollbar* w = (Scrollbar*)d_window;
        const WidgetLookFeel& wlf = getLookNFeel();
        const Rectf area(wlf.getNamedArea("ThumbTrackArea").getArea().getPixelRect(*w));

        Thumb* theThumb = w->getThumb();
        float posExtent = w->getDocumentSize() - w->getPageSize();

        if (d_vertical)
        {
            float slideExtent = area.getHeight() - theThumb->getPixelSize().d_height;
            return (CoordConverter::asAbsolute(theThumb->getYPosition(), w->getPixelSize().d_height) - area.top()) / (slideExtent / posExtent);
        }
        else
        {
            float slideExtent = area.getWidth() - theThumb->getPixelSize().d_width;
            return (CoordConverter::asAbsolute(theThumb->getXPosition(), w->getPixelSize().d_width) - area.left()) / (slideExtent / posExtent);
        }
    }
Пример #23
0
void FalagardItemEntry::render()
{
    ItemEntry* item = static_cast<ItemEntry*>(d_window);

    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();

    const StateImagery* imagery;
    // render basic imagery
    String state = item->isDisabled() ? "Disabled" : "Enabled";
    if (item->isSelectable() && item->isSelected())
    {
        imagery = &wlf.getStateImagery(item->isDisabled()?"SelectedDisabled":"SelectedEnabled");
    }
    else
    {
        imagery = &wlf.getStateImagery(item->isDisabled()?"Disabled":"Enabled");
    }
    imagery->render(*d_window);
}
Пример #24
0
    Rectf FalagardItemListbox::getItemRenderingArea(bool hscroll,
                                                    bool vscroll) const
    {
    	const ItemListbox* const lb = static_cast<ItemListbox*>(d_window);
        const WidgetLookFeel& wlf = getLookNFeel();
        const String area_name("ItemRenderArea");
        const String alternate_name("ItemRenderingArea");
        const String scroll_suffix(
            vscroll ? hscroll ? "HVScroll" : "VScroll" : hscroll ? "HScroll" : "");

        if (wlf.isNamedAreaDefined(area_name + scroll_suffix))
                return wlf.getNamedArea(area_name + scroll_suffix).getArea().getPixelRect(*lb);

        if (wlf.isNamedAreaDefined(alternate_name + scroll_suffix))
                return wlf.getNamedArea(alternate_name + scroll_suffix).getArea().getPixelRect(*lb);

        // default to plain ItemRenderingArea
        if (wlf.isNamedAreaDefined(area_name))
            return wlf.getNamedArea(area_name).getArea().getPixelRect(*lb);
        else
            return wlf.getNamedArea(alternate_name).getArea().getPixelRect(*lb);
    }
Пример #25
0
 Rect FalagardMenubar::getItemRenderArea(void) const
 {
     const WidgetLookFeel& wlf = getLookNFeel();
     return wlf.getNamedArea("ItemRenderArea").getArea().getPixelRect(*d_window);
 }
Пример #26
0
    void FalagardListHeaderSegment::render()
    {
        ListHeaderSegment* w = (ListHeaderSegment*)d_window;
        // get WidgetLookFeel for the assigned look.
        const WidgetLookFeel& wlf = getLookNFeel();

        const StateImagery* imagery;

        // get imagery for main state.
        if (w->isDisabled())
        {
            imagery = &wlf.getStateImagery("Disabled");
        }
        else if ((w->isSegmentHovering() != w->isSegmentPushed()) && !w->isSplitterHovering() && w->isClickable())
        {
            imagery = &wlf.getStateImagery("Hover");
        }
        else if (w->isSplitterHovering())
        {
            imagery = &wlf.getStateImagery("SplitterHover");
        }
        else
        {
            imagery = &wlf.getStateImagery("Normal");
        }

        // do main rendering
        imagery->render(*w);

        // Render sorting icon as needed
        ListHeaderSegment::SortDirection sort_dir = w->getSortDirection();
        if (sort_dir == ListHeaderSegment::Ascending)
        {
            imagery = &wlf.getStateImagery("AscendingSortIcon");
            imagery->render(*w);
        }
        else if (sort_dir == ListHeaderSegment::Descending)
        {
            imagery = &wlf.getStateImagery("DescendingSortIcon");
            imagery->render(*w);
        }

        // draw ghost copy if the segment is being dragged.
        if (w->isBeingDragMoved())
        {
            Size pixel_size = w->getPixelSize();
            Rect targetArea(0, 0, pixel_size.d_width, pixel_size.d_height);
            targetArea.offset(w->getDragMoveOffset());
            imagery = &wlf.getStateImagery("DragGhost");
            imagery->render(*w, targetArea);

            // Render sorting icon as needed
            if (sort_dir == ListHeaderSegment::Ascending)
            {
                imagery = &wlf.getStateImagery("GhostAscendingSortIcon");
                imagery->render(*w, targetArea);
            }
            else if (sort_dir == ListHeaderSegment::Descending)
            {
                imagery = &wlf.getStateImagery("GhostDescendingSortIcon");
                imagery->render(*w, targetArea);
            }
        }
    }
Пример #27
0
Size FalagardItemEntry::getItemPixelSize() const
{
    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();
    return wlf.getNamedArea("ContentSize").getArea().getPixelRect(*d_window).getSize();
}
Пример #28
0
//----------------------------------------------------------------------------//
void FalagardEditbox::render()
{
    Editbox* w = static_cast<Editbox*>(d_window);
    const StateImagery* imagery;

    // draw container etc
    // get WidgetLookFeel for the assigned look.
    const WidgetLookFeel& wlf = getLookNFeel();
    // try and get imagery for the approprite state.
    imagery = &wlf.getStateImagery(
        w->isDisabled() ? "Disabled" : (w->isReadOnly() ? "ReadOnly" : "Enabled"));

    // peform the rendering operation for the container.
    imagery->render(*w);

    // get destination area for text
    const Rect textArea(wlf.getNamedArea("TextArea").getArea().getPixelRect(*w));

    //
    // Required preliminary work for text rendering operations
    //
    Font* font = w->getFont();

    // no font == no more rendering
    if (!font)
        return;

    // This will point to the final string to be used for rendering.  Useful
    // because it means we do not have to have duplicate code or be copying
    // getText() for handling masked/unmasked text.
    String* editText;

    // Create a 'masked' version of the string if needed.
    String maskedText, windowText;
    if (w->isTextMasked())
    {
        maskedText.insert(0, w->getText().length(), w->getMaskCodePoint());
        editText = &maskedText;
    }
    // text not masked to editText will be the windows getText() String.
    else
    {
        windowText = w->getTextVisual();
        editText = &windowText;
    }

    // calculate best position to render text to ensure carat is always visible
    float textOffset;
    size_t cartIndex = w->getCaratIndex();

#ifdef CEGUI_BIDI_SUPPORT
    // the char before the cart bidi type
    bool currCharIsRtl = false;
    if ((editText->size() > 0) && (cartIndex > 0))
    {
        size_t curCartIndex = w->getCaratIndex();
        BidiCharType charBeforeCartType = w->getBiDiVisualMapping()->
            getBidiCharType((*editText)[curCartIndex - 1]);
        // for neutral chars you decide by the char after
        for (; BCT_NEUTRAL == charBeforeCartType &&
               (editText->size() > curCartIndex); curCartIndex++)
        {
            charBeforeCartType = w->getBiDiVisualMapping()->
                getBidiCharType((*editText)[curCartIndex - 1]);
        }

        currCharIsRtl  = (BCT_RIGHT_TO_LEFT == charBeforeCartType);
    }

    bool isFirstChar = cartIndex == 0;

    // the pos is by the char before
    if (!isFirstChar)
        cartIndex--;

    // we need to find the cart pos by the logical to visual map
    if (w->getBiDiVisualMapping()->getV2lMapping().size() > cartIndex)
        cartIndex = w->getBiDiVisualMapping()->getL2vMapping()[cartIndex];

    // for non RTL char - the cart pos is after the char
    if (!currCharIsRtl)
        cartIndex++;

    // if first char is not rtl - we need to stand at the start of the line
    if (isFirstChar)
    {
        bool firstCharRtl =
            (editText->size() > 0) &&
            (BCT_RIGHT_TO_LEFT == w->getBiDiVisualMapping()->
                getBidiCharType((*editText)[0]));

        if (!firstCharRtl)
            cartIndex--;
    }
#endif

    float extentToCarat = font->getTextExtent(editText->substr(0, cartIndex));

    // get carat imagery
    const ImagerySection& caratImagery = wlf.getImagerySection("Carat");
    // store carat width
    float caratWidth = caratImagery.getBoundingRect(*w, textArea).getWidth();

    // if box is inactive
    if (!w->hasInputFocus())
        textOffset = d_lastTextOffset;
    // if carat is to the left of the box
    else if ((d_lastTextOffset + extentToCarat) < 0)
        textOffset = -extentToCarat;
    // if carat is off to the right.
    else if ((d_lastTextOffset + extentToCarat) >= (textArea.getWidth() - caratWidth))
        textOffset = textArea.getWidth() - extentToCarat - caratWidth;
    // else carat is already within the box
    else
        textOffset = d_lastTextOffset;

    ColourRect colours;
    float alpha_comp = w->getEffectiveAlpha();

    //
    // Draw label text
    //
    // setup initial rect for text formatting
    Rect text_part_rect(textArea);
    // allow for scroll position
    text_part_rect.d_left += textOffset;
    // centre text vertically within the defined text area
    text_part_rect.d_top += (textArea.getHeight() - font->getFontHeight()) * 0.5f;

    // get unhighlighted text colour (saves accessing property twice)
    colour unselectedColour(getUnselectedTextColour());

    // see if the editbox is active or inactive.
    bool active = (!w->isReadOnly()) && w->hasInputFocus();

#ifdef CEGUI_BIDI_SUPPORT
    if (w->getSelectionLength() == 0)
    {
        // no highlighted text - we can draw the whole thing
        colours.setColours(unselectedColour);
        colours.modulateAlpha(alpha_comp);
        font->drawText(w->getGeometryBuffer(), *editText,
                       text_part_rect.getPosition(), &textArea, colours);

        // adjust rect for next section
        text_part_rect.d_left += font->getTextExtent(*editText);

    }
    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 (size_t i = 0 ; i < editText->size() ; i++)
        {
            // get the char
            String currChar = editText->substr(i, 1);
            size_t realPos = 0;

            // get he visual pos of the char
            if (w->getBiDiVisualMapping()->getV2lMapping().size() > i)
            {
                realPos = w->getBiDiVisualMapping()->getV2lMapping()[i];
            }

            // check if it is in the highlighted region
            bool highlighted =
                realPos >= w->getSelectionStartIndex() &&
                realPos < w->getSelectionStartIndex() + w->getSelectionLength();

            float charAdvance = font->getGlyphData(currChar[0])->getAdvance(1.0f);

            if (highlighted)
            {
                colours.setColours(getSelectedTextColour());
                colours.modulateAlpha(alpha_comp);

                {

                    // calculate area for selection imagery.
                    Rect hlarea(textArea);
                    hlarea.d_left = text_part_rect.d_left ;
                    hlarea.d_right = text_part_rect.d_left + charAdvance ;

                    // render the selection imagery.
                    wlf.getStateImagery(active ? "ActiveSelection" :
                                                 "InactiveSelection").
                        render(*w, hlarea, 0, &textArea);
                }

            }
            else
            {
                colours.setColours(unselectedColour);
                colours.modulateAlpha(alpha_comp);
            }
            font->drawText(w->getGeometryBuffer(), currChar,
                           text_part_rect.getPosition(), &textArea, colours);

            // adjust rect for next section
            text_part_rect.d_left += charAdvance;

        }
    }
#else
    //
    // Render selection imagery.
    //
    if (w->getSelectionLength() != 0)
    {
        // calculate required start and end offsets of selection imagery.
        float selStartOffset =
            font->getTextExtent(editText->substr(0, w->getSelectionStartIndex()));
        float selEndOffset =
            font->getTextExtent(editText->substr(0, w->getSelectionEndIndex()));

        // calculate area for selection imagery.
        Rect hlarea(textArea);
        hlarea.d_left += textOffset + selStartOffset;
        hlarea.d_right = hlarea.d_left + (selEndOffset - selStartOffset);

        // render the selection imagery.
        wlf.getStateImagery(active ? "ActiveSelection" :
                                     "InactiveSelection").
            render(*w, hlarea, 0, &textArea);
    }

    // draw pre-highlight text
    String sect = editText->substr(0, w->getSelectionStartIndex());
    colours.setColours(unselectedColour);
    colours.modulateAlpha(alpha_comp);
    font->drawText(w->getGeometryBuffer(), sect, text_part_rect.getPosition(),
                   &textArea, colours);

    // adjust rect for next section
    text_part_rect.d_left += font->getTextExtent(sect);

    // draw highlight text
    sect = editText->substr(w->getSelectionStartIndex(), w->getSelectionLength());
    colours.setColours(getSelectedTextColour());
    colours.modulateAlpha(alpha_comp);
    font->drawText(w->getGeometryBuffer(), sect, text_part_rect.getPosition(),
                   &textArea, colours);

    // adjust rect for next section
    text_part_rect.d_left += font->getTextExtent(sect);

    // draw post-highlight text
    sect = editText->substr(w->getSelectionEndIndex());
    colours.setColours(unselectedColour);
    colours.modulateAlpha(alpha_comp);
    font->drawText(w->getGeometryBuffer(), sect, text_part_rect.getPosition(),
                   &textArea, colours);

    // remember this for next time.
    d_lastTextOffset = textOffset;
#endif

    //
    // Render carat
    //
    if (active && (!d_blinkCaret || d_showCaret))
    {
        Rect caratRect(textArea);
        caratRect.d_left += extentToCarat + textOffset;

        caratImagery.render(*w, caratRect, 0, &textArea);
    }
}