Ignore:
Timestamp:
Jan 7, 2017, 8:54:23 PM (7 years ago)
Author:
chronos
Message:
  • Removed: Do not create file association at runtime as it is done by installer program.
  • Modified: Additional source formating using Delphi formatter.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Components/EOTButton.pas

    r10 r14  
    88
    99const
    10 eotBlinkOff=-1; eotCancel=0; eotGray=1; eotBlinkOn=2; eotBackToNego=3;
     10  eotBlinkOff = -1;
     11  eotCancel = 0;
     12  eotGray = 1;
     13  eotBlinkOn = 2;
     14  eotBackToNego = 3;
    1115
    1216type
     
    1519    destructor Destroy; override;
    1620    procedure SetButtonIndexFast(x: integer);
    17     procedure SetBack(ca: TCanvas; x,y: integer);
     21    procedure SetBack(ca: TCanvas; x, y: integer);
    1822  private
    1923    FTemplate: TBitmap;
     
    3741procedure Register;
    3842begin
    39 RegisterComponents('Samples', [TEOTButton]);
     43  RegisterComponents('Samples', [TEOTButton]);
    4044end;
    4145
    42 procedure ImageOp_CBC(Dst,Src: TBitmap; xDst,yDst,xSrc,ySrc,w,h,Color0,Color2: integer);
     46procedure ImageOp_CBC(Dst, Src: TBitmap; xDst, yDst, xSrc, ySrc, w, h, Color0,
     47  Color2: integer);
    4348// Src is template
    4449// B channel = Color0 amp
     
    4651// R channel = Color2 amp
    4752type
    48 TLine=array[0..9999,0..2] of Byte;
     53  TLine = array [0 .. 9999, 0 .. 2] of Byte;
    4954var
    50 ix,iy,amp0,amp1,trans,Value: integer;
    51 SrcLine,DstLine: ^TLine;
     55  ix, iy, amp0, amp1, trans, Value: integer;
     56  SrcLine, DstLine: ^TLine;
    5257begin
    53 for iy:=0 to h-1 do
     58  for iy := 0 to h - 1 do
    5459  begin
    55   SrcLine:=Src.ScanLine[ySrc+iy];
    56   DstLine:=Dst.ScanLine[yDst+iy];
    57   for ix:=0 to w-1 do
     60    SrcLine := Src.ScanLine[ySrc + iy];
     61    DstLine := Dst.ScanLine[yDst + iy];
     62    for ix := 0 to w - 1 do
    5863    begin
    59     trans:=SrcLine[xSrc+ix,0]*2; // green channel = transparency
    60     amp0:=SrcLine[xSrc+ix,1]*2;
    61     amp1:=SrcLine[xSrc+ix,2]*2;
    62     if trans<>$FF then
     64      trans := SrcLine[xSrc + ix, 0] * 2; // green channel = transparency
     65      amp0 := SrcLine[xSrc + ix, 1] * 2;
     66      amp1 := SrcLine[xSrc + ix, 2] * 2;
     67      if trans <> $FF then
    6368      begin
    64       Value:=(DstLine[xDst+ix][0]*trans+(Color2 shr 16 and $FF)*amp1+(Color0 shr 16 and $FF)*amp0) div $FF;
    65       if Value<256 then
    66         DstLine[xDst+ix][0]:=Value
    67       else DstLine[xDst+ix][0]:=255;
    68       Value:=(DstLine[xDst+ix][1]*trans+(Color2 shr 8 and $FF)*amp1+(Color0 shr 8 and $FF)*amp0) div $FF;
    69       if Value<256 then
    70         DstLine[xDst+ix][1]:=Value
    71       else DstLine[xDst+ix][1]:=255;
    72       Value:=(DstLine[xDst+ix][2]*trans+(Color2 and $FF)*amp1+(Color0 and $FF)*amp0) div $FF;
    73       if Value<256 then
    74         DstLine[xDst+ix][2]:=Value
    75       else DstLine[xDst+ix][2]:=255;
     69        Value := (DstLine[xDst + ix][0] * trans + (Color2 shr 16 and $FF) * amp1
     70          + (Color0 shr 16 and $FF) * amp0) div $FF;
     71        if Value < 256 then
     72          DstLine[xDst + ix][0] := Value
     73        else
     74          DstLine[xDst + ix][0] := 255;
     75        Value := (DstLine[xDst + ix][1] * trans + (Color2 shr 8 and $FF) * amp1
     76          + (Color0 shr 8 and $FF) * amp0) div $FF;
     77        if Value < 256 then
     78          DstLine[xDst + ix][1] := Value
     79        else
     80          DstLine[xDst + ix][1] := 255;
     81        Value := (DstLine[xDst + ix][2] * trans + (Color2 and $FF) * amp1 +
     82          (Color0 and $FF) * amp0) div $FF;
     83        if Value < 256 then
     84          DstLine[xDst + ix][2] := Value
     85        else
     86          DstLine[xDst + ix][2] := 255;
    7687      end
    7788    end
     
    8192constructor TEOTButton.Create;
    8293begin
    83 inherited Create(aOwner);
    84 Buffer:=TBitmap.Create;
    85 Buffer.PixelFormat:=pf24bit;
    86 Buffer.Width:=48;
    87 Buffer.Height:=48;
    88 Back:=TBitmap.Create;
    89 Back.PixelFormat:=pf24bit;
    90 Back.Width:=48;
    91 Back.Height:=48;
    92 ShowHint:=true;
    93 SetBounds(0,0,48,48);
     94  inherited Create(aOwner);
     95  Buffer := TBitmap.Create;
     96  Buffer.PixelFormat := pf24bit;
     97  Buffer.Width := 48;
     98  Buffer.Height := 48;
     99  Back := TBitmap.Create;
     100  Back.PixelFormat := pf24bit;
     101  Back.Width := 48;
     102  Back.Height := 48;
     103  ShowHint := true;
     104  SetBounds(0, 0, 48, 48);
    94105end;
    95106
    96107destructor TEOTButton.Destroy;
    97108begin
    98 Buffer.Free;
    99 Back.Free;
    100 inherited Destroy;
     109  Buffer.Free;
     110  Back.Free;
     111  inherited Destroy;
    101112end;
    102113
    103114procedure TEOTButton.Paint;
    104115begin
    105 with Canvas do
    106   if FGraphic<>nil then
     116  with Canvas do
     117    if FGraphic <> nil then
    107118    begin
    108     BitBlt(Buffer.Canvas.Handle,0,0,48,48,Back.Canvas.Handle,0,0,SRCCOPY);
    109     ImageOp_CBC(Buffer, Template, 0, 0, 133, 149+48*byte(FDown), 48, 48, $000000, $FFFFFF);
    110     if FIndex>=0 then
    111       ImageOp_CBC(Buffer, Template, 8, 8, 1+32*byte(FIndex), 246, 32, 32, $000000, $FFFFFF);
    112     BitBlt(Canvas.Handle,0,0,48,48,Buffer.Canvas.Handle,0,0,SRCCOPY);
     119      BitBlt(Buffer.Canvas.Handle, 0, 0, 48, 48, Back.Canvas.Handle, 0,
     120        0, SRCCOPY);
     121      ImageOp_CBC(Buffer, Template, 0, 0, 133, 149 + 48 * Byte(FDown), 48, 48,
     122        $000000, $FFFFFF);
     123      if FIndex >= 0 then
     124        ImageOp_CBC(Buffer, Template, 8, 8, 1 + 32 * Byte(FIndex), 246, 32, 32,
     125          $000000, $FFFFFF);
     126      BitBlt(Canvas.Handle, 0, 0, 48, 48, Buffer.Canvas.Handle, 0, 0, SRCCOPY);
    113127    end
    114   else begin Brush.Color:=$0000FF; FrameRect(Rect(0,0,48,48)) end
     128    else
     129    begin
     130      Brush.Color := $0000FF;
     131      FrameRect(Rect(0, 0, 48, 48))
     132    end
    115133end;
    116134
    117135procedure TEOTButton.SetIndex(x: integer);
    118136begin
    119 if x<>FIndex then
     137  if x <> FIndex then
    120138  begin
    121   FIndex:=x;
    122   Invalidate
     139    FIndex := x;
     140    Invalidate
    123141  end
    124142end;
     
    126144procedure TEOTButton.SetButtonIndexFast(x: integer);
    127145begin
    128 if Visible and (x<>FIndex) then
     146  if Visible and (x <> FIndex) then
    129147  begin
    130   FIndex:=x;
    131   try
    132     Paint
    133   except
     148    FIndex := x;
     149    try
     150      Paint
     151    except
    134152    end
    135153  end
    136154end;
    137155
    138 procedure TEOTButton.SetBack(ca: TCanvas; x,y: integer);
     156procedure TEOTButton.SetBack(ca: TCanvas; x, y: integer);
    139157begin
    140 BitBlt(Back.Canvas.Handle,0,0,48,48,ca.Handle,x,y,SRCCOPY);
     158  BitBlt(Back.Canvas.Handle, 0, 0, 48, 48, ca.Handle, x, y, SRCCOPY);
    141159end;
    142160
    143161end.
    144 
Note: See TracChangeset for help on using the changeset viewer.