Unit SortGrid

***************************************************************************** Class: TSortGrid Copyright © 1996 Author: Bill Menees bmenees@usit.net www.public.usit.net/bmenees Modified by Eric W. Engler, Feb 1997 - fixed a bug in autodetection of type - OnBeginSort event was called before the autodetect of type; moved to after. - expanded date sort to incl datetime (these are usu compatible in Delphi) - added a time sort IMPORTANT! Do NOT use Delphi's "Break on Exception" option if you run a program that uses this component from the Delphi GUI. This VCL uses exceptions during normal processing.

Classes

TSortedList -
TSortGrid - Here's the main new class: TSortGrid

Functions

DateTimeCompare -
NumericCompare -
Register - I put TSortGrid on the 'Additional' page because I like having it with the other grids.
StringCompare -
TimeCompare -

Types

PSortedListEntry
TBeginSortEvent
TCellBevel
TCellBevelStyle
TCellValidateEvent
TClickSortEvent
TEndSortEvent
TFormatDrawCellEvent
TFormatOptions
TSizeChangedEvent
TSortCompare
TSortDirection
TSortedListEntry
TSortOptions
TSortStyle
TUpdateGridEvent
TVertAlignment

Constants

Variables


Functions


function DateTimeCompare(const Str1, Str2: String): Integer;


function NumericCompare(const Str1, Str2: String): Integer;


procedure Register;

I put TSortGrid on the 'Additional' page because I like having it with the other grids.

function StringCompare(const Str1, Str2: String): Integer;


function TimeCompare(const Str1, Str2: String): Integer;


Types


PSortedListEntry = ^TSortedListEntry

TBeginSortEvent = procedure(Sender: TObject; Col: Longint; var SortOptions: TSortOptions) of object

TCellBevel = record
Style : TCellBevelStyle;
UpperLeftColor : TColor;
LowerRightColor : TColor;
end;
********************************************************} {*** NOTE: This is one of the structures in TFormatOptions.
TCellBevelStyle = (cbNone, cbRaised, cbLowered);

TCellValidateEvent = procedure(Sender: TObject; Col, Row: Longint;
                     var Value: String; var Valid: Boolean) of object

TClickSortEvent = procedure(Sender: TObject; Col, Row: Longint;
                          var SortOptions: TSortOptions) of object

TEndSortEvent = procedure(Sender: TObject; Col: Longint) of object

TFormatDrawCellEvent = procedure(Sender: TObject; Col, Row: Longint;
                          State: TGridDrawState;
                          var FormatOptions: TFormatOptions) of object
These are the new events defined for TSortGrid.
TFormatOptions = record
Brush : TBrush;
Font : TFont;
AlignmentHorz : TAlignment;
AlignmentVert : TVertAlignment;
Bevel : TCellBevel;
HideText : Boolean;
end;
************************************************} {*** NOTE: These are the display options you can set for each cell in OnGetCellFormat.
TSizeChangedEvent = procedure(Sender: TObject; OldColCount, OldRowCount: Longint) of object

TSortCompare = function (const Str1, Str2: String): Integer
TSortCompare must return < 0 if Str1 is less than Str2, 0 if they are equal, and > 0 if Str1 is greater than Str2.
TSortDirection = (sdAscending, sdDescending);

TSortedListEntry = record
Str : String;
RowNum : Longint;
end;
Used only if SortStyle = ssCustom.
TSortOptions = record
SortStyle : TSortStyle;
SortDirection : TSortDirection;
SortCaseSensitive : Boolean;
SortCompare : TSortCompare;
end;
************************************************************} {*** NOTE: These are the options you can set to affect sorting.
TSortStyle = (ssAutomatic, ssAlphabetic, ssNumeric, ssDateTime, ssTime,ssCustom);

TUpdateGridEvent = procedure(Sender: TObject; Index: Longint) of object

TVertAlignment = (taTopJustify, taBottomJustify, taMiddle);

Constants


Variables