⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 teethemes.pas

📁 TeeChart7Source 控件
💻 PAS
字号:
{*******************************************}
{ TeeChart Pro visual Themes                }
{ Copyright (c) 2003-2004 by David Berneda  }
{ All Rights Reserved                       }
{*******************************************}
unit TeeThemes;
{$I TeeDefs.inc}

interface

uses Classes,
     {$IFDEF CLX}
     QGraphics,
     {$ELSE}
     Graphics,
     {$ENDIF}
     TeEngine, Chart, TeCanvas;

type
  TDefaultTheme=class(TChartTheme)
  protected
    procedure ChangeAxis(Axis:TChartAxis);
    procedure ChangeSeries(Series:TChartSeries);
    procedure ChangeWall(Wall:TChartWall; AColor:TColor);
    procedure ResetGradient(Gradient:TTeeGradient);
  public
    procedure Apply; override;
    function Description:string; override;
  end;

  TExcelTheme=class(TDefaultTheme)
  public
    procedure Apply; override;
    function Description:string; override;
  end;

  TClassicTheme=class(TDefaultTheme)
  public
    procedure Apply; override;
    function Description:string; override;
  end;

  TBusinessTheme=class(TDefaultTheme)
  public
    procedure Apply; override;
    function Description:string; override;
  end;

  TWebTheme=class(TDefaultTheme)
  public
    procedure Apply; override;
    function Description:string; override;
  end;

  TWindowsXPTheme=class(TBusinessTheme)
  public
    procedure Apply; override;
    function Description:string; override;
  end;

  TBlueSkyTheme=class(TDefaultTheme)
  public
    procedure Apply; override;
    function Description:string; override;
  end;

procedure ApplyChartTheme(Theme:TChartThemeClass; Chart:TCustomChart; PaletteIndex:Integer); overload;
procedure ApplyChartTheme(Theme:TChartThemeClass; Chart:TCustomChart); overload;

type
  TThemesList=class(TList)
  private
    function GetTheme(Index:Integer):TChartThemeClass;
  public
    property Theme[Index:Integer]:TChartThemeClass read GetTheme; default;
  end;

var 
  ChartThemes : TThemesList=nil;

procedure RegisterChartThemes(const Themes:Array of TChartThemeClass);

implementation

uses {$IFDEF CLX}
     QControls,
     {$ELSE}
     Controls,
     {$ENDIF}
     TeeConst, TeeProCo, TeeProcs;

{ TDefaultTheme }
function TDefaultTheme.Description: string;
begin
  result:='TeeChart default';
end;

procedure TDefaultTheme.ResetGradient(Gradient:TTeeGradient);
begin
  with Gradient do
  begin
    Visible:=False;
    StartColor:=clWhite;
    Direction:=gdTopBottom;
    EndColor:=clYellow;
    MidColor:=clNone;
    Balance:=50;
  end;
end;

procedure TDefaultTheme.ChangeWall(Wall:TChartWall; AColor:TColor);
begin
  with Wall do
  begin
    Pen.Visible:=True;
    Pen.Color:=clBlack;
    Pen.Width:=1;
    Pen.Style:=psSolid;
    Gradient.Visible:=False;

    Color:=AColor;
    Dark3D:=True;
    Size:=0;
  end;
end;

procedure TDefaultTheme.ChangeAxis(Axis:TChartAxis);
begin
  with Axis do
  begin
    Axis.Width:=2;
    Axis.Color:=clBlack;

    Grid.Visible:=True;
    Grid.Color:=clGray;
    Grid.Style:=psDot;
    Grid.SmallDots:=False;
    Grid.Centered:=False;

    Ticks.Color:=clDkGray;
    TicksInner.Visible:=True;
    MinorTicks.Visible:=True;

    MinorGrid.Hide;
    MinorTickCount:=3;

    MinorTickLength:=2;
    TickLength:=4;
    TickInnerLength:=0;

    with LabelsFont do
    begin
      Name:=GetDefaultFontName;
      Size:=GetDefaultFontSize;
      Style:=[];
      Color:=clBlack;
    end;

    Title.Font.Name:=GetDefaultFontName;
  end;
end;

procedure TDefaultTheme.ChangeSeries(Series:TChartSeries);
begin
  with Series.Marks do
  begin
    Transparent:=False;
    Gradient.Visible:=False;
    Font.Name:=GetDefaultFontName;
    Font.Size:=GetDefaultFontSize;
    Arrow.Color:=clWhite;
  end;
end;

procedure TDefaultTheme.Apply;
var t : Integer;
begin
  inherited;

  Chart.BevelInner:=bvNone;
  Chart.BevelOuter:=bvRaised;
  Chart.BevelWidth:=1;
  Chart.Border.Hide;
  Chart.BorderRound:=0;
  Chart.Border.Hide;

  Chart.Shadow.Size:=0;

  Chart.Color:=clBtnFace;

  ResetGradient(Chart.Gradient);

  with Chart.Legend do
  begin
    Shadow.VertSize:=3;
    Shadow.HorizSize:=3;
    Shadow.Transparency:=0;
    Font.Name:=GetDefaultFontName;
    Font.Size:=GetDefaultFontSize;
    Symbol.DefaultPen:=True;
    Transparent:=False;
    Pen.Visible:=True;
    DividingLines.Hide;
    Gradient.Visible:=False;
  end;

  ChangeWall(Chart.Walls.Left,$0080FFFF);
  ChangeWall(Chart.Walls.Right,clSilver);
  ChangeWall(Chart.Walls.Back,clSilver);
  ChangeWall(Chart.Walls.Bottom,clWhite);

  Chart.Walls.Back.Transparent:=True;

  for t:=0 to Chart.Axes.Count-1 do
    ChangeAxis(Chart.Axes[t]);

  for t:=0 to Chart.SeriesCount-1 do
    ChangeSeries(Chart[t]);

  with Chart.Title do
  begin
    Font.Name:=GetDefaultFontName;
    Font.Size:=GetDefaultFontSize;
    Font.Color:=clBlue;
  end;

  ColorPalettes.ApplyPalette(Chart,0);
end;

{ TClassicTheme }

procedure TClassicTheme.Apply;
const ClassicFont = 'Times New Roman';

  procedure ChangeWall(Wall:TChartWall);
  begin
    with Wall do
    begin
      Pen.Visible:=True;
      Pen.Color:=clBlack;
      Pen.Width:=1;
      Pen.Style:=psSolid;
      Gradient.Visible:=False;

      Color:=clWhite;
      Dark3D:=False;
      Size:=8;
    end;
  end;

  procedure ChangeAxis(Axis:TChartAxis);
  begin
    Axis.Axis.Width:=1;
    Axis.Grid.Color:=clBlack;
    Axis.Grid.Style:=psSolid;
    Axis.Grid.Visible:=True;

    Axis.Ticks.Color:=clBlack;

    Axis.MinorTicks.Hide;
    Axis.TicksInner.Hide;

    with Axis.LabelsFont do
    begin
      Name:=ClassicFont;
      Size:=10;
    end;

    Axis.Title.Font.Name:=ClassicFont;
  end;

  procedure ChangeSeries(Series:TChartSeries);
  begin
    with Series.Marks do
    begin
      Gradient.Visible:=False;
      Transparent:=True;
      Font.Name:=ClassicFont;
      Font.Size:=10;
      Arrow.Color:=clBlack;
    end;
  end;

var t : Integer;
begin
  inherited;

  Chart.BevelInner:=bvNone;
  Chart.BevelOuter:=bvNone;
  Chart.BorderRound:=0;

  with Chart.Border do
  begin
    Visible:=True;
    Width:=1;
    Style:=psSolid;
    Color:=clBlack;
  end;

  Chart.Color:=clWhite;
  Chart.Gradient.Visible:=False;

  with Chart.Legend do
  begin
    Shadow.VertSize:=0;
    Shadow.HorizSize:=0;
    Font.Name:=ClassicFont;
    Font.Size:=10;
    Transparent:=True;
    Pen.Hide;
    Symbol.DefaultPen:=False;
    Symbol.Pen.Hide;
  end;

  ChangeWall(Chart.Walls.Left);
  ChangeWall(Chart.Walls.Right);
  ChangeWall(Chart.Walls.Back);
  ChangeWall(Chart.Walls.Bottom);

  Chart.Walls.Back.Transparent:=False;

  for t:=0 to Chart.Axes.Count-1 do
    ChangeAxis(Chart.Axes[t]);

  Chart.Axes.Bottom.Grid.Centered:=True;

  for t:=0 to Chart.SeriesCount-1 do
    ChangeSeries(Chart[t]);

  with Chart.Title do
  begin
    Font.Name:=ClassicFont;
    Font.Size:=12;
    Font.Color:=clBlack;
  end;

  ColorPalettes.ApplyPalette(Chart,5);
end;

function TClassicTheme.Description: string;
begin
  result:='Classic';
end;

{ TBusinessTheme }

procedure TBusinessTheme.Apply;
var t : Integer;
begin
  inherited;

  Chart.BevelInner:=bvNone;
  Chart.BevelOuter:=bvNone;

  Chart.Border.Visible:=True;
  Chart.BorderRound:=10;
  Chart.Border.Width:=6;
  Chart.Border.Color:=clNavy;

  ResetGradient(Chart.Gradient);

  Chart.Gradient.Visible:=True;
  Chart.Gradient.EndColor:=clDkGray;

  Chart.Color:=clBtnFace;

  with Chart.Legend do
  begin
    Shadow.VertSize:=3;
    Shadow.HorizSize:=3;
    Font.Name:=GetDefaultFontName;
    Font.Size:=GetDefaultFontSize;
    Symbol.DefaultPen:=True;
    Transparent:=False;
    Pen.Visible:=True;

    ResetGradient(Gradient);

    Gradient.Visible:=True;
  end;

  ChangeWall(Chart.Walls.Left,$0080FFFF);
  ChangeWall(Chart.Walls.Right,clSilver);
  ChangeWall(Chart.Walls.Back,clSilver);
  ChangeWall(Chart.Walls.Bottom,clWhite);

  Chart.Walls.Back.Transparent:=True;

  for t:=0 to Chart.Axes.Count-1 do
      ChangeAxis(Chart.Axes[t]);

  for t:=0 to Chart.SeriesCount-1 do
  begin
    ChangeSeries(Chart[t]);
    with Chart[t].Marks.Gradient do
    begin
      Visible:=True;
      StartColor:=clSilver;
    end;
  end;

  with Chart.Title do
  begin
    Font.Name:=GetDefaultFontName;
    Font.Size:=GetDefaultFontSize;
    Font.Color:=clBlue;
  end;

  ColorPalettes.ApplyPalette(Chart,2);
end;

function TBusinessTheme.Description: string;
begin
  result:=TeeMsg_WizardTab;  // Business
end;

{ TExcelTheme }

function TExcelTheme.Description: string;
begin
  result:='Microsoft

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -