Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

XInterface.DrawOpText


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
class DrawOpText extends DrawOpBase;

var localized string Text;
var string FontName;            // Font to use
var int             MaxLines;           // In case a multiline is too tall.
/** set to true to wrap text on "|" */
var bool            bWrapText;

var byte VertAlign;

function Draw(Canvas Canvas)
{
    local Font Fnt;
    local int i;
    local float X, Y, XL, YL, TextHeight, StrHeight, StrWidth;
    local array<string> Lines;

    Super.Draw(Canvas);
    if (FontName != "")
    {
        Fnt = GetFont(FontName, Canvas.SizeX);
        if (Fnt != None)
            Canvas.Font = Fnt;
    }

    Canvas.FontScaleX = 0.9;
    Canvas.FontScaleY = 0.9;

    X = Lft * Canvas.SizeX;
    Y = Top * Canvas.SizeY;
    XL = Width * Canvas.SizeX;
    YL = Height * Canvas.SizeY;

    Canvas.StrLen(Text, StrWidth, StrHeight);
    if (bWrapText) Canvas.WrapStringToArray(Text, Lines, XL, "|");
        else Lines[0] = Text;
    TextHeight = StrHeight * Lines.length;

    switch ( VertAlign )
    {
        case 1: // Center
            Y = Y + (YL - TextHeight) / 2;
            break;

        case 2: // Bottom
            Y = Y + YL - TextHeight;
            break;
    }

    for ( i = 0; i < Lines.Length; i++ )
    {
        Canvas.StrLen(Lines[i], StrWidth, StrHeight);
        switch ( Justification )
        {
            case 0: // left
                Canvas.SetPos(X, Y);
                break;

            case 1: // center
                Canvas.SetPos(X + (XL - StrWidth) / 2, Y);
                break;

            case 2: // right
                Canvas.SetPos(X + XL - StrWidth, Y);
                break;
        }

        Canvas.DrawText(Lines[i]);
        Y += StrHeight;
    }
}

defaultproperties
{
     FontName="XInterface.UT2DefaultFont"
     MaxLines=99
     bWrapText=Wahr
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Fr 30.3.2007 08:43:46.000 - Creation time: Mo 16.4.2007 11:20:46.453 - Created with UnCodeX