|
@@ -84,11 +84,13 @@ type
|
|
property SortDirection: TSortDirection read FSortDirection write SetSortDirection;
|
|
property SortDirection: TSortDirection read FSortDirection write SetSortDirection;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ TVisualColumnRenderer = procedure(Sender: TObject; ACol, ARow: Longint; Canvas: TCanvas; Rect: TRect; State: TGridDrawState; const CellData: Variant; var Handled: boolean) of object;
|
|
|
|
+
|
|
{ TVisualGrid Events }
|
|
{ TVisualGrid Events }
|
|
|
|
|
|
TPreparePopupMenuEvent = procedure(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu) of object;
|
|
TPreparePopupMenuEvent = procedure(Sender: TObject; constref ASelection: TVisualGridSelection; out APopupMenu: TPopupMenu) of object;
|
|
TSelectionEvent = procedure(Sender: TObject; constref ASelection: TVisualGridSelection) of object;
|
|
TSelectionEvent = procedure(Sender: TObject; constref ASelection: TVisualGridSelection) of object;
|
|
- TDrawVisualCellEvent = procedure(Sender: TObject; ACol, ARow: Longint; Canvas: TCanvas; Rect: TRect; State: TGridDrawState; const RowData: Variant; var Handled: boolean) of object;
|
|
|
|
|
|
+ TDrawVisualCellEvent = procedure(Sender: TObject; ACol, ARow: Longint; Canvas: TCanvas; Rect: TRect; State: TGridDrawState; const CellData: Variant; var Handled: boolean) of object;
|
|
TColumnInitializeEvent = procedure(Sender: TObject; AColIndex:Integer; AColumn : TVisualColumn) of object;
|
|
TColumnInitializeEvent = procedure(Sender: TObject; AColIndex:Integer; AColumn : TVisualColumn) of object;
|
|
|
|
|
|
{ TVisualGrid Exceptions }
|
|
{ TVisualGrid Exceptions }
|
|
@@ -251,8 +253,6 @@ type
|
|
FCurrentSelectionType: TSelectionType;
|
|
FCurrentSelectionType: TSelectionType;
|
|
FLastSelection: TVisualGridSelection;
|
|
FLastSelection: TVisualGridSelection;
|
|
FIgnoreSelectionEvent: boolean;
|
|
FIgnoreSelectionEvent: boolean;
|
|
- FDefaultStretchedColumn : Integer;
|
|
|
|
- FDefaultColumnWidths : TArray<Integer>;
|
|
|
|
FCellPadding : TRect;
|
|
FCellPadding : TRect;
|
|
FWidgetControl: TControl;
|
|
FWidgetControl: TControl;
|
|
FWidgetControlParent: TWinControl;
|
|
FWidgetControlParent: TWinControl;
|
|
@@ -304,6 +304,9 @@ type
|
|
FTotalDataCount: Integer;
|
|
FTotalDataCount: Integer;
|
|
FLastFetchDataResult: TLastFetchDataResult;
|
|
FLastFetchDataResult: TLastFetchDataResult;
|
|
FSortColumn: TVisualColumn;
|
|
FSortColumn: TVisualColumn;
|
|
|
|
+ FDefaultStretchedColumn : Integer;
|
|
|
|
+ FDefaultColumnWidths : TArray<Integer>;
|
|
|
|
+ FColumnRenderers : TArray<TVisualColumnRenderer>;
|
|
|
|
|
|
FOnDrawVisualCell: TDrawVisualCellEvent;
|
|
FOnDrawVisualCell: TDrawVisualCellEvent;
|
|
FOnColumnInitialize : TColumnInitializeEvent;
|
|
FOnColumnInitialize : TColumnInitializeEvent;
|
|
@@ -342,6 +345,7 @@ type
|
|
property FetchDataInThread: boolean read FFetchDataInThread write SetFetchDataInThread;
|
|
property FetchDataInThread: boolean read FFetchDataInThread write SetFetchDataInThread;
|
|
property DefaultStretchedColumn: Integer read FDefaultStretchedColumn write FDefaultStretchedColumn;
|
|
property DefaultStretchedColumn: Integer read FDefaultStretchedColumn write FDefaultStretchedColumn;
|
|
property DefaultColumnWidths : TArray<Integer> read FDefaultColumnWidths write FDefaultColumnWidths;
|
|
property DefaultColumnWidths : TArray<Integer> read FDefaultColumnWidths write FDefaultColumnWidths;
|
|
|
|
+ property ColumnRenderers : TArray<TVisualColumnRenderer> read FColumnRenderers write FColumnRenderers;
|
|
|
|
|
|
property CanPage: boolean read FCanPage write SetCanPage default true;
|
|
property CanPage: boolean read FCanPage write SetCanPage default true;
|
|
property CanSearch: boolean read FCanSearch write SetCanSearch default true;
|
|
property CanSearch: boolean read FCanSearch write SetCanSearch default true;
|
|
@@ -398,6 +402,13 @@ type
|
|
property OnPreparePopupMenu;
|
|
property OnPreparePopupMenu;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ { TVisualCellRenderers }
|
|
|
|
+
|
|
|
|
+ TVisualCellRenderers = class
|
|
|
|
+ public
|
|
|
|
+ class procedure DollarValue (Sender: TObject; ACol, ARow: Longint; Canvas: TCanvas; Rect: TRect; State: TGridDrawState; const CellData: Variant; var Handled: boolean);
|
|
|
|
+ end;
|
|
|
|
+
|
|
{ TVisualGridSearchExpressionService }
|
|
{ TVisualGridSearchExpressionService }
|
|
|
|
|
|
TVisualGridSearchExpressionService = class
|
|
TVisualGridSearchExpressionService = class
|
|
@@ -582,6 +593,26 @@ begin
|
|
Result := Selections[0].Height + 1;
|
|
Result := Selections[0].Height + 1;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+{ TVisualCellRenderers }
|
|
|
|
+
|
|
|
|
+class procedure TVisualCellRenderers.DollarValue (Sender: TObject; ACol, ARow: Longint; Canvas: TCanvas; Rect: TRect; State: TGridDrawState; const CellData: Variant; var Handled: boolean);
|
|
|
|
+var
|
|
|
|
+ LReal : Real;
|
|
|
|
+ LTextStyle: TTextStyle;
|
|
|
|
+begin
|
|
|
|
+ if NOT VarIsNumeric(CellData) then
|
|
|
|
+ exit;
|
|
|
|
+
|
|
|
|
+ LReal := CellData;
|
|
|
|
+ Canvas.Font.Color:= IIF (LReal < 0, clRed, clGreen);
|
|
|
|
+ Canvas.Font.Style:=[fsBold];
|
|
|
|
+ LTextStyle := Canvas.TextStyle;
|
|
|
|
+ LTextStyle.Alignment:=taRightJustify;
|
|
|
|
+ Canvas.TextStyle:=LTextStyle;
|
|
|
|
+ Canvas.TextRect(Rect, Rect.Left+2, Rect.Top+2, Format('$%.2F', [LReal]), LTextStyle);
|
|
|
|
+ Handled := true;
|
|
|
|
+end;
|
|
|
|
+
|
|
{ TFetchDataThread }
|
|
{ TFetchDataThread }
|
|
|
|
|
|
procedure TFetchDataThread.Execute;
|
|
procedure TFetchDataThread.Execute;
|
|
@@ -2237,6 +2268,7 @@ procedure TCustomVisualGrid.StandardDrawCell(Sender: TObject; ACol,
|
|
var
|
|
var
|
|
LHandled: boolean;
|
|
LHandled: boolean;
|
|
LCellData: Variant;
|
|
LCellData: Variant;
|
|
|
|
+ LColRenderer : TVisualColumnRenderer;
|
|
begin
|
|
begin
|
|
LHandled := False;
|
|
LHandled := False;
|
|
|
|
|
|
@@ -2250,8 +2282,18 @@ begin
|
|
|
|
|
|
Rect := CalculateCellContentRect(Rect);
|
|
Rect := CalculateCellContentRect(Rect);
|
|
|
|
|
|
|
|
+ // Try user-settable cell renderer
|
|
if Assigned(FOnDrawVisualCell) then
|
|
if Assigned(FOnDrawVisualCell) then
|
|
FOnDrawVisualCell(Self, ACol, ARow, Canvas, Rect, State, LCellData, LHandled);
|
|
FOnDrawVisualCell(Self, ACol, ARow, Canvas, Rect, State, LCellData, LHandled);
|
|
|
|
+
|
|
|
|
+ // Try user-settable column renderer
|
|
|
|
+ if (NOT LHandled) AND (ACol < Length(FColumnRenderers)) then begin
|
|
|
|
+ LColRenderer := FColumnRenderers[ACol];
|
|
|
|
+ if Assigned(LColRenderer) then
|
|
|
|
+ LColRenderer(Self, ACol, ARow, Canvas, Rect, State, LCellData, LHandled);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ // Use default renderer
|
|
if not LHandled then
|
|
if not LHandled then
|
|
DoDrawCell(Self, ACol, ARow, Rect, State, LCellData);
|
|
DoDrawCell(Self, ACol, ARow, Rect, State, LCellData);
|
|
end;
|
|
end;
|
|
@@ -2403,6 +2445,7 @@ begin
|
|
Result.Bottom := ClipValue(ARect.Bottom - FCellPadding.Bottom - PLATFORM_CELL_RECT_Y_OFFSET, 2, 100000);
|
|
Result.Bottom := ClipValue(ARect.Bottom - FCellPadding.Bottom - PLATFORM_CELL_RECT_Y_OFFSET, 2, 100000);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+
|
|
initialization
|
|
initialization
|
|
{$I *.inc}
|
|
{$I *.inc}
|
|
|
|
|