home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / AddOns / Components / Essentials / SETUP.EXE / %MAINDIR% / Eslabel.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1998-11-28  |  27.5 KB  |  875 lines

  1. {*********************************************************}
  2. {*                  ESLABEL.PAS 1.05                     *}
  3. {*      Copyright (c) 1997-98 TurboPower Software Co     *}
  4. {*                 All rights reserved.                  *}
  5. {*********************************************************}
  6.  
  7. {$I ES.INC}
  8.  
  9. {$B-} {Complete Boolean Evaluation}
  10. {$I+} {Input/Output-Checking}
  11. {$P+} {Open Parameters}
  12. {$T-} {Typed @ Operator}
  13. {$W-} {Windows Stack Frame}
  14. {$X+} {Extended Syntax}
  15.  
  16. {$IFNDEF Win32}
  17.   {$G+} {286 Instructions}
  18.   {$N+} {Numeric Coprocessor}
  19.   {$C MOVEABLE,DEMANDLOAD,DISCARDABLE}
  20. {$ENDIF}
  21.  
  22. unit EsLabel;
  23.   {-label component}
  24.  
  25. interface
  26.  
  27. uses
  28.   {$IFDEF Win32} Windows, {$ELSE} WinTypes, WinProcs, {$ENDIF}
  29.   Classes, Controls, Graphics, Messages, StdCtrls, SysUtils,
  30.   EsConst, EsData, EsUtil;
  31.  
  32. type
  33.   {preset "looks"}
  34.   TEsAppearance = (apNone, apCustom, apFlying, apRaised, apSunken, apShadow);
  35.   {preset color schemes}
  36.   TEsColorScheme = (csCustom, csText, csWindows, csEmbossed, csGold, csSteel);
  37.   {options for varying the shadow/highlight for the label}
  38.   TEsGraduateStyle = (gsNone, gsHorizontal, gsVertical);
  39.   {directions for shading (highlights and shadows)}
  40.   TEsShadeDirection = (sdNone, sdUp, sdUpRight, sdRight, sdDownRight, sdDown,
  41.                      sdDownLeft, sdLeft, sdUpLeft);
  42.   {options for varying the text of the label}
  43.   TEsShadeStyle = (ssPlain, ssExtrude, ssGraduated);
  44.  
  45.   TEsDepth = 0..255;
  46.  
  47. const
  48.   lblDefAppearance         = apRaised;
  49.   lblDefAutoSize           = False;
  50.   lblDefColorScheme        = csWindows;
  51.   lblDefFontName           = 'Times New Roman';
  52.   lblDefFontSize           = 20;
  53.   lblDefGraduateFromColor  = clGray;
  54.   lblDefGraduateStyle      = gsNone;
  55.   lblDefHighlightColor     = clWhite;
  56.   lblDefHighlightDepth     = 1;
  57.   lblDefHighlightDirection = sdUpLeft;
  58.   lblDefHighlightStyle     = ssPlain;
  59.   lblDefShadowColor        = clBlack;
  60.   lblDefShadowDepth        = 1;
  61.   lblDefShadowDirection    = sdDownRight;
  62.   lblDefShadowStyle        = ssPlain;
  63.   lblDefTransparent        = True;
  64.   lblDefWordWrap           = True;
  65.  
  66. type
  67.   TEsCustomSettings = class(TPersistent)
  68.   private
  69.     {.Z+}
  70.     {property variables}
  71.     FGraduateFromColor  : TColor;
  72.     FGraduateStyle      : TEsGraduateStyle;
  73.     FHighlightColor     : TColor;
  74.     FHighlightDepth     : TEsDepth;
  75.     FHighlightDirection : TEsShadeDirection;
  76.     FHighlightStyle     : TEsShadeStyle;
  77.     FShadowColor        : TColor;
  78.     FShadowDepth        : TEsDepth;
  79.     FShadowDirection    : TEsShadeDirection;
  80.     FShadowStyle        : TEsShadeStyle;
  81.  
  82.     {event variables}
  83.     FOnColorChange      : TNotifyEvent;
  84.     FOnStyleChange      : TNotifyEvent;
  85.  
  86.     {internal variables}
  87.     FUpdating           : Boolean;
  88.  
  89.     {internal methods}
  90.     procedure DoOnColorChange;
  91.     procedure DoOnStyleChange;
  92.  
  93.     {property methods}
  94.     procedure SetGraduateFromColor(Value : TColor);
  95.     procedure SetGraduateStyle(Value : TEsGraduateStyle);
  96.     procedure SetHighlightColor(Value : TColor);
  97.     procedure SetHighlightDepth(Value : TEsDepth);
  98.     procedure SetHighlightDirection(Value : TEsShadeDirection);
  99.     procedure SetHighlightStyle(Value : TEsShadeStyle);
  100.     procedure SetShadowColor(Value : TColor);
  101.     procedure SetShadowDepth(Value : TEsDepth);
  102.     procedure SetShadowDirection(Value : TEsShadeDirection);
  103.     procedure SetShadowStyle(Value : TEsShadeStyle);
  104.     {.Z-}
  105.   public
  106.     procedure Assign(Source : TPersistent);
  107.       override;
  108.  
  109.     procedure BeginUpdate;
  110.     procedure EndUpdate;
  111.  
  112.     {.Z+}
  113.     property OnColorChange : TNotifyEvent
  114.       read FOnColorChange
  115.       write FOnColorChange;
  116.  
  117.     property OnStyleChange : TNotifyEvent
  118.       read FOnStyleChange
  119.       write FOnStyleChange;
  120.     {.Z-}
  121.  
  122.   published
  123.     property GraduateFromColor : TColor
  124.       read FGraduateFromColor
  125.       write SetGraduateFromColor
  126.       default lblDefGraduateFromColor;
  127.  
  128.     property GraduateStyle : TEsGraduateStyle
  129.       read FGraduateStyle
  130.       write SetGraduateStyle
  131.       default lblDefGraduateStyle;
  132.  
  133.     property HighlightColor : TColor
  134.       read FHighlightColor
  135.       write SetHighlightColor
  136.       default lblDefHighlightColor;
  137.  
  138.     property HighlightDepth : TEsDepth
  139.       read FHighlightDepth
  140.       write SetHighlightDepth
  141.       default lblDefHighlightDepth;
  142.  
  143.     property HighlightDirection : TEsShadeDirection
  144.       read FHighlightDirection
  145.       write SetHighlightDirection
  146.       default lblDefHighlightDirection;
  147.  
  148.     property HighlightStyle : TEsShadeStyle
  149.       read FHighlightStyle
  150.       write SetHighlightStyle
  151.       default lblDefHighlightStyle;
  152.  
  153.     property ShadowColor : TColor
  154.       read FShadowColor
  155.       write SetShadowColor
  156.       default lblDefShadowColor;
  157.  
  158.     property ShadowDepth : TEsDepth
  159.       read FShadowDepth
  160.       write SetShadowDepth
  161.       default lblDefShadowDepth;
  162.  
  163.     property ShadowDirection : TEsShadeDirection
  164.       read FShadowDirection
  165.       write SetShadowDirection
  166.       default lblDefShadowDirection;
  167.  
  168.     property ShadowStyle : TEsShadeStyle
  169.       read FShadowStyle
  170.       write SetShadowStyle
  171.       default lblDefShadowStyle;
  172.   end;
  173.  
  174.   TEsCustomLabel = class(TCustomLabel)
  175.   protected {private}
  176.     {.Z+}
  177.     {property variables}
  178.     FAppearance         : TEsAppearance;
  179.     FColorScheme        : TEsColorScheme;
  180.     FCustomSettings     : TEsCustomSettings;
  181.  
  182.     {interal variables}
  183.     eslSchemes          : array [TEsColorScheme, (cpHighlight, cpShadow, cpFace)] of TColor;
  184.     SettingColorScheme  : Boolean;
  185.     SettingAppearance   : Boolean;
  186.  
  187.     {property methods}
  188.     function GetVersion : string;
  189.     function GetWordWrap : Boolean;
  190.     procedure SetAppearance(Value : TEsAppearance);
  191.     procedure SetColorScheme(Value : TEsColorScheme);
  192.     procedure SetWordWrap(Value : Boolean);
  193.     procedure SetVersion(const Value : string);
  194.  
  195.     {internal methods}
  196.     procedure PaintPrim(CR : TRect; Flags : Word);
  197.     procedure ColorChanged(Sender : TObject);
  198.     procedure StyleChanged(Sender : TObject);
  199.     {.Z-}
  200.  
  201.   protected
  202.     {.Z+}
  203.     procedure Paint;
  204.       override;
  205.     {.Z-}
  206.  
  207.     {protected properties} {can be published by descendants}
  208.     property Appearance : TEsAppearance
  209.       read FAppearance
  210.       write SetAppearance
  211.       default lblDefAppearance;
  212.  
  213.     property ColorScheme : TEsColorScheme
  214.       read FColorScheme
  215.       write SetColorScheme
  216.       default lblDefColorScheme;
  217.  
  218.     property CustomSettings : TEsCustomSettings
  219.       read FCustomSettings
  220.       write FCustomSettings;
  221.  
  222.     property Version : string
  223.       read GetVersion
  224.       write SetVersion
  225.       stored False;
  226.  
  227.     property WordWrap : Boolean
  228.       read GetWordWrap
  229.       write SetWordWrap
  230.       default lblDefWordWrap;
  231.  
  232.   public
  233.     {.Z+}
  234.     constructor Create(AOwner : TComponent);
  235.       override;
  236.     destructor Destroy;
  237.       override;
  238.  
  239.     procedure PaintTo(DC : TEshDC; CR : TRect; Flags : Word);
  240.  
  241.     property AutoSize;
  242.     {.Z-}
  243.   end;
  244.  
  245.   TEsLabel = class(TEsCustomLabel)
  246.   published
  247.     {properties}
  248.     property Align;
  249.     property Alignment;
  250.     property Appearance;
  251.     property Caption;
  252.     property Color;
  253.     property ColorScheme;
  254.     property Cursor;
  255.     property CustomSettings;
  256.     property DragCursor;
  257.     property DragMode;
  258.     property Enabled;
  259.     property FocusControl;
  260.     property Font;
  261.     property ParentColor;
  262.     property ParentFont;
  263.     property ParentShowHint;
  264.     property ShowAccelChar;
  265.     property ShowHint;
  266.     property Transparent
  267.       default lblDefTransparent;
  268.     property Version;
  269.     property Visible;
  270.     property WordWrap;
  271.  
  272.     {events}
  273.     property OnClick;
  274.     property OnDblClick;
  275.     property OnDragDrop;
  276.     property OnDragOver;
  277.     property OnEndDrag;
  278.     property OnMouseDown;
  279.     property OnMouseMove;
  280.     property OnMouseUp;
  281.   end;
  282.  
  283.  
  284. implementation
  285.  
  286.  
  287. {$IFDEF TRIALRUN}
  288. uses
  289.   EsTrial;
  290. {$I ESTRIALF.INC}
  291. {$ENDIF}
  292.  
  293.  
  294. {*** TEsCustomSettings ***}
  295.  
  296. procedure TEsCustomSettings.Assign(Source : TPersistent);
  297. var
  298.   LS : TEsCustomSettings absolute Source;
  299. begin
  300.   if Assigned(Source) and (Source is TEsCustomSettings) then begin
  301.     FGraduateFromColor := LS.GraduateFromColor;
  302.     FGraduateStyle := LS.GraduateStyle;
  303.     FHighlightColor := LS.HighlightColor;
  304.     FHighlightDepth := LS.HighlightDepth;
  305.     FHighlightDirection := LS.HighlightDirection;
  306.     FHighlightStyle := LS.HighlightStyle;
  307.     FShadowColor := LS.ShadowColor;
  308.     FShadowDepth := LS.ShadowDepth;
  309.     FShadowDirection := LS.ShadowDirection;
  310.     FShadowStyle := LS.ShadowStyle;
  311.   end else
  312.     inherited Assign(Source);
  313. end;
  314.  
  315. procedure TEsCustomSettings.BeginUpdate;
  316. begin
  317.   FUpdating := True;
  318. end;
  319.  
  320. procedure TEsCustomSettings.EndUpdate;
  321. begin
  322.   FUpdating := False;
  323.   DoOnColorChange;
  324.   DoOnStyleChange;
  325. end;
  326.  
  327. procedure TEsCustomSettings.DoOnColorChange;
  328. begin
  329.   if not FUpdating and Assigned(FOnColorChange) then
  330.     FOnColorChange(Self);
  331. end;
  332.  
  333. procedure TEsCustomSettings.DoOnStyleChange;
  334. begin
  335.   if not FUpdating and Assigned(FOnStyleChange) then
  336.     FOnStyleChange(Self);
  337. end;
  338.  
  339. procedure TEsCustomSettings.SetGraduateFromColor(Value : TColor);
  340. begin
  341.   if Value <> FGraduateFromColor then begin
  342.     FGraduateFromColor := Value;
  343.     DoOnColorChange;
  344.   end;
  345. end;
  346.  
  347. procedure TEsCustomSettings.SetGraduateStyle(Value : TEsGraduateStyle);
  348. begin
  349.   if Value <> FGraduateStyle then begin
  350.     FGraduateStyle := Value;
  351.     DoOnStyleChange;
  352.   end;
  353. end;
  354.  
  355. procedure TEsCustomSettings.SetHighlightColor(Value : TColor);
  356. begin
  357.   if Value <> FHighlightColor then begin
  358.     FHighlightColor := Value;
  359.     DoOnColorChange;
  360.   end;
  361. end;
  362.  
  363. procedure TEsCustomSettings.SetHighlightDepth(Value : TEsDepth);
  364. begin
  365.   if Value <> FHighlightDepth then begin
  366.     FHighlightDepth := Value;
  367.     DoOnStyleChange;
  368.   end;
  369. end;
  370.  
  371. procedure TEsCustomSettings.SetHighlightDirection(Value : TEsShadeDirection);
  372. begin
  373.   if Value <> FHighlightDirection then begin
  374.     FHighlightDirection := Value;
  375.     DoOnStyleChange;
  376.   end;
  377. end;
  378.  
  379. procedure TEsCustomSettings.SetHighlightStyle(Value : TEsShadeStyle);
  380. begin
  381.   if Value <> FHighlightStyle then begin
  382.     FHighlightStyle := Value;
  383.     DoOnStyleChange;
  384.   end;
  385. end;
  386.  
  387. procedure TEsCustomSettings.SetShadowColor(Value : TColor);
  388. begin
  389.   if Value <> FShadowColor then begin
  390.     FShadowColor := Value;
  391.     DoOnColorChange;
  392.   end;
  393. end;
  394.  
  395. procedure TEsCustomSettings.SetShadowDepth(Value : TEsDepth);
  396. begin
  397.   if Value <> FShadowDepth then begin
  398.     FShadowDepth := Value;
  399.     DoOnStyleChange;
  400.   end;
  401. end;
  402.  
  403. procedure TEsCustomSettings.SetShadowDirection(Value : TEsShadeDirection);
  404. begin
  405.   if Value <> FShadowDirection then begin
  406.     FShadowDirection := Value;
  407.     DoOnStyleChange;
  408.   end;
  409. end;
  410.  
  411. procedure TEsCustomSettings.SetShadowStyle(Value : TEsShadeStyle);
  412. begin
  413.   if Value <> FShadowStyle then begin
  414.     FShadowStyle := Value;
  415.     DoOnStyleChange;
  416.   end;
  417. end;
  418.  
  419.  
  420. {*** TEsCustomLabel ***}
  421.  
  422. constructor TEsCustomLabel.Create(AOwner : TComponent);
  423. {$IFDEF TRIALRUN}
  424. var
  425.   X : Integer;
  426. {$ENDIF}
  427. begin
  428.   inherited Create(AOwner);
  429.  
  430.   eslSchemes[csWindows, cpHighlight] := lblDefHighlightColor;
  431.   eslSchemes[csWindows, cpFace] := clGray;
  432.   eslSchemes[csWindows, cpShadow] := lblDefShadowColor;
  433.  
  434.   eslSchemes[csText, cpHighlight] := clWhite;
  435.   eslSchemes[csText, cpFace] := clBlack;
  436.   eslSchemes[csText, cpShadow] := clGray;
  437.  
  438.   eslSchemes[csEmbossed, cpHighlight] := clWhite;
  439.   eslSchemes[csEmbossed, cpFace] := clSilver;
  440.   eslSchemes[csEmbossed, cpShadow] := clBlack;
  441.  
  442.   eslSchemes[csGold, cpHighlight] := clYellow;
  443.   eslSchemes[csGold, cpFace] := clOlive;
  444.   eslSchemes[csGold, cpShadow] := clBlack;
  445.  
  446.   eslSchemes[csSteel, cpHighlight] := clAqua;
  447.   eslSchemes[csSteel, cpFace] := clTeal;
  448.   eslSchemes[csSteel, cpShadow] := clNavy;
  449.  
  450.   eslSchemes[csCustom, cpHighlight] := eslSchemes[csWindows,cpHighlight];
  451.   eslSchemes[csCustom, cpFace] := eslSchemes[csWindows,cpFace];
  452.   eslSchemes[csCustom, cpShadow] := eslSchemes[csWindows,cpShadow];
  453.  
  454.   {initialize defaults}
  455.   FAppearance                         := lblDefAppearance;
  456.   FColorScheme                        := lblDefColorScheme;
  457.   FCustomSettings                     := TEsCustomSettings.Create;
  458.   FCustomSettings.FGraduateFromColor  := lblDefGraduateFromColor;
  459.   FCustomSettings.FGraduateStyle      := lblDefGraduateStyle;
  460.   FCustomSettings.FHighlightColor     := eslSchemes[csWindows, cpHighlight];
  461.   FCustomSettings.FHighlightDepth     := lblDefHighlightDepth;
  462.   FCustomSettings.FHighlightDirection := lblDefHighlightDirection;
  463.   FCustomSettings.FHighlightStyle     := lblDefHighlightStyle;
  464.   FCustomSettings.FShadowColor        := eslSchemes[csWindows, cpShadow];
  465.   FCustomSettings.FShadowDepth        := lblDefShadowDepth;
  466.   FCustomSettings.FShadowDirection    := lblDefShadowDirection;
  467.   FCustomSettings.FShadowStyle        := lblDefShadowStyle;
  468.   FCustomSettings.OnColorChange       := ColorChanged;
  469.   FCustomSettings.OnStyleChange       := StyleChanged;
  470.  
  471.   AutoSize            := lblDefAutoSize;
  472.   Height              := 35;
  473.   Width               := 150;
  474.   Transparent         := lblDefTransparent;
  475.   Font.Name           := lblDefFontName;
  476.   Font.Size           := lblDefFontSize;
  477.   Font.Color          := eslSchemes[FColorScheme, cpFace];
  478.   WordWrap            := lblDefWordWrap;
  479.  
  480.   SettingColorScheme  := False;
  481.   SettingAppearance   := False;
  482.  
  483. {$IFDEF TRIALRUN}
  484.   X := _CC_;
  485.   if (X < ccRangeLow) or (X > ccRangeHigh) then Halt;
  486.   X := _VC_;
  487.   if (X < ccRangeLow) or (X > ccRangeHigh) then Halt;
  488. {$ENDIF}
  489. end;
  490.  
  491. destructor TEsCustomLabel.Destroy;
  492. begin
  493.   FCustomSettings.Free;
  494.   FCustomSettings := nil;
  495.  
  496.   inherited Destroy;
  497. end;
  498.  
  499. function TEsCustomLabel.GetVersion : string;
  500. begin
  501.   Result := EsVersionStr;
  502. end;
  503.  
  504. function TEsCustomLabel.GetWordWrap : Boolean;
  505. begin
  506.   Result := inherited WordWrap;
  507. end;
  508.  
  509. procedure TEsCustomLabel.Paint;
  510. const
  511.   Alignments : array [TAlignment] of Word = (DT_LEFT, DT_RIGHT, DT_CENTER);
  512.   Wrap : array[Boolean] of Word = (0, DT_WORDBREAK);
  513.   Prefix : array[Boolean] of Word = (DT_NOPREFIX, 0);
  514. begin
  515.   PaintPrim(ClientRect, Wrap[WordWrap] or DT_EXPANDTABS or
  516.                       Alignments[Alignment] or Prefix[ShowAccelChar]);
  517. end;
  518.  
  519. procedure TEsCustomLabel.PaintPrim(CR : TRect; Flags : Word);
  520. const
  521.   DrawingOffset : array [TEsShadeDirection, (ioX, ioY)] of -1..1 =
  522.       ((0,0),(0,-1),(+1,-1),(+1,0),(+1,+1),(0,+1),(-1,+1),(-1,0),(-1,-1));
  523.   BandCount = 16;
  524. var
  525.   I          : Integer;
  526.   MinOffset  : Integer;
  527.   MaxOffset  : Integer;
  528.   IX, IY     : Integer;
  529.   IU, IV     : Integer;
  530.   Limit      : Integer;
  531.   Adjustment : Integer;
  532.   AdjustR    : Double;
  533.   AdjustG    : Double;
  534.   AdjustB    : Double;
  535.   Step       : Double;
  536.   RctTemp    : TRect;
  537.   FromR      : Byte;
  538.   FromG      : Byte;
  539.   FromB      : Byte;
  540.   ToR        : Byte;
  541.   ToG        : Byte;
  542.   ToB        : Byte;
  543.   BmpTemp    : TBitmap;
  544.   BmpWork    : TBitmap;
  545.   CnvWork    : TCanvas;
  546.   Buf        : PChar;                                                  {!!.03}
  547. begin
  548.   {get offsets based on shadow and highlight directions and depths}
  549.   MinOffset := Min(Min(Min(Min(DrawingOffset[FCustomSettings.HighlightDirection, ioX] * FCustomSettings.HighlightDepth,
  550.                DrawingOffset[FCustomSettings.ShadowDirection, ioX] * FCustomSettings.ShadowDepth),
  551.                DrawingOffset[FCustomSettings.HighlightDirection, ioY] * FCustomSettings.HighlightDepth),
  552.                DrawingOffset[FCustomSettings.ShadowDirection, ioY] * FCustomSettings.ShadowDepth), 0);
  553.   MaxOffset := Max(Max(Max(Max(DrawingOffset[FCustomSettings.HighlightDirection, ioX] * FCustomSettings.HighlightDepth,
  554.                DrawingOffset[FCustomSettings.ShadowDirection, ioX] * FCustomSettings.ShadowDepth),
  555.                DrawingOffset[FCustomSettings.HighlightDirection, ioY] * FCustomSettings.HighlightDepth),
  556.                DrawingOffset[FCustomSettings.ShadowDirection, ioY] * FCustomSettings.ShadowDepth), 0);
  557.  
  558.   if Flags and DT_CENTER <> 0 then
  559.     Adjustment := (MaxOffset - MinOffset) div 2
  560.   else if Flags and DT_RIGHT <> 0 then
  561.     Adjustment := MaxOffset - MinOffset
  562.   else
  563.     Adjustment := 0;
  564.  
  565.   {create temporary drawing surfaces}
  566.   BmpTemp := TBitmap.Create;
  567.   BmpWork := TBitmap.Create;
  568.   try
  569.     BmpTemp.Height := CR.Bottom-CR.Top;
  570.     BmpTemp.Width := CR.Right-CR.Left;
  571.     BmpTemp.Canvas.Font := Self.Font;
  572.  
  573.     BmpWork.Height := CR.Bottom-CR.Top;
  574.     BmpWork.Width := CR.Right-CR.Left;
  575.     BmpWork.Canvas.Font := Self.Font;
  576.  
  577.     {get copy of our canvas}
  578.     BmpWork.Canvas.CopyRect(CR, Self.Canvas, CR);
  579.  
  580.     {set starting point for text - IX, IY}
  581.     IX := 0; IY := 0;
  582.     if not Transparent then begin
  583.       BmpWork.Canvas.Brush.Color := Self.Color;
  584.       BmpWork.Canvas.Brush.Style := bsSolid;
  585.       BmpWork.Canvas.FillRect(CR);
  586.     end;
  587.     BmpWork.Canvas.Brush.Style := bsClear;
  588.  
  589.     Buf := StrAlloc(GetTextLen+1);                                     {!!.03}
  590.     try                                                                {!!.03}
  591.       {get label's caption}                                            {!!.03}
  592.       GetTextBuf(Buf, GetTextLen+1);                                   {!!.03}
  593.  
  594.       {prepare for extruding shadow, if requested}
  595.       GetRGB(FCustomSettings.ShadowColor, FromR, FromG, FromB);
  596.       AdjustR := 0;
  597.       AdjustG := 0;
  598.       AdjustB := 0;
  599.       Limit := FCustomSettings.ShadowDepth;
  600.       if (FCustomSettings.ShadowStyle <> ssPlain) and (FCustomSettings.ShadowDepth > 1) then begin
  601.         Limit := 1;
  602.         {find changes in RGB colors}
  603.         if FCustomSettings.ShadowStyle = ssGraduated then begin
  604.           GetRGB(Font.Color, ToR, ToG, ToB);
  605.           AdjustR := (ToR - FromR) / (FCustomSettings.ShadowDepth - 1);
  606.           AdjustG := (ToG - FromG) / (FCustomSettings.ShadowDepth - 1);
  607.           AdjustB := (ToB - FromB) / (FCustomSettings.ShadowDepth - 1);
  608.         end;
  609.       end;
  610.       CnvWork := BmpWork.Canvas;
  611.  
  612.       {process for each copy of the shadow}
  613.       for I := FCustomSettings.ShadowDepth downto Limit do begin
  614.         CnvWork.Font.Color :=
  615.           RGB(FromR + Round(AdjustR * (FCustomSettings.ShadowDepth - I)),
  616.               FromG + Round(AdjustG * (FCustomSettings.ShadowDepth - I)),
  617.               FromB + Round(AdjustB * (FCustomSettings.ShadowDepth - I)));
  618.         {create a rect that is offset for the shadow}
  619.         RctTemp:= Rect(
  620.           CR.Left - MinOffset -Adjustment + DrawingOffset[FCustomSettings.ShadowDirection, ioX] * I,
  621.           CR.Top - MinOffset + DrawingOffset[FCustomSettings.ShadowDirection, ioY] * I,
  622.           CR.Right - MinOffset - Adjustment + DrawingOffset[FCustomSettings.ShadowDirection, ioX] * I,
  623.           CR.Bottom - MinOffset + DrawingOffset[FCustomSettings.ShadowDirection, ioY] * I);
  624.         {draw shadow text with alignment}
  625.         DrawText(CnvWork.Handle, Buf, StrLen(Buf), RctTemp, Flags);
  626.       end;
  627.  
  628.       {prepare for extruding highlight, if requested}
  629.       GetRGB(FCustomSettings.HighlightColor, FromR, FromG, FromB);
  630.       AdjustR := 0;
  631.       AdjustG := 0;
  632.       AdjustB := 0;
  633.       Limit := FCustomSettings.HighlightDepth;
  634.       if (FCustomSettings.HighlightStyle <> ssPlain) and (FCustomSettings.HighlightDepth > 1) then begin
  635.         Limit := 1;
  636.         if FCustomSettings.HighlightStyle = ssGraduated then begin {find changes in RGB Colors}
  637.           GetRGB(Font.Color, ToR, ToG, ToB);
  638.           AdjustR := (ToR - FromR) / (FCustomSettings.HighlightDepth - 1);
  639.           AdjustG := (ToG - FromG) / (FCustomSettings.HighlightDepth - 1);
  640.           AdjustB := (ToB - FromB) / (FCustomSettings.HighlightDepth - 1);
  641.         end;
  642.       end;
  643.  
  644.       CnvWork := BmpWork.Canvas;
  645.  
  646.       {process for each copy of the highlight}
  647.       for I := FCustomSettings.HighlightDepth downto Limit do begin
  648.         CnvWork.Font.Color :=
  649.           RGB(FromR + Round(AdjustR * (FCustomSettings.HighlightDepth - I)),
  650.               FromG + Round(AdjustG * (FCustomSettings.HighlightDepth - I)),
  651.               FromB + Round(AdjustB * (FCustomSettings.HighlightDepth - I)));
  652.         {create a rect that is offset for the highlight}
  653.         RctTemp:= Rect(
  654.           CR.Left - MinOffset - Adjustment + DrawingOffset[FCustomSettings.HighlightDirection, ioX] * I,
  655.           CR.Top - MinOffset + DrawingOffset[FCustomSettings.HighlightDirection, ioY] * I,
  656.           CR.Right - MinOffset - Adjustment + DrawingOffset[FCustomSettings.HighlightDirection, ioX] * I,
  657.           CR.Bottom - MinOffset + DrawingOffset[FCustomSettings.HighlightDirection, ioY] * I);
  658.         {draw highlight text with alignment}
  659.         DrawText(CnvWork.Handle, Buf, StrLen(Buf), RctTemp, Flags);
  660.       end;
  661.  
  662.       if FCustomSettings.GraduateStyle <> gsNone then begin
  663.         {copy original canvas to work area}
  664.         BmpTemp.Canvas.CopyRect(CR, BmpWork.Canvas, CR);
  665.         {choose an unusual color}
  666.         BmpTemp.Canvas.Font.Color := $00FE09F1;
  667.         BmpTemp.Canvas.Brush.Style := bsClear;
  668.         CnvWork := BmpTemp.Canvas;
  669.       end else begin
  670.         BmpWork.Canvas.Font.Color := Font.Color;  {restore original font Color}
  671.         CnvWork := BmpWork.Canvas;
  672.       end;
  673.  
  674.       {create a rect that is offset for the original text}
  675.       RctTemp:= Rect(CR.Left - MinOffset - Adjustment,
  676.                      CR.Top - MinOffset,
  677.                      CR.Right - MinOffset - Adjustment,
  678.                      CR.Bottom - MinOffset);
  679.  
  680.       {draw original text with alignment}
  681.       DrawText(CnvWork.Handle, Buf, StrLen(Buf), RctTemp, Flags);
  682.     finally                                                            {!!.03}
  683.       StrDispose(Buf);                                                 {!!.03}
  684.     end;                                                               {!!.03}
  685.  
  686.     if FCustomSettings.GraduateStyle <> gsNone then begin
  687.       {transfer graduations from temporary canvas}
  688.       {calculate start point and extent}
  689.       Limit := BmpWork.Canvas.TextWidth(Caption);
  690.       IV := IY - MinOffset;
  691.  
  692.       if Flags and DT_CENTER <> 0 then
  693.         IU := (CR.Right-CR.Left - Limit) div 2 - MinOffset - Adjustment
  694.       else if Flags and DT_RIGHT <> 0 then
  695.         IU := CR.Bottom-CR.Top - MaxOffset - Limit
  696.       else
  697.         IU := IX - MinOffset;
  698.  
  699.       if FCustomSettings.GraduateStyle = gsVertical then
  700.         Limit := CR.Bottom-CR.Top-1                                    {!!.04}
  701.       else
  702.         Dec(Limit);
  703.  
  704.       {calculate change in color at each step}
  705.       GetRGB(FCustomSettings.GraduateFromColor, FromR, FromG, FromB);
  706.       GetRGB(Font.Color, ToR, ToG, ToB);
  707.       AdjustR := (ToR - FromR) / Pred(BandCount);
  708.       AdjustG := (ToG - FromG) / Pred(BandCount);
  709.       AdjustB := (ToB - FromB) / Pred(BandCount);
  710.  
  711.       Step := Limit / Pred(BandCount);
  712.  
  713.       {and draw it onto the canvas}
  714.       BmpWork.Canvas.Brush.Style := bsSolid;
  715.       for I := 0 to Pred(BandCount) do begin
  716.         BmpWork.Canvas.Brush.Color := RGB(FromR + Round(AdjustR * I),
  717.                                           FromG + Round(AdjustG * I),
  718.                                           FromB + Round(AdjustB * I));
  719.         if FCustomSettings.GraduateStyle = gsVertical then
  720.           RctTemp := Rect(0, IV + Round(I*Step), CR.Right-CR.Left, IV + Round((I+1)*Step))
  721.         else
  722.           RctTemp := Rect(IU + Round(I*Step), 0, IU + Round((I+1)*Step), CR.Bottom-CR.Top);
  723.         BmpWork.Canvas.BrushCopy(RctTemp, BmpTemp, RctTemp, BmpTemp.Canvas.Font.Color);
  724.       end;
  725.     end;
  726.  
  727.     Canvas.CopyRect(CR, BmpWork.Canvas, CR);
  728.   finally
  729.     BmpTemp.Free;
  730.     BmpWork.Free;
  731.   end;
  732. end;
  733.  
  734. procedure TEsCustomLabel.PaintTo(DC : TEshDC; CR : TRect; Flags : Word);
  735. begin
  736.   Canvas.Handle := DC;
  737.   try
  738.     if not Transparent then begin
  739.       Canvas.Brush.Color := Self.Color;
  740.       Canvas.Brush.Style := bsSolid;
  741.       {clear complete client area}
  742.       Canvas.FillRect(Rect(0, 0, CR.Right, CR.Bottom));
  743.     end;
  744.     Canvas.Brush.Style := bsClear;
  745.     PaintPrim(CR, Flags)
  746.   finally
  747.     Canvas.Handle := 0;
  748.   end;
  749. end;
  750.  
  751. procedure TEsCustomLabel.SetAppearance(Value : TEsAppearance);
  752. begin
  753.   if FAppearance <> Value then begin
  754.     SettingAppearance := True;
  755.     try
  756.       FAppearance := Value;
  757.       FCustomSettings.BeginUpdate;
  758.       try
  759.         FCustomSettings.HighlightColor := eslSchemes[ColorScheme,cpHighlight];
  760.         case FAppearance of
  761.           apRaised:
  762.             begin
  763.               FCustomSettings.HighlightDirection := sdUpLeft;
  764.               FCustomSettings.ShadowDirection := sdDownRight;
  765.               FCustomSettings.HighlightDepth := 1;
  766.               FCustomSettings.ShadowDepth := 1;
  767.             end;
  768.           apSunken:
  769.             begin
  770.               FCustomSettings.HighlightDirection := sdDownRight;
  771.               FCustomSettings.ShadowDirection := sdUpLeft;
  772.               FCustomSettings.HighlightDepth := 1;
  773.               FCustomSettings.ShadowDepth := 1;
  774.             end;
  775.           apShadow:
  776.             begin
  777.               FCustomSettings.HighlightDirection := sdNone;
  778.               FCustomSettings.ShadowDirection := sdDownRight;
  779.               FCustomSettings.HighlightDepth := 0;
  780.               FCustomSettings.ShadowDepth := 2;
  781.             end;
  782.           apFlying:
  783.             begin
  784.               FCustomSettings.HighlightDirection := sdDownRight;
  785.               FCustomSettings.ShadowDirection := sdDownRight;
  786.               FCustomSettings.HighlightDepth :=1;
  787.               FCustomSettings.ShadowDepth :=5;
  788.               {flying has two shadows}
  789.               FCustomSettings.HighlightColor := eslSchemes[ColorScheme, cpShadow];
  790.             end;
  791.           apNone:
  792.             begin
  793.               FCustomSettings.HighlightDirection := sdNone;
  794.               FCustomSettings.ShadowDirection := sdNone;
  795.               FCustomSettings.HighlightDepth :=0;
  796.               FCustomSettings.ShadowDepth :=0;
  797.             end;
  798.         end;
  799.       finally
  800.         FCustomSettings.EndUpdate;
  801.       end;
  802.     finally
  803.       SettingAppearance := False;
  804.       Perform(CM_TEXTCHANGED, 0, 0);
  805.     end;
  806.   end;
  807. end;
  808.  
  809. procedure TEsCustomLabel.SetColorScheme(Value : TEsColorScheme);
  810. begin
  811.   if FColorScheme <> Value then begin
  812.     SettingColorScheme := True;
  813.     try
  814.       FColorScheme := Value;
  815.       FCustomSettings.BeginUpdate;
  816.       try
  817.         FCustomSettings.HighlightColor := eslSchemes[FColorScheme, cpHighlight];
  818.         Font.Color := eslSchemes[FColorScheme, cpFace];
  819.         FCustomSettings.ShadowColor := eslSchemes[FColorScheme, cpShadow];
  820.         if FColorScheme <> csCustom then begin
  821.           eslSchemes[csCustom, cpHighlight] := eslSchemes[FColorScheme, cpHighlight];
  822.           eslSchemes[csCustom, cpFace] := eslSchemes[FColorScheme, cpFace];
  823.           eslSchemes[csCustom, cpShadow] := eslSchemes[FColorScheme, cpShadow];
  824.         end;
  825.       finally
  826.         FCustomSettings.EndUpdate;
  827.       end;
  828.     finally
  829.       SettingColorScheme := False;
  830.       Perform(CM_TEXTCHANGED, 0, 0);
  831.     end;
  832.   end;
  833. end;
  834.  
  835. procedure TEsCustomLabel.ColorChanged(Sender : TObject);
  836. begin
  837.   if csLoading in ComponentState then
  838.     Exit;
  839.  
  840.   Invalidate;
  841.  
  842.   if not SettingColorScheme then
  843.     FColorScheme := csCustom;
  844.  
  845.   if not SettingColorScheme then
  846.     Perform(CM_COLORCHANGED, 0, 0);
  847. end;
  848.  
  849. procedure TEsCustomLabel.StyleChanged(Sender : TObject);
  850. begin
  851.   if csLoading in ComponentState then
  852.     Exit;
  853.  
  854.   Invalidate;
  855.  
  856.   if not SettingAppearance then begin
  857.     FAppearance := apCustom;
  858.     Perform(CM_TEXTCHANGED, 0, 0);
  859.   end;
  860. end;
  861.  
  862. procedure TEsCustomLabel.SetVersion(const Value : string);
  863. begin
  864. end;
  865.  
  866. procedure TEsCustomLabel.SetWordWrap(Value : Boolean);
  867. begin
  868.   if Value <> WordWrap then begin
  869.     inherited WordWrap := Value;
  870.     Invalidate;
  871.   end;
  872. end;
  873.  
  874. end.
  875.