Arrays pascal声明2d颜色数组-类型定义错误

Arrays pascal声明2d颜色数组-类型定义错误,arrays,components,pascal,Arrays,Components,Pascal,我正在创建一个自定义组件,它覆盖canvas paint函数来绘制图形状态面板,我已经让它工作了,并且作为尝试改进代码的一部分,我希望将我的颜色存储在一个数组中,但是我无法确定如何正确定义数组 有人能给我指一下正确的方向吗 type TOC_StepState = (sst_red, sst_yellow, sst_green); TOC_StepStatus = class(TCustomPanel) private { Private declarations } fstatus :

我正在创建一个自定义组件,它覆盖canvas paint函数来绘制图形状态面板,我已经让它工作了,并且作为尝试改进代码的一部分,我希望将我的颜色存储在一个数组中,但是我无法确定如何正确定义数组

有人能给我指一下正确的方向吗

type
TOC_StepState = (sst_red, sst_yellow, sst_green);
TOC_StepStatus = class(TCustomPanel)
private
  { Private declarations }
  fstatus : TOC_StepState;
  innerRect : TRect;

 const stateColor : array[TOC_StepState,2]  // <<<< fails here
 of TColor = ((clRed,clRed,clRed), (clYellow,clYellow,clYellow), (clGreen,clGreen,clGreen)); 

protected
  { Protected declarations }
  procedure Paint;
  override;
public
  { Public declarations }

published
  { Published declarations }
  property status : TOC_StepState read fstatus write fstatus;
end;
类型
TOC_步骤状态=(sst_红色、sst_黄色、sst_绿色);
TOC_StepStatus=类别(TCustomPanel)
私有的
{私有声明}
fstatus:TOC_StepState;
内直肌:TRect;

const stateColor:array[TOC_StepState,2]/如果我正在解释您试图正确执行的操作,那么这应该可以:

const
  stateColor : array[TOC_StepState] of array[TOC_StepState] of TColor =
      ((clRed,clRed,clRed),
       (clYellow,clYellow,clYellow),
       (clGreen,clGreen,clGreen));

这种语法也会起作用(但我发现它的可读性稍差—您可能会有不同的感觉):

const
  stateColor : array[0..2] of array[TOC_StepState] of TColor =
      ((clRed,clRed,clRed),
       (clYellow,clYellow,clYellow),
       (clGreen,clGreen,clGreen));
stateColor: array[0..2, TOC_StepState] of TColor =
    ((clRed, clRed, clRed),
     (clYellow, clYellow, clYellow),
     (clGreen, clGreen, clGreen));