const
{$IFDEF PAIDVERS}
SDLVersionInfo = 'ntabed_r1210_full';
IsLightEd = false;
{$ELSE}
SDLVersionInfo = 'ntabed_r1210_lighted';
IsLightEd = true;
{$ENDIF}
Release = 1210;
MAXPOPUPDCMDS = 13; { number of commands in data area popup menu }
MAXPOPUPMCMDS = 4; { number of commands in mark submenu }
MAXPOPUPUCMDS = 4; { number of commands in unmark submenu }
MAXPOPUPHCMDS = 5; { number of commands in header area popup menu }
popMenData = $1000000; { popup menu identifiers }
popMenHeader = $2000000;
popMenMark = $3000000;
popMenUnMark = $4000000;
pdMarkA = $0001; { mask values of popup commands in data area }
pdMarkB = $0002;
pdUnMarkA = $0004;
pdUnMarkB = $0008;
pdUnMarkAll = $0010;
pdClear = $0020;
pdCopy = $0040;
pdPaste = $0080;
pdExtClip = $0100;
pdEdit = $0200;
pdSelAll = $0400;
pdEmptyCells = $0800;
pdAllCmds = $7FFFFFFF;
phEditIdentifier = $0001;
phChangePrecision = $0002;
phSelectRowColumn = $0004;
phInsertRowColumn = $0008;
phDeleteRowColumn = $0010;
phAllCmds = $7FFFFFFF;
pmMarkRange = $0001; { mask values of popup submenu for mark commands }
pmMarkColumn = $0002;
pmMarkRow = $0004;
pmMarkAll = $0008;
pmAllCmds = $7FFFFFFF;
puMarkRange = $0001; { mask values of popup submenu for unmark commands }
puMarkColumn = $0002;
puMarkRow = $0004;
puMarkAll = $0008;
puAllCmds = $7FFFFFFF;
type
ESDLNTabedError = class(ESDLError); { exception type to indicate errors }
TBeforePopupEvent = procedure (Sender: TObject; PMenu: TPopupMenu) of object;
TBeforeRenderCellEvent = procedure (Sender: TObject; colix, rowix: integer;
var Text: string; var ColorText, ColorBakg: TColor;
var FontStyles: TFontStyles) of object;
{$IFDEF GE_LEV29}
[ComponentPlatformsAttribute(pidWin32 or pidWin64 or pidWin64x)]
{$ENDIF}
TNTabEd = class(TCustomGrid)
private
FAutoAdvance : boolean; { TRUE: go to next cell on CR }
FAutoAdvDir : TOrientation;
FOnChange : TNotifyEvent;
FOnBeforePopup : TBeforePopupEvent;
FOnHeadingChanged: TNotifyEvent;
FOnChangeAttrib : TNotifyEvent;
FOnChangeLayout : TNotifyEvent;
FOnChangeCellSt : TNotifyEvent;
FOnChangeEmptySt : TNotifyEvent;
FOnBeforeRenderCell : TBeforeRenderCellEvent;
FOnChangeSetup : TNotifyEvent;
FOnTopLeftChanged: TNotifyEvent;
FOnSelChanged : TNotifyEvent;
FOnPaste : TNotifyEvent;
FOnClear : TNotifyEvent;
FOnPercentDone : TOnPercentDoneEvent;
FOldSel : TGridRect; // used to detect selection changes
FClassColWidth : integer; { width of class info column }
FOptRowHeight : boolean; { TRUE: row height is adjusted
automatically for changed fonts }
FColOffset : integer; { =1 if row attrib. visible, else 0 }
FRowOffset : integer;{=1 if column attrib. visible, else 0 }
FEmptyMsg : string; {message displayed when no. of rows=0 }
FDecP : array of shortint; { nr. of dec. pl. shown }
FClipUseFullPrec : boolean; { TRUE: use full precision for
copying to ClipBoard }
FDataCopy : TDataTable;{ backup matrix for copy and paste }
FDataCopyAvail : boolean;{ TRUE if data in copy/paste container
is available }
FExtMatAssigned : boolean; { if TRUE: external matrix assigned }
FShowCellCursor : boolean;
FNumWidth : integer; { width of numeric field }
FOnGetEditText : TGetEditEvent;
FOnSetEditText : TSetEditEvent;
FSortIncludeHd : boolean; { flag to indicate sorting mode }
FSuppressPaint : boolean; { TRUE: suppress all paint calls }
FInternSuppPaint : boolean; { TRUE: suppress all paint calls }
FBlockIntPopup : boolean; { TRUE: block internal popup }
FCommEdAllowed : boolean; { TRUE: comment editing allowed }
FReadOnly : boolean; { TRUE: editor is in readonly mode }
FPopupD : TPopUpMenu; { popup menu for right mouse
click in data area }
FPopupDMask : longint; { mask for enabling popup commands }
FPopupH : TPopUpMenu; { popup menu for right mouse
click in header area }
FPopupHMask : longint; { mask for enabling popup commands }
FPopupMMask : longint; { mask for enabling popup commands }
FPopupUMask : longint; { mask for enabling popup commands }
FColorBkgnd : TColor; { background color of control }
FColorEmptyMsg : TColor; { color of empty message }
FColorFixed : TColor; { color of fixed columns/rows }
FColorNormal : TColor; { color of unmarked text }
FColorMarked1 : TColor; { color of marked text A }
FColorMarked2 : TColor; { color of marked text B }
FColorMarkedBoth : TColor; { color of marked text A&B }
FColorSelected : TColor; { color of header of selected row }
FColorRngSelFG : TColor; { color selected range, foreground }
FColorRngSelBG : TColor; { color selected range, foreground }
FBoldSelHeads : boolean; { TRUE: selected header is in bold }
FBoldMarks : boolean;{ TRUE: marked data displayed in bold }
FNameEdActive : boolean; { to indicate an act. NameEd comp. }
FNameEd : TEdit; { editor for identifiers }
FCommentMMActive : boolean; { indicates an act. CommentEd comp. }
FCommentMM : TMemo; { editor for comment }
FDropdownCount : integer;
FColPickList : TStringList;
FVRangeLow : double; { lower limit of valid numbers }
FVRangeHigh : double; { upper limit of valid numbers }
procedure ColumnsGetPickListItems (ACol, ARow: Integer;
Items: TStrings);
procedure SetDropdownCount(value:integer);
procedure CommentMemoKeyPress(Sender: TObject; var Key: Char);
procedure DisplayCellCursor (cx, cy: integer);
procedure ExchangeDuringSort (Sender: TObject; ExchgWhat: byte;
index1, index2, first, last: longint);
function GetColAttVis: boolean;
function GetRowAttVis: boolean;
function GetRowAttrib (RowNr: longint): byte;
function GetCellState (ACol, ARow: longint): byte;
function GetColAttrib (ColNr: longint): byte;
function GetColName (ColNr: longint): TDTNameStr;
function GetColWidths(Index: Longint): Integer;
function GetComment: string;
function GetDecPlaces (ColNr: longint): shortint;
function GetDefColWidth: integer;
function GetElem (ACol, ARow: longint): double;
function GetElemMarkedA (ACol, ARow: longint): boolean;
function GetElemMarkedB (ACol, ARow: longint): boolean;
function GetIsNumber (ACol, ARow: longint): boolean;
function GetIsEmpty (ACol, ARow: longint): boolean;
function GetLeftCol: integer;
function GetTopRow: integer;
function GetNrCols: longint;
function GetNrRows: longint;
function GetPopupDCaption (ix: integer): TDTNameStr;
function GetPopupMCaption (ix: integer): TDTNameStr;
function GetPopupUCaption (ix: integer): TDTNameStr;
function GetPopupHCaption (ix: integer): TDTNameStr;
function GetRowName (RowNr: longint): TDTNameStr;
procedure DataHasChanged (Sender: TObject);
procedure SetupHasChanged (Sender: TObject);
procedure NameEdKeyPress(Sender: TObject; var Key: Char);
procedure DataHasBeenResized (Sender: TObject; OldColumns, OldRows,
NewColumns, NewRows: longint);
procedure NTPercDone (Sender: TObject; Percent: integer);
procedure SetSuppressPaint (supp: boolean);
procedure SetBoldMarks (bold: boolean);
procedure SetBoldSelHeads (bold: boolean);
procedure SetRowAttrib (RowNr: longint; Attrib: byte);
procedure SetCellState (ACol, ARow: longint; const Value: byte);
procedure SetColAttrib (ColNr: longint; Attrib: byte);
procedure SetColAttVis (vis: boolean);
procedure SetRowAttVis (vis: boolean);
procedure SetOptRowHeight (opt: boolean);
procedure SetColName (ColNr: longint; HLine: TDTNameStr);
procedure SetColorBackground (color: TColor);
procedure SetColorEmptyMsg (color: TColor);
procedure SetColorFixed (color: TColor);
procedure SetColorMarkedA (color: TColor);
procedure SetColorMarkedB (color: TColor);
procedure SetColorMarkedBoth (color: TColor);
procedure SetColorNormal (color: TColor);
procedure SetColorSelected (color: TColor);
procedure SetFColorRngSelFG (color: TColor);
procedure SetFColorRngSelBG (color: TColor);
procedure SetColWidths(Index: Longint; Value: Integer);
procedure SetRowHeight (Index: Longint; Value: Integer);
procedure SetDecPlaces (ColNr: longint; Dp: shortint);
procedure SetDefColWidth (DefW: integer);
procedure SetDataReadOnly (Value: boolean);
procedure SetElem (ACol, ARow: longint; const Value: double);
procedure SetElemMarkedA (ACol, ARow: longint; const Value: boolean);
procedure SetElemMarkedB (ACol, ARow: longint; const Value: boolean);
procedure SetEmptyMsg (value: string);
procedure SetIsEmpty (ACol, ARow: longint; const Value: boolean);
procedure SetComment (cmt: string);
procedure SetLeftCol (ix: integer);
procedure SetTopRow (ix: integer);
procedure SetNrCols (NrCols: longint);
procedure SetNrRows (NrRows: longint);
procedure SetNumWidth (nw: integer);
procedure SetPopupDMask (mask: longint);
procedure SetPopupHMask (mask: longint);
procedure SetRowName (RowNr: longint; HLine: TDTNameStr);
procedure SetPopupDCaption (ix: integer; text: TDTNameStr);
procedure SetPopupMCaption (ix: integer; text: TDTNameStr);
procedure SetPopupUCaption (ix: integer; text: TDTNameStr);
procedure SetPopupHCaption (ix: integer; text: TDTNameStr);
procedure SetShowCellCursor (Value: boolean);
procedure PopupMenuDLoadPopup(Sender: TObject);
procedure FontHasChanged (Sender: TObject);
procedure WMGetDlgCode (var Message: TWMGetDlgCode);
message WM_GETDLGCODE;
protected
procedure Paint; override;
procedure Keypress (var Key: char); override;
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
function DoMouseWheelDown (Shift: TShiftState;
MousePos: TPoint): Boolean; override;
function DoMouseWheelUp (Shift: TShiftState;
MousePos: TPoint): Boolean; override;
procedure BeforeRenderCell (Sender: TObject; colix, rowix: integer;
var text: string; var ColorText, ColorBakg: TColor;
var FontStyles: TFontStyles);
function CreateEditor: TInplaceEdit; override;
function GetEditStyle(ACol, ARow: integer): TEditStyle; override;
{$IFDEF ISCLX}
function GetEditText (ACol, ARow: Longint): WideString; override;
procedure SetEditText (ACol, ARow: Longint;
const Value: WideString); override;
{$ELSE}
function GetEditText (ACol, ARow: Longint): string; override;
procedure SetEditText (ACol, ARow: Longint;
const Value: string); override;
{$ENDIF}
procedure DrawCell (ACol, ARow: Longint; ARect: TRect;
AState: TGridDrawState); override;
procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
procedure MouseDown (Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
procedure MouseUp (Button: TMouseButton;
Shift: TShiftState; X, Y: Integer); override;
procedure TopLeftChanged; override;
public
Data : TDataTable; { data matrix }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AssignAnotherDataMatrix (NewDTab: TDataTable);
function AutoColWidth (ColNr: longint; IncludeHeader: boolean;
Addon: integer): integer;
function AutoRowHeight (RowNr: longint; Addon: integer): integer;
procedure ChangedAttrib;
procedure ChangedCellStates;
procedure ChangedEmptyStates;
procedure ChangedData;
procedure ChangedHeading;
procedure ChangedLayout;
procedure ChangedSetup;
procedure ChangedSelection;
property EditorMode;
procedure Fill (value: double);
function FillMarkedCells (value: double; Statemask: byte): integer;
property Elem[ACol, ARow: longint]: double
read GetElem write SetElem; default;
property CellState[ACol, ARow: longint]: byte
read GetCellState write SetCellState;
property ElemMarkedA[ACol, ARow: longint]: boolean
read GetElemMarkedA write SetElemMarkedA;
property ElemMarkedB[ACol, ARow: longint]: boolean
read GetElemMarkedB write SetElemMarkedB;
procedure ExchangeMarkings;
function GetClipMatrixSize (var NCols, NRows: integer): boolean;
procedure Redimension (NrCols, NrRows: longint);
property RowAttrib [ix: longint]: byte
read GetRowAttrib write SetRowAttrib;
property ColAttrib [ix: longint]: byte
read GetColAttrib write SetColAttrib;
function IfColumnMarked (col: longint): boolean;
function IfRowMarked (row: longint): boolean;
function IfAnyMarked: boolean;
procedure InsertRow (ix: longint);
procedure InsertColumn (ix: longint);
procedure InvertCellStates (StateMask: byte);
property IsNumber[ACol, ARow: longint]: boolean read GetIsNumber;
property IsEmpty[ACol, ARow: longint]: boolean
read GetIsEmpty write SetIsEmpty;
procedure Clear;
property ColName[ix: longint]: TDTNameStr
read GetColName write SetColName;
property ColWidths[Index: Longint]: Integer
read GetColWidths write SetColWidths;
function CopyCellStatesFrom (ExtTab: TNTabEd): boolean;
procedure CopyContentsFrom (ExtTab: TNTabEd);
procedure PopupMenuClickClear (Sender: TObject);
procedure PopupMenuClickEmptyCells (Sender: TObject);
procedure PopupMenuClickResetEmptyStates (Sender: TObject);
procedure PopupMenuClickMarkARange (Sender: TObject);
procedure PopupMenuClickMarkARow (Sender: TObject);
procedure PopupMenuClickMarkAAll (Sender: TObject);
procedure PopupMenuClickMarkAColumn (Sender: TObject);
procedure PopupMenuClickMarkBRange (Sender: TObject);
procedure PopupMenuClickMarkBRow (Sender: TObject);
procedure PopupMenuClickMarkBAll (Sender: TObject);
procedure PopupMenuClickMarkBColumn (Sender: TObject);
procedure PopupMenuClickUnMarkARange (Sender: TObject);
procedure PopupMenuClickUnMarkARow (Sender: TObject);
procedure PopupMenuClickUnMarkAAll (Sender: TObject);
procedure PopupMenuClickUnMarkAColumn (Sender: TObject);
procedure PopupMenuClickUnMarkBRange (Sender: TObject);
procedure PopupMenuClickUnMarkBRow (Sender: TObject);
procedure PopupMenuClickUnMarkBAll (Sender: TObject);
procedure PopupMenuClickUnMarkBColumn (Sender: TObject);
procedure PopupMenuClickUnMarkAll (Sender: TObject);
procedure PopupMenuClickCopy (Sender: TObject);
procedure PopupMenuClickPaste (Sender: TObject);
procedure PopupMenuClickEdit (Sender: TObject);
procedure PopupMenuClickExtClip (Sender: TObject);
procedure PopupMenuClickSelAll (Sender: TObject);
procedure PopupMenuClickChangeID (Sender: TObject);
procedure PopupMenuClickPrecision (Sender: TObject);
procedure PopupMenuClickSelectCol (Sender: TObject);
procedure PopupMenuClickSelectRow (Sender: TObject);
procedure PopupMenuClickInsertCol (Sender: TObject);
procedure PopupMenuClickInsertRow (Sender: TObject);
procedure PopupMenuClickDeleteCol (Sender: TObject);
procedure PopupMenuClickDeleteRow (Sender: TObject);
property Precision[ColNr: longint]: shortint
read GetDecPlaces write SetDecPlaces;
procedure RemoveRow (ix: longint);
procedure RemoveColumn (ix: longint);
property RowName[ix: longint]: TDTNameStr
read GetRowName write SetRowName;
property RowHeights;
property Selection;
procedure SortCols (SortRowIx: integer; Ascending: boolean;
LowCol, LowRow, HighCol, HighRow: integer;
IncludeHeaders: boolean);
procedure SortRows (SortColIx: integer; Ascending: boolean;
LowCol, LowRow, HighCol, HighRow: integer;
IncludeHeaders: boolean);
procedure SortColAttributes (Ascending: boolean;
LowCol, LowRow, HighCol, HighRow: integer);
procedure SortColNames (Ascending: boolean;
LowCol, LowRow, HighCol, HighRow: integer);overload;
procedure SortColNames (Ascending, IgnoreCase: boolean;
LowCol, LowRow, HighCol, HighRow: integer);overload;
procedure SortRowAttributes (Ascending: boolean;
LowCol, LowRow, HighCol, HighRow: integer);
procedure SortRowNames (Ascending: boolean;
LowCol, LowRow, HighCol, HighRow: integer); overload;
procedure SortRowNames (Ascending, IgnoreCase: boolean;
LowCol, LowRow, HighCol, HighRow: integer); overload;
procedure MarkAllElemsA;
procedure MarkAllElemsB;
procedure MirrorColumns;
procedure MirrorRows;
procedure UnMarkAllElems;
function NrOfMarkedDataA: integer;
function NrOfMarkedDataB: integer;
function FindColIndex (ColID: TDTNameStr): integer;
function FindRowIndex (RowID: TDTNameStr): integer;
property SuppressPaint: boolean
read FSuppressPaint write SetSuppressPaint;
property PopupDMask: longint read FPopupDMask write SetPopupDMask;
property PopupHMask: longint read FPopupHMask write SetPopupHMask;
property PopupDCaptions[ix: integer]: TDTNameStr
read GetPopupDCaption
write SetPopupDCaption;
property PopupMCaptions[ix: integer]: TDTNameStr
read GetPopupMCaption
write SetPopupMCaption;
property PopupUCaptions[ix: integer]: TDTNameStr
read GetPopupUCaption
write SetPopupUCaption;
property PopupHCaptions[ix: integer]: TDTNameStr
read GetPopupHCaption
write SetPopupHCaption;
published
property Align;
property AutoAdvance: boolean read FAutoAdvance write FAutoAdvance;
property AutoAdvanceDir: TOrientation
read FAutoAdvDir write FAutoAdvDir;
property AttribRowVisible: boolean
read GetRowAttVis write SetRowAttVis;
property AttribColVisible: boolean
read GetColAttVis write SetColAttVis;
property BlockInternalPopup: boolean
read FBlockIntPopup write FBlockIntPopup;
property CommentEditingAllowed: boolean
read FCommEdAllowed write FCommEdAllowed;
property Comment: string read GetComment write SetComment;
property ColorBackground: TColor
read FColorBkgnd write SetColorBackground;
property ColorEmptyMsg: TColor
read FColorEmptyMsg write SetColorEmptyMsg;
property ColorFixed: TColor read FColorFixed write SetColorFixed;
property ColorNormal: TColor read FColorNormal write SetColorNormal;
property ColorSelected: TColor
read FColorSelected write SetColorSelected;
property ColorMarkedA: TColor
read FColorMarked1 write SetColorMarkedA;
property ColorMarkedB: TColor
read FColorMarked2 write SetColorMarkedB;
property ColorMarkedBoth: TColor
read FColorMarkedBoth write SetColorMarkedBoth;
property ColorRangeSelFG: TColor
read FColorRngSelFG write SetFColorRngSelFG;
property ColorRangeSelBG: TColor
read FColorRngSelBG write SetFColorRngSelBG;
property DefaultColWidth: integer
read GetDefColWidth write SetDefColWidth;
property DefaultRowHeight;
{$IFDEF GE_LEV16}
property DrawingStyle;
property GradientStartColor;
property GradientEndColor;
{$ENDIF}
{$IFDEF GE_LEV17}
property StyleElements;
{$ENDIF}
property EmptyMessage: string read FEmptyMsg write SetEmptyMsg;
property Font;
property ParentFont;
property PopupMenu;
property BoldMarks: boolean
read FBoldMarks write SetBoldMarks;
property BoldSelHeads: boolean
read FBoldSelHeads write SetBoldSelHeads;
property ClipboardUseFullPrec: boolean
read FClipUseFullPrec write FClipUseFullPrec;
property LeftCol: integer read GetLeftCol write SetLeftCol;
property NomEditDropDownCount: integer
read FDropDownCount write SetDropdownCount default 8;
property NrOfColumns: longint read GetNrCols write SetNrCols;
property NrOfRows: longint read GetNrRows write SetNrRows;
property NumWidth: integer read FNumWidth write SetNumWidth;
property DataReadOnly: boolean read FReadOnly write SetDataReadOnly;
property OptimizeRowHeight: boolean
read FOptRowHeight write SetOptRowHeight;
property Options stored True;
property ShowCellCursor: boolean
read FShowCellCursor write SetShowCellCursor;
property TopRow: integer read GetTopRow write SetTopRow;
property VRangeHigh: double read FVRangeHigh write FVRangeHigh;
property VRangeLow: double read FVRangeLow write FVRangeLow;
property Visible;
property VisibleColCount;
property VisibleRowCount;
property OnGetEditText: TGetEditEvent
read FOnGetEditText write FOnGetEditText;
property OnSetEditText: TSetEditEvent
read FOnSetEditText write FOnSetEditText;
property OnMouseDown;
property OnMouseUp;
property OnMouseMove;
property OnMouseWheelDown;
property OnMouseWheelUp;
property OnTopLeftChanged: TNotifyEvent
read FOnTopLeftChanged write FOnTopLeftChanged;
property OnSelectionChanged: TNotifyEvent
read FOnSelChanged write FOnSelChanged;
property OnBeforePopup: TBeforePopupEvent
read FOnBeforePopup write FOnBeforePopup;
property OnClick;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
property OnChangeSetup: TNotifyEvent
read FOnChangeSetup write FOnChangeSetup;
property OnClear: TNotifyEvent read FOnClear write FOnClear;
property OnPaste: TNotifyEvent read FOnPaste write FOnPaste;
property OnPercentDone: TOnPercentDoneEvent
read FOnPercentDone write FOnPercentDone;
property OnDblClick;
property OnHeadingChanged: TNotifyEvent read FOnHeadingChanged
write FOnHeadingChanged;
property OnAttributeChanged: TNotifyEvent read FOnChangeAttrib
write FOnChangeAttrib;
property OnCellStateChanged: TNotifyEvent read FOnChangeCellSt
write FOnChangeCellSt;
property OnEmptyStChanged: TNotifyEvent read FOnChangeEmptySt
write FOnChangeEmptySt;
property OnLayoutChanged: TNotifyEvent read FOnChangeLayout
write FOnChangeLayout;
property OnBeforeRenderCell: TBeforeRenderCellEvent
read FOnBeforeRenderCell write FOnBeforeRenderCell;
property OnKeyDown;
property OnKeyPress;
property OnKeyUp;
end;
|