TButtonColor

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

TButtonColor

Post by fjrohlf » Tue Nov 17, 2015 5:17 pm

Is there some documentation or a good example of the use of the TButtonColor component? I have not been able to find much information.

Thanks,

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TButtonColor

Post by Yeray » Wed Nov 18, 2015 12:22 pm

Hello,

The documentation says:
TButtonColor wrote:Description
This Button control is internally used at Chart Editor dialogs.

It's like a normal TButton control, but includes a property to "link" this button to a Color property.

The Color is used to display a graphical filled rectangle at the right side of the button.
Clicking the button will automatically show the Color editor dialog to change the color.

Example:

Code: Select all

ButtonPen1.LinkProperty( Series1, 'SeriesColor' );
Here you have another example with two:

Code: Select all

uses Series;

var Series1: TLineSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.View3D:=false;
  Chart1.Legend.Visible:=false;

  Series1:=Chart1.AddSeries(TLineSeries) as TLineSeries;

  Series1.FillSampleValues();
  Series1.Pointer.Visible:=true;
  Series1.Pointer.Color:=Series1.Color;

  ButtonColor1.LinkProperty(Series1, 'SeriesColor');
  ButtonColor2.LinkProperty(Series1.Pointer.Brush, 'Color');
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

Re: TButtonColor

Post by fjrohlf » Wed Nov 18, 2015 1:22 pm

So one does not have to enter any code for the button's onclick event? I would not have guessed that. Thanks again for your help.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TButtonColor

Post by Yeray » Wed Nov 18, 2015 1:45 pm

Hi,
fjrohlf wrote:So one does not have to enter any code for the button's onclick event?
Exactly. You just have to link a TColor property to it.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

Re: TButtonColor

Post by fjrohlf » Wed Nov 18, 2015 6:59 pm

That works very well - but how does one set the initial color of the "symbol"? Initially it is black and it does change once one clicks on it and selects a color but I would like it to start with a specified color (i.e., the existing color of a series).

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TButtonColor

Post by Yeray » Thu Nov 19, 2015 8:17 am

Hello,
fjrohlf wrote:That works very well - but how does one set the initial color of the "symbol"? Initially it is black and it does change once one clicks on it and selects a color but I would like it to start with a specified color (i.e., the existing color of a series).
The code I posted above does it for me here. Doesn't for you?
Can you arrange a simple example project we can run as-is to reproduce the problem here?

Thanks in advance.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

Re: TButtonColor

Post by fjrohlf » Thu Nov 19, 2015 1:07 pm

see attached. Unfortunately, It uses some components from TMS but you should be able to see my buttoncolor code.
Attachments
myDemo1.zip
(5.4 KiB) Downloaded 924 times

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TButtonColor

Post by Yeray » Thu Nov 19, 2015 2:45 pm

Hello,
fjrohlf wrote:Unfortunately, It uses some components from TMS but you should be able to see my buttoncolor code.
After cleaning any 3rd party reference I made the simplified example to work with this code:

Code: Select all

procedure TForm2.FormCreate(Sender: TObject);
var
  i: integer;
  Series1: TpointSeries;
  seriesarray: array [1 .. 3] of TpointSeries;
  buttonsarray: array [1 .. 3] of TButtonColor;
  ButtonColori: TButtonColor;
begin
  Chart1.View3D := false;
  Chart1.Legend.Visible := false;
  for i := 1 to 3 do begin
    Series1 := Chart1.AddSeries(TpointSeries) as TpointSeries;
    seriesarray[i] := Series1;
    Series1.FillSampleValues();
    ButtonColori := TButtonColor.Create(self);
    buttonsarray[i] := ButtonColori;
    buttonsarray[i].Parent := Self;
    buttonsarray[i].Left := 15;
    buttonsarray[i].Top := buttonsarray[i].Height * i + 15;
    buttonsarray[i].Caption := IntToStr(i) + '   ';
    buttonsarray[i].SymbolWidth := 30;
    buttonsarray[i].LinkProperty(Series1,'SeriesColor');
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

fjrohlf
Newbie
Newbie
Posts: 33
Joined: Mon Sep 07, 2015 12:00 am

Re: TButtonColor

Post by fjrohlf » Thu Nov 19, 2015 4:11 pm

ok, that does work. It even works when I restore the parent as the newly created TAdvTabSheet. Thanks!

One last thing - how can i set the initial colors for the button and the series? If I use code such as
Series1.Pointer.Color := clRed;
then the series has that initial color but the button does not (they have the colors that the series would have had without the change given above). I believe the answer to this will reveal what the problem was in my original code.

Yeray
Site Admin
Site Admin
Posts: 9613
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TButtonColor

Post by Yeray » Mon Nov 23, 2015 10:42 am

Hello,

Using a TPointSeries you should change the series color, not the pointer color:

Code: Select all

  Series1.Color := clRed;
Here the complete code that works fine for me:

Code: Select all

procedure TForm2.FormCreate(Sender: TObject);
var
  i: integer;
  Series1: TpointSeries;
  seriesarray: array [1 .. 3] of TpointSeries;
  buttonsarray: array [1 .. 3] of TButtonColor;
  ButtonColori: TButtonColor;
begin
  Chart1.View3D := false;
  Chart1.Legend.Visible := false;
  for i := 1 to 3 do begin
    Series1 := Chart1.AddSeries(TpointSeries) as TpointSeries;
    seriesarray[i] := Series1;
    Series1.FillSampleValues();
    ButtonColori := TButtonColor.Create(self);
    buttonsarray[i] := ButtonColori;
    buttonsarray[i].Parent := Self;
    buttonsarray[i].Left := 15;
    buttonsarray[i].Top := buttonsarray[i].Height*i + 5;
    buttonsarray[i].Caption := IntToStr(i) + '   ';
    buttonsarray[i].SymbolWidth := 30;
    ButtonColori.LinkProperty(Series1,'SeriesColor');
  end;

  Series1.Color := clRed;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply