2010-03-05 21:57:25 +00:00
|
|
|
{ rxdbgrid unit
|
|
|
|
|
2021-05-20 06:28:45 +00:00
|
|
|
Copyright (C) 2005-2021 Lagunov Aleksey alexs75@yandex.ru and Lazarus team
|
2017-01-25 09:56:51 +00:00
|
|
|
original conception from rx library for Delphi (c)
|
2010-03-05 21:57:25 +00:00
|
|
|
|
|
|
|
This library is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU Library General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or (at your
|
|
|
|
option) any later version with the following modification:
|
|
|
|
|
|
|
|
As a special exception, the copyright holders of this library give you
|
|
|
|
permission to link this library with independent modules to produce an
|
|
|
|
executable, regardless of the license terms of these independent modules,and
|
|
|
|
to copy and distribute the resulting executable under terms of your choice,
|
|
|
|
provided that you also meet, for each linked independent module, the terms
|
|
|
|
and conditions of the license of that module. An independent module is a
|
|
|
|
module which is not derived from or based on this library. If you modify
|
|
|
|
this library, you may extend this exception to your version of the library,
|
|
|
|
but you are not obligated to do so. If you do not wish to do so, delete this
|
|
|
|
exception statement from your version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License
|
|
|
|
for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Library General Public License
|
|
|
|
along with this library; if not, write to the Free Software Foundation,
|
|
|
|
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
}
|
|
|
|
|
2013-07-11 16:28:38 +00:00
|
|
|
{$I rx.inc}
|
2010-03-05 21:57:25 +00:00
|
|
|
|
2020-03-24 13:25:48 +00:00
|
|
|
unit RxDBGrid;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
|
|
|
interface
|
|
|
|
|
|
|
|
uses
|
2014-09-11 09:31:28 +00:00
|
|
|
Classes, SysUtils, LResources, LCLType, LCLIntf, Forms, Controls, Buttons,
|
2017-08-22 12:28:33 +00:00
|
|
|
Graphics, Dialogs, Grids, rxdbutils, DBGrids, DB, PropertyStorage, rxlclutils,
|
2017-12-11 08:33:08 +00:00
|
|
|
LMessages, types, StdCtrls, Menus, rxspin, LCLVersion;
|
2009-07-06 16:26:45 +00:00
|
|
|
|
|
|
|
const
|
2011-05-07 14:48:11 +00:00
|
|
|
CBadQuickSearchSymbols = [VK_UNKNOWN..VK_HELP] + [VK_LWIN..VK_SLEEP] +
|
|
|
|
[VK_NUMLOCK..VK_SCROLL] + [VK_LSHIFT..VK_OEM_102] + [VK_PROCESSKEY] +
|
|
|
|
[VK_ATTN..VK_UNDEFINED];
|
|
|
|
CCancelQuickSearchKeys = [VK_ESCAPE, VK_CANCEL, VK_DELETE, VK_INSERT,
|
|
|
|
VK_DOWN, VK_UP, VK_NEXT, VK_PRIOR, VK_TAB, VK_RETURN, VK_HOME,
|
|
|
|
VK_END, VK_SPACE, VK_MULTIPLY];
|
2007-08-09 21:36:59 +00:00
|
|
|
|
|
|
|
type
|
2012-02-23 04:46:16 +00:00
|
|
|
//forward declarations
|
|
|
|
TRxDBGrid = class;
|
|
|
|
TRxColumn = class;
|
2014-07-23 11:40:36 +00:00
|
|
|
TRxDBGridAbstractTools = class;
|
2017-04-24 12:44:17 +00:00
|
|
|
TRxDbGridColumnsEnumerator = class;
|
2017-05-18 13:58:44 +00:00
|
|
|
TRxColumnFooterItemsEnumerator = class;
|
2012-02-23 04:46:16 +00:00
|
|
|
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
TRxQuickSearchNotifyEvent = procedure(Sender: TObject; Field: TField;
|
|
|
|
var AValue: string) of object;
|
2009-07-06 16:26:45 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
TSortMarker = (smNone, smDown, smUp);
|
2007-08-28 21:55:23 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
TGetBtnParamsEvent = procedure(Sender: TObject; Field: TField;
|
2007-08-09 21:36:59 +00:00
|
|
|
AFont: TFont; var Background: TColor; var SortMarker: TSortMarker;
|
2011-05-07 14:48:11 +00:00
|
|
|
IsDown: boolean) of object;
|
2007-08-28 21:55:23 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
TGetCellPropsEvent = procedure(Sender: TObject; Field: TField;
|
2007-08-09 21:36:59 +00:00
|
|
|
AFont: TFont; var Background: TColor) of object;
|
2007-08-28 21:55:23 +00:00
|
|
|
|
2016-08-26 19:26:05 +00:00
|
|
|
TRxDBGridDataHintShowEvent = procedure(Sender: TObject; CursorPos: TPoint;
|
|
|
|
Cell: TGridCoord; Column: TRxColumn; var HintStr: string;
|
|
|
|
var Processed: boolean) of object;
|
|
|
|
|
2017-05-18 11:16:05 +00:00
|
|
|
TRxDBGridCalcRowHeight = procedure(Sender: TRxDBGrid; var ARowHegth:integer) of object;
|
2017-06-13 08:58:24 +00:00
|
|
|
TRxDBGridMergeCellsEvent = procedure (Sender: TObject; ACol : Integer;
|
|
|
|
var ALeft, ARight : Integer; var ADisplayColumn: TRxColumn) of object;
|
2017-05-18 11:16:05 +00:00
|
|
|
|
2016-08-26 19:26:05 +00:00
|
|
|
//Freeman35 added
|
2014-07-28 12:25:45 +00:00
|
|
|
TOnRxCalcFooterValues = procedure(Sender: TObject; Column: TRxColumn; var AValue : Variant) of object;
|
2015-09-07 07:42:04 +00:00
|
|
|
TOnRxColumnFooterDraw = procedure(Sender: TObject; ABrush: TBrush; AFont : TFont;
|
|
|
|
const Rect: TRect; Column: TRxColumn; var AText :String) of object;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2015-07-27 12:32:43 +00:00
|
|
|
TRxColumnOption = (coCustomizeVisible, coCustomizeWidth, coFixDecimalSeparator, coDisableDialogFind);
|
2014-07-28 10:24:14 +00:00
|
|
|
TRxColumnOptions = set of TRxColumnOption;
|
|
|
|
|
2012-08-23 17:03:53 +00:00
|
|
|
TRxColumnEditButtonStyle = (ebsDropDownRx, ebsEllipsisRx, ebsGlyphRx, ebsUpDownRx,
|
|
|
|
ebsPlusRx, ebsMinusRx);
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
TFooterValueType = (fvtNon, fvtSum, fvtAvg, fvtCount, fvtFieldValue,
|
2011-05-07 14:48:11 +00:00
|
|
|
fvtStaticText, fvtMax, fvtMin, fvtRecNo);
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
TOptionRx = (rdgAllowColumnsForm,
|
2011-05-07 14:48:11 +00:00
|
|
|
rdgAllowDialogFind,
|
|
|
|
rdgHighlightFocusCol, //TODO:
|
|
|
|
rdgHighlightFocusRow, //TODO:
|
|
|
|
rdgDblClickOptimizeColWidth,
|
|
|
|
rdgFooterRows,
|
|
|
|
rdgXORColSizing,
|
|
|
|
rdgFilter,
|
|
|
|
rdgMultiTitleLines,
|
|
|
|
rdgMrOkOnDblClik,
|
|
|
|
rdgAllowQuickSearch,
|
|
|
|
rdgAllowQuickFilter,
|
|
|
|
rdgAllowFilterForm,
|
|
|
|
rdgAllowSortForm,
|
|
|
|
rdgAllowToolMenu,
|
2012-10-17 13:17:40 +00:00
|
|
|
rdgCaseInsensitiveSort,
|
2016-08-23 06:15:57 +00:00
|
|
|
rdgWordWrap,
|
2017-06-09 13:26:54 +00:00
|
|
|
rdgDisableWordWrapTitles,
|
|
|
|
rdgColSpanning
|
2011-05-07 14:48:11 +00:00
|
|
|
);
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
TOptionsRx = set of TOptionRx;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
TCreateLookup = TNotifyEvent;
|
|
|
|
TDisplayLookup = TNotifyEvent;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
TRxDBGridCommand = (rxgcNone, rxgcShowFindDlg, rxgcShowColumnsDlg,
|
2011-05-07 14:48:11 +00:00
|
|
|
rxgcShowFilterDlg, rxgcShowSortDlg, rxgcShowQuickFilter,
|
2012-09-24 14:21:22 +00:00
|
|
|
rxgcHideQuickFilter, rxgcSelectAll, rxgcDeSelectAll, rxgcInvertSelection,
|
2014-01-15 11:35:25 +00:00
|
|
|
rxgcOptimizeColumnsWidth, rxgcCopyCellValue
|
2012-09-24 14:21:22 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
);
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
TRxFilterOpCode = (fopEQ, fopNotEQ, fopStartFrom, fopEndTo, fopLike, fopNotLike);
|
2016-11-08 08:10:02 +00:00
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
{ TRxDBGridKeyStroke }
|
|
|
|
|
|
|
|
TRxDBGridKeyStroke = class(TCollectionItem)
|
|
|
|
private
|
|
|
|
FCommand: TRxDBGridCommand;
|
|
|
|
FEnabled: boolean;
|
|
|
|
FShortCut: TShortCut;
|
|
|
|
FKey: word; // Virtual keycode, i.e. VK_xxx
|
|
|
|
FShift: TShiftState;
|
|
|
|
procedure SetCommand(const AValue: TRxDBGridCommand);
|
|
|
|
procedure SetShortCut(const AValue: TShortCut);
|
|
|
|
protected
|
|
|
|
function GetDisplayName: string; override;
|
|
|
|
public
|
2013-02-12 11:44:08 +00:00
|
|
|
procedure Assign(Source: TPersistent); override;
|
2010-05-19 15:33:28 +00:00
|
|
|
published
|
|
|
|
property Command: TRxDBGridCommand read FCommand write SetCommand;
|
|
|
|
property ShortCut: TShortCut read FShortCut write SetShortCut;
|
2011-05-07 14:48:11 +00:00
|
|
|
property Enabled: boolean read FEnabled write FEnabled;
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ TRxDBGridKeyStrokes }
|
|
|
|
|
2013-02-12 11:44:08 +00:00
|
|
|
TRxDBGridKeyStrokes = class(TOwnedCollection)
|
2010-05-19 15:33:28 +00:00
|
|
|
private
|
2011-05-07 14:48:11 +00:00
|
|
|
function GetItem(Index: integer): TRxDBGridKeyStroke;
|
|
|
|
procedure SetItem(Index: integer; const AValue: TRxDBGridKeyStroke);
|
2010-05-19 15:33:28 +00:00
|
|
|
protected
|
|
|
|
procedure Update(Item: TCollectionItem); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TPersistent);
|
2013-02-12 11:44:08 +00:00
|
|
|
procedure Assign(Source: TPersistent); override;
|
2010-05-19 15:33:28 +00:00
|
|
|
function Add: TRxDBGridKeyStroke;
|
|
|
|
function AddE(ACommand: TRxDBGridCommand; AShortCut: TShortCut): TRxDBGridKeyStroke;
|
|
|
|
procedure ResetDefaults;
|
2011-05-07 14:48:11 +00:00
|
|
|
function FindRxCommand(AKey: word; AShift: TShiftState): TRxDBGridCommand;
|
|
|
|
function FindRxKeyStrokes(ACommand: TRxDBGridCommand): TRxDBGridKeyStroke;
|
2010-05-19 15:33:28 +00:00
|
|
|
public
|
2013-03-28 15:40:03 +00:00
|
|
|
property Items[Index: integer]: TRxDBGridKeyStroke read GetItem write SetItem; default;
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
2016-11-08 08:10:02 +00:00
|
|
|
{ TRxDBGridSearchOptions }
|
|
|
|
|
|
|
|
TRxDBGridSearchOptions = class(TPersistent)
|
|
|
|
private
|
|
|
|
FFromStart: boolean;
|
2019-05-17 11:51:53 +00:00
|
|
|
FHilightColor: TColor;
|
|
|
|
FHilightSearch: boolean;
|
2016-11-08 08:10:02 +00:00
|
|
|
FOwner:TRxDBGrid;
|
|
|
|
FQuickSearchOptions: TLocateOptions;
|
|
|
|
protected
|
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TRxDBGrid);
|
|
|
|
published
|
|
|
|
property QuickSearchOptions:TLocateOptions read FQuickSearchOptions write FQuickSearchOptions;
|
|
|
|
property FromStart:boolean read FFromStart write FFromStart;
|
2019-05-17 11:51:53 +00:00
|
|
|
property HilightSearch:boolean read FHilightSearch write FHilightSearch default true;
|
|
|
|
property HilightColor:TColor read FHilightColor write FHilightColor default clYellow;
|
2016-11-08 08:10:02 +00:00
|
|
|
end;
|
|
|
|
|
2014-01-15 12:04:11 +00:00
|
|
|
{ TRxDBGridCollumnConstraint }
|
|
|
|
|
|
|
|
TRxDBGridCollumnConstraints = class(TPersistent)
|
|
|
|
private
|
|
|
|
FMaxWidth: integer;
|
|
|
|
FMinWidth: integer;
|
|
|
|
FOwner: TPersistent;
|
|
|
|
procedure SetMaxWidth(AValue: integer);
|
|
|
|
procedure SetMinWidth(AValue: integer);
|
|
|
|
protected
|
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TPersistent);
|
|
|
|
published
|
2014-01-15 12:18:24 +00:00
|
|
|
property MinWidth:integer read FMinWidth write SetMinWidth default 0;
|
|
|
|
property MaxWidth:integer read FMaxWidth write SetMaxWidth default 0;
|
2014-01-15 12:04:11 +00:00
|
|
|
end;
|
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
{ TRxDBGridFooterOptions }
|
|
|
|
|
|
|
|
TRxDBGridFooterOptions = class(TPersistent)
|
|
|
|
private
|
|
|
|
FActive: boolean;
|
|
|
|
FColor: TColor;
|
2016-05-05 06:22:50 +00:00
|
|
|
FDrawFullLine: boolean;
|
2012-02-23 04:46:16 +00:00
|
|
|
FOwner: TRxDBGrid;
|
|
|
|
FRowCount: integer;
|
|
|
|
FStyle: TTitleStyle;
|
|
|
|
procedure SetActive(AValue: boolean);
|
|
|
|
procedure SetColor(AValue: TColor);
|
2016-05-05 06:22:50 +00:00
|
|
|
procedure SetDrawFullLine(AValue: boolean);
|
2012-02-23 04:46:16 +00:00
|
|
|
procedure SetRowCount(AValue: integer);
|
|
|
|
procedure SetStyle(AValue: TTitleStyle);
|
|
|
|
protected
|
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
|
|
|
public
|
|
|
|
constructor Create(Owner: TRxDBGrid);
|
|
|
|
destructor Destroy; override;
|
|
|
|
published
|
|
|
|
property Active: boolean read FActive write SetActive default false;
|
|
|
|
property Color: TColor read FColor write SetColor default clWindow;
|
|
|
|
property RowCount: integer read FRowCount write SetRowCount default 0;
|
|
|
|
property Style: TTitleStyle read FStyle write SetStyle default tsLazarus;
|
2016-05-05 06:22:50 +00:00
|
|
|
property DrawFullLine: boolean read FDrawFullLine write SetDrawFullLine;
|
2012-02-23 04:46:16 +00:00
|
|
|
end;
|
|
|
|
|
2015-09-07 07:42:04 +00:00
|
|
|
{ TRxDBGridColumnDefValues }
|
|
|
|
|
|
|
|
TRxDBGridColumnDefValues = class(TPersistent)
|
|
|
|
private
|
|
|
|
FBlobText: string;
|
|
|
|
FOwner: TRxDBGrid;
|
|
|
|
protected
|
|
|
|
procedure AssignTo(Dest: TPersistent); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TRxDBGrid);
|
|
|
|
destructor Destroy; override;
|
|
|
|
published
|
|
|
|
property BlobText:string read FBlobText write FBlobText;
|
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2009-12-10 22:02:14 +00:00
|
|
|
{ TRxDBGridSortEngine }
|
2010-05-19 15:33:28 +00:00
|
|
|
TRxSortEngineOption = (seoCaseInsensitiveSort);
|
2009-12-10 22:02:14 +00:00
|
|
|
TRxSortEngineOptions = set of TRxSortEngineOption;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2009-12-10 22:02:14 +00:00
|
|
|
TRxDBGridSortEngine = class
|
2013-03-19 13:45:06 +00:00
|
|
|
protected
|
|
|
|
FGrid:TRxDBGrid;
|
2007-08-09 21:36:59 +00:00
|
|
|
public
|
2014-02-08 11:02:58 +00:00
|
|
|
procedure Sort(FieldName: string; ADataSet: TDataSet; Asc: boolean; SortOptions: TRxSortEngineOptions); virtual; abstract;
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure SortList(ListField: string; ADataSet: TDataSet; Asc: array of boolean; SortOptions: TRxSortEngineOptions); virtual;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2009-12-10 22:02:14 +00:00
|
|
|
TRxDBGridSortEngineClass = class of TRxDBGridSortEngine;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
TMLCaptionItem = class
|
2011-05-07 14:48:11 +00:00
|
|
|
Caption: string;
|
|
|
|
Width: integer;
|
2016-08-22 13:32:34 +00:00
|
|
|
Height: integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
Next: TMLCaptionItem;
|
|
|
|
Prior: TMLCaptionItem;
|
2013-03-12 14:08:34 +00:00
|
|
|
FInvalidDraw:integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
Col: TGridColumn;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxColumnTitle }
|
2007-08-10 22:15:51 +00:00
|
|
|
TRxColumnTitle = class(TColumnTitle)
|
2007-08-09 21:36:59 +00:00
|
|
|
private
|
2007-08-10 22:15:51 +00:00
|
|
|
FHint: string;
|
2007-08-09 21:36:59 +00:00
|
|
|
FOrientation: TTextOrientation;
|
2007-08-10 22:15:51 +00:00
|
|
|
FShowHint: boolean;
|
2011-05-07 14:48:11 +00:00
|
|
|
FCaptionLines: TFPList;
|
2009-06-29 16:01:00 +00:00
|
|
|
function GetCaptionLinesCount: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure SetOrientation(const AValue: TTextOrientation);
|
2009-06-29 16:01:00 +00:00
|
|
|
procedure ClearCaptionML;
|
2007-08-10 22:15:51 +00:00
|
|
|
protected
|
2008-01-28 05:21:43 +00:00
|
|
|
procedure SetCaption(const AValue: TCaption); override;
|
2007-08-10 22:15:51 +00:00
|
|
|
public
|
|
|
|
constructor Create(TheColumn: TGridColumn); override;
|
|
|
|
destructor Destroy; override;
|
2011-05-07 14:48:11 +00:00
|
|
|
property CaptionLinesCount: integer read GetCaptionLinesCount;
|
|
|
|
function CaptionLine(ALine: integer): TMLCaptionItem;
|
2007-08-09 21:36:59 +00:00
|
|
|
published
|
2011-05-07 14:48:11 +00:00
|
|
|
property Orientation: TTextOrientation read FOrientation write SetOrientation;
|
2007-08-10 22:15:51 +00:00
|
|
|
property Hint: string read FHint write FHint;
|
2011-05-07 14:48:11 +00:00
|
|
|
property ShowHint: boolean read FShowHint write FShowHint default False;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
{ TRxColumnFooterItem }
|
|
|
|
TRxColumnFooterItem = class(TCollectionItem)
|
|
|
|
private
|
2017-02-10 07:05:15 +00:00
|
|
|
FColor: TColor;
|
2015-07-28 10:15:04 +00:00
|
|
|
FIsDefaultFont: boolean;
|
|
|
|
FLayout: TTextLayout;
|
|
|
|
FOwner: TRxColumn;
|
|
|
|
FAlignment: TAlignment;
|
|
|
|
FDisplayFormat: string;
|
|
|
|
FFieldName: string;
|
|
|
|
FField:TField;
|
|
|
|
FFont: TFont;
|
|
|
|
FValue: string;
|
|
|
|
FValueType: TFooterValueType;
|
|
|
|
FTestValue: double;
|
|
|
|
FCountRec:integer;
|
|
|
|
procedure FontChanged(Sender: TObject);
|
|
|
|
function GetFont: TFont;
|
|
|
|
function IsFontStored: Boolean;
|
|
|
|
procedure SetAlignment(AValue: TAlignment);
|
2017-02-10 07:05:15 +00:00
|
|
|
procedure SetColor(AValue: TColor);
|
2015-07-28 10:15:04 +00:00
|
|
|
procedure SetDisplayFormat(AValue: string);
|
|
|
|
procedure SetFieldName(AValue: string);
|
|
|
|
procedure SetFont(AValue: TFont);
|
|
|
|
procedure SetLayout(AValue: TTextLayout);
|
|
|
|
procedure SetValue(AValue: string);
|
|
|
|
procedure SetValueType(AValue: TFooterValueType);
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
function GetFieldValue: string;
|
|
|
|
function GetRecordsCount: string;
|
|
|
|
function GetRecNo: string;
|
|
|
|
function GetStatTotal: string;
|
|
|
|
procedure ResetTestValue;
|
|
|
|
procedure UpdateTestValue;
|
|
|
|
|
|
|
|
function DeleteTestValue: boolean;
|
|
|
|
function PostTestValue: boolean;
|
|
|
|
function ErrorTestValue: boolean;
|
|
|
|
protected
|
|
|
|
procedure UpdateTestValueFromVar(AValue:Variant);
|
|
|
|
property IsDefaultFont: boolean read FIsDefaultFont;
|
|
|
|
public
|
|
|
|
constructor Create(ACollection: TCollection); override;
|
|
|
|
destructor Destroy; override;
|
|
|
|
function DisplayText: string;
|
|
|
|
procedure FillDefaultFont;
|
|
|
|
|
|
|
|
property Owner: TRxColumn read FOwner;
|
|
|
|
property NumericValue: double read FTestValue;
|
|
|
|
property CountRec:integer read FCountRec;
|
|
|
|
published
|
|
|
|
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
|
|
|
|
property Layout: TTextLayout read FLayout write SetLayout default tlCenter;
|
|
|
|
property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
|
|
|
|
property FieldName: string read FFieldName write SetFieldName;
|
|
|
|
property Value: string read FValue write SetValue;
|
|
|
|
property ValueType: TFooterValueType read FValueType write SetValueType default fvtNon;
|
|
|
|
property Font: TFont read GetFont write SetFont stored IsFontStored;
|
2017-02-10 07:05:15 +00:00
|
|
|
property Color : TColor read FColor write SetColor stored IsFontStored default clNone;
|
2015-07-28 10:15:04 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ TRxColumnFooterItems }
|
|
|
|
|
|
|
|
TRxColumnFooterItems = class(TOwnedCollection)
|
|
|
|
private
|
|
|
|
function GetItem(Index: integer): TRxColumnFooterItem;
|
|
|
|
procedure SetItem(Index: integer; const AValue: TRxColumnFooterItem);
|
|
|
|
protected
|
|
|
|
procedure Update(Item: TCollectionItem); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TPersistent);
|
2017-05-18 13:58:44 +00:00
|
|
|
function GetEnumerator: TRxColumnFooterItemsEnumerator;
|
2015-07-28 10:15:04 +00:00
|
|
|
public
|
|
|
|
property Items[Index: integer]: TRxColumnFooterItem read GetItem write SetItem; default;
|
|
|
|
end;
|
2013-03-28 15:40:03 +00:00
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
{ TRxColumnFooterItemsEnumerator }
|
|
|
|
|
|
|
|
TRxColumnFooterItemsEnumerator = class
|
|
|
|
private
|
|
|
|
FList: TRxColumnFooterItems;
|
|
|
|
FPosition: Integer;
|
|
|
|
public
|
|
|
|
constructor Create(AList: TRxColumnFooterItems);
|
|
|
|
function GetCurrent: TRxColumnFooterItem;
|
|
|
|
function MoveNext: Boolean;
|
|
|
|
property Current: TRxColumnFooterItem read GetCurrent;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
{ TRxColumnFilter }
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
TRxFilterState = (rxfsAll, rxfsEmpty, rxfsNonEmpty, rxfsFilter{, rxfsTopXXXX});
|
2017-12-18 08:35:51 +00:00
|
|
|
TRxFilterStyle = (rxfstSimple, rxfstDialog, rxfstManualEdit, rxfstBoth);
|
2017-04-24 12:24:50 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
TRxColumnFilter = class(TPersistent)
|
|
|
|
private
|
2018-01-30 08:00:10 +00:00
|
|
|
FIsFontStored:Boolean;
|
|
|
|
FIsEmptyFontStored:Boolean;
|
2016-09-08 08:51:40 +00:00
|
|
|
FAllValue: string;
|
2017-04-24 12:24:50 +00:00
|
|
|
FCurrentValues: TStringList;
|
2013-05-08 05:26:49 +00:00
|
|
|
FEnabled: boolean;
|
2017-12-18 08:35:51 +00:00
|
|
|
FManulEditValue: string;
|
2017-12-06 07:17:42 +00:00
|
|
|
FNotEmptyValue: string;
|
2011-05-07 14:48:11 +00:00
|
|
|
FOwner: TRxColumn;
|
2017-04-24 12:24:50 +00:00
|
|
|
FState: TRxFilterState;
|
|
|
|
FStyle: TRxFilterStyle;
|
2007-08-10 22:15:51 +00:00
|
|
|
FValueList: TStringList;
|
|
|
|
FEmptyValue: string;
|
|
|
|
FEmptyFont: TFont;
|
|
|
|
FFont: TFont;
|
|
|
|
FAlignment: TAlignment;
|
2011-05-07 14:48:11 +00:00
|
|
|
FDropDownRows: integer;
|
2007-08-10 22:15:51 +00:00
|
|
|
FColor: TColor;
|
2017-12-18 08:35:51 +00:00
|
|
|
function GetDisplayFilterValue: string;
|
2007-08-10 22:15:51 +00:00
|
|
|
function GetItemIndex: integer;
|
2018-01-30 08:00:10 +00:00
|
|
|
function IsEmptyFontStored: Boolean;
|
|
|
|
function IsFontStored: Boolean;
|
|
|
|
procedure FontChanged(Sender: TObject);
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure SetColor(const AValue: TColor);
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure SetEmptyFont(AValue: TFont);
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure SetFont(const AValue: TFont);
|
|
|
|
procedure SetItemIndex(const AValue: integer);
|
|
|
|
public
|
2011-05-07 14:48:11 +00:00
|
|
|
constructor Create(Owner: TRxColumn); virtual;
|
2007-08-10 22:15:51 +00:00
|
|
|
destructor Destroy; override;
|
2017-12-18 08:35:51 +00:00
|
|
|
procedure ClearFilter;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
property State:TRxFilterState read FState write FState;
|
|
|
|
property CurrentValues : TStringList read FCurrentValues;
|
2017-12-18 08:35:51 +00:00
|
|
|
property ManulEditValue : string read FManulEditValue write FManulEditValue;
|
|
|
|
property DisplayFilterValue:string read GetDisplayFilterValue;
|
2007-08-10 22:15:51 +00:00
|
|
|
published
|
2018-01-30 08:00:10 +00:00
|
|
|
property Font: TFont read FFont write SetFont stored IsFontStored;
|
2011-05-07 14:48:11 +00:00
|
|
|
property Alignment: TAlignment read FAlignment write FAlignment default
|
|
|
|
taLeftJustify;
|
|
|
|
property DropDownRows: integer read FDropDownRows write FDropDownRows;
|
2007-08-10 22:15:51 +00:00
|
|
|
property Color: TColor read FColor write SetColor default clWhite;
|
2017-05-18 11:57:06 +00:00
|
|
|
property ValueList: TStringList read FValueList;
|
2011-05-07 14:48:11 +00:00
|
|
|
property EmptyValue: string read FEmptyValue write FEmptyValue;
|
2017-12-06 07:17:42 +00:00
|
|
|
property NotEmptyValue: string read FNotEmptyValue write FNotEmptyValue;
|
2016-09-08 08:51:40 +00:00
|
|
|
property AllValue: string read FAllValue write FAllValue;
|
2018-01-30 08:00:10 +00:00
|
|
|
property EmptyFont: TFont read FEmptyFont write SetEmptyFont stored IsEmptyFontStored;
|
2011-05-07 14:48:11 +00:00
|
|
|
property ItemIndex: integer read GetItemIndex write SetItemIndex;
|
2013-05-08 05:26:49 +00:00
|
|
|
property Enabled:boolean read FEnabled write FEnabled default true;
|
2017-04-24 12:24:50 +00:00
|
|
|
property Style : TRxFilterStyle read FStyle write FStyle default rxfstSimple;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2012-08-23 17:03:53 +00:00
|
|
|
{ TRxColumnEditButton }
|
|
|
|
|
|
|
|
TRxColumnEditButton = class(TCollectionItem)
|
|
|
|
private
|
2015-06-17 08:09:34 +00:00
|
|
|
FEnabled: Boolean;
|
2012-08-23 17:03:53 +00:00
|
|
|
FShortCut: TShortCut;
|
|
|
|
FStyle: TRxColumnEditButtonStyle;
|
|
|
|
FButton:TSpeedButton;
|
|
|
|
FVisible: Boolean;
|
2014-02-02 11:14:10 +00:00
|
|
|
//
|
|
|
|
FSpinBtn:TRxSpinButton;
|
2012-08-23 17:03:53 +00:00
|
|
|
function GetGlyph: TBitmap;
|
|
|
|
function GetHint: String;
|
|
|
|
function GetNumGlyphs: Integer;
|
|
|
|
function GetOnButtonClick: TNotifyEvent;
|
|
|
|
function GetWidth: Integer;
|
|
|
|
procedure SetGlyph(AValue: TBitmap);
|
|
|
|
procedure SetHint(AValue: String);
|
|
|
|
procedure SetNumGlyphs(AValue: Integer);
|
|
|
|
procedure SetOnButtonClick(AValue: TNotifyEvent);
|
|
|
|
procedure SetStyle(AValue: TRxColumnEditButtonStyle);
|
|
|
|
procedure SetVisible(AValue: Boolean);
|
|
|
|
procedure SetWidth(AValue: Integer);
|
2014-02-02 11:14:10 +00:00
|
|
|
|
|
|
|
procedure DoBottomClick(Sender: TObject);
|
|
|
|
procedure DoTopClick(Sender: TObject);
|
2012-08-23 17:03:53 +00:00
|
|
|
protected
|
|
|
|
function GetDisplayName: string; override;
|
|
|
|
public
|
|
|
|
constructor Create(ACollection: TCollection); override;
|
|
|
|
destructor Destroy; override;
|
|
|
|
published
|
2015-06-17 08:09:34 +00:00
|
|
|
property Enabled: Boolean read FEnabled write FEnabled default true;
|
2012-08-23 17:03:53 +00:00
|
|
|
property Glyph: TBitmap read GetGlyph write SetGlyph;
|
|
|
|
property Hint: String read GetHint write SetHint;
|
|
|
|
property NumGlyphs: Integer read GetNumGlyphs write SetNumGlyphs default 1;
|
|
|
|
property ShortCut: TShortCut read FShortCut write FShortCut default scNone;
|
|
|
|
property Style: TRxColumnEditButtonStyle read FStyle write SetStyle default ebsDropDownRx;
|
|
|
|
property Visible: Boolean read FVisible write SetVisible default true;
|
|
|
|
property Width: Integer read GetWidth write SetWidth default 15;
|
|
|
|
property OnClick: TNotifyEvent read GetOnButtonClick write SetOnButtonClick;
|
|
|
|
end;
|
|
|
|
|
|
|
|
TRxColumnEditButtons = class(TCollection)
|
|
|
|
private
|
|
|
|
FOwner: TPersistent;
|
|
|
|
function GetItem(Index: integer): TRxColumnEditButton;
|
|
|
|
procedure SetItem(Index: integer; AValue: TRxColumnEditButton);
|
|
|
|
protected
|
|
|
|
procedure Update(Item: TCollectionItem); override;
|
|
|
|
public
|
|
|
|
constructor Create(AOwner: TPersistent);
|
|
|
|
function Add: TRxColumnEditButton;
|
|
|
|
public
|
|
|
|
property Items[Index: integer]: TRxColumnEditButton read GetItem write SetItem; default;
|
|
|
|
end;
|
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
TColumnGroupItemValue = class
|
|
|
|
FieldName:string;
|
|
|
|
GroupValue:Double;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TColumnGroupItem }
|
|
|
|
|
|
|
|
TColumnGroupItem = class
|
2017-05-26 13:05:56 +00:00
|
|
|
private
|
|
|
|
FValues:TFPList;
|
|
|
|
RecBookMark:TBookMark;
|
2017-05-18 13:58:44 +00:00
|
|
|
FieldValue:string;
|
|
|
|
RecordCount:integer;
|
2017-05-26 13:05:56 +00:00
|
|
|
RecordNo:integer;
|
|
|
|
function GetItems(FieldName: string): TColumnGroupItemValue;
|
|
|
|
procedure ClearValues;
|
|
|
|
function AddItem(AFieldName:string):TColumnGroupItemValue;
|
|
|
|
public
|
2017-05-18 13:58:44 +00:00
|
|
|
constructor Create;
|
|
|
|
destructor Destroy; override;
|
2017-05-26 13:05:56 +00:00
|
|
|
property Items[FieldName:string]:TColumnGroupItemValue read GetItems;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ TColumnGroupItems }
|
|
|
|
|
|
|
|
TColumnGroupItems = class
|
|
|
|
private
|
2017-05-26 13:05:56 +00:00
|
|
|
FColor: TColor;
|
|
|
|
//for calc
|
|
|
|
FGroupField:TField;
|
|
|
|
FCurItem:TColumnGroupItem;
|
|
|
|
FCurrentValue:String;
|
|
|
|
//params
|
2017-05-18 13:58:44 +00:00
|
|
|
FActive: boolean;
|
2017-05-26 13:05:56 +00:00
|
|
|
FGroupFieldName: string;
|
|
|
|
FList:TFPList;
|
|
|
|
FRxDBGrid:TRxDBGrid;
|
2017-05-18 13:58:44 +00:00
|
|
|
procedure SetActive(AValue: boolean);
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure SetColor(AValue: TColor);
|
|
|
|
protected
|
|
|
|
function AddGroupItem:TColumnGroupItem;
|
|
|
|
procedure InitGroup;
|
|
|
|
procedure DoneGroup;
|
2017-05-18 13:58:44 +00:00
|
|
|
public
|
2017-05-26 13:05:56 +00:00
|
|
|
constructor Create(ARxDBGrid:TRxDBGrid);
|
2017-05-18 13:58:44 +00:00
|
|
|
destructor Destroy; override;
|
|
|
|
procedure Clear;
|
|
|
|
procedure UpdateValues;
|
2017-06-20 12:38:18 +00:00
|
|
|
function FindGroupItem(ARecBookMark: TBookMark): TColumnGroupItem;
|
2017-05-26 13:05:56 +00:00
|
|
|
property GroupFieldName:string read FGroupFieldName write FGroupFieldName;
|
2017-05-18 13:58:44 +00:00
|
|
|
published
|
|
|
|
property Active:boolean read FActive write SetActive;
|
2017-05-26 13:05:56 +00:00
|
|
|
property Color:TColor read FColor write SetColor;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{ TRxColumnGroupParam }
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
TRxColumnGroupParam = class
|
2017-05-18 13:58:44 +00:00
|
|
|
private
|
2017-05-26 13:05:56 +00:00
|
|
|
FAlignment: TAlignment;
|
|
|
|
FColor: TColor;
|
|
|
|
FDisplayFormat: string;
|
|
|
|
FLayout: TTextLayout;
|
|
|
|
FStaticText: string;
|
2017-05-18 13:58:44 +00:00
|
|
|
FValueType: TFooterValueType;
|
2017-05-26 13:05:56 +00:00
|
|
|
FColumn:TRxColumn;
|
|
|
|
FIsDefaultFont: boolean;
|
|
|
|
FFont: TFont;
|
|
|
|
procedure FontChanged(Sender: TObject);
|
|
|
|
function GetDisplayText: string;
|
|
|
|
function GetFont: TFont;
|
|
|
|
function IsFontStored: Boolean;
|
|
|
|
procedure SetAlignment(AValue: TAlignment);
|
|
|
|
procedure SetColor(AValue: TColor);
|
|
|
|
procedure SetDisplayFormat(AValue: string);
|
|
|
|
procedure SetFont(AValue: TFont);
|
|
|
|
procedure SetLayout(AValue: TTextLayout);
|
|
|
|
procedure SetStaticText(AValue: string);
|
2017-05-18 13:58:44 +00:00
|
|
|
protected
|
2017-05-26 13:05:56 +00:00
|
|
|
function GetGroupItems:TColumnGroupItem;
|
|
|
|
function GetGroupItem:TColumnGroupItemValue;
|
|
|
|
function GetRecordsCount: string;
|
|
|
|
function GetGroupTotal: string;
|
|
|
|
function GetGroupValue: string;
|
|
|
|
function GetRecNo: string;
|
2017-05-18 13:58:44 +00:00
|
|
|
public
|
2017-05-26 13:05:56 +00:00
|
|
|
constructor Create(AColumn:TRxColumn);
|
|
|
|
destructor Destroy; override;
|
|
|
|
procedure FillDefaultFont;
|
|
|
|
procedure UpdateValues;
|
|
|
|
property DisplayText:string read GetDisplayText;
|
|
|
|
published
|
|
|
|
property ValueType:TFooterValueType read FValueType write FValueType default fvtNon;
|
|
|
|
property Alignment:TAlignment read FAlignment write SetAlignment default taLeftJustify;
|
|
|
|
property Layout: TTextLayout read FLayout write SetLayout default tlCenter;
|
|
|
|
property DisplayFormat: string read FDisplayFormat write SetDisplayFormat;
|
|
|
|
property StaticText: string read FStaticText write SetStaticText;
|
|
|
|
property Font: TFont read GetFont write SetFont stored IsFontStored;
|
|
|
|
property Color : TColor read FColor write SetColor stored IsFontStored default clNone;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxColumn }
|
|
|
|
|
|
|
|
TRxColumn = class(TColumn)
|
|
|
|
private
|
2011-09-22 17:07:49 +00:00
|
|
|
FDirectInput: boolean;
|
2012-08-23 17:03:53 +00:00
|
|
|
FEditButtons: TRxColumnEditButtons;
|
2015-07-28 10:15:04 +00:00
|
|
|
FFooter: TRxColumnFooterItem;
|
2014-01-15 12:04:11 +00:00
|
|
|
FConstraints:TRxDBGridCollumnConstraints;
|
2011-05-07 14:48:11 +00:00
|
|
|
FFilter: TRxColumnFilter;
|
2017-05-26 13:05:56 +00:00
|
|
|
FGroupParam: TRxColumnGroupParam;
|
2007-08-09 21:36:59 +00:00
|
|
|
FImageList: TImageList;
|
2011-05-07 14:48:11 +00:00
|
|
|
FKeyList: TStrings;
|
|
|
|
FNotInKeyListIndex: integer;
|
2012-09-17 19:52:38 +00:00
|
|
|
FOnDrawColumnCell: TDrawColumnCellEvent;
|
2014-07-28 10:24:14 +00:00
|
|
|
FOptions: TRxColumnOptions;
|
2020-07-02 07:13:46 +00:00
|
|
|
FPopupMenu: TPopupMenu;
|
2014-02-08 11:02:58 +00:00
|
|
|
FSortFields: string;
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortOrder: TSortMarker;
|
|
|
|
FSortPosition: integer;
|
2012-10-17 13:17:40 +00:00
|
|
|
FWordWrap: boolean;
|
2015-07-28 10:15:04 +00:00
|
|
|
FFooters: TRxColumnFooterItems;
|
2014-01-15 12:04:11 +00:00
|
|
|
function GetConstraints: TRxDBGridCollumnConstraints;
|
2015-07-28 10:15:04 +00:00
|
|
|
function GetFooter: TRxColumnFooterItem;
|
|
|
|
function GetFooters: TRxColumnFooterItems;
|
2007-08-09 21:36:59 +00:00
|
|
|
function GetKeyList: TStrings;
|
2014-02-08 11:02:58 +00:00
|
|
|
function GetSortFields:string;
|
2014-01-15 12:04:11 +00:00
|
|
|
procedure SetConstraints(AValue: TRxDBGridCollumnConstraints);
|
2012-08-23 17:03:53 +00:00
|
|
|
procedure SetEditButtons(AValue: TRxColumnEditButtons);
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure SetFilter(const AValue: TRxColumnFilter);
|
2015-07-28 10:15:04 +00:00
|
|
|
procedure SetFooter(const AValue: TRxColumnFooterItem);
|
|
|
|
procedure SetFooters(AValue: TRxColumnFooterItems);
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure SetImageList(const AValue: TImageList);
|
|
|
|
procedure SetKeyList(const AValue: TStrings);
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure SetNotInKeyListIndex(const AValue: integer);
|
2012-10-17 13:17:40 +00:00
|
|
|
procedure SetWordWrap(AValue: boolean);
|
2007-08-09 21:36:59 +00:00
|
|
|
protected
|
2011-05-07 14:48:11 +00:00
|
|
|
function CreateTitle: TGridColumnTitle; override;
|
2014-01-15 12:04:11 +00:00
|
|
|
procedure ColumnChanged; override;
|
2007-08-09 21:36:59 +00:00
|
|
|
public
|
|
|
|
constructor Create(ACollection: TCollection); override;
|
2011-05-07 14:48:11 +00:00
|
|
|
destructor Destroy; override;
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure OptimizeWidth;
|
2013-03-28 15:40:03 +00:00
|
|
|
property SortOrder: TSortMarker read FSortOrder write FSortOrder;
|
2012-09-21 17:06:21 +00:00
|
|
|
property SortPosition: integer read FSortPosition;
|
2017-05-26 13:05:56 +00:00
|
|
|
property GroupParam:TRxColumnGroupParam read FGroupParam;
|
2007-08-09 21:36:59 +00:00
|
|
|
published
|
2014-01-15 12:04:11 +00:00
|
|
|
property Constraints:TRxDBGridCollumnConstraints read GetConstraints write SetConstraints;
|
2011-09-22 17:07:49 +00:00
|
|
|
property DirectInput : boolean read FDirectInput write FDirectInput default true;
|
2012-08-23 17:03:53 +00:00
|
|
|
property EditButtons:TRxColumnEditButtons read FEditButtons write SetEditButtons;
|
2014-07-28 10:24:14 +00:00
|
|
|
property Filter: TRxColumnFilter read FFilter write SetFilter;
|
2015-07-28 10:15:04 +00:00
|
|
|
property Footer: TRxColumnFooterItem read GetFooter write SetFooter;
|
|
|
|
property Footers: TRxColumnFooterItems read GetFooters write SetFooters;
|
2014-07-28 10:24:14 +00:00
|
|
|
property ImageList: TImageList read FImageList write SetImageList;
|
|
|
|
property KeyList: TStrings read GetKeyList write SetKeyList;
|
|
|
|
property NotInKeyListIndex: integer read FNotInKeyListIndex write SetNotInKeyListIndex default -1;
|
|
|
|
property Options:TRxColumnOptions read FOptions write FOptions default [coCustomizeVisible, coCustomizeWidth];
|
|
|
|
property SortFields: string read FSortFields write FSortFields;
|
2012-10-17 13:17:40 +00:00
|
|
|
property WordWrap:boolean read FWordWrap write SetWordWrap default false;
|
2014-07-28 10:24:14 +00:00
|
|
|
property OnDrawColumnCell: TDrawColumnCellEvent read FOnDrawColumnCell write FOnDrawColumnCell;
|
2020-07-02 07:13:46 +00:00
|
|
|
property PopupMenu: TPopupMenu read FPopupMenu write FPopupMenu;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxDbGridColumns }
|
|
|
|
TRxDbGridColumns = class(TDbGridColumns)
|
2015-05-25 10:12:12 +00:00
|
|
|
private
|
|
|
|
function GetColumn(Index: Integer): TRxColumn;
|
|
|
|
procedure SetColumn(Index: Integer; AValue: TRxColumn);
|
2007-08-09 21:36:59 +00:00
|
|
|
protected
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure Notify(Item: TCollectionItem;Action: TCollectionNotification); override;
|
2007-08-10 22:15:51 +00:00
|
|
|
public
|
2011-05-07 14:48:11 +00:00
|
|
|
function Add: TRxColumn;
|
2017-04-24 12:44:17 +00:00
|
|
|
function GetEnumerator: TRxDbGridColumnsEnumerator;
|
2015-05-25 10:12:12 +00:00
|
|
|
property Items[Index: Integer]: TRxColumn read GetColumn write SetColumn; default;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2017-04-24 12:44:17 +00:00
|
|
|
{ TRxDbGridColumnsEnumerator }
|
|
|
|
|
|
|
|
TRxDbGridColumnsEnumerator = class
|
|
|
|
private
|
|
|
|
FList: TRxDbGridColumns;
|
|
|
|
FPosition: Integer;
|
|
|
|
public
|
|
|
|
constructor Create(AList: TRxDbGridColumns);
|
|
|
|
function GetCurrent: TRxColumn;
|
|
|
|
function MoveNext: Boolean;
|
|
|
|
property Current: TRxColumn read GetCurrent;
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
{ TRxDbGridColumnsSortList }
|
|
|
|
|
|
|
|
TRxDbGridColumnsSortList = class(TFPList)
|
|
|
|
private
|
|
|
|
function GetCollumn(Index: Integer): TRxColumn;
|
|
|
|
public
|
|
|
|
property Collumn[Index: Integer]: TRxColumn read GetCollumn; default;
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
{ TFilterListCellEditor }
|
|
|
|
|
|
|
|
TFilterListCellEditor = class(TComboBox)
|
|
|
|
private
|
|
|
|
FGrid: TCustomGrid;
|
2011-05-07 14:48:11 +00:00
|
|
|
FCol: integer;
|
|
|
|
FMouseFlag: boolean;
|
2007-08-10 22:15:51 +00:00
|
|
|
protected
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure WndProc(var TheMessage: TLMessage); override;
|
|
|
|
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
2007-08-10 22:15:51 +00:00
|
|
|
public
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure Show(Grid: TCustomGrid; Col: integer);
|
2007-08-10 22:15:51 +00:00
|
|
|
property Grid: TCustomGrid read FGrid;
|
2011-05-07 14:48:11 +00:00
|
|
|
property Col: integer read FCol;
|
|
|
|
property MouseFlag: boolean read FMouseFlag write FMouseFlag;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
{ TFilterColDlgButton }
|
|
|
|
|
|
|
|
TFilterColDlgButton = class(TSpeedButton)
|
|
|
|
private
|
|
|
|
FGrid: TRxDBGrid;
|
|
|
|
FCol: integer;
|
|
|
|
public
|
|
|
|
procedure Show(AGrid: TRxDBGrid; Col: integer);
|
|
|
|
property Col: integer read FCol;
|
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2017-12-05 12:00:42 +00:00
|
|
|
{ TFilterSimpleEdit }
|
|
|
|
|
|
|
|
TFilterSimpleEdit = class(TEdit)
|
|
|
|
private
|
|
|
|
FGrid: TCustomGrid;
|
|
|
|
FCol: integer;
|
|
|
|
FMouseFlag: boolean;
|
|
|
|
protected
|
|
|
|
procedure WndProc(var TheMessage: TLMessage); override;
|
|
|
|
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
|
|
|
public
|
|
|
|
procedure Show(Grid: TCustomGrid; Col: integer);
|
|
|
|
property Grid: TCustomGrid read FGrid;
|
|
|
|
property Col: integer read FCol;
|
|
|
|
property MouseFlag: boolean read FMouseFlag write FMouseFlag;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
{ TRxDBGrid }
|
|
|
|
TRxDBGrid = class(TCustomDBGrid)
|
2007-08-09 21:36:59 +00:00
|
|
|
private
|
2020-09-21 12:02:51 +00:00
|
|
|
FDrawGetDefaultRowHeight:integer;
|
2015-09-07 07:42:04 +00:00
|
|
|
FColumnDefValues: TRxDBGridColumnDefValues;
|
2018-01-30 08:00:10 +00:00
|
|
|
FIsSelectedDefaultFont:boolean;
|
2017-04-27 07:57:02 +00:00
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
FFooterOptions: TRxDBGridFooterOptions;
|
2020-03-24 13:25:48 +00:00
|
|
|
FBeforeSorting: TNotifyEvent;
|
2017-05-18 11:16:05 +00:00
|
|
|
FOnCalcRowHeight: TRxDBGridCalcRowHeight;
|
2016-11-08 08:10:02 +00:00
|
|
|
FSearchOptions: TRxDBGridSearchOptions;
|
2018-01-30 08:00:10 +00:00
|
|
|
FSelectedFont: TFont;
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortColumns: TRxDbGridColumnsSortList;
|
2011-08-27 20:03:59 +00:00
|
|
|
FSortingNow:Boolean;
|
2011-05-07 14:48:11 +00:00
|
|
|
FInProcessCalc: integer;
|
2017-06-09 13:26:54 +00:00
|
|
|
|
|
|
|
FOnMergeCells: TRxDBGridMergeCellsEvent;
|
|
|
|
FMergeLock: Integer;
|
2012-09-17 10:07:41 +00:00
|
|
|
//
|
2010-05-19 15:33:28 +00:00
|
|
|
FKeyStrokes: TRxDBGridKeyStrokes;
|
2007-08-09 21:36:59 +00:00
|
|
|
FOnGetCellProps: TGetCellPropsEvent;
|
2007-08-10 22:15:51 +00:00
|
|
|
FOptionsRx: TOptionsRx;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
FOnGetBtnParams: TGetBtnParamsEvent;
|
2011-05-07 14:48:11 +00:00
|
|
|
FOnFiltred: TNotifyEvent;
|
2014-07-28 12:25:45 +00:00
|
|
|
FOnRxCalcFooterValues :TOnRxCalcFooterValues;
|
2015-09-07 07:42:04 +00:00
|
|
|
FOnRxColumnFooterDraw :TOnRxColumnFooterDraw;
|
2007-08-09 21:36:59 +00:00
|
|
|
//auto sort support
|
2012-09-21 17:06:21 +00:00
|
|
|
|
|
|
|
FAutoSort : boolean;
|
|
|
|
FSortEngine : TRxDBGridSortEngine;
|
|
|
|
FPressedCol : TRxColumn;
|
2012-09-17 10:07:41 +00:00
|
|
|
//
|
2011-05-07 14:48:11 +00:00
|
|
|
FPressed: boolean;
|
|
|
|
FSwapButtons: boolean;
|
|
|
|
FTracking: boolean;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
F_Clicked: boolean;
|
|
|
|
F_PopupMenu: TPopupMenu;
|
|
|
|
F_MenuBMP: TBitmap;
|
2009-08-17 17:50:27 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
F_EventOnFilterRec: TFilterRecordEvent;
|
2009-08-06 16:59:07 +00:00
|
|
|
F_EventOnBeforeDelete: TDataSetNotifyEvent;
|
2011-05-07 14:48:11 +00:00
|
|
|
F_EventOnBeforePost: TDataSetNotifyEvent;
|
|
|
|
F_EventOnDeleteError: TDataSetErrorEvent;
|
|
|
|
F_EventOnPostError: TDataSetErrorEvent;
|
|
|
|
F_LastFilter: TStringList;
|
|
|
|
F_CreateLookup: TCreateLookup;
|
|
|
|
F_DisplayLookup: TDisplayLookup;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
//storage
|
2007-08-10 22:15:51 +00:00
|
|
|
//Column resize
|
2011-05-07 14:48:11 +00:00
|
|
|
FColumnResizing: boolean;
|
|
|
|
|
|
|
|
FFilterListEditor: TFilterListCellEditor;
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterColDlgButton: TFilterColDlgButton;
|
2017-12-05 12:00:42 +00:00
|
|
|
FFilterSimpleEdit:TFilterSimpleEdit;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2017-02-27 05:38:55 +00:00
|
|
|
// FOldPosition: Integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
FVersion: integer;
|
|
|
|
FPropertyStorageLink: TPropertyStorageLink;
|
2008-01-31 13:23:03 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FAfterQuickSearch: TRxQuickSearchNotifyEvent;
|
|
|
|
FBeforeQuickSearch: TRxQuickSearchNotifyEvent;
|
|
|
|
FQuickUTF8Search: string;
|
2012-05-08 14:14:10 +00:00
|
|
|
FOldDataSetState:TDataSetState;
|
2015-05-25 10:12:12 +00:00
|
|
|
FToolsList:TFPList;
|
2009-07-06 16:26:45 +00:00
|
|
|
|
2014-06-14 07:16:52 +00:00
|
|
|
FOnSortChanged: TNotifyEvent;
|
2016-08-26 19:26:05 +00:00
|
|
|
FOnDataHintShow:TRxDBGridDataHintShowEvent;
|
2014-06-14 07:16:52 +00:00
|
|
|
|
2017-05-18 10:25:59 +00:00
|
|
|
FSaveOnDataSetScrolled: TDataSetScrolledEvent;
|
2017-05-26 13:05:56 +00:00
|
|
|
//Group data suppert
|
|
|
|
FGroupItems:TColumnGroupItems;
|
2017-05-18 10:25:59 +00:00
|
|
|
|
2009-08-17 17:50:27 +00:00
|
|
|
procedure DoCreateJMenu;
|
2007-08-09 21:36:59 +00:00
|
|
|
function GetColumns: TRxDbGridColumns;
|
2012-02-23 04:46:16 +00:00
|
|
|
function GetFooterColor: TColor;
|
|
|
|
function GetFooterRowCount: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
function GetPropertyStorage: TCustomPropertyStorage;
|
2012-05-12 17:51:20 +00:00
|
|
|
function GetSortField: string;
|
2012-09-21 17:06:21 +00:00
|
|
|
function GetSortOrder: TSortMarker;
|
2009-06-29 16:01:00 +00:00
|
|
|
function GetTitleButtons: boolean;
|
2007-08-09 21:36:59 +00:00
|
|
|
function IsColumnsStored: boolean;
|
2013-11-09 16:56:32 +00:00
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure SelectedFontChanged(Sender: TObject);
|
|
|
|
function IsSelectedFontStored: Boolean;
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure SetAutoSort(const AValue: boolean);
|
2015-09-07 07:42:04 +00:00
|
|
|
procedure SetColumnDefValues(AValue: TRxDBGridColumnDefValues);
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure SetColumns(const AValue: TRxDbGridColumns);
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure SetFooterColor(const AValue: TColor);
|
2012-02-23 04:46:16 +00:00
|
|
|
procedure SetFooterOptions(AValue: TRxDBGridFooterOptions);
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure SetFooterRowCount(const AValue: integer);
|
2010-05-19 15:33:28 +00:00
|
|
|
procedure SetKeyStrokes(const AValue: TRxDBGridKeyStrokes);
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure SetOptionsRx(const AValue: TOptionsRx);
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure SetPropertyStorage(const AValue: TCustomPropertyStorage);
|
2016-11-08 08:10:02 +00:00
|
|
|
procedure SetSearchOptions(AValue: TRxDBGridSearchOptions);
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure SetSelectedFont(AValue: TFont);
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure SetTitleButtons(const AValue: boolean);
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TrackButton(X, Y: integer);
|
|
|
|
function GetDrawFullLine: boolean;
|
|
|
|
procedure SetDrawFullLine(Value: boolean);
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure StopTracking;
|
|
|
|
procedure CalcTitle;
|
2009-06-29 16:01:00 +00:00
|
|
|
procedure ClearMLCaptionPointers;
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure FillDefaultFonts;
|
2011-05-07 14:48:11 +00:00
|
|
|
function getFilterRect(bRect: TRect): TRect;
|
|
|
|
function getTitleRect(bRect: TRect): TRect;
|
|
|
|
procedure OutCaptionCellText(aCol, aRow: integer; const aRect: TRect;
|
|
|
|
aState: TGridDrawState; const ACaption: string);
|
|
|
|
procedure OutCaptionCellText90(aCol, aRow: integer; const aRect: TRect;
|
|
|
|
aState: TGridDrawState; const ACaption: string;
|
|
|
|
const TextOrient: TTextOrientation);
|
2012-09-26 14:19:29 +00:00
|
|
|
procedure OutCaptionSortMarker(const aRect: TRect; ASortMarker: TSortMarker; ASortPosition:integer);
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure OutCaptionMLCellText(aCol, aRow: integer; aRect: TRect;
|
|
|
|
aState: TGridDrawState; MLI: TMLCaptionItem);
|
2009-08-06 16:59:07 +00:00
|
|
|
procedure UpdateJMenuStates;
|
2010-05-19 15:33:28 +00:00
|
|
|
procedure UpdateJMenuKeys;
|
2011-05-07 14:48:11 +00:00
|
|
|
function SortEngineOptions: TRxSortEngineOptions;
|
2011-10-12 13:35:03 +00:00
|
|
|
procedure GetScrollbarParams(out aRange, aPage, aPos: Integer);
|
|
|
|
procedure RestoreEditor;
|
2007-08-09 21:36:59 +00:00
|
|
|
//storage
|
|
|
|
procedure OnIniSave(Sender: TObject);
|
|
|
|
procedure OnIniLoad(Sender: TObject);
|
2011-12-23 19:13:50 +00:00
|
|
|
|
|
|
|
procedure CleanDSEvent;
|
2013-03-28 15:40:03 +00:00
|
|
|
|
2012-10-17 13:17:40 +00:00
|
|
|
|
2013-05-08 05:26:49 +00:00
|
|
|
function UpdateRowsHeight:integer;
|
2012-10-17 13:17:40 +00:00
|
|
|
procedure ResetRowHeght;
|
2013-03-12 14:08:34 +00:00
|
|
|
|
|
|
|
procedure DoClearInvalidTitle;
|
|
|
|
procedure DoDrawInvalidTitle;
|
2013-05-16 17:57:58 +00:00
|
|
|
procedure DoSetColEdtBtn;
|
2014-07-23 11:40:36 +00:00
|
|
|
procedure AddTools(ATools:TRxDBGridAbstractTools);
|
|
|
|
procedure RemoveTools(ATools:TRxDBGridAbstractTools);
|
2018-02-02 10:42:27 +00:00
|
|
|
procedure UpdateToolsState(ATools:TRxDBGridAbstractTools);
|
2017-05-18 10:25:59 +00:00
|
|
|
|
|
|
|
procedure OnDataSetScrolled(aDataSet:TDataSet; Distance: Integer);
|
2017-12-28 08:57:47 +00:00
|
|
|
procedure FillFilterData;
|
2021-02-20 08:27:49 +00:00
|
|
|
procedure DoCblClickMrOk;
|
2007-08-09 21:36:59 +00:00
|
|
|
protected
|
2015-06-17 08:09:34 +00:00
|
|
|
FRxDbGridLookupComboEditor: TCustomControl;
|
|
|
|
FRxDbGridDateEditor: TWinControl;
|
2017-06-20 12:38:18 +00:00
|
|
|
FGroupItemDrawCur:TColumnGroupItem;
|
2014-09-18 10:50:52 +00:00
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure CollumnSortListUpdate;
|
|
|
|
procedure CollumnSortListClear;
|
|
|
|
procedure CollumnSortListApply;
|
|
|
|
|
2014-04-09 17:33:24 +00:00
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function DatalinkActive: boolean;
|
2019-04-18 08:47:25 +00:00
|
|
|
function DataSetNotEmpty: boolean;
|
2013-05-16 17:57:58 +00:00
|
|
|
procedure AdjustEditorBounds(NewCol,NewRow:Integer); override;
|
2012-09-05 18:39:35 +00:00
|
|
|
procedure LinkActive(Value: Boolean); override;
|
|
|
|
|
2018-02-01 08:47:24 +00:00
|
|
|
function GetFieldDisplayText(AField:TField; ACollumn:TRxColumn):string;
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure DefaultDrawCellA(aCol, aRow: integer; aRect: TRect;
|
|
|
|
aState: TGridDrawState);
|
|
|
|
procedure DefaultDrawTitle(aCol, aRow: integer; aRect: TRect;
|
|
|
|
aState: TGridDrawState);
|
|
|
|
procedure DefaultDrawFilter(aCol, aRow: integer; aRect: TRect;
|
|
|
|
aState: TGridDrawState);
|
|
|
|
procedure DefaultDrawCellData(aCol, aRow: integer; aRect: TRect;
|
|
|
|
aState: TGridDrawState);
|
|
|
|
procedure DrawCell(aCol, aRow: integer; aRect: TRect; aState: TGridDrawState);
|
|
|
|
override;
|
2012-08-26 10:35:54 +00:00
|
|
|
procedure SetDBHandlers(Value: boolean);virtual;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure DrawRow(ARow: Integer); override;
|
|
|
|
procedure DrawFocusRect(aCol,aRow:Integer; ARect:TRect); override;
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure DrawFooterRows; virtual;
|
2018-02-01 08:47:24 +00:00
|
|
|
procedure DrawCellBitmap(RxColumn: TRxColumn; aRect: TRect;
|
|
|
|
aState: TGridDrawState; AImageIndex: integer); virtual;
|
2012-08-23 17:03:53 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure DoTitleClick(ACol: longint; ACollumn: TRxColumn; Shift: TShiftState); virtual;
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
|
2014-10-15 07:48:42 +00:00
|
|
|
procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
|
|
|
procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer); override;
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
2014-10-15 07:48:42 +00:00
|
|
|
procedure KeyPress(var Key: char); override;
|
2009-07-06 16:26:45 +00:00
|
|
|
procedure UTF8KeyPress(var UTF8Key: TUTF8Char); override;
|
2011-05-07 14:48:11 +00:00
|
|
|
function CreateColumns: TGridColumns; override;
|
|
|
|
procedure SetEditText(ACol, ARow: longint; const Value: string); override;
|
2014-10-15 07:48:42 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure ColRowMoved(IsColumn: boolean; FromIndex, ToIndex: integer); override;
|
|
|
|
procedure Paint; override;
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure MoveSelection; override;
|
2013-03-03 09:35:53 +00:00
|
|
|
function GetBufferCount: integer; override;
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure CMHintShow(var Message: TLMessage); message CM_HINTSHOW;
|
|
|
|
procedure FFilterListEditorOnChange(Sender: TObject);
|
|
|
|
procedure FFilterListEditorOnCloseUp(Sender: TObject);
|
2017-04-24 12:24:50 +00:00
|
|
|
procedure FFilterColDlgButtonOnClick(Sender: TObject);
|
2017-12-05 12:00:42 +00:00
|
|
|
procedure FFilterSimpleEditOnChange(Sender: TObject);
|
2017-04-24 12:24:50 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure InternalOptimizeColumnsWidth(AColList: TList);
|
2009-06-29 16:01:00 +00:00
|
|
|
procedure VisualChange; override;
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure EditorWidthChanged(aCol,aWidth: Integer); override;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure SetQuickUTF8Search(AValue: string);
|
2009-08-06 16:59:07 +00:00
|
|
|
procedure BeforeDel(DataSet: TDataSet);
|
|
|
|
procedure BeforePo(DataSet: TDataSet);
|
2014-10-15 07:48:42 +00:00
|
|
|
procedure ErrorDel(DataSet: TDataSet; E: EDatabaseError; var DataAction: TDataAction);
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure ErrorPo(DataSet: TDataSet; E: EDatabaseError; var DataAction: TDataAction);
|
|
|
|
procedure OnFind(Sender: TObject);
|
|
|
|
procedure OnFilterBy(Sender: TObject);
|
|
|
|
procedure OnFilter(Sender: TObject);
|
|
|
|
procedure OnFilterClose(Sender: TObject);
|
|
|
|
procedure OnSortBy(Sender: TObject);
|
|
|
|
procedure OnChooseVisibleFields(Sender: TObject);
|
2012-09-24 14:21:22 +00:00
|
|
|
procedure OnSelectAllRows(Sender: TObject);
|
2014-01-15 11:35:25 +00:00
|
|
|
procedure OnCopyCellValue(Sender: TObject);
|
2016-09-20 07:48:58 +00:00
|
|
|
procedure OnOptimizeColWidth(Sender: TObject);
|
2010-05-19 15:33:28 +00:00
|
|
|
procedure Loaded; override;
|
2012-04-15 21:22:58 +00:00
|
|
|
procedure UpdateFooterRowOnUpdateActive;
|
2012-08-23 17:03:53 +00:00
|
|
|
|
|
|
|
procedure DoEditorHide; override;
|
|
|
|
procedure DoEditorShow; override;
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure CheckNewCachedSizes(var AGCache:TGridDataCache); override;
|
2012-08-23 17:03:53 +00:00
|
|
|
|
2017-06-09 13:56:12 +00:00
|
|
|
function GetEditMask(aCol, aRow: Longint): string; override;
|
|
|
|
function GetEditText(aCol, aRow: Longint): string; override;
|
|
|
|
function GetDefaultEditor(Column: Integer): TWinControl; override;
|
|
|
|
|
2017-06-09 13:26:54 +00:00
|
|
|
procedure PrepareCanvas(aCol, aRow: Integer; AState: TGridDrawState); override;
|
2020-07-02 07:13:46 +00:00
|
|
|
function GetPopupMenu: TPopupMenu; override;
|
2017-09-19 05:43:18 +00:00
|
|
|
{$IFDEF DEVELOPER_RX}
|
|
|
|
procedure InternalAdjustRowCount(var RecCount:integer); override;
|
|
|
|
{$ENDIF}
|
2014-02-02 11:14:10 +00:00
|
|
|
property Editor;
|
2007-08-09 21:36:59 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
destructor Destroy; override;
|
2012-05-12 17:51:20 +00:00
|
|
|
|
2016-05-12 07:25:00 +00:00
|
|
|
procedure EraseBackground(DC: HDC); override;
|
2012-05-12 17:51:20 +00:00
|
|
|
procedure FilterRec(DataSet: TDataSet; var Accept: boolean);
|
2011-05-07 14:48:11 +00:00
|
|
|
function EditorByStyle(Style: TColumnButtonStyle): TWinControl; override;
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure LayoutChanged; override;
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure SetFocus; override;
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure ShowFindDialog;
|
|
|
|
procedure ShowColumnsDialog;
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure ShowSortDialog;
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure ShowFilterDialog;
|
2011-05-07 14:48:11 +00:00
|
|
|
function ColumnByFieldName(AFieldName: string): TRxColumn;
|
|
|
|
function ColumnByCaption(ACaption: string): TRxColumn;
|
2012-05-12 17:51:20 +00:00
|
|
|
procedure CalcStatTotals;
|
|
|
|
procedure OptimizeColumnsWidth(AColList: string);
|
|
|
|
procedure OptimizeColumnsWidthAll;
|
|
|
|
procedure UpdateTitleHight;
|
|
|
|
procedure GetOnCreateLookup;
|
|
|
|
procedure GetOnDisplayLookup;
|
2012-09-24 14:21:22 +00:00
|
|
|
procedure SelectAllRows;
|
|
|
|
procedure DeSelectAllRows;
|
|
|
|
procedure InvertSelection;
|
2014-02-04 16:58:30 +00:00
|
|
|
procedure CopyCellValue;
|
2017-05-30 08:25:18 +00:00
|
|
|
function CreateToolMenuItem(ShortCut: char; const ACaption: string; MenuAction: TNotifyEvent):TMenuItem;
|
|
|
|
procedure RemoveToolMenuItem(MenuAction: TNotifyEvent);
|
2012-05-12 17:51:20 +00:00
|
|
|
|
2017-06-13 11:29:31 +00:00
|
|
|
procedure CalcCellExtent(ACol, ARow: Integer; var ARect: TRect);
|
|
|
|
function IsMerged(ACol : Integer): Boolean; overload;
|
|
|
|
function IsMerged(ACol : Integer; out ALeft, ARight: Integer; out AColumn: TRxColumn): Boolean; overload;
|
|
|
|
|
2014-06-14 07:16:52 +00:00
|
|
|
procedure SetSort(AFields: array of String; ASortMarkers: array of TSortMarker; PreformSort: Boolean = False);
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
property Canvas;
|
|
|
|
property DefaultTextStyle;
|
|
|
|
property EditorBorderStyle;
|
|
|
|
property EditorMode;
|
|
|
|
property ExtendedColSizing;
|
|
|
|
property FastEditing;
|
|
|
|
property FocusRectVisible;
|
|
|
|
property SelectedRows;
|
2011-05-07 14:48:11 +00:00
|
|
|
property QuickUTF8Search: string read FQuickUTF8Search write SetQuickUTF8Search;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2012-05-12 17:51:20 +00:00
|
|
|
property SortField:string read GetSortField;
|
2012-09-21 17:06:21 +00:00
|
|
|
property SortOrder:TSortMarker read GetSortOrder;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
property SortColumns:TRxDbGridColumnsSortList read FSortColumns;
|
2017-05-26 13:05:56 +00:00
|
|
|
property GroupItems:TColumnGroupItems read FGroupItems;
|
2007-08-09 21:36:59 +00:00
|
|
|
published
|
2015-09-07 07:42:04 +00:00
|
|
|
property AfterQuickSearch: TRxQuickSearchNotifyEvent read FAfterQuickSearch write FAfterQuickSearch;
|
|
|
|
property ColumnDefValues:TRxDBGridColumnDefValues read FColumnDefValues write SetColumnDefValues;
|
|
|
|
property BeforeQuickSearch: TRxQuickSearchNotifyEvent read FBeforeQuickSearch write FBeforeQuickSearch;
|
|
|
|
property OnGetBtnParams: TGetBtnParamsEvent read FOnGetBtnParams write FOnGetBtnParams;
|
2009-06-29 16:01:00 +00:00
|
|
|
property TitleButtons: boolean read GetTitleButtons write SetTitleButtons;
|
2011-05-07 14:48:11 +00:00
|
|
|
property AutoSort: boolean read FAutoSort write SetAutoSort;
|
2015-09-07 07:42:04 +00:00
|
|
|
property OnGetCellProps: TGetCellPropsEvent read FOnGetCellProps write FOnGetCellProps;
|
|
|
|
property Columns: TRxDbGridColumns read GetColumns write SetColumns stored IsColumnsStored;
|
2011-05-07 14:48:11 +00:00
|
|
|
property KeyStrokes: TRxDBGridKeyStrokes read FKeyStrokes write SetKeyStrokes;
|
2012-02-23 04:46:16 +00:00
|
|
|
property FooterOptions:TRxDBGridFooterOptions read FFooterOptions write SetFooterOptions;
|
2016-11-08 08:10:02 +00:00
|
|
|
property SearchOptions:TRxDBGridSearchOptions read FSearchOptions write SetSearchOptions;
|
2017-05-18 11:16:05 +00:00
|
|
|
property OnCalcRowHeight:TRxDBGridCalcRowHeight read FOnCalcRowHeight write FOnCalcRowHeight;
|
2018-01-30 08:00:10 +00:00
|
|
|
property SelectedFont:TFont read FSelectedFont write SetSelectedFont stored IsSelectedFontStored;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
|
|
|
//storage
|
2015-09-07 07:42:04 +00:00
|
|
|
property PropertyStorage: TCustomPropertyStorage read GetPropertyStorage write SetPropertyStorage;
|
2011-05-07 14:48:11 +00:00
|
|
|
property Version: integer read FVersion write FVersion default 0;
|
|
|
|
property OptionsRx: TOptionsRx read FOptionsRx write SetOptionsRx;
|
2012-02-23 04:46:16 +00:00
|
|
|
property FooterColor: TColor read GetFooterColor write SetFooterColor default clWindow; deprecated;
|
|
|
|
property FooterRowCount: integer read GetFooterRowCount write SetFooterRowCount default 0; deprecated;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
property OnFiltred: TNotifyEvent read FOnFiltred write FOnFiltred;
|
2014-06-14 07:16:52 +00:00
|
|
|
property OnSortChanged: TNotifyEvent read FOnSortChanged write FOnSortChanged;
|
2020-03-24 13:25:48 +00:00
|
|
|
property BeforeSorting: TNotifyEvent read FBeforeSorting write FBeforeSorting;
|
2016-08-26 19:26:05 +00:00
|
|
|
property OnDataHintShow: TRxDBGridDataHintShowEvent read FOnDataHintShow write FOnDataHintShow;
|
2014-06-14 07:16:52 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
//from DBGrid
|
|
|
|
property Align;
|
|
|
|
property AlternateColor;
|
|
|
|
property Anchors;
|
|
|
|
property AutoAdvance default aaRightDown;
|
|
|
|
property AutoFillColumns;
|
2008-01-28 05:21:43 +00:00
|
|
|
property AutoEdit;
|
2009-07-08 15:44:33 +00:00
|
|
|
property BiDiMode;
|
2007-08-09 21:36:59 +00:00
|
|
|
property BorderSpacing;
|
|
|
|
property BorderStyle;
|
|
|
|
property Color;
|
2016-11-02 13:57:10 +00:00
|
|
|
property CellHintPriority;
|
2007-08-10 22:15:51 +00:00
|
|
|
property BorderColor;
|
2016-05-05 06:49:18 +00:00
|
|
|
property DrawFullLine: boolean read GetDrawFullLine write SetDrawFullLine; deprecated;
|
2007-08-10 22:15:51 +00:00
|
|
|
property FocusColor;
|
2008-02-21 11:51:39 +00:00
|
|
|
property FixedHotColor;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
property SelectedColor;
|
|
|
|
property GridLineColor;
|
|
|
|
property GridLineStyle;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
property Constraints;
|
|
|
|
property DataSource;
|
|
|
|
property DefaultDrawing;
|
2017-05-18 10:25:59 +00:00
|
|
|
property DefaultRowHeight;
|
2018-10-23 10:42:44 +00:00
|
|
|
property DoubleBuffered;
|
2014-07-10 07:33:19 +00:00
|
|
|
|
|
|
|
property DefaultColWidth;
|
|
|
|
|
2009-07-08 15:44:33 +00:00
|
|
|
property DragCursor;
|
|
|
|
property DragKind;
|
|
|
|
property DragMode;
|
2007-08-09 21:36:59 +00:00
|
|
|
property Enabled;
|
|
|
|
property FixedColor;
|
2009-07-08 15:44:33 +00:00
|
|
|
property FixedCols;
|
2007-08-09 21:36:59 +00:00
|
|
|
property Flat;
|
|
|
|
property Font;
|
2008-01-28 05:21:43 +00:00
|
|
|
property HeaderHotZones;
|
|
|
|
property HeaderPushZones;
|
2007-08-09 21:36:59 +00:00
|
|
|
//property ImeMode;
|
|
|
|
//property ImeName;
|
|
|
|
property Options;
|
2018-10-23 10:42:44 +00:00
|
|
|
property Options2;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OptionsExtra;
|
2009-07-08 15:44:33 +00:00
|
|
|
property ParentBiDiMode;
|
2017-05-18 10:25:59 +00:00
|
|
|
property ParentColor default false;
|
2018-10-23 10:42:44 +00:00
|
|
|
property ParentDoubleBuffered;
|
2007-08-09 21:36:59 +00:00
|
|
|
//property ParentCtl3D;
|
|
|
|
property ParentFont;
|
2009-07-08 15:44:33 +00:00
|
|
|
property ParentShowHint;
|
2007-08-09 21:36:59 +00:00
|
|
|
property PopupMenu;
|
|
|
|
property ReadOnly;
|
2008-01-28 05:21:43 +00:00
|
|
|
property Scrollbars default ssBoth;
|
2007-08-09 21:36:59 +00:00
|
|
|
property ShowHint;
|
|
|
|
property TabOrder;
|
|
|
|
property TabStop;
|
2016-11-02 13:57:10 +00:00
|
|
|
property TabAdvance;
|
2007-08-09 21:36:59 +00:00
|
|
|
property TitleFont;
|
2010-01-23 07:14:50 +00:00
|
|
|
property TitleImageList;
|
2007-08-09 21:36:59 +00:00
|
|
|
property TitleStyle;
|
2010-01-23 07:14:50 +00:00
|
|
|
property UseXORFeatures;
|
2007-08-09 21:36:59 +00:00
|
|
|
property Visible;
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnCellClick;
|
|
|
|
property OnColEnter;
|
|
|
|
property OnColExit;
|
|
|
|
property OnColumnMoved;
|
2007-10-17 10:19:26 +00:00
|
|
|
property OnColumnSized;
|
2017-05-18 10:25:59 +00:00
|
|
|
property OnContextPopup;
|
2007-10-17 10:19:26 +00:00
|
|
|
property OnDragDrop;
|
|
|
|
property OnDragOver;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnDrawColumnCell;
|
|
|
|
property OnDblClick;
|
|
|
|
property OnEditButtonClick;
|
2014-02-02 06:02:22 +00:00
|
|
|
property OnEditingDone;
|
2009-07-08 15:44:33 +00:00
|
|
|
property OnEndDock;
|
2007-10-17 10:19:26 +00:00
|
|
|
property OnEndDrag;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnEnter;
|
|
|
|
property OnExit;
|
|
|
|
property OnFieldEditMask;
|
2017-05-18 10:25:59 +00:00
|
|
|
property OnGetCellHint;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnKeyDown;
|
|
|
|
property OnKeyPress;
|
|
|
|
property OnKeyUp;
|
|
|
|
property OnMouseDown;
|
|
|
|
property OnMouseMove;
|
|
|
|
property OnMouseUp;
|
2016-01-21 13:50:25 +00:00
|
|
|
property OnMouseEnter;
|
|
|
|
property OnMouseLeave;
|
2014-09-29 07:02:18 +00:00
|
|
|
property OnMouseWheel;
|
|
|
|
property OnMouseWheelDown;
|
|
|
|
property OnMouseWheelUp;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnPrepareCanvas;
|
2007-10-17 10:19:26 +00:00
|
|
|
property OnSelectEditor;
|
2009-07-08 15:44:33 +00:00
|
|
|
property OnStartDock;
|
2007-10-17 10:19:26 +00:00
|
|
|
property OnStartDrag;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnTitleClick;
|
2014-07-28 12:25:45 +00:00
|
|
|
property OnRxCalcFooterValues: TOnRxCalcFooterValues read FOnRxCalcFooterValues write FOnRxCalcFooterValues;
|
2015-09-07 07:42:04 +00:00
|
|
|
property OnRxColumnFooterDraw: TOnRxColumnFooterDraw read FOnRxColumnFooterDraw write FOnRxColumnFooterDraw;
|
2007-08-09 21:36:59 +00:00
|
|
|
property OnUserCheckboxBitmap;
|
2019-11-20 09:54:00 +00:00
|
|
|
{$IF LCL_FullVersion >= 2010000}
|
2019-03-06 05:44:57 +00:00
|
|
|
property OnUserCheckboxImage;
|
2019-11-20 09:54:00 +00:00
|
|
|
{$IFEND}
|
2014-09-11 09:35:53 +00:00
|
|
|
property OnUserCheckboxState;
|
2008-09-17 11:18:28 +00:00
|
|
|
property OnUTF8KeyPress;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2014-09-11 09:35:53 +00:00
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
property OnCreateLookup: TCreateLookup read F_CreateLookup write F_CreateLookup;
|
|
|
|
property OnDisplayLookup: TDisplayLookup read F_DisplayLookup write F_DisplayLookup;
|
2017-06-09 13:26:54 +00:00
|
|
|
property OnMergeCells:TRxDBGridMergeCellsEvent read FOnMergeCells write FOnMergeCells;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
{ TRxDBGridAbstractTools }
|
2015-05-25 10:12:12 +00:00
|
|
|
TRxDBGridToolsEvent = (rxteMouseDown, rxteMouseUp, rxteMouseMove, rxteKeyDown, rxteKeyUp);
|
|
|
|
TRxDBGridToolsEvents = set of TRxDBGridToolsEvent;
|
2014-07-23 11:40:36 +00:00
|
|
|
|
|
|
|
TRxDBGridAbstractTools = class(TComponent)
|
|
|
|
private
|
2018-02-02 10:42:27 +00:00
|
|
|
FEnabled: boolean;
|
2014-07-23 11:40:36 +00:00
|
|
|
FOnAfterExecute: TNotifyEvent;
|
|
|
|
FOnBeforeExecute: TNotifyEvent;
|
2014-07-25 11:53:30 +00:00
|
|
|
FShowSetupForm: boolean;
|
2014-07-23 11:40:36 +00:00
|
|
|
procedure ExecTools(Sender:TObject);
|
2018-02-02 10:42:27 +00:00
|
|
|
procedure SetEnabled(AValue: boolean);
|
2014-07-23 11:40:36 +00:00
|
|
|
protected
|
|
|
|
FRxDBGrid: TRxDBGrid;
|
|
|
|
FCaption:string;
|
2015-05-25 10:12:12 +00:00
|
|
|
FToolsEvents:TRxDBGridToolsEvents;
|
2014-07-23 11:40:36 +00:00
|
|
|
procedure SetRxDBGrid(AValue: TRxDBGrid);
|
|
|
|
function DoExecTools:boolean; virtual;
|
2014-07-25 11:53:30 +00:00
|
|
|
function DoSetupTools:boolean; virtual;
|
2015-05-25 10:12:12 +00:00
|
|
|
function MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer):boolean; virtual;
|
2017-05-30 07:49:41 +00:00
|
|
|
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
|
2014-07-23 11:40:36 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
2015-05-25 10:12:12 +00:00
|
|
|
destructor Destroy; override;
|
2014-07-23 11:40:36 +00:00
|
|
|
function Execute:boolean;
|
|
|
|
published
|
|
|
|
property RxDBGrid:TRxDBGrid read FRxDBGrid write SetRxDBGrid;
|
|
|
|
property Caption:string read FCaption write FCaption;
|
2014-07-25 11:53:30 +00:00
|
|
|
property ShowSetupForm:boolean read FShowSetupForm write FShowSetupForm default false;
|
2014-07-23 11:40:36 +00:00
|
|
|
property OnBeforeExecute:TNotifyEvent read FOnBeforeExecute write FOnBeforeExecute;
|
|
|
|
property OnAfterExecute:TNotifyEvent read FOnAfterExecute write FOnAfterExecute;
|
2018-02-02 10:42:27 +00:00
|
|
|
property Enabled:boolean read FEnabled write SetEnabled default true;
|
2014-07-23 11:40:36 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure RegisterRxDBGridSortEngine(RxDBGridSortEngineClass: TRxDBGridSortEngineClass;
|
2012-09-27 14:27:35 +00:00
|
|
|
DataSetClassName: string);
|
2007-08-09 21:36:59 +00:00
|
|
|
|
|
|
|
implementation
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2018-05-08 12:31:39 +00:00
|
|
|
uses Math, rxdateutil, rxdconst, rxstrutils, rxutils, strutils, rxdbgrid_findunit, Themes,
|
2017-06-09 13:26:54 +00:00
|
|
|
rxdbgrid_columsunit, RxDBGrid_PopUpFilterUnit, rxlookup, rxtooledit, LCLProc,
|
2018-05-08 12:31:39 +00:00
|
|
|
Clipbrd, rxfilterby, rxsortby, variants, LazUTF8, DateUtils;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2016-05-11 12:44:15 +00:00
|
|
|
{$R rxdbgrid.res}
|
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
const
|
2014-01-15 11:35:25 +00:00
|
|
|
EditorCommandStrs: array[rxgcNone .. High(TRxDBGridCommand)] of TIdentMapEntry =
|
2011-05-07 14:48:11 +00:00
|
|
|
(
|
|
|
|
(Value: Ord(rxgcNone); Name: 'rxcgNone'),
|
|
|
|
(Value: Ord(rxgcShowFindDlg); Name: 'rxgcShowFindDlg'),
|
|
|
|
(Value: Ord(rxgcShowColumnsDlg); Name: 'rxgcShowColumnsDlg'),
|
|
|
|
(Value: Ord(rxgcShowFilterDlg); Name: 'rxgcShowFilterDlg'),
|
|
|
|
(Value: Ord(rxgcShowSortDlg); Name: 'rxgcShowSortDlg'),
|
|
|
|
(Value: Ord(rxgcShowQuickFilter); Name: 'rxgcShowQuickFilter'),
|
2012-09-24 14:21:22 +00:00
|
|
|
(Value: Ord(rxgcHideQuickFilter); Name: 'rxgcHideQuickFilter'),
|
|
|
|
(Value: Ord(rxgcSelectAll); Name: 'rxgcSelectAll'),
|
|
|
|
(Value: Ord(rxgcDeSelectAll); Name: 'rxgcDeSelectAll'),
|
|
|
|
(Value: Ord(rxgcInvertSelection); Name: 'rxgcInvertSelection'),
|
2014-01-15 11:35:25 +00:00
|
|
|
(Value: Ord(rxgcOptimizeColumnsWidth); Name: 'rxgcOptimizeColumnsWidth'),
|
|
|
|
(Value: Ord(rxgcCopyCellValue); Name: 'rxgcCopyCellValue')
|
2011-05-07 14:48:11 +00:00
|
|
|
);
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
var
|
|
|
|
RxDBGridSortEngineList: TStringList;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2016-05-11 12:44:15 +00:00
|
|
|
FMarkerUp : TBitmap = nil;
|
|
|
|
FMarkerDown : TBitmap = nil;
|
|
|
|
FEllipsisRxBMP: TBitmap = nil;
|
|
|
|
FGlyphRxBMP: TBitmap = nil;
|
|
|
|
FUpDownRxBMP: TBitmap = nil;
|
|
|
|
FPlusRxBMP: TBitmap = nil;
|
|
|
|
FMinusRxBMP: TBitmap = nil;
|
|
|
|
|
|
|
|
|
2012-09-27 14:27:35 +00:00
|
|
|
procedure RegisterRxDBGridSortEngine(
|
|
|
|
RxDBGridSortEngineClass: TRxDBGridSortEngineClass; DataSetClassName: string);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
Pos: integer;
|
|
|
|
RxDBGridSortEngine: TRxDBGridSortEngine;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-09-27 14:27:35 +00:00
|
|
|
if not RxDBGridSortEngineList.Find(DataSetClassName, Pos) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
RxDBGridSortEngine := RxDBGridSortEngineClass.Create;
|
2012-09-27 14:27:35 +00:00
|
|
|
RxDBGridSortEngineList.AddObject(DataSetClassName, RxDBGridSortEngine);
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure GridInvalidateRow(Grid: TRxDBGrid; Row: longint);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
I: longint;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
for I := 0 to Grid.ColCount - 1 do
|
|
|
|
Grid.InvalidateCell(I, Row);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2013-03-29 18:17:29 +00:00
|
|
|
type
|
|
|
|
THackDataSet = class(TDataSet);
|
|
|
|
|
|
|
|
|
2007-11-06 11:15:05 +00:00
|
|
|
type
|
|
|
|
|
|
|
|
{ TRxDBGridLookupComboEditor }
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
TRxDBGridLookupComboEditor = class(TRxCustomDBLookupCombo)
|
2007-11-06 11:15:05 +00:00
|
|
|
private
|
|
|
|
FGrid: TRxDBGrid;
|
2011-05-07 14:48:11 +00:00
|
|
|
FCol, FRow: integer;
|
|
|
|
FLDS: TDataSource;
|
2007-11-06 11:15:05 +00:00
|
|
|
protected
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure WndProc(var TheMessage: TLMessage); override;
|
|
|
|
procedure KeyDown(var Key: word; Shift: TShiftState); override;
|
2007-11-06 11:15:05 +00:00
|
|
|
procedure msg_SetGrid(var Msg: TGridMessage); message GM_SETGRID;
|
|
|
|
procedure msg_SetValue(var Msg: TGridMessage); message GM_SETVALUE;
|
2012-09-20 14:02:20 +00:00
|
|
|
procedure msg_GetValue(var Msg: TGridMessage); message GM_GETVALUE;
|
2012-09-19 14:06:46 +00:00
|
|
|
procedure OnInternalClosePopup(AResult:boolean);override;
|
2012-09-20 14:02:20 +00:00
|
|
|
procedure ShowList; override;
|
2007-11-06 11:15:05 +00:00
|
|
|
public
|
|
|
|
constructor Create(AOwner: TComponent); override;
|
|
|
|
destructor Destroy; override;
|
|
|
|
end;
|
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
{ TRxDBGridDateEditor }
|
|
|
|
TRxDBGridDateEditor = class(TCustomRxDateEdit)
|
|
|
|
private
|
|
|
|
FGrid: TRxDBGrid;
|
2011-05-07 14:48:11 +00:00
|
|
|
FCol, FRow: integer;
|
2008-01-31 13:23:03 +00:00
|
|
|
protected
|
2014-04-09 17:33:24 +00:00
|
|
|
procedure EditChange; override;
|
2019-08-23 07:24:28 +00:00
|
|
|
procedure EditKeyDown(var Key: word; Shift: TShiftState); override;
|
2008-01-31 13:23:03 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure WndProc(var TheMessage: TLMessage); override;
|
2008-01-31 13:23:03 +00:00
|
|
|
procedure msg_SetGrid(var Msg: TGridMessage); message GM_SETGRID;
|
|
|
|
procedure msg_SetValue(var Msg: TGridMessage); message GM_SETVALUE;
|
|
|
|
procedure msg_GetValue(var Msg: TGridMessage); message GM_GETVALUE;
|
|
|
|
procedure msg_SelectAll(var Msg: TGridMessage); message GM_SELECTALL;
|
|
|
|
|
|
|
|
public
|
2011-09-22 17:07:49 +00:00
|
|
|
constructor Create(Aowner : TComponent); override;
|
2008-01-31 13:23:03 +00:00
|
|
|
procedure EditingDone; override;
|
|
|
|
end;
|
|
|
|
|
2017-12-05 12:00:42 +00:00
|
|
|
{ TFilterSimpleEdit }
|
|
|
|
|
|
|
|
procedure TFilterSimpleEdit.WndProc(var TheMessage: TLMessage);
|
|
|
|
begin
|
|
|
|
if TheMessage.msg = LM_KILLFOCUS then
|
|
|
|
begin
|
|
|
|
Change;
|
|
|
|
Hide;
|
|
|
|
if HWND(TheMessage.WParam) = HWND(Handle) then
|
|
|
|
begin
|
|
|
|
// lost the focus but it returns to ourselves
|
|
|
|
// eat the message.
|
|
|
|
TheMessage.Result := 0;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
inherited WndProc(TheMessage);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TFilterSimpleEdit.KeyDown(var Key: word; Shift: TShiftState);
|
|
|
|
begin
|
|
|
|
inherited KeyDown(Key, Shift);
|
|
|
|
case Key of
|
|
|
|
VK_RETURN:
|
|
|
|
begin
|
|
|
|
Change;
|
|
|
|
Hide;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TFilterSimpleEdit.Show(Grid: TCustomGrid; Col: integer);
|
|
|
|
begin
|
|
|
|
FGrid := Grid;
|
|
|
|
FCol := Col;
|
|
|
|
Visible := True;
|
|
|
|
SetFocus;
|
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
{ TRxColumnGroupParam }
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure TRxColumnGroupParam.FontChanged(Sender: TObject);
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
2018-01-30 08:00:10 +00:00
|
|
|
FisDefaultFont := FFont.IsDefault;
|
2017-05-26 13:05:56 +00:00
|
|
|
FColumn.ColumnChanged;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
function TRxColumnGroupParam.GetDisplayText: string;
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
case FValueType of
|
|
|
|
fvtCount : Result := GetRecordsCount;
|
|
|
|
fvtSum,
|
|
|
|
fvtAvg,
|
|
|
|
fvtMax,
|
|
|
|
fvtMin : Result := GetGroupTotal;
|
|
|
|
fvtRecNo : Result := GetRecNo;
|
|
|
|
fvtStaticText:Result := FStaticText;
|
|
|
|
fvtFieldValue:Result := GetGroupValue;
|
|
|
|
else
|
|
|
|
//fvtNon,
|
|
|
|
Result:='';
|
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
function TRxColumnGroupParam.GetFont: TFont;
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
Result := FFont;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.IsFontStored: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not FisDefaultFont;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.SetAlignment(AValue: TAlignment);
|
|
|
|
begin
|
|
|
|
if FAlignment=AValue then Exit;
|
|
|
|
FAlignment:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.SetColor(AValue: TColor);
|
|
|
|
begin
|
|
|
|
if FColor=AValue then Exit;
|
|
|
|
FColor:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.SetDisplayFormat(AValue: string);
|
|
|
|
begin
|
|
|
|
if FDisplayFormat=AValue then Exit;
|
|
|
|
FDisplayFormat:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.SetFont(AValue: TFont);
|
|
|
|
begin
|
|
|
|
if not FFont.IsEqual(AValue) then
|
|
|
|
FFont.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.SetLayout(AValue: TTextLayout);
|
|
|
|
begin
|
|
|
|
if FLayout=AValue then Exit;
|
|
|
|
FLayout:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.SetStaticText(AValue: string);
|
|
|
|
begin
|
|
|
|
if FStaticText=AValue then Exit;
|
|
|
|
FStaticText:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.GetGroupItems: TColumnGroupItem;
|
|
|
|
begin
|
|
|
|
Result:=nil;
|
|
|
|
if TRxDBGrid(FColumn.Grid).DatalinkActive then
|
|
|
|
Result:=TRxDBGrid(FColumn.Grid).FGroupItemDrawCur;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.GetGroupItem: TColumnGroupItemValue;
|
|
|
|
var
|
|
|
|
FCGDI: TColumnGroupItem;
|
|
|
|
begin
|
|
|
|
Result:=nil;
|
|
|
|
if TRxDBGrid(FColumn.Grid).DatalinkActive then
|
|
|
|
begin
|
|
|
|
FCGDI:=TRxDBGrid(FColumn.Grid).FGroupItemDrawCur;
|
|
|
|
if Assigned(FCGDI) then
|
|
|
|
Result:=FCGDI.GetItems(FColumn.FieldName);
|
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.GetRecordsCount: string;
|
|
|
|
var
|
|
|
|
V: TColumnGroupItem;
|
|
|
|
begin
|
|
|
|
V:=GetGroupItems;
|
|
|
|
if Assigned(V) then
|
|
|
|
begin
|
|
|
|
if DisplayFormat <> '' then
|
|
|
|
Result := Format(DisplayFormat, [V.RecordCount])
|
|
|
|
else
|
|
|
|
Result := IntToStr(V.RecordCount);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.GetGroupTotal: string;
|
|
|
|
var
|
|
|
|
V: TColumnGroupItemValue;
|
|
|
|
F: TField;
|
|
|
|
begin
|
|
|
|
V:=GetGroupItem;
|
|
|
|
if Assigned(V) then
|
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FColumn.Grid).DataSource.DataSet.FieldByName(FColumn.FieldName);
|
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
|
|
|
if F.DataType in [ftSmallint, ftInteger, ftWord, ftFloat, ftCurrency,
|
2019-10-28 10:09:21 +00:00
|
|
|
ftDate, ftTime, ftDateTime, ftTimeStamp, ftLargeint, ftBCD, ftFMTBcd] then
|
2017-05-26 13:05:56 +00:00
|
|
|
begin
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
if FValueType in [fvtSum, fvtAvg] then
|
|
|
|
Result := ''
|
|
|
|
else
|
|
|
|
if V.GroupValue = 0 then
|
|
|
|
Result := ''
|
|
|
|
else
|
|
|
|
if FDisplayFormat = '' then
|
|
|
|
Result := DateToStr(V.GroupValue)
|
|
|
|
else
|
|
|
|
Result := FormatDateTime(FDisplayFormat, V.GroupValue);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if F.DataType in [ftSmallint, ftInteger, ftWord, ftLargeint] then
|
|
|
|
begin
|
|
|
|
if FDisplayFormat = '' then
|
|
|
|
Result := IntToStr(Round(V.GroupValue))
|
|
|
|
else
|
|
|
|
Result := FormatFloat(FDisplayFormat, V.GroupValue);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if FDisplayFormat <> '' then
|
|
|
|
Result := FormatFloat(FDisplayFormat, V.GroupValue)
|
|
|
|
else
|
|
|
|
if F.DataType = ftCurrency then
|
|
|
|
Result := FloatToStrF(V.GroupValue, ffCurrency, 12, 2)
|
|
|
|
else
|
|
|
|
Result := FloatToStr(V.GroupValue);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.GetGroupValue: string;
|
|
|
|
var
|
|
|
|
V: TColumnGroupItem;
|
|
|
|
begin
|
|
|
|
V:=GetGroupItems;
|
|
|
|
if Assigned(V) then
|
|
|
|
Result := V.FieldValue
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnGroupParam.GetRecNo: string;
|
|
|
|
var
|
|
|
|
V: TColumnGroupItem;
|
|
|
|
begin
|
|
|
|
V:=GetGroupItems;
|
|
|
|
if Assigned(V) then
|
|
|
|
begin
|
|
|
|
if DisplayFormat <> '' then
|
|
|
|
Result := Format(DisplayFormat, [V.RecordNo])
|
|
|
|
else
|
|
|
|
Result := IntToStr(V.RecordNo);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxColumnGroupParam.Create(AColumn: TRxColumn);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FColumn:=AColumn;
|
|
|
|
FValueType:=fvtNon;
|
|
|
|
FAlignment:=taLeftJustify;
|
|
|
|
FLayout := tlCenter;
|
|
|
|
FColor:=clNone;
|
|
|
|
|
|
|
|
FFont := TFont.Create;
|
|
|
|
FillDefaultFont;
|
|
|
|
FFont.OnChange := @FontChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxColumnGroupParam.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FFont);
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.FillDefaultFont;
|
|
|
|
var
|
|
|
|
AGrid: TCustomGrid;
|
|
|
|
begin
|
|
|
|
if not Assigned(FColumn) then exit;
|
|
|
|
AGrid := FColumn.Grid;
|
|
|
|
if (AGrid<>nil) then
|
|
|
|
begin
|
|
|
|
FFont.Assign(AGrid.Font);
|
|
|
|
FIsDefaultFont := True;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnGroupParam.UpdateValues;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
V: TColumnGroupItemValue;
|
|
|
|
begin
|
|
|
|
if (ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and (FColumn.FieldName <> '') then
|
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FColumn.Grid).DataSource.DataSet.FindField(FColumn.FieldName);
|
|
|
|
V:=TRxDBGrid(FColumn.Grid).FGroupItems.FCurItem.Items[FColumn.FieldName];
|
|
|
|
if not Assigned(V) then
|
|
|
|
V:=TRxDBGrid(FColumn.Grid).FGroupItems.FCurItem.AddItem(FColumn.FieldName);
|
|
|
|
if Assigned(F) and Assigned(V) then
|
|
|
|
begin
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtMax: V.GroupValue := Max(V.GroupValue, F.AsDateTime);
|
|
|
|
fvtMin: V.GroupValue := Min(V.GroupValue, F.AsDateTime);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtAvg,
|
|
|
|
fvtSum: V.GroupValue := V.GroupValue + F.AsFloat;
|
|
|
|
fvtMax: V.GroupValue := Max(V.GroupValue, F.AsFloat);
|
|
|
|
fvtMin: V.GroupValue := Min(V.GroupValue, F.AsFloat);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ TRxColumnFooterItemsEnumerator }
|
|
|
|
|
|
|
|
constructor TRxColumnFooterItemsEnumerator.Create(AList: TRxColumnFooterItems);
|
|
|
|
begin
|
|
|
|
FList := AList;
|
|
|
|
FPosition := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItemsEnumerator.GetCurrent: TRxColumnFooterItem;
|
|
|
|
begin
|
|
|
|
Result := FList[FPosition];
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItemsEnumerator.MoveNext: Boolean;
|
|
|
|
begin
|
|
|
|
Inc(FPosition);
|
|
|
|
Result := FPosition < FList.Count;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TColumnGroupItems }
|
|
|
|
|
|
|
|
procedure TColumnGroupItems.SetActive(AValue: boolean);
|
|
|
|
begin
|
|
|
|
if FActive=AValue then Exit;
|
|
|
|
FActive:=AValue;
|
2017-05-26 13:05:56 +00:00
|
|
|
if FActive then
|
|
|
|
begin
|
|
|
|
FRxDBGrid.CalcStatTotals;
|
2017-06-08 11:16:02 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
FRxDBGrid.UpdateRowsHeight;
|
2017-05-26 13:05:56 +00:00
|
|
|
FRxDBGrid.VisualChange;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure TColumnGroupItems.SetColor(AValue: TColor);
|
|
|
|
begin
|
|
|
|
if FColor=AValue then Exit;
|
|
|
|
FColor:=AValue;
|
|
|
|
FRxDBGrid.Invalidate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TColumnGroupItems.Create(ARxDBGrid: TRxDBGrid);
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FActive:=false;
|
2017-05-26 13:05:56 +00:00
|
|
|
FList:=TFPList.Create;
|
|
|
|
FRxDBGrid:=ARxDBGrid;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TColumnGroupItems.Destroy;
|
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
Clear;
|
|
|
|
FreeAndNil(FList);
|
2017-05-18 13:58:44 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
function TColumnGroupItems.FindGroupItem(ARecBookMark: TBookMark
|
|
|
|
): TColumnGroupItem;
|
|
|
|
var
|
|
|
|
S, E, i: Integer;
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
|
|
|
Result:=nil;
|
2017-05-26 13:05:56 +00:00
|
|
|
if FList.Count = 0 then exit;
|
|
|
|
S:=0;
|
|
|
|
E:=FList.Count - 1;
|
|
|
|
{
|
|
|
|
while (S<=E) do
|
|
|
|
begin
|
|
|
|
i:=(E+S) div 2;
|
|
|
|
if (TColumnGroupItem(FList[i]).RecordNo = ARecordNo) then
|
|
|
|
begin
|
|
|
|
Result:=TColumnGroupItem(FList[i]);
|
|
|
|
Exit;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (TColumnGroupItem(FList[i]).RecordNo > ARecordNo) then E:=i-1
|
|
|
|
else S:=i+1;
|
|
|
|
end; }
|
|
|
|
|
|
|
|
for i:=0 to FList.Count-1 do
|
|
|
|
if FRxDBGrid.DataSource.DataSet.CompareBookmarks(TColumnGroupItem(FList[i]).RecBookMark, ARecBookMark) = 0 then
|
|
|
|
exit(TColumnGroupItem(FList[i]))
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TColumnGroupItems.Clear;
|
2017-05-26 13:05:56 +00:00
|
|
|
var
|
|
|
|
i: Integer;
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
for i:=0 to FList.Count-1 do
|
|
|
|
TColumnGroupItem(FList[i]).Free;
|
|
|
|
FList.Clear;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TColumnGroupItems.UpdateValues;
|
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
if not Assigned(FGroupField) then Exit;
|
|
|
|
if (FCurrentValue <> FGroupField.DisplayText) or (not Assigned(FCurItem)) then
|
|
|
|
begin
|
|
|
|
DoneGroup;
|
|
|
|
FCurItem:=AddGroupItem;
|
|
|
|
FCurrentValue:=FGroupField.DisplayText;
|
|
|
|
FCurItem.RecordCount:=1;
|
|
|
|
FCurItem.RecordNo:=FRxDBGrid.DataSource.DataSet.RecNo;
|
|
|
|
FCurItem.RecBookMark:=FRxDBGrid.DataSource.DataSet.Bookmark;
|
|
|
|
FCurItem.FieldValue:=FCurrentValue;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Inc(FCurItem.RecordCount);
|
|
|
|
FCurItem.RecordNo:=FRxDBGrid.DataSource.DataSet.RecNo;
|
|
|
|
FCurItem.RecBookMark:=FRxDBGrid.DataSource.DataSet.Bookmark;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TColumnGroupItems.AddGroupItem: TColumnGroupItem;
|
|
|
|
begin
|
|
|
|
Result:=TColumnGroupItem.Create;
|
|
|
|
FList.Add(Result);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TColumnGroupItems.InitGroup;
|
|
|
|
begin
|
|
|
|
if (FRxDBGrid.DataSource.DataSet.RecordCount > 0) and (FGroupFieldName <> '') then
|
|
|
|
begin
|
|
|
|
FGroupField:=FRxDBGrid.DataSource.DataSet.FieldByName(FGroupFieldName);
|
|
|
|
FCurrentValue:=FGroupField.DisplayText;
|
|
|
|
end;
|
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure TColumnGroupItems.DoneGroup;
|
|
|
|
begin
|
|
|
|
{ TODO : Необходимо список закладок отсортировать }
|
|
|
|
if Assigned(FCurItem) then
|
|
|
|
begin
|
|
|
|
//FCurItem.RecordNo:=FRxDBGrid.DataSource.DataSet.RecNo;
|
|
|
|
//FCurItem.RecordNo:=PtrInt(FRxDBGrid.DataSource.DataSet.ActiveBuffer);
|
|
|
|
//FList.Sort(@DoListSortCompare);
|
|
|
|
//FCurItem.RecordNo:=FRxDBGrid.DataSource.DataSet.Bookmark;
|
|
|
|
end;
|
|
|
|
FCurItem:=nil;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
{ TColumnGroupItem }
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
function TColumnGroupItem.GetItems(FieldName: string): TColumnGroupItemValue;
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
Result:=nil;
|
|
|
|
for i:=0 to FValues.Count-1 do
|
|
|
|
if TColumnGroupItemValue(FValues[i]).FieldName = FieldName then
|
|
|
|
Exit(TColumnGroupItemValue(FValues[i]));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TColumnGroupItem.ClearValues;
|
|
|
|
var
|
|
|
|
i: Integer;
|
2017-05-18 13:58:44 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
for i:=0 to FValues.Count-1 do
|
|
|
|
TColumnGroupItemValue(FValues[i]).Free;
|
|
|
|
FValues.Clear;
|
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
function TColumnGroupItem.AddItem(AFieldName: string): TColumnGroupItemValue;
|
|
|
|
begin
|
|
|
|
Result:=TColumnGroupItemValue.Create;
|
|
|
|
FValues.Add(Result);
|
|
|
|
Result.FieldName:=AFieldName;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TColumnGroupItem.Create;
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FValues:=TFPList.Create;
|
2017-05-18 13:58:44 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TColumnGroupItem.Destroy;
|
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
ClearValues;
|
|
|
|
FreeAndNil(FValues);
|
2017-05-18 13:58:44 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2017-04-24 12:44:17 +00:00
|
|
|
{ TRxDbGridColumnsEnumerator }
|
|
|
|
|
|
|
|
constructor TRxDbGridColumnsEnumerator.Create(AList: TRxDbGridColumns);
|
|
|
|
begin
|
|
|
|
FList := AList;
|
|
|
|
FPosition := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDbGridColumnsEnumerator.GetCurrent: TRxColumn;
|
|
|
|
begin
|
|
|
|
Result := FList[FPosition];
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDbGridColumnsEnumerator.MoveNext: Boolean;
|
|
|
|
begin
|
|
|
|
Inc(FPosition);
|
|
|
|
Result := FPosition < FList.Count;
|
|
|
|
end;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
{ TFilterColDlgButton }
|
|
|
|
|
|
|
|
procedure TFilterColDlgButton.Show(AGrid: TRxDBGrid; Col: integer);
|
|
|
|
begin
|
|
|
|
FGrid := AGrid;
|
|
|
|
FCol := Col;
|
|
|
|
Visible := True;
|
|
|
|
end;
|
|
|
|
|
2016-11-08 08:10:02 +00:00
|
|
|
{ TRxDBGridSearchOptions }
|
|
|
|
|
|
|
|
procedure TRxDBGridSearchOptions.AssignTo(Dest: TPersistent);
|
|
|
|
begin
|
|
|
|
if Dest is TRxDBGridSearchOptions then
|
|
|
|
begin
|
|
|
|
TRxDBGridSearchOptions(Dest).FQuickSearchOptions:=FQuickSearchOptions;
|
|
|
|
TRxDBGridSearchOptions(Dest).FFromStart:=FFromStart;
|
2019-05-17 11:51:53 +00:00
|
|
|
TRxDBGridSearchOptions(Dest).FHilightSearch:=FHilightSearch;
|
|
|
|
TRxDBGridSearchOptions(Dest).FHilightColor:=FHilightColor;
|
2016-11-08 08:10:02 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited AssignTo(Dest);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxDBGridSearchOptions.Create(AOwner: TRxDBGrid);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner:=AOwner;
|
|
|
|
FQuickSearchOptions:=[loPartialKey, loCaseInsensitive];
|
|
|
|
FFromStart:=false;
|
2019-05-17 11:51:53 +00:00
|
|
|
FHilightSearch:=true;
|
|
|
|
FHilightColor:=clYellow;
|
2016-11-08 08:10:02 +00:00
|
|
|
end;
|
|
|
|
|
2015-09-07 07:42:04 +00:00
|
|
|
{ TRxDBGridColumnDefValues }
|
|
|
|
|
|
|
|
procedure TRxDBGridColumnDefValues.AssignTo(Dest: TPersistent);
|
|
|
|
begin
|
|
|
|
if Dest is TRxDBGridColumnDefValues then
|
|
|
|
begin
|
|
|
|
TRxDBGridColumnDefValues(Dest).FBlobText:=FBlobText;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited AssignTo(Dest);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxDBGridColumnDefValues.Create(AOwner: TRxDBGrid);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner:=AOwner;
|
|
|
|
FBlobText:=sBlobText;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxDBGridColumnDefValues.Destroy;
|
|
|
|
begin
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
{ TRxColumnFooterItem }
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.FontChanged(Sender: TObject);
|
|
|
|
begin
|
2018-01-30 08:00:10 +00:00
|
|
|
FisDefaultFont := Font.IsDefault;
|
2015-07-28 10:15:04 +00:00
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.GetFont: TFont;
|
|
|
|
begin
|
|
|
|
Result := FFont;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.IsFontStored: Boolean;
|
|
|
|
begin
|
|
|
|
Result := not FisDefaultFont;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.SetAlignment(AValue: TAlignment);
|
|
|
|
begin
|
|
|
|
if FAlignment = AValue then exit;
|
|
|
|
FAlignment := AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
2017-02-10 07:05:15 +00:00
|
|
|
procedure TRxColumnFooterItem.SetColor(AValue: TColor);
|
|
|
|
begin
|
|
|
|
if FColor=AValue then Exit;
|
|
|
|
FColor:=AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
procedure TRxColumnFooterItem.SetDisplayFormat(AValue: string);
|
|
|
|
begin
|
|
|
|
if FDisplayFormat=AValue then Exit;
|
|
|
|
FDisplayFormat:=AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.SetFieldName(AValue: string);
|
|
|
|
begin
|
|
|
|
if FFieldName=AValue then Exit;
|
|
|
|
FFieldName:=AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.SetFont(AValue: TFont);
|
|
|
|
begin
|
|
|
|
if not FFont.IsEqual(AValue) then
|
|
|
|
FFont.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.SetLayout(AValue: TTextLayout);
|
|
|
|
begin
|
|
|
|
if FLayout=AValue then Exit;
|
|
|
|
FLayout:=AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.SetValue(AValue: string);
|
|
|
|
begin
|
|
|
|
if FValue=AValue then Exit;
|
|
|
|
FValue:=AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.SetValueType(AValue: TFooterValueType);
|
|
|
|
begin
|
|
|
|
if FValueType=AValue then Exit;
|
|
|
|
FValueType:=AValue;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.GetFieldValue: string;
|
|
|
|
begin
|
|
|
|
if (FFieldName <> '') and TRxDBGrid(FOwner.Grid).DatalinkActive then
|
|
|
|
Result := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FieldByName(FFieldName).AsString
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.GetRecordsCount: string;
|
|
|
|
begin
|
|
|
|
if TRxDBGrid(FOwner.Grid).DatalinkActive then
|
|
|
|
begin
|
|
|
|
if DisplayFormat <> '' then
|
2017-05-18 11:57:06 +00:00
|
|
|
Result := Format(DisplayFormat, [FCountRec])
|
2015-07-28 10:15:04 +00:00
|
|
|
else
|
2017-05-18 11:57:06 +00:00
|
|
|
Result := IntToStr(FCountRec);
|
2015-07-28 10:15:04 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.GetRecNo: string;
|
|
|
|
begin
|
|
|
|
if TRxDBGrid(FOwner.Grid).DatalinkActive then
|
|
|
|
begin
|
|
|
|
if DisplayFormat <> '' then
|
|
|
|
Result := Format(DisplayFormat, [TRxDBGrid(FOwner.Grid).DataSource.DataSet.RecNo])
|
|
|
|
else
|
|
|
|
Result := IntToStr(TRxDBGrid(FOwner.Grid).DataSource.DataSet.RecNo);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.GetStatTotal: string;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
begin
|
|
|
|
if (FFieldName <> '') and TRxDBGrid(FOwner.Grid).DatalinkActive and
|
|
|
|
(TRxDBGrid(FOwner.Grid).DataSource.DataSet.RecordCount <> 0) then
|
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FieldByName(FFieldName);
|
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
|
|
|
if F.DataType in [ftSmallint, ftInteger, ftWord, ftFloat, ftCurrency,
|
2019-10-28 10:09:21 +00:00
|
|
|
ftDate, ftTime, ftDateTime, ftTimeStamp, ftLargeint, ftBCD, ftFMTBcd] then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
if FValueType in [fvtSum, fvtAvg] then
|
|
|
|
Result := ''
|
|
|
|
else
|
|
|
|
if FTestValue = 0 then
|
|
|
|
Result := ''
|
|
|
|
else
|
|
|
|
if FDisplayFormat = '' then
|
|
|
|
Result := DateToStr(FTestValue)
|
|
|
|
else
|
|
|
|
Result := FormatDateTime(FDisplayFormat, FTestValue);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if F.DataType in [ftSmallint, ftInteger, ftWord, ftLargeint] then
|
|
|
|
begin
|
|
|
|
if FDisplayFormat = '' then
|
|
|
|
Result := IntToStr(Round(FTestValue))
|
|
|
|
else
|
2017-01-12 08:40:43 +00:00
|
|
|
Result := FormatFloat(FDisplayFormat, FTestValue);
|
2015-07-28 10:15:04 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if FDisplayFormat <> '' then
|
|
|
|
Result := FormatFloat(FDisplayFormat, FTestValue)
|
|
|
|
else
|
|
|
|
if F.DataType = ftCurrency then
|
|
|
|
Result := FloatToStrF(FTestValue, ffCurrency, 12, 2)
|
|
|
|
else
|
|
|
|
Result := FloatToStr(FTestValue);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.ResetTestValue;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
begin
|
|
|
|
FTestValue := 0;
|
|
|
|
FCountRec:=0;
|
|
|
|
|
|
|
|
if (ValueType in [fvtMin, fvtMax]) and (TRxDBGrid(
|
2017-03-26 16:13:34 +00:00
|
|
|
FOwner.Grid).DataSource.DataSet.RecordCount <> 0) and (FFieldName<>'') then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FieldByName(FFieldName);
|
|
|
|
if (Assigned(F)) and not (F.IsNull) then
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
FTestValue := F.AsDateTime
|
|
|
|
else
|
|
|
|
FTestValue := F.AsFloat;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.UpdateTestValue;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
begin
|
2017-03-26 16:13:34 +00:00
|
|
|
if (ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and (FFieldName<>'') then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FindField(FFieldName);
|
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, F.AsDateTime);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, F.AsDateTime);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtSum: FTestValue := FTestValue + F.AsFloat;
|
|
|
|
// fvtAvg:
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, F.AsFloat);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, F.AsFloat);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.DeleteTestValue: boolean;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
begin
|
|
|
|
Result := True;
|
2017-03-26 16:13:34 +00:00
|
|
|
if (ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and (FFieldName<>'') then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FieldByName(FFieldName);
|
|
|
|
if (Assigned(F)) and not (F.IsNull) then
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
Result := not ((FValueType in [fvtMax, fvtMin]) and (FTestValue = F.AsDateTime))
|
|
|
|
else
|
|
|
|
if FValueType in [fvtMax, fvtMin] then
|
|
|
|
Result := (FTestValue <> F.AsFloat)
|
|
|
|
else
|
|
|
|
FTestValue := FTestValue - F.AsFloat;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.PostTestValue: boolean;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
begin
|
|
|
|
Result := True;
|
2017-03-26 16:13:34 +00:00
|
|
|
if (ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and (FFieldName<>'') then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FieldByName(FFieldName);
|
|
|
|
if Assigned(F) then
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
if FValueType in [fvtMax, fvtMin] then
|
|
|
|
if F.DataSet.State = dsinsert then
|
|
|
|
begin
|
|
|
|
if not (F.IsNull) then
|
|
|
|
case FValueType of
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, F.AsDateTime);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, F.AsDateTime);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (F.OldValue <> null) and (FTestValue = TDateTime(F.OldValue)) then
|
|
|
|
Result := False
|
|
|
|
else
|
|
|
|
if not F.IsNull then
|
|
|
|
case FValueType of
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, F.AsDateTime);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, F.AsDateTime);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if F.DataSet.State = dsinsert then
|
|
|
|
begin
|
|
|
|
if not F.IsNull then
|
|
|
|
case FValueType of
|
|
|
|
fvtSum: FTestValue := FTestValue + F.AsFloat;
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, F.AsFloat);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, F.AsFloat);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (FValueType in [fvtMax, fvtMin]) and (F.OldValue <> null) and
|
|
|
|
(FTestValue = Float(F.OldValue)) then
|
|
|
|
Result := False
|
|
|
|
else
|
|
|
|
case FValueType of
|
|
|
|
fvtSum:
|
|
|
|
begin
|
|
|
|
if not F.IsNull then
|
|
|
|
begin
|
|
|
|
if F.OldValue <> null then
|
|
|
|
FTestValue := FTestValue - Float(F.OldValue);
|
|
|
|
FTestValue := FTestValue + F.AsFloat;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
fvtMax: if not F.IsNull then
|
|
|
|
FTestValue := Max(FTestValue, F.AsFloat);
|
|
|
|
fvtMin: if not F.IsNull then
|
|
|
|
FTestValue := Min(FTestValue, F.AsFloat);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.ErrorTestValue: boolean;
|
|
|
|
var
|
|
|
|
F: TField;
|
|
|
|
begin
|
|
|
|
Result := True;
|
2017-03-26 16:13:34 +00:00
|
|
|
if (ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and (FFieldName<>'') then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
F := TRxDBGrid(FOwner.Grid).DataSource.DataSet.FieldByName(FFieldName);
|
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
|
|
|
if F.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
if (FValueType in [fvtMax, fvtMin]) and not (F.IsNull) then
|
|
|
|
begin
|
|
|
|
if not (F.IsNull) and (FTestValue = F.AsDateTime) then
|
|
|
|
Result := False
|
|
|
|
else
|
|
|
|
if (F.DataSet.RecordCount <> 0) and (F.OldValue <> null) then
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, TDateTime(F.OldValue));
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, TDateTime(F.OldValue));
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (FValueType in [fvtMax, fvtMin]) and not (F.IsNull) and (FTestValue = F.AsFloat) then
|
|
|
|
Result := False
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtSum:
|
|
|
|
if F.DataSet.RecordCount = 0 then
|
|
|
|
begin
|
|
|
|
{ if not F.IsNull then
|
|
|
|
FTestValue := FTestValue - F.AsFloat;}
|
|
|
|
{ TODO -oalexs : need rewrite this code - where difficult! }
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if F.OldValue <> null then
|
|
|
|
FTestValue := FTestValue + Float(F.OldValue);
|
|
|
|
if not F.IsNull then
|
|
|
|
FTestValue := FTestValue - F.AsFloat;
|
|
|
|
end;
|
|
|
|
fvtMax:
|
|
|
|
if (F.DataSet.RecordCount <> 0) and (F.OldValue <> null) then
|
|
|
|
FTestValue := Max(FTestValue, Float(F.OldValue));
|
|
|
|
fvtMin:
|
|
|
|
if (F.DataSet.RecordCount <> 0) and (F.OldValue <> null) then
|
|
|
|
FTestValue := Min(FTestValue, Float(F.OldValue));
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.UpdateTestValueFromVar(AValue: Variant);
|
|
|
|
begin
|
|
|
|
if FValueType in [fvtSum, fvtAvg, fvtMax, fvtMin] then
|
|
|
|
begin
|
|
|
|
if (not VarIsEmpty(AValue)) and (AValue <> null) and Assigned(FField) then
|
|
|
|
begin
|
|
|
|
if FField.DataType in [ftDate, ftTime, ftDateTime, ftTimeStamp] then
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, AValue);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, AValue);
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtSum,
|
|
|
|
fvtAvg: FTestValue := FTestValue + AValue;
|
|
|
|
fvtMax: FTestValue := Max(FTestValue, AValue);
|
|
|
|
fvtMin: FTestValue := Min(FTestValue, AValue);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxColumnFooterItem.Create(ACollection: TCollection);
|
|
|
|
begin
|
|
|
|
inherited Create(ACollection);
|
|
|
|
if Assigned(ACollection) then
|
|
|
|
FOwner := TRxColumn(TRxColumnFooterItems(ACollection).Owner);
|
|
|
|
|
|
|
|
FTestValue := 0;
|
|
|
|
FLayout := tlCenter;
|
2017-02-10 07:05:15 +00:00
|
|
|
FColor:=clNone;
|
2015-07-28 10:15:04 +00:00
|
|
|
|
|
|
|
FFont := TFont.Create;
|
|
|
|
FillDefaultFont;
|
|
|
|
FFont.OnChange := @FontChanged;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxColumnFooterItem.Destroy;
|
|
|
|
begin
|
2015-08-05 08:21:15 +00:00
|
|
|
FreeAndNil(FFont);
|
2015-07-28 10:15:04 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFooterItem.DisplayText: string;
|
|
|
|
begin
|
|
|
|
case FValueType of
|
|
|
|
fvtSum,
|
|
|
|
fvtAvg,
|
|
|
|
fvtMax,
|
|
|
|
fvtMin: Result := GetStatTotal;
|
|
|
|
fvtCount: Result := GetRecordsCount;
|
|
|
|
fvtFieldValue: Result := GetFieldValue;
|
|
|
|
fvtStaticText: Result := FValue;
|
|
|
|
fvtRecNo: Result := GetRecNo;
|
|
|
|
else
|
|
|
|
Result := '';
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItem.FillDefaultFont;
|
|
|
|
var
|
|
|
|
AGrid: TCustomGrid;
|
|
|
|
begin
|
|
|
|
if not Assigned(FOwner) then exit;
|
|
|
|
AGrid := FOwner.Grid;
|
|
|
|
if (AGrid<>nil) then
|
|
|
|
begin
|
|
|
|
FFont.Assign(AGrid.Font);
|
|
|
|
FIsDefaultFont := True;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TRxColumnFooterItems }
|
|
|
|
|
|
|
|
function TRxColumnFooterItems.GetItem(Index: integer): TRxColumnFooterItem;
|
|
|
|
begin
|
|
|
|
Result := TRxColumnFooterItem(inherited GetItem(Index));
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItems.SetItem(Index: integer;
|
|
|
|
const AValue: TRxColumnFooterItem);
|
|
|
|
begin
|
|
|
|
inherited SetItem(Index, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFooterItems.Update(Item: TCollectionItem);
|
|
|
|
begin
|
|
|
|
inherited Update(Item);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxColumnFooterItems.Create(AOwner: TPersistent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner, TRxColumnFooterItem);
|
|
|
|
end;
|
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
function TRxColumnFooterItems.GetEnumerator: TRxColumnFooterItemsEnumerator;
|
|
|
|
begin
|
|
|
|
Result:=TRxColumnFooterItemsEnumerator.Create(Self);
|
|
|
|
end;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
{ TRxDBGridAbstractTools }
|
|
|
|
|
|
|
|
procedure TRxDBGridAbstractTools.SetRxDBGrid(AValue: TRxDBGrid);
|
|
|
|
begin
|
|
|
|
if FRxDBGrid=AValue then Exit;
|
|
|
|
if Assigned(FRxDBGrid) then
|
|
|
|
FRxDBGrid.RemoveTools(Self);
|
|
|
|
FRxDBGrid:=AValue;
|
|
|
|
if Assigned(FRxDBGrid) then
|
|
|
|
FRxDBGrid.AddTools(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGridAbstractTools.DoExecTools: boolean;
|
|
|
|
begin
|
2016-05-12 07:25:00 +00:00
|
|
|
Result:=false;
|
2014-07-23 11:40:36 +00:00
|
|
|
end;
|
|
|
|
|
2014-07-25 11:53:30 +00:00
|
|
|
function TRxDBGridAbstractTools.DoSetupTools: boolean;
|
|
|
|
begin
|
|
|
|
Result:=true;
|
|
|
|
end;
|
|
|
|
|
2015-05-25 10:12:12 +00:00
|
|
|
function TRxDBGridAbstractTools.MouseDown(Button: TMouseButton;
|
|
|
|
Shift: TShiftState; X, Y: integer): boolean;
|
|
|
|
begin
|
|
|
|
Result:=false;
|
|
|
|
end;
|
|
|
|
|
2017-05-30 07:49:41 +00:00
|
|
|
procedure TRxDBGridAbstractTools.Notification(AComponent: TComponent;
|
|
|
|
Operation: TOperation);
|
|
|
|
begin
|
|
|
|
inherited Notification(AComponent, Operation);
|
|
|
|
if (AComponent = FRxDBGrid) and (Operation = opRemove) then
|
|
|
|
FRxDBGrid := nil;
|
|
|
|
end;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
procedure TRxDBGridAbstractTools.ExecTools(Sender: TObject);
|
|
|
|
begin
|
|
|
|
Execute;
|
|
|
|
end;
|
|
|
|
|
2018-02-02 10:42:27 +00:00
|
|
|
procedure TRxDBGridAbstractTools.SetEnabled(AValue: boolean);
|
|
|
|
begin
|
|
|
|
if FEnabled=AValue then Exit;
|
|
|
|
FEnabled:=AValue;
|
|
|
|
FRxDBGrid.UpdateToolsState(Self);
|
|
|
|
end;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
constructor TRxDBGridAbstractTools.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
2015-05-25 10:12:12 +00:00
|
|
|
FToolsEvents:=[];
|
2014-07-23 11:40:36 +00:00
|
|
|
FCaption:=Name;
|
2014-07-25 11:53:30 +00:00
|
|
|
FShowSetupForm:=false;
|
2018-02-02 10:42:27 +00:00
|
|
|
FEnabled:=true;
|
2014-07-23 11:40:36 +00:00
|
|
|
end;
|
|
|
|
|
2015-05-25 10:12:12 +00:00
|
|
|
destructor TRxDBGridAbstractTools.Destroy;
|
|
|
|
begin
|
|
|
|
SetRxDBGrid(nil);
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
function TRxDBGridAbstractTools.Execute: boolean;
|
|
|
|
begin
|
2014-08-05 12:51:26 +00:00
|
|
|
Result:=true;
|
2014-07-23 11:40:36 +00:00
|
|
|
if Assigned(FOnBeforeExecute) then
|
|
|
|
FOnBeforeExecute(Self);
|
2014-07-25 11:53:30 +00:00
|
|
|
|
|
|
|
if FShowSetupForm then
|
|
|
|
Result:=DoSetupTools;
|
|
|
|
|
|
|
|
if Result then
|
|
|
|
Result:=DoExecTools;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
if Assigned(FOnAfterExecute) then
|
|
|
|
FOnAfterExecute(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2014-01-15 12:04:11 +00:00
|
|
|
{ TRxDBGridCollumnConstraint }
|
|
|
|
|
|
|
|
procedure TRxDBGridCollumnConstraints.SetMaxWidth(AValue: integer);
|
|
|
|
begin
|
|
|
|
if FMaxWidth=AValue then Exit;
|
2014-01-15 12:18:24 +00:00
|
|
|
if (FMinWidth<>0) and (AValue<>0) and (AValue < FMinWidth) then exit;
|
2014-01-15 12:04:11 +00:00
|
|
|
FMaxWidth:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridCollumnConstraints.SetMinWidth(AValue: integer);
|
|
|
|
begin
|
|
|
|
if FMinWidth=AValue then Exit;
|
2014-01-15 12:18:24 +00:00
|
|
|
if (FMaxWidth<>0) and (AValue<>0) and (AValue > FMaxWidth) then exit;
|
2014-01-15 12:04:11 +00:00
|
|
|
FMinWidth:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridCollumnConstraints.AssignTo(Dest: TPersistent);
|
|
|
|
begin
|
|
|
|
if Dest is TRxDBGridCollumnConstraints then
|
|
|
|
begin
|
|
|
|
TRxDBGridCollumnConstraints(Dest).FMinWidth:=FMinWidth;
|
|
|
|
TRxDBGridCollumnConstraints(Dest).FMaxWidth:=FMaxWidth;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited AssignTo(Dest);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxDBGridCollumnConstraints.Create(AOwner: TPersistent);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner:=AOwner;
|
|
|
|
end;
|
2013-03-28 15:40:03 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
{ TRxDbGridColumnsSortList }
|
|
|
|
|
|
|
|
function TRxDbGridColumnsSortList.GetCollumn(Index: Integer): TRxColumn;
|
|
|
|
begin
|
|
|
|
Result:=TRxColumn(Items[Index]);
|
|
|
|
end;
|
|
|
|
|
2012-08-23 17:03:53 +00:00
|
|
|
{ TRxColumnEditButton }
|
|
|
|
|
|
|
|
function TRxColumnEditButton.GetGlyph: TBitmap;
|
|
|
|
begin
|
|
|
|
Result:=FButton.Glyph;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnEditButton.GetHint: String;
|
|
|
|
begin
|
|
|
|
Result:=FButton.Hint;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnEditButton.GetNumGlyphs: Integer;
|
|
|
|
begin
|
|
|
|
Result:=FButton.NumGlyphs;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnEditButton.GetOnButtonClick: TNotifyEvent;
|
|
|
|
begin
|
|
|
|
Result:=FButton.OnClick;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnEditButton.GetWidth: Integer;
|
|
|
|
begin
|
|
|
|
Result:=FButton.Width;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetGlyph(AValue: TBitmap);
|
|
|
|
begin
|
|
|
|
FButton.Glyph.Assign(AValue);
|
|
|
|
if not (csLoading in TRxDBGrid(TRxColumnEditButtons(Collection).Owner).ComponentState) then
|
|
|
|
FStyle:=ebsGlyphRx;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetHint(AValue: String);
|
|
|
|
begin
|
|
|
|
FButton.Hint:=AValue;
|
2014-02-02 11:14:10 +00:00
|
|
|
FSpinBtn.Hint:=AValue;
|
2012-08-23 17:03:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetNumGlyphs(AValue: Integer);
|
|
|
|
begin
|
|
|
|
FButton.NumGlyphs:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetOnButtonClick(AValue: TNotifyEvent);
|
|
|
|
begin
|
|
|
|
FButton.OnClick:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetStyle(AValue: TRxColumnEditButtonStyle);
|
|
|
|
begin
|
|
|
|
if FStyle=AValue then Exit;
|
|
|
|
FStyle:=AValue;
|
2016-09-14 07:27:19 +00:00
|
|
|
case FStyle of
|
|
|
|
ebsDropDownRx:FButton.Glyph.Assign(FMarkerDown);
|
|
|
|
ebsEllipsisRx:FButton.Glyph.Assign(FEllipsisRxBMP);
|
|
|
|
ebsGlyphRx:FButton.Glyph.Assign(FGlyphRxBMP);
|
|
|
|
ebsUpDownRx:FButton.Glyph.Assign(FUpDownRxBMP);
|
|
|
|
ebsPlusRx:FButton.Glyph.Assign(FPlusRxBMP);
|
|
|
|
ebsMinusRx:FButton.Glyph.Assign(FMinusRxBMP);
|
|
|
|
else
|
|
|
|
FButton.Glyph.Assign(nil);
|
|
|
|
end;
|
2012-08-23 17:03:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetVisible(AValue: Boolean);
|
|
|
|
begin
|
|
|
|
FVisible:=AValue;
|
2014-02-02 11:14:10 +00:00
|
|
|
if AValue then
|
|
|
|
begin
|
|
|
|
if Style = ebsUpDownRx then
|
|
|
|
begin
|
|
|
|
FSpinBtn.Visible:=AValue;
|
|
|
|
FButton.Visible:=false;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
FButton.Visible:=AValue;
|
|
|
|
FSpinBtn.Visible:=false;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
FButton.Visible:=AValue;
|
|
|
|
FSpinBtn.Visible:=AValue;
|
|
|
|
end;
|
2012-08-23 17:03:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.SetWidth(AValue: Integer);
|
|
|
|
begin
|
|
|
|
FButton.Width:=AValue;
|
2014-02-02 11:14:10 +00:00
|
|
|
FSpinBtn.Width:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.DoBottomClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
F:TField;
|
|
|
|
Col:TRxColumn;
|
|
|
|
|
|
|
|
msg: TGridMessage;
|
2020-04-15 22:28:52 +00:00
|
|
|
V: Boolean;
|
2014-02-02 11:14:10 +00:00
|
|
|
begin
|
|
|
|
Col:=TRxColumnEditButtons(Collection).FOwner as TRxColumn;
|
|
|
|
F:=Col.Field;
|
|
|
|
|
|
|
|
if Assigned(F) and (F.DataType in NumericDataTypes) then
|
|
|
|
begin
|
|
|
|
if not (F.DataSet.State in dsEditModes) then
|
|
|
|
F.DataSet.Edit;
|
2015-04-09 12:38:05 +00:00
|
|
|
|
|
|
|
if F.IsNull then
|
|
|
|
F.Value:=0;
|
|
|
|
|
2020-04-15 22:28:52 +00:00
|
|
|
if F is TLongintField then
|
2020-04-24 09:06:20 +00:00
|
|
|
V:=((TLongintField(F).MinValue <> 0) or (TLongintField(F).MaxValue <> 0)) and (TLongintField(F).MinValue < F.Value)
|
2020-04-15 22:28:52 +00:00
|
|
|
else
|
|
|
|
if F is TFloatField then
|
2020-04-24 09:06:20 +00:00
|
|
|
V:=((TFloatField(F).MinValue <> 0) or (TFloatField(F).MaxValue <> 0)) and (TFloatField(F).MinValue < F.Value)
|
2020-04-15 22:28:52 +00:00
|
|
|
else
|
|
|
|
V:=true;
|
|
|
|
|
|
|
|
if V then
|
|
|
|
F.Value:=F.Value - 1;
|
2014-02-02 11:14:10 +00:00
|
|
|
|
|
|
|
Msg.LclMsg.msg:=GM_SETVALUE;
|
|
|
|
Msg.Grid:=Col.Grid;
|
|
|
|
Msg.Value:=F.DisplayText;
|
|
|
|
TRxDBGrid(Col.Grid).Editor.Dispatch(Msg);
|
|
|
|
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButton.DoTopClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
F:TField;
|
|
|
|
Col:TRxColumn;
|
|
|
|
|
|
|
|
msg: TGridMessage;
|
2020-04-15 22:28:52 +00:00
|
|
|
V: Boolean;
|
2014-02-02 11:14:10 +00:00
|
|
|
begin
|
|
|
|
Col:=TRxColumnEditButtons(Collection).FOwner as TRxColumn;
|
|
|
|
F:=Col.Field;
|
|
|
|
|
|
|
|
if Assigned(F) and (F.DataType in NumericDataTypes) then
|
|
|
|
begin
|
|
|
|
if not (F.DataSet.State in dsEditModes) then
|
|
|
|
F.DataSet.Edit;
|
2015-04-09 12:38:05 +00:00
|
|
|
|
|
|
|
if F.IsNull then
|
|
|
|
F.Value:=0;
|
2020-04-15 22:28:52 +00:00
|
|
|
|
|
|
|
if F is TLongintField then
|
2020-04-24 09:06:20 +00:00
|
|
|
V:=((TLongintField(F).MinValue <> 0) or (TLongintField(F).MaxValue <> 0)) and (TLongintField(F).MaxValue > F.Value)
|
2020-04-15 22:28:52 +00:00
|
|
|
else
|
|
|
|
if F is TFloatField then
|
2020-04-24 09:06:20 +00:00
|
|
|
V:=((TFloatField(F).MinValue <> 0) or (TFloatField(F).MaxValue <> 0)) and (TFloatField(F).MaxValue > F.Value)
|
2020-04-15 22:28:52 +00:00
|
|
|
else
|
|
|
|
V:=true;
|
|
|
|
|
|
|
|
if V then
|
|
|
|
F.Value:=F.Value + 1;
|
2014-02-02 11:14:10 +00:00
|
|
|
|
|
|
|
Msg.LclMsg.msg:=GM_SETVALUE;
|
|
|
|
Msg.Grid:=Col.Grid;
|
|
|
|
Msg.Value:=F.DisplayText;
|
|
|
|
TRxDBGrid(Col.Grid).Editor.Dispatch(Msg);
|
|
|
|
end;
|
2012-08-23 17:03:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnEditButton.GetDisplayName: string;
|
|
|
|
begin
|
|
|
|
if Hint<>'' then
|
|
|
|
Result:=Hint
|
|
|
|
else
|
|
|
|
Result:='TRxColumnEditButton';
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxColumnEditButton.Create(ACollection: TCollection);
|
|
|
|
begin
|
|
|
|
inherited Create(ACollection);
|
|
|
|
FButton:=TSpeedButton.Create(nil);
|
2016-05-11 12:44:15 +00:00
|
|
|
|
2014-02-02 11:14:10 +00:00
|
|
|
FSpinBtn:=TRxSpinButton.Create(nil);
|
|
|
|
FSpinBtn.OnBottomClick:=@DoBottomClick;
|
|
|
|
FSpinBtn.OnTopClick:=@DoTopClick;
|
|
|
|
|
2012-08-23 17:03:53 +00:00
|
|
|
FVisible:=true;
|
2015-06-17 08:09:34 +00:00
|
|
|
FEnabled:=true;
|
2012-08-23 17:03:53 +00:00
|
|
|
Width:=15;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxColumnEditButton.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FButton);
|
2014-02-02 11:14:10 +00:00
|
|
|
FreeAndNil(FSpinBtn);
|
2012-08-23 17:03:53 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TRxColumnEditButtons }
|
|
|
|
|
|
|
|
function TRxColumnEditButtons.GetItem(Index: integer): TRxColumnEditButton;
|
|
|
|
begin
|
|
|
|
Result:= TRxColumnEditButton(inherited Items[Index]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButtons.SetItem(Index: integer;
|
|
|
|
AValue: TRxColumnEditButton);
|
|
|
|
begin
|
|
|
|
inherited SetItem(Index, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnEditButtons.Update(Item: TCollectionItem);
|
|
|
|
begin
|
|
|
|
inherited Update(Item);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxColumnEditButtons.Create(AOwner: TPersistent);
|
|
|
|
begin
|
|
|
|
inherited Create(TRxColumnEditButton);
|
|
|
|
FOwner:=AOwner;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnEditButtons.Add: TRxColumnEditButton;
|
|
|
|
begin
|
|
|
|
Result := TRxColumnEditButton(inherited Add);
|
|
|
|
end;
|
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
{ TRxDBGridFooterOptions }
|
|
|
|
|
|
|
|
procedure TRxDBGridFooterOptions.SetActive(AValue: boolean);
|
|
|
|
begin
|
|
|
|
if FActive=AValue then Exit;
|
|
|
|
FActive:=AValue;
|
2012-02-25 07:27:11 +00:00
|
|
|
|
|
|
|
{ TODO : Устаревший код - в следующей версии необходимо убрать }
|
|
|
|
if FActive then
|
|
|
|
FOwner.FOptionsRx:=FOwner.FOptionsRx + [rdgFooterRows]
|
|
|
|
else
|
|
|
|
FOwner.FOptionsRx:=FOwner.FOptionsRx - [rdgFooterRows];
|
|
|
|
|
2015-05-25 10:12:12 +00:00
|
|
|
if FActive then
|
|
|
|
FOwner.CalcStatTotals;
|
2012-02-25 07:27:11 +00:00
|
|
|
FOwner.VisualChange;
|
2012-02-23 04:46:16 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridFooterOptions.SetColor(AValue: TColor);
|
|
|
|
begin
|
|
|
|
if FColor=AValue then Exit;
|
|
|
|
FColor:=AValue;
|
|
|
|
FOwner.Invalidate;
|
|
|
|
end;
|
|
|
|
|
2016-05-05 06:22:50 +00:00
|
|
|
procedure TRxDBGridFooterOptions.SetDrawFullLine(AValue: boolean);
|
|
|
|
begin
|
|
|
|
if FDrawFullLine=AValue then Exit;
|
|
|
|
FDrawFullLine:=AValue;
|
2016-05-05 06:49:18 +00:00
|
|
|
FOwner.VisualChange;
|
2016-05-05 06:22:50 +00:00
|
|
|
end;
|
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
procedure TRxDBGridFooterOptions.SetRowCount(AValue: integer);
|
|
|
|
begin
|
|
|
|
if FRowCount=AValue then Exit;
|
|
|
|
FRowCount:=AValue;
|
|
|
|
FOwner.VisualChange;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridFooterOptions.SetStyle(AValue: TTitleStyle);
|
|
|
|
begin
|
|
|
|
if FStyle=AValue then Exit;
|
|
|
|
FStyle:=AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridFooterOptions.AssignTo(Dest: TPersistent);
|
|
|
|
var
|
|
|
|
FO:TRxDBGridFooterOptions absolute Dest;
|
|
|
|
begin
|
|
|
|
if Dest is TRxDBGridFooterOptions then
|
|
|
|
begin
|
|
|
|
FO.Active:=Active;
|
|
|
|
FO.Color:=Color;
|
|
|
|
FO.RowCount:=RowCount;
|
|
|
|
FO.Style:=Style;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited AssignTo(Dest);
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxDBGridFooterOptions.Create(Owner: TRxDBGrid);
|
|
|
|
begin
|
|
|
|
inherited Create;
|
|
|
|
FOwner:=Owner;
|
|
|
|
|
|
|
|
FColor := clWindow;
|
|
|
|
FRowCount := 0;
|
|
|
|
FStyle := tsLazarus;
|
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxDBGridFooterOptions.Destroy;
|
|
|
|
begin
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
|
|
|
|
{ TRxDBGridDateEditor }
|
2014-04-09 17:33:24 +00:00
|
|
|
procedure TRxDBGridDateEditor.EditChange;
|
2013-10-28 08:06:33 +00:00
|
|
|
var
|
|
|
|
D:TDateTime;
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
2014-04-09 17:33:24 +00:00
|
|
|
inherited EditChange;
|
2019-08-23 07:24:28 +00:00
|
|
|
if (FGrid<>nil) and Visible then
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
2019-08-23 07:24:28 +00:00
|
|
|
if TryStrToDate(Text, D) then
|
|
|
|
FGrid.EditorTextChanged(FCol, FRow, Text)
|
2008-01-31 13:23:03 +00:00
|
|
|
else
|
2019-08-23 07:24:28 +00:00
|
|
|
FGrid.EditorTextChanged(FCol, FRow, '')
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2019-08-23 07:24:28 +00:00
|
|
|
|
|
|
|
procedure TRxDBGridDateEditor.EditKeyDown(var Key: word; Shift: TShiftState);
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
function AllSelected: boolean;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := (SelLength > 0) and (SelLength = UTF8Length(Text));
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
|
|
|
function AtStart: boolean;
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := (SelStart = 0);
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
|
|
|
function AtEnd: boolean;
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := ((SelStart + 1) > UTF8Length(Text)) or AllSelected;
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
procedure doEditorKeyDown;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FGrid <> nil then
|
2008-01-31 13:23:03 +00:00
|
|
|
FGrid.EditorkeyDown(Self, key, shift);
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
procedure doGridKeyDown;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FGrid <> nil then
|
2008-01-31 13:23:03 +00:00
|
|
|
FGrid.KeyDown(Key, shift);
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
function GetFastEntry: boolean;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FGrid <> nil then
|
2008-01-31 13:23:03 +00:00
|
|
|
Result := FGrid.FastEditing
|
|
|
|
else
|
|
|
|
Result := False;
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
procedure CheckEditingKey;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (FGrid = nil) or FGrid.EditorIsReadOnly then
|
2008-01-31 13:23:03 +00:00
|
|
|
Key := 0;
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
var
|
|
|
|
IntSel: boolean;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
inherited KeyDown(Key, Shift);
|
2008-01-31 13:23:03 +00:00
|
|
|
case Key of
|
|
|
|
VK_F2:
|
2011-05-07 14:48:11 +00:00
|
|
|
if AllSelected then
|
|
|
|
begin
|
2008-01-31 13:23:03 +00:00
|
|
|
SelLength := 0;
|
|
|
|
SelStart := Length(Text);
|
|
|
|
end;
|
|
|
|
VK_DELETE:
|
|
|
|
CheckEditingKey;
|
|
|
|
VK_UP, VK_DOWN:
|
|
|
|
doGridKeyDown;
|
|
|
|
VK_LEFT, VK_RIGHT:
|
2011-05-07 14:48:11 +00:00
|
|
|
if GetFastEntry then
|
|
|
|
begin
|
|
|
|
IntSel :=
|
|
|
|
((Key = VK_LEFT) and not AtStart) or ((Key = VK_RIGHT) and not AtEnd);
|
|
|
|
if not IntSel then
|
|
|
|
begin
|
2008-01-31 13:23:03 +00:00
|
|
|
doGridKeyDown;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
|
|
|
VK_END, VK_HOME:
|
|
|
|
;
|
|
|
|
else
|
|
|
|
doEditorKeyDown;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridDateEditor.WndProc(var TheMessage: TLMessage);
|
|
|
|
begin
|
2011-09-22 17:07:49 +00:00
|
|
|
if FGrid<>nil then
|
|
|
|
case TheMessage.Msg of
|
|
|
|
LM_CLEAR,
|
|
|
|
LM_CUT,
|
|
|
|
LM_PASTE:
|
|
|
|
begin
|
|
|
|
if FGrid.EditorIsReadOnly then
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if TheMessage.msg = LM_KILLFOCUS then
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
|
|
|
if HWND(TheMessage.WParam) = HWND(Handle) then
|
|
|
|
begin
|
|
|
|
// lost the focus but it returns to ourselves
|
|
|
|
// eat the message.
|
|
|
|
TheMessage.Result := 0;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
inherited WndProc(TheMessage);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridDateEditor.msg_SetGrid(var Msg: TGridMessage);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FGrid := Msg.Grid as TRxDBGrid;
|
|
|
|
Msg.Options := EO_AUTOSIZE or EO_SELECTALL
|
|
|
|
{or EO_HOOKEXIT or EO_HOOKKEYPRESS or EO_HOOKKEYUP};
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridDateEditor.msg_SetValue(var Msg: TGridMessage);
|
2015-06-17 08:09:34 +00:00
|
|
|
var
|
|
|
|
D: TDateTime;
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
2015-06-17 08:09:34 +00:00
|
|
|
if FGrid.SelectedField.DataType in [ftDate, ftDateTime] then
|
|
|
|
Self.Date := FGrid.SelectedField.AsDateTime
|
|
|
|
else
|
|
|
|
if TryStrToDateTime(FGrid.SelectedField.AsString, D) then
|
|
|
|
Self.Date := D
|
|
|
|
else
|
|
|
|
Self.Clear;
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridDateEditor.msg_GetValue(var Msg: TGridMessage);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
sText: string;
|
2008-01-31 13:23:03 +00:00
|
|
|
begin
|
2019-08-23 07:24:28 +00:00
|
|
|
if Date = NullDate then
|
|
|
|
sText := ''
|
|
|
|
else
|
|
|
|
sText := Text;
|
2011-05-07 14:48:11 +00:00
|
|
|
Msg.Value := sText;
|
2008-01-31 13:23:03 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridDateEditor.msg_SelectAll(var Msg: TGridMessage);
|
|
|
|
begin
|
|
|
|
SelectAll;
|
|
|
|
end;
|
|
|
|
|
2011-09-22 17:07:49 +00:00
|
|
|
constructor TRxDBGridDateEditor.Create(Aowner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(Aowner);
|
|
|
|
AutoSize := false;
|
2016-03-17 08:34:27 +00:00
|
|
|
Spacing:=0;
|
2011-10-13 15:45:13 +00:00
|
|
|
UpdateMask;
|
2011-09-22 17:07:49 +00:00
|
|
|
end;
|
|
|
|
|
2008-01-31 13:23:03 +00:00
|
|
|
procedure TRxDBGridDateEditor.EditingDone;
|
|
|
|
begin
|
|
|
|
inherited EditingDone;
|
2011-05-07 14:48:11 +00:00
|
|
|
if FGrid <> nil then
|
2008-01-31 13:23:03 +00:00
|
|
|
FGrid.EditingDone;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
2007-11-06 11:15:05 +00:00
|
|
|
{ TRxDBGridLookupComboEditor }
|
|
|
|
|
|
|
|
procedure TRxDBGridLookupComboEditor.WndProc(var TheMessage: TLMessage);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if TheMessage.msg = LM_KILLFOCUS then
|
2007-11-06 11:15:05 +00:00
|
|
|
begin
|
|
|
|
if HWND(TheMessage.WParam) = HWND(Handle) then
|
|
|
|
begin
|
|
|
|
// lost the focus but it returns to ourselves
|
|
|
|
// eat the message.
|
|
|
|
TheMessage.Result := 0;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
inherited WndProc(TheMessage);
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGridLookupComboEditor.KeyDown(var Key: word; Shift: TShiftState);
|
2007-11-06 11:15:05 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure doGridKeyDown;
|
|
|
|
begin
|
|
|
|
if Assigned(FGrid) then
|
|
|
|
FGrid.KeyDown(Key, shift);
|
|
|
|
end;
|
2007-11-06 11:15:05 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure doEditorKeyDown;
|
|
|
|
begin
|
|
|
|
if FGrid <> nil then
|
|
|
|
FGrid.EditorkeyDown(Self, key, shift);
|
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function GetFastEntry: boolean;
|
|
|
|
begin
|
|
|
|
if FGrid <> nil then
|
|
|
|
Result := FGrid.FastEditing
|
|
|
|
else
|
|
|
|
Result := False;
|
|
|
|
end;
|
2012-09-20 14:02:20 +00:00
|
|
|
procedure CheckEditingKey;
|
|
|
|
begin
|
|
|
|
if (FGrid=nil) or FGrid.EditorIsReadOnly then
|
|
|
|
Key := 0;
|
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2007-11-06 11:15:05 +00:00
|
|
|
begin
|
2012-09-20 14:02:20 +00:00
|
|
|
CheckEditingKey;
|
2007-11-06 11:15:05 +00:00
|
|
|
case Key of
|
|
|
|
VK_UP,
|
2011-05-07 14:48:11 +00:00
|
|
|
VK_DOWN:
|
2007-11-06 11:15:05 +00:00
|
|
|
if (not PopupVisible) and (not (ssAlt in Shift)) then
|
|
|
|
begin
|
|
|
|
doGridKeyDown;
|
2012-09-20 14:02:20 +00:00
|
|
|
Key:=0;
|
2007-11-06 11:15:05 +00:00
|
|
|
exit;
|
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
VK_LEFT, VK_RIGHT:
|
|
|
|
if GetFastEntry then
|
|
|
|
begin
|
|
|
|
doGridKeyDown;
|
|
|
|
exit;
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
else
|
|
|
|
begin
|
|
|
|
inherited KeyDown(Key, Shift);
|
|
|
|
doEditorKeyDown;
|
|
|
|
exit;
|
|
|
|
end;
|
2007-11-06 11:15:05 +00:00
|
|
|
end;
|
|
|
|
inherited KeyDown(Key, Shift);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridLookupComboEditor.msg_SetGrid(var Msg: TGridMessage);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FGrid := Msg.Grid as TRxDBGrid;
|
|
|
|
Msg.Options := EO_AUTOSIZE;
|
2007-11-06 11:15:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridLookupComboEditor.msg_SetValue(var Msg: TGridMessage);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
F: TField;
|
2007-11-06 11:15:05 +00:00
|
|
|
begin
|
|
|
|
FCol := Msg.Col;
|
|
|
|
FRow := Msg.Row;
|
2011-05-07 14:48:11 +00:00
|
|
|
F := FGrid.SelectedField;
|
|
|
|
DataSource := FGrid.DataSource;
|
2007-11-06 11:15:05 +00:00
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
2018-10-17 05:44:07 +00:00
|
|
|
FLDS.DataSet := nil;
|
|
|
|
{ DataField := '';
|
|
|
|
LookupDisplay := '';
|
|
|
|
LookupField := '';
|
|
|
|
|
|
|
|
FLDS.DataSet := F.LookupDataSet; }
|
2011-05-07 14:48:11 +00:00
|
|
|
DataField := F.KeyFields;
|
2018-10-17 05:44:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
LookupDisplay := F.LookupResultField;
|
|
|
|
LookupField := F.LookupKeyFields;
|
2018-10-17 05:44:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FLDS.DataSet := F.LookupDataSet;
|
2018-10-17 05:44:07 +00:00
|
|
|
|
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
FGrid.GetOnCreateLookup;
|
2007-11-06 11:15:05 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2012-09-20 14:02:20 +00:00
|
|
|
procedure TRxDBGridLookupComboEditor.msg_GetValue(var Msg: TGridMessage);
|
|
|
|
var
|
|
|
|
sText: string;
|
|
|
|
F:TField;
|
|
|
|
begin
|
|
|
|
if Assigned(FGrid.SelectedField) and Assigned(FLDS.DataSet) then
|
|
|
|
begin
|
2020-09-07 12:03:46 +00:00
|
|
|
// F:=FLDS.DataSet.FieldByName(LookupDisplay);
|
|
|
|
F:=FLDS.DataSet.FieldByName(LookupField);
|
2012-09-20 14:02:20 +00:00
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
|
|
|
sText := F.DisplayText;
|
|
|
|
Msg.Value := sText;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
procedure TRxDBGridLookupComboEditor.ShowList;
|
|
|
|
begin
|
|
|
|
FGrid.GetOnDisplayLookup;
|
|
|
|
inherited ShowList;
|
|
|
|
end;
|
2007-11-06 11:15:05 +00:00
|
|
|
|
2012-09-19 14:06:46 +00:00
|
|
|
procedure TRxDBGridLookupComboEditor.OnInternalClosePopup(AResult: boolean);
|
2012-09-20 14:02:20 +00:00
|
|
|
procedure CheckEditingKey;
|
|
|
|
begin
|
|
|
|
if (FGrid=nil) or FGrid.EditorIsReadOnly then
|
|
|
|
// Key := 0;
|
|
|
|
end;
|
2012-09-19 14:06:46 +00:00
|
|
|
var
|
|
|
|
F:TField;
|
|
|
|
begin
|
|
|
|
inherited OnInternalClosePopup(AResult);
|
2012-09-20 14:02:20 +00:00
|
|
|
CheckEditingKey;
|
2012-09-19 14:06:46 +00:00
|
|
|
if (AResult) and Assigned(FGrid.SelectedField) and Assigned(FLDS.DataSet) then
|
|
|
|
begin
|
2020-09-07 12:03:46 +00:00
|
|
|
//F:=FLDS.DataSet.FieldByName(LookupDisplay);
|
|
|
|
F:=FLDS.DataSet.FieldByName(LookupField);
|
2012-09-19 14:06:46 +00:00
|
|
|
if Assigned(F) then
|
2012-09-20 14:02:20 +00:00
|
|
|
begin
|
|
|
|
if (FGrid<>nil) and Visible then begin
|
|
|
|
FGrid.SetEditText(FCol, FRow, F.DisplayText);
|
|
|
|
end;
|
|
|
|
end;
|
2012-09-19 14:06:46 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-11-06 11:15:05 +00:00
|
|
|
constructor TRxDBGridLookupComboEditor.Create(AOwner: TComponent);
|
|
|
|
begin
|
|
|
|
inherited Create(AOwner);
|
2011-05-07 14:48:11 +00:00
|
|
|
FLDS := TDataSource.Create(nil);
|
|
|
|
LookupSource := FLDS;
|
2011-09-22 17:07:49 +00:00
|
|
|
AutoSize := false;
|
2018-02-09 08:21:55 +00:00
|
|
|
Style:=rxcsDropDownList;
|
2007-11-06 11:15:05 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxDBGridLookupComboEditor.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FLDS);
|
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxDBGrid }
|
|
|
|
|
|
|
|
procedure TRxDBGrid.SetTitleButtons(const AValue: boolean);
|
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
if AValue then
|
2011-05-07 14:48:11 +00:00
|
|
|
Options := Options + [dgHeaderPushedLook]
|
2009-06-29 16:01:00 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
Options := Options - [dgHeaderPushedLook];
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-10-12 13:35:03 +00:00
|
|
|
procedure TRxDBGrid.GetScrollbarParams(out aRange, aPage, aPos: Integer);
|
|
|
|
begin
|
|
|
|
if (DataSource.DataSet<>nil) and DataSource.DataSet.Active then begin
|
|
|
|
if DataSource.DataSet.IsSequenced then begin
|
|
|
|
aRange := DataSource.DataSet.RecordCount + VisibleRowCount - 1;
|
|
|
|
aPage := VisibleRowCount;
|
|
|
|
if aPage<1 then aPage := 1;
|
|
|
|
if DataSource.DataSet.BOF then aPos := 0 else
|
|
|
|
if DataSource.DataSet.EOF then aPos := aRange
|
|
|
|
else
|
|
|
|
aPos := DataSource.DataSet.RecNo - 1; // RecNo is 1 based
|
|
|
|
if aPos<0 then aPos:=0;
|
|
|
|
end else begin
|
|
|
|
aRange := 6;
|
|
|
|
aPage := 2;
|
|
|
|
if DataSource.DataSet.EOF then aPos := 4 else
|
|
|
|
if DataSource.DataSet.BOF then aPos := 0
|
|
|
|
else aPos := 2;
|
|
|
|
end;
|
|
|
|
end else begin
|
|
|
|
aRange := 0;
|
|
|
|
aPage := 0;
|
|
|
|
aPos := 0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.RestoreEditor;
|
|
|
|
begin
|
2012-09-26 14:19:29 +00:00
|
|
|
if EditorMode then
|
|
|
|
begin
|
2011-10-12 13:35:03 +00:00
|
|
|
EditorMode := False;
|
|
|
|
EditorMode := True;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure TRxDBGrid.SetAutoSort(const AValue: boolean);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
S: string;
|
|
|
|
Pos: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FAutoSort = AValue then
|
|
|
|
exit;
|
|
|
|
FAutoSort := AValue;
|
|
|
|
if Assigned(DataSource) and Assigned(DataSource.DataSet) and
|
|
|
|
DataSource.DataSet.Active then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S := DataSource.DataSet.ClassName;
|
2009-12-10 22:02:14 +00:00
|
|
|
if RxDBGridSortEngineList.Find(S, Pos) then
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortEngine := RxDBGridSortEngineList.Objects[Pos] as TRxDBGridSortEngine
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortEngine := nil;
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortColumns.Clear;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2015-09-07 07:42:04 +00:00
|
|
|
procedure TRxDBGrid.SetColumnDefValues(AValue: TRxDBGridColumnDefValues);
|
|
|
|
begin
|
|
|
|
FColumnDefValues.AssignTo(AValue);
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
function TRxDBGrid.GetColumns: TRxDbGridColumns;
|
|
|
|
begin
|
2017-02-27 05:38:55 +00:00
|
|
|
Result := TRxDbGridColumns(inherited Columns);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
function TRxDBGrid.GetFooterColor: TColor;
|
|
|
|
begin
|
|
|
|
Result:=FFooterOptions.FColor;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGrid.GetFooterRowCount: integer;
|
|
|
|
begin
|
|
|
|
Result:=FFooterOptions.RowCount;
|
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function TRxDBGrid.GetDrawFullLine: boolean;
|
|
|
|
begin
|
2016-05-05 06:49:18 +00:00
|
|
|
Result := FFooterOptions.FDrawFullLine;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2009-08-17 17:50:27 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.SetDrawFullLine(Value: boolean);
|
2009-08-17 17:50:27 +00:00
|
|
|
begin
|
2016-05-05 06:49:18 +00:00
|
|
|
FFooterOptions.DrawFullLine := Value;
|
2009-08-17 17:50:27 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-30 08:25:18 +00:00
|
|
|
function TRxDBGrid.CreateToolMenuItem(ShortCut: char; const ACaption: string;
|
|
|
|
MenuAction: TNotifyEvent): TMenuItem;
|
|
|
|
begin
|
|
|
|
Result := TMenuItem.Create(F_PopupMenu);
|
|
|
|
F_PopupMenu.Items.Add(Result);
|
|
|
|
Result.Caption := ACaption;
|
|
|
|
if ShortCut <> #0 then
|
|
|
|
Result.ShortCut := KeyToShortCut(Ord(ShortCut), [ssCtrl]);
|
|
|
|
Result.OnClick := MenuAction;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.RemoveToolMenuItem(MenuAction: TNotifyEvent);
|
2016-09-09 09:55:03 +00:00
|
|
|
var
|
|
|
|
R: TMenuItem;
|
2017-05-30 08:25:18 +00:00
|
|
|
I: Integer;
|
2016-09-09 09:55:03 +00:00
|
|
|
begin
|
2017-05-30 08:25:18 +00:00
|
|
|
if not Assigned(MenuAction) then Exit;
|
|
|
|
for I:=F_PopupMenu.Items.Count-1 downto 0 do
|
|
|
|
begin
|
|
|
|
R:=F_PopupMenu.Items[I];
|
|
|
|
if R.OnClick = MenuAction then
|
|
|
|
begin
|
|
|
|
F_PopupMenu.Items.Delete(i);
|
|
|
|
R.Free;
|
|
|
|
end;
|
|
|
|
end;
|
2016-09-09 09:55:03 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2016-09-09 09:55:03 +00:00
|
|
|
procedure TRxDBGrid.DoCreateJMenu;
|
2009-08-17 17:50:27 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
F_PopupMenu := TPopupMenu.Create(Self);
|
|
|
|
F_PopupMenu.Name := 'OptionsMenu';
|
2016-09-09 09:55:03 +00:00
|
|
|
CreateToolMenuItem('F', sRxDBGridFind, @OnFind);
|
|
|
|
CreateToolMenuItem('T', sRxDBGridFilter, @OnFilterBy);
|
|
|
|
CreateToolMenuItem('E', sRxDBGridFilterSimple, @OnFilter);
|
|
|
|
CreateToolMenuItem('Q', sRxDBGridFilterClear, @OnFilterClose);
|
|
|
|
CreateToolMenuItem(#0, '-', nil);
|
|
|
|
CreateToolMenuItem('C', sRxDBGridSortByColumns, @OnSortBy);
|
|
|
|
CreateToolMenuItem('W', sRxDBGridSelectColumns, @OnChooseVisibleFields);
|
|
|
|
CreateToolMenuItem('A', sRxDBGridSelectAllRows, @OnSelectAllRows);
|
|
|
|
CreateToolMenuItem(#0, sRxDBGridCopyCellValue, @OnCopyCellValue);
|
2016-09-20 07:48:58 +00:00
|
|
|
CreateToolMenuItem(#0, sRxDBGridOptimizeColWidth, @OnOptimizeColWidth);
|
2009-08-17 17:50:27 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
function TRxDBGrid.GetPropertyStorage: TCustomPropertyStorage;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := FPropertyStorageLink.Storage;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2012-05-12 17:51:20 +00:00
|
|
|
function TRxDBGrid.GetSortField: string;
|
|
|
|
begin
|
2012-09-21 17:06:21 +00:00
|
|
|
if FSortColumns.Count > 0 then
|
2014-02-08 11:02:58 +00:00
|
|
|
Result:=FSortColumns[0].GetSortFields
|
2012-05-12 17:51:20 +00:00
|
|
|
else
|
|
|
|
Result:='';
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
function TRxDBGrid.GetSortOrder: TSortMarker;
|
|
|
|
begin
|
|
|
|
if FSortColumns.Count > 0 then
|
|
|
|
Result:=FSortColumns[0].SortOrder
|
|
|
|
else
|
|
|
|
Result:=smNone;
|
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
function TRxDBGrid.GetTitleButtons: boolean;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := dgHeaderPushedLook in Options;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
function TRxDBGrid.IsColumnsStored: boolean;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := TRxDbGridColumns(TCustomDrawGrid(Self).Columns).Enabled;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure TRxDBGrid.SelectedFontChanged(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FIsSelectedDefaultFont:=FSelectedFont.IsDefault;
|
|
|
|
VisualChange;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGrid.IsSelectedFontStored: Boolean;
|
|
|
|
begin
|
|
|
|
Result:=not FIsSelectedDefaultFont
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure TRxDBGrid.SetColumns(const AValue: TRxDbGridColumns);
|
|
|
|
begin
|
2017-02-27 05:38:55 +00:00
|
|
|
inherited Columns := TDBGridColumns(AValue);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.SetFooterColor(const AValue: TColor);
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
FFooterOptions.Color := AValue;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.SetFooterOptions(AValue: TRxDBGridFooterOptions);
|
|
|
|
begin
|
|
|
|
FFooterOptions.AssignTo(AValue);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.SetFooterRowCount(const AValue: integer);
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
FFooterOptions.RowCount:=AValue;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
procedure TRxDBGrid.SetKeyStrokes(const AValue: TRxDBGridKeyStrokes);
|
|
|
|
begin
|
|
|
|
if Assigned(AValue) then
|
|
|
|
FKeyStrokes.Assign(AValue)
|
|
|
|
else
|
|
|
|
FKeyStrokes.Clear;
|
|
|
|
|
|
|
|
UpdateJMenuKeys;
|
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.SetOptionsRx(const AValue: TOptionsRx);
|
2009-10-28 19:31:30 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
OldOpt: TOptionsRx;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FOptionsRx = AValue then
|
|
|
|
exit;
|
2013-03-14 14:29:55 +00:00
|
|
|
BeginUpdate;
|
2011-05-07 14:48:11 +00:00
|
|
|
OldOpt := FOptionsRx;
|
|
|
|
FOptionsRx := AValue;
|
|
|
|
UseXORFeatures := rdgXORColSizing in AValue;
|
|
|
|
if (rdgFilter in AValue) and not (rdgFilter in OldOpt) then
|
2009-10-28 19:31:30 +00:00
|
|
|
begin
|
2017-12-28 08:57:47 +00:00
|
|
|
FillFilterData;
|
2009-10-28 19:31:30 +00:00
|
|
|
LayoutChanged;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if rdgFilter in OldOpt then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FFilterListEditor.Hide;
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterColDlgButton.Hide;
|
2017-12-05 12:00:42 +00:00
|
|
|
FFilterSimpleEdit.Hide;
|
2011-05-07 14:48:11 +00:00
|
|
|
LayoutChanged;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2012-02-25 07:27:11 +00:00
|
|
|
|
|
|
|
FFooterOptions.FActive:=rdgFooterRows in FOptionsRx;
|
2012-10-17 13:17:40 +00:00
|
|
|
|
|
|
|
if (rdgWordWrap in OldOpt) and not (rdgWordWrap in FOptionsRx) then
|
|
|
|
ResetRowHeght;
|
|
|
|
|
2013-03-14 14:29:55 +00:00
|
|
|
EndUpdate;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.SetPropertyStorage(const AValue: TCustomPropertyStorage);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FPropertyStorageLink.Storage := AValue;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2016-11-08 08:10:02 +00:00
|
|
|
procedure TRxDBGrid.SetSearchOptions(AValue: TRxDBGridSearchOptions);
|
|
|
|
begin
|
|
|
|
FSearchOptions.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure TRxDBGrid.SetSelectedFont(AValue: TFont);
|
|
|
|
begin
|
|
|
|
if not FSelectedFont.IsEqual(AValue) then
|
|
|
|
FSelectedFont.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
function TRxDBGrid.DatalinkActive: boolean;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := Assigned(DataSource) and Assigned(DataSource.DataSet) and
|
|
|
|
DataSource.DataSet.Active;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2019-04-18 08:47:25 +00:00
|
|
|
function TRxDBGrid.DataSetNotEmpty: boolean;
|
|
|
|
begin
|
|
|
|
Result := Assigned(DataSource) and Assigned(DataSource.DataSet) and (not DataSource.DataSet.IsEmpty);
|
|
|
|
end;
|
|
|
|
|
2013-05-16 17:57:58 +00:00
|
|
|
procedure TRxDBGrid.AdjustEditorBounds(NewCol, NewRow: Integer);
|
|
|
|
begin
|
2017-10-26 07:14:08 +00:00
|
|
|
inherited AdjustEditorBounds(NewCol, NewRow);
|
2013-05-16 17:57:58 +00:00
|
|
|
if EditorMode then
|
|
|
|
begin
|
|
|
|
DoSetColEdtBtn;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.TrackButton(X, Y: integer);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
|
|
|
Cell: TGridCoord;
|
2011-05-07 14:48:11 +00:00
|
|
|
NewPressed: boolean;
|
|
|
|
I, Offset: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
|
|
|
Cell := MouseCoord(X, Y);
|
2017-05-18 11:57:06 +00:00
|
|
|
Offset := RowCount;
|
2007-08-09 21:36:59 +00:00
|
|
|
NewPressed := PtInRect(Rect(0, 0, ClientWidth, ClientHeight), Point(X, Y)) and
|
2007-08-10 22:15:51 +00:00
|
|
|
(FPressedCol = TColumn(ColumnFromGridColumn(Cell.X))) and (Cell.Y < Offset);
|
2007-08-09 21:36:59 +00:00
|
|
|
if FPressed <> NewPressed then
|
|
|
|
begin
|
|
|
|
FPressed := NewPressed;
|
|
|
|
for I := 0 to Offset - 1 do
|
|
|
|
GridInvalidateRow(Self, I);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.StopTracking;
|
|
|
|
begin
|
|
|
|
if FTracking then
|
|
|
|
begin
|
|
|
|
TrackButton(-1, -1);
|
|
|
|
FTracking := False;
|
|
|
|
MouseCapture := False;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.CalcTitle;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i, j: integer;
|
2017-09-11 08:30:46 +00:00
|
|
|
H, H1, W, W1, FDefRowH: integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
rxCol, rxColNext: TRxColumn;
|
|
|
|
rxTit, rxTitleNext: TRxColumnTitle;
|
|
|
|
MLRec1, P: TMLCaptionItem;
|
|
|
|
MLRec2: TMLCaptionItem;
|
2009-07-02 16:37:41 +00:00
|
|
|
tmpCanvas: TCanvas;
|
2017-09-11 08:36:40 +00:00
|
|
|
FWC: SizeInt;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2021-09-10 13:03:24 +00:00
|
|
|
//FDefRowH:=GetDefaultRowHeight;
|
|
|
|
FDefRowH:=DefaultRowHeight;
|
2017-09-11 08:30:46 +00:00
|
|
|
|
2010-02-23 00:06:12 +00:00
|
|
|
{ TODO -oalexs : need rewrite code - split to 2 step:
|
|
|
|
1. make links between column
|
|
|
|
2. calc title width for all linked column series }
|
2011-05-07 14:48:11 +00:00
|
|
|
if RowCount = 0 then
|
|
|
|
exit;
|
2009-07-02 16:37:41 +00:00
|
|
|
tmpCanvas := GetWorkingCanvas(Canvas);
|
|
|
|
try
|
|
|
|
ClearMLCaptionPointers;
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxCol := TRxColumn(Columns[i]);
|
2009-07-02 16:37:41 +00:00
|
|
|
if Assigned(rxCol) and rxCol.Visible then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxTit := TRxColumnTitle(rxCol.Title);
|
2009-07-02 16:37:41 +00:00
|
|
|
if Assigned(rxTit) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2009-07-02 16:37:41 +00:00
|
|
|
if rxTit.Orientation in [toVertical270, toVertical90] then
|
2014-09-15 11:27:14 +00:00
|
|
|
// H := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) + tmpCanvas.TextWidth('W')*2) div DefaultRowHeight, H)
|
2009-07-02 16:37:41 +00:00
|
|
|
else
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxColNext := nil;
|
|
|
|
rxTitleNext := nil;
|
|
|
|
if i < Columns.Count - 1 then
|
2009-07-02 16:37:41 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxColNext := TRxColumn(Columns[i + 1]);
|
|
|
|
rxTitleNext := TRxColumnTitle(rxColNext.Title);
|
2009-07-02 16:37:41 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2014-09-15 11:27:14 +00:00
|
|
|
// W := Max(rxCol.Width - 6, 1);
|
2009-07-02 16:37:41 +00:00
|
|
|
if rxTit.CaptionLinesCount > 0 then
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2014-09-15 11:27:14 +00:00
|
|
|
// H2 := 0;
|
|
|
|
// H1 := 0;
|
2011-05-07 14:48:11 +00:00
|
|
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
MLRec1 := rxTit.CaptionLine(j);
|
2010-02-23 00:06:12 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if Assigned(rxTitleNext) and (rxTitleNext.CaptionLinesCount > j) then
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2012-07-23 16:27:52 +00:00
|
|
|
//make links to next column - and in the next column set link to prior-current
|
2011-05-07 14:48:11 +00:00
|
|
|
MLRec2 := rxTitleNext.CaptionLine(j);
|
2009-07-02 16:37:41 +00:00
|
|
|
if MLRec1.Caption = MLRec2.Caption then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
MLRec1.Next := MLRec2;
|
|
|
|
MLRec2.Prior := MLRec1;
|
2012-07-23 16:27:52 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
break;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
MLRec1.Width := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2014-09-15 11:27:14 +00:00
|
|
|
{ if W > MLRec1.Width then
|
2011-05-07 14:48:11 +00:00
|
|
|
H2 := 1
|
2009-07-02 16:37:41 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
H2 := MLRec1.Width div W + 1;
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if H2 > WordCount(MLRec1.Caption, [' ']) then
|
|
|
|
H2 := WordCount(MLRec1.Caption, [' ']);
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2014-09-15 11:27:14 +00:00
|
|
|
H1 := H1 + H2;}
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2009-06-29 16:01:00 +00:00
|
|
|
end
|
2014-09-15 11:27:14 +00:00
|
|
|
{ else
|
2009-07-02 16:37:41 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
|
|
|
|
if H1 > WordCount(rxTit.Caption, [' ']) then
|
|
|
|
H1 := WordCount(rxTit.Caption, [' ']);
|
2009-07-02 16:37:41 +00:00
|
|
|
end;
|
2014-09-15 11:27:14 +00:00
|
|
|
H := Max(H1, H); }
|
2009-07-02 16:37:41 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
MLRec1 := rxTit.CaptionLine(j);
|
2009-07-02 16:37:41 +00:00
|
|
|
if MLRec1.Width < rxTit.Column.Width then
|
2011-05-07 14:48:11 +00:00
|
|
|
MLRec1.Width := rxTit.Column.Width;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2010-06-29 16:38:27 +00:00
|
|
|
//Тут расчёт высоты заголовка каждой колонки - надо обработать слитые заголовки
|
2014-09-15 11:27:14 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
H := 1;
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
2010-06-29 16:38:27 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxCol := TRxColumn(Columns[i]);
|
|
|
|
rxTit := TRxColumnTitle(rxCol.Title);
|
|
|
|
H1 := 0;
|
2014-09-15 11:27:14 +00:00
|
|
|
W := Max(rxCol.Width - 6, 1);
|
2010-07-08 17:43:31 +00:00
|
|
|
//Не забудем про вертикальную ориентацию
|
2010-07-09 16:21:55 +00:00
|
|
|
if Assigned(rxCol) and rxCol.Visible and Assigned(rxTit) then
|
2010-06-29 16:38:27 +00:00
|
|
|
begin
|
2010-07-09 16:21:55 +00:00
|
|
|
if rxTit.Orientation in [toVertical270, toVertical90] then
|
2011-05-07 14:48:11 +00:00
|
|
|
H1 := Max((tmpCanvas.TextWidth(Columns[i].Title.Caption) +
|
2017-09-11 08:30:46 +00:00
|
|
|
tmpCanvas.TextWidth('W')) div FDefRowH, H)
|
2010-07-09 16:21:55 +00:00
|
|
|
else
|
2010-06-29 16:38:27 +00:00
|
|
|
begin
|
2014-09-15 11:27:14 +00:00
|
|
|
if rxTit.CaptionLinesCount = 0 then
|
2010-06-29 16:38:27 +00:00
|
|
|
begin
|
2014-09-15 11:27:14 +00:00
|
|
|
H1 := Max((tmpCanvas.TextWidth(rxTit.Caption) + 2) div W + 1, H);
|
2017-09-11 08:30:46 +00:00
|
|
|
FWC:=WordCount(rxTit.Caption, [' ']);
|
|
|
|
if H1 > FWC then H1 := FWC;
|
2014-09-15 11:27:14 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if rxTit.CaptionLinesCount > H then
|
|
|
|
H := rxTit.CaptionLinesCount;
|
|
|
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
2010-06-29 16:38:27 +00:00
|
|
|
begin
|
2014-09-15 11:27:14 +00:00
|
|
|
MLRec1 := rxTit.CaptionLine(j);
|
2016-05-12 07:25:00 +00:00
|
|
|
//S := MLRec1.Caption;
|
2014-09-15 11:27:14 +00:00
|
|
|
if not Assigned(MLRec1.Prior) then
|
2010-07-09 16:21:55 +00:00
|
|
|
begin
|
2014-09-15 11:27:14 +00:00
|
|
|
W := rxCol.Width;
|
|
|
|
P := MLRec1.Next;
|
|
|
|
while Assigned(P) do
|
|
|
|
begin
|
|
|
|
Inc(W, P.Col.Width);
|
|
|
|
P := P.Next;
|
|
|
|
end;
|
|
|
|
W1 := tmpCanvas.TextWidth(MLRec1.Caption) + 2;
|
|
|
|
if W1 > W then
|
2016-08-22 13:32:34 +00:00
|
|
|
MLRec1.Height := Min(W1 div Max(W, 1) + 1, UTF8Length(MLRec1.Caption))
|
2014-09-15 11:27:14 +00:00
|
|
|
else
|
2016-08-22 13:32:34 +00:00
|
|
|
MLRec1.Height := 1;
|
2014-09-15 11:27:14 +00:00
|
|
|
|
|
|
|
P := MLRec1.Next;
|
|
|
|
while Assigned(P) do
|
|
|
|
begin
|
2016-08-22 13:32:34 +00:00
|
|
|
P.Height := MLRec1.Height;
|
2014-09-15 11:27:14 +00:00
|
|
|
P := P.Next;
|
|
|
|
end;
|
2010-07-09 16:21:55 +00:00
|
|
|
end;
|
2016-08-22 13:32:34 +00:00
|
|
|
H1 := H1 + MLRec1.Height;
|
2010-06-29 16:38:27 +00:00
|
|
|
end;
|
2014-09-15 11:27:14 +00:00
|
|
|
|
2010-06-29 16:38:27 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
2010-07-08 17:43:31 +00:00
|
|
|
if H1 > H then
|
2011-05-07 14:48:11 +00:00
|
|
|
H := H1;
|
2010-07-08 17:43:31 +00:00
|
|
|
end;
|
|
|
|
|
2016-08-23 06:15:57 +00:00
|
|
|
if not (rdgDisableWordWrapTitles in OptionsRx) then
|
2017-09-11 08:30:46 +00:00
|
|
|
RowHeights[0] := FDefRowH * H
|
2016-08-23 06:15:57 +00:00
|
|
|
else
|
2017-09-11 08:30:46 +00:00
|
|
|
RowHeights[0] := FDefRowH;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2009-07-02 16:37:41 +00:00
|
|
|
if rdgFilter in OptionsRx then
|
|
|
|
begin
|
2017-12-18 08:35:51 +00:00
|
|
|
H:=FDefRowH;
|
|
|
|
if Assigned(FFilterListEditor) then
|
|
|
|
H:=Max(H, FFilterListEditor.Height);
|
|
|
|
|
2017-12-05 12:00:42 +00:00
|
|
|
if Assigned(FFilterSimpleEdit) then
|
2017-12-18 08:35:51 +00:00
|
|
|
H:=Max(H, FFilterSimpleEdit.Height);
|
|
|
|
|
|
|
|
RowHeights[0] := RowHeights[0] + H;
|
2009-07-02 16:37:41 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
finally
|
2011-05-07 14:48:11 +00:00
|
|
|
if TmpCanvas <> Canvas then
|
2009-07-02 16:37:41 +00:00
|
|
|
FreeWorkingCanvas(tmpCanvas);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
procedure TRxDBGrid.ClearMLCaptionPointers;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i, j: integer;
|
|
|
|
rxCol: TRxColumn;
|
|
|
|
rxTit: TRxColumnTitle;
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxCol := TRxColumn(Columns[i]);
|
2009-06-29 16:01:00 +00:00
|
|
|
if Assigned(rxCol) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxTit := TRxColumnTitle(rxCol.Title);
|
2009-06-29 16:01:00 +00:00
|
|
|
if Assigned(rxTit) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
for j := 0 to rxTit.CaptionLinesCount - 1 do
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
rxTit.CaptionLine(j).Next := nil;
|
|
|
|
rxTit.CaptionLine(j).Prior := nil;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
|
|
|
end;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure TRxDBGrid.FillDefaultFonts;
|
|
|
|
begin
|
|
|
|
FSelectedFont.Assign(Font);
|
|
|
|
//FSelectedFont.Color:=clHighlightText;
|
|
|
|
FIsSelectedDefaultFont := True;
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
function TRxDBGrid.getFilterRect(bRect: TRect): TRect;
|
|
|
|
begin
|
|
|
|
Result := bRect;
|
2009-10-28 19:31:30 +00:00
|
|
|
if Assigned(FFilterListEditor) then
|
|
|
|
Result.Top := bRect.Bottom - FFilterListEditor.Height
|
|
|
|
else
|
2021-09-10 13:03:24 +00:00
|
|
|
Result.Top := bRect.Bottom - DefaultRowHeight;
|
|
|
|
// Result.Top := bRect.Bottom - GetDefaultRowHeight;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGrid.getTitleRect(bRect: TRect): TRect;
|
|
|
|
begin
|
|
|
|
Result := bRect;
|
2009-10-28 19:31:30 +00:00
|
|
|
if Assigned(FFilterListEditor) then
|
|
|
|
Result.Bottom := bRect.Bottom - FFilterListEditor.Height
|
|
|
|
else
|
2021-09-10 13:03:24 +00:00
|
|
|
Result.Bottom := bRect.Bottom - DefaultRowHeight
|
|
|
|
// Result.Bottom := bRect.Bottom - GetDefaultRowHeight;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.OutCaptionCellText(aCol, aRow: integer; const aRect: TRect;
|
2009-06-29 16:01:00 +00:00
|
|
|
aState: TGridDrawState; const ACaption: string);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (TitleStyle = tsNative) then
|
2010-11-17 19:16:46 +00:00
|
|
|
DrawThemedCell(aCol, aRow, aRect, aState)
|
|
|
|
else
|
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
Canvas.FillRect(aRect);
|
2010-11-17 19:16:46 +00:00
|
|
|
DrawCellGrid(aCol, aRow, aRect, aState);
|
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
if ACaption <> '' then
|
2010-11-17 19:16:46 +00:00
|
|
|
begin
|
2016-08-23 06:15:57 +00:00
|
|
|
if not (rdgDisableWordWrapTitles in OptionsRx) then
|
|
|
|
WriteTextHeader(Canvas, aRect, ACaption, GetColumnAlignment(aCol, True))
|
|
|
|
else
|
|
|
|
DrawCellText(aCol, aRow, aRect, aState, ACaption);
|
2010-11-17 19:16:46 +00:00
|
|
|
end;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.OutCaptionCellText90(aCol, aRow: integer;
|
|
|
|
const aRect: TRect; aState: TGridDrawState; const ACaption: string;
|
|
|
|
const TextOrient: TTextOrientation);
|
2009-06-29 16:01:00 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
dW, dY: integer;
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (TitleStyle = tsNative) then
|
2010-11-17 19:16:46 +00:00
|
|
|
DrawThemedCell(aCol, aRow, aRect, aState)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Canvas.FillRect(aRect);
|
2011-05-07 14:48:11 +00:00
|
|
|
DrawCellGrid(aCol, aRow, aRect, aState);
|
2010-11-17 19:16:46 +00:00
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
|
|
|
|
if TextOrient in [toVertical90, toVertical270] then
|
2010-01-14 18:51:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
dW := ((aRect.Bottom - aRect.Top) - Canvas.TextWidth(ACaption)) div 2;
|
|
|
|
dY := ((aRect.Right - aRect.Left) - Canvas.TextHeight(ACaption)) div 2;
|
2010-01-14 18:51:51 +00:00
|
|
|
end
|
2009-06-29 16:01:00 +00:00
|
|
|
else
|
2010-01-14 18:51:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
dW := 0;
|
|
|
|
dY := 0;
|
2010-01-14 18:51:51 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
OutTextXY90(Canvas, aRect.Left + dY, aRect.Top + dw, ACaption, TextOrient);
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2012-09-26 14:19:29 +00:00
|
|
|
procedure TRxDBGrid.OutCaptionSortMarker(const aRect: TRect;
|
|
|
|
ASortMarker: TSortMarker; ASortPosition: integer);
|
2009-06-29 16:01:00 +00:00
|
|
|
var
|
2012-09-26 14:19:29 +00:00
|
|
|
X, Y, W: integer;
|
|
|
|
S:string;
|
|
|
|
F:TFont;
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
|
|
|
if (dgHeaderPushedLook in Options) then
|
|
|
|
begin
|
2012-09-26 14:19:29 +00:00
|
|
|
if (ASortMarker <> smNone) and (ASortPosition>0) then
|
|
|
|
begin
|
|
|
|
F:=TFont.Create;
|
|
|
|
F.Assign(Font);
|
|
|
|
|
|
|
|
if Font.Size = 0 then
|
|
|
|
Font.Size:=7
|
|
|
|
else
|
|
|
|
Font.Size:=Font.Size-2;
|
|
|
|
S:='('+IntToStr(ASortPosition)+')';
|
|
|
|
W:=Canvas.TextWidth(S) + 10;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
W:=6;
|
|
|
|
F:=nil;
|
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
if ASortMarker = smDown then
|
|
|
|
begin
|
2012-09-26 14:19:29 +00:00
|
|
|
X := aRect.Right - FMarkerDown.Width - W;
|
2011-05-07 14:48:11 +00:00
|
|
|
Y := Trunc((aRect.Top + aRect.Bottom - FMarkerDown.Height) / 2);
|
2009-06-29 16:01:00 +00:00
|
|
|
Canvas.Draw(X, Y, FMarkerDown);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if ASortMarker = smUp then
|
|
|
|
begin
|
2012-09-26 14:19:29 +00:00
|
|
|
X := aRect.Right - FMarkerUp.Width - W;
|
2011-05-07 14:48:11 +00:00
|
|
|
Y := Trunc((aRect.Top + aRect.Bottom - FMarkerUp.Height) / 2);
|
2009-06-29 16:01:00 +00:00
|
|
|
Canvas.Draw(X, Y, FMarkerUp);
|
|
|
|
end;
|
2012-09-26 14:19:29 +00:00
|
|
|
|
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
|
|
|
Canvas.TextOut( X + FMarkerDown.Width, Y, S);
|
|
|
|
Font.Assign(F);
|
|
|
|
FreeAndNil(F);
|
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.OutCaptionMLCellText(aCol, aRow: integer;
|
2009-06-29 16:01:00 +00:00
|
|
|
aRect: TRect; aState: TGridDrawState; MLI: TMLCaptionItem);
|
|
|
|
var
|
|
|
|
MLINext: TMLCaptionItem;
|
2010-02-23 00:06:12 +00:00
|
|
|
Rgn: HRGN;
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
MLINext := MLI.Next;
|
2009-06-29 16:01:00 +00:00
|
|
|
while Assigned(MLINext) do
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
aRect.Right := aRect.Right + MLINext.Col.Width;
|
|
|
|
MLINext := MLINext.Next;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
2010-02-23 00:06:12 +00:00
|
|
|
|
|
|
|
Rgn := CreateRectRgn(aRect.Left, aRect.Top, aRect.Right, aRect.Bottom);
|
|
|
|
SelectClipRgn(Canvas.Handle, Rgn);
|
2009-06-29 16:01:00 +00:00
|
|
|
OutCaptionCellText(aCol, aRow, aRect, aState, MLI.Caption);
|
2010-02-23 00:06:12 +00:00
|
|
|
SelectClipRgn(Canvas.Handle, 0);
|
|
|
|
DeleteObject(Rgn);
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
procedure TRxDBGrid.UpdateJMenuStates;
|
|
|
|
begin
|
2012-10-18 14:11:00 +00:00
|
|
|
F_PopupMenu.Items[0].Visible := rdgAllowDialogFind in FOptionsRx;
|
|
|
|
F_PopupMenu.Items[1].Visible := rdgAllowFilterForm in FOptionsRx;
|
|
|
|
F_PopupMenu.Items[2].Visible := rdgAllowQuickFilter in FOptionsRx;
|
|
|
|
F_PopupMenu.Items[3].Visible :=
|
2011-05-07 14:48:11 +00:00
|
|
|
(rdgFilter in FOptionsRx) or (rdgAllowFilterForm in FOptionsRx);
|
2012-10-18 14:11:00 +00:00
|
|
|
F_PopupMenu.Items[5].Visible := rdgAllowSortForm in FOptionsRx;
|
|
|
|
F_PopupMenu.Items[6].Visible := rdgAllowColumnsForm in FOptionsRx;
|
|
|
|
F_PopupMenu.Items[7].Visible := dgMultiselect in Options;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
procedure TRxDBGrid.UpdateJMenuKeys;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function DoShortCut(Cmd: TRxDBGridCommand): TShortCut;
|
|
|
|
var
|
|
|
|
K: TRxDBGridKeyStroke;
|
|
|
|
begin
|
|
|
|
K := FKeyStrokes.FindRxKeyStrokes(Cmd);
|
|
|
|
if Assigned(K) and K.Enabled then
|
|
|
|
Result := K.ShortCut
|
|
|
|
else
|
|
|
|
Result := 0;
|
|
|
|
end;
|
2010-05-19 15:33:28 +00:00
|
|
|
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
F_PopupMenu.Items[0].ShortCut := DoShortCut(rxgcShowFindDlg);
|
|
|
|
F_PopupMenu.Items[1].ShortCut := DoShortCut(rxgcShowFilterDlg);
|
|
|
|
F_PopupMenu.Items[2].ShortCut := DoShortCut(rxgcShowQuickFilter);
|
|
|
|
F_PopupMenu.Items[3].ShortCut := DoShortCut(rxgcHideQuickFilter);
|
|
|
|
F_PopupMenu.Items[5].ShortCut := DoShortCut(rxgcShowSortDlg);
|
|
|
|
F_PopupMenu.Items[6].ShortCut := DoShortCut(rxgcShowColumnsDlg);
|
2012-09-24 14:21:22 +00:00
|
|
|
F_PopupMenu.Items[7].ShortCut := DoShortCut(rxgcSelectAll);
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
2009-12-10 22:02:14 +00:00
|
|
|
function TRxDBGrid.SortEngineOptions: TRxSortEngineOptions;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := [];
|
2009-12-10 22:02:14 +00:00
|
|
|
if rdgCaseInsensitiveSort in FOptionsRx then
|
|
|
|
Include(Result, seoCaseInsensitiveSort);
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure TRxDBGrid.OnIniSave(Sender: TObject);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
|
|
|
S, S1: string;
|
|
|
|
C: TRxColumn;
|
2023-10-09 07:39:41 +00:00
|
|
|
SF: TCaption;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S := Owner.Name + '.' + Name;
|
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S + sVersion, FVersion);
|
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S + sCount, Columns.Count);
|
|
|
|
S := S + sItem;
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S1 := S + IntToStr(i);
|
|
|
|
C := TRxColumn(Columns[i]);
|
2023-10-09 07:39:41 +00:00
|
|
|
SF:=StrToHexText(C.Title.Caption);
|
|
|
|
FPropertyStorageLink.Storage.WriteString(S1 + sCaption, SF);
|
2020-08-18 08:30:06 +00:00
|
|
|
//FPropertyStorageLink.Storage.WriteInteger(S1 + sWidth, C.Width);
|
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S1 + sWidth, C.StoredWidth);
|
2011-05-07 14:48:11 +00:00
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S1 + sIndex, C.Index);
|
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S1 + sVisible, Ord(C.Visible));
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2009-12-03 17:41:24 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
{ TODO : Необходимо подключить сохранение списка колонок сортировки }
|
|
|
|
{
|
|
|
|
FSortColumns;
|
2009-12-03 17:41:24 +00:00
|
|
|
if Assigned(FSortField) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S1 + sSortMarker, Ord(FSortOrder));
|
|
|
|
FPropertyStorageLink.Storage.WriteString(S1 + sSortField, FSortField.FieldName);
|
2009-12-03 17:41:24 +00:00
|
|
|
end
|
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
FPropertyStorageLink.Storage.WriteInteger(S1 + sSortMarker, Ord(smNone));
|
2012-09-21 17:06:21 +00:00
|
|
|
}
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.OnIniLoad(Sender: TObject);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i, ACount: integer;
|
2023-10-09 07:39:41 +00:00
|
|
|
S, S1, ColumName, SF: string;
|
2011-05-07 14:48:11 +00:00
|
|
|
C: TRxColumn;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S := Owner.Name + '.' + Name;
|
|
|
|
ACount := FPropertyStorageLink.Storage.ReadInteger(S + sVersion, FVersion);
|
|
|
|
//Check cfg version
|
2007-08-09 21:36:59 +00:00
|
|
|
if ACount = FVersion then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
ACount := FPropertyStorageLink.Storage.ReadInteger(S + sCount, 0);
|
|
|
|
S := S + sItem;
|
|
|
|
for i := 0 to ACount - 1 do
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S1 := S + IntToStr(i);
|
2023-10-09 07:39:41 +00:00
|
|
|
SF:=FPropertyStorageLink.Storage.ReadString(S1 + sCaption, '');
|
|
|
|
ColumName := HexTextToStr(SF);
|
2011-05-07 14:48:11 +00:00
|
|
|
if ColumName <> '' then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
C := ColumnByCaption(ColumName);
|
2007-08-09 21:36:59 +00:00
|
|
|
if Assigned(C) then
|
2009-11-12 21:22:17 +00:00
|
|
|
begin
|
2018-03-30 08:50:27 +00:00
|
|
|
{$IFDEF FIX_WIDTH_WIDE_STRING96}
|
|
|
|
if Screen.PixelsPerInch = 96 then
|
|
|
|
{$ENDIF}
|
2011-05-07 14:48:11 +00:00
|
|
|
C.Width := FPropertyStorageLink.Storage.ReadInteger(S1 + sWidth, C.Width);
|
2018-03-23 11:05:50 +00:00
|
|
|
C.Visible := FPropertyStorageLink.Storage.ReadInteger(S1 + sVisible, Ord(C.Visible)) = 1;
|
|
|
|
C.Index := Min(FPropertyStorageLink.Storage.ReadInteger(S1 + sIndex, C.Index), Columns.Count - 1);
|
2009-11-12 21:22:17 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
2009-12-03 17:41:24 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
{ TODO : Необходимо подключить востановление списка колонок сортировки }
|
|
|
|
{ FSortOrder := TSortMarker(FPropertyStorageLink.Storage.ReadInteger(
|
2011-05-07 14:48:11 +00:00
|
|
|
S1 + sSortMarker, Ord(smNone)));
|
|
|
|
if Assigned(FSortEngine) and (FSortOrder <> smNone) and DatalinkActive then
|
2009-12-03 17:41:24 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
ColumName := FPropertyStorageLink.Storage.ReadString(S1 + sSortField, '');
|
|
|
|
if ColumName <> '' then
|
2009-12-03 17:41:24 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortField := DataSource.DataSet.FindField(ColumName);
|
2009-12-03 17:41:24 +00:00
|
|
|
if Assigned(FSortField) then
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortEngine.Sort(FSortField, DataSource.DataSet, FSortOrder = smUp,
|
|
|
|
SortEngineOptions);
|
2009-12-03 17:41:24 +00:00
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
end;}
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-12-23 19:13:50 +00:00
|
|
|
procedure TRxDBGrid.CleanDSEvent;
|
|
|
|
begin
|
|
|
|
if Assigned(DataSource) and Assigned(DataSource.DataSet) then
|
|
|
|
begin
|
|
|
|
if DataSource.DataSet.OnPostError = @ErrorPo then
|
|
|
|
DataSource.DataSet.OnPostError := F_EventOnPostError;
|
2012-04-15 21:05:55 +00:00
|
|
|
|
|
|
|
if DataSource.DataSet.OnFilterRecord = @FilterRec then
|
|
|
|
DataSource.DataSet.OnFilterRecord := F_EventOnFilterRec;
|
|
|
|
|
|
|
|
if DataSource.DataSet.BeforeDelete = @BeforeDel then
|
|
|
|
DataSource.DataSet.BeforeDelete := F_EventOnBeforeDelete;
|
|
|
|
|
|
|
|
if DataSource.DataSet.BeforePost = @BeforePo then
|
|
|
|
DataSource.DataSet.BeforePost:=F_EventOnBeforePost;
|
|
|
|
|
|
|
|
if DataSource.DataSet.OnDeleteError = @ErrorDel then
|
|
|
|
DataSource.DataSet.OnDeleteError:=F_EventOnDeleteError;
|
|
|
|
|
|
|
|
if DataSource.DataSet.OnPostError = @ErrorPo then
|
|
|
|
DataSource.DataSet.OnPostError:=F_EventOnPostError;
|
|
|
|
|
2018-06-18 06:34:41 +00:00
|
|
|
if Datalink.OnDataSetScrolled = @OnDataSetScrolled then
|
|
|
|
Datalink.OnDataSetScrolled:=FSaveOnDataSetScrolled;
|
|
|
|
|
2012-04-15 21:05:55 +00:00
|
|
|
F_EventOnPostError:=nil;
|
|
|
|
F_EventOnFilterRec:=nil;
|
|
|
|
F_EventOnBeforeDelete:=nil;
|
|
|
|
F_EventOnBeforePost:=nil;
|
|
|
|
F_EventOnDeleteError:=nil;
|
|
|
|
F_EventOnPostError:=nil;
|
2018-06-18 06:34:41 +00:00
|
|
|
FSaveOnDataSetScrolled:=nil;
|
2011-12-23 19:13:50 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure TRxDBGrid.CollumnSortListUpdate;
|
|
|
|
var
|
|
|
|
i, J:integer;
|
|
|
|
C:TRxColumn;
|
|
|
|
begin
|
|
|
|
FSortColumns.Clear;
|
|
|
|
for i:=0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
C:=TRxColumn(Columns[i]);
|
|
|
|
if C.SortOrder <> smNone then
|
|
|
|
begin
|
|
|
|
if FSortColumns.Count <> 0 then
|
|
|
|
begin
|
|
|
|
for j:=0 to FSortColumns.Count-1 do
|
|
|
|
if FSortColumns[j].FSortPosition > C.FSortPosition then
|
|
|
|
begin
|
|
|
|
FSortColumns.Insert(j, C);
|
|
|
|
C:=nil;
|
|
|
|
Break;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if C<>nil then
|
|
|
|
FSortColumns.Add(C);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
for i:=0 to FSortColumns.Count - 1 do
|
|
|
|
FSortColumns[i].FSortPosition:=i;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.CollumnSortListClear;
|
|
|
|
var
|
|
|
|
i:integer;
|
|
|
|
begin
|
|
|
|
FSortColumns.Clear;
|
|
|
|
for i:=0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
TRxColumn(Columns[i]).FSortOrder:=smNone;
|
|
|
|
TRxColumn(Columns[i]).FSortPosition:=0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.CollumnSortListApply;
|
|
|
|
var
|
|
|
|
i:integer;
|
|
|
|
S:string;
|
|
|
|
Asc:array of boolean;
|
|
|
|
begin
|
2013-03-28 15:40:03 +00:00
|
|
|
if (FSortColumns.Count = 0) then exit;
|
2016-05-12 07:25:00 +00:00
|
|
|
S:='';
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortingNow:=true;
|
2014-03-13 19:54:30 +00:00
|
|
|
if (FSortColumns.Count>1) or (Pos(';', FSortColumns[0].GetSortFields)>0) then
|
2012-09-26 14:19:29 +00:00
|
|
|
begin
|
|
|
|
SetLength(Asc, FSortColumns.Count);
|
|
|
|
for i := 0 to FSortColumns.Count - 1 do
|
|
|
|
begin
|
|
|
|
Asc[i]:=FSortColumns[i].FSortOrder = smUp;
|
|
|
|
if S<>'' then
|
|
|
|
S:=S+';';
|
2014-02-08 11:02:58 +00:00
|
|
|
S:=S + FSortColumns[i].GetSortFields;
|
2012-09-26 14:19:29 +00:00
|
|
|
end;
|
|
|
|
{ TODO : Необходимо добавить опцию регистронезависимого поиска }
|
|
|
|
FSortEngine.SortList(S, DataSource.DataSet, Asc, SortEngineOptions);
|
|
|
|
end
|
|
|
|
else
|
2014-02-08 11:02:58 +00:00
|
|
|
FSortEngine.Sort(FSortColumns[0].GetSortFields, DataSource.DataSet, FSortColumns[0].FSortOrder = smUp, SortEngineOptions);
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortingNow:=false;
|
|
|
|
end;
|
|
|
|
|
2014-04-09 17:33:24 +00:00
|
|
|
procedure TRxDBGrid.Notification(AComponent: TComponent; Operation: TOperation);
|
2020-07-02 07:13:46 +00:00
|
|
|
var
|
|
|
|
C: TRxColumn;
|
2014-04-09 17:33:24 +00:00
|
|
|
begin
|
|
|
|
inherited Notification(AComponent, Operation);
|
|
|
|
if Assigned(Datalink) and (AComponent = DataSource) and (Operation = opRemove) then
|
|
|
|
begin
|
|
|
|
ShowMessage('i');
|
2014-07-23 11:40:36 +00:00
|
|
|
end
|
|
|
|
else
|
2020-07-02 07:13:46 +00:00
|
|
|
if (Operation = opRemove) then
|
|
|
|
begin
|
|
|
|
if (AComponent is TRxDBGridAbstractTools) then
|
|
|
|
RemoveTools(TRxDBGridAbstractTools(AComponent))
|
|
|
|
else
|
|
|
|
if (AComponent is TPopupMenu) then
|
|
|
|
begin
|
|
|
|
for C in Columns do
|
|
|
|
if C.PopupMenu = AComponent then
|
|
|
|
C.PopupMenu:=nil;
|
|
|
|
end;
|
|
|
|
end;
|
2014-04-09 17:33:24 +00:00
|
|
|
end;
|
|
|
|
|
2013-05-08 05:26:49 +00:00
|
|
|
function TRxDBGrid.UpdateRowsHeight: integer;
|
2012-10-17 13:17:40 +00:00
|
|
|
var
|
2017-05-18 11:16:05 +00:00
|
|
|
i, J, H, H1, H2:integer;
|
2012-10-17 13:17:40 +00:00
|
|
|
F:TField;
|
|
|
|
S:string;
|
|
|
|
CurActiveRecord: Integer;
|
|
|
|
R:TRxColumn;
|
2017-05-26 13:05:56 +00:00
|
|
|
P: PtrInt;
|
2017-05-18 10:25:59 +00:00
|
|
|
|
2012-10-17 13:17:40 +00:00
|
|
|
begin
|
2013-05-08 05:26:49 +00:00
|
|
|
Result:=0;
|
2017-05-26 13:05:56 +00:00
|
|
|
if (not (Assigned(DataLink) and DataLink.Active)) or ((GCache.VisibleGrid.Top=0) and (GCache.VisibleGrid.Bottom=0)) then
|
2012-10-17 13:17:40 +00:00
|
|
|
exit;
|
|
|
|
|
|
|
|
CurActiveRecord:=DataLink.ActiveRecord;
|
2013-05-08 05:26:49 +00:00
|
|
|
H2:=0;
|
2017-05-18 11:16:05 +00:00
|
|
|
|
2012-10-17 13:17:40 +00:00
|
|
|
for i:=GCache.VisibleGrid.Top to GCache.VisibleGrid.Bottom do
|
|
|
|
begin
|
|
|
|
DataLink.ActiveRecord:=i - FixedRows;
|
2017-05-26 13:05:56 +00:00
|
|
|
P:=PtrInt(DataSource.DataSet.ActiveBuffer);
|
2012-10-17 13:17:40 +00:00
|
|
|
H:=1;
|
|
|
|
for j:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
R:=Columns[j] as TRxColumn;;
|
|
|
|
if R.WordWrap then
|
|
|
|
begin
|
|
|
|
F:=R.Field;
|
|
|
|
if Assigned(F) then
|
|
|
|
S:=F.DisplayText
|
|
|
|
else
|
|
|
|
S:='';
|
|
|
|
|
|
|
|
H1 := Max((Canvas.TextWidth(S) + 2) div R.Width + 1, H);
|
|
|
|
if H1 > WordCount(S, [' ']) then
|
|
|
|
H1 := WordCount(S, [' ']);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
H1:=1;
|
|
|
|
H:=Max(H, H1);
|
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if FGroupItems.Active and DatalinkActive then
|
|
|
|
if Assigned(FGroupItems.FindGroupItem(DataSource.DataSet.Bookmark)) then
|
|
|
|
Inc(H);
|
|
|
|
|
|
|
|
|
2012-10-17 13:17:40 +00:00
|
|
|
if i<RowCount then
|
2013-05-08 05:26:49 +00:00
|
|
|
begin
|
2017-05-18 11:16:05 +00:00
|
|
|
if Assigned(FOnCalcRowHeight) then
|
|
|
|
FOnCalcRowHeight(Self, H);
|
2021-09-10 13:03:24 +00:00
|
|
|
//RowHeights[i] := GetDefaultRowHeight * H;
|
|
|
|
RowHeights[i] := DefaultRowHeight * H;
|
|
|
|
|
2013-05-08 05:26:49 +00:00
|
|
|
H2:=H2 + RowHeights[i];
|
|
|
|
if H2<=ClientHeight then
|
|
|
|
Inc(Result);
|
|
|
|
end;
|
2012-10-17 13:17:40 +00:00
|
|
|
end;
|
|
|
|
DataLink.ActiveRecord:=CurActiveRecord;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.ResetRowHeght;
|
|
|
|
var
|
|
|
|
i:integer;
|
|
|
|
begin
|
|
|
|
for i:=1 to RowCount-1 do
|
2021-09-10 13:03:24 +00:00
|
|
|
RowHeights[i] := DefaultRowHeight
|
|
|
|
// RowHeights[i] := GetDefaultRowHeight;
|
2012-10-17 13:17:40 +00:00
|
|
|
end;
|
|
|
|
|
2013-03-12 14:08:34 +00:00
|
|
|
procedure TRxDBGrid.DoClearInvalidTitle;
|
|
|
|
var
|
|
|
|
i, j:integer;
|
|
|
|
FTitle:TRxColumnTitle;
|
|
|
|
begin
|
|
|
|
for i:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
FTitle:=TRxColumnTitle(Columns[i].Title);
|
|
|
|
for j:=0 to FTitle.CaptionLinesCount-1 do
|
|
|
|
FTitle.CaptionLine(j).FInvalidDraw:=0;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.DoDrawInvalidTitle;
|
|
|
|
var
|
2017-05-18 11:57:06 +00:00
|
|
|
i, j:integer;
|
2013-03-12 14:08:34 +00:00
|
|
|
MLI:TMLCaptionItem;
|
|
|
|
FTitle:TRxColumnTitle;
|
|
|
|
begin
|
|
|
|
for i:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
FTitle:=TRxColumnTitle(Columns[i].Title);
|
|
|
|
for j:=0 to FTitle.CaptionLinesCount - 1 do
|
|
|
|
begin
|
|
|
|
MLI:=FTitle.CaptionLine(j);
|
|
|
|
if MLI.FInvalidDraw<0 then
|
|
|
|
begin
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2013-05-16 17:57:58 +00:00
|
|
|
procedure TRxDBGrid.DoSetColEdtBtn;
|
|
|
|
var
|
|
|
|
R:TRxColumn;
|
|
|
|
i, w:integer;
|
2014-02-02 11:14:10 +00:00
|
|
|
SB:TGraphicControl;
|
2013-05-16 17:57:58 +00:00
|
|
|
begin
|
|
|
|
R:=SelectedColumn as TRxColumn;
|
|
|
|
|
|
|
|
if Assigned(Editor) and Assigned(R) then
|
|
|
|
begin
|
|
|
|
W:=0;
|
|
|
|
for i:=0 to R.EditButtons.Count-1 do
|
|
|
|
begin
|
2015-06-17 08:09:34 +00:00
|
|
|
if R.EditButtons[i].Visible and R.EditButtons[i].Enabled then
|
2013-05-16 17:57:58 +00:00
|
|
|
W:=W+R.EditButtons[i].Width;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if W>0 then
|
|
|
|
begin
|
|
|
|
if Editor.Name = 'ButtonEditor' then
|
|
|
|
begin
|
|
|
|
Editor.Left:=Editor.Left - W;
|
|
|
|
W:=Editor.Width + Editor.Left;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Editor.Width:=Editor.Width - W;
|
|
|
|
W:=Editor.Width + Editor.Left;
|
|
|
|
end;
|
|
|
|
|
|
|
|
for i:=0 to R.EditButtons.Count-1 do
|
2015-06-17 08:09:34 +00:00
|
|
|
if R.EditButtons[i].Visible and R.EditButtons[i].Enabled then
|
2013-05-16 17:57:58 +00:00
|
|
|
begin
|
2014-02-02 11:14:10 +00:00
|
|
|
if R.EditButtons[i].Style = ebsUpDownRx then
|
|
|
|
begin
|
|
|
|
SB:=R.EditButtons[i].FSpinBtn;
|
|
|
|
TRxSpinButton(SB).FocusControl:=Editor;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
SB:=R.EditButtons[i].FButton;
|
|
|
|
|
|
|
|
SB.Parent:=Self;
|
|
|
|
SB.Left:=W;
|
|
|
|
SB.Top:=Editor.Top;
|
|
|
|
SB.Height:=Editor.Height;
|
|
|
|
SB.Visible:=true;
|
2017-05-18 11:57:06 +00:00
|
|
|
|
2014-02-02 11:14:10 +00:00
|
|
|
W:=W+R.EditButtons[i].Width;
|
2013-05-16 17:57:58 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
procedure TRxDBGrid.AddTools(ATools: TRxDBGridAbstractTools);
|
|
|
|
var
|
|
|
|
i:integer;
|
|
|
|
R: TMenuItem;
|
|
|
|
begin
|
2018-02-02 10:42:27 +00:00
|
|
|
if not Assigned(ATools) then Exit;
|
|
|
|
|
2014-07-23 11:40:36 +00:00
|
|
|
for i:=8 to F_PopupMenu.Items.Count - 1 do
|
|
|
|
if F_PopupMenu.Items[i].Tag = IntPtr(ATools) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
R := TMenuItem.Create(F_PopupMenu);
|
|
|
|
F_PopupMenu.Items.Add(R);
|
|
|
|
R.Caption := ATools.FCaption;
|
|
|
|
R.OnClick := @(ATools.ExecTools);
|
|
|
|
R.Tag:=IntPtr(ATools);
|
2018-02-02 10:42:27 +00:00
|
|
|
R.Enabled:=ATools.Enabled;
|
2015-05-25 10:12:12 +00:00
|
|
|
|
|
|
|
if Assigned(FToolsList) and (FToolsList.IndexOf(ATools)<0) then
|
|
|
|
FToolsList.Add(ATools);
|
2014-07-23 11:40:36 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.RemoveTools(ATools: TRxDBGridAbstractTools);
|
|
|
|
var
|
|
|
|
i:integer;
|
|
|
|
R: TMenuItem;
|
|
|
|
begin
|
|
|
|
for i:=8 to F_PopupMenu.Items.Count - 1 do
|
|
|
|
if F_PopupMenu.Items[i].Tag = IntPtr(ATools) then
|
|
|
|
begin
|
|
|
|
R:=F_PopupMenu.Items[i];
|
|
|
|
F_PopupMenu.Items.Delete(i);
|
|
|
|
R.Free;
|
|
|
|
exit;
|
|
|
|
end;
|
2015-05-25 10:12:12 +00:00
|
|
|
|
|
|
|
if Assigned(FToolsList) then
|
|
|
|
FToolsList.Remove(ATools);
|
2014-07-23 11:40:36 +00:00
|
|
|
end;
|
|
|
|
|
2018-02-02 10:42:27 +00:00
|
|
|
procedure TRxDBGrid.UpdateToolsState(ATools: TRxDBGridAbstractTools);
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
begin
|
|
|
|
if not Assigned(ATools) then Exit;
|
|
|
|
for i:=8 to F_PopupMenu.Items.Count - 1 do
|
|
|
|
if F_PopupMenu.Items[i].Tag = IntPtr(ATools) then
|
|
|
|
begin
|
|
|
|
F_PopupMenu.Items[i].Enabled:=ATools.Enabled;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2017-05-18 10:25:59 +00:00
|
|
|
procedure TRxDBGrid.OnDataSetScrolled(aDataSet: TDataSet; Distance: Integer);
|
|
|
|
begin
|
|
|
|
if Assigned(FSaveOnDataSetScrolled) then
|
|
|
|
FSaveOnDataSetScrolled(aDataSet, Distance);
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if (rdgWordWrap in FOptionsRx) or (FGroupItems.Active) then
|
2017-05-18 10:25:59 +00:00
|
|
|
UpdateRowsHeight;
|
|
|
|
end;
|
|
|
|
|
2017-11-23 08:28:58 +00:00
|
|
|
function TRxDBGrid.GetFieldDisplayText(AField: TField; ACollumn: TRxColumn
|
|
|
|
): string;
|
|
|
|
var
|
2022-02-06 20:23:06 +00:00
|
|
|
J, i: Integer;
|
2017-11-23 08:28:58 +00:00
|
|
|
begin
|
|
|
|
Result:='';
|
|
|
|
if Assigned(AField) then
|
|
|
|
begin
|
|
|
|
if AField.dataType <> ftBlob then
|
|
|
|
begin
|
2017-12-11 08:33:08 +00:00
|
|
|
{$IF lcl_fullversion >= 1090000}
|
2017-11-23 08:28:58 +00:00
|
|
|
if CheckDisplayMemo(AField) then
|
2022-02-06 20:23:06 +00:00
|
|
|
begin
|
|
|
|
Result := AField.AsString;
|
|
|
|
{$IFDEF RDBGridDisplayMemoText_ClearSC}
|
|
|
|
for i:=1 to Length(Result) do
|
|
|
|
if Result[i] < ' ' then
|
|
|
|
Result[i]:=' ';
|
|
|
|
{$ENDIF}
|
|
|
|
end
|
2017-11-23 08:28:58 +00:00
|
|
|
else
|
2017-12-11 08:33:08 +00:00
|
|
|
{$ENDIF}
|
2017-11-23 08:28:58 +00:00
|
|
|
Result := AField.DisplayText;
|
|
|
|
if Assigned(ACollumn) and (ACollumn.KeyList.Count > 0) and (ACollumn.PickList.Count > 0) then
|
|
|
|
begin
|
|
|
|
J := ACollumn.KeyList.IndexOf(Result);
|
|
|
|
if (J >= 0) and (J < ACollumn.PickList.Count) then
|
|
|
|
Result := ACollumn.PickList[j];
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := FColumnDefValues.FBlobText;
|
|
|
|
end
|
|
|
|
end;
|
|
|
|
|
2018-05-08 12:31:39 +00:00
|
|
|
function CompareDates(List: TStringList; Index1, Index: Integer): Integer;
|
|
|
|
var
|
|
|
|
d1, d2: TDateTime;
|
|
|
|
begin
|
|
|
|
TryStrToDateTime(List[Index1], d1);
|
|
|
|
TryStrToDateTime(List[Index], d2);
|
|
|
|
Result := -CompareDate(d1, d2);
|
|
|
|
end;
|
|
|
|
(*
|
|
|
|
function CompareIntegers(List: TStringList; Index1, Index: Integer): Integer;
|
|
|
|
var
|
|
|
|
d1, d2: Extended;
|
|
|
|
begin
|
|
|
|
TryStrToFloat(List[Index1], d1);
|
|
|
|
TryStrToFloat(List[Index], d2);
|
|
|
|
Result := -CompareValue(d1, d2);
|
|
|
|
end;
|
|
|
|
*)
|
|
|
|
|
2017-12-28 08:57:47 +00:00
|
|
|
procedure TRxDBGrid.FillFilterData;
|
|
|
|
var
|
|
|
|
i: Integer;
|
|
|
|
C: TRxColumn;
|
|
|
|
FBS, FAS: TDataSetNotifyEvent;
|
2018-05-08 12:31:39 +00:00
|
|
|
|
2017-12-28 08:57:47 +00:00
|
|
|
begin
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
C := TRxColumn(Columns[i]);
|
2018-05-08 12:31:39 +00:00
|
|
|
C.Filter.ValueList.SortStyle := sslAuto;
|
2017-12-28 08:57:47 +00:00
|
|
|
C.Filter.ValueList.Clear;
|
|
|
|
C.Filter.CurrentValues.Clear;
|
|
|
|
C.Filter.ManulEditValue:='';
|
|
|
|
C.Filter.ItemIndex := -1;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if DatalinkActive then
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.DisableControls;
|
|
|
|
DataSource.DataSet.Filtered := True;
|
|
|
|
FBS:=DataSource.DataSet.BeforeScroll;
|
|
|
|
FAS:=DataSource.DataSet.AfterScroll;
|
|
|
|
DataSource.DataSet.BeforeScroll:=nil;
|
|
|
|
DataSource.DataSet.AfterScroll:=nil;
|
|
|
|
DataSource.DataSet.First;
|
|
|
|
while not DataSource.DataSet.EOF do
|
|
|
|
begin
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
C := TRxColumn(Columns[i]);
|
|
|
|
if C.Filter.Enabled and (C.Field <> nil) and (C.Filter.ValueList.IndexOf(C.Field.DisplayText) < 0) then
|
2019-10-23 10:12:58 +00:00
|
|
|
C.Filter.ValueList.Add(GetFieldDisplayText(C.Field, C)); // C.Field.DisplayText);
|
|
|
|
//C.Filter.ValueList.Add(C.Field.DisplayText);
|
2017-12-28 08:57:47 +00:00
|
|
|
end;
|
|
|
|
DataSource.DataSet.Next;
|
|
|
|
end;
|
|
|
|
DataSource.DataSet.First;
|
|
|
|
DataSource.DataSet.BeforeScroll:=FBS;
|
|
|
|
DataSource.DataSet.AfterScroll:=FAS;
|
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
end;
|
2018-05-08 12:31:39 +00:00
|
|
|
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
C := TRxColumn(Columns[i]);
|
|
|
|
|
|
|
|
if Assigned(C.Field) and (C.Field.DataType in DataTimeTypes) then
|
|
|
|
begin
|
|
|
|
C.Filter.ValueList.SortStyle := sslUser;
|
|
|
|
C.Filter.ValueList.CustomSort(@CompareDates);
|
|
|
|
end
|
|
|
|
{ else
|
|
|
|
if Assigned(C.Field) and (C.Field.DataType in NumericDataTypes) then
|
|
|
|
begin
|
|
|
|
C.Filter.ValueList.SortStyle := sslUser;
|
|
|
|
C.Filter.ValueList.CustomSort(@CompareIntegers);
|
|
|
|
end};
|
|
|
|
|
|
|
|
C.Filter.ValueList.SortStyle := sslNone;
|
|
|
|
C.Filter.ValueList.Insert(0, C.Filter.AllValue);
|
|
|
|
C.Filter.ValueList.Insert(0, C.Filter.EmptyValue);
|
|
|
|
end;
|
|
|
|
|
2017-12-28 08:57:47 +00:00
|
|
|
end;
|
|
|
|
|
2021-02-20 08:27:49 +00:00
|
|
|
procedure TRxDBGrid.DoCblClickMrOk;
|
|
|
|
begin
|
|
|
|
if Owner is TCustomForm then
|
|
|
|
TCustomForm(Owner).ModalResult := mrOk
|
|
|
|
else
|
|
|
|
if Owner is TCustomFrame then
|
|
|
|
begin
|
|
|
|
if TCustomFrame(Owner).Owner is TCustomForm then
|
|
|
|
((TCustomFrame(Owner).Owner) as TCustomForm).ModalResult := mrOk
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.DefaultDrawCellA(aCol, aRow: integer; aRect: TRect;
|
2007-08-09 21:36:59 +00:00
|
|
|
aState: TGridDrawState);
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
PrepareCanvas(aCol, aRow, aState);
|
|
|
|
if rdgFilter in OptionsRx then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
DefaultDrawFilter(aCol, aRow, getFilterRect(aRect), aState);
|
|
|
|
DefaultDrawTitle(aCol, aRow, getTitleRect(aRect), aState);
|
2007-08-10 22:15:51 +00:00
|
|
|
end
|
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
DefaultDrawTitle(aCol, aRow, aRect, aState);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.DefaultDrawTitle(aCol, aRow: integer; aRect: TRect;
|
2007-08-10 22:15:51 +00:00
|
|
|
aState: TGridDrawState);
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2013-03-12 14:08:34 +00:00
|
|
|
procedure DoClearMLIInvalid(MLI1: TMLCaptionItem);
|
|
|
|
begin
|
|
|
|
while Assigned(MLI1) do
|
|
|
|
begin
|
|
|
|
inc(MLI1.FInvalidDraw);
|
|
|
|
MLI1:=MLI1.Next;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
|
|
|
ASortMarker: TSortMarker;
|
2012-09-26 14:19:29 +00:00
|
|
|
ASortPosition: integer;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
Background: TColor;
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
|
|
|
Down: boolean;
|
2007-08-10 22:15:51 +00:00
|
|
|
aRect2: TRect;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FTitle: TRxColumnTitle;
|
2012-09-21 17:06:21 +00:00
|
|
|
GrdCol: TRxColumn;
|
|
|
|
|
2017-05-18 11:57:06 +00:00
|
|
|
MLI : TMLCaptionItem;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (dgIndicator in Options) and (aCol = 0) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Canvas.FillRect(aRect);
|
|
|
|
if F_Clicked then
|
|
|
|
aState := aState + [gdPushed];
|
2010-11-17 19:16:46 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if (TitleStyle = tsNative) then
|
|
|
|
DrawThemedCell(aCol, aRow, aRect, aState)
|
|
|
|
else
|
|
|
|
DrawCellGrid(aCol, aRow, aRect, aState);
|
2010-11-17 19:16:46 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if DatalinkActive and (rdgAllowToolMenu in FOptionsRx) then
|
|
|
|
Canvas.Draw((ARect.Left + ARect.Right - F_MenuBMP.Width) div 2,
|
|
|
|
(ARect.Top + ARect.Bottom - F_MenuBMP.Height) div 2, F_MenuBMP);
|
|
|
|
exit;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
GrdCol := TRxColumn(ColumnFromGridColumn(aCol));
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
Down := FPressed and (dgHeaderPushedLook in Options) and
|
2012-09-21 17:06:21 +00:00
|
|
|
(FPressedCol = GrdCol);
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
if Assigned(GrdCol) then
|
2012-09-26 14:19:29 +00:00
|
|
|
begin
|
|
|
|
ASortMarker := GrdCol.FSortOrder;
|
|
|
|
if FSortColumns.Count>1 then
|
|
|
|
ASortPosition:=GrdCol.FSortPosition
|
|
|
|
else
|
|
|
|
ASortPosition:=-1;
|
|
|
|
end
|
2012-09-21 17:06:21 +00:00
|
|
|
else
|
|
|
|
ASortMarker := smNone;
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
if Assigned(FOnGetBtnParams) and Assigned(GetFieldFromGridColumn(aCol)) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Background := Canvas.Brush.Color;
|
2007-08-09 21:36:59 +00:00
|
|
|
FOnGetBtnParams(Self, GetFieldFromGridColumn(aCol), Canvas.Font,
|
2011-05-07 14:48:11 +00:00
|
|
|
Background, ASortMarker, Down);
|
|
|
|
Canvas.Brush.Color := Background;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if (gdFixed in aState) and (aRow = 0) and (ACol >= FixedCols) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
//GrdCol := ColumnFromGridColumn(aCol);
|
2007-08-10 22:15:51 +00:00
|
|
|
if Assigned(GrdCol) then
|
2011-05-07 14:48:11 +00:00
|
|
|
FTitle := TRxColumnTitle(GrdCol.Title)
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
FTitle := nil;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
if Assigned(FTitle) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FTitle.Orientation <> toHorizontal then
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
OutCaptionCellText90(aCol, aRow, aRect, aState, FTitle.Caption,
|
|
|
|
FTitle.Orientation);
|
2009-06-29 16:01:00 +00:00
|
|
|
if Down then
|
2011-05-07 14:48:11 +00:00
|
|
|
aState := aState + [gdPushed];
|
2009-06-29 16:01:00 +00:00
|
|
|
end
|
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
if (FTitle.CaptionLinesCount > 0) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
aRect2.Left := aRect.Left;
|
|
|
|
aRect2.Right := aRect.Right;
|
|
|
|
aRect2.Top := aRect.Top;
|
|
|
|
for i := 0 to FTitle.CaptionLinesCount - 1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
MLI := FTitle.CaptionLine(i);
|
|
|
|
aRect2.Right := aRect.Right;
|
2008-01-28 20:37:35 +00:00
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
if i = FTitle.CaptionLinesCount - 1 then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
aRect2.Bottom := aRect.Bottom;
|
|
|
|
aRect.Top := ARect2.Top;
|
2009-06-29 16:01:00 +00:00
|
|
|
if Down then
|
2012-09-26 14:19:29 +00:00
|
|
|
aState := aState + [gdPushed]
|
|
|
|
else
|
|
|
|
aState := aState - [gdPushed]
|
|
|
|
;
|
2009-06-29 16:01:00 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2020-09-21 12:02:51 +00:00
|
|
|
aRect2.Bottom := aRect2.Top + MLI.Height * FDrawGetDefaultRowHeight;
|
2012-09-26 14:19:29 +00:00
|
|
|
aState := aState - [gdPushed];
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
2008-01-28 20:37:35 +00:00
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
|
|
|
|
if Assigned(MLI.Next) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
if Assigned(MLI.Prior) then
|
|
|
|
begin
|
|
|
|
if aCol = LeftCol then
|
2013-03-12 14:08:34 +00:00
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
OutCaptionMLCellText(aCol, aRow, aRect2, aState, MLI);
|
2013-03-12 14:08:34 +00:00
|
|
|
DoClearMLIInvalid(MLI);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Dec(MLI.FInvalidDraw);
|
2009-06-29 16:01:00 +00:00
|
|
|
end
|
|
|
|
else
|
2013-03-12 14:08:34 +00:00
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
OutCaptionMLCellText(aCol, aRow, aRect2, aState, MLI);
|
2013-03-12 14:08:34 +00:00
|
|
|
DoClearMLIInvalid(MLI);
|
|
|
|
end;
|
2009-06-29 16:01:00 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if not Assigned(MLI.Prior) then
|
|
|
|
begin
|
|
|
|
OutCaptionCellText(aCol, aRow, aRect2, aState, MLI.Caption);
|
2013-03-12 14:08:34 +00:00
|
|
|
DoClearMLIInvalid(MLI);
|
2009-06-29 16:01:00 +00:00
|
|
|
end
|
|
|
|
else
|
2013-03-12 14:08:34 +00:00
|
|
|
begin
|
|
|
|
if aCol = LeftCol then
|
|
|
|
begin
|
|
|
|
OutCaptionMLCellText(aCol, aRow, aRect2, aState, MLI);
|
|
|
|
DoClearMLIInvalid(MLI);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
Dec(MLI.FInvalidDraw);
|
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
aRect2.Top := aRect2.Bottom;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
2008-01-28 20:37:35 +00:00
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
if Down then
|
2011-05-07 14:48:11 +00:00
|
|
|
aState := aState + [gdPushed];
|
2009-06-29 16:01:00 +00:00
|
|
|
OutCaptionCellText(aCol, aRow, aRect, aState, FTitle.Caption);
|
2008-01-28 20:37:35 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
end
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
OutCaptionCellText(aCol, aRow, aRect, aState, GetDefaultColumnTitle(aCol));
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2012-09-26 14:19:29 +00:00
|
|
|
OutCaptionSortMarker(aRect, ASortMarker, ASortPosition+1);
|
2007-08-09 21:36:59 +00:00
|
|
|
end
|
|
|
|
else
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
|
|
|
if Down then
|
2011-05-07 14:48:11 +00:00
|
|
|
aState := aState + [gdPushed];
|
2009-06-29 16:01:00 +00:00
|
|
|
OutCaptionCellText(aCol, aRow, aRect, aState, '');
|
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.DefaultDrawFilter(aCol, aRow: integer; aRect: TRect;
|
2007-08-10 22:15:51 +00:00
|
|
|
aState: TGridDrawState);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
bg: TColor;
|
|
|
|
al: TAlignment;
|
|
|
|
ft: TFont;
|
|
|
|
MyCol: integer;
|
|
|
|
TxS: TTextStyle;
|
2017-04-24 12:24:50 +00:00
|
|
|
S: String;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
if (dgIndicator in Options) and (aCol = 0) then
|
|
|
|
begin
|
|
|
|
if (TitleStyle = tsNative) then
|
|
|
|
DrawThemedCell(aCol, aRow, aRect, aState)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Canvas.FillRect(aRect);
|
|
|
|
DrawCellGrid(aCol, aRow, aRect, aState);
|
|
|
|
end;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if (TitleStyle = tsNative) then
|
|
|
|
DrawThemedCell(aCol, aRow, aRect, aState)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Canvas.FillRect(aRect);
|
|
|
|
DrawCellGrid(aCol, aRow, aRect, aState);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
Inc(aRect.Left, 1);
|
|
|
|
Dec(aRect.Right, 1);
|
|
|
|
Inc(aRect.Top, 1);
|
|
|
|
Dec(aRect.Bottom, 1);
|
|
|
|
|
2018-02-02 19:50:56 +00:00
|
|
|
if Columns.Count > (aCol - ord(dgIndicator in Options)) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
bg := Canvas.Brush.Color;
|
|
|
|
al := Canvas.TextStyle.Alignment;
|
2012-02-23 04:46:16 +00:00
|
|
|
// ft := Canvas.Font;
|
|
|
|
ft:=TFont.Create;
|
|
|
|
ft.Assign(Canvas.Font);
|
2011-05-07 14:48:11 +00:00
|
|
|
TxS := Canvas.TextStyle;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2018-02-02 19:50:56 +00:00
|
|
|
MyCol := Columns.RealIndex(aCol - ord(dgIndicator in Options));
|
2007-08-10 22:15:51 +00:00
|
|
|
with TRxColumn(Columns[MyCol]).Filter do
|
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
if (TitleStyle <> tsNative) then
|
|
|
|
begin
|
|
|
|
Canvas.Brush.Color := Color;
|
|
|
|
Canvas.FillRect(aRect);
|
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2017-12-18 08:35:51 +00:00
|
|
|
S:=DisplayFilterValue;
|
|
|
|
if (aRect.Right - aRect.Left) >= Canvas.TextWidth(S) then
|
|
|
|
TxS.Alignment := Alignment
|
|
|
|
else
|
|
|
|
TxS.Alignment := taLeftJustify;
|
|
|
|
Canvas.TextStyle := TxS;
|
|
|
|
|
|
|
|
if State in [rxfsEmpty, rxfsNonEmpty] then
|
|
|
|
Canvas.Font := TRxColumn(Columns[MyCol]).Filter.EmptyFont;
|
|
|
|
|
|
|
|
DrawCellText(aCol, aRow, aRect, aState, S);
|
|
|
|
(*
|
2017-04-24 12:24:50 +00:00
|
|
|
if CurrentValues.Count > 0 then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2017-04-24 12:24:50 +00:00
|
|
|
S:=CurrentValues[0];
|
|
|
|
if CurrentValues.Count > 1 then
|
|
|
|
S:=S + '(...)';
|
2007-08-10 22:15:51 +00:00
|
|
|
Canvas.Font := Font;
|
2017-04-24 12:24:50 +00:00
|
|
|
if (aRect.Right - aRect.Left) >= Canvas.TextWidth(S) then
|
2007-08-10 22:15:51 +00:00
|
|
|
TxS.Alignment := Alignment
|
|
|
|
else
|
|
|
|
TxS.Alignment := taLeftJustify;
|
2011-05-07 14:48:11 +00:00
|
|
|
Canvas.TextStyle := TxS;
|
2017-04-24 12:24:50 +00:00
|
|
|
DrawCellText(aCol, aRow, aRect, aState, S);
|
2007-08-10 22:15:51 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2017-12-18 08:35:51 +00:00
|
|
|
if (Style in (rxfstManualEdit, rxfstBoth)) and (ManulEditValue<>'') then
|
|
|
|
S:=ManulEditValue
|
|
|
|
else
|
2017-04-24 12:24:50 +00:00
|
|
|
if State = rxfsEmpty then
|
2017-12-18 08:35:51 +00:00
|
|
|
S:=Filter.EmptyValue
|
2017-04-24 12:24:50 +00:00
|
|
|
else
|
2017-12-06 07:17:42 +00:00
|
|
|
if State = rxfsNonEmpty then
|
2017-12-18 08:35:51 +00:00
|
|
|
S:=Filter.NotEmptyValue
|
2017-12-06 07:17:42 +00:00
|
|
|
else
|
2017-04-24 12:24:50 +00:00
|
|
|
if State = rxfsAll then
|
2017-12-18 08:35:51 +00:00
|
|
|
S:=Filter.AllValue
|
2017-04-24 12:24:50 +00:00
|
|
|
else
|
|
|
|
S:='';
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
Canvas.Font := TRxColumn(Columns[MyCol]).Filter.EmptyFont;
|
2017-04-24 12:24:50 +00:00
|
|
|
if (aRect.Right - aRect.Left) >= Canvas.TextWidth(S) then
|
2007-08-10 22:15:51 +00:00
|
|
|
TxS.Alignment := Alignment
|
|
|
|
else
|
|
|
|
TxS.Alignment := taLeftJustify;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
Canvas.TextStyle := TxS;
|
2017-04-24 12:24:50 +00:00
|
|
|
DrawCellText(aCol, aRow, aRect, aState, S)
|
2017-12-18 08:35:51 +00:00
|
|
|
end; *)
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
// Canvas.Font := ft;
|
|
|
|
Canvas.Font.Assign(ft);
|
|
|
|
ft.Free;
|
2007-08-10 22:15:51 +00:00
|
|
|
Canvas.Brush.Color := bg;
|
2011-05-07 14:48:11 +00:00
|
|
|
// Canvas.TextStyle.Alignment := al;
|
2007-08-10 22:15:51 +00:00
|
|
|
TxS.Alignment := al;
|
2011-05-07 14:48:11 +00:00
|
|
|
Canvas.TextStyle := TxS;
|
2007-08-10 22:15:51 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
bg := Canvas.Brush.Color;
|
|
|
|
Canvas.Brush.Color := Color;
|
|
|
|
Canvas.FillRect(aRect);
|
|
|
|
Canvas.Brush.Color := bg;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.DefaultDrawCellData(aCol, aRow: integer; aRect: TRect;
|
2007-08-09 21:36:59 +00:00
|
|
|
aState: TGridDrawState);
|
2019-05-17 11:51:53 +00:00
|
|
|
procedure DoDrawHilightSearch(const ADisplayText:string);
|
|
|
|
var
|
|
|
|
sHRec: TRect;
|
|
|
|
FSaveColor: TColor;
|
|
|
|
L: PtrInt;
|
|
|
|
begin
|
|
|
|
L:=UTF8Pos(UTF8UpperCase(FQuickUTF8Search), UTF8UpperCase(ADisplayText));
|
|
|
|
if L = 0 then Exit;
|
|
|
|
sHRec:=aRect;
|
|
|
|
dec(sHRec.Right, varCellPadding);
|
|
|
|
Inc(sHRec.Left, varCellPadding);
|
|
|
|
|
|
|
|
case Canvas.TextStyle.Alignment of
|
|
|
|
Classes.taLeftJustify:
|
|
|
|
begin
|
|
|
|
sHRec.Left:=sHRec.Left + Canvas.TextWidth(UTF8Copy(ADisplayText, 1, L-1));
|
|
|
|
sHRec.Width:=Canvas.TextWidth(FQuickUTF8Search);
|
|
|
|
end;
|
|
|
|
Classes.taRightJustify:
|
|
|
|
begin
|
|
|
|
sHRec.Left:=sHRec.Right - Canvas.TextWidth(UTF8Copy(ADisplayText, L, UTF8Length(ADisplayText)));
|
|
|
|
sHRec.Width:=Canvas.TextWidth(FQuickUTF8Search);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
FSaveColor:=Canvas.Brush.Color;
|
|
|
|
Canvas.Brush.Color:=FSearchOptions.HilightColor;
|
|
|
|
Canvas.FillRect(sHRec);
|
|
|
|
Canvas.Brush.Color:=FSaveColor;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
|
|
|
S: string;
|
|
|
|
F: TField;
|
2011-05-07 14:48:11 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:26:54 +00:00
|
|
|
j, DataCol, L, R: integer;
|
2017-06-13 08:58:24 +00:00
|
|
|
FIsMerged: Boolean;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2017-06-13 08:58:24 +00:00
|
|
|
FIsMerged:=false;
|
|
|
|
|
|
|
|
C:=nil;
|
|
|
|
F:=nil;
|
|
|
|
|
|
|
|
if rdgColSpanning in OptionsRx then
|
|
|
|
if IsMerged(aCol, L, R, C) then
|
|
|
|
begin
|
|
|
|
aCol:=L;
|
|
|
|
FIsMerged:=true;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if Assigned(OnDrawColumnCell) and not (CsDesigning in ComponentState) then
|
2016-10-25 06:22:32 +00:00
|
|
|
begin
|
|
|
|
DataCol := ColumnIndexFromGridColumn(aCol);
|
2017-06-13 08:58:24 +00:00
|
|
|
if not Assigned(C) then
|
|
|
|
C:=TRxColumn(ColumnFromGridColumn(aCol));
|
|
|
|
OnDrawColumnCell(Self, aRect, DataCol, C, aState)
|
2016-10-25 06:22:32 +00:00
|
|
|
end
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2017-06-09 13:26:54 +00:00
|
|
|
|
2017-06-13 08:58:24 +00:00
|
|
|
|
|
|
|
if not Assigned(C) then
|
|
|
|
C := ColumnFromGridColumn(aCol) as TRxColumn;
|
|
|
|
if Assigned(C) then
|
|
|
|
F:=C.Field;
|
|
|
|
|
2012-09-18 16:29:12 +00:00
|
|
|
if Assigned(C) and Assigned(C.FOnDrawColumnCell) then
|
2012-09-17 19:52:38 +00:00
|
|
|
C.OnDrawColumnCell(Self, aRect, aCol, TColumn(ColumnFromGridColumn(aCol)), aState)
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
case ColumnEditorStyle(aCol, F) of
|
2019-05-17 11:51:53 +00:00
|
|
|
cbsCheckBoxColumn:DrawCheckBoxBitmaps(aCol, aRect, F);
|
2018-01-15 06:52:16 +00:00
|
|
|
else
|
|
|
|
S:=GetFieldDisplayText(F, C);
|
|
|
|
if ((rdgWordWrap in FOptionsRx) and Assigned(C) and (C.WordWrap)) or (FIsMerged) then
|
|
|
|
WriteTextHeader(Canvas, aRect, S, C.Alignment)
|
|
|
|
else
|
2019-05-17 11:51:53 +00:00
|
|
|
begin
|
|
|
|
if FSearchOptions.HilightSearch and (SelectedField = F) and (FQuickUTF8Search<>'') then
|
|
|
|
DoDrawHilightSearch(S);
|
2018-01-15 06:52:16 +00:00
|
|
|
DrawCellText(aCol, aRow, aRect, aState, S);
|
2019-05-17 11:51:53 +00:00
|
|
|
end;
|
2012-09-17 19:52:38 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.DrawCell(aCol, aRow: integer; aRect: TRect; aState: TGridDrawState);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
2017-05-26 13:05:56 +00:00
|
|
|
RxColumn, C: TRxColumn;
|
2011-05-07 14:48:11 +00:00
|
|
|
AImageIndex: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
FBackground: TColor;
|
2017-05-26 13:05:56 +00:00
|
|
|
gRect: TRect;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (gdFixed in aState) and (aRow = 0) then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
DefaultDrawCellA(aCol, aRow, aRect, aState);
|
|
|
|
end
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
if not ((gdFixed in aState) or ((aCol = 0) and (dgIndicator in Options)) or
|
|
|
|
((aRow = 0) and (dgTitles in Options))) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2017-06-09 13:26:54 +00:00
|
|
|
|
|
|
|
if rdgColSpanning in OptionsRx then
|
|
|
|
CalcCellExtent(acol, arow, aRect);
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
PrepareCanvas(aCol, aRow, aState);
|
2019-05-27 06:13:32 +00:00
|
|
|
if FGroupItems.Active and Assigned(FGroupItemDrawCur) then
|
2017-05-26 13:05:56 +00:00
|
|
|
begin
|
2019-05-27 06:13:32 +00:00
|
|
|
gRect:=aRect;
|
|
|
|
aRect.Bottom:=aRect.Bottom - DefaultRowHeight - 1;
|
|
|
|
gRect.Top:=aRect.Bottom;
|
|
|
|
gRect.Bottom:=gRect.Bottom - 2;
|
|
|
|
end;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-05-27 06:13:32 +00:00
|
|
|
if Assigned(FOnGetCellProps) and not (gdSelected in aState) then
|
|
|
|
begin
|
|
|
|
FBackground := Canvas.Brush.Color;
|
|
|
|
FOnGetCellProps(Self, GetFieldFromGridColumn(aCol), Canvas.Font, FBackground);
|
|
|
|
Canvas.Brush.Color := FBackground;
|
|
|
|
end;
|
|
|
|
Canvas.FillRect(aRect);
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-05-27 06:13:32 +00:00
|
|
|
DrawCellGrid(aCol, aRow, aRect, aState);
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2019-05-27 06:13:32 +00:00
|
|
|
if DataSetNotEmpty then
|
|
|
|
begin
|
2019-04-18 08:47:25 +00:00
|
|
|
RxColumn := TRxColumn(ColumnFromGridColumn(aCol));
|
|
|
|
if Assigned(RxColumn) and Assigned(RxColumn.Field) and
|
|
|
|
Assigned(RxColumn.ImageList) then
|
|
|
|
begin
|
|
|
|
AImageIndex := StrToIntDef(RxColumn.KeyList.Values[RxColumn.Field.AsString],
|
|
|
|
RxColumn.NotInKeyListIndex);
|
|
|
|
if (AImageIndex > -1) and (AImageIndex < RxColumn.ImageList.Count) then
|
|
|
|
DrawCellBitmap(RxColumn, aRect, aState, AImageIndex);
|
|
|
|
end
|
|
|
|
else
|
2019-05-27 06:13:32 +00:00
|
|
|
DefaultDrawCellData(aCol, aRow, aRect, aState);
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-04-18 08:47:25 +00:00
|
|
|
if FGroupItems.Active and Assigned(FGroupItemDrawCur) then
|
|
|
|
begin
|
|
|
|
C := ColumnFromGridColumn(aCol) as TRxColumn;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-04-18 08:47:25 +00:00
|
|
|
if C.FGroupParam.Color <> clNone then
|
|
|
|
Canvas.Brush.Color := C.FGroupParam.Color
|
|
|
|
else
|
|
|
|
if FGroupItems.Color <> clNone then
|
|
|
|
Canvas.Brush.Color := FGroupItems.Color
|
|
|
|
else
|
|
|
|
Canvas.Brush.Color := Color;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-04-18 08:47:25 +00:00
|
|
|
Canvas.Font.Color:=Font.Color;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-04-18 08:47:25 +00:00
|
|
|
Canvas.FillRect(gRect);
|
2017-05-26 13:05:56 +00:00
|
|
|
|
2019-04-18 08:47:25 +00:00
|
|
|
if C.FGroupParam.FValueType <> fvtNon then
|
|
|
|
WriteTextHeader(Canvas, gRect, C.FGroupParam.DisplayText, C.FGroupParam.Alignment);
|
|
|
|
end;
|
2019-05-27 06:13:32 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited DrawCell(aCol, aRow, aRect, aState);
|
|
|
|
end;
|
|
|
|
|
2013-03-03 09:35:53 +00:00
|
|
|
procedure TRxDBGrid.LinkActive(Value: Boolean);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
S: string;
|
|
|
|
Pos: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
|
|
|
if Value then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S := DataSource.DataSet.ClassName;
|
2009-12-10 22:02:14 +00:00
|
|
|
if RxDBGridSortEngineList.Find(S, Pos) then
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortEngine := RxDBGridSortEngineList.Objects[Pos] as TRxDBGridSortEngine
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortEngine := nil;
|
2013-03-28 21:46:45 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
inherited LinkActive(Value);
|
|
|
|
if not Value then
|
2007-09-01 11:39:17 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FSortEngine := nil;
|
|
|
|
if SelectedRows.Count > 0 then
|
2007-09-01 11:39:17 +00:00
|
|
|
SelectedRows.Clear;
|
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
|
|
|
if not FSortingNow then
|
|
|
|
CollumnSortListClear;
|
2017-05-18 11:57:06 +00:00
|
|
|
if not (csDesigning in ComponentState) then
|
2012-08-26 10:35:54 +00:00
|
|
|
SetDBHandlers(Value);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.SetDBHandlers(Value: boolean);
|
|
|
|
begin
|
2015-09-10 10:26:04 +00:00
|
|
|
if Value then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-08-26 10:35:54 +00:00
|
|
|
if DataSource.DataSet.OnFilterRecord <> @FilterRec then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-08-26 10:35:54 +00:00
|
|
|
F_EventOnFilterRec := DataSource.DataSet.OnFilterRecord;
|
|
|
|
DataSource.DataSet.OnFilterRecord := @FilterRec;
|
|
|
|
end;
|
|
|
|
if DataSource.DataSet.BeforeDelete <> @BeforeDel then
|
|
|
|
begin
|
|
|
|
F_EventOnBeforeDelete := DataSource.DataSet.BeforeDelete;
|
|
|
|
DataSource.DataSet.BeforeDelete := @BeforeDel;
|
|
|
|
end;
|
|
|
|
if DataSource.DataSet.BeforePost <> @BeforePo then
|
|
|
|
begin
|
|
|
|
F_EventOnBeforePost := DataSource.DataSet.BeforePost;
|
|
|
|
DataSource.DataSet.BeforePost := @BeforePo;
|
|
|
|
end;
|
|
|
|
if DataSource.DataSet.OnDeleteError <> @ErrorDel then
|
|
|
|
begin
|
|
|
|
F_EventOnDeleteError := DataSource.DataSet.OnDeleteError;
|
|
|
|
DataSource.DataSet.OnDeleteError := @ErrorDel;
|
|
|
|
end;
|
|
|
|
if DataSource.DataSet.OnPostError <> @ErrorPo then
|
|
|
|
begin
|
|
|
|
F_EventOnPostError := DataSource.DataSet.OnPostError;
|
|
|
|
DataSource.DataSet.OnPostError := @ErrorPo;
|
|
|
|
end;
|
|
|
|
CalcStatTotals;
|
|
|
|
if rdgFilter in OptionsRx then
|
2017-12-28 08:57:47 +00:00
|
|
|
begin
|
|
|
|
FillFilterData;
|
|
|
|
//OnFilter(nil);
|
|
|
|
end;
|
2012-08-26 10:35:54 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
if Assigned(DataSource) and Assigned(DataSource.DataSet) then
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.OnFilterRecord := F_EventOnFilterRec;
|
|
|
|
F_EventOnFilterRec := nil;
|
|
|
|
DataSource.DataSet.BeforeDelete := F_EventOnBeforeDelete;
|
|
|
|
F_EventOnBeforeDelete := nil;
|
|
|
|
DataSource.DataSet.BeforePost := F_EventOnBeforePost;
|
|
|
|
F_EventOnBeforePost := nil;
|
|
|
|
DataSource.DataSet.OnDeleteError := F_EventOnDeleteError;
|
|
|
|
F_EventOnDeleteError := nil;
|
|
|
|
DataSource.DataSet.OnPostError := F_EventOnPostError;
|
|
|
|
F_EventOnPostError := nil;
|
2012-02-23 04:46:16 +00:00
|
|
|
if rdgFilter in OptionsRx then
|
2017-12-28 08:57:47 +00:00
|
|
|
begin
|
|
|
|
FillFilterData;
|
|
|
|
//OnFilter(nil);
|
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
2012-08-26 10:35:54 +00:00
|
|
|
F_LastFilter.Clear;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure TRxDBGrid.DrawRow(ARow: Integer);
|
|
|
|
var
|
|
|
|
P: TBookMark;
|
|
|
|
begin
|
|
|
|
FGroupItemDrawCur:=nil;
|
2017-06-08 11:16:02 +00:00
|
|
|
if FGroupItems.Active and DatalinkActive then
|
2017-05-26 13:05:56 +00:00
|
|
|
begin
|
|
|
|
if (ARow>=FixedRows) then
|
|
|
|
begin
|
|
|
|
DataLink.ActiveRecord:=ARow-FixedRows;
|
|
|
|
P:=DataSource.DataSet.Bookmark;
|
|
|
|
FGroupItemDrawCur:=FGroupItems.FindGroupItem(P);
|
|
|
|
end;
|
2017-06-08 11:16:02 +00:00
|
|
|
end;
|
2017-05-26 13:05:56 +00:00
|
|
|
inherited DrawRow(ARow);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.DrawFocusRect(aCol, aRow: Integer; ARect: TRect);
|
|
|
|
begin
|
2017-06-13 08:58:24 +00:00
|
|
|
CalcCellExtent(acol, arow, aRect);
|
|
|
|
CalcCellExtent(ACol, ARow, ARect);
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if FGroupItems.Active and Assigned(FGroupItemDrawCur) then
|
|
|
|
ARect.Bottom:=ARect.Bottom - DefaultRowHeight;
|
|
|
|
inherited DrawFocusRect(aCol, aRow, ARect);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.DrawFooterRows;
|
|
|
|
var
|
|
|
|
FooterRect: TRect;
|
2011-05-07 14:48:11 +00:00
|
|
|
R: TRect;
|
2007-08-10 22:15:51 +00:00
|
|
|
TotalYOffs: integer;
|
|
|
|
TotalWidth: integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
|
|
|
C: TRxColumn;
|
|
|
|
Background: TColor;
|
2007-08-10 22:15:51 +00:00
|
|
|
ClipArea: Trect;
|
2011-05-07 14:48:11 +00:00
|
|
|
TxS: TTextStyle;
|
2015-07-28 10:15:04 +00:00
|
|
|
j: Integer;
|
|
|
|
FItem: TRxColumnFooterItem;
|
2015-09-07 07:42:04 +00:00
|
|
|
//FreeMan35 added
|
|
|
|
AText: String;
|
|
|
|
ABrush: TBrush;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2014-09-18 10:50:52 +00:00
|
|
|
TotalWidth := GCache.ClientWidth;
|
2017-05-30 07:49:41 +00:00
|
|
|
//TotalYOffs := GCache.ClientHeight {- (GetDefaultRowHeight * FFooterOptions.RowCount)};
|
|
|
|
TotalYOffs := GCache.ClientRect.Bottom {- (GetDefaultRowHeight * FFooterOptions.RowCount)};
|
2012-02-25 07:27:11 +00:00
|
|
|
|
2020-09-21 12:02:51 +00:00
|
|
|
FooterRect := Rect(0, TotalYOffs, TotalWidth, TotalYOffs + FDrawGetDefaultRowHeight * FFooterOptions.RowCount);
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
Background := Canvas.Brush.Color;
|
2011-05-07 14:48:11 +00:00
|
|
|
Canvas.Brush.Color := Color;
|
2007-08-10 22:15:51 +00:00
|
|
|
Canvas.FillRect(FooterRect);
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
R.Top := TotalYOffs;
|
2020-09-21 12:02:51 +00:00
|
|
|
R.Bottom := TotalYOffs + FDrawGetDefaultRowHeight * FFooterOptions.RowCount;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
Canvas.Brush.Color := FFooterOptions.FColor;
|
2007-08-10 22:15:51 +00:00
|
|
|
if (Columns.Count > 0) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
TxS := Canvas.TextStyle;
|
|
|
|
|
2016-05-05 06:49:18 +00:00
|
|
|
if FFooterOptions.FDrawFullLine then
|
2011-05-07 14:48:11 +00:00
|
|
|
begin
|
|
|
|
ColRowToOffset(True, True, 0, R.Left, R.Right);
|
|
|
|
Canvas.Pen.Color := GridLineColor;
|
|
|
|
Canvas.MoveTo(R.Right - 1, R.Top);
|
|
|
|
Canvas.LineTo(R.Right - 1, RowHeights[0]);
|
|
|
|
end;
|
|
|
|
|
2015-09-07 07:42:04 +00:00
|
|
|
ABrush := nil;//initialize, no need create everytime.
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
R.Top := TotalYOffs;
|
2020-09-21 12:02:51 +00:00
|
|
|
R.Bottom := TotalYOffs + FDrawGetDefaultRowHeight;
|
2015-07-28 10:15:04 +00:00
|
|
|
|
|
|
|
for j:=0 to FFooterOptions.RowCount-1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
for i := GCache.VisibleGrid.Left to GCache.VisibleGrid.Right do
|
2011-05-07 14:48:11 +00:00
|
|
|
begin
|
2015-07-28 10:15:04 +00:00
|
|
|
ColRowToOffset(True, True, i, R.Left, R.Right);
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2016-05-05 06:49:18 +00:00
|
|
|
if FFooterOptions.FDrawFullLine then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
|
|
|
Canvas.MoveTo(R.Right - 1, R.Top);
|
|
|
|
Canvas.LineTo(R.Right - 1, RowHeights[0]);
|
|
|
|
end;
|
|
|
|
|
|
|
|
C := ColumnFromGridColumn(i) as TRxColumn;
|
|
|
|
if Assigned(C) then
|
|
|
|
begin
|
|
|
|
FItem:=nil;
|
|
|
|
if (J = 0) then
|
|
|
|
begin
|
|
|
|
if (C.Footers.Count = 0) then
|
|
|
|
FItem:=C.Footer
|
|
|
|
else
|
|
|
|
FItem:=C.Footers[0];
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if J <= C.Footers.Count-1 then
|
|
|
|
FItem:=C.Footers[j];
|
|
|
|
|
|
|
|
if Assigned(FItem) then
|
|
|
|
begin
|
|
|
|
TxS.Alignment := FItem.Alignment;
|
|
|
|
TxS.Layout := FItem.Layout;
|
|
|
|
Canvas.TextStyle := TxS;
|
|
|
|
if not FItem.IsDefaultFont then
|
|
|
|
Canvas.Font:=FItem.Font
|
|
|
|
else
|
|
|
|
Canvas.Font:=Font;
|
2015-09-07 07:42:04 +00:00
|
|
|
|
2017-02-10 07:05:15 +00:00
|
|
|
if FItem.Color <> clNone then
|
|
|
|
Canvas.Brush.Color:=FItem.Color
|
|
|
|
else
|
|
|
|
Canvas.Brush.Color:=FFooterOptions.FColor;
|
|
|
|
|
|
|
|
if not Assigned(OnRxColumnFooterDraw) then
|
|
|
|
begin
|
|
|
|
Canvas.FillRect(R);
|
|
|
|
DrawCellGrid(i, 0, R, []);
|
|
|
|
DrawCellText(i, 0, R, [], FItem.DisplayText);
|
2015-09-07 07:42:04 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2017-02-10 07:05:15 +00:00
|
|
|
if not Assigned(ABrush)then
|
|
|
|
ABrush := TBrush.Create;
|
2015-09-07 07:42:04 +00:00
|
|
|
ABrush.Assign(Canvas.Brush);//Backup Brush info
|
|
|
|
AText := FItem.DisplayText;
|
|
|
|
OnRxColumnFooterDraw(Self, Canvas.Brush, Canvas.Font, R, C, AText);
|
|
|
|
Canvas.FillRect(R);//need repaint cell
|
|
|
|
DrawCellGrid(i, 0, R, []);//need reDraw cell
|
|
|
|
DrawCellText(i, 0, R, [], AText);
|
|
|
|
Canvas.Brush.Assign(ABrush);//Restore Brush info
|
|
|
|
end;
|
2017-02-10 07:05:15 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Canvas.FillRect(R);
|
|
|
|
DrawCellGrid(i, 0, R, []);
|
2015-07-28 10:15:04 +00:00
|
|
|
end;
|
2017-02-10 07:05:15 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
Canvas.FillRect(R);
|
|
|
|
DrawCellGrid(i, 0, R, []);
|
2015-09-07 07:42:04 +00:00
|
|
|
end;//Assigned(C)
|
2007-10-17 10:19:26 +00:00
|
|
|
end;
|
2015-07-28 10:15:04 +00:00
|
|
|
|
|
|
|
R.Top := R.Bottom;
|
2020-09-21 12:02:51 +00:00
|
|
|
R.Bottom := R.Bottom + FDrawGetDefaultRowHeight;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2015-07-28 10:15:04 +00:00
|
|
|
|
2015-09-07 07:42:04 +00:00
|
|
|
if assigned(ABrush)then FreeAndNil(ABrush);
|
|
|
|
|
2016-05-05 06:49:18 +00:00
|
|
|
if FFooterOptions.FDrawFullLine then
|
2011-05-07 14:48:11 +00:00
|
|
|
begin
|
|
|
|
Canvas.MoveTo(FooterRect.Left, FooterRect.Top);
|
|
|
|
Canvas.LineTo(R.Right, FooterRect.Top);
|
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
ClipArea := Canvas.ClipRect;
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to FixedCols - 1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
ColRowToOffset(True, True, i, R.Left, R.Right);
|
2012-02-23 04:46:16 +00:00
|
|
|
if FFooterOptions.FStyle = tsNative then
|
|
|
|
DrawThemedCell(i, 0, R, [gdFixed])
|
|
|
|
else
|
|
|
|
DrawCellGrid(i, 0, R, [gdFixed]);
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
if ((R.Left < ClipArea.Right) and (R.Right > ClipArea.Left)) then
|
2013-03-29 20:34:42 +00:00
|
|
|
DefaultDrawTitle(i, 0, getTitleRect(R), [gdFixed]);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
Canvas.Brush.Color := Background;
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure TRxDBGrid.DoTitleClick(ACol: longint; ACollumn: TRxColumn;
|
|
|
|
Shift: TShiftState);
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2017-05-18 11:57:06 +00:00
|
|
|
if FAutoSort and (ACollumn.Field <> nil) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-09-21 17:06:21 +00:00
|
|
|
if ssCtrl in Shift then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-09-21 17:06:21 +00:00
|
|
|
if ACollumn.FSortOrder <> smNone then
|
|
|
|
begin
|
|
|
|
if ACollumn.FSortOrder = smUp then
|
|
|
|
ACollumn.FSortOrder := smDown
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
ACollumn.FSortOrder := smNone;
|
|
|
|
ACollumn.FSortPosition:=0;
|
|
|
|
end;
|
|
|
|
end
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
2012-09-21 17:06:21 +00:00
|
|
|
begin
|
|
|
|
ACollumn.FSortOrder := smUp;
|
|
|
|
ACollumn.FSortPosition:=FSortColumns.Count;
|
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
2012-09-21 17:06:21 +00:00
|
|
|
if (FSortColumns.Count>0) and (FSortColumns[0] = ACollumn) then
|
|
|
|
begin
|
2014-04-18 11:43:18 +00:00
|
|
|
if Assigned(FSortEngine) then
|
|
|
|
begin
|
|
|
|
if FSortColumns[0].FSortOrder = smUp then
|
|
|
|
FSortColumns[0].FSortOrder := smDown
|
|
|
|
else
|
|
|
|
FSortColumns[0].FSortOrder := smUp;
|
|
|
|
end
|
2012-09-21 17:06:21 +00:00
|
|
|
else
|
2014-04-18 11:43:18 +00:00
|
|
|
begin
|
|
|
|
case ACollumn.FSortOrder of
|
|
|
|
smNone: ACollumn.FSortOrder := smUp;
|
|
|
|
smUp: ACollumn.FSortOrder := smDown;
|
|
|
|
smDown: ACollumn.FSortOrder := smNone;
|
|
|
|
end;
|
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
CollumnSortListClear;
|
|
|
|
ACollumn.FSortOrder := smUp;
|
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2020-03-24 13:25:48 +00:00
|
|
|
if Assigned(FBeforeSorting) then
|
|
|
|
begin
|
|
|
|
FSortingNow := True;
|
|
|
|
FBeforeSorting(Self);
|
|
|
|
FSortingNow := False;
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
CollumnSortListUpdate;
|
2014-04-18 11:43:18 +00:00
|
|
|
if Assigned(FSortEngine) then
|
2014-04-09 18:19:30 +00:00
|
|
|
CollumnSortListApply;
|
2014-06-14 07:16:52 +00:00
|
|
|
if Assigned(FOnSortChanged) then
|
|
|
|
begin
|
|
|
|
FSortingNow := True;
|
|
|
|
FOnSortChanged(Self);
|
|
|
|
FSortingNow := False;
|
|
|
|
end;
|
2010-03-26 18:27:12 +00:00
|
|
|
end
|
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
HeaderClick(True, ACol);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.MouseMove(Shift: TShiftState; X, Y: integer);
|
2007-08-10 22:15:51 +00:00
|
|
|
var
|
|
|
|
Cell: TGridCoord;
|
2011-05-07 14:48:11 +00:00
|
|
|
Rect: TRect;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FTracking then
|
|
|
|
TrackButton(X, Y);
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited MouseMove(Shift, X, Y);
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if (rdgFilter in OptionsRx) and (dgColumnResize in Options) and
|
|
|
|
(Cursor = crHSplit) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
Cell := MouseCoord(X, Y);
|
2011-05-07 14:48:11 +00:00
|
|
|
Rect := getFilterRect(CellRect(Cell.x, Cell.y));
|
|
|
|
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) and (Rect.Top < Y) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
Cursor := crDefault;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if FColumnResizing and (MouseToGridZone(X, Y) = gzFixedCols) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2007-08-09 21:36:59 +00:00
|
|
|
CalcTitle;
|
2012-02-25 07:27:11 +00:00
|
|
|
if FFooterOptions.Active and (dgColumnResize in Options) and (FFooterOptions.RowCount > 0) then
|
2007-08-10 22:15:51 +00:00
|
|
|
DrawFooterRows;
|
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
|
|
|
Cell: TGridCoord;
|
2011-05-07 14:48:11 +00:00
|
|
|
Rect: TRect;
|
2013-03-14 14:29:55 +00:00
|
|
|
C:TRxColumn;
|
2015-05-25 10:12:12 +00:00
|
|
|
i: Integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-09-19 14:06:46 +00:00
|
|
|
QuickUTF8Search := '';
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
Cell := MouseCoord(X, Y);
|
2017-04-24 12:24:50 +00:00
|
|
|
|
|
|
|
if FFilterColDlgButton.Visible then
|
|
|
|
FFilterColDlgButton.Hide;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
if (DatalinkActive) and (DataSource.DataSet.State = dsBrowse) and
|
|
|
|
(Button = mbLeft) and (Cell.X = 0) and (Cell.Y = 0) and
|
|
|
|
(dgIndicator in Options) and (rdgAllowToolMenu in FOptionsRx) then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
F_Clicked := True;
|
2009-08-17 17:50:27 +00:00
|
|
|
InvalidateCell(0, 0);
|
|
|
|
end
|
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2007-08-10 22:15:51 +00:00
|
|
|
if (rdgFilter in OptionsRx) and DatalinkActive then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2007-08-10 22:15:51 +00:00
|
|
|
Cell := MouseCoord(X, Y);
|
2011-05-07 14:48:11 +00:00
|
|
|
Rect := getFilterRect(CellRect(Cell.x, Cell.y));
|
|
|
|
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) and (Rect.Top < Y) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2018-02-02 19:50:56 +00:00
|
|
|
C:=TRxColumn (Columns[Columns.RealIndex(Cell.x - ord(dgIndicator in Options))]);
|
2013-05-08 05:26:49 +00:00
|
|
|
if (C.Filter.Enabled) and (C.Filter.ValueList.Count > 0) then
|
2013-03-14 14:29:55 +00:00
|
|
|
begin
|
2017-04-24 12:24:50 +00:00
|
|
|
if C.Filter.Style = rxfstSimple then
|
|
|
|
begin
|
2017-12-05 12:00:42 +00:00
|
|
|
if FFilterSimpleEdit.Visible then
|
|
|
|
FFilterSimpleEdit.Hide;
|
|
|
|
if FFilterColDlgButton.Visible then
|
|
|
|
FFilterColDlgButton.Hide;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterListEditor.Style := csDropDownList;
|
|
|
|
if C.Filter.DropDownRows>0 then
|
|
|
|
FFilterListEditor.DropDownCount := C.Filter.DropDownRows;
|
2013-03-14 14:29:55 +00:00
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterListEditor.Parent := Self;
|
|
|
|
FFilterListEditor.Width := Rect.Right - Rect.Left;
|
|
|
|
FFilterListEditor.Height := Rect.Bottom - Rect.Top;
|
|
|
|
FFilterListEditor.BoundsRect := Rect;
|
2013-03-14 14:29:55 +00:00
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterListEditor.Items.Assign(C.Filter.ValueList);
|
2013-03-14 14:29:55 +00:00
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
if C.Filter.CurrentValues.Count>0 then
|
|
|
|
FFilterListEditor.Text := C.Filter.CurrentValues[0]
|
|
|
|
else
|
|
|
|
FFilterListEditor.Text := '';
|
2018-02-02 19:50:56 +00:00
|
|
|
FFilterListEditor.Show(Self, Cell.x - ord(dgIndicator in Options));
|
2017-04-24 12:24:50 +00:00
|
|
|
end
|
|
|
|
else
|
2017-12-05 12:00:42 +00:00
|
|
|
if C.Filter.Style = rxfstManualEdit then
|
2017-04-24 12:24:50 +00:00
|
|
|
begin
|
|
|
|
if FFilterListEditor.Visible then
|
|
|
|
FFilterListEditor.Hide;
|
|
|
|
|
2017-12-05 12:00:42 +00:00
|
|
|
if FFilterColDlgButton.Visible then
|
|
|
|
FFilterColDlgButton.Hide;
|
|
|
|
|
|
|
|
FFilterSimpleEdit.Parent := Self;
|
|
|
|
FFilterSimpleEdit.Width := Rect.Right - Rect.Left;
|
|
|
|
FFilterSimpleEdit.Height := Rect.Bottom - Rect.Top;
|
|
|
|
FFilterSimpleEdit.BoundsRect := Rect;
|
2018-02-02 19:50:56 +00:00
|
|
|
FFilterSimpleEdit.Show(Self, Cell.x - ord(dgIndicator in Options));
|
2017-12-18 08:35:51 +00:00
|
|
|
{ if C.Filter.CurrentValues.Count>0 then
|
|
|
|
FFilterSimpleEdit.Text := C.Filter.CurrentValues[C.Filter.CurrentValues.Count - 1]
|
|
|
|
else}
|
|
|
|
FFilterSimpleEdit.Text := C.Filter.ManulEditValue;
|
2017-12-05 12:00:42 +00:00
|
|
|
end
|
|
|
|
else
|
2017-12-18 08:35:51 +00:00
|
|
|
if C.Filter.Style = rxfstDialog then
|
2017-12-05 12:00:42 +00:00
|
|
|
begin
|
|
|
|
if FFilterListEditor.Visible then
|
|
|
|
FFilterListEditor.Hide;
|
|
|
|
|
|
|
|
if FFilterSimpleEdit.Visible then
|
|
|
|
FFilterSimpleEdit.Hide;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterColDlgButton.Parent:=Self;
|
|
|
|
FFilterColDlgButton.Width := 32;
|
|
|
|
FFilterColDlgButton.Height := Rect.Bottom - Rect.Top;
|
|
|
|
FFilterColDlgButton.Top := Rect.Top;
|
|
|
|
FFilterColDlgButton.Left := Rect.Right - FFilterColDlgButton.Width;
|
2018-02-02 19:50:56 +00:00
|
|
|
FFilterColDlgButton.Show(Self, Cell.x - ord(dgIndicator in Options));
|
2017-04-24 12:24:50 +00:00
|
|
|
end
|
2017-12-18 08:35:51 +00:00
|
|
|
else
|
|
|
|
if C.Filter.Style = rxfstBoth then
|
|
|
|
begin
|
|
|
|
if FFilterListEditor.Visible then
|
|
|
|
FFilterListEditor.Hide;
|
|
|
|
|
|
|
|
FFilterColDlgButton.Parent:=Self;
|
|
|
|
FFilterColDlgButton.Width := 32;
|
|
|
|
FFilterColDlgButton.Height := Rect.Bottom - Rect.Top;
|
|
|
|
FFilterColDlgButton.Top := Rect.Top;
|
|
|
|
FFilterColDlgButton.Left := Rect.Right - FFilterColDlgButton.Width;
|
2018-02-02 19:50:56 +00:00
|
|
|
FFilterColDlgButton.Show(Self, Cell.x - ord(dgIndicator in Options));
|
2017-12-18 08:35:51 +00:00
|
|
|
|
|
|
|
FFilterSimpleEdit.Parent := Self;
|
|
|
|
FFilterSimpleEdit.Width := Rect.Right - Rect.Left - FFilterColDlgButton.Width;
|
|
|
|
FFilterSimpleEdit.Height := Rect.Bottom - Rect.Top;
|
|
|
|
Rect.Width:=Rect.Width - FFilterColDlgButton.Width;
|
|
|
|
FFilterSimpleEdit.BoundsRect := Rect;
|
2018-02-02 19:50:56 +00:00
|
|
|
FFilterSimpleEdit.Show(Self, Cell.x - ord(dgIndicator in Options));
|
2017-12-18 08:35:51 +00:00
|
|
|
{ if C.Filter.CurrentValues.Count>0 then
|
|
|
|
FFilterSimpleEdit.Text := C.Filter.CurrentValues[0]
|
|
|
|
else}
|
|
|
|
FFilterSimpleEdit.Text := C.Filter.ManulEditValue;
|
|
|
|
end
|
2013-03-14 14:29:55 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
if dgColumnResize in Options then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FColumnResizing := True;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if FAutoSort then
|
|
|
|
begin
|
|
|
|
Cell := MouseCoord(X, Y);
|
2011-05-07 14:48:11 +00:00
|
|
|
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2007-08-10 22:15:51 +00:00
|
|
|
if (dgColumnResize in Options) and (Button = mbRight) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Shift := Shift + [ssLeft];
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
|
|
|
end
|
|
|
|
else
|
2007-08-10 22:15:51 +00:00
|
|
|
if Button = mbLeft then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (MouseToGridZone(X, Y) = gzFixedCols) and
|
|
|
|
(dgColumnResize in Options) and (Cursor = crHSplit) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
if (ssDouble in Shift) and (rdgDblClickOptimizeColWidth in FOptionsRx) then
|
|
|
|
begin
|
|
|
|
if Assigned(ColumnFromGridColumn(Cell.X)) then
|
|
|
|
TRxColumn(ColumnFromGridColumn(Cell.X)).OptimizeWidth;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
MouseCapture := True;
|
|
|
|
FTracking := True;
|
2012-09-21 17:06:21 +00:00
|
|
|
FPressedCol := TRxColumn(ColumnFromGridColumn(Cell.X));
|
2007-08-10 22:15:51 +00:00
|
|
|
TrackButton(X, Y);
|
2012-07-23 16:27:52 +00:00
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end
|
2007-08-10 22:15:51 +00:00
|
|
|
else
|
2015-05-25 10:12:12 +00:00
|
|
|
begin
|
2007-08-10 22:15:51 +00:00
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
2015-05-25 10:12:12 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end
|
|
|
|
else
|
2015-05-25 10:12:12 +00:00
|
|
|
begin
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
2015-05-25 10:12:12 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end
|
|
|
|
else
|
2007-08-28 21:55:23 +00:00
|
|
|
begin
|
2015-05-25 10:12:12 +00:00
|
|
|
for i:=0 to FToolsList.Count-1 do
|
|
|
|
if (rxteMouseDown in TRxDBGridAbstractTools(FToolsList[i]).FToolsEvents) then
|
|
|
|
if TRxDBGridAbstractTools(FToolsList[i]).MouseDown(Button, Shift, X, Y) then
|
|
|
|
exit;
|
|
|
|
|
2021-02-20 08:27:49 +00:00
|
|
|
if (rdgMrOkOnDblClik in FOptionsRx) and (Cell.Y > 0) and (Cell.X >= Ord(dgIndicator in Options)) and (ssDouble in Shift) then
|
|
|
|
DoCblClickMrOk;
|
|
|
|
(* begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (Cell.Y > 0) and (Cell.X >= Ord(dgIndicator in Options)) and
|
|
|
|
(ssDouble in Shift) then
|
2007-08-28 21:55:23 +00:00
|
|
|
begin
|
|
|
|
if Owner is TCustomForm then
|
2011-05-07 14:48:11 +00:00
|
|
|
TCustomForm(Owner).ModalResult := mrOk;
|
2007-08-28 21:55:23 +00:00
|
|
|
end;
|
2021-02-20 08:27:49 +00:00
|
|
|
end; *)
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited MouseDown(Button, Shift, X, Y);
|
2007-08-28 21:55:23 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: integer);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
|
|
|
Cell: TGridCoord;
|
2011-05-07 14:48:11 +00:00
|
|
|
ACol: longint;
|
|
|
|
DoClick: boolean;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
ShowMenu: boolean;
|
|
|
|
MPT: TPoint;
|
|
|
|
Rct: TRect;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
ShowMenu := False;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FColumnResizing := False;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
if (dgHeaderPushedLook in Options) and FTracking and (FPressedCol <> nil) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
|
|
|
Cell := MouseCoord(X, Y);
|
2011-05-07 14:48:11 +00:00
|
|
|
DoClick := PtInRect(Rect(0, 0, ClientWidth, ClientHeight), Point(X, Y)) and
|
2012-09-21 17:06:21 +00:00
|
|
|
(Cell.Y < RowHeights[0]) and (FPressedCol = TRxColumn(ColumnFromGridColumn(Cell.X)));
|
2007-08-09 21:36:59 +00:00
|
|
|
StopTracking;
|
|
|
|
if DoClick then
|
|
|
|
begin
|
|
|
|
ACol := Cell.X;
|
2011-05-07 14:48:11 +00:00
|
|
|
if (dgIndicator in Options) then
|
|
|
|
Dec(ACol);
|
|
|
|
if DataLinkActive and (ACol >= 0) and (ACol < Columns.Count) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2012-09-21 17:06:21 +00:00
|
|
|
FPressedCol := TRxColumn(ColumnFromGridColumn(Cell.X));
|
2007-08-10 22:15:51 +00:00
|
|
|
if Assigned(FPressedCol) then
|
2012-09-21 17:06:21 +00:00
|
|
|
DoTitleClick(FPressedCol.Index, FPressedCol, Shift);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
2009-08-17 17:50:27 +00:00
|
|
|
if FSwapButtons then
|
|
|
|
begin
|
2007-08-09 21:36:59 +00:00
|
|
|
FSwapButtons := False;
|
|
|
|
MouseCapture := False;
|
2009-08-17 17:50:27 +00:00
|
|
|
if Button = mbRight then
|
|
|
|
Button := mbLeft;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2009-08-17 17:50:27 +00:00
|
|
|
if (DatalinkActive) and (DataSource.DataSet.State = dsBrowse) and
|
|
|
|
(rdgAllowToolMenu in FOptionsRx) then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Cell := MouseCoord(X, Y);
|
|
|
|
if ((Button = mbLeft) and (Cell.X = 0) and (Cell.Y = 0) and
|
|
|
|
(dgIndicator in Options)) or (F_Clicked) then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
F_Clicked := False;
|
2009-08-17 17:50:27 +00:00
|
|
|
InvalidateCell(0, 0);
|
2011-05-07 14:48:11 +00:00
|
|
|
ShowMenu := True;
|
|
|
|
Button := mbRight;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
end;
|
2009-08-17 17:50:27 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited MouseUp(Button, Shift, X, Y);
|
2009-08-06 16:59:07 +00:00
|
|
|
|
|
|
|
if (DatalinkActive) and (DataSource.DataSet.State = dsBrowse) and (ShowMenu) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Rct := CellRect(0, 0);
|
2009-08-17 17:50:27 +00:00
|
|
|
MPT.X := Rct.Left;
|
|
|
|
if rdgFilter in FOptionsRx then
|
2021-09-10 13:03:24 +00:00
|
|
|
// MPT.Y := Rct.Bottom - GetDefaultRowHeight
|
|
|
|
MPT.Y := Rct.Bottom - DefaultRowHeight
|
2009-08-17 17:50:27 +00:00
|
|
|
else
|
|
|
|
MPT.Y := Rct.Bottom;
|
2009-08-06 16:59:07 +00:00
|
|
|
MPT := ClientToScreen(MPT);
|
2012-10-18 14:11:00 +00:00
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
UpdateJMenuStates;
|
2011-05-07 14:48:11 +00:00
|
|
|
F_PopupMenu.Popup(MPT.X, MPT.Y);
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.SetQuickUTF8Search(AValue: string);
|
2009-07-06 16:26:45 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
ClearSearchValue: boolean;
|
|
|
|
OldSearchString: string;
|
2009-07-06 16:26:45 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (rdgAllowQuickSearch in OptionsRx) then
|
2009-07-06 16:26:45 +00:00
|
|
|
begin
|
|
|
|
OldSearchString := Self.FQuickUTF8Search;
|
2011-05-07 14:48:11 +00:00
|
|
|
if (OldSearchString <> AValue) and Assigned(Self.FBeforeQuickSearch) then
|
|
|
|
Self.FBeforeQuickSearch(Self, SelectedField, AValue);
|
2009-07-06 16:26:45 +00:00
|
|
|
if OldSearchString <> AValue then
|
|
|
|
begin
|
|
|
|
ClearSearchValue := True;
|
2011-05-07 14:48:11 +00:00
|
|
|
if (Length(AValue) > 0) and (Self.DatalinkActive) then
|
2009-07-06 16:26:45 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (DataSource.DataSet.State = dsBrowse) and
|
|
|
|
(not (DataSource.DataSet.EOF and DataSource.DataSet.BOF)) then
|
2009-07-06 16:26:45 +00:00
|
|
|
begin
|
|
|
|
//1.Вызываем процедурку поиска...
|
2011-05-07 14:48:11 +00:00
|
|
|
if DataSetLocateThrough(Self.DataSource.DataSet,
|
2016-11-08 08:10:02 +00:00
|
|
|
Self.SelectedField.FieldName, AValue, FSearchOptions.FQuickSearchOptions, rsdAll, FSearchOptions.FFromStart) then
|
2011-05-07 14:48:11 +00:00
|
|
|
Self.FQuickUTF8Search := AValue;
|
|
|
|
ClearSearchValue := False;
|
2009-07-06 16:26:45 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
if ClearSearchValue then
|
|
|
|
begin
|
|
|
|
Self.FQuickUTF8Search := '';
|
|
|
|
end;
|
2019-05-17 11:51:53 +00:00
|
|
|
Invalidate;
|
2011-05-07 14:48:11 +00:00
|
|
|
if (OldSearchString <> Self.FQuickUTF8Search) and
|
|
|
|
Assigned(Self.FAfterQuickSearch) then
|
2009-07-06 16:26:45 +00:00
|
|
|
Self.FAfterQuickSearch(Self, SelectedField, OldSearchString);
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2009-07-06 16:26:45 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
//TODO: сделать отображение ищущейся буквы/строки.
|
2009-07-06 16:26:45 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.UTF8KeyPress(var UTF8Key: TUTF8Char);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
CheckUp: boolean;
|
2009-07-06 16:26:45 +00:00
|
|
|
begin
|
|
|
|
inherited UTF8KeyPress(UTF8Key);
|
2023-11-15 12:02:14 +00:00
|
|
|
if (rdgAllowQuickSearch in OptionsRx) and (ReadOnly or (Assigned(SelectedColumn) and SelectedColumn.ReadOnly)) then
|
2009-07-06 16:26:45 +00:00
|
|
|
begin
|
|
|
|
//0. Проверяем что это кнопка значащая, увеличиваем "строку поиска"
|
|
|
|
if Length(UTF8Key) = 1 then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
//DebugLn('Ord Of Key:',IntToStr(Ord(UTF8Key[1])));
|
|
|
|
CheckUp := not (Ord(UTF8Key[1]) in CBadQuickSearchSymbols);
|
2009-07-06 16:26:45 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
CheckUp := True;
|
2011-05-07 14:48:11 +00:00
|
|
|
// DebugLn('RxDBGrid.UTF8KeyPress check',IfThen(CheckUp,'True','False'),'INIT UTF8Key= ',UTF8Key,' Selected Field: ', Self.SelectedField.FieldName);
|
2009-07-06 16:26:45 +00:00
|
|
|
if CheckUp then
|
|
|
|
QuickUTF8Search := QuickUTF8Search + Trim(UTF8Key);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.KeyDown(var Key: word; Shift: TShiftState);
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2017-09-19 05:43:18 +00:00
|
|
|
procedure DoShowFindDlg;
|
|
|
|
begin
|
|
|
|
if not (rdgAllowDialogFind in OptionsRx) then
|
|
|
|
exit;
|
|
|
|
if Length(QuickUTF8Search) > 0 then
|
|
|
|
QuickUTF8Search := '';
|
|
|
|
ShowFindDialog;
|
|
|
|
end;
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2017-09-19 05:43:18 +00:00
|
|
|
procedure DoShowColumnsDlg;
|
|
|
|
begin
|
|
|
|
if not (rdgAllowColumnsForm in OptionsRx) then
|
|
|
|
exit;
|
|
|
|
if Length(QuickUTF8Search) > 0 then
|
|
|
|
QuickUTF8Search := '';
|
|
|
|
ShowColumnsDialog;
|
|
|
|
end;
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2017-09-19 05:43:18 +00:00
|
|
|
procedure DoShowQuickFilter;
|
|
|
|
begin
|
|
|
|
if not (rdgAllowQuickFilter in FOptionsRx) then
|
|
|
|
exit;
|
|
|
|
OnFilter(Self);
|
|
|
|
end;
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2009-07-06 16:26:45 +00:00
|
|
|
if (Key in CCancelQuickSearchKeys) then
|
2011-05-07 14:48:11 +00:00
|
|
|
if Length(QuickUTF8Search) > 0 then
|
|
|
|
QuickUTF8Search := '';
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited KeyDown(Key, Shift);
|
2010-05-19 15:33:28 +00:00
|
|
|
if Key <> 0 then
|
|
|
|
begin
|
|
|
|
case FKeyStrokes.FindRxCommand(Key, Shift) of
|
2011-05-07 14:48:11 +00:00
|
|
|
rxgcShowFindDlg: DoShowFindDlg;
|
|
|
|
rxgcShowColumnsDlg: DoShowColumnsDlg;
|
|
|
|
rxgcShowFilterDlg: OnFilterBy(Self);
|
|
|
|
rxgcShowQuickFilter: DoShowQuickFilter;
|
|
|
|
rxgcHideQuickFilter: OnFilterClose(Self);
|
|
|
|
rxgcShowSortDlg: OnSortBy(Self);
|
2012-09-24 14:21:22 +00:00
|
|
|
rxgcSelectAll: SelectAllRows;
|
|
|
|
rxgcDeSelectAll: DeSelectAllRows;
|
|
|
|
rxgcInvertSelection:InvertSelection;
|
|
|
|
rxgcOptimizeColumnsWidth:OptimizeColumnsWidthAll;
|
2014-01-15 11:35:25 +00:00
|
|
|
rxgcCopyCellValue:OnCopyCellValue(Self);
|
2012-09-24 14:21:22 +00:00
|
|
|
else
|
|
|
|
exit;
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
Key := 0;
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2014-10-15 07:48:42 +00:00
|
|
|
procedure TRxDBGrid.KeyPress(var Key: char);
|
|
|
|
begin
|
|
|
|
inherited KeyPress(Key);
|
|
|
|
if Assigned(SelectedColumn) and Assigned(SelectedColumn.Field) and (SelectedColumn.Field.DataType in [ftFloat, ftCurrency]) and
|
|
|
|
(coFixDecimalSeparator in TRxColumn(SelectedColumn).Options) then
|
|
|
|
if (Key in [',', '.']) then
|
|
|
|
Key:=DefaultFormatSettings.DecimalSeparator
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
function TRxDBGrid.CreateColumns: TGridColumns;
|
|
|
|
begin
|
|
|
|
Result := TRxDbGridColumns.Create(Self, TRxColumn);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.DrawCellBitmap(RxColumn: TRxColumn; aRect: TRect;
|
|
|
|
aState: TGridDrawState; AImageIndex: integer);
|
|
|
|
var
|
|
|
|
ClientSize: TSize;
|
2011-05-07 14:48:11 +00:00
|
|
|
H, W: integer;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
|
|
|
InflateRect(aRect, -1, -1);
|
|
|
|
|
2007-08-28 22:21:31 +00:00
|
|
|
H := RxColumn.ImageList.Height;
|
|
|
|
W := RxColumn.ImageList.Width;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
ClientSize.cx := Min(aRect.Right - aRect.Left, W);
|
|
|
|
ClientSize.cy := Min(aRect.Bottom - aRect.Top, H);
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2007-08-28 22:21:31 +00:00
|
|
|
if ClientSize.cx = W then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
aRect.Left := (aRect.Left + aRect.Right - W) div 2;
|
|
|
|
aRect.Right := aRect.Left + W;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-28 22:21:31 +00:00
|
|
|
if ClientSize.cy = H then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
aRect.Top := (aRect.Top + aRect.Bottom - H) div 2;
|
|
|
|
aRect.Bottom := aRect.Top + H;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
2018-02-01 08:47:24 +00:00
|
|
|
RxColumn.ImageList.Draw(Canvas, aRect.Left, aRect.Top, AImageIndex);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.SetEditText(ACol, ARow: longint; const Value: string);
|
2007-08-09 21:36:59 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:56:12 +00:00
|
|
|
j, L, R: integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
S: string;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2017-06-13 10:52:46 +00:00
|
|
|
C:=nil;
|
2017-06-09 13:56:12 +00:00
|
|
|
if (rdgColSpanning in OptionsRx) then
|
2017-06-13 08:58:24 +00:00
|
|
|
if IsMerged(aCol, L, R, C) then
|
2017-06-09 13:56:12 +00:00
|
|
|
aCol:=L;
|
|
|
|
|
2017-06-13 08:58:24 +00:00
|
|
|
if not Assigned(C) then
|
|
|
|
C := ColumnFromGridColumn(aCol) as TRxColumn;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
S := Value;
|
|
|
|
if Assigned(C) and (C.KeyList.Count > 0) and (C.PickList.Count > 0) then
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
J := C.PickList.IndexOf(S);
|
|
|
|
if (J >= 0) and (J < C.KeyList.Count) then
|
|
|
|
S := C.KeyList[j];
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
inherited SetEditText(ACol, ARow, S);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.ColRowMoved(IsColumn: boolean; FromIndex, ToIndex: integer);
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
|
|
|
inherited ColRowMoved(IsColumn, FromIndex, ToIndex);
|
|
|
|
if IsColumn then
|
|
|
|
CalcTitle;
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.Paint;
|
2014-09-18 10:50:52 +00:00
|
|
|
var
|
|
|
|
P:TPoint;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2013-03-28 15:40:03 +00:00
|
|
|
Inc(FInProcessCalc);
|
2013-03-12 14:08:34 +00:00
|
|
|
DoClearInvalidTitle;
|
2021-09-10 13:03:24 +00:00
|
|
|
// FDrawGetDefaultRowHeight:=GetDefaultRowHeight;
|
|
|
|
FDrawGetDefaultRowHeight:=DefaultRowHeight;
|
2013-03-12 14:08:34 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
inherited Paint;
|
2013-03-12 14:08:34 +00:00
|
|
|
|
|
|
|
DoDrawInvalidTitle;
|
|
|
|
|
2012-02-25 07:27:11 +00:00
|
|
|
if FFooterOptions.Active and (FFooterOptions.RowCount > 0) then
|
2007-08-10 22:15:51 +00:00
|
|
|
DrawFooterRows;
|
2017-05-18 10:25:59 +00:00
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
Dec(FInProcessCalc);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.MoveSelection;
|
|
|
|
begin
|
|
|
|
inherited MoveSelection;
|
2017-05-30 08:25:18 +00:00
|
|
|
(* if Assigned(FFooterOptions) and FFooterOptions.Active and (FFooterOptions.RowCount > 0) then
|
|
|
|
DrawFooterRows; *)
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2013-03-03 09:35:53 +00:00
|
|
|
function TRxDBGrid.GetBufferCount: integer;
|
2013-05-08 05:26:49 +00:00
|
|
|
var
|
2017-05-18 10:25:59 +00:00
|
|
|
H, H1:integer;
|
|
|
|
i: LongInt;
|
2013-03-03 09:35:53 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
{ Result := ClientHeight div DefaultRowHeight;
|
|
|
|
if dgTitles in Options then
|
|
|
|
Dec(Result, 1);}
|
|
|
|
|
2021-09-10 13:03:24 +00:00
|
|
|
//if GetDefaultRowHeight > 0 then
|
|
|
|
if DefaultRowHeight > 0 then
|
2013-03-03 09:35:53 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
H:=ClientHeight;
|
2016-09-14 07:27:19 +00:00
|
|
|
if FFooterOptions.Active then
|
2021-09-10 13:03:24 +00:00
|
|
|
//H:=H - GetDefaultRowHeight * FFooterOptions.RowCount;
|
|
|
|
H:=H - DefaultRowHeight * FFooterOptions.RowCount;
|
2017-05-18 10:25:59 +00:00
|
|
|
|
2017-10-24 12:38:03 +00:00
|
|
|
|
2021-09-10 13:03:24 +00:00
|
|
|
//Result := H div GetDefaultRowHeight;
|
|
|
|
Result := H div DefaultRowHeight;
|
2017-09-19 05:43:18 +00:00
|
|
|
|
|
|
|
if rdgFilter in OptionsRx then
|
|
|
|
Dec(Result, 1);
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if dgTitles in Options then
|
2017-10-24 12:38:03 +00:00
|
|
|
//Dec(Result, 1);
|
2021-09-10 13:03:24 +00:00
|
|
|
//Result:=Result - RowHeights[0] div GetDefaultRowHeight;
|
|
|
|
Result:=Result - RowHeights[0] div DefaultRowHeight;
|
2016-09-14 07:27:19 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
Result := 1;
|
2013-03-03 09:35:53 +00:00
|
|
|
end;
|
|
|
|
|
2016-08-26 19:26:05 +00:00
|
|
|
procedure TRxDBGrid.CMHintShow(var Message: TLMessage);
|
|
|
|
var
|
|
|
|
Cell: TGridCoord;
|
|
|
|
tCol: TRxColumn;
|
|
|
|
HintStr_: string;
|
|
|
|
Processed: boolean;
|
|
|
|
rec: integer;
|
|
|
|
CellRect_: TRect;
|
|
|
|
begin
|
|
|
|
if Assigned(TCMHintShow(Message).HintInfo) then
|
|
|
|
begin
|
|
|
|
with TCMHintShow(Message).HintInfo^ do
|
|
|
|
begin
|
|
|
|
Cell := MouseCoord(CursorPos.X, CursorPos.Y);
|
|
|
|
tCol := TRxColumn(ColumnFromGridColumn(Cell.X));
|
|
|
|
if (Cell.Y = 0) and (Cell.X >= Ord(dgIndicator in Options)) then
|
|
|
|
begin
|
|
|
|
if Assigned(tCol) and (TRxColumnTitle(tCol.Title).Hint <> '') and
|
|
|
|
(TRxColumnTitle(tCol.Title).FShowHint) then
|
|
|
|
HintStr := TRxColumnTitle(tCol.Title).Hint;
|
|
|
|
end
|
|
|
|
else
|
2016-09-20 06:34:17 +00:00
|
|
|
if Cell.X >= Ord(dgIndicator in Options) then
|
2016-08-26 19:26:05 +00:00
|
|
|
begin
|
|
|
|
CellRect_ := CellRect(Cell.X, Cell.Y);
|
|
|
|
if (CellRect_.Bottom > CursorPos.Y) and (CellRect_.Right > CursorPos.X) then
|
|
|
|
if Assigned(FOnDataHintShow) then
|
|
|
|
begin
|
2020-04-05 19:57:18 +00:00
|
|
|
Processed := False;
|
2016-08-26 19:26:05 +00:00
|
|
|
rec := DataLink.ActiveRecord;
|
|
|
|
try
|
|
|
|
DataLink.ActiveRecord := Cell.y - 1;
|
|
|
|
HintStr_ := tCol.Field.DisplayText;
|
2020-04-05 19:57:18 +00:00
|
|
|
FOnDataHintShow(Self, CursorPos, Cell, tCol, HintStr_, Processed);
|
2016-08-26 19:26:05 +00:00
|
|
|
finally
|
|
|
|
DataLink.ActiveRecord := rec;
|
|
|
|
end;
|
|
|
|
if Processed then
|
|
|
|
HintStr := HintStr_;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
inherited CMHintShow(Message);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.FFilterListEditorOnChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FFilterListEditor.Hide;
|
|
|
|
with TRxColumn(Columns[Columns.RealIndex(FFilterListEditor.Col)]).Filter do
|
|
|
|
begin
|
2016-09-08 08:51:40 +00:00
|
|
|
if (FFilterListEditor.Text = EmptyValue) then
|
|
|
|
begin
|
2017-12-18 08:35:51 +00:00
|
|
|
ClearFilter;
|
|
|
|
{ CurrentValues.Clear;
|
|
|
|
State:=rxfsEmpty;}
|
2016-09-08 08:51:40 +00:00
|
|
|
end
|
|
|
|
else
|
2018-01-12 10:28:22 +00:00
|
|
|
if (FFilterListEditor.Text = AllValue) {or (FFilterListEditor.Text = '')} then
|
2016-09-08 08:51:40 +00:00
|
|
|
begin
|
2017-12-18 08:35:51 +00:00
|
|
|
ClearFilter;
|
2017-04-24 12:24:50 +00:00
|
|
|
State:=rxfsAll;
|
2016-09-08 08:51:40 +00:00
|
|
|
end
|
2007-08-10 22:15:51 +00:00
|
|
|
else
|
2016-09-08 08:51:40 +00:00
|
|
|
begin
|
2017-12-18 08:35:51 +00:00
|
|
|
ClearFilter;
|
2017-04-24 12:24:50 +00:00
|
|
|
CurrentValues.Add(FFilterListEditor.Text);
|
|
|
|
State:=rxfsFilter;
|
2016-09-08 08:51:40 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2014-09-22 11:28:22 +00:00
|
|
|
DataSource.DataSet.DisableControls;
|
|
|
|
DataSource.DataSet.Filtered:=false;
|
|
|
|
DataSource.DataSet.Filtered:=true;
|
2009-08-06 16:59:07 +00:00
|
|
|
CalcStatTotals;
|
2014-09-22 11:28:22 +00:00
|
|
|
DataSource.DataSet.EnableControls;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
if Assigned(FOnFiltred) then
|
|
|
|
FOnFiltred(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.FFilterListEditorOnCloseUp(Sender: TObject);
|
|
|
|
begin
|
|
|
|
FFilterListEditor.Hide;
|
|
|
|
FFilterListEditor.Changed;
|
2007-08-28 21:55:23 +00:00
|
|
|
SetFocus;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
procedure TRxDBGrid.FFilterColDlgButtonOnClick(Sender: TObject);
|
|
|
|
var
|
|
|
|
RxDBGrid_PopUpFilterForm: TRxDBGrid_PopUpFilterForm;
|
2017-04-27 07:57:02 +00:00
|
|
|
R, P: TPoint;
|
2017-04-24 12:24:50 +00:00
|
|
|
FRxCol: TRxColumn;
|
2017-04-27 07:57:02 +00:00
|
|
|
FRect: TRect;
|
2017-04-24 12:24:50 +00:00
|
|
|
begin
|
|
|
|
FRxCol:=TRxColumn(Columns[Columns.RealIndex(FFilterColDlgButton.Col)]);
|
2017-04-27 07:57:02 +00:00
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
RxDBGrid_PopUpFilterForm:=TRxDBGrid_PopUpFilterForm.CreatePopUpFilterForm(FRxCol);
|
2017-04-27 07:57:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
P:=Point(FFilterColDlgButton.Left, FFilterColDlgButton.Top + FFilterColDlgButton.Width);
|
|
|
|
|
|
|
|
|
|
|
|
if RxDBGrid_PopUpFilterForm.Width < FRxCol.Width then
|
|
|
|
P.X:=FFilterColDlgButton.Left + FFilterColDlgButton.Width - RxDBGrid_PopUpFilterForm.Width
|
|
|
|
else
|
|
|
|
P.X:=FFilterColDlgButton.Left + FFilterColDlgButton.Width - FRxCol.Width;
|
|
|
|
|
|
|
|
R:=ClientToScreen(P);
|
|
|
|
if R.X + RxDBGrid_PopUpFilterForm.Width > Screen.Width then
|
|
|
|
R.X:=Screen.Width - RxDBGrid_PopUpFilterForm.Width;
|
|
|
|
|
2017-04-24 12:24:50 +00:00
|
|
|
RxDBGrid_PopUpFilterForm.Left:=R.X;
|
|
|
|
RxDBGrid_PopUpFilterForm.Top:=R.Y;
|
|
|
|
RxDBGrid_PopUpFilterForm.ShowModal;
|
|
|
|
RxDBGrid_PopUpFilterForm.Free;
|
|
|
|
end;
|
|
|
|
|
2017-12-05 12:00:42 +00:00
|
|
|
procedure TRxDBGrid.FFilterSimpleEditOnChange(Sender: TObject);
|
|
|
|
begin
|
|
|
|
with TRxColumn(Columns[Columns.RealIndex(FFilterSimpleEdit.Col)]).Filter do
|
|
|
|
begin
|
2017-12-18 08:35:51 +00:00
|
|
|
if (FFilterSimpleEdit.Text = '') and (Style = rxfstManualEdit) then
|
2017-12-05 12:25:42 +00:00
|
|
|
begin
|
|
|
|
CurrentValues.Clear;
|
|
|
|
State:=rxfsAll;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
State:=rxfsFilter;
|
2017-12-18 08:35:51 +00:00
|
|
|
ManulEditValue:=FFilterSimpleEdit.Text;
|
2017-12-05 12:00:42 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
DataSource.DataSet.DisableControls;
|
|
|
|
DataSource.DataSet.Filtered:=false;
|
|
|
|
DataSource.DataSet.Filtered:=true;
|
|
|
|
CalcStatTotals;
|
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
|
|
|
|
if Assigned(FOnFiltred) then
|
|
|
|
FOnFiltred(Self);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.InternalOptimizeColumnsWidth(AColList: TList);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
P: TBookmark;
|
|
|
|
i, W, n: integer;
|
|
|
|
WA: PIntegerArray;
|
|
|
|
S: string;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
GetMem(WA, SizeOf(integer) * AColList.Count);
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
for I := 0 to AColList.Count - 1 do
|
2010-01-23 07:14:50 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if TRxColumnTitle(TRxColumn(AColList[i]).Title).CaptionLinesCount > 1 then
|
|
|
|
WA^[i] := Max(Canvas.TextWidth(
|
|
|
|
TRxColumnTitle(TRxColumn(AColList[i]).Title).CaptionLine(
|
|
|
|
TRxColumnTitle(TRxColumn(AColList[i]).Title).CaptionLinesCount -
|
|
|
|
1).Caption) + 8, 20)
|
2010-01-23 07:14:50 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
WA^[i] := Max(Canvas.TextWidth(TRxColumn(AColList[i]).Title.Caption) + 8, 20);
|
2010-01-23 07:14:50 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
|
|
|
with DataSource.DataSet do
|
|
|
|
begin
|
|
|
|
DisableControls;
|
2011-05-07 14:48:11 +00:00
|
|
|
P := GetBookmark;
|
2007-08-10 22:15:51 +00:00
|
|
|
First;
|
|
|
|
try
|
2011-05-07 14:48:11 +00:00
|
|
|
while not EOF do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
for I := 0 to AColList.Count - 1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2017-11-23 08:28:58 +00:00
|
|
|
(*
|
2013-05-21 17:01:09 +00:00
|
|
|
if Assigned(TRxColumn(AColList[i]).Field) then
|
|
|
|
S := TRxColumn(AColList[i]).Field.DisplayText
|
|
|
|
else
|
|
|
|
S:='';
|
2009-11-03 15:33:19 +00:00
|
|
|
with TRxColumn(AColList[i]) do
|
|
|
|
if (KeyList.Count > 0) and (PickList.Count > 0) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
n := KeyList.IndexOf(S);
|
|
|
|
if (n <> -1) and (n < PickList.Count) then
|
|
|
|
S := PickList.Strings[n];
|
2017-11-23 08:28:58 +00:00
|
|
|
end; *)
|
|
|
|
S:=GetFieldDisplayText(TRxColumn(AColList[i]).Field, TRxColumn(AColList[i]));
|
2011-05-07 14:48:11 +00:00
|
|
|
W := Canvas.TextWidth(S) + 6;
|
|
|
|
if WA^[i] < W then
|
|
|
|
WA^[i] := W;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
Next;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
GotoBookmark(p);
|
|
|
|
FreeBookmark(p);
|
|
|
|
EnableControls;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
for I := 0 to AColList.Count - 1 do
|
|
|
|
if WA^[i] > 0 then
|
|
|
|
TRxColumn(AColList[i]).Width := WA^[i];
|
|
|
|
|
|
|
|
FreeMem(WA, SizeOf(integer) * AColList.Count);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2017-05-18 10:25:59 +00:00
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
procedure TRxDBGrid.VisualChange;
|
2017-05-18 10:25:59 +00:00
|
|
|
var
|
|
|
|
P: TPoint;
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2009-07-02 16:37:41 +00:00
|
|
|
CalcTitle;
|
2017-05-18 10:25:59 +00:00
|
|
|
|
|
|
|
if FFooterOptions.Active and (FFooterOptions.RowCount > 0) then
|
|
|
|
begin
|
|
|
|
P:=GCache.MaxClientXY;
|
|
|
|
with GCache do
|
2021-09-10 13:03:24 +00:00
|
|
|
//MaxClientXY.Y:=MaxClientXY.Y - (GetDefaultRowHeight * FFooterOptions.RowCount + 2);
|
|
|
|
MaxClientXY.Y:=MaxClientXY.Y - (DefaultRowHeight * FFooterOptions.RowCount + 2);
|
2017-05-18 10:25:59 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if ((rdgWordWrap in FOptionsRx) or (Assigned(FGroupItems) and FGroupItems.Active)) and (HandleAllocated) then
|
2017-05-18 10:25:59 +00:00
|
|
|
UpdateRowsHeight;
|
|
|
|
|
2014-01-19 18:47:05 +00:00
|
|
|
inherited VisualChange;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure TRxDBGrid.EditorWidthChanged(aCol, aWidth: Integer);
|
|
|
|
var
|
|
|
|
R:TRect;
|
|
|
|
begin
|
|
|
|
inherited EditorWidthChanged(aCol, aWidth);
|
|
|
|
if FFilterListEditor.Visible then
|
|
|
|
begin
|
|
|
|
R:=CellRect(FFilterListEditor.Col+1,0);
|
|
|
|
FFilterListEditor.Width:=Columns[FFilterListEditor.Col].Width;
|
|
|
|
FFilterListEditor.Left:=R.Left;
|
2017-04-24 12:24:50 +00:00
|
|
|
end
|
|
|
|
else
|
2017-12-05 12:00:42 +00:00
|
|
|
if FFilterSimpleEdit.Visible then
|
|
|
|
begin
|
|
|
|
R:=CellRect(FFilterSimpleEdit.Col+1,0);
|
|
|
|
FFilterSimpleEdit.Width:=Columns[FFilterSimpleEdit.Col].Width;
|
|
|
|
FFilterSimpleEdit.Left:=R.Left;
|
|
|
|
end
|
|
|
|
else
|
2017-04-24 12:24:50 +00:00
|
|
|
if FFilterColDlgButton.Visible then
|
|
|
|
begin
|
2017-12-05 12:00:42 +00:00
|
|
|
R:=CellRect(FFilterColDlgButton.Col+1,0);
|
2017-04-24 12:24:50 +00:00
|
|
|
FFilterColDlgButton.Left := R.Right - FFilterColDlgButton.Width;
|
2013-03-28 15:40:03 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-11-06 11:15:05 +00:00
|
|
|
function TRxDBGrid.EditorByStyle(Style: TColumnButtonStyle): TWinControl;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
F: TField;
|
2007-11-06 11:15:05 +00:00
|
|
|
begin
|
|
|
|
if Style = cbsAuto then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
F := SelectedField;
|
2007-11-06 11:15:05 +00:00
|
|
|
if Assigned(F) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if Assigned(F.LookupDataSet) and (F.LookupKeyFields <> '') and
|
|
|
|
(F.LookupResultField <> '') and (F.KeyFields <> '') then
|
2007-11-06 11:15:05 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := FRxDbGridLookupComboEditor;
|
2007-11-06 11:15:05 +00:00
|
|
|
exit;
|
|
|
|
end
|
2008-01-31 13:23:03 +00:00
|
|
|
else
|
|
|
|
if F.DataType in [ftDate, ftDateTime] then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := FRxDbGridDateEditor;
|
2008-01-31 13:23:03 +00:00
|
|
|
exit;
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2007-11-06 11:15:05 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := inherited EditorByStyle(Style);
|
2011-09-22 17:07:49 +00:00
|
|
|
|
|
|
|
if (Style = cbsPickList) and (Result is TCustomComboBox) then
|
|
|
|
begin
|
|
|
|
if TRxColumn(SelectedColumn).DirectInput then
|
|
|
|
TCustomComboBox(Result).Style:=csDropDown
|
|
|
|
else
|
|
|
|
TCustomComboBox(Result).Style:=csDropDownList;
|
|
|
|
end;
|
|
|
|
|
2007-11-06 11:15:05 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.CalcStatTotals;
|
|
|
|
var
|
2014-04-02 11:44:09 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P_26: TBookmark;
|
|
|
|
{$ENDIF}
|
2014-03-27 12:36:50 +00:00
|
|
|
P: TBookmark;
|
2016-05-12 07:25:00 +00:00
|
|
|
i, cnt: integer;
|
2011-05-07 14:48:11 +00:00
|
|
|
APresent: boolean;
|
2013-03-29 18:17:29 +00:00
|
|
|
|
|
|
|
DHS:THackDataSet;
|
|
|
|
|
|
|
|
SaveState:TDataSetState;
|
|
|
|
SavePos:integer;
|
|
|
|
SaveActiveRecord:integer;
|
|
|
|
|
|
|
|
SaveAfterScroll:TDataSetNotifyEvent;
|
|
|
|
SaveBeforeScroll:TDataSetNotifyEvent;
|
2017-05-18 13:58:44 +00:00
|
|
|
C:TRxColumn;
|
2014-07-28 12:25:45 +00:00
|
|
|
AValue:Variant;
|
2014-08-14 12:50:39 +00:00
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
FCList, FCList2:TFPList;
|
2015-07-28 10:15:04 +00:00
|
|
|
j: Integer;
|
2017-05-18 13:58:44 +00:00
|
|
|
F: TRxColumnFooterItem;
|
2017-05-26 13:05:56 +00:00
|
|
|
S: String;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
if (not (DatalinkActive and (FGroupItems.Active or FFooterOptions.Active))) or (Columns.Count = 0) or (gsAddingAutoColumns in GridStatus) then
|
2007-08-10 22:15:51 +00:00
|
|
|
Exit;
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2020-05-29 21:08:57 +00:00
|
|
|
if Datalink.ActiveRecord < 0 then exit;
|
|
|
|
|
2014-07-28 12:25:45 +00:00
|
|
|
if Assigned(OnRxCalcFooterValues)then
|
|
|
|
begin
|
|
|
|
Inc(FInProcessCalc);
|
2017-05-18 13:58:44 +00:00
|
|
|
for C in Columns do
|
2014-07-28 12:25:45 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
C.Footer.ResetTestValue;
|
2014-07-28 12:25:45 +00:00
|
|
|
AValue:=Null;
|
2017-05-18 13:58:44 +00:00
|
|
|
OnRxCalcFooterValues(Self, C, AValue);
|
|
|
|
if AValue<>null then C.Footer.FTestValue := AValue;
|
2014-07-28 12:25:45 +00:00
|
|
|
end;
|
|
|
|
Dec(FInProcessCalc);
|
|
|
|
Exit;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
APresent := False;
|
2017-05-18 13:58:44 +00:00
|
|
|
for C in Columns do
|
2010-03-15 17:56:12 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
APresent := (C.Footer.FValueType in [fvtSum, fvtAvg, fvtMax, fvtMin, fvtCount]) {or (C.FGroupItems.Active)};
|
2015-07-28 10:15:04 +00:00
|
|
|
if not APresent then
|
2017-05-23 10:48:55 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
for F in C.Footers do
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
APresent:=F.FValueType in [fvtSum, fvtAvg, fvtMax, fvtMin, fvtCount];
|
2015-07-28 10:15:04 +00:00
|
|
|
if APresent then
|
|
|
|
break;
|
|
|
|
end;
|
2017-05-23 10:48:55 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
break;
|
2010-03-15 17:56:12 +00:00
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if (not APresent) and (not FGroupItems.Active) then Exit;
|
2010-03-15 17:56:12 +00:00
|
|
|
|
2013-09-30 20:52:47 +00:00
|
|
|
|
2013-03-29 18:17:29 +00:00
|
|
|
Inc(FInProcessCalc);
|
|
|
|
|
2013-03-29 20:34:42 +00:00
|
|
|
cnt:=0;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
|
|
|
if FGroupItems.Active then FGroupItems.Clear;
|
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
for C in Columns do
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
C.Footer.ResetTestValue;
|
|
|
|
for F in C.Footers do F.ResetTestValue;
|
2015-07-28 10:15:04 +00:00
|
|
|
end;
|
2013-03-29 18:17:29 +00:00
|
|
|
|
2013-09-30 20:52:47 +00:00
|
|
|
if (DataSource.DataSet.RecordCount<=0) then
|
|
|
|
begin
|
|
|
|
Dec(FInProcessCalc);
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
|
2013-03-29 18:17:29 +00:00
|
|
|
DHS:=THackDataSet(DataSource.DataSet);
|
2014-03-27 12:36:50 +00:00
|
|
|
|
2014-03-31 11:08:07 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P:=DataSource.DataSet.GetBookmark;
|
|
|
|
{$ELSE}
|
|
|
|
P := DHS.Bookmark;
|
|
|
|
{$ENDIF}
|
2014-03-27 12:36:50 +00:00
|
|
|
|
2013-03-29 18:17:29 +00:00
|
|
|
SaveState:=DHS.SetTempState(dsBrowse);
|
|
|
|
|
|
|
|
SaveAfterScroll:=DHS.AfterScroll;
|
|
|
|
SaveBeforeScroll:=DHS.BeforeScroll;
|
|
|
|
DHS.AfterScroll:=nil;
|
|
|
|
DHS.BeforeScroll:=nil;
|
|
|
|
|
2017-02-27 05:38:55 +00:00
|
|
|
SaveActiveRecord:=Datalink.ActiveRecord;
|
|
|
|
Datalink.ActiveRecord:=0;
|
2013-03-29 18:17:29 +00:00
|
|
|
SavePos:=DHS.RecNo;
|
|
|
|
|
2014-08-14 12:50:39 +00:00
|
|
|
FCList:=TFPList.Create;
|
2017-05-18 13:58:44 +00:00
|
|
|
FCList2:=TFPList.Create;
|
|
|
|
|
|
|
|
for C in Columns do
|
2014-08-14 12:50:39 +00:00
|
|
|
begin
|
2023-09-08 11:29:09 +00:00
|
|
|
if (C.Footer.ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and C.Visible and (C.Footer.FieldName<>'') then
|
2014-08-14 12:50:39 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
FCList.Add(C);
|
|
|
|
C.Footer.FField:=DHS.FieldByName(C.Footer.FieldName);
|
2014-08-14 12:50:39 +00:00
|
|
|
end;
|
2015-07-28 10:15:04 +00:00
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
for F in C.Footers do
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
2023-09-08 11:29:09 +00:00
|
|
|
if (F.ValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and C.Visible and (F.FieldName<>'') then
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
if FCList.IndexOf(C) < 0 then
|
|
|
|
FCList.Add(C);
|
|
|
|
F.FField:=DHS.FieldByName(F.FieldName);
|
2015-07-28 10:15:04 +00:00
|
|
|
end;
|
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if FGroupItems.Active then
|
|
|
|
if C.FGroupParam.ValueType <> fvtNon then
|
|
|
|
FCList2.Add(C);
|
2014-08-14 12:50:39 +00:00
|
|
|
end;
|
2013-03-29 18:17:29 +00:00
|
|
|
|
|
|
|
DHS.First;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
|
|
|
if FGroupItems.Active then
|
|
|
|
FGroupItems.InitGroup;
|
|
|
|
|
2013-03-29 18:17:29 +00:00
|
|
|
while not DHS.EOF do
|
|
|
|
begin
|
2014-08-14 12:50:39 +00:00
|
|
|
for i:=0 to FCList.Count-1 do
|
2013-03-29 18:17:29 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
C:=TRxColumn(FCList[i]);
|
|
|
|
if (C.FFooter.FValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and Assigned(C.FFooter.FField) then
|
|
|
|
C.FFooter.UpdateTestValueFromVar(C.FFooter.FField.AsVariant);
|
2015-07-28 10:15:04 +00:00
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
for F in C.FFooters do
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
if (F.FValueType in [fvtSum, fvtAvg, fvtMax, fvtMin]) and Assigned(F.FField) then
|
|
|
|
F.UpdateTestValueFromVar( F.FField.AsVariant)
|
2015-07-28 10:15:04 +00:00
|
|
|
end;
|
2013-03-29 18:17:29 +00:00
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if FGroupItems.Active then
|
|
|
|
begin
|
|
|
|
FGroupItems.UpdateValues;
|
|
|
|
for i:=0 to FCList2.Count-1 do
|
|
|
|
TRxColumn(FCList2[i]).FGroupParam.UpdateValues;
|
|
|
|
end;
|
2017-05-18 13:58:44 +00:00
|
|
|
|
2013-03-29 20:34:42 +00:00
|
|
|
inc(cnt);
|
2013-03-29 18:17:29 +00:00
|
|
|
DHS.Next;
|
|
|
|
end;
|
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
//calc agregate values
|
2017-05-18 13:58:44 +00:00
|
|
|
for C in Columns do
|
2013-03-29 20:34:42 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
if C.Footer.ValueType = fvtCount then
|
|
|
|
C.FFooter.FCountRec:=Cnt
|
2014-08-14 12:50:39 +00:00
|
|
|
else
|
2017-05-18 13:58:44 +00:00
|
|
|
if C.Footer.ValueType = fvtAvg then
|
|
|
|
C.FFooter.FTestValue:=C.FFooter.FTestValue / Cnt;
|
2015-07-28 10:15:04 +00:00
|
|
|
|
2017-05-18 13:58:44 +00:00
|
|
|
for F in C.Footers do
|
2015-07-28 10:15:04 +00:00
|
|
|
begin
|
2017-05-18 13:58:44 +00:00
|
|
|
if F.ValueType = fvtCount then
|
|
|
|
F.FCountRec:=Cnt
|
2015-07-28 10:15:04 +00:00
|
|
|
else
|
2017-05-18 13:58:44 +00:00
|
|
|
if F.ValueType = fvtAvg then
|
|
|
|
F.FTestValue:=F.FTestValue / Cnt;
|
2015-07-28 10:15:04 +00:00
|
|
|
end;
|
2013-03-29 20:34:42 +00:00
|
|
|
end;
|
2017-05-18 11:57:06 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if FGroupItems.Active then
|
|
|
|
FGroupItems.DoneGroup;
|
|
|
|
|
|
|
|
FCList2.Free;
|
|
|
|
FCList.Free;
|
|
|
|
|
|
|
|
//Restore cursor position
|
2017-02-27 05:38:55 +00:00
|
|
|
if Min(Datalink.RecordCount + SavePos - 1, DHS.RecNo) > 0 then
|
|
|
|
DHS.RecNo := Min(Datalink.RecordCount + SavePos - 1, DHS.RecNo);
|
2013-03-29 18:17:29 +00:00
|
|
|
|
|
|
|
while not DHS.BOF do
|
|
|
|
begin
|
|
|
|
if SavePos = DHS.RecNo then
|
|
|
|
break;
|
|
|
|
DHS.Prior;
|
|
|
|
end;
|
|
|
|
|
2014-08-14 12:50:39 +00:00
|
|
|
for i:=0 to Columns.Count-1 do
|
|
|
|
TRxColumn(Columns[i]).Footer.FField:=nil;
|
|
|
|
|
2017-02-27 05:38:55 +00:00
|
|
|
Datalink.ActiveRecord:=SaveActiveRecord;
|
2013-03-29 18:17:29 +00:00
|
|
|
DHS.RestoreState(SaveState);
|
|
|
|
|
|
|
|
DHS.AfterScroll := SaveAfterScroll;
|
|
|
|
DHS.BeforeScroll := SaveBeforeScroll;
|
2007-08-10 22:15:51 +00:00
|
|
|
|
2014-03-31 11:08:07 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
2014-04-02 11:44:09 +00:00
|
|
|
P_26:=DHS.GetBookmark;
|
|
|
|
if DHS.CompareBookmarks(P_26, P)<>0 then
|
|
|
|
DHS.GotoBookmark(P); //workaround for fix navigation problem
|
2014-03-31 11:08:07 +00:00
|
|
|
DHS.FreeBookmark(P);
|
2014-04-02 11:44:09 +00:00
|
|
|
DHS.FreeBookmark(P_26);
|
|
|
|
{$ELSE}
|
2016-02-18 07:09:38 +00:00
|
|
|
if DHS.BookmarkValid(P) and (DHS.CompareBookmarks(DHS.Bookmark, P)<>0) then
|
2014-04-02 11:44:09 +00:00
|
|
|
DHS.Bookmark:=P; //workaround for fix navigation problem
|
2014-03-31 11:08:07 +00:00
|
|
|
{$ENDIF}
|
2014-03-27 12:36:50 +00:00
|
|
|
|
2014-04-02 11:44:09 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
Dec(FInProcessCalc);
|
2011-05-07 14:48:11 +00:00
|
|
|
if FInProcessCalc < 0 then
|
|
|
|
FInProcessCalc := 0;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.OptimizeColumnsWidth(AColList: string);
|
2007-08-10 22:15:51 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
ColList: TList;
|
|
|
|
|
|
|
|
procedure DoFillColList;
|
|
|
|
var
|
|
|
|
L: integer;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
L := Pos(';', AColList);
|
|
|
|
while L > 0 do
|
|
|
|
begin
|
|
|
|
if AColList <> '' then
|
|
|
|
ColList.Add(ColumnByFieldName(Copy(AColList, 1, L - 1)));
|
|
|
|
Delete(AColList, 1, L);
|
|
|
|
L := Pos(';', AColList);
|
|
|
|
end;
|
|
|
|
if AColList <> '' then
|
|
|
|
ColList.Add(ColumnByFieldName(AColList));
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (not DatalinkActive) or (Columns.Count = 0) then
|
|
|
|
Exit;
|
|
|
|
ColList := TList.Create;
|
2007-08-10 22:15:51 +00:00
|
|
|
DoFillColList;
|
|
|
|
InternalOptimizeColumnsWidth(ColList);
|
|
|
|
ColList.Free;
|
2013-08-14 20:09:46 +00:00
|
|
|
|
|
|
|
if Assigned(OnColumnSized) then
|
|
|
|
OnColumnSized(Self);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.OptimizeColumnsWidthAll;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
ColList: TList;
|
|
|
|
i: integer;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (not DatalinkActive) or (Columns.Count = 0) then
|
|
|
|
Exit;
|
|
|
|
ColList := TList.Create;
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
ColList.Add(Columns[i]);
|
|
|
|
InternalOptimizeColumnsWidth(ColList);
|
|
|
|
ColList.Free;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.UpdateTitleHight;
|
|
|
|
begin
|
|
|
|
CalcTitle;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.FilterRec(DataSet: TDataSet; var Accept: boolean);
|
2009-08-06 16:59:07 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2017-12-18 08:35:51 +00:00
|
|
|
Filter: TRxColumnFilter;
|
|
|
|
F: TField;
|
2019-10-23 10:12:58 +00:00
|
|
|
C: TRxColumn;
|
|
|
|
S: String;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Accept := True;
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2019-10-23 10:12:58 +00:00
|
|
|
C:=Columns[i];
|
|
|
|
Filter:=TRxColumn(C).Filter;
|
|
|
|
F:=TRxColumn(C).Field;
|
2017-12-18 08:35:51 +00:00
|
|
|
if Filter.State = rxfsAll then
|
|
|
|
Accept:=true
|
|
|
|
else
|
|
|
|
if Filter.State = rxfsEmpty then
|
|
|
|
Accept:=F.IsNull
|
|
|
|
else
|
|
|
|
if Filter.State = rxfsNonEmpty then
|
|
|
|
Accept:=not F.IsNull
|
|
|
|
else
|
2017-04-24 12:24:50 +00:00
|
|
|
{ if Filter.State = rxfsTopXXXX then
|
|
|
|
begin
|
|
|
|
if DataSet.State = dsFilter then
|
|
|
|
Accept:=true
|
|
|
|
else
|
|
|
|
Accept:=DataSet.RecNo < Filter.TopRecord;
|
|
|
|
if not Accept then
|
|
|
|
Break;
|
|
|
|
end
|
|
|
|
else}
|
2017-12-18 08:35:51 +00:00
|
|
|
begin
|
2019-10-23 10:12:58 +00:00
|
|
|
S:=GetFieldDisplayText(F, C);
|
|
|
|
if Filter.CurrentValues.Count > 0 then
|
|
|
|
Accept := Filter.CurrentValues.IndexOf(S) >= 0;
|
|
|
|
|
|
|
|
if Accept and (Filter.Style in [rxfstBoth, rxfstManualEdit]) and (Filter.ManulEditValue<>'') then
|
|
|
|
Accept := UTF8Pos(UTF8UpperCase(Filter.ManulEditValue), UTF8UpperCase(S)) > 0;
|
|
|
|
(*
|
2017-04-24 12:24:50 +00:00
|
|
|
if Filter.CurrentValues.Count > 0 then
|
2017-12-18 08:35:51 +00:00
|
|
|
Accept := Filter.CurrentValues.IndexOf(F.DisplayText) >= 0;
|
|
|
|
|
|
|
|
if Accept and (Filter.Style in [rxfstBoth, rxfstManualEdit]) and (Filter.ManulEditValue<>'') then
|
|
|
|
Accept := UTF8Pos(UTF8UpperCase(Filter.ManulEditValue), UTF8UpperCase(F.DisplayText)) > 0;
|
2019-10-23 10:12:58 +00:00
|
|
|
*)
|
2017-12-18 08:35:51 +00:00
|
|
|
if not Accept then
|
|
|
|
Break;
|
2012-09-26 14:19:29 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
if Assigned(F_EventOnFilterRec) then
|
2011-05-07 14:48:11 +00:00
|
|
|
F_EventOnFilterRec(DataSet, Accept);
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.BeforeDel(DataSet: TDataSet);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-02-25 07:27:11 +00:00
|
|
|
if FFooterOptions.Active and (DatalinkActive) then
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2009-08-06 16:59:07 +00:00
|
|
|
if not TRxColumn(Columns[i]).Footer.DeleteTestValue then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FInProcessCalc := -1;
|
|
|
|
Break;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
if Assigned(F_EventOnBeforeDelete) then
|
|
|
|
F_EventOnBeforeDelete(DataSet);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.BeforePo(DataSet: TDataSet);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2013-03-12 14:08:34 +00:00
|
|
|
C:TRxColumn;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2013-03-12 14:08:34 +00:00
|
|
|
if DatalinkActive then
|
|
|
|
begin
|
|
|
|
if FooterOptions.Active then
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2013-03-12 14:08:34 +00:00
|
|
|
begin
|
2009-08-06 16:59:07 +00:00
|
|
|
if not TRxColumn(Columns[i]).Footer.PostTestValue then
|
|
|
|
begin
|
2013-03-12 14:08:34 +00:00
|
|
|
FInProcessCalc := -1;
|
|
|
|
Break;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
2013-03-12 14:08:34 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
if rdgFilter in OptionsRx then
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
C:=TRxColumn(Columns[i]);
|
|
|
|
if Assigned(C.Field) and (C.Filter.ValueList.IndexOf(C.Field.DisplayText)< 0) then
|
|
|
|
C.Filter.ValueList.Add(C.Field.DisplayText);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
if Assigned(F_EventOnBeforePost) then
|
|
|
|
F_EventOnBeforePost(DataSet);
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.ErrorDel(DataSet: TDataSet; E: EDatabaseError;
|
|
|
|
var DataAction: TDataAction);
|
2009-08-06 16:59:07 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-02-25 07:27:11 +00:00
|
|
|
if FFooterOptions.Active and (DatalinkActive) then
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2009-08-06 16:59:07 +00:00
|
|
|
if not TRxColumn(Columns[i]).Footer.ErrorTestValue then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FInProcessCalc := -1;
|
2009-08-06 16:59:07 +00:00
|
|
|
Break;
|
|
|
|
end;
|
|
|
|
if Assigned(F_EventOnDeleteError) then
|
2011-05-07 14:48:11 +00:00
|
|
|
F_EventOnDeleteError(DataSet, E, DataAction);
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.ErrorPo(DataSet: TDataSet; E: EDatabaseError;
|
|
|
|
var DataAction: TDataAction);
|
2009-08-06 16:59:07 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2019-01-17 08:37:42 +00:00
|
|
|
F: TRxColumnFooterItem;
|
|
|
|
R: TRxColumn;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-02-25 07:27:11 +00:00
|
|
|
if FFooterOptions.Active and (DatalinkActive) then
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2019-01-17 08:37:42 +00:00
|
|
|
begin
|
|
|
|
R:=TRxColumn(Columns[i]);
|
|
|
|
F:=TRxColumn(Columns[i]).Footer;
|
2009-08-06 16:59:07 +00:00
|
|
|
if not TRxColumn(Columns[i]).Footer.ErrorTestValue then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
FInProcessCalc := -1;
|
2009-08-06 16:59:07 +00:00
|
|
|
Break;
|
|
|
|
end;
|
2019-01-17 08:37:42 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
if Assigned(F_EventOnPostError) then
|
2011-05-07 14:48:11 +00:00
|
|
|
F_EventOnPostError(DataSet, E, DataAction);
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.OnFind(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if rdgAllowDialogFind in OptionsRx then
|
|
|
|
ShowFindDialog;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.OnFilterBy(Sender: TObject);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
NewFilter: string;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
if DataLinkActive then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
OptionsRx := OptionsRx - [rdgFilter];
|
|
|
|
rxFilterByForm := TrxFilterByForm.Create(Application);
|
|
|
|
NewFilter := DataSource.DataSet.Filter;
|
2012-09-17 10:07:41 +00:00
|
|
|
if rxFilterByForm.Execute(Self, NewFilter, F_LastFilter) then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
if NewFilter <> '' then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
DataSource.DataSet.Filter := NewFilter;
|
2009-08-06 16:59:07 +00:00
|
|
|
DataSource.DataSet.Filtered := True;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.Filtered := False;
|
|
|
|
end;
|
|
|
|
CalcStatTotals;
|
|
|
|
end;
|
|
|
|
FreeAndNil(rxFilterByForm);
|
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
|
|
|
procedure TRxDBGrid.OnFilter(Sender: TObject);
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
C: TRxColumn;
|
|
|
|
i: integer;
|
2014-07-18 05:03:51 +00:00
|
|
|
FBS, FAS:TDataSetNotifyEvent;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2013-03-14 14:29:55 +00:00
|
|
|
BeginUpdate;
|
2011-05-07 14:48:11 +00:00
|
|
|
OptionsRx := OptionsRx + [rdgFilter];
|
2017-12-28 08:57:47 +00:00
|
|
|
{
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
C := TRxColumn(Columns[i]);
|
2009-08-06 16:59:07 +00:00
|
|
|
C.Filter.ValueList.Clear;
|
2017-04-24 12:24:50 +00:00
|
|
|
C.Filter.CurrentValues.Clear;
|
2017-12-18 08:35:51 +00:00
|
|
|
C.Filter.ManulEditValue:='';
|
2011-05-07 14:48:11 +00:00
|
|
|
C.Filter.ItemIndex := -1;
|
2009-08-06 16:59:07 +00:00
|
|
|
C.Filter.ValueList.Add(C.Filter.EmptyValue);
|
2016-09-08 08:51:40 +00:00
|
|
|
C.Filter.ValueList.Add(C.Filter.AllValue);
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
|
2012-02-23 04:46:16 +00:00
|
|
|
if DatalinkActive then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
DataSource.DataSet.DisableControls;
|
|
|
|
DataSource.DataSet.Filtered := True;
|
2014-07-18 05:03:51 +00:00
|
|
|
FBS:=DataSource.DataSet.BeforeScroll;
|
|
|
|
FAS:=DataSource.DataSet.AfterScroll;
|
|
|
|
DataSource.DataSet.BeforeScroll:=nil;
|
|
|
|
DataSource.DataSet.AfterScroll:=nil;
|
2012-02-23 04:46:16 +00:00
|
|
|
DataSource.DataSet.First;
|
|
|
|
while not DataSource.DataSet.EOF do
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2012-02-23 04:46:16 +00:00
|
|
|
for i := 0 to Columns.Count - 1 do
|
|
|
|
begin
|
|
|
|
C := TRxColumn(Columns[i]);
|
2013-05-08 05:26:49 +00:00
|
|
|
if C.Filter.Enabled and (C.Field <> nil) and (C.Filter.ValueList.IndexOf(C.Field.DisplayText) < 0) then
|
2012-02-23 04:46:16 +00:00
|
|
|
C.Filter.ValueList.Add(C.Field.DisplayText);
|
|
|
|
end;
|
|
|
|
DataSource.DataSet.Next;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
2012-02-23 04:46:16 +00:00
|
|
|
DataSource.DataSet.First;
|
2014-07-18 05:03:51 +00:00
|
|
|
DataSource.DataSet.BeforeScroll:=FBS;
|
|
|
|
DataSource.DataSet.AfterScroll:=FAS;
|
2012-02-23 04:46:16 +00:00
|
|
|
DataSource.DataSet.EnableControls;
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
2017-12-28 08:57:47 +00:00
|
|
|
}
|
2013-03-14 14:29:55 +00:00
|
|
|
EndUpdate;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
|
|
|
procedure TRxDBGrid.OnFilterClose(Sender: TObject);
|
2011-05-07 14:48:11 +00:00
|
|
|
begin
|
|
|
|
OptionsRx := OptionsRx - [rdgFilter];
|
|
|
|
DataSource.DataSet.Filtered := False;
|
2009-08-06 16:59:07 +00:00
|
|
|
CalcStatTotals;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.OnSortBy(Sender: TObject);
|
2009-08-06 16:59:07 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2012-09-21 17:06:21 +00:00
|
|
|
S1: string;
|
|
|
|
FSortListField:TStringList;
|
|
|
|
FColumn:TRxColumn;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
if DatalinkActive then
|
|
|
|
begin
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortListField:=TStringList.Create;
|
|
|
|
try
|
|
|
|
rxSortByForm := TrxSortByForm.Create(Application);
|
|
|
|
rxSortByForm.CheckBox1.Checked := rdgCaseInsensitiveSort in FOptionsRx;
|
|
|
|
if rxSortByForm.Execute(Self, FSortListField) then
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
2021-10-20 06:39:44 +00:00
|
|
|
for i:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
FColumn:=Columns[i];
|
|
|
|
FColumn.FSortPosition:=0;
|
|
|
|
FColumn.FSortOrder:=smNone;
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
for i := 0 to FSortListField.Count - 1 do
|
|
|
|
begin
|
|
|
|
S1:=FSortListField.Strings[i];
|
|
|
|
FColumn:=TRxColumn(ColumnByFieldName(Copy(S1, 2, Length(S1))));
|
|
|
|
if S1[1] = '1' then
|
|
|
|
FColumn.FSortOrder := smUp
|
|
|
|
else
|
|
|
|
FColumn.FSortOrder := smDown;
|
2009-12-10 22:02:14 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
FColumn.FSortPosition:=i;
|
|
|
|
end;
|
2009-12-10 22:02:14 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
CollumnSortListUpdate;
|
|
|
|
|
|
|
|
if rxSortByForm.CheckBox1.Checked then
|
|
|
|
Include(FOptionsRx, rdgCaseInsensitiveSort)
|
|
|
|
else
|
|
|
|
Exclude(FOptionsRx, rdgCaseInsensitiveSort);
|
|
|
|
|
|
|
|
CollumnSortListApply;
|
2014-06-14 07:16:52 +00:00
|
|
|
if Assigned(FOnSortChanged) then
|
|
|
|
begin
|
|
|
|
FSortingNow := True;
|
|
|
|
FOnSortChanged(Self);
|
|
|
|
FSortingNow := False;
|
|
|
|
end;
|
2012-09-21 17:06:21 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
finally
|
|
|
|
FreeAndNil(rxSortByForm);
|
|
|
|
FreeAndNil(FSortListField);
|
2009-08-06 16:59:07 +00:00
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.OnChooseVisibleFields(Sender: TObject);
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
if rdgAllowColumnsForm in OptionsRx then
|
|
|
|
ShowColumnsDialog;
|
|
|
|
end;
|
|
|
|
|
2012-09-24 14:21:22 +00:00
|
|
|
procedure TRxDBGrid.OnSelectAllRows(Sender: TObject);
|
|
|
|
begin
|
|
|
|
SelectAllRows;
|
|
|
|
end;
|
|
|
|
|
2014-01-15 11:35:25 +00:00
|
|
|
procedure TRxDBGrid.OnCopyCellValue(Sender: TObject);
|
2014-02-04 16:58:30 +00:00
|
|
|
var
|
|
|
|
P:TBookMark;
|
|
|
|
S:string;
|
2016-11-17 06:48:21 +00:00
|
|
|
i, k, j:integer;
|
2014-01-15 11:35:25 +00:00
|
|
|
begin
|
2014-02-04 16:58:30 +00:00
|
|
|
if DatalinkActive then
|
2014-01-15 11:35:25 +00:00
|
|
|
begin
|
2016-11-17 06:48:21 +00:00
|
|
|
if (dgMultiselect in Options) and (SelectedRows.Count>1) then
|
|
|
|
begin
|
|
|
|
S:='';
|
|
|
|
DataSource.DataSet.DisableControls;
|
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P:=DataSource.DataSet.GetBookmark;
|
|
|
|
{$ELSE}
|
|
|
|
P:=DataSource.DataSet.Bookmark;
|
|
|
|
{$ENDIF}
|
|
|
|
try
|
|
|
|
for j:=0 to SelectedRows.Count-1 do
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.Bookmark:=SelectedRows[j];
|
|
|
|
if S<>'' then
|
|
|
|
S:=S+LineEnding;
|
|
|
|
K:=0;
|
|
|
|
for i:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
if Assigned(Columns[i].Field) then
|
|
|
|
begin
|
|
|
|
if K<>0 then
|
|
|
|
S:=S+#9;
|
2017-12-21 11:28:44 +00:00
|
|
|
|
2019-10-23 10:12:58 +00:00
|
|
|
S:=S + GetFieldDisplayText(Columns[i].Field, Columns[i]);
|
|
|
|
(* {$IF lcl_fullversion >= 1090000}
|
2017-12-21 11:28:44 +00:00
|
|
|
if CheckDisplayMemo(Columns[i].Field) then
|
|
|
|
S :=S + Columns[i].Field.AsString
|
|
|
|
else
|
|
|
|
{$ENDIF}
|
2019-10-23 10:12:58 +00:00
|
|
|
S:=S+Columns[i].Field.DisplayText; *)
|
2016-11-17 06:48:21 +00:00
|
|
|
inc(K);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
DataSource.DataSet.GotoBookmark(P);
|
|
|
|
DataSource.DataSet.FreeBookmark(P);
|
|
|
|
{$ELSE}
|
|
|
|
DataSource.DataSet.Bookmark:=P;
|
|
|
|
{$ENDIF}
|
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
if S<>'' then
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
Clipboard.Open;
|
|
|
|
Clipboard.AsText:=S;
|
|
|
|
finally
|
|
|
|
Clipboard.Close;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end
|
2017-12-21 11:28:44 +00:00
|
|
|
(* else
|
2014-02-04 16:58:30 +00:00
|
|
|
if (dgMultiselect in Options) and (SelectedRows.Count>1) then
|
|
|
|
begin
|
|
|
|
S:='';
|
|
|
|
DataSource.DataSet.DisableControls;
|
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P:=DataSource.DataSet.GetBookmark;
|
|
|
|
{$ELSE}
|
|
|
|
P:=DataSource.DataSet.Bookmark;
|
|
|
|
{$ENDIF}
|
|
|
|
try
|
|
|
|
DataSource.DataSet.First;
|
|
|
|
while not DataSource.DataSet.EOF do
|
|
|
|
begin
|
|
|
|
if S<>'' then
|
|
|
|
S:=S+LineEnding;
|
|
|
|
K:=0;
|
|
|
|
for i:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
if Assigned(Columns[i].Field) then
|
|
|
|
begin
|
|
|
|
if K<>0 then
|
|
|
|
S:=S+#9;
|
|
|
|
S:=S+Columns[i].Field.DisplayText;
|
|
|
|
inc(K);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
DataSource.DataSet.Next;
|
|
|
|
end;
|
|
|
|
finally
|
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
DataSource.DataSet.GotoBookmark(P);
|
|
|
|
DataSource.DataSet.FreeBookmark(P);
|
|
|
|
{$ELSE}
|
|
|
|
DataSource.DataSet.Bookmark:=P;
|
|
|
|
{$ENDIF}
|
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
if S<>'' then
|
|
|
|
begin
|
|
|
|
try
|
|
|
|
Clipboard.Open;
|
|
|
|
Clipboard.AsText:=S;
|
|
|
|
finally
|
|
|
|
Clipboard.Close;
|
|
|
|
end;
|
|
|
|
end;
|
2017-12-21 11:28:44 +00:00
|
|
|
end *)
|
2014-02-04 16:58:30 +00:00
|
|
|
else
|
|
|
|
if Assigned(SelectedField) then
|
2014-01-15 11:35:25 +00:00
|
|
|
try
|
|
|
|
Clipboard.Open;
|
2017-12-21 11:28:44 +00:00
|
|
|
|
|
|
|
{$IF lcl_fullversion >= 1090000}
|
|
|
|
if CheckDisplayMemo(SelectedField) then
|
|
|
|
Clipboard.AsText:=SelectedField.AsString
|
|
|
|
else
|
|
|
|
{$ENDIF}
|
|
|
|
Clipboard.AsText:=SelectedField.DisplayText;
|
2014-01-15 11:35:25 +00:00
|
|
|
finally
|
|
|
|
Clipboard.Close;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2016-09-20 07:48:58 +00:00
|
|
|
procedure TRxDBGrid.OnOptimizeColWidth(Sender: TObject);
|
|
|
|
begin
|
|
|
|
OptimizeColumnsWidthAll;
|
|
|
|
end;
|
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
procedure TRxDBGrid.Loaded;
|
|
|
|
begin
|
|
|
|
inherited Loaded;
|
|
|
|
UpdateJMenuKeys;
|
|
|
|
end;
|
|
|
|
|
2012-04-15 21:22:58 +00:00
|
|
|
procedure TRxDBGrid.UpdateFooterRowOnUpdateActive;
|
|
|
|
begin
|
2012-05-08 14:14:10 +00:00
|
|
|
if Assigned(DataSource) then
|
|
|
|
begin
|
|
|
|
if DataSource.State <> FOldDataSetState then
|
|
|
|
begin
|
|
|
|
if (FOldDataSetState in dsEditModes) and (DataSource.State = dsBrowse) then
|
|
|
|
CalcStatTotals;
|
|
|
|
FOldDataSetState:=DataSource.State;
|
|
|
|
end;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
FOldDataSetState:=dsInactive;
|
2012-04-15 21:22:58 +00:00
|
|
|
end;
|
|
|
|
|
2012-08-23 17:03:53 +00:00
|
|
|
procedure TRxDBGrid.DoEditorHide;
|
|
|
|
var
|
|
|
|
R:TRxColumn;
|
2016-05-12 07:25:00 +00:00
|
|
|
i:integer;
|
2012-08-23 17:03:53 +00:00
|
|
|
begin
|
|
|
|
inherited DoEditorHide;
|
|
|
|
R:=SelectedColumn as TRxColumn;
|
|
|
|
|
2012-09-07 14:12:36 +00:00
|
|
|
if Assigned(Editor) and Assigned(R) then
|
2012-08-23 17:03:53 +00:00
|
|
|
for i:=0 to R.EditButtons.Count-1 do
|
2014-02-02 11:14:10 +00:00
|
|
|
begin
|
|
|
|
if R.EditButtons[i].Style = ebsUpDownRx then
|
|
|
|
R.EditButtons[i].FSpinBtn.Visible:=false
|
|
|
|
else
|
|
|
|
R.EditButtons[i].FButton.Visible:=false;
|
|
|
|
end;
|
2012-08-23 17:03:53 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.DoEditorShow;
|
2017-05-26 13:05:56 +00:00
|
|
|
var
|
|
|
|
R, R1: TRect;
|
|
|
|
FSaveRow: Integer;
|
|
|
|
P: TBookMark;
|
|
|
|
FG: TColumnGroupItem;
|
2012-08-23 17:03:53 +00:00
|
|
|
begin
|
|
|
|
inherited DoEditorShow;
|
2017-05-26 13:05:56 +00:00
|
|
|
|
|
|
|
{ if FGroupItems.Active then
|
|
|
|
begin
|
|
|
|
if (Row>=FixedRows) then
|
|
|
|
begin
|
|
|
|
FSaveRow:=DataLink.ActiveRecord;
|
|
|
|
DataLink.ActiveRecord:=Row-FixedRows;
|
|
|
|
P:=DataSource.DataSet.Bookmark;
|
|
|
|
DataLink.ActiveRecord:=FSaveRow;
|
|
|
|
FG:=FGroupItems.FindGroupItem(P);
|
|
|
|
if Assigned(FG) then
|
|
|
|
begin
|
|
|
|
R:=CellRect(Col, Row);
|
|
|
|
Editor.SetBounds(R.Left, R.Top, R.Right - R.Left - 1, R.Bottom - R.Top - DefaultRowHeight - 1);
|
|
|
|
R1:=Editor.BoundsRect;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end; }
|
2017-06-09 13:26:54 +00:00
|
|
|
|
|
|
|
if rdgColSpanning in OptionsRx then
|
|
|
|
begin
|
|
|
|
if IsMerged(Col) then
|
|
|
|
begin
|
|
|
|
CalcCellExtent(Col, Row, R);
|
|
|
|
Editor.SetBounds(R.Left, R.Top, R.Right-R.Left-1, R.Bottom-R.Top-1);
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2013-05-16 17:57:58 +00:00
|
|
|
DoSetColEdtBtn;
|
2012-08-23 17:03:53 +00:00
|
|
|
end;
|
2017-05-18 11:57:06 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
procedure TRxDBGrid.CheckNewCachedSizes(var AGCache: TGridDataCache);
|
|
|
|
begin
|
|
|
|
inherited CheckNewCachedSizes(AGCache);
|
2017-05-30 07:49:41 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
if FFooterOptions.Active then
|
|
|
|
begin
|
2017-05-30 07:49:41 +00:00
|
|
|
// AGCache.ClientHeight:=AGCache.ClientHeight - DefaultRowHeight * FFooterOptions.RowCount;
|
2017-05-26 13:05:56 +00:00
|
|
|
AGCache.ScrollHeight:=AGCache.ScrollHeight - DefaultRowHeight * FFooterOptions.RowCount;
|
|
|
|
AGCache.ClientRect.Bottom:=AGCache.ClientRect.Bottom - DefaultRowHeight * FFooterOptions.RowCount;
|
|
|
|
end;
|
2017-05-30 07:49:41 +00:00
|
|
|
|
2017-05-26 13:05:56 +00:00
|
|
|
end;
|
|
|
|
|
2017-06-09 13:26:54 +00:00
|
|
|
procedure TRxDBGrid.CalcCellExtent(ACol, ARow: Integer; var ARect: TRect);
|
|
|
|
var
|
|
|
|
L, T, R, B: Integer;
|
2017-06-13 08:58:24 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:26:54 +00:00
|
|
|
begin
|
2017-06-13 08:58:24 +00:00
|
|
|
if IsMerged(ACol, L, R, C) then
|
2017-06-09 13:26:54 +00:00
|
|
|
begin
|
|
|
|
ARect.TopLeft := CellRect(L, ARow).TopLeft;
|
|
|
|
ARect.BottomRight := CellRect(R, ARow).BottomRight;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2017-06-13 08:58:24 +00:00
|
|
|
function TRxDBGrid.IsMerged(ACol: Integer): Boolean;
|
2017-06-09 13:26:54 +00:00
|
|
|
var
|
2017-06-13 08:58:24 +00:00
|
|
|
L, R: Integer;
|
|
|
|
C: TRxColumn;
|
2017-06-09 13:26:54 +00:00
|
|
|
begin
|
2017-06-13 08:58:24 +00:00
|
|
|
Result := IsMerged(ACol, L, R, C);
|
2017-06-09 13:26:54 +00:00
|
|
|
end;
|
|
|
|
|
2017-06-13 08:58:24 +00:00
|
|
|
function TRxDBGrid.IsMerged(ACol: Integer; out ALeft, ARight: Integer; out
|
|
|
|
AColumn: TRxColumn): Boolean;
|
2017-06-09 13:26:54 +00:00
|
|
|
begin
|
|
|
|
Result := false;
|
2017-06-13 08:58:24 +00:00
|
|
|
AColumn:=nil;
|
2017-06-09 13:26:54 +00:00
|
|
|
ALeft := ACol;
|
|
|
|
ARight := ACol;
|
|
|
|
|
2017-06-13 08:58:24 +00:00
|
|
|
if (rdgColSpanning in OptionsRx) and Assigned(FOnMergeCells) then
|
|
|
|
begin
|
|
|
|
inc(FMergeLock);
|
|
|
|
FOnMergeCells(Self, ACol, ALeft, ARight, AColumn);
|
|
|
|
if ALeft > ARight then
|
|
|
|
SwapValues(ALeft, ARight);
|
|
|
|
Result := (ALeft <> ARight);
|
|
|
|
dec(FMergeLock);
|
|
|
|
end;
|
2017-06-09 13:26:54 +00:00
|
|
|
end;
|
|
|
|
|
2017-06-09 13:56:12 +00:00
|
|
|
function TRxDBGrid.GetEditMask(aCol, aRow: Longint): string;
|
|
|
|
var
|
|
|
|
L, R: Integer;
|
2017-06-13 08:58:24 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:56:12 +00:00
|
|
|
begin
|
|
|
|
if (rdgColSpanning in OptionsRx) then
|
2017-06-13 08:58:24 +00:00
|
|
|
if IsMerged(aCol, L, R, C) then
|
|
|
|
begin
|
|
|
|
if Assigned(C) then
|
|
|
|
aCol:=C.Index
|
|
|
|
else
|
|
|
|
aCol:=L;
|
|
|
|
end;
|
2017-06-09 13:56:12 +00:00
|
|
|
Result:=inherited GetEditMask(aCol, aRow);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGrid.GetEditText(aCol, aRow: Longint): string;
|
|
|
|
var
|
|
|
|
R, L: Integer;
|
2017-06-13 08:58:24 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:56:12 +00:00
|
|
|
begin
|
|
|
|
if (rdgColSpanning in OptionsRx) then
|
2017-06-13 08:58:24 +00:00
|
|
|
if IsMerged(aCol, L, R, C) then
|
|
|
|
begin
|
|
|
|
if Assigned(C) then
|
|
|
|
aCol:=C.Index
|
|
|
|
else
|
|
|
|
aCol:=L;
|
|
|
|
end;
|
2017-06-09 13:56:12 +00:00
|
|
|
Result:=inherited GetEditText(aCol, aRow);
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGrid.GetDefaultEditor(Column: Integer): TWinControl;
|
|
|
|
var
|
|
|
|
L, R: Integer;
|
2017-06-13 08:58:24 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:56:12 +00:00
|
|
|
begin
|
|
|
|
if (rdgColSpanning in OptionsRx) then
|
2017-06-13 08:58:24 +00:00
|
|
|
if IsMerged(Column, L, R, C) then
|
|
|
|
begin
|
|
|
|
if Assigned(C) then
|
|
|
|
Column:=C.Index
|
|
|
|
else
|
|
|
|
Column:=L;
|
|
|
|
end;
|
2017-06-09 13:56:12 +00:00
|
|
|
Result:=inherited GetDefaultEditor(Column);
|
|
|
|
end;
|
|
|
|
|
2017-06-09 13:26:54 +00:00
|
|
|
procedure TRxDBGrid.PrepareCanvas(aCol, aRow: Integer; AState: TGridDrawState);
|
2018-01-30 08:00:10 +00:00
|
|
|
function IsCellButtonColumn(ACell: TPoint): boolean;
|
|
|
|
var
|
|
|
|
Column: TGridColumn;
|
|
|
|
begin
|
|
|
|
Column := ColumnFromGridColumn(ACell.X);
|
|
|
|
result := (Column<>nil) and (Column.ButtonStyle=cbsButtonColumn) and
|
|
|
|
(ACell.y>=FixedRows);
|
|
|
|
end;
|
|
|
|
|
2017-06-09 13:26:54 +00:00
|
|
|
var
|
|
|
|
L, R, RR: Integer;
|
2017-06-13 08:58:24 +00:00
|
|
|
C: TRxColumn;
|
2017-06-09 13:26:54 +00:00
|
|
|
begin
|
|
|
|
if (rdgColSpanning in OptionsRx) then
|
2017-06-13 08:58:24 +00:00
|
|
|
if not ((gdFixed in aState) and (aRow = 0)) then
|
|
|
|
if ((Row - FixedRows) = Datalink.ActiveRecord) and IsMerged(ACol, L, R, C) then
|
|
|
|
if (aCol >= L) and (aCol <= R) then
|
|
|
|
AState := AState + [gdSelected, gdFocused];
|
2017-06-09 13:26:54 +00:00
|
|
|
inherited PrepareCanvas(aCol, aRow, AState);
|
2018-01-30 08:00:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
if (gdSelected in AState) then
|
|
|
|
begin
|
|
|
|
if not IsCellButtonColumn(point(aCol,aRow)) then
|
|
|
|
if not FIsSelectedDefaultFont then
|
|
|
|
begin
|
|
|
|
Canvas.Font:=FSelectedFont;
|
|
|
|
if FSelectedFont.Color = clDefault then
|
|
|
|
Canvas.Font.Color := clHighlightText;
|
|
|
|
end;
|
|
|
|
end;
|
2017-06-09 13:26:54 +00:00
|
|
|
end;
|
|
|
|
|
2020-07-02 07:13:46 +00:00
|
|
|
function TRxDBGrid.GetPopupMenu: TPopupMenu;
|
|
|
|
var
|
|
|
|
C: TRxColumn;
|
|
|
|
R: TPoint;
|
|
|
|
C1: TGridCoord;
|
|
|
|
begin
|
2020-07-02 09:58:49 +00:00
|
|
|
if not (csDestroying in ComponentState) then
|
|
|
|
begin
|
|
|
|
R:=ScreenToClient(Mouse.CursorPos);
|
|
|
|
C1:=MouseCoord(R.X, R.Y);
|
|
|
|
C:=TRxColumn(ColumnFromGridColumn(C1.X));
|
|
|
|
if Assigned(C) and Assigned(C.PopupMenu) then
|
|
|
|
Result:=C.PopupMenu
|
|
|
|
else
|
|
|
|
Result:=inherited GetPopupMenu;
|
|
|
|
end
|
2020-07-02 07:13:46 +00:00
|
|
|
else
|
|
|
|
Result:=inherited GetPopupMenu;
|
|
|
|
end;
|
|
|
|
|
2017-09-19 05:43:18 +00:00
|
|
|
{$IFDEF DEVELOPER_RX}
|
|
|
|
type
|
|
|
|
THackDataLink = class(TDataLink)
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.InternalAdjustRowCount(var RecCount: integer);
|
|
|
|
var
|
|
|
|
CurActiveRecord, j, H1, FRec, H, H2: Integer;
|
|
|
|
i: LongInt;
|
|
|
|
R: TRxColumn;
|
|
|
|
F: TField;
|
|
|
|
S: String;
|
|
|
|
begin
|
|
|
|
inherited InternalAdjustRowCount(RecCount);
|
|
|
|
|
|
|
|
if (not (Assigned(DataLink) and DataLink.Active)) or ((GCache.VisibleGrid.Top=0) and (GCache.VisibleGrid.Bottom=0)) then
|
|
|
|
exit;
|
|
|
|
|
|
|
|
CurActiveRecord:=DataLink.ActiveRecord;
|
|
|
|
|
|
|
|
if dgTitles in Options then
|
|
|
|
begin
|
|
|
|
FRec:=1;
|
|
|
|
H2:=1;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
FRec:=0;
|
|
|
|
H2:=0;
|
|
|
|
end;
|
|
|
|
|
|
|
|
for i:=GCache.VisibleGrid.Top to GCache.VisibleGrid.Bottom do
|
|
|
|
begin
|
|
|
|
DataLink.ActiveRecord:=i - FixedRows;
|
|
|
|
// P:=PtrInt(DataSource.DataSet.ActiveBuffer);
|
|
|
|
H:=1;
|
|
|
|
for j:=0 to Columns.Count-1 do
|
|
|
|
begin
|
|
|
|
R:=Columns[j] as TRxColumn;
|
|
|
|
if R.WordWrap then
|
|
|
|
begin
|
|
|
|
F:=R.Field;
|
|
|
|
if Assigned(F) then
|
|
|
|
S:=F.DisplayText
|
|
|
|
else
|
|
|
|
S:='';
|
|
|
|
|
|
|
|
H1 := Max((Canvas.TextWidth(S) + 2) div R.Width + 1, H);
|
|
|
|
if H1 > WordCount(S, [' ']) then
|
|
|
|
H1 := WordCount(S, [' ']);
|
|
|
|
end
|
|
|
|
else
|
|
|
|
H1:=1;
|
|
|
|
H:=Max(H, H1);
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if FGroupItems.Active and DatalinkActive then
|
|
|
|
if Assigned(FGroupItems.FindGroupItem(DataSource.DataSet.Bookmark)) then
|
|
|
|
Inc(H);
|
|
|
|
|
|
|
|
|
|
|
|
if i<RowCount then
|
|
|
|
begin
|
|
|
|
if Assigned(FOnCalcRowHeight) then
|
|
|
|
FOnCalcRowHeight(Self, H);
|
|
|
|
RowHeights[i] := GetDefaultRowHeight * H;
|
|
|
|
H2:=H2 + RowHeights[i];
|
|
|
|
if H2<=ClientHeight then
|
|
|
|
Inc(Result);
|
|
|
|
end;}
|
|
|
|
|
|
|
|
if H2 + H > RecCount then
|
|
|
|
begin
|
|
|
|
// RecCount:=FRec;
|
|
|
|
if (FRec < FixedRows + CurActiveRecord) {and (CurActiveRecord = DataLink.ActiveRecord)} then
|
|
|
|
begin
|
|
|
|
TopRow:=1;
|
|
|
|
// THackDataLink(DataLink).FirstRecord:=THackDataLink(DataLink).FirstRecord + 1;
|
|
|
|
{ H:=CurActiveRecord - DataLink.ActiveRecord;
|
|
|
|
THackDataLink(DataLink).FirstRecord:=THackDataLink(DataLink).FirstRecord + 1;
|
|
|
|
THackDataSet(DataLink.DataSet).RecalcBufListSize;}
|
|
|
|
// THackDataLink(DataLink).BufferCount:=FRec;
|
|
|
|
H:=0;
|
|
|
|
end;
|
|
|
|
// DataLink.BufferCount:=FRec;
|
|
|
|
// break;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
begin
|
|
|
|
FRec:=FRec + 1;
|
|
|
|
H2:=H2 + H;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
DataLink.ActiveRecord:=CurActiveRecord;
|
|
|
|
|
|
|
|
end;
|
|
|
|
{$ENDIF}
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.GetOnCreateLookup;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
if Assigned(F_CreateLookup) then
|
|
|
|
F_CreateLookup(FRxDbGridLookupComboEditor);
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGrid.GetOnDisplayLookup;
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
if Assigned(F_DisplayLookup) then
|
|
|
|
F_DisplayLookup(FRxDbGridLookupComboEditor);
|
|
|
|
end;
|
2012-09-24 14:21:22 +00:00
|
|
|
|
|
|
|
procedure TRxDBGrid.SelectAllRows;
|
|
|
|
var
|
|
|
|
P:TBookMark;
|
|
|
|
begin
|
|
|
|
if DatalinkActive then
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.DisableControls;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P:=DataSource.DataSet.GetBookmark;
|
|
|
|
{$ELSE}
|
2012-09-24 14:21:22 +00:00
|
|
|
P:=DataSource.DataSet.Bookmark;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$ENDIF}
|
2012-09-24 14:21:22 +00:00
|
|
|
try
|
|
|
|
DataSource.DataSet.First;
|
|
|
|
while not DataSource.DataSet.EOF do
|
|
|
|
begin
|
|
|
|
SelectedRows.CurrentRowSelected:=true;
|
|
|
|
DataSource.DataSet.Next;
|
|
|
|
end;
|
|
|
|
finally
|
2012-09-25 18:03:19 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
DataSource.DataSet.GotoBookmark(P);
|
|
|
|
DataSource.DataSet.FreeBookmark(P);
|
|
|
|
{$ELSE}
|
2012-09-24 14:21:22 +00:00
|
|
|
DataSource.DataSet.Bookmark:=P;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$ENDIF}
|
2012-09-24 14:21:22 +00:00
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.DeSelectAllRows;
|
|
|
|
var
|
|
|
|
P:TBookMark;
|
|
|
|
begin
|
|
|
|
if DatalinkActive then
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.DisableControls;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P:=DataSource.DataSet.GetBookmark;
|
|
|
|
{$ELSE}
|
2012-09-24 14:21:22 +00:00
|
|
|
P:=DataSource.DataSet.Bookmark;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$ENDIF}
|
2012-09-24 14:21:22 +00:00
|
|
|
try
|
|
|
|
DataSource.DataSet.First;
|
|
|
|
while not DataSource.DataSet.EOF do
|
|
|
|
begin
|
|
|
|
SelectedRows.CurrentRowSelected:=false;
|
|
|
|
DataSource.DataSet.Next;
|
|
|
|
end;
|
|
|
|
finally
|
2012-09-25 18:03:19 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
DataSource.DataSet.GotoBookmark(P);
|
|
|
|
DataSource.DataSet.FreeBookmark(P);
|
|
|
|
{$ELSE}
|
2012-09-24 14:21:22 +00:00
|
|
|
DataSource.DataSet.Bookmark:=P;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$ENDIF}
|
2012-09-24 14:21:22 +00:00
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.InvertSelection;
|
|
|
|
var
|
|
|
|
P:TBookMark;
|
|
|
|
begin
|
|
|
|
if DatalinkActive then
|
|
|
|
begin
|
|
|
|
DataSource.DataSet.DisableControls;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
P:=DataSource.DataSet.GetBookmark;
|
|
|
|
{$ELSE}
|
2012-09-24 14:21:22 +00:00
|
|
|
P:=DataSource.DataSet.Bookmark;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$ENDIF}
|
2012-09-24 14:21:22 +00:00
|
|
|
try
|
|
|
|
DataSource.DataSet.First;
|
|
|
|
while not DataSource.DataSet.EOF do
|
|
|
|
begin
|
|
|
|
SelectedRows.CurrentRowSelected:=not SelectedRows.CurrentRowSelected;
|
|
|
|
DataSource.DataSet.Next;
|
|
|
|
end;
|
|
|
|
finally
|
2012-09-25 18:03:19 +00:00
|
|
|
{$IFDEF NoAutomatedBookmark}
|
|
|
|
DataSource.DataSet.GotoBookmark(P);
|
|
|
|
DataSource.DataSet.FreeBookmark(P);
|
|
|
|
{$ELSE}
|
2012-09-24 14:21:22 +00:00
|
|
|
DataSource.DataSet.Bookmark:=P;
|
2012-09-25 18:03:19 +00:00
|
|
|
{$ENDIF}
|
2012-09-24 14:21:22 +00:00
|
|
|
DataSource.DataSet.EnableControls;
|
|
|
|
end;
|
|
|
|
Invalidate;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2014-02-04 16:58:30 +00:00
|
|
|
procedure TRxDBGrid.CopyCellValue;
|
|
|
|
begin
|
|
|
|
OnCopyCellValue(Self);
|
|
|
|
end;
|
|
|
|
|
2014-06-14 07:16:52 +00:00
|
|
|
procedure TRxDBGrid.SetSort(AFields: array of String;
|
|
|
|
ASortMarkers: array of TSortMarker; PreformSort: Boolean);
|
|
|
|
var
|
|
|
|
I: Integer;
|
|
|
|
C: TRxColumn;
|
|
|
|
begin
|
|
|
|
CollumnSortListClear;
|
|
|
|
if (Length(AFields) > 0) and (Length(AFields) = Length(ASortMarkers)) then
|
|
|
|
begin
|
|
|
|
for I := 0 to Length(AFields) - 1 do
|
|
|
|
begin
|
|
|
|
C := ColumnByFieldName(AFields[I]);
|
|
|
|
if C <> nil then
|
|
|
|
begin
|
|
|
|
C.SortOrder := ASortMarkers[I];
|
|
|
|
C.FSortPosition := I;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
CollumnSortListUpdate;
|
|
|
|
end;
|
|
|
|
if PreformSort then
|
|
|
|
begin
|
|
|
|
if Assigned(FSortEngine) then
|
|
|
|
CollumnSortListApply;
|
|
|
|
if Assigned(FOnSortChanged) then
|
|
|
|
begin
|
|
|
|
FSortingNow := True;
|
|
|
|
FOnSortChanged(Self);
|
|
|
|
FSortingNow := False;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2017-05-18 11:57:06 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
constructor TRxDBGrid.Create(AOwner: TComponent);
|
|
|
|
begin
|
2012-09-05 18:39:35 +00:00
|
|
|
FFooterOptions:=TRxDBGridFooterOptions.Create(Self);
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited Create(AOwner);
|
2007-08-28 21:55:23 +00:00
|
|
|
{$IFDEF RXDBGRID_OPTIONS_WO_CANCEL_ON_EXIT}
|
2011-05-07 14:48:11 +00:00
|
|
|
Options := Options - [dgCancelOnExit];
|
2007-08-28 21:55:23 +00:00
|
|
|
{$ENDIF}
|
2017-05-18 10:25:59 +00:00
|
|
|
FSaveOnDataSetScrolled:=Datalink.OnDataSetScrolled;
|
|
|
|
Datalink.OnDataSetScrolled:=@OnDataSetScrolled;
|
|
|
|
|
2015-05-25 10:12:12 +00:00
|
|
|
FToolsList:=TFPList.Create;
|
2015-09-07 07:42:04 +00:00
|
|
|
FColumnDefValues:=TRxDBGridColumnDefValues.Create(Self);
|
2016-11-08 08:10:02 +00:00
|
|
|
FSearchOptions:=TRxDBGridSearchOptions.Create(Self);
|
2007-08-28 21:55:23 +00:00
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
FSortColumns:=TRxDbGridColumnsSortList.Create;
|
2017-05-26 13:05:56 +00:00
|
|
|
FGroupItems:=TColumnGroupItems.Create(Self);
|
2018-12-13 11:42:18 +00:00
|
|
|
F_MenuBMP := TBitmap.Create;
|
|
|
|
RxAssignBitmap(F_MenuBMP, 'rx_menu_grid');
|
2012-09-21 17:06:21 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
Options := Options - [dgTabs];
|
2017-05-26 13:05:56 +00:00
|
|
|
|
|
|
|
// TDrawGrid(Self).Options:=TDrawGrid(Self).Options + [goColSpanning];
|
|
|
|
|
2015-09-07 07:42:04 +00:00
|
|
|
OptionsRx := OptionsRx + [rdgAllowColumnsForm, rdgAllowDialogFind, rdgAllowQuickFilter];
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FAutoSort := True;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
F_Clicked := False;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2009-08-17 17:50:27 +00:00
|
|
|
DoCreateJMenu;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2013-02-12 11:44:08 +00:00
|
|
|
FKeyStrokes := TRxDBGridKeyStrokes.Create(Self);
|
|
|
|
FKeyStrokes.ResetDefaults;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
F_LastFilter := TStringList.Create;
|
|
|
|
|
|
|
|
FPropertyStorageLink := TPropertyStorageLink.Create;
|
|
|
|
FPropertyStorageLink.OnSave := @OnIniSave;
|
|
|
|
FPropertyStorageLink.OnLoad := @OnIniLoad;
|
2007-08-09 21:36:59 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
FFilterListEditor := TFilterListCellEditor.Create(nil);
|
2020-05-14 20:44:46 +00:00
|
|
|
FFilterListEditor.Name := 'FilterListEditor';
|
|
|
|
FFilterListEditor.Visible := False;
|
|
|
|
FFilterListEditor.Items.Append('');
|
|
|
|
//FFilterListEditor.ReadOnly := True;
|
|
|
|
FFilterListEditor.AutoComplete := True;
|
|
|
|
FFilterListEditor.OnChange := @FFilterListEditorOnChange;
|
|
|
|
FFilterListEditor.OnCloseUp := @FFilterListEditorOnCloseUp;
|
2017-04-24 12:24:50 +00:00
|
|
|
|
|
|
|
FFilterColDlgButton:=TFilterColDlgButton.Create(nil);
|
|
|
|
FFilterColDlgButton.Name := 'FilterColDlgButton';
|
|
|
|
FFilterColDlgButton.Visible := False;
|
|
|
|
FFilterColDlgButton.OnClick := @FFilterColDlgButtonOnClick;
|
|
|
|
FFilterColDlgButton.Glyph.Assign(FEllipsisRxBMP);
|
|
|
|
|
2017-12-05 12:00:42 +00:00
|
|
|
|
|
|
|
FFilterSimpleEdit:=TFilterSimpleEdit.Create(nil);
|
|
|
|
FFilterSimpleEdit.Name := 'FFilterSimpleEdit';
|
|
|
|
FFilterSimpleEdit.Visible := False;
|
|
|
|
FFilterSimpleEdit.OnChange := @FFilterSimpleEditOnChange;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FColumnResizing := False;
|
2007-11-06 11:15:05 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FRxDbGridLookupComboEditor := TRxDBGridLookupComboEditor.Create(nil);
|
|
|
|
FRxDbGridLookupComboEditor.Name := 'RxDBGridLookupComboEditor';
|
|
|
|
FRxDbGridLookupComboEditor.Visible := False;
|
|
|
|
|
|
|
|
FRxDbGridDateEditor := TRxDBGridDateEditor.Create(nil);
|
|
|
|
FRxDbGridDateEditor.Name := 'RxDbGridDateEditor';
|
|
|
|
FRxDbGridDateEditor.Visible := False;
|
2010-05-19 15:33:28 +00:00
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
FSelectedFont:=TFont.Create;
|
|
|
|
FSelectedFont.OnChange:=@SelectedFontChanged;
|
|
|
|
FillDefaultFonts;
|
2010-05-19 15:33:28 +00:00
|
|
|
UpdateJMenuKeys;
|
2013-02-12 11:44:08 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxDBGrid.Destroy;
|
|
|
|
begin
|
2011-12-23 19:13:50 +00:00
|
|
|
CleanDSEvent;
|
2018-01-30 08:00:10 +00:00
|
|
|
FreeAndNil(FSelectedFont);
|
2018-01-29 06:23:01 +00:00
|
|
|
FreeAndNil(FFilterSimpleEdit);
|
2012-02-23 04:46:16 +00:00
|
|
|
FreeAndNil(FFooterOptions);
|
2007-11-06 11:15:05 +00:00
|
|
|
FreeAndNil(FRxDbGridLookupComboEditor);
|
2008-01-31 13:23:03 +00:00
|
|
|
FreeAndNil(FRxDbGridDateEditor);
|
2007-08-09 21:36:59 +00:00
|
|
|
FreeAndNil(FPropertyStorageLink);
|
2007-08-10 22:15:51 +00:00
|
|
|
FreeAndNil(FFilterListEditor);
|
2017-04-24 12:24:50 +00:00
|
|
|
FreeAndNil(FFilterColDlgButton);
|
2009-08-06 16:59:07 +00:00
|
|
|
FreeAndNil(F_PopupMenu);
|
|
|
|
FreeAndNil(F_MenuBMP);
|
|
|
|
FreeAndNil(F_LastFilter);
|
2010-05-19 15:33:28 +00:00
|
|
|
FreeAndNil(FKeyStrokes);
|
2015-05-25 10:12:12 +00:00
|
|
|
FreeAndNil(FToolsList);
|
2015-09-07 07:42:04 +00:00
|
|
|
FreeAndNil(FColumnDefValues);
|
2016-11-08 08:10:02 +00:00
|
|
|
FreeAndNil(FSearchOptions);
|
2017-05-26 13:05:56 +00:00
|
|
|
FreeAndNil(FGroupItems);
|
2016-11-08 08:10:02 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited Destroy;
|
2012-09-21 17:06:21 +00:00
|
|
|
FreeAndNil(FSortColumns);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.LayoutChanged;
|
|
|
|
begin
|
2012-09-19 20:14:13 +00:00
|
|
|
if csDestroying in ComponentState then
|
|
|
|
exit;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
inherited LayoutChanged;
|
2013-03-29 18:17:29 +00:00
|
|
|
if DatalinkActive and (FInProcessCalc = 0) and (Datalink.DataSet.State = dsBrowse) then
|
|
|
|
CalcStatTotals;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure TRxDBGrid.SetFocus;
|
|
|
|
begin
|
|
|
|
inherited SetFocus;
|
|
|
|
if FFilterListEditor.Visible then
|
|
|
|
FFilterListEditor.Hide;
|
2017-04-24 12:24:50 +00:00
|
|
|
|
|
|
|
if FFilterColDlgButton.Visible then
|
|
|
|
FFilterColDlgButton.Hide;
|
2013-03-28 15:40:03 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxDBGrid.ShowFindDialog;
|
|
|
|
begin
|
|
|
|
ShowRxDBGridFindForm(Self);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGrid.ShowColumnsDialog;
|
|
|
|
begin
|
|
|
|
ShowRxDBGridColumsForm(Self);
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure TRxDBGrid.ShowSortDialog;
|
|
|
|
begin
|
|
|
|
OnSortBy(nil);
|
|
|
|
end;
|
|
|
|
|
2013-03-28 15:40:03 +00:00
|
|
|
procedure TRxDBGrid.ShowFilterDialog;
|
|
|
|
begin
|
|
|
|
OnFilterBy(nil);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
function TRxDBGrid.ColumnByFieldName(AFieldName: string): TRxColumn;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := nil;
|
|
|
|
AFieldName := UpperCase(AFieldName);
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if UpperCase(Columns[i].FieldName) = AFieldName then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := Columns[i] as TRxColumn;
|
2007-08-10 22:15:51 +00:00
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2009-11-12 21:22:17 +00:00
|
|
|
function TRxDBGrid.ColumnByCaption(ACaption: string): TRxColumn;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2009-11-12 21:22:17 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := nil;
|
|
|
|
ACaption := UpperCase(ACaption);
|
|
|
|
for i := 0 to Columns.Count - 1 do
|
2009-12-03 17:41:24 +00:00
|
|
|
if ACaption = UpperCase(Columns[i].Title.Caption) then
|
2009-11-12 21:22:17 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := TRxColumn(Columns[i]);
|
2009-11-12 21:22:17 +00:00
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2012-11-02 00:53:24 +00:00
|
|
|
procedure TRxDBGrid.EraseBackground(DC: HDC);
|
|
|
|
begin
|
|
|
|
// The correct implementation is doing nothing
|
|
|
|
end;
|
|
|
|
|
2015-05-25 10:12:12 +00:00
|
|
|
function TRxDbGridColumns.GetColumn(Index: Integer): TRxColumn;
|
|
|
|
begin
|
|
|
|
Result:=TRxColumn( inherited Items[Index] );
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDbGridColumns.SetColumn(Index: Integer; AValue: TRxColumn);
|
|
|
|
begin
|
|
|
|
Items[Index].Assign( AValue );
|
|
|
|
end;
|
|
|
|
|
2012-09-21 17:06:21 +00:00
|
|
|
procedure TRxDbGridColumns.Notify(Item: TCollectionItem;
|
|
|
|
Action: TCollectionNotification);
|
|
|
|
begin
|
|
|
|
inherited Notify(Item, Action);
|
|
|
|
TRxDBGrid(Grid).CollumnSortListUpdate;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxDbGridColumns }
|
|
|
|
function TRxDbGridColumns.Add: TRxColumn;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := TRxColumn(inherited Add);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2017-04-24 12:44:17 +00:00
|
|
|
function TRxDbGridColumns.GetEnumerator: TRxDbGridColumnsEnumerator;
|
|
|
|
begin
|
|
|
|
Result:=TRxDbGridColumnsEnumerator.Create(Self);
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxColumn }
|
|
|
|
|
|
|
|
function TRxColumn.GetKeyList: TStrings;
|
|
|
|
begin
|
|
|
|
Result := FKeyList;
|
|
|
|
end;
|
|
|
|
|
2014-02-08 11:02:58 +00:00
|
|
|
function TRxColumn.GetSortFields: string;
|
|
|
|
begin
|
|
|
|
if FSortFields = '' then
|
|
|
|
Result:=FieldName
|
|
|
|
else
|
|
|
|
Result:=FSortFields;
|
|
|
|
end;
|
|
|
|
|
2014-01-15 12:04:11 +00:00
|
|
|
procedure TRxColumn.SetConstraints(AValue: TRxDBGridCollumnConstraints);
|
|
|
|
begin
|
|
|
|
FConstraints.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2012-08-23 17:03:53 +00:00
|
|
|
procedure TRxColumn.SetEditButtons(AValue: TRxColumnEditButtons);
|
|
|
|
begin
|
|
|
|
FEditButtons.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxColumn.SetFilter(const AValue: TRxColumnFilter);
|
|
|
|
begin
|
|
|
|
FFilter.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
function TRxColumn.GetFooter: TRxColumnFooterItem;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := FFooter;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
function TRxColumn.GetFooters: TRxColumnFooterItems;
|
|
|
|
begin
|
|
|
|
Result:=FFooters;
|
|
|
|
end;
|
|
|
|
|
2014-01-15 12:04:11 +00:00
|
|
|
function TRxColumn.GetConstraints: TRxDBGridCollumnConstraints;
|
|
|
|
begin
|
|
|
|
Result:=FConstraints;
|
|
|
|
end;
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
procedure TRxColumn.SetFooter(const AValue: TRxColumnFooterItem);
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
FFooter.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2015-07-28 10:15:04 +00:00
|
|
|
procedure TRxColumn.SetFooters(AValue: TRxColumnFooterItems);
|
|
|
|
begin
|
|
|
|
FFooters.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
procedure TRxColumn.SetImageList(const AValue: TImageList);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FImageList = AValue then
|
|
|
|
exit;
|
|
|
|
FImageList := AValue;
|
2007-08-09 21:36:59 +00:00
|
|
|
if Grid <> nil then
|
|
|
|
Grid.Invalidate;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumn.SetKeyList(const AValue: TStrings);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if AValue = nil then
|
2018-12-05 10:28:46 +00:00
|
|
|
FKeyList.Clear
|
2007-08-09 21:36:59 +00:00
|
|
|
else
|
|
|
|
KeyList.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxColumn.SetNotInKeyListIndex(const AValue: integer);
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FNotInKeyListIndex = AValue then
|
|
|
|
exit;
|
|
|
|
FNotInKeyListIndex := AValue;
|
2007-08-09 21:36:59 +00:00
|
|
|
if Grid <> nil then
|
|
|
|
Grid.Invalidate;
|
|
|
|
end;
|
|
|
|
|
2012-10-17 13:17:40 +00:00
|
|
|
procedure TRxColumn.SetWordWrap(AValue: boolean);
|
|
|
|
begin
|
|
|
|
if FWordWrap=AValue then Exit;
|
|
|
|
FWordWrap:=AValue;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
function TRxColumn.CreateTitle: TGridColumnTitle;
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := TRxColumnTitle.Create(Self);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2014-01-15 12:04:11 +00:00
|
|
|
procedure TRxColumn.ColumnChanged;
|
|
|
|
begin
|
|
|
|
inherited ColumnChanged;
|
|
|
|
if Assigned(FConstraints) and (FConstraints.MinWidth <> 0) and (FConstraints.MinWidth > Width) then
|
|
|
|
Width:=FConstraints.MinWidth;
|
2014-01-15 12:18:24 +00:00
|
|
|
|
|
|
|
if Assigned(FConstraints) and (FConstraints.MaxWidth <> 0) and (FConstraints.MaxWidth < Width) then
|
|
|
|
Width:=FConstraints.MaxWidth;
|
2014-01-15 12:04:11 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
constructor TRxColumn.Create(ACollection: TCollection);
|
|
|
|
begin
|
|
|
|
inherited Create(ACollection);
|
2018-12-05 10:28:46 +00:00
|
|
|
FKeyList := TStringList.Create;
|
2011-05-07 14:48:11 +00:00
|
|
|
FNotInKeyListIndex := -1;
|
2014-01-15 12:04:11 +00:00
|
|
|
FConstraints:=TRxDBGridCollumnConstraints.Create(Self);
|
2015-07-28 10:15:04 +00:00
|
|
|
FFooter := TRxColumnFooterItem.Create(nil);
|
|
|
|
FFooter.FOwner:=Self;
|
|
|
|
FFooter.FillDefaultFont;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
FFilter := TRxColumnFilter.Create(Self);
|
2011-09-22 17:07:49 +00:00
|
|
|
FDirectInput := true;
|
2012-08-23 17:03:53 +00:00
|
|
|
FEditButtons:=TRxColumnEditButtons.Create(Self);
|
2014-07-28 10:24:14 +00:00
|
|
|
FOptions:=[coCustomizeVisible, coCustomizeWidth];
|
2015-07-28 10:15:04 +00:00
|
|
|
FFooters:=TRxColumnFooterItems.Create(Self);
|
2017-05-26 13:05:56 +00:00
|
|
|
FGroupParam:=TRxColumnGroupParam.Create(Self);
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
destructor TRxColumn.Destroy;
|
2007-08-09 21:36:59 +00:00
|
|
|
begin
|
2017-05-26 13:05:56 +00:00
|
|
|
FreeAndNil(FGroupParam);
|
2015-07-28 10:15:04 +00:00
|
|
|
FreeAndNil(FFooters);
|
2012-08-23 17:03:53 +00:00
|
|
|
FreeAndNil(FEditButtons);
|
2018-12-05 10:28:46 +00:00
|
|
|
FreeAndNil(FKeyList);
|
2007-08-10 22:15:51 +00:00
|
|
|
FreeAndNil(FFooter);
|
|
|
|
FreeAndNil(FFilter);
|
2014-01-15 12:04:11 +00:00
|
|
|
FreeAndNil(FConstraints);
|
2011-05-07 14:48:11 +00:00
|
|
|
inherited Destroy;
|
2007-08-09 21:36:59 +00:00
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxColumn.OptimizeWidth;
|
|
|
|
begin
|
|
|
|
if Grid <> nil then
|
|
|
|
TRxDBGrid(Grid).OptimizeColumnsWidth(FieldName);
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
{ TRxColumnTitle }
|
|
|
|
procedure TRxColumnTitle.SetOrientation(const AValue: TTextOrientation);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FOrientation = AValue then
|
|
|
|
exit;
|
|
|
|
FOrientation := AValue;
|
2007-08-09 21:36:59 +00:00
|
|
|
TRxDBGrid(TRxColumn(Column).Grid).CalcTitle;
|
|
|
|
TRxColumn(Column).ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
2009-06-29 16:01:00 +00:00
|
|
|
function TRxColumnTitle.GetCaptionLinesCount: integer;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
if Assigned(FCaptionLines) then
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := FCaptionLines.Count
|
2009-06-29 16:01:00 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := 0;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function TRxColumnTitle.CaptionLine(ALine: integer): TMLCaptionItem;
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if Assigned(FCaptionLines) and (FCaptionLines.Count > 0) and
|
|
|
|
(ALine >= 0) and (FCaptionLines.Count > ALine) then
|
|
|
|
Result := TMLCaptionItem(FCaptionLines[ALine])
|
2007-08-10 22:15:51 +00:00
|
|
|
else
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := nil;
|
2009-06-29 16:01:00 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnTitle.ClearCaptionML;
|
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
|
|
|
R: TMLCaptionItem;
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
for i := 0 to FCaptionLines.Count - 1 do
|
2009-06-29 16:01:00 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
R := TMLCaptionItem(FCaptionLines[i]);
|
2009-06-29 16:01:00 +00:00
|
|
|
R.Free;
|
|
|
|
end;
|
|
|
|
FCaptionLines.Clear;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2008-01-28 05:21:43 +00:00
|
|
|
procedure TRxColumnTitle.SetCaption(const AValue: TCaption);
|
2007-08-10 22:15:51 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
c: integer;
|
|
|
|
s: string;
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure AddMLStr(AStr: string);
|
|
|
|
var
|
|
|
|
R: TMLCaptionItem;
|
|
|
|
begin
|
|
|
|
R := TMLCaptionItem.Create;
|
|
|
|
R.Caption := AStr;
|
|
|
|
R.Col := Column;
|
|
|
|
FCaptionLines.Add(R);
|
|
|
|
end;
|
2009-06-29 16:01:00 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
inherited SetCaption(AValue);
|
2009-06-29 16:01:00 +00:00
|
|
|
ClearCaptionML;
|
2011-05-07 14:48:11 +00:00
|
|
|
c := Pos('|', AValue);
|
|
|
|
if C > 0 then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
S := AValue;
|
|
|
|
while C > 0 do
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
AddMLStr(Copy(S, 1, C - 1));
|
2007-08-10 22:15:51 +00:00
|
|
|
System.Delete(S, 1, C);
|
2011-05-07 14:48:11 +00:00
|
|
|
c := Pos('|', S);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2011-05-07 14:48:11 +00:00
|
|
|
if S <> '' then
|
2009-06-29 16:01:00 +00:00
|
|
|
AddMLStr(S);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
2009-06-22 17:58:57 +00:00
|
|
|
if not (csLoading in Column.Grid.ComponentState) and Column.Grid.HandleAllocated then
|
2007-08-10 22:15:51 +00:00
|
|
|
TRxDBGrid(Column.Grid).CalcTitle;
|
|
|
|
end;
|
|
|
|
|
|
|
|
constructor TRxColumnTitle.Create(TheColumn: TGridColumn);
|
|
|
|
begin
|
|
|
|
inherited Create(TheColumn);
|
|
|
|
{$IFDEF NEW_STYLE_TITLE_ALIGNMENT_RXDBGRID}
|
2011-05-07 14:48:11 +00:00
|
|
|
Alignment := taCenter;
|
2007-08-10 22:15:51 +00:00
|
|
|
{$ENDIF}
|
2011-05-07 14:48:11 +00:00
|
|
|
FCaptionLines := TFPList.Create;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxColumnTitle.Destroy;
|
|
|
|
begin
|
2009-06-29 16:01:00 +00:00
|
|
|
ClearCaptionML;
|
|
|
|
FreeAndNil(FCaptionLines);
|
2007-08-10 22:15:51 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
|
|
|
{ TFilterListCellEditor }
|
|
|
|
|
|
|
|
procedure TFilterListCellEditor.WndProc(var TheMessage: TLMessage);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if TheMessage.msg = LM_KILLFOCUS then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
Change;
|
|
|
|
Hide;
|
2011-05-07 14:48:11 +00:00
|
|
|
if HWND(TheMessage.WParam) = HWND(Handle) then
|
|
|
|
begin
|
2007-08-10 22:15:51 +00:00
|
|
|
// lost the focus but it returns to ourselves
|
|
|
|
// eat the message.
|
|
|
|
TheMessage.Result := 0;
|
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
inherited WndProc(TheMessage);
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TFilterListCellEditor.KeyDown(var Key: word; Shift: TShiftState);
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
inherited KeyDown(Key, Shift);
|
2007-08-10 22:15:51 +00:00
|
|
|
case Key of
|
|
|
|
VK_RETURN:
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
DroppedDown := False;
|
|
|
|
Change;
|
|
|
|
Hide;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TFilterListCellEditor.Show(Grid: TCustomGrid; Col: integer);
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2008-01-31 13:23:03 +00:00
|
|
|
FGrid := Grid;
|
|
|
|
FCol := Col;
|
2011-05-07 14:48:11 +00:00
|
|
|
Visible := True;
|
2008-01-31 13:23:03 +00:00
|
|
|
SetFocus;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
{ TRxColumnFilter }
|
|
|
|
|
|
|
|
function TRxColumnFilter.GetItemIndex: integer;
|
|
|
|
begin
|
2017-04-24 12:24:50 +00:00
|
|
|
if CurrentValues.Count > 0 then
|
|
|
|
Result := FValueList.IndexOf(CurrentValues[0])
|
|
|
|
else
|
|
|
|
Result := -1;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
function TRxColumnFilter.IsEmptyFontStored: Boolean;
|
|
|
|
begin
|
|
|
|
Result:=FIsEmptyFontStored;
|
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxColumnFilter.IsFontStored: Boolean;
|
|
|
|
begin
|
|
|
|
Result:=FIsFontStored;
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFilter.FontChanged(Sender: TObject);
|
|
|
|
begin
|
|
|
|
if Sender = FFont then
|
|
|
|
FIsFontStored:=not FFont.IsDefault
|
|
|
|
else
|
|
|
|
FIsEmptyFontStored:=not FEmptyFont.IsDefault;
|
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
2017-12-18 08:35:51 +00:00
|
|
|
function TRxColumnFilter.GetDisplayFilterValue: string;
|
|
|
|
begin
|
|
|
|
Result:='';
|
|
|
|
if CurrentValues.Count > 0 then
|
|
|
|
begin
|
|
|
|
Result:=CurrentValues[0];
|
|
|
|
if CurrentValues.Count > 1 then
|
|
|
|
Result:=Result + '(...)';
|
|
|
|
end
|
|
|
|
else
|
|
|
|
if (Style in [rxfstManualEdit, rxfstBoth]) and (ManulEditValue<>'') then
|
|
|
|
Result:=ManulEditValue
|
|
|
|
else
|
|
|
|
if State = rxfsEmpty then
|
|
|
|
Result:=EmptyValue
|
|
|
|
else
|
|
|
|
if State = rxfsNonEmpty then
|
|
|
|
Result:=NotEmptyValue
|
|
|
|
else
|
|
|
|
if State = rxfsAll then
|
|
|
|
Result:=AllValue;
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxColumnFilter.SetColor(const AValue: TColor);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FColor = AValue then
|
|
|
|
exit;
|
|
|
|
FColor := AValue;
|
2007-08-10 22:15:51 +00:00
|
|
|
FOwner.ColumnChanged;
|
|
|
|
end;
|
|
|
|
|
2018-01-30 08:00:10 +00:00
|
|
|
procedure TRxColumnFilter.SetEmptyFont(AValue: TFont);
|
|
|
|
begin
|
|
|
|
if not FEmptyFont.IsEqual(AValue) then
|
|
|
|
FEmptyFont.Assign(AValue);
|
|
|
|
end;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
procedure TRxColumnFilter.SetFont(const AValue: TFont);
|
|
|
|
begin
|
2018-01-30 08:00:10 +00:00
|
|
|
if not FFont.IsEqual(AValue) then
|
|
|
|
FFont.Assign(AValue);
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxColumnFilter.SetItemIndex(const AValue: integer);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if (AValue >= -1) and (AValue < FValueList.Count) then
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
2017-04-24 12:24:50 +00:00
|
|
|
CurrentValues.Clear;
|
|
|
|
if AValue > -1 then
|
|
|
|
CurrentValues.Add(FValueList[AValue]);
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
FOwner.ColumnChanged;
|
2011-05-07 14:48:11 +00:00
|
|
|
end;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
constructor TRxColumnFilter.Create(Owner: TRxColumn);
|
2007-08-10 22:15:51 +00:00
|
|
|
begin
|
|
|
|
inherited Create;
|
2011-05-07 14:48:11 +00:00
|
|
|
FOwner := Owner;
|
2018-01-30 08:00:10 +00:00
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
FFont := TFont.Create;
|
2018-01-30 08:00:10 +00:00
|
|
|
FFont.OnChange:=@FontChanged;
|
2007-08-10 22:15:51 +00:00
|
|
|
FEmptyFont := TFont.Create;
|
2018-01-30 08:00:10 +00:00
|
|
|
FEmptyFont.OnChange:=@FontChanged;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
FValueList := TStringList.Create;
|
2011-05-07 14:48:11 +00:00
|
|
|
FValueList.Sorted := True;
|
2017-04-24 12:24:50 +00:00
|
|
|
FCurrentValues:=TStringList.Create;
|
|
|
|
FCurrentValues.Sorted:=true;
|
|
|
|
|
2007-08-10 22:15:51 +00:00
|
|
|
FColor := clWhite;
|
2017-04-24 12:24:50 +00:00
|
|
|
State:=rxfsAll;
|
|
|
|
Style:=rxfstSimple;
|
2009-08-06 16:59:07 +00:00
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
FEmptyFont.Style := [fsItalic];
|
2017-12-06 07:17:42 +00:00
|
|
|
FEmptyValue := sRxDBGridEmptyFilter;
|
2016-09-08 08:51:40 +00:00
|
|
|
FAllValue := sRxDBGridAllFilter;
|
2017-12-06 07:17:42 +00:00
|
|
|
FNotEmptyValue:=sRxDBGridNotEmptyFilter;
|
2013-05-08 05:26:49 +00:00
|
|
|
FEnabled:=true;
|
2007-08-10 22:15:51 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
destructor TRxColumnFilter.Destroy;
|
|
|
|
begin
|
|
|
|
FreeAndNil(FFont);
|
|
|
|
FreeAndNil(FEmptyFont);
|
|
|
|
FreeAndNil(FValueList);
|
2017-04-24 12:24:50 +00:00
|
|
|
FreeAndNil(FCurrentValues);
|
2007-08-10 22:15:51 +00:00
|
|
|
inherited Destroy;
|
|
|
|
end;
|
|
|
|
|
2017-12-18 08:35:51 +00:00
|
|
|
procedure TRxColumnFilter.ClearFilter;
|
|
|
|
begin
|
|
|
|
CurrentValues.Clear;
|
|
|
|
FManulEditValue:='';
|
|
|
|
FState:=rxfsEmpty;
|
|
|
|
end;
|
|
|
|
|
2009-08-06 16:59:07 +00:00
|
|
|
{ TExDBGridSortEngine }
|
|
|
|
|
2009-12-10 22:02:14 +00:00
|
|
|
procedure TRxDBGridSortEngine.SortList(ListField: string; ADataSet: TDataSet;
|
2012-09-21 17:06:21 +00:00
|
|
|
Asc: array of boolean; SortOptions: TRxSortEngineOptions);
|
2009-08-06 16:59:07 +00:00
|
|
|
begin
|
|
|
|
|
|
|
|
end;
|
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
{ TRxDBGridKeyStroke }
|
|
|
|
|
|
|
|
procedure TRxDBGridKeyStroke.SetCommand(const AValue: TRxDBGridCommand);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FCommand = AValue then
|
|
|
|
exit;
|
|
|
|
FCommand := AValue;
|
2013-02-12 12:00:56 +00:00
|
|
|
Changed(False);
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridKeyStroke.SetShortCut(const AValue: TShortCut);
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
if FShortCut = AValue then
|
|
|
|
exit;
|
|
|
|
FShortCut := AValue;
|
2010-05-19 15:33:28 +00:00
|
|
|
Menus.ShortCutToKey(FShortCut, FKey, FShift);
|
2013-02-12 12:00:56 +00:00
|
|
|
Changed(False);
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGridKeyStroke.GetDisplayName: string;
|
|
|
|
begin
|
|
|
|
IntToIdent(Ord(FCommand), Result, EditorCommandStrs);
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := Result + ' - ' + ShortCutToText(FShortCut);
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
2013-02-12 11:44:08 +00:00
|
|
|
procedure TRxDBGridKeyStroke.Assign(Source: TPersistent);
|
|
|
|
begin
|
|
|
|
if Source is TRxDBGridKeyStroke then
|
|
|
|
begin
|
|
|
|
Command := TRxDBGridKeyStroke(Source).Command;
|
|
|
|
ShortCut := TRxDBGridKeyStroke(Source).ShortCut;
|
|
|
|
Enabled := TRxDBGridKeyStroke(Source).Enabled;
|
|
|
|
end
|
|
|
|
else
|
|
|
|
inherited Assign(Source);
|
|
|
|
end;
|
|
|
|
|
2010-05-19 15:33:28 +00:00
|
|
|
{ TRxDBGridKeyStrokes }
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function TRxDBGridKeyStrokes.GetItem(Index: integer): TRxDBGridKeyStroke;
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
|
|
|
Result := TRxDBGridKeyStroke(inherited GetItem(Index));
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
procedure TRxDBGridKeyStrokes.SetItem(Index: integer; const AValue: TRxDBGridKeyStroke);
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
|
|
|
inherited SetItem(Index, AValue);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridKeyStrokes.Update(Item: TCollectionItem);
|
|
|
|
begin
|
|
|
|
inherited Update(Item);
|
2014-01-15 11:35:25 +00:00
|
|
|
if (UpdateCount = 0) and Assigned(Owner) and Assigned(TRxDBGrid(Owner).FKeyStrokes) then
|
2010-05-19 15:33:28 +00:00
|
|
|
TRxDBGrid(Owner).UpdateJMenuKeys;
|
|
|
|
end;
|
|
|
|
|
|
|
|
|
|
|
|
constructor TRxDBGridKeyStrokes.Create(AOwner: TPersistent);
|
|
|
|
begin
|
2013-02-12 11:44:08 +00:00
|
|
|
inherited Create(AOwner, TRxDBGridKeyStroke);
|
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridKeyStrokes.Assign(Source: TPersistent);
|
|
|
|
var
|
|
|
|
i: integer;
|
|
|
|
begin
|
|
|
|
if Source is TRxDBGridKeyStrokes then
|
|
|
|
begin
|
|
|
|
Clear;
|
|
|
|
for i := 0 to TRxDBGridKeyStrokes(Source).Count-1 do
|
|
|
|
begin
|
|
|
|
with Add do
|
|
|
|
Assign(TRxDBGridKeyStrokes(Source)[i]);
|
|
|
|
end;
|
2015-07-28 10:15:04 +00:00
|
|
|
end
|
|
|
|
else
|
2013-02-12 11:44:08 +00:00
|
|
|
inherited Assign(Source);
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
function TRxDBGridKeyStrokes.Add: TRxDBGridKeyStroke;
|
|
|
|
begin
|
|
|
|
Result := TRxDBGridKeyStroke(inherited Add);
|
2011-05-07 14:48:11 +00:00
|
|
|
Result.Enabled := True;
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function TRxDBGridKeyStrokes.AddE(ACommand: TRxDBGridCommand;
|
|
|
|
AShortCut: TShortCut): TRxDBGridKeyStroke;
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := nil;
|
|
|
|
Result := Add;
|
|
|
|
Result.FShortCut := AShortCut;
|
|
|
|
Result.FCommand := ACommand;
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
|
|
|
procedure TRxDBGridKeyStrokes.ResetDefaults;
|
|
|
|
begin
|
|
|
|
Clear;
|
|
|
|
AddE(rxgcShowFindDlg, Menus.ShortCut(Ord('F'), [ssCtrl]));
|
|
|
|
AddE(rxgcShowColumnsDlg, Menus.ShortCut(Ord('W'), [ssCtrl]));
|
|
|
|
AddE(rxgcShowFilterDlg, Menus.ShortCut(Ord('T'), [ssCtrl]));
|
|
|
|
AddE(rxgcShowSortDlg, Menus.ShortCut(Ord('S'), [ssCtrl]));
|
|
|
|
AddE(rxgcShowQuickFilter, Menus.ShortCut(Ord('Q'), [ssCtrl]));
|
|
|
|
AddE(rxgcHideQuickFilter, Menus.ShortCut(Ord('H'), [ssCtrl]));
|
2012-09-24 14:21:22 +00:00
|
|
|
AddE(rxgcSelectAll, Menus.ShortCut(Ord('A'), [ssCtrl]));
|
|
|
|
AddE(rxgcDeSelectAll, Menus.ShortCut(Ord('-'), [ssCtrl]));
|
|
|
|
AddE(rxgcInvertSelection, Menus.ShortCut(Ord('*'), [ssCtrl]));
|
|
|
|
AddE(rxgcOptimizeColumnsWidth, Menus.ShortCut(Ord('+'), [ssCtrl]));
|
2014-01-15 11:35:25 +00:00
|
|
|
AddE(rxgcCopyCellValue, Menus.ShortCut(Ord('C'), [ssCtrl]));
|
2010-05-19 15:33:28 +00:00
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function TRxDBGridKeyStrokes.FindRxCommand(AKey: word;
|
|
|
|
AShift: TShiftState): TRxDBGridCommand;
|
2010-05-19 15:33:28 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
|
|
|
K: TRxDBGridKeyStroke;
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := rxgcNone;
|
|
|
|
for i := 0 to Count - 1 do
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
K := Items[i];
|
2010-05-19 15:33:28 +00:00
|
|
|
if (K.FKey = AKey) and (K.FShift = AShift) and (K.FEnabled) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := K.FCommand;
|
2010-05-19 15:33:28 +00:00
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
function TRxDBGridKeyStrokes.FindRxKeyStrokes(ACommand: TRxDBGridCommand):
|
|
|
|
TRxDBGridKeyStroke;
|
2010-05-19 15:33:28 +00:00
|
|
|
var
|
2011-05-07 14:48:11 +00:00
|
|
|
i: integer;
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := nil;
|
|
|
|
for i := 0 to Count - 1 do
|
2010-05-19 15:33:28 +00:00
|
|
|
begin
|
|
|
|
if (Items[i].Command = ACommand) then
|
|
|
|
begin
|
2011-05-07 14:48:11 +00:00
|
|
|
Result := Items[i];
|
2010-05-19 15:33:28 +00:00
|
|
|
exit;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
end;
|
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
initialization
|
2013-11-09 16:56:32 +00:00
|
|
|
RegisterPropertyToSkip( TRxDBGrid, 'AllowedOperations', 'This property duplicated standart DBGrid.Options', '');
|
2017-04-24 12:24:50 +00:00
|
|
|
RegisterPropertyToSkip( TRxColumnFilter, 'IsNull', 'depricated property', '');
|
|
|
|
RegisterPropertyToSkip( TRxColumnFilter, 'IsAll', 'depricated property', '');
|
|
|
|
RegisterPropertyToSkip( TRxColumnFilter, 'Value', 'depricated property', '');
|
|
|
|
|
2011-05-07 14:48:11 +00:00
|
|
|
RxDBGridSortEngineList := TStringList.Create;
|
|
|
|
RxDBGridSortEngineList.Sorted := True;
|
2007-10-17 10:19:26 +00:00
|
|
|
|
2018-12-13 11:42:18 +00:00
|
|
|
FMarkerUp := TBitmap.Create;
|
|
|
|
FMarkerDown := TBitmap.Create;
|
|
|
|
FEllipsisRxBMP:=TBitmap.Create;
|
|
|
|
FGlyphRxBMP:=TBitmap.Create;
|
|
|
|
FUpDownRxBMP:=TBitmap.Create;
|
|
|
|
FPlusRxBMP:=TBitmap.Create;
|
|
|
|
FMinusRxBMP:=TBitmap.Create;
|
|
|
|
|
|
|
|
RxAssignBitmap(FMarkerUp, 'rx_markerup');
|
|
|
|
RxAssignBitmap(FMarkerDown, 'rx_markerdown');
|
|
|
|
RxAssignBitmap(FEllipsisRxBMP, 'rx_Ellipsis');
|
|
|
|
RxAssignBitmap(FGlyphRxBMP, 'rx_Glyph');
|
|
|
|
RxAssignBitmap(FUpDownRxBMP, 'rx_UpDown');
|
|
|
|
RxAssignBitmap(FPlusRxBMP, 'rx_plus');
|
|
|
|
RxAssignBitmap(FMinusRxBMP, 'rx_minus');
|
2016-05-11 12:44:15 +00:00
|
|
|
|
2007-08-09 21:36:59 +00:00
|
|
|
finalization
|
2011-05-07 14:48:11 +00:00
|
|
|
|
|
|
|
while (RxDBGridSortEngineList.Count > 0) do
|
2007-08-28 21:55:23 +00:00
|
|
|
begin
|
2009-12-10 22:02:14 +00:00
|
|
|
RxDBGridSortEngineList.Objects[0].Free;
|
|
|
|
RxDBGridSortEngineList.Delete(0);
|
2007-08-11 21:11:20 +00:00
|
|
|
end;
|
2009-12-10 22:02:14 +00:00
|
|
|
RxDBGridSortEngineList.Free;
|
2011-05-07 14:48:11 +00:00
|
|
|
|
2016-05-11 12:44:15 +00:00
|
|
|
FreeAndNil(FMarkerUp);
|
|
|
|
FreeAndNil(FMarkerDown);
|
|
|
|
FreeAndNil(FEllipsisRxBMP);
|
|
|
|
FreeAndNil(FGlyphRxBMP);
|
|
|
|
FreeAndNil(FUpDownRxBMP);
|
|
|
|
FreeAndNil(FPlusRxBMP);
|
|
|
|
FreeAndNil(FMinusRxBMP);
|
2007-08-09 21:36:59 +00:00
|
|
|
end.
|
|
|
|
|