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

XInterface.GUIMultiColumnList


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
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
class GUIMultiColumnList extends GUIVertList
    native;

// (cpptext)
// (cpptext)
// (cpptext)
// (cpptext)

struct native init MultiColumnSortData
{
    var() editconst const string SortString;    // Set by GetSortString()
    var() editconst const int    SortItem;      // Should be the index into your array for the corresponding SortString

cppstruct
{
    FMultiColumnSortData( INT InSortItem = INDEX_NONE, const TCHAR* InString = TEXT("") );
}
};

// There should always be the same number of ColumnHeadings as InitColumnPerc
var() localized array<string> ColumnHeadings;
var()           array<float>  InitColumnPerc;
var() localized array<string> ColumnHeadingHints;


// Set natively, for speed
var const array<MultiColumnSortData> SortData;      // Filled with results of GetSortString()
var const array<int>                 InvSortData;   // Used for keeping same item selected after sorting
var() const editconst array<float>             ColumnWidths;


// sorting stuff
var()          float CellSpacing;
var()          int   SortColumn;            // Column that is currently used for sorting ( -1 for no sorting )
var()          bool  NeedsSorting;          // Will automatically sort when this is true
var()          bool  SortDescending;        // Used by native sorting to determine which direction to sort
var()          bool  ExpandLastColumn;      // If true & columns widths do not add up to 100%, last column will be stretched


// notification
delegate OnColumnSized(int column);
native final function int GetListIndex( int YourArrayIndex );
native final function ChangeSortOrder();
native final function SortList();
native final function UpdatedItem( int YourArrayIndex );            // should be called when we update an item's data
native final function RemovedItem( int YourArrayIndex );

// must be called when we add an item to the list.
// If your data is contained in a single array, but is represented as multiple multicolumn lists,
// pass in your array index (see UT2K4Tab_PlayerLoginControls for an example of this)
native final function AddedItem(optional int YourArrayIndex);
delegate string GetSortString( int YourArrayIndex );

function int CurrentListId()
{
    if (Index < 0)
        return -1;

    return SortData[Index].SortItem;
}

event OnSortChanged()
{
    if (SortData.Length <= 0)
        return;

    ChangeSortOrder();

    // resort list
    SortList();

    // remap the selection item back again to keep the same item selected
    if ( IsValid() )
        Index = InvSortData[Index];
}

function Clear()
{
    SortData.Remove(0,SortData.Length);
    InvSortData.Remove(0,InvSortData.Length);
    Super.Clear();
}

function RemovedCurrent()
{
    if ( IsValid() )
    {
        RemovedItem(CurrentListId());
        SetIndex(Index);
    }
}

function ResolutionChanged( int ResX, int ResY )
{
    if ( !bInit )
        bInit = True;

    Super.ResolutionChanged(ResX,ResY);
}

event InitializeColumns(Canvas C)
{
    local int i;
    local float AW;

    if ( bDebugging )
        log(Name@"#### InitializeColumns ActualWidth() = "@ActualWidth()@"WinWidth:"$WinWidth);

    AW = ActualWidth();
    for(i=0; i<InitColumnPerc.Length; i++)
    {
        if ( bDebugging )
            log(Name@"#### InitColumnPerc["$i$"]:"$InitColumnPerc[i]);

        ColumnWidths[i] = AW * InitColumnPerc[i];
    }
    bInit = false;
}

function bool InternalOnPreDraw(Canvas C)
{
    local float x;
    local int i;

    if (bInit)
        return false;

    if( NeedsSorting )
    {
        SortList();
        if ( IsValid() )
            Index = InvSortData[Index];
    }

    if( ExpandLastColumn )
    {
        for( i=0;i<ColumnWidths.Length-1;i++ )
            x += ColumnWidths[i];
        ColumnWidths[i] = ActualWidth() - x;
    }

    return false;
}

function GetCellLeftWidth( int Column, out float Left, out float Width )
{
    local int i;

    Left = ClientBounds[0];

    for( i=0;i<Column && i<ColumnWidths.Length;i++ )
        Left += ColumnWidths[i];
    if( i<ColumnWidths.Length )
        Width = ColumnWidths[i];
    else
        Width = 0;

    Left += CellSpacing;
    Width -= 2*CellSpacing;

    if ( Left >= Bounds[2] )
        Width = 0;

    if (Left + Width >= Bounds[2])
        Width = Bounds[2] - Left;

    if ( Width < 0 )
        Width = 0;
}

function Sort()
{
    SortList();
}

function Dump()
{
    local int i;

    log("Dumping multicolumn list contents  '"$Name$"'");

    for ( i = 0; i < SortData.Length; i++ )
    {
        if ( i < InvSortData.Length )
            log(" " $ i $ ")" @ "'" $ SortData[i].SortString $ "'" @ SortData[i].SortItem @ "InvSortData:"$InvSortData[i]);
        else log(" " $ i $ ")" @ "'" $ SortData[i].SortString $ "'" @ SortData[i].SortItem @ "InvSortData: Invalid");
    }
}

defaultproperties
{
     CellSpacing=1.000000
     OnPreDraw=GUIMultiColumnList.InternalOnPreDraw
}

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:48.031 - Created with UnCodeX