mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 10:18:15 +02:00
LCL: TBar properties can now be changed from Aleksey Lagunov
git-svn-id: trunk@10178 -
This commit is contained in:
parent
722f971500
commit
921f2b2e64
112
lcl/chart.pp
112
lcl/chart.pp
@ -35,24 +35,48 @@ uses
|
|||||||
type
|
type
|
||||||
|
|
||||||
TPosLabel=(plLeft, plCenter, plRight);
|
TPosLabel=(plLeft, plCenter, plRight);
|
||||||
|
TCustomBarChart = class;
|
||||||
{ TCustomBarChart }
|
{ TBar }
|
||||||
|
|
||||||
TBar = class(TCollectionItem)
|
TBar = class(TCollectionItem)
|
||||||
private
|
private
|
||||||
|
FColor: TColor;
|
||||||
FSName: String;
|
FSName: String;
|
||||||
FValue: integer;
|
FValue: integer;
|
||||||
FColor: TColor;
|
procedure SetColor(const AValue: TColor);
|
||||||
public
|
procedure SetSName(const AValue: String);
|
||||||
|
procedure SetValue(const AValue: integer);
|
||||||
|
procedure UpdateBarChart;
|
||||||
|
protected
|
||||||
|
function GetDisplayName: string; override;
|
||||||
|
published
|
||||||
|
property SName: String read FSName write SetSName;
|
||||||
|
property Value: integer read FValue write SetValue;
|
||||||
|
property Color: TColor read FColor write SetColor;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TBarChartItems }
|
||||||
|
|
||||||
|
TBarChartItems = class(TCollection)
|
||||||
|
private
|
||||||
|
FBarChart : TCustomBarChart;
|
||||||
|
public
|
||||||
|
constructor Create(BarChart: TCustomBarChart);
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TCustomBarChart }
|
||||||
|
|
||||||
TCustomBarChart = class(TPanel)
|
TCustomBarChart = class(TPanel)
|
||||||
private
|
private
|
||||||
FUpdateCount: Integer;
|
FUpdateCount: Integer;
|
||||||
FBars: TCollection;
|
FBars: TCollection;
|
||||||
FDepth: byte;
|
FDepth: byte;
|
||||||
FLabelPosition:TPosLabel;
|
FLabelPosition:TPosLabel;
|
||||||
|
function GetBars: TCollection;
|
||||||
function NormalizeScaleUnits(OldScale: Integer): Integer;
|
function NormalizeScaleUnits(OldScale: Integer): Integer;
|
||||||
|
procedure SetBars(const AValue: TCollection);
|
||||||
|
procedure SetDepth(const AValue: byte);
|
||||||
|
procedure SetLabelPosition(const AValue: TPosLabel);
|
||||||
protected
|
protected
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
public
|
public
|
||||||
@ -64,9 +88,11 @@ type
|
|||||||
function BarCount: Integer;
|
function BarCount: Integer;
|
||||||
procedure BeginUpdate;
|
procedure BeginUpdate;
|
||||||
procedure EndUpdate;
|
procedure EndUpdate;
|
||||||
|
procedure UpdateBarChart;
|
||||||
published
|
published
|
||||||
property Depth: byte read FDepth write FDepth;
|
property Bars: TCollection read GetBars write SetBars;
|
||||||
property LabelPosition: TPosLabel read FLabelPosition write FLabelPosition;
|
property Depth: byte read FDepth write SetDepth;
|
||||||
|
property LabelPosition: TPosLabel read FLabelPosition write SetLabelPosition;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -128,7 +154,7 @@ end;
|
|||||||
constructor TCustomBarChart.Create(AOwner: TComponent);
|
constructor TCustomBarChart.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited Create(AOwner);
|
inherited Create(AOwner);
|
||||||
FBars:=TCollection.Create(TBar);
|
FBars:=TBarChartItems.Create(Self);
|
||||||
FDepth:=5;
|
FDepth:=5;
|
||||||
FLabelPosition:=plLeft;
|
FLabelPosition:=plLeft;
|
||||||
SetInitialBounds(0,0,150,120);
|
SetInitialBounds(0,0,150,120);
|
||||||
@ -183,6 +209,30 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TCustomBarChart.GetBars: TCollection;
|
||||||
|
begin
|
||||||
|
Result:=FBars;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomBarChart.SetBars(const AValue: TCollection);
|
||||||
|
begin
|
||||||
|
FBars.Assign(AValue);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomBarChart.SetDepth(const AValue: byte);
|
||||||
|
begin
|
||||||
|
if FDepth=AValue then exit;
|
||||||
|
FDepth:=AValue;
|
||||||
|
UpdateBarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TCustomBarChart.SetLabelPosition(const AValue: TPosLabel);
|
||||||
|
begin
|
||||||
|
if FLabelPosition=AValue then exit;
|
||||||
|
FLabelPosition:=AValue;
|
||||||
|
UpdateBarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomBarChart.Paint;
|
procedure TCustomBarChart.Paint;
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -335,10 +385,56 @@ begin
|
|||||||
Invalidate;
|
Invalidate;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomBarChart.UpdateBarChart;
|
||||||
|
begin
|
||||||
|
if FUpdateCount = 0 then
|
||||||
|
Invalidate;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCustomBarChart.BarCount: Integer;
|
function TCustomBarChart.BarCount: Integer;
|
||||||
begin
|
begin
|
||||||
Result:=FBars.Count;
|
Result:=FBars.Count;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TBar }
|
||||||
|
|
||||||
end.
|
procedure TBar.SetColor(const AValue: TColor);
|
||||||
|
begin
|
||||||
|
if FColor=AValue then exit;
|
||||||
|
FColor:=AValue;
|
||||||
|
UpdateBarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBar.SetSName(const AValue: String);
|
||||||
|
begin
|
||||||
|
if FSName=AValue then exit;
|
||||||
|
FSName:=AValue;
|
||||||
|
UpdateBarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBar.SetValue(const AValue: integer);
|
||||||
|
begin
|
||||||
|
if FValue=AValue then exit;
|
||||||
|
FValue:=AValue;
|
||||||
|
UpdateBarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TBar.UpdateBarChart;
|
||||||
|
begin
|
||||||
|
(Collection as TBarChartItems).FBarChart.UpdateBarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TBar.GetDisplayName: string;
|
||||||
|
begin
|
||||||
|
Result:=FSName;
|
||||||
|
end;
|
||||||
|
|
||||||
|
{ TBarChartItems }
|
||||||
|
|
||||||
|
constructor TBarChartItems.Create(BarChart: TCustomBarChart);
|
||||||
|
begin
|
||||||
|
inherited Create(TBar);
|
||||||
|
FBarChart:=BarChart;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
|
@ -373,6 +373,7 @@ Type
|
|||||||
property OnMouseuP;
|
property OnMouseuP;
|
||||||
property OnResize;
|
property OnResize;
|
||||||
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
|
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
|
||||||
|
property TabOrder;
|
||||||
property Values: TStrings read FValues write SetValues;
|
property Values: TStrings read FValues write SetValues;
|
||||||
property Visible;
|
property Visible;
|
||||||
end;
|
end;
|
||||||
|
@ -144,8 +144,7 @@ type
|
|||||||
procedure SetAutoScroll(Value: Boolean);
|
procedure SetAutoScroll(Value: Boolean);
|
||||||
procedure SetHorzScrollBar(Value: TControlScrollBar);
|
procedure SetHorzScrollBar(Value: TControlScrollBar);
|
||||||
procedure SetVertScrollBar(Value: TControlScrollBar);
|
procedure SetVertScrollBar(Value: TControlScrollBar);
|
||||||
//todo: rename to IsScrollbarsStored
|
function StoreScrollBars : Boolean;
|
||||||
Function StoreScrollBars : Boolean;
|
|
||||||
protected
|
protected
|
||||||
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
|
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
|
||||||
procedure CreateWnd; override;
|
procedure CreateWnd; override;
|
||||||
|
Loading…
Reference in New Issue
Block a user