home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1998 April A / Pcwk4a98.iso / PROGRAM / DELPHI16 / KTMBEVEL / KTMBEVEL.PAS < prev    next >
Pascal/Delphi Source File  |  1997-11-19  |  32KB  |  1,227 lines

  1. unit ktMBevel; { v2.1b    11/20/1997 - Bugfix in bspPortrait painting}
  2.  
  3. interface
  4.  
  5. uses
  6.     {$IFDEF    Win32} Windows,    {$ELSE}    WinTypes,    WinProcs,    {$ENDIF} Classes,
  7.     ExtCtrls,    Controls,    Graphics,    SysUtils,    Messages;
  8.  
  9. type
  10.     TBevelStyle    =    (bstLowered, bstNone,    bstRaised);
  11.     TBevelShape    =    (bspBottomLine,    bspLeftLine, bspPortrait,    bspRect, bspRightLine,
  12.                                     bspTopLine);
  13.     TBevelWidth    =    1..MaxInt;
  14.     TBorderWidth = 0..MaxInt;
  15.     TDensity = 0..100;
  16.     TShadowStyle = (ssBlack, ssCopy, ssDithered, ssMask, ssMaskNotPen, ssMerge,
  17.                                     ssMergeNotPen, ssNot,    ssNotAND,    ssNotCopy, ssNotMask,    ssNotMerge,
  18.                                     ssNotOR, ssNotXOR, ssTransparent,    ssWhite, ssXOR);
  19.     TTransparence    =    (trNone, trSemi, trTransparent);
  20.  
  21. type
  22.     TktMBevel    =    class(TGraphicControl)
  23.     private
  24.         FBevelInner: TBevelStyle;
  25.         FBevelOuter: TBevelStyle;
  26.         FBevelWidth: TBevelWidth;
  27.         FBorderWidth:    TBorderWidth;
  28.         FColor:    TColor;
  29.         FColorDensity: TDensity;
  30.         FColorFixed: Boolean;
  31.         FColorHighlight: TColor;
  32.         FColorShadow:    TColor;
  33.         FDensityDepended:    Boolean;
  34.         FEdgeSize: Integer;
  35.         FShadowColor:    TColor;
  36.         FShadowDensity:    TDensity;
  37.         FShadowed: Boolean;
  38.         FShadowOffsetX:    Integer;
  39.         FShadowOffsetY:    Integer;
  40.         FShadowStyle:    TShadowStyle;
  41.         FShape:    TBevelShape;
  42.         FTransparence: TTransparence;
  43.         TempDensity: TDensity;
  44.         procedure    SetBevelInner(Value: TBevelStyle);
  45.         procedure    SetBevelOuter(Value: TBevelStyle);
  46.         procedure    SetBevelWidth(Value: TBevelWidth);
  47.         procedure    SetBorderWidth(Value:    TBorderWidth);
  48.         procedure    SetColor(Value:    TColor);
  49.         procedure    SetColorDensity(Value: TDensity);
  50.         procedure    SetColorHighlight(Value: TColor);
  51.         procedure    SetColorFixed(Value: Boolean);
  52.         procedure    SetColorShadow(Value:    TColor);
  53.         procedure    SetDensityDepended(Value:    Boolean);
  54.         procedure    SetEdgeSize(Value: Integer);
  55.         procedure    SetShadowColor(Value:    TColor);
  56.         procedure    SetShadowDensity(Value:    TDensity);
  57.         procedure    SetShadowed(Value: Boolean);
  58.         procedure    SetShadowOffsetX(Value:    Integer);
  59.         procedure    SetShadowOffsetY(Value:    Integer);
  60.         procedure    SetShadowStyle(Value:    TShadowStyle);
  61.         procedure    SetShape(Value:    TBevelShape);
  62.         procedure    SetTransparence(Value: TTransparence);
  63.     protected
  64.         procedure    Paint; override;
  65.     public
  66.         constructor    Create(AOwner: TComponent);    override;
  67.         destructor Destroy;    override;
  68.     published
  69.         property Align;
  70.         property BevelInner: TBevelStyle read    FBevelInner    write    SetBevelInner
  71.                                 default    bstRaised;
  72.         property BevelOuter: TBevelStyle read    FBevelOuter    write    SetBevelOuter
  73.                                 default    bstLowered;
  74.         property BevelWidth: TBevelWidth read    FBevelWidth    write    SetBevelWidth    default    1;
  75.         property BorderWidth:    TBorderWidth read    FBorderWidth write SetBorderWidth
  76.                                 default    0;
  77.         property Color:    TColor read    FColor write SetColor    default    clBtnFace;
  78.         property ColorFixed: Boolean read    FColorFixed    write    SetColorFixed    default    True;
  79.         property ColorHighlight: TColor    read FColorHighlight write SetColorHighlight
  80.                                 default    clBtnHighlight;
  81.         property ColorShadow:    TColor read    FColorShadow write SetColorShadow
  82.                                 default    clBtnShadow;
  83.         property ColorDensity: TDensity    read FColorDensity write SetColorDensity
  84.                                 default    100;
  85.         property DensityDepended:    Boolean    read FDensityDepended    write
  86.                                 SetDensityDepended default True;
  87.         property EdgeSize: Integer read    FEdgeSize    write    SetEdgeSize    default    15;
  88.         property ParentShowHint;
  89.         property ShadowColor:    TColor read    FShadowColor write SetShadowColor
  90.                                 default    clGray;
  91.         property ShadowDensity:    TDensity read    FShadowDensity write SetShadowDensity
  92.                                 default    60;
  93.         property Shadowed: Boolean read    FShadowed    write    SetShadowed    default    False;
  94.         property ShadowOffsetX:    Integer    read FShadowOffsetX    write    SetShadowOffsetX
  95.                                 default    3;
  96.         property ShadowOffsetY:    Integer    read FShadowOffsetY    write    SetShadowOffsetY
  97.                                 default    3;
  98.         property ShadowStyle:    TShadowStyle read    FShadowStyle write SetShadowStyle
  99.                                 default    ssDithered;
  100.         property Shape:    TBevelShape    read FShape    write    SetShape default bspRect;
  101.         property ShowHint;
  102.         property Transparence: TTransparence read    FTransparence    write    SetTransparence
  103.                                 default    trNone;
  104.         property Visible;
  105. end;
  106.  
  107.     {    TktMultiBevel    Class    Inheritance    }
  108.  
  109.     TktMultiBevel    =    class(TktMBevel)
  110.     private
  111.     protected
  112.     public
  113.         constructor    Create(AOwner: TComponent);    override;
  114.     published
  115.         property Align;
  116.         property BevelInner;
  117.         property BevelOuter;
  118.         property BevelWidth;
  119.         property BorderWidth;
  120.         property Color;
  121.         property ColorFixed;
  122.         property ColorHighlight;
  123.         property ColorShadow;
  124.         property EdgeSize;
  125.         property ParentShowHint;
  126.         property ShadowColor;
  127.         property Shadowed;
  128.         property ShadowOffsetX;
  129.         property ShadowOffsetY;
  130.         property ShadowStyle;
  131.         property Shape;
  132.         property ShowHint;
  133.         property Transparence;
  134.         property Visible;
  135.     end;
  136.  
  137.     {    TktBevelButton Class Inheritance }
  138.  
  139.     TktBevelButton = class(TktMBevel)
  140.     private
  141.         FOnEnter:    TNotifyEvent;
  142.         FOnExit: TNotifyEvent;
  143.         FOnMouseDown:    TNotifyEvent;
  144.         FOnMouseUp:    TNotifyEvent;
  145.     protected
  146.         procedure    Paint; override;
  147.         procedure    MouseDown(Button:    TMouseButton;    Shift: TShiftState;    X, Y:    Integer);    override;
  148.         procedure    MouseUp(Button:    TMouseButton;    Shift: TShiftState;    X, Y:    Integer);    override;
  149.     public
  150.         constructor    Create(AOwner: TComponent);    override;
  151.         procedure    CMMouseEnter(var msg:TMessage);    message    CM_MOUSEENTER;
  152.         procedure    CMMouseLeave(var msg:    TMessage); message CM_MOUSELEAVE;
  153.     published
  154.         property Align;
  155.         property BevelInner;
  156.         property BevelOuter;
  157.         property BevelWidth;
  158.         property BorderWidth;
  159.         property Color;
  160.         property ColorDensity;
  161.         Property DensityDepended;
  162.         property ColorFixed;
  163.         property ColorHighlight;
  164.         property ColorShadow;
  165.         property EdgeSize;
  166.         property ParentShowHint;
  167.         property ShadowColor;
  168.         property ShadowDensity;
  169.         property Shadowed;
  170.         property ShadowOffsetX;
  171.         property ShadowOffsetY;
  172.         property ShadowStyle;
  173.         property Shape;
  174.         property ShowHint;
  175.         property Transparence;
  176.         property Visible;
  177.  
  178.         property OnClick;
  179.         property OnEnter:    TNotifyEvent read    FOnEnter write FOnEnter;
  180.         property OnExit: TNotifyEvent    read FOnExit write FOnExit;
  181.         property OnMouseDown:    TNotifyEvent read    FOnMouseDown write FOnMouseDown;
  182.         property OnMouseUp:    TNotifyEvent read    FOnMouseUp write FOnMouseUp;
  183.     end;
  184.  
  185. procedure    Register;
  186.  
  187.  
  188. implementation
  189.  
  190. {$IFDEF    Win32}
  191.     {$R    *.d32}
  192. {$ELSE}
  193.     {$R    *.d16}
  194. {$ENDIF}
  195.  
  196.  
  197. procedure    Register;
  198. begin
  199.     RegisterComponents('Samples',[TktMultiBevel, TktBevelButton]);
  200. end;
  201.  
  202. {~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}
  203.  
  204. {     Utilities    }
  205.  
  206. function Min(X,    Y: Integer): Integer;
  207. begin
  208.     if X < Y then    Result:= X else    Result:= Y;
  209. end;
  210.  
  211. function Max(X,    Y: Integer): Integer;
  212. begin
  213.     if X > Y then    Result:= X else    Result:= Y;
  214. end;
  215.  
  216. function CheckBackground(Canvas: TCanvas;    var    Rect:    TRect):    Boolean;
  217. var
  218.     x: Integer;    SColor:    TColor;
  219. begin
  220.     Result:= False;
  221.     with Canvas, Rect    do
  222.     begin
  223.         SColor:= Pixels[Left,Top];
  224.         for    x:=    Left + 1 to    Right    -    1    do
  225.         begin
  226.             Result:= abs((SColor - Pixels[x, Top]))    >    2;
  227.             if Result    =    True then    Break;
  228.         end;
  229.     end;
  230. end;
  231.  
  232. function CorrectColor(C    :    Real)    :    Integer;
  233. begin
  234.     Result :=    Round(C);
  235.     if Result    >    255    then Result    := 255;
  236.     if Result    <    0    then Result    := 0;
  237. end;
  238.  
  239. function MergeColorExt(C1, C2    :    TColor;    Grade: Byte) : TColor;
  240. var
  241.     R, G,    B    :    Real;
  242. begin
  243.     R    := (GetRValue(C1)    *    Grade    /    100    +    GetRValue(C2)    *    (100-Grade)    /    100);
  244.     G    := (GetGValue(C1)    *    Grade    /    100    +    GetGValue(C2)    *    (100-Grade)    /    100);
  245.     B    := (GetBValue(C1)    *    Grade    /    100    +    GetBValue(C2)    *    (100-Grade)    /    100);
  246.     Result :=    RGB(CorrectColor(R), CorrectColor(G),    CorrectColor(B));
  247. end;
  248.  
  249. procedure    Frame3DPortrait(Canvas:    TCanvas; var Rect: TRect;
  250.  topColor, BottomColor:    TColor;    Width: Integer;    Edge:    Integer);
  251. var
  252.     P1,    P2,    P3,    P4,    P5,    P6,    P7,    P8:    TPoint;
  253.     i: Integer;
  254. begin
  255.     dec(Rect.Bottom);
  256.     dec(Rect.Right);
  257.     for    i:=    0    to Width - 1 do
  258.     begin
  259.         with Canvas, Rect    do
  260.         begin
  261.             P1.x:= Left    +    i;
  262.             P1.y:= Bottom    -    Edge - i div 2;
  263.             P2.x:= P1.x;
  264.             P2.y:= Top + Edge    +    i    div    2;
  265.             P3.x:= Left    +    Edge + i div 2;
  266.             P3.y:= Top + i;
  267.             P4.x:= Right - Edge    -    i    div    2;
  268.             P4.y:= P3.y;
  269.             P5.x:= Right - i;
  270.             P5.y:= P2.y;
  271.             P6.x:= P5.x;
  272.             P6.y:= P1.y;
  273.             P7.x:= P4.x;
  274.             P7.y:= Bottom    -    i;
  275.             P8.x:= P3.x;
  276.             P8.y:= P7.y;
  277.             Pen.Width:=    1;
  278.             Pen.Color:=    TopColor;
  279.             PolyLine([P1,    P2,    P3,    P4,    P5]);
  280.             Pen.Color:=    BottomColor;
  281.             PolyLine([P5,    P6,    P7,    P8,    P1]);
  282.         end;
  283.     end;
  284.     for    i:=    1    to (Width    -    1) div 2 do
  285.     begin
  286.         with Canvas, Rect    do
  287.         begin
  288.             Pen.Color:=    TopColor;
  289.             P2.x:= Left    +    2*i    -    1;
  290.             P2.y:= Top + Edge    +    i;
  291.             MoveTo(Left    +    Edge + i - 1,Top + 2*i);
  292.             LineTo(P2.x,P2.y);
  293.             P5.x:= Right - 2*i + 1;
  294.             P5.y:= P2.y;
  295.             MoveTo(Right - Edge    -    i    +    1,Top    +    2*i);
  296.             LineTo(P5.x,P5.y);
  297.             Pen.Color:=    BottomColor;
  298.             P6.x:= P5.x;
  299.             P6.y:= Bottom    -    Edge - i;
  300.             MoveTo(Right - Edge    -    i    +    1,Bottom - 2*i);
  301.             LineTo(P6.x,P6.y);
  302.             P1.x:= P2.x;
  303.             P1.y:= P6.y;
  304.             MoveTo(Left    +    Edge + i - 1,Bottom    -    2*i);
  305.             LineTo(P1.x,P1.y);
  306.         end;
  307.     end;
  308. end;
  309.  
  310. procedure    EffectRect(Canvas: TCanvas;    var    Rect:    TRect; Pen:    TPen);
  311. var
  312.     i: Integer;
  313. begin
  314.     with Canvas, Rect    do
  315.     begin
  316.         if (Right    -Left) < (Bottom -Top) then
  317.         begin
  318.             for    i:=    Left to    Right    do
  319.             begin
  320.                 MoveTo(i,    Top);
  321.                 LineTo(i,    Bottom + 1);
  322.             end;
  323.         end
  324.         else
  325.         begin
  326.             for    i:=    Top    to Bottom    do
  327.             begin
  328.                 MoveTo(Left, i);
  329.                 LineTo(Right + 1,    i);
  330.             end;
  331.         end;
  332.     end;
  333. end;
  334.  
  335. procedure    DitheredRect(Canvas: TCanvas;    var    Rect:    TRect; Color:    TColor;
  336.                         Density: Integer);
  337. var
  338.     x, y:    Integer;
  339. begin
  340.     with Canvas, Rect    do
  341.     begin
  342.         for    y:=    Top    to Bottom    do
  343.             for    x:=    Left to    Right    do
  344.                 Pixels[x,    y]:= MergeColorExt(Color,    Pixels[x,    y],    Density);
  345.     end;
  346. end;
  347.  
  348. procedure    FrameDitheredRect(Canvas:    TCanvas; var Rect: TRect;
  349.      Color:    TColor;    Density, Width:    Integer);
  350. var
  351.     i, j,    k, l,    x, y:    Integer;
  352. begin
  353.     dec(Rect.Right);
  354.     dec(Rect.Bottom);
  355.     with Canvas, Rect    do
  356.     begin
  357.         i:=    Top    +    Width;
  358.         j:=    Bottom - Width;
  359.         k:=    Left + Width - 1;
  360.         l:=    Right    -    Width    +    1;
  361.         for    y:=    Top    to Bottom    do
  362.         begin
  363.             if (y    <    i) or    (y > j)    then
  364.                 for    x:=    Left to    Right    do
  365.                     Pixels[x,    y]:= MergeColorExt(Color,    Pixels[x,    y],    Density)
  366.             else
  367.             begin
  368.                 for    x:=    Left to    k    do
  369.                     Pixels[x,    y]:= MergeColorExt(Color,    Pixels[x,    y],    Density);
  370.                 for    x:=    l    to Right do
  371.                     Pixels[x,    y]:= MergeColorExt(Color,    Pixels[x,    y],    Density);
  372.             end;
  373.         end;
  374.     end;
  375. end;
  376.  
  377. procedure    FrameDitheredPortrait(Canvas:    TCanvas; var Rect: TRect;
  378.      Color:    TColor;    Density, Width,    Edge:    Integer);
  379. var
  380.     P1,    P2,    P3,    P4:    TPoint;
  381.     i, j,    k, l,    m, x:    Integer;
  382.  
  383. begin
  384.     dec(Rect.Bottom);    dec(Rect.Right);
  385.     with Canvas, Rect    do
  386.     begin
  387.         j:=    Bottom - Top;
  388.         for    i:=    1    to Width do
  389.         begin
  390.             P1.x:= Left    +    Edge - i;
  391.             P1.y:= Top + i - 1;
  392.             P2.x:= Right - Edge    +    i;
  393.             for    x:=    P1.x to    P2.x do
  394.                  Pixels[x, P1.y]:= MergeColorExt(Color,    Pixels[x,    P1.y], Density);
  395.         end;
  396.         m:=    i;
  397.         for    i:=    m    to Edge    +    Width    div    3    do
  398.         begin
  399.             if i <=    Edge then
  400.             begin
  401.                 P1.x:= Left    +    Edge - i;
  402.                 P2.x:= Right - Edge    +    i;
  403.                 P3.x:= P1.x    +    Width    +    Width    div    3;
  404.                 P4.x:= P2.x    -    Width    -    Width    div    3;
  405.             end
  406.             else
  407.             begin
  408.                 P1.x:= Left;
  409.                 P2.x:= Right;
  410.                 P3.x:= P1.x    +    Width    +    Width    div    3    -    (i - Edge);
  411.                 P4.x:= P2.x    -    Width    -    Width    div    3    +    (i - Edge);
  412.             end;
  413.             P1.y:= Top + i - 1;
  414.             for    x:=    P1.x to    P3.x do
  415.                  Pixels[x, P1.y]:= MergeColorExt(Color,    Pixels[x,    P1.y], Density);
  416.             for    x:=    P4.x to    P2.x do
  417.                  Pixels[x, P1.y]:= MergeColorExt(Color,    Pixels[x,    P1.y], Density);
  418.         end;
  419.         m:=    i;
  420.         for    i:=    m    to j - Edge    -    (Width)    div    3    +    1    do
  421.         begin
  422.             P1.x:= Left;
  423.             P2.x:= Right;
  424.             P3.x:= Left    +    Width    -    1;
  425.             P4.x:= P2.x    -    Width    +    1;
  426.             P1.y:= Top + i - 1;
  427.             for    x:=    P1.x to    P3.x do
  428.                  Pixels[x, P1.y]:= MergeColorExt(Color,    Pixels[x,    P1.y], Density);
  429.             for    x:=    P4.x to    P2.x do
  430.                  Pixels[x, P1.y]:= MergeColorExt(Color,    Pixels[x,    P1.y], Density);
  431.         end;
  432.         m:=    i;
  433.         k:=    0;
  434.         for    i:=    m    to j - Width + 1 do
  435.         begin
  436.             l:=    i    -    m;
  437.             begin
  438.                 if i <=    j    -    Edge + 1 then
  439.                 begin
  440.                     P1.x:= Left;
  441.                     P2.x:= Right;
  442.                     P3.x:= P1.x    +    Width    +    l;
  443.                     P4.x:= P2.x    -    Width    -    l    ;
  444.                 end
  445.                 else
  446.                 begin
  447.                     P1.x:= Left    +    k;
  448.                     P2.x:= Right - k;
  449.                     P3.x:= P1.x    +    Width    +    Width    div    3;
  450.                     P4.x:= P2.x    -    Width    -    Width    div    3;
  451.                     inc(k);
  452.                 end;
  453.                 P1.y:= Top + i - 1;
  454.                 for    x:=    P1.x to    P3.x do
  455.                     Pixels[x,    P1.y]:=    MergeColorExt(Color, Pixels[x, P1.y],    Density);
  456.                 for    x:=    P4.x to    P2.x do
  457.                     Pixels[x,    P1.y]:=    MergeColorExt(Color, Pixels[x, P1.y],    Density);
  458.             end;
  459.         end;
  460.         m:=    i;
  461.         for    i:=    m    to j + 1 do
  462.         begin
  463.             P1.x:= Left    +    k;
  464.             P2.x:= Right - k;
  465.             inc(k);
  466.             P1.y:= Top + i - 1;
  467.             for    x:=    P1.x to    P2.x do
  468.                  Pixels[x, P1.y]:= MergeColorExt(Color,    Pixels[x,    P1.y], Density);
  469.         end;
  470.     end;
  471. end;
  472.  
  473. {     TktMBevel    }
  474.  
  475. constructor     TktMBevel.Create(AOwner:    TComponent);
  476. begin
  477.     inherited    Create(AOwner);
  478.         FBevelInner:=    bstRaised;
  479.         FBevelOuter:=    bstLowered;
  480.         FBevelWidth:=    1;
  481.         FBorderWidth:= 0;
  482.         FColor:= clBtnFace;
  483.         FColorDensity:=    100;
  484.         FColorFixed:=    True;
  485.         FColorHighlight:=    clBtnHighlight;
  486.         FColorShadow:= clBtnShadow;
  487.         FDensityDepended:= True;
  488.         FShadowDensity:= 50;
  489.         FEdgeSize:=    15;
  490.         Height:= 50;
  491.         FShadowColor:= clGray;
  492.         FShadowDensity:= 60;
  493.         FShadowed:=    False;
  494.         FShadowOffsetX:= 3;
  495.         FShadowOffsetY:= 3;
  496.         FShadowStyle:= ssDithered;
  497.         FShape:= bspRect;
  498.         FTransparence:=    trNone;
  499.         TempDensity:=    50;
  500.         Width:=    75;
  501. end;
  502.  
  503. destructor TktMBevel.Destroy;
  504. begin
  505.     inherited    Destroy;
  506. end;
  507.  
  508. procedure    TktMBevel.SetBevelInner(Value: TBevelStyle);
  509. begin
  510.     if Value <>    FBevelInner    then
  511.     begin
  512.         FBevelInner:=    Value;
  513.         Invalidate;
  514.     end;
  515. end;
  516.  
  517. procedure    TktMBevel.SetBevelOuter(Value: TBevelStyle);
  518. begin
  519.     if Value <>    FBevelOuter    then
  520.     begin
  521.         FBevelOuter:=    Value;
  522.         Invalidate;
  523.     end;
  524. end;
  525.  
  526. procedure    TktMBevel.SetBevelWidth(Value: TBevelWidth);
  527. begin
  528.     if Value <>    FBevelWidth    then
  529.     begin
  530.         FBevelWidth:=    Value;
  531.         Invalidate;
  532.     end;
  533. end;
  534.  
  535. procedure    TktMBevel.SetBorderWidth(Value:    TBorderWidth);
  536. begin
  537.     if Value <>    FBorderWidth then
  538.     begin
  539.         FBorderWidth:= Value;
  540.         Invalidate;
  541.     end;
  542. end;
  543.  
  544. procedure    TktMBevel.SetColor(Value:    TColor);
  545. begin
  546.     if FColor    <> Value then    FColor:= Value;
  547.     if FColorFixed then
  548.     begin
  549.         if FColor    =    clBtnFace    then
  550.         begin
  551.             FColorHighlight:=    clBtnHighlight;
  552.             FColorShadow:= clBtnShadow;
  553.         end
  554.         else
  555.         begin
  556.             FColorHighlight:=    MergeColorExt(FColor,clWhite,33);
  557.             FColorShadow:= MergeColorExt(FColor,clBlack,66);
  558.         end;
  559.     end;
  560.     Invalidate;
  561. end;
  562.  
  563. procedure    TktMBevel.SetColorDensity(Value: TDensity);
  564. begin
  565.     if FColorDensity <>    Value    then
  566.     begin
  567.         FColorDensity:=    Value;
  568.         if FTransparence = trSemi    then TempDensity:= Value;
  569.         if    FDensityDepended then    FShadowDensity:= Round(FColorDensity * 60    /    100);
  570.         Invalidate;
  571.     end;
  572. end;
  573.  
  574. procedure    TktMBevel.SetColorHighlight(Value: TColor);
  575. begin
  576.     if not FColorFixed then
  577.     begin
  578.         if Value <>    FColorHighlight    then
  579.         begin
  580.             FColorHighlight:=    Value;
  581.             Invalidate;
  582.         end;
  583.     end;
  584. end;
  585.  
  586. procedure    TktMBevel.SetColorShadow(Value:    TColor);
  587. begin
  588.     if not FColorFixed then
  589.     begin
  590.         if Value <>    FColorShadow then
  591.         begin
  592.             FColorShadow:= Value;
  593.             Invalidate;
  594.         end;
  595.     end;
  596. end;
  597.  
  598. procedure    TktMBevel.SetColorFixed(Value: Boolean);
  599. begin
  600.     if Value <>    FColorFixed    then FColorFixed:= Value;
  601.     if FColorFixed then    SetColor(FColor)
  602.         else Invalidate;
  603. end;
  604.  
  605. procedure    TktMBevel.SetDensityDepended(Value:    Boolean);
  606. var    d: TDensity;
  607. begin
  608.     if Value <>    FDensityDepended then
  609.     begin
  610.         FDensityDepended:= Value;
  611.         d:=    Round(FColorDensity    *    60 / 100);
  612.         if (FDensityDepended = True) and (FShadowDensity <>    d) then
  613.         begin
  614.             FShadowDensity:= d;
  615.             if FShadowStyle    =    ssDithered then    Invalidate;
  616.         end;
  617.     end;
  618. end;
  619.  
  620. procedure    TktMBevel.SetEdgeSize(Value: Integer);
  621. begin
  622.     if Value <>    FEdgeSize    then
  623.     begin
  624.         FEdgeSize:=    Value;
  625.         Invalidate;
  626.     end;
  627. end;
  628.  
  629. procedure    TktMBevel.SetShadowColor(Value:    TColor);
  630. begin
  631.     if Value <>    FShadowColor then
  632.     begin
  633.         FShadowColor:= Value;
  634.         Invalidate;
  635.     end;
  636. end;
  637.  
  638. procedure    TktMBevel.SetShadowDensity(Value:    TDensity);
  639. begin
  640.     if not FDensityDepended    then
  641.     begin
  642.         if Value <>    FShadowDensity then
  643.         begin
  644.             FShadowDensity:= Value;
  645.             Invalidate;
  646.         end;
  647.     end;
  648. end;
  649.  
  650. procedure    TktMBevel.SetShadowed(Value: Boolean);
  651. begin
  652.     if (Value    <> FShadowed)    and    (FTransparence <>    trTransparent) then
  653.     begin
  654.         FShadowed:=    Value;
  655.         Invalidate;
  656.     end;
  657. end;
  658.  
  659. procedure    TktMBevel.SetShadowOffsetX(Value:    Integer);
  660. begin
  661.     if Value <>    FShadowOffsetX then
  662.     begin
  663.         FShadowOffsetX:= Value;
  664.         Invalidate;
  665.     end;
  666. end;
  667.  
  668. procedure    TktMBevel.SetShadowOffsetY(Value:    Integer);
  669. begin
  670.     if Value <>    FShadowOffsetY then
  671.     begin
  672.         FShadowOffsetY:= Value;
  673.         Invalidate;
  674.     end;
  675. end;
  676.  
  677. procedure    TktMBevel.SetShadowStyle(Value:    TShadowStyle);
  678. begin
  679.     if Value <>    FShadowStyle then
  680.     begin
  681.         FShadowStyle:= Value;
  682.         Invalidate;
  683.     end;
  684. end;
  685.  
  686. procedure    TktMBevel.SetShape(Value:    TBevelShape);
  687. begin
  688.     if Value <>    FShape then
  689.     begin
  690.         FShape:= Value;
  691.         Invalidate;
  692.     end;
  693. end;
  694.  
  695. procedure    TktMBevel.SetTransparence(Value: TTransparence);
  696. begin
  697.     if Value <>    FTransparence    then
  698.     begin
  699.         FTransparence:=    Value;
  700.         case FTransparence of
  701.             trTransparent    :    begin
  702.                                                 FShadowed:=    False;
  703.                                                 SetColorDensity(0);
  704.                                             end;
  705.             trNone                :    SetColorDensity(100);
  706.             trSemi                :    SetColorDensity(TempDensity);
  707.         end;
  708.     end;
  709. end;
  710.  
  711. procedure    TktMBevel.Paint;
  712. var
  713.     Rc,    RectA: TRect;
  714.     s, s1, s2, ox, oy: Integer;
  715.     P1,    P2,    P3,    P4,    P5:    TPoint;
  716.  
  717.     procedure    CalcShadow;
  718.     begin
  719.         case FShape    of
  720.             bspTopLine     : begin
  721.                                                 P1.x:= max(ox, 0);
  722.                                                 P1.y:= max(oy, 0);
  723.                                                 P2.x:= min(Rc.Right, Rc.Right    +    ox);
  724.                                                 P2.y:= P1.y    +    s    -    1;
  725.                                             end;
  726.             bspBottomLine    :    begin
  727.                                                 P1.x:= max(ox, 0);
  728.                                                 P2.y:= min(Rc.Bottom + oy    -    1, Rc.Bottom - 1);
  729.                                                 P2.x:= min(Rc.Right, Rc.Right    +    ox);
  730.                                                 P1.y:= P2.y    -    s    +    1;
  731.                                             end;
  732.             bspLeftLine        :    begin
  733.                                                 P1.x:= max(ox, 0);
  734.                                                 P1.y:= max(oy, 0);
  735.                                                 P2.x:= P1.x    +    s    -    1;
  736.                                                 P2.y:= min(Rc.Bottom - 1,    Rc.Bottom    +    oy - 1);
  737.                                             end;
  738.             bspRightLine : begin
  739.                                                 P2.x:= min(Rc.Right    -    1, Rc.Right    +    ox - 1);
  740.                                                 P1.y:= max(oy, 0);
  741.                                                 P1.x:= P2.x    -    s    +    1;
  742.                                                 P2.y:= min(Rc.Bottom + oy    -    1, Rc.Bottom - 1);
  743.                                             end;
  744.             bspPortrait,
  745.             bspRect                :    begin
  746.                                                 P1.x:= max(ox, 0);
  747.                                                 P1.y:= max(oy, 0);
  748.                                                 P2.x:= min(Rc.Right, Rc.Right    +    ox);
  749.                                                 P2.y:= min(Rc.Bottom,    Rc.Bottom    +    oy);
  750.                                             end;
  751.         end;
  752.         P3.x:= P2.x;
  753.         P3.y:= P1.y;
  754.         P4.x:= P1.x;
  755.         P4.y:= P2.y;
  756.         P5:= P1;
  757.         RectA:=    rect(P1.x, P1.y, P2.x, P2.y);
  758.     end;
  759.  
  760.     procedure    PaintDithered;
  761.     begin
  762.         with Canvas    do
  763.         begin
  764.             Pen.Mode:= pmCopy;
  765.             case Shape of
  766.                 bspBottomLine,
  767.                 bspLeftLine,
  768.                 bspRightLine,
  769.                 bspTopLine        :    DitheredRect(Canvas, RectA,    FShadowColor,    FShadowDensity);
  770.                 bspRect                :    FrameDitheredRect(Canvas,    RectA, FShadowColor, FShadowDensity, s);
  771.                 bspPortrait        :    FrameDitheredPortrait(Canvas,    RectA, FShadowColor, FShadowDensity,
  772.                                                     s, FEdgeSize);
  773.             end;
  774.         end;
  775.     end;
  776.  
  777.     procedure    PaintShadow;
  778.     var
  779.         i: Integer;
  780.     begin
  781.         with Canvas    do
  782.         begin
  783.             Pen.Width:=    1;
  784.             Pen.Color:=    FShadowColor;
  785.             case FShadowStyle    of
  786.                 ssBlack                :    Pen.Mode:= pmBlack;
  787.                 ssCopy                :    Pen.Mode:= pmCopy;
  788.                 ssDithered        :    begin
  789.                                                     if CheckBackGround(Canvas, RectA)    then
  790.                                                     begin
  791.                                                         PaintDithered;
  792.                                                         Exit;
  793.                                                     end
  794.                                                     else
  795.                                                     begin
  796.                                                         Pen.Mode:= pmCopy;
  797.                                                         Pen.Color:=    MergeColorExt(FShadowColor,
  798.                                                                     Pixels[RectA.Left, RectA.Top],FShadowDensity);
  799.                                                     end;
  800.                                                 end;
  801.                 ssMask                :    Pen.Mode:= pmMask;
  802.                 ssMaskNotPen    :    Pen.Mode:= pmMaskNotPen;
  803.                 ssMerge                :    Pen.Mode:= pmMerge;
  804.                 ssMergeNotPen    :    Pen.Mode:= pmMergeNotPen;
  805.                 ssNot                    :    Pen.Mode:= pmNot;
  806.                 ssNotAND            :    Pen.Mode:= pmMaskPenNot;
  807.                 ssNotCopy            :    Pen.Mode:= pmNotCopy;
  808.                 ssNotMask            :    Pen.Mode:= pmNotMask;
  809.                 ssNotMerge        :    Pen.Mode:= pmNotMerge;
  810.                 ssNotOR                :    Pen.Mode:= pmMergePenNot;
  811.                 ssNotXOR            :    Pen.Mode:= pmNotXor;
  812.                 ssTransparent    :    Pen.Mode:= pmNop;
  813.                 ssWhite                :    Pen.Mode:= pmWhite;
  814.                 ssXOR                    :    Pen.Mode:= pmXor;
  815.             end;
  816.             case FShape    of
  817.                 bspRect                :    begin
  818.                                                     for    i:=    1    to s do
  819.                                                     begin
  820.                                                         dec(P2.x);
  821.                                                         dec(P2.y);
  822.                                                         P3.x:= P2.x;
  823.                                                         P4.y:= P2.y;
  824.                                                         PolyLine([P1,    P3,    P2,    P4,    P1]);
  825.                                                         inc(P1.x);
  826.                                                         inc(P1.y);
  827.                                                         P3.y:= P1.y;
  828.                                                         P4.x:= P1.x;
  829.                                                     end;
  830.                                                 end;
  831.                 bspPortrait        :    Frame3DPortrait(Canvas,    RectA, Pen.Color, Pen.Color,
  832.                                                     s, FEdgeSize);
  833.                 bspBottomLine,
  834.                 bspLeftLine,
  835.                 bspRightLine,
  836.                 bspTopLine     : EffectRect(Canvas,    RectA, Pen);
  837.             end;
  838.             Pen.Mode:= pmCopy;
  839.             Pen.Style:=    psSolid;
  840.         end;
  841.     end;
  842.  
  843.     procedure    CalcBevelOuter;
  844.     begin
  845.         case FShape    of
  846.             bspTopLine     : begin
  847.                                                 P1.x:= max(-ox,    0);
  848.                                                 P1.y:= max(-oy,    0);
  849.                                                 P2.x:= min(Rc.Right, Rc.Right    -    ox);
  850.                                                 P2.y:= P1.y    +    s;
  851.                                             end;
  852.             bspBottomLine    :    begin
  853.                                                 P1.x:= max(-ox,    0);
  854.                                                 P2.y:= min(Rc.Bottom,    Rc.Bottom    -    oy);
  855.                                                 P2.x:= min(Rc.Right, Rc.Right    -    ox);
  856.                                                 P1.y:= P2.y    -    s;
  857.                                             end;
  858.             bspLeftLine        :    begin
  859.                                                 P1.x:= max(-ox,    0);
  860.                                                 P1.y:= max(-oy,    0);
  861.                                                 P2.x:= P1.x    +    s;
  862.                                                 P2.y:= min(Rc.Bottom,    Rc.Bottom    -    oy);
  863.                                             end;
  864.             bspRightLine : begin
  865.                                                 P2.x:= min(Rc.Right, Rc.Right    -    ox);
  866.                                                 P1.y:= max(-oy,    0);
  867.                                                 P1.x:= P2.x    -    s;
  868.                                                 P2.y:= min(Rc.Bottom,    Rc.Bottom    -    oy);
  869.                                             end;
  870.             bspRect, bspPortrait:    begin
  871.                                                             P1.x:= max(-ox,    0);
  872.                                                             P1.y:= max(-oy,    0);
  873.                                                             P2.x:= min(Rc.Right, Rc.Right    -    ox);
  874.                                                             P2.y:= min(Rc.Bottom,    Rc.Bottom    -    oy);
  875.                                                         end;
  876.         end;
  877.         RectA:=    rect(P1.x, P1.y, P2.x, P2.y);
  878.     end;
  879.  
  880.     procedure    PaintBevelOuter;
  881.     begin
  882.         with Canvas, RectA do
  883.         begin
  884.             if FShape    =    bspPortrait    then
  885.             begin
  886.                 case FBevelOuter of
  887.                     bstLowered:    Frame3DPortrait(Canvas,    RectA, FColorShadow, FColorHighlight,
  888.                                                 FBevelWidth, FEdgeSize);
  889.                     bstRaised    :    Frame3DPortrait(Canvas,    RectA, FColorHighlight,    FColorShadow,
  890.                                                 FBevelWidth, FEdgeSize);
  891.                 end;
  892.             end
  893.             else
  894.             case FBevelOuter of
  895.                 bstLowered:    Frame3D(Canvas,    RectA, FColorShadow, FColorHighlight,    FBevelWidth);
  896.                 bstRaised    :    Frame3D(Canvas,    RectA, FColorHighlight,    FColorShadow,    FBevelWidth);
  897.             end;
  898.         end;
  899.     end;
  900.  
  901.     procedure    CalcBorder;
  902.     var    v: Integer;
  903.     begin
  904.         if FBevelOuter <>    bstNone    then
  905.         begin
  906.             case FShape    of
  907.                 bspTopLine     : begin
  908.                                                     P1.x:= max(FBevelWidth - ox, FBevelWidth);
  909.                                                     P1.y:= max(FBevelWidth - oy, FBevelWidth);
  910.                                                     P2.x:= min(Rc.Right    -    FBevelWidth    -    1, Rc.Right    -    ox
  911.                                                                      - FBevelWidth - 1);
  912.                                                     P2.y:= P1.y    +    FBorderwidth - 1;
  913.                                                 end;
  914.                 bspBottomLine    :    begin
  915.                                                     P1.x:= max(FBevelWidth - ox, FBevelWidth);
  916.                                                     P2.y:= min(Rc.Bottom - 1 - FBevelWidth,    Rc.Bottom    -    1
  917.                                                                         -    oy - FBevelWidth);
  918.                                                     P2.x:= min(Rc.Right    -    1    -    FBevelWidth, Rc.Right     - 1
  919.                                                                         -    ox - FBevelWidth);
  920.                                                     P1.y:= P2.y    -    FBorderwidth + 1;
  921.                                                 end;
  922.                 bspLeftLine        :    begin
  923.                                                     P1.x:= max(FBevelWidth - ox, FBevelWidth);
  924.                                                     P1.y:= max(FBevelWidth - oy, FBevelWidth);
  925.                                                     P2.x:= P1.x    +    FBorderWidth - 1;
  926.                                                     P2.y:= min(Rc.Bottom - FBevelWidth - 1,    Rc.Bottom    -    oy
  927.                                                                  - FBevelWidth - 1);
  928.                                                 end;
  929.                 bspRightLine : begin
  930.                                                     P2.x:= min(Rc.Right    -    FBevelWidth    -    1, Rc.Right    -    ox
  931.                                                                  - FBevelWidth - 1);
  932.                                                     P1.y:= max(FBevelWidth - oy, FBevelWidth);
  933.                                                     P1.x:= P2.x    -    FBorderWidth + 1;
  934.                                                     P2.y:= min(Rc.Bottom - FBevelWidth - 1,    Rc.Bottom    -    oy
  935.                                                                  - FBevelWidth - 1);
  936.                                                 end;
  937.                 bspRect, bspPortrait:    begin
  938.                                                                 P1.x:= max(FBevelWidth - ox, FBevelWidth);
  939.                                                                 P1.y:= max(FBevelWidth - oy, FBevelWidth);
  940.                                                                 P2.x:= min(Rc.Right    -    FBevelWidth, Rc.Right    -    ox
  941.                                                                                  - FBevelWidth);
  942.                                                                 P2.y:= min(Rc.Bottom - FBevelWidth,    Rc.Bottom    -    oy
  943.                                                                                  - FBevelWidth);
  944.                                                             end;
  945.             end;
  946.         end
  947.         else
  948.         begin
  949.             case FShape    of
  950.                 bspTopLine     : begin
  951.                                                     P1.x:= max(- ox, 0);
  952.                                                     P1.y:= max(- oy, 0);
  953.                                                     P2.x:= min(Rc.Right    -    1, Rc.Right    -    1    -    ox);
  954.                                                     P2.y:= P1.y    +    FBorderwidth - 1;
  955.                                                 end;
  956.                 bspBottomLine    :    begin
  957.                                                     P1.x:= max(- ox, 0);
  958.                                                     P2.y:= min(Rc.Bottom - 1,    Rc.Bottom    -    1    -    oy);
  959.                                                     P2.x:= min(Rc.Right    -    1, Rc.Right    -    1    -    ox);
  960.                                                     P1.y:= P2.y    -    FBorderwidth + 1;
  961.                                                 end;
  962.                 bspLeftLine        :    begin
  963.                                                     P1.x:= max(- ox, 0);
  964.                                                     P1.y:= max(- oy, 0);
  965.                                                     P2.x:= P1.x    +    FBorderWidth - 1;
  966.                                                     P2.y:= min(Rc.Bottom - 1,    Rc.Bottom    -    1    -    oy);
  967.                                                 end;
  968.                 bspRightLine : begin
  969.                                                     P2.x:= min(Rc.Right, Rc.Right    -    ox);
  970.                                                     P1.y:= max(- oy, 0);
  971.                                                     P1.x:= P2.x    -    FBorderWidth + 1;
  972.                                                     P2.y:= min(Rc.Bottom - 1,    Rc.Bottom    -    1    -    oy);
  973.                                                 end;
  974.                 bspRect, bspPortrait:    begin
  975.                                                                 P1.x:= max(-ox,    0);
  976.                                                                 P1.y:= max(-oy,    0);
  977.                                                                 P2.x:= min(Rc.Right, Rc.Right    -    ox);
  978.                                                                 P2.y:= min(Rc.Bottom,    Rc.Bottom    -    oy);
  979.                                                             end;
  980.             end;
  981.         end;
  982.         RectA:=    rect(P1.x, P1.y, P2.x, P2.y);
  983.     end;
  984.  
  985.     procedure    PaintDitheredBorder;
  986.     begin
  987.         case FShape    of
  988.             bspPortrait        :    if FBevelOuter <>    bstNone    then
  989.                                                 FrameDitheredPortrait(Canvas,    RectA, FColor, FColorDensity,
  990.                                                     FBorderWidth,    FEdgeSize    -    (FBevelWidth)    div    2)
  991.                                             else
  992.                                                 FrameDitheredPortrait(Canvas,    RectA, FColor, FColorDensity,
  993.                                                     FBorderWidth,    FEdgeSize);
  994.             bspRect                :    FrameDitheredRect(Canvas,    RectA, FColor, FColorDensity,
  995.                                                 FBorderWidth);
  996.             bspBottomLine,
  997.             bspLeftLine,
  998.             bspRightLine,
  999.             bspTopLine     : DitheredRect(Canvas,    RectA, FColor, FColorDensity);
  1000.         end;
  1001.     end;
  1002.  
  1003.     procedure    PaintFilledBorder(Color: TColor);
  1004.     var
  1005.         i: Integer;
  1006.     begin
  1007.         with Canvas    do
  1008.         case FShape    of
  1009.             bspPortrait        :    Frame3DPortrait(Canvas,    RectA, Color,    Color, FBorderWidth,
  1010.                                                 FEdgeSize    -    FBevelWidth    div    2    -    1);
  1011.             bspRect                :    begin
  1012.                                                 Brush.Color:=    Color;
  1013.                                                 for    i:=    1    to FBorderWidth    do
  1014.                                                 begin
  1015.                                                     FrameRect(RectA);
  1016.                                                     inc(P1.x);
  1017.                                                     inc(P1.y);
  1018.                                                     dec(P2.x);
  1019.                                                     dec(P2.y);
  1020.                                                     RectA:=    rect(P1.x, P1.y, P2.x, P2.y);
  1021.                                                 end;
  1022.                                             end;
  1023.             bspBottomLine,
  1024.             bspLeftLine,
  1025.             bspRightLine,
  1026.             bspTopLine        :    begin
  1027.                                                 Pen.Width:=    1;
  1028.                                                 Pen.Color:=    Color;
  1029.                                                 Pen.Mode:= pmCopy;
  1030.                                                 EffectRect(Canvas, RectA,    Pen);
  1031.                                             end;
  1032.         end;
  1033.     end;
  1034.  
  1035.     procedure    PaintBorder;
  1036.     begin
  1037.         with Canvas, RectA do
  1038.         begin
  1039.             if (FTransparence    =    trSemi)    or (FColorDensity    <    100) then
  1040.             begin
  1041.                 if FShadowed or    CheckBackGround(Canvas,    RectA) then    PaintDitheredBorder
  1042.                 else
  1043.                     PaintFilledBorder(MergeColorExt(FColor,    Pixels[RectA.Left, RectA.Top],
  1044.                         FColorDensity));
  1045.             end
  1046.             else PaintFilledBorder(FColor);
  1047.         end;
  1048.     end;
  1049.  
  1050.     procedure    CalcBevelInner;
  1051.     begin
  1052.             P1.x:= max(s1    -    ox,    s1);
  1053.             P1.y:= max(s1    -    oy,    s1);
  1054.             P2.x:= min(Rc.Right    -    s1,    Rc.Right - ox    -    s1);
  1055.             P2.y:= min(Rc.Bottom - s1, Rc.Bottom - oy    -    s1);
  1056.             RectA:=    rect(P1.x, P1.y, P2.x, P2.y);
  1057.     end;
  1058.  
  1059.     procedure    PaintBevelInner;
  1060.     var    E: Integer;
  1061.     begin
  1062.         with Canvas, RectA do
  1063.         begin
  1064.             if Shape = bspPortrait then
  1065.             begin
  1066.                 if FBorderWidth    >    0    then
  1067.                 begin
  1068.                     if FBevelOuter <>    bstNone    then
  1069.                         E:=    FEdgeSize    -    (FBevelWidth + 2)    div    2    -    (FBorderWidth    +    2) div 2
  1070.                     else
  1071.                         E:=    FEdgeSize    -    1    -    (FBorderWidth    +    2) div 2;
  1072.                 end
  1073.                 else
  1074.                 begin
  1075.                     if FBevelOuter <>    bstNone    then
  1076.                         E:=    FEdgeSize    -    (FBevelWidth + 2)    div    2
  1077.                     else
  1078.                         E:=    FEdgeSize;
  1079.                 end;
  1080.                 case FBevelInner of
  1081.                     bstLowered:    Frame3DPortrait(Canvas,    RectA, FColorShadow, FColorHighlight,
  1082.                                                 FBevelWidth, E);
  1083.                     bstRaised    :    Frame3DPortrait(Canvas,    RectA, FColorHighlight,    FColorShadow,
  1084.                                                 FBevelWidth, E);
  1085.                 end;
  1086.             end
  1087.             else
  1088.             case FBevelInner of
  1089.                 bstLowered:    Frame3D(Canvas,    RectA, FColorShadow, FColorHighlight,    FBevelWidth);
  1090.                 bstRaised    :    Frame3D(Canvas,    RectA, FColorHighlight,    FColorShadow,    FBevelWidth);
  1091.             end;
  1092.         end;
  1093.     end;
  1094.  
  1095.     procedure    BevelRect;
  1096.     begin
  1097.         if (FBevelInner    <> bstNone)    and    ((FShape = bspRect)    or
  1098.                 (FShape    =    bspPortrait))    then s2:=    FBevelWidth
  1099.             else s2:=    0;
  1100.         if FBevelOuter = bstNone then    s1:= FBorderWidth
  1101.             else
  1102.             case FShape    of
  1103.                 bspRect,bspPortrait    :    s1:= FBevelWidth + FBorderWidth;
  1104.                 bspBottomLine, bspLeftLine,    bspRightLine,    bspTopLine:
  1105.                                 s1:= 2*FBevelWidth + FBorderWidth;
  1106.             end;
  1107.         s:=    s1 + s2;
  1108.         if not FShadowed then
  1109.         begin
  1110.             ox:= 0;
  1111.             oy:= 0;
  1112.         end
  1113.         else
  1114.         begin
  1115.             if s > 0 then
  1116.             begin
  1117.                 ox:= FShadowOffsetX;
  1118.                 oy:= FShadowOffsetY;
  1119.                 CalcShadow;
  1120.                 PaintShadow;
  1121.             end;
  1122.         end;
  1123.     if (FBorderWidth > 0)    and    (FTransparence <>    trTransparent) then
  1124.         begin
  1125.             CalcBorder;
  1126.             PaintBorder;
  1127.         end;
  1128.         if FBevelOuter <>    bstNone    then
  1129.         begin
  1130.             CalcBevelOuter;
  1131.             PaintBevelOuter;
  1132.         end;
  1133.         if (FBevelInner    <> bstNone)
  1134.             and    ((FShape = bspRect)    or (FShape = bspPortrait)) then
  1135.         begin
  1136.             CalcBevelInner;
  1137.             PaintBevelInner;
  1138.         end;
  1139.     end;
  1140.  
  1141. begin
  1142.     Rc:= GetClientRect;
  1143.     BevelRect;
  1144. end;
  1145.  
  1146. {    TktMultiBevel    }
  1147.  
  1148. constructor    TktMultiBevel.Create(AOwner: TComponent);
  1149. begin
  1150.     inherited    Create(AOwner);
  1151. end;
  1152.  
  1153. {    TktBevelButton    }
  1154.  
  1155. constructor    TktBevelButton.Create(AOwner:    TComponent);
  1156. begin
  1157.     inherited    Create(AOwner);
  1158.     ControlStyle:= [csCaptureMouse,    csClickEvents, csFramed];
  1159.     FBevelOuter:=    bstNone;
  1160.     Height:= 35;
  1161.     Width:=    90;
  1162. end;
  1163.  
  1164. procedure    TktBevelButton.Paint;
  1165. var
  1166.     RectA, Rc: TRect;
  1167.     P1,    P2:    TPoint;
  1168.     ox,    oy:    Integer;
  1169. begin
  1170.     inherited    Paint;
  1171.     if csDesigning in    ComponentState then
  1172.     begin
  1173.         Rc:= GetClientRect;
  1174.         if not FShadowed then
  1175.         begin
  1176.             P1.x:= Rc.Left;
  1177.             P1.y:= Rc.Top;
  1178.             P2.x:= Rc.Right;
  1179.             P2.y:= Rc.Bottom;
  1180.         end
  1181.         else
  1182.         begin
  1183.             ox:= FShadowOffsetX;
  1184.             oy:= FShadowOffsetY;
  1185.             P1.x:= max(-ox,    0);
  1186.             P1.y:= max(-oy,    0);
  1187.             P2.x:= min(Rc.Right, Rc.Right    -    ox);
  1188.             P2.y:= min(Rc.Bottom,    Rc.Bottom    -    oy);
  1189.         end;
  1190.         RectA:=    Rect(P1.x, P1.y, P2.x, P2.y);
  1191.         Frame3D(Canvas,    RectA, clBlack,    clBlack, 1);
  1192.      end;
  1193. end;
  1194.  
  1195. procedure    TktBevelButton.MouseDown(Button: TMouseButton; Shift:    TShiftState;
  1196.                 X, Y:    Integer);
  1197. begin
  1198.     SetBevelOuter(bstLowered);
  1199.     inherited    MouseDown(Button,    Shift, X,    Y);
  1200.     if Assigned(FOnMouseDown)    then FOnMouseDown(Self);
  1201. end;
  1202.  
  1203. procedure    TktBevelButton.MouseUp(Button: TMouseButton; Shift:    TShiftState;
  1204.                 X, Y:    Integer);
  1205. begin
  1206.     SetBevelOuter(bstRaised);
  1207.     inherited    MouseUp(Button,    Shift, X,    Y);;
  1208.     if Assigned(FOnMouseUp)    then FOnMouseUp(Self);
  1209. end;
  1210.  
  1211. procedure    TktBevelButton.CMMouseEnter(var    msg:TMessage);
  1212. begin
  1213.     inherited;
  1214.     SetBevelOuter(bstRaised);
  1215.     if Assigned(FOnEnter)    then FOnEnter(Self);
  1216. end;
  1217.  
  1218. procedure    TktBevelButton.CMMouseLeave(var    msg: TMessage);
  1219. begin
  1220.     inherited;
  1221.     SetBevelOuter(bstNone);
  1222.     if Assigned(FOnExit) then    FOnExit(Self);
  1223. end;
  1224.  
  1225. end.
  1226.  
  1227.