public void SetText(string str)
 {
     textWidget.SetText(str);
     float height = textWidget.GetTextHeight(false);
     float width = textWidget.GetTextWidth();
     Rect newArea = new Rect(0, width, 0, height);
     textWidget.SetAreaRect(newArea);
     textWidget.SetVScrollPosition(0);
     this.SetAreaRect(newArea);
 }
        public void AddNode(int oid, ObjectNode objNode)
        {
            // Create a namebar scene node and entity to handle names
            Axiom.MathLib.Vector3 offset = new Axiom.MathLib.Vector3(0, 2 * Client.OneMeter, 0);
            SceneNode sceneNode = objNode.SceneNode.CreateChildSceneNode("namebar." + oid, offset);
            TexturedBillboardSet widget = new TexturedBillboardSet("billboard." + oid);
            widget.MaterialName = "font-material";
            widget.BillboardType = BillboardType.Point;
            widget.CommonDirection = Axiom.MathLib.Vector3.NegativeUnitZ;
            sceneNode.AttachObject(widget);

            // Set the target mesh for methods like Font.DrawText
            meshRenderer.BeginRender(widget);
            Rect dummyRect = new Rect();
            dummyRect.left = 0;
            dummyRect.top = 0;
            dummyRect.Height = 150;
            dummyRect.Width = 600;
            font.DrawText("This is a test", dummyRect, 0);
            meshRenderer.EndRender();
        }
 public void SetFont(Font font)
 {
     textWidget.Font = font;
     textWidget.UpdateText();
     float height = textWidget.GetTextHeight(false);
     float width = textWidget.GetTextWidth();
     Rect newArea = new Rect(0, width, 0, height);
     textWidget.SetAreaRect(newArea);
     textWidget.SetVScrollPosition(0);
     this.SetAreaRect(newArea);
 }
 public void SetText(string str)
 {
     // Maximum dimensions
     Rect newArea = new Rect(0, 200, 0, 200);
     // Initial size to see how we wrap
     textWidget.SetAreaRect(newArea);
     textWidget.SetText(str);
     float textHeight = textWidget.GetTextHeight(false);
     float textWidth = textWidget.GetTextWidth();
     // smallest size that will still fit all the text
     textWidget.SetAreaRect(new Rect(left.Width, left.Width + textWidth, top.Height, top.Height + textHeight));
     newArea.Height = textHeight + top.Height + Math.Max(bottom.Height, bottomCenter.Height);
     newArea.Width = textWidth + left.Width + right.Width;
     // textWidget.SetVScrollPosition(0);
     this.SetAreaRect(newArea);
 }
 public void SetFont(Font font)
 {
     textWidget.Font = font;
     // Maximum dimensions
     Rect newArea = new Rect(0, 200, 0, 200);
     textWidget.SetAreaRect(newArea);
     textWidget.UpdateText();
     // textWidget.SetVScrollPosition(0);
     float textHeight = textWidget.GetTextHeight(false);
     float textWidth = textWidget.GetTextWidth();
     // smallest size that will still fit all the text
     textWidget.SetAreaRect(new Rect(left.Width, left.Width + textWidth, top.Height, top.Height + textHeight));
     newArea.Height = textHeight + top.Height + Math.Max(bottom.Height, bottomCenter.Height);
     newArea.Width = textWidth + left.Width + right.Width;
     this.SetAreaRect(newArea);
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="position"></param>
        /// <param name="clipRect"></param>
        protected override void DrawSelf(Vector3 position, Rect clipRect)
        {
            Vector3 finalPos = position;
            float origWidth = area.Width;
            float origHeight = area.Height;
            Size finalSize = new Size();
            // Pass our alpha settings to the textures we draw
            colors.SetAlpha(this.EffectiveAlpha);

            // calculate 'adjustments' required to accommodate corner pieces.
            float coordAdj = 0, sizeAdj = 0;

            // draw top-edge, if required
            if (top != null) {
                // calculate adjustments required if top-left corner will be rendered.
                if (topLeft != null) {
                    sizeAdj	= topLeft.Width;
                    coordAdj = topLeft.Width;
                }
                else {
                    coordAdj = 0;
                    sizeAdj	= 0;
                }

                // calculate adjustments required if top-right corner will be rendered.
                if (topRight != null) {
                    sizeAdj += topRight.Width;
                }

                finalSize.width		= origWidth - sizeAdj;
                finalSize.height    = top.Height;
                finalPos.x          = position.x + coordAdj;

                top.Draw(finalPos, finalSize, clipRect, colors);
            }

            // draw bottom-edge, if required
            if (bottom != null) {
                // calculate adjustments required if bottom-left corner will be rendered.
                if (bottomLeft != null) {
                    sizeAdj = bottomLeft.Width;
                    coordAdj = bottomLeft.Width;
                }
                else {
                    coordAdj = 0;
                    sizeAdj	= 0;
                }

                // calculate adjustments required if bottom-right corner will be rendered.
                if (bottomRight != null) {
                    sizeAdj += bottomRight.Width;
                }

                if (bottomCenter != null) {
                    float leftPortion = (float)Math.Floor((origWidth - sizeAdj) / 2);
                    float rightPortion = origWidth - sizeAdj - bottomCenter.Width - leftPortion;

                    // Draw the left portion of the bottom edge
                    finalSize.width = leftPortion;
                    finalSize.height = bottom.Height;
                    finalPos.x = position.x + coordAdj;
                    finalPos.y = position.y + origHeight - finalSize.height;

                    bottom.Draw(finalPos, finalSize, clipRect, colors);

                    finalSize.width = bottomCenter.Width;
                    finalSize.height = bottomCenter.Height;
                    finalPos.x = position.x + coordAdj + leftPortion;
                    finalPos.y = position.y + origHeight - finalSize.height;

                    bottomCenter.Draw(finalPos, finalSize, clipRect, colors);

                    finalSize.width = rightPortion;
                    finalSize.height = bottom.Height;
                    finalPos.x = position.x + coordAdj + leftPortion + bottomCenter.Width;
                    finalPos.y = position.y + origHeight - finalSize.height;

                    bottom.Draw(finalPos, finalSize, clipRect, colors);
                } else {
                    finalSize.width = origWidth - sizeAdj;
                    finalSize.height = bottom.Height;
                    finalPos.x = position.x + coordAdj;
                    finalPos.y = position.y + origHeight - finalSize.height;

                    bottom.Draw(finalPos, finalSize, clipRect, colors);
                }
            }

            // reset x co-ordinate to input value
            finalPos.x = position.x;

            // draw left-edge, if required
            if (left != null) {
                // calculate adjustments required if top-left corner will be rendered.
                if (topLeft != null) {
                    sizeAdj = topLeft.Height;
                    coordAdj = topLeft.Height;
                }
                else {
                    coordAdj = 0;
                    sizeAdj	= 0;
                }

                // calculate adjustments required if bottom-left corner will be rendered.
                if (bottomLeft != null) {
                    sizeAdj += bottomLeft.Height;
                }

                finalSize.height	= origHeight - sizeAdj;
                finalSize.width		= left.Width;
                finalPos.y			= position.y + coordAdj;

                left.Draw(finalPos, finalSize, clipRect, colors);
            }

            // draw right-edge, if required
            if (right != null) {
                // calculate adjustments required if top-left corner will be rendered.
                if (topRight != null) {
                    sizeAdj = topRight.Height;
                    coordAdj = topRight.Height;
                }
                else {
                    coordAdj = 0;
                    sizeAdj	= 0;
                }

                // calculate adjustments required if bottom-right corner will be rendered.
                if (bottomRight != null) {
                    sizeAdj += bottomRight.Height;
                }

                finalSize.height	= origHeight - sizeAdj;
                finalSize.width		= left.Width;
                finalPos.y			= position.y + coordAdj;
                finalPos.x			= position.x + origWidth - finalSize.width;

                right.Draw(finalPos, finalSize, clipRect, colors);
            }

            // draw required corner pieces...
            if (topLeft != null) {
                topLeft.Draw(position, clipRect, colors);
            }

            if (topRight != null) {
                finalPos.x = position.x + origWidth - topRight.Width;
                finalPos.y = position.y;
                topRight.Draw(finalPos, clipRect, colors);
            }

            if (bottomLeft != null) {
                finalPos.x = position.x;
                finalPos.y = position.y + origHeight - bottomLeft.Height;
                bottomLeft.Draw(finalPos, clipRect, colors);
            }

            if (bottomRight != null) {
                finalPos.x = position.x + origWidth - bottomRight.Width;
                finalPos.y = position.y + origHeight - bottomRight.Height;
                bottomRight.Draw(finalPos, clipRect, colors);
            }

            if (background != null) {
                float sizeAdjX = 0;
                float coordAdjX = 0;
                float sizeAdjY = 0;
                float coordAdjY = 0;
                if (top != null) {
                    sizeAdjY += top.Height;
                    coordAdjY += top.Height;
                }
                if (bottom != null) {
                    sizeAdjY += bottom.Height;
                }
                if (left != null) {
                    sizeAdjX += left.Width;
                    coordAdjX += left.Width;
                }
                if (right != null) {
                    sizeAdjX += right.Width;
                }
                finalSize.height = origHeight - sizeAdjY;
                finalSize.width = origWidth - sizeAdjX;
                finalPos.y = position.y + coordAdjY;
                finalPos.x = position.x + coordAdjX;

                background.Draw(finalPos, finalSize, clipRect, colors);
            }
        }
        /// <summary>
        ///		Perform the actual rendering for this Window.
        /// </summary>
        /// <param name="z">float value specifying the base Z co-ordinate that should be used when rendering.</param>
        protected override void DrawSelf(float z)
        {
            // Don't do anything if we don't have any text
            if (this.Text == string.Empty)
                return;
            // render what base class needs to render first
            base.DrawSelf(z);

            // render text
            Font textFont = this.Font;

            Size max = this.MaximumSize;
            Rect maxRect = new Rect(0, max.width, 0, max.height);

            string message = this.Text;
            // get total pixel height of the text based on its format
            float textHeight =
                textFont.GetFormattedLineCount(message, maxRect, horzFormatting) * textFont.LineSpacing;
            float textWidth =
                textFont.GetFormattedTextExtent(message, maxRect, horzFormatting);
            float height = Math.Min(textHeight, max.height);
            float width = textWidth;

            Rect absRect = this.UnclippedPixelRect;
            int newTop = (int)(absRect.Bottom - height);
            int newLeft = (int)(absRect.Left + (absRect.Width - width) / 2);
            int newBottom = newTop + (int)height;
            int newRight = newLeft + (int)width;
            Rect newAbsRect = new Rect(newLeft, newRight, newTop, newBottom);
            SetAreaRect(newAbsRect);

            Rect clipper = newAbsRect.GetIntersection(this.PixelRect);

            textColors.SetAlpha(EffectiveAlpha);

            // The z value for this will be slightly less, so that the text
            // is in front of the background
            textFont.DrawText(
                message,
                this.UnclippedInnerRect,
                this.ZValue - Renderer.GuiZLayerStep,
                clipper,
                horzFormatting,
                textColors);
        }