mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 07:16:49 +02:00
TAChart: Add event OnGetMarkText to TChartSeries providing more parameters. Deprecate OnGetMark. Issue #40647.
This commit is contained in:
parent
0a423300ae
commit
33801729a2
@ -365,7 +365,7 @@ begin
|
|||||||
if Result<>shrSuccess then exit;
|
if Result<>shrSuccess then exit;
|
||||||
|
|
||||||
if not (csDesigning in ComponentState) and
|
if not (csDesigning in ComponentState) and
|
||||||
(KeywordPrefix<>'') and
|
// (KeywordPrefix<>'') and
|
||||||
(LeftStr(HelpKeyword,length(KeywordPrefix))=KeywordPrefix) then
|
(LeftStr(HelpKeyword,length(KeywordPrefix))=KeywordPrefix) then
|
||||||
begin
|
begin
|
||||||
// HelpKeyword starts with KeywordPrefix -> add default node
|
// HelpKeyword starts with KeywordPrefix -> add default node
|
||||||
|
@ -131,8 +131,12 @@ type
|
|||||||
property Transparency;
|
property Transparency;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
TChartSeries = class;
|
||||||
|
|
||||||
TChartGetMarkEvent = procedure (
|
TChartGetMarkEvent = procedure (
|
||||||
out AFormattedMark: String; AIndex: Integer) of object;
|
out AFormattedMark: String; AIndex: Integer) of object;
|
||||||
|
TChartGetMarkTextEvent = procedure (ASeries: TChartSeries;
|
||||||
|
APointIndex, AXIndex, AYIndex: Integer; var AFormattedMark: String) of object;
|
||||||
|
|
||||||
{ TChartSeries }
|
{ TChartSeries }
|
||||||
|
|
||||||
@ -142,6 +146,7 @@ type
|
|||||||
FListener: TListener;
|
FListener: TListener;
|
||||||
FMarks: TChartMarks;
|
FMarks: TChartMarks;
|
||||||
FOnGetMark: TChartGetMarkEvent;
|
FOnGetMark: TChartGetMarkEvent;
|
||||||
|
FOnGetMarkText: TChartGetMarkTextEvent;
|
||||||
FSource: TCustomChartSource;
|
FSource: TCustomChartSource;
|
||||||
FStyles: TChartStyles;
|
FStyles: TChartStyles;
|
||||||
FStylesListener: TListener;
|
FStylesListener: TListener;
|
||||||
@ -149,7 +154,8 @@ type
|
|||||||
function GetSource: TCustomChartSource;
|
function GetSource: TCustomChartSource;
|
||||||
function IsSourceStored: boolean;
|
function IsSourceStored: boolean;
|
||||||
procedure SetMarks(AValue: TChartMarks);
|
procedure SetMarks(AValue: TChartMarks);
|
||||||
procedure SetOnGetMark(AValue: TChartGetMarkEvent);
|
procedure SetOnGetMark(AValue: TChartGetMarkEvent); deprecated;
|
||||||
|
procedure SetOnGetMarkText(AValue: TChartGetMarkTextEvent);
|
||||||
procedure SetSource(AValue: TCustomChartSource);
|
procedure SetSource(AValue: TCustomChartSource);
|
||||||
procedure SetStyles(AValue: TChartStyles);
|
procedure SetStyles(AValue: TChartStyles);
|
||||||
protected
|
protected
|
||||||
@ -222,8 +228,8 @@ type
|
|||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
function Extent: TDoubleRect; virtual;
|
function Extent: TDoubleRect; virtual;
|
||||||
procedure FindYRange(AXMin, AXMax: Double; var AYMin, AYMax: Double); virtual;
|
procedure FindYRange(AXMin, AXMax: Double; var AYMin, AYMax: Double); virtual;
|
||||||
function FormattedMark(
|
function FormattedMark(AIndex: Integer; AFormat: String = '';
|
||||||
AIndex: Integer; AFormat: String = ''; AYIndex: Integer = 0): String;
|
AYIndex: Integer = 0; AXIndex: Integer = 0): String;
|
||||||
function IsEmpty: Boolean; override;
|
function IsEmpty: Boolean; override;
|
||||||
function ListSource: TListChartSource;
|
function ListSource: TListChartSource;
|
||||||
property Marks: TChartMarks
|
property Marks: TChartMarks
|
||||||
@ -247,7 +253,8 @@ type
|
|||||||
property Title;
|
property Title;
|
||||||
property ZPosition;
|
property ZPosition;
|
||||||
published
|
published
|
||||||
property OnGetMark: TChartGetMarkEvent read FOnGetMark write SetOnGetMark;
|
property OnGetMark: TChartGetMarkEvent read FOnGetMark write SetOnGetMark; deprecated 'Use OnGetMarkText instead'; // To be removed in Laz 5
|
||||||
|
property OnGetMarkText: TChartGetMarkTextEvent read FOnGetMarkText write SetOnGetMarkText;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TLabelDirection = (ldLeft, ldTop, ldRight, ldBottom);
|
TLabelDirection = (ldLeft, ldTop, ldRight, ldBottom);
|
||||||
@ -795,6 +802,7 @@ begin
|
|||||||
with TChartSeries(ASource) do begin
|
with TChartSeries(ASource) do begin
|
||||||
Self.Marks.Assign(FMarks);
|
Self.Marks.Assign(FMarks);
|
||||||
Self.FOnGetMark := FOnGetMark;
|
Self.FOnGetMark := FOnGetMark;
|
||||||
|
Self.FOnGetMarkText := FOnGetMarkText;
|
||||||
Self.Source := FSource;
|
Self.Source := FSource;
|
||||||
Self.Styles := FStyles;
|
Self.Styles := FStyles;
|
||||||
end;
|
end;
|
||||||
@ -888,14 +896,18 @@ begin
|
|||||||
Source.FindYRange(AXMin, AXMax, false, AYMin, AYMax);
|
Source.FindYRange(AXMin, AXMax, false, AYMin, AYMax);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TChartSeries.FormattedMark(
|
function TChartSeries.FormattedMark(AIndex: Integer; AFormat: String;
|
||||||
AIndex: Integer; AFormat: String; AYIndex: Integer): String;
|
AYIndex, AXIndex: Integer): String;
|
||||||
begin
|
begin
|
||||||
if Assigned(FOnGetMark) then
|
if Assigned(FOnGetMark) then
|
||||||
FOnGetMark(Result, AIndex)
|
FOnGetMark(Result, AIndex)
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
Result := Source.FormatItem(
|
Result := Source.FormatItem(
|
||||||
IfThen(AFormat = '', Marks.Format, AFormat), AIndex, AYIndex);
|
IfThen(AFormat = '', Marks.Format, AFormat), AIndex, AYIndex);
|
||||||
|
if Assigned(FOnGetMarkText) then
|
||||||
|
FOnGetMarkText(Self, AIndex, AXIndex, AYIndex, Result)
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.GetBounds(var ABounds: TDoubleRect);
|
procedure TChartSeries.GetBounds(var ABounds: TDoubleRect);
|
||||||
@ -1114,6 +1126,13 @@ begin
|
|||||||
UpdateParentChart;
|
UpdateParentChart;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TChartSeries.SetOnGetMarkText(AValue: TChartGetMarkTextEvent);
|
||||||
|
begin
|
||||||
|
if TMethod(FOnGetMarkText) = TMethod(AValue) then exit;
|
||||||
|
FOnGetMarkText := AValue;
|
||||||
|
UpdateParentChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TChartSeries.SetSource(AValue: TCustomChartSource);
|
procedure TChartSeries.SetSource(AValue: TCustomChartSource);
|
||||||
begin
|
begin
|
||||||
if AValue = FBuiltinSource then
|
if AValue = FBuiltinSource then
|
||||||
|
108
lcl/dbgrids.pas
108
lcl/dbgrids.pas
@ -79,7 +79,8 @@ type
|
|||||||
|
|
||||||
TDbGridExtraOption = (
|
TDbGridExtraOption = (
|
||||||
dgeAutoColumns, // if uncustomized columns, add them anyway?
|
dgeAutoColumns, // if uncustomized columns, add them anyway?
|
||||||
dgeCheckboxColumn // enable the use of checkbox in columns
|
dgeCheckboxColumn, // enable the use of checkbox in columns
|
||||||
|
dgeMouseWheelPageScroll // forces the mouse-wheel to scroll by pages
|
||||||
);
|
);
|
||||||
TDbGridExtraOptions = set of TDbGridExtraOption;
|
TDbGridExtraOptions = set of TDbGridExtraOption;
|
||||||
|
|
||||||
@ -614,6 +615,7 @@ type
|
|||||||
property HeaderPushZones;
|
property HeaderPushZones;
|
||||||
//property ImeMode;
|
//property ImeMode;
|
||||||
//property ImeName;
|
//property ImeName;
|
||||||
|
property MouseWheelSpeedupKey;
|
||||||
property Options;
|
property Options;
|
||||||
property Options2;
|
property Options2;
|
||||||
property OptionsExtra;
|
property OptionsExtra;
|
||||||
@ -3070,29 +3072,129 @@ begin
|
|||||||
{$ifdef dbgDBGrid}DebugLnExit('%s.DoExit DONE', [ClassName]);{$endif}
|
{$ifdef dbgDBGrid}DebugLnExit('%s.DoExit DONE', [ClassName]);{$endif}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function SpeedupKeyPressed(Shift: TShiftState; SpeedupKey: TMouseWheelSpeedupKey): Boolean;
|
||||||
|
begin
|
||||||
|
case SpeedupKey of
|
||||||
|
mwskNone:
|
||||||
|
Result := false;
|
||||||
|
mwskShift:
|
||||||
|
Result := (Shift = [ssShift]);
|
||||||
|
mwskCtrl:
|
||||||
|
Result := (Shift * [ssCtrl, ssMeta] <> []); // check also ssMeta for Mac
|
||||||
|
mwskShiftCtrl:
|
||||||
|
Result := (Shift * [ssCtrl, ssMeta] <> []) and (Shift * [ssShift] <> []);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
(*
|
||||||
function TCustomDBGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
function TCustomDBGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
||||||
): Boolean;
|
): Boolean;
|
||||||
|
var
|
||||||
|
delta: Integer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if Assigned(OnMouseWheelDown) then
|
if Assigned(OnMouseWheelDown) then
|
||||||
OnMouseWheelDown(Self, Shift, MousePos, Result);
|
OnMouseWheelDown(Self, Shift, MousePos, Result);
|
||||||
if not Result and FDatalink.Active then begin
|
if not Result and FDatalink.Active then begin
|
||||||
FDatalink.MoveBy(1);
|
if (dgeMouseWheelPageScroll in FExtraOptions) or SpeedupKeyPressed(Shift, MouseWheelSpeedupKey) then
|
||||||
|
begin
|
||||||
|
if Row < VisibleRowCount then
|
||||||
|
delta := VisibleRowCount - Row
|
||||||
|
else
|
||||||
|
delta := VisibleRowCount;
|
||||||
|
end else
|
||||||
|
delta := 1;
|
||||||
|
FDatalink.MoveBy(delta);
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomDBGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
function TCustomDBGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
||||||
): Boolean;
|
): Boolean;
|
||||||
|
var
|
||||||
|
delta: Integer;
|
||||||
begin
|
begin
|
||||||
Result := False;
|
Result := False;
|
||||||
if Assigned(OnMouseWheelUp) then
|
if Assigned(OnMouseWheelUp) then
|
||||||
OnMouseWheelUp(Self, Shift, MousePos, Result);
|
OnMouseWheelUp(Self, Shift, MousePos, Result);
|
||||||
if not Result and FDatalink.Active then begin
|
if not Result and FDatalink.Active then begin
|
||||||
FDatalink.MoveBy(-1);
|
if (dgeMouseWheelPageScroll in FExtraOptions) or SpeedupKeyPressed(Shift, MouseWheelSpeedupKey) then
|
||||||
|
begin
|
||||||
|
if Row > 1 then
|
||||||
|
delta := Row - 1
|
||||||
|
else
|
||||||
|
delta := VisibleRowCount;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
delta := 1;
|
||||||
|
FDatalink.MoveBy(-delta);
|
||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
*)
|
||||||
|
function TCustomDBGrid.DoMouseWheelDown(Shift: TShiftState; MousePos: TPoint
|
||||||
|
): Boolean;
|
||||||
|
var
|
||||||
|
delta, row1: Integer;
|
||||||
|
bBack: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if Assigned(OnMouseWheelDown) then
|
||||||
|
OnMouseWheelDown(Self, Shift, MousePos, Result);
|
||||||
|
if not Result and FDatalink.Active then begin
|
||||||
|
if (dgeMouseWheelPageScroll in FExtraOptions) or SpeedupKeyPressed(Shift, MouseWheelSpeedupKey) then
|
||||||
|
begin
|
||||||
|
row1 := Row;
|
||||||
|
if Row < VisibleRowCount then
|
||||||
|
delta := VisibleRowCount * 2 - Row
|
||||||
|
else
|
||||||
|
delta := VisibleRowCount;
|
||||||
|
bBack := True;
|
||||||
|
end else Begin
|
||||||
|
bBack := False;
|
||||||
|
delta := 1;
|
||||||
|
End;
|
||||||
|
if FDatalink.MoveBy(delta) <> delta then
|
||||||
|
begin
|
||||||
|
FDatalink.MoveBy(1);
|
||||||
|
bBack := False;
|
||||||
|
end;
|
||||||
|
if bBack then
|
||||||
|
FDatalink.MoveBy(-(Row - row1));
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TCustomDBGrid.DoMouseWheelUp(Shift: TShiftState; MousePos: TPoint
|
||||||
|
): Boolean;
|
||||||
|
var
|
||||||
|
delta, row1: Integer;
|
||||||
|
bBack: Boolean;
|
||||||
|
begin
|
||||||
|
Result := False;
|
||||||
|
if Assigned(OnMouseWheelUp) then
|
||||||
|
OnMouseWheelUp(Self, Shift, MousePos, Result);
|
||||||
|
if not Result and FDatalink.Active then begin
|
||||||
|
if (dgeMouseWheelPageScroll in FExtraOptions) or SpeedupKeyPressed(Shift, MouseWheelSpeedupKey) then
|
||||||
|
begin
|
||||||
|
row1 := Row - 1;
|
||||||
|
delta := VisibleRowCount + Row - 1;
|
||||||
|
bBack := True;
|
||||||
|
end else Begin
|
||||||
|
bBack := False;
|
||||||
|
delta := 1;
|
||||||
|
End;
|
||||||
|
if FDatalink.MoveBy(-delta) <> -delta then
|
||||||
|
begin
|
||||||
|
FDatalink.MoveBy(-1);
|
||||||
|
bBack := False;
|
||||||
|
end;
|
||||||
|
if bBack then
|
||||||
|
FDatalink.MoveBy(row1);
|
||||||
|
Result := True;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
function TCustomDBGrid.GetEditMask(aCol, aRow: Longint): string;
|
function TCustomDBGrid.GetEditMask(aCol, aRow: Longint): string;
|
||||||
var
|
var
|
||||||
|
@ -146,6 +146,8 @@ type
|
|||||||
TAutoAdvance = (aaNone,aaDown,aaRight,aaLeft, aaRightDown, aaLeftDown,
|
TAutoAdvance = (aaNone,aaDown,aaRight,aaLeft, aaRightDown, aaLeftDown,
|
||||||
aaRightUp, aaLeftUp);
|
aaRightUp, aaLeftUp);
|
||||||
|
|
||||||
|
TMouseWheelSpeedupKey = (mwskNone, mwskShift, mwskCtrl, mwskShiftCtrl);
|
||||||
|
|
||||||
{ Option goRangeSelect: --> select a single range only, or multiple ranges }
|
{ Option goRangeSelect: --> select a single range only, or multiple ranges }
|
||||||
TRangeSelectMode = (rsmSingle, rsmMulti);
|
TRangeSelectMode = (rsmSingle, rsmMulti);
|
||||||
|
|
||||||
@ -843,6 +845,7 @@ type
|
|||||||
FSizing: TSizingRec;
|
FSizing: TSizingRec;
|
||||||
FRowAutoInserted: Boolean;
|
FRowAutoInserted: Boolean;
|
||||||
FMouseWheelOption: TMouseWheelOption;
|
FMouseWheelOption: TMouseWheelOption;
|
||||||
|
FMouseWheelSpeedupKey: TMouseWheelSpeedupKey;
|
||||||
FSavedHint: String;
|
FSavedHint: String;
|
||||||
FCellHintPriority: TCellHintPriority;
|
FCellHintPriority: TCellHintPriority;
|
||||||
FOnGetCellHint: TGetCellHintEvent;
|
FOnGetCellHint: TGetCellHintEvent;
|
||||||
@ -1277,6 +1280,7 @@ type
|
|||||||
property IsCellSelected[aCol,aRow: Integer]: boolean read GetIsCellSelected;
|
property IsCellSelected[aCol,aRow: Integer]: boolean read GetIsCellSelected;
|
||||||
property LeftCol:Integer read GetLeftCol write SetLeftCol;
|
property LeftCol:Integer read GetLeftCol write SetLeftCol;
|
||||||
property MouseWheelOption: TMouseWheelOption read FMouseWheelOption write FMouseWheelOption default mwCursor;
|
property MouseWheelOption: TMouseWheelOption read FMouseWheelOption write FMouseWheelOption default mwCursor;
|
||||||
|
property MouseWheelSpeedupKey: TMouseWheelSpeedupKey read FMouseWheelSpeedupKey write FMouseWheelSpeedupKey default mwskCtrl;
|
||||||
property Options: TGridOptions read FOptions write SetOptions default DefaultGridOptions;
|
property Options: TGridOptions read FOptions write SetOptions default DefaultGridOptions;
|
||||||
property Options2: TGridOptions2 read FOptions2 write SetOptions2 default DefaultGridOptions2;
|
property Options2: TGridOptions2 read FOptions2 write SetOptions2 default DefaultGridOptions2;
|
||||||
property RangeSelectMode: TRangeSelectMode read FRangeSelectMode write SetRangeSelectMode default rsmSingle;
|
property RangeSelectMode: TRangeSelectMode read FRangeSelectMode write SetRangeSelectMode default rsmSingle;
|
||||||
@ -10073,6 +10077,8 @@ begin
|
|||||||
FSpecialCursors[gcsRowHeightChanging] := crVSplit;
|
FSpecialCursors[gcsRowHeightChanging] := crVSplit;
|
||||||
FSpecialCursors[gcsDragging] := crMultiDrag;
|
FSpecialCursors[gcsDragging] := crMultiDrag;
|
||||||
|
|
||||||
|
FMouseWheelSpeedupKey := mwskCtrl;
|
||||||
|
|
||||||
varRubberSpace := Scale96ToScreen(constRubberSpace);
|
varRubberSpace := Scale96ToScreen(constRubberSpace);
|
||||||
varCellPadding := Scale96ToScreen(constCellPadding);
|
varCellPadding := Scale96ToScreen(constCellPadding);
|
||||||
varColRowBorderTolerance := Scale96ToScreen(constColRowBorderTolerance);
|
varColRowBorderTolerance := Scale96ToScreen(constColRowBorderTolerance);
|
||||||
@ -11634,6 +11640,12 @@ begin
|
|||||||
tmpCanvas.Font := Font;
|
tmpCanvas.Font := Font;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
if Assigned(FOnPrepareCanvas) then
|
||||||
|
begin
|
||||||
|
FOnPrepareCanvas(self, aCol, i, []);
|
||||||
|
tmpCanvas.Font := Canvas.Font;
|
||||||
|
end;
|
||||||
|
|
||||||
if (i=0) and (FixedRows>0) and (C<>nil) then
|
if (i=0) and (FixedRows>0) and (C<>nil) then
|
||||||
aText := C.Title.Caption
|
aText := C.Title.Caption
|
||||||
else
|
else
|
||||||
|
@ -244,7 +244,7 @@ begin
|
|||||||
if Result<>shrSuccess then exit;
|
if Result<>shrSuccess then exit;
|
||||||
|
|
||||||
if not (csDesigning in ComponentState)
|
if not (csDesigning in ComponentState)
|
||||||
and (KeywordPrefix<>'')
|
//and (KeywordPrefix<>'')
|
||||||
and (LeftStr(HelpKeyword,length(KeywordPrefix))=KeywordPrefix) then begin
|
and (LeftStr(HelpKeyword,length(KeywordPrefix))=KeywordPrefix) then begin
|
||||||
// HelpKeyword starts with KeywordPrefix -> add default node
|
// HelpKeyword starts with KeywordPrefix -> add default node
|
||||||
if FKeywordPrefixNode=nil then
|
if FKeywordPrefixNode=nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user