LCL: TBar properties can now be changed from Aleksey Lagunov

git-svn-id: trunk@10178 -
This commit is contained in:
mattias 2006-11-07 23:10:10 +00:00
parent 722f971500
commit 921f2b2e64
3 changed files with 106 additions and 10 deletions

View File

@ -35,24 +35,48 @@ uses
type
TPosLabel=(plLeft, plCenter, plRight);
{ TCustomBarChart }
TCustomBarChart = class;
{ TBar }
TBar = class(TCollectionItem)
private
FColor: TColor;
FSName: String;
FValue: integer;
FColor: TColor;
public
procedure SetColor(const AValue: TColor);
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;
{ TBarChartItems }
TBarChartItems = class(TCollection)
private
FBarChart : TCustomBarChart;
public
constructor Create(BarChart: TCustomBarChart);
end;
{ TCustomBarChart }
TCustomBarChart = class(TPanel)
private
FUpdateCount: Integer;
FBars: TCollection;
FDepth: byte;
FLabelPosition:TPosLabel;
function GetBars: TCollection;
function NormalizeScaleUnits(OldScale: Integer): Integer;
procedure SetBars(const AValue: TCollection);
procedure SetDepth(const AValue: byte);
procedure SetLabelPosition(const AValue: TPosLabel);
protected
procedure Paint; override;
public
@ -64,9 +88,11 @@ type
function BarCount: Integer;
procedure BeginUpdate;
procedure EndUpdate;
procedure UpdateBarChart;
published
property Depth: byte read FDepth write FDepth;
property LabelPosition: TPosLabel read FLabelPosition write FLabelPosition;
property Bars: TCollection read GetBars write SetBars;
property Depth: byte read FDepth write SetDepth;
property LabelPosition: TPosLabel read FLabelPosition write SetLabelPosition;
end;
@ -128,7 +154,7 @@ end;
constructor TCustomBarChart.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBars:=TCollection.Create(TBar);
FBars:=TBarChartItems.Create(Self);
FDepth:=5;
FLabelPosition:=plLeft;
SetInitialBounds(0,0,150,120);
@ -183,6 +209,30 @@ begin
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;
var
@ -335,10 +385,56 @@ begin
Invalidate;
end;
procedure TCustomBarChart.UpdateBarChart;
begin
if FUpdateCount = 0 then
Invalidate;
end;
function TCustomBarChart.BarCount: Integer;
begin
Result:=FBars.Count;
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.

View File

@ -373,6 +373,7 @@ Type
property OnMouseuP;
property OnResize;
property ReadOnly: Boolean read GetReadOnly write SetReadOnly default False;
property TabOrder;
property Values: TStrings read FValues write SetValues;
property Visible;
end;

View File

@ -144,8 +144,7 @@ type
procedure SetAutoScroll(Value: Boolean);
procedure SetHorzScrollBar(Value: TControlScrollBar);
procedure SetVertScrollBar(Value: TControlScrollBar);
//todo: rename to IsScrollbarsStored
Function StoreScrollBars : Boolean;
function StoreScrollBars : Boolean;
protected
procedure AlignControls(AControl: TControl; var ARect: TRect); override;
procedure CreateWnd; override;