home *** CD-ROM | disk | FTP | other *** search
/ Chip 2002 March / Chip_2002-03_cd1.bin / zkuste / delphi / kolekce / d123456 / SIMONS.ZIP / Units / RackCtls.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-05-24  |  62.4 KB  |  2,236 lines

  1. unit RackCtls;
  2.  
  3. { RackControls:
  4.   TLEDButton, TButtonPanel, TScrewPanel, TLEDDisplay, TLEDMeter
  5.  
  6.   (C)opyright 2000 Version 1.04
  7.   Autor : Simon Reinhardt
  8.   eMail : reinhardt@picsoft.de
  9.   Internet : http://www.picsoft.de
  10.  
  11.   RackControls ist eine Komponentensammlung zur Erstellung von
  12.   Audiorack-Σhnlichen OberflΣchen. Diese Komponenten sind
  13.   Public Domain, das Urheberrecht liegt aber beim Autor.
  14.  
  15.   Die Komponente TLEDDisplay ist eine Weiterentwicklung
  16.   der Komponente TLCDDisplay von Luis Iglesias:
  17.   luis.iglesias@vigo.org
  18.  
  19.   ─nderungen, die bei LEDDisplay nachfolgende Nullen bei LeadingZeros=False doch zeichnet
  20.   ErgΣnzt von Wolfgang Kleinrath
  21.  
  22.   Eigenschaft FSingleLED ergΣnzt von U. Conrad }
  23.  
  24. interface
  25.  
  26. {$I SRDefine.inc}
  27.  
  28. uses
  29.   {$IFDEF SR_Win32} Windows, {$ELSE} WinTypes, WinProcs, Menus, {$ENDIF} Classes,
  30.   Graphics, Controls, ExtCtrls, SysUtils, Messages, Forms;
  31.  
  32. type
  33.   TBorderStyle     = (bsNone, bsSingle);
  34.   TButtonDirection = (bdBottomUp, bdLeftUp, bdNone, bdRightUp, bdTopUp);
  35.   TContrast        = 0..9;
  36.   TDecSeperator    = (dsPoint,dsComma,dsDoublePoint,dsMinus);
  37.   TMeterDirection  = (mdDown, mdLeft, mdRight, mdUp);
  38.   TNumGlyphs       = 0..4;
  39.   TScrewSize       = 1..8;
  40.   TSegmentStyle    = (ssRectangular, ssBeveled);
  41.   TTextPosition    = (tpAbove, tpBelow, tpNone, tpOnButton);
  42.  
  43.   TLEDButton = class(TGraphicControl)
  44.   private
  45.     FBeveled:          boolean;
  46.     FBorderStyle:      TBorderStyle;
  47.     FButtonDirection:  TButtonDirection;
  48.     FColor:            TColor;
  49.     FColorHighlight:   TColor;
  50.     FColorLED:         TColor;
  51.     FColorLEDOff:      TColor;
  52.     FColorShadow:      TColor;
  53.     FDepth:            integer;
  54.     FDown:             boolean;
  55.     FFont:             TFont;
  56.     FGlyph:            TBitmap;
  57.     FLEDContrast:      TContrast;
  58.     FNumGlyphs:        TNumGlyphs;
  59.     FShowLED:          boolean;
  60.     FStateOn:          boolean;
  61.     FSwitching:        boolean;
  62.     FTextPosition:     TTextPosition;
  63.  
  64.     FMouseDown:        boolean;
  65.     FOnClick:          TNotifyEvent;
  66.  
  67.   protected
  68.     procedure Paint;  override;
  69.     procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  70.        override;
  71.     procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  72.        override;
  73.  
  74.     procedure SetBeveled(newValue: boolean);
  75.     procedure SetBorderStyle(newBorderStyle: TBorderStyle);
  76.     procedure SetButtonDirection(NewDirection: TButtonDirection);
  77.     procedure SetColor(newColor: TColor);
  78.     procedure SetColorLED(newColor: TColor);
  79.     procedure SetDepth(newValue: integer);
  80.     procedure SetFont(newFont: TFont);
  81.     procedure SetGlyph(newGlyph: TBitmap);
  82.     procedure SetLEDContrast(newContrast: TContrast);
  83.     procedure SetNumGlyphs(newNumGlyphs: TNumGlyphs);
  84.     procedure SetShowLED(newValue: boolean);
  85.     procedure SetStateOn(newValue: boolean);
  86.     procedure SetTextPosition(newValue: TTextPosition);
  87.  
  88.     procedure DrawBorder(Dest:TRect);
  89.     procedure DrawCaption(Dest:TRect);
  90.     procedure DrawGlyph(Dest:TRect);
  91.     procedure DrawLED(var Dest:TRect);
  92.  
  93.   public
  94.     constructor Create(AOwner: TComponent); override;
  95.     destructor Destroy; override;
  96.  
  97.     procedure CMTextChanged(var msg: TMessage);message CM_TEXTCHANGED;
  98.     procedure CMDialogChar(var Message: TCMDialogChar);message CM_DIALOGCHAR;
  99.  
  100.   published
  101.     {$IFDEF SR_Delphi5_Up}
  102.     property Action;
  103.     property Anchors;
  104.     {$ENDIF}
  105.     property Beveled: boolean read FBeveled write SetBeveled;
  106.     property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle;
  107.     property ButtonDirection: TButtonDirection read FButtonDirection write SetButtonDirection;
  108.     property Caption;
  109.     property Color: TColor read FColor write SetColor;
  110.     property ColorLED: TColor read FColorLED write SetColorLED;
  111.     property Depth: integer read FDepth write SetDepth;
  112.     property Enabled;
  113.     property Font: TFont read FFont write SetFont;
  114.     property Glyph: TBitmap read FGlyph write SetGlyph;
  115.     property LEDContrast: TContrast read FLEDContrast write SetLEDContrast;
  116.     property NumGlyphs: TNumGlyphs read FNumGlyphs write SetNumGlyphs default 1;
  117.     property ParentFont;
  118.     property ParentShowHint;
  119.     {$IFDEF SR_Delphi3_Up}
  120.     property PopupMenu;
  121.     {$ENDIF}
  122.     property ShowHint;
  123.     property ShowLED: boolean read FShowLED write SetShowLED;
  124.     property StateOn: boolean read FStateOn write SetStateOn;
  125.     property Switching: boolean read FSwitching write FSwitching;
  126.     property TextPosition: TTextPosition read FTextPosition write SetTextPosition;
  127.     property Visible;
  128.  
  129.     property OnClick;
  130.     property OnDblClick;
  131.     property OnMouseDown;
  132.     property OnMouseMove;
  133.     property OnMouseUp;
  134.   end;
  135.  
  136.   TButtonPanel = class(TCustomPanel)
  137.   private
  138.     FBeveled:          boolean;
  139.     FBorderStyle:      TBorderStyle;
  140.     FColor:            TColor;
  141.     FColorHighlight:   TColor;
  142.     FColorShadow:      TColor;
  143.     FDepth:            integer;
  144.     FPanelDirection:   TButtonDirection;
  145.     FShowLED:          boolean;
  146.  
  147.   protected
  148.     procedure Paint;  override;
  149.  
  150.     procedure SetBeveled(newValue: boolean);
  151.     procedure SetBorderStyle(newBorderStyle: TBorderStyle);
  152.     procedure SetColor(newColor: TColor);
  153.     procedure SetDepth(newValue: integer);
  154.     procedure SetPanelDirection(NewDirection: TButtonDirection);
  155.     procedure SetShowLED(newValue: boolean);
  156.  
  157.     procedure DrawBorder(Dest:TRect);
  158.     procedure DrawCaption(Dest:TRect);
  159.     procedure DrawLED(var Dest:TRect);
  160.  
  161.   public
  162.     constructor Create(AOwner: TComponent); override;
  163.     destructor Destroy; override;
  164.  
  165.   published
  166.     property Align;
  167.     property Alignment;
  168.     {$IFDEF SR_Delphi5_Up}
  169.     property Anchors;
  170.     {$ENDIF}
  171.     property Beveled: boolean read FBeveled write SetBeveled;
  172.     property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle;
  173.     property Caption;
  174.     property Color: TColor read FColor write SetColor;
  175.     property Ctl3D;
  176.     property Depth: integer read FDepth write SetDepth;
  177.     property DragCursor;
  178.     property DragMode;
  179.     property Enabled;
  180.     {$IFDEF SR_Delphi3_Up}
  181.     property FullRepaint;
  182.     {$ENDIF}
  183.     property Font;
  184.     property Locked;
  185.     property PanelDirection: TButtonDirection read FPanelDirection write SetPanelDirection;
  186.     property ParentColor;
  187.     property ParentCtl3D;
  188.     property ParentFont;
  189.     property ParentShowHint;
  190.     property PopupMenu;
  191.     property ShowHint;
  192.     property ShowLED: boolean read FShowLED write SetShowLED;
  193.     property TabOrder;
  194.     property TabStop;
  195.     property Visible;
  196.  
  197.     property OnClick;
  198.     property OnDblClick;
  199.     property OnDragDrop;
  200.     property OnDragOver;
  201.     property OnEndDrag;
  202.     property OnEnter;
  203.     property OnExit;
  204.     property OnMouseDown;
  205.     property OnMouseMove;
  206.     property OnMouseUp;
  207.     property OnResize;
  208.     {$IFDEF SR_Delphi3_Up}
  209.     property OnStartDrag;
  210.     {$ENDIF}
  211.   end;
  212.  
  213.   TScrewPanel = class(TCustomPanel)
  214.   private
  215.     FColor:            TColor;
  216.     FColorHighlight:   TColor;
  217.     FColorShadow:      TColor;
  218.     FMargin:           integer;
  219.     FScrewSize:        TScrewSize;
  220.     FShowScrews:       boolean;
  221.  
  222.   protected
  223.     procedure Paint;  override;
  224.  
  225.     procedure SetColor(newColor: TColor);
  226.     procedure SetMargin(newValue: integer);
  227.     procedure SetScrewSize(newValue: TScrewSize);
  228.     procedure SetShowScrews(newValue: boolean);
  229.  
  230.     procedure DrawScrew(X,Y:integer);
  231.     procedure DrawBevel(ARect:TRect;Raised:boolean);
  232.  
  233.   public
  234.     constructor Create(AOwner: TComponent); override;
  235.     destructor Destroy; override;
  236.  
  237.   published
  238.     property Align;
  239.     property Alignment;
  240.     {$IFDEF SR_Delphi5_Up}
  241.     property Anchors;
  242.     {$ENDIF}
  243.     property BevelInner;
  244.     property BevelOuter;
  245.     property BevelWidth;
  246.     property BorderWidth;
  247.     property BorderStyle;
  248.     property Caption;
  249.     property Color: TColor read FColor write SetColor;
  250.     property Ctl3D;
  251.     property DragCursor;
  252.     property DragMode;
  253.     property Enabled;
  254.     {$IFDEF SR_Delphi3_Up}
  255.     property FullRepaint;
  256.     {$ENDIF}
  257.     property Font;
  258.     property Locked;
  259.     property Margin: integer read FMargin write SetMargin;
  260.     property ParentColor;
  261.     property ParentCtl3D;
  262.     property ParentFont;
  263.     property ParentShowHint;
  264.     property PopupMenu;
  265.     property ScrewSize: TScrewSize read FScrewSize write SetScrewSize;
  266.     property ShowHint;
  267.     property ShowScrews: boolean read FShowScrews write SetShowScrews;
  268.     property TabOrder;
  269.     property TabStop;
  270.     property Visible;
  271.  
  272.     property OnClick;
  273.     property OnDblClick;
  274.     property OnDragDrop;
  275.     property OnDragOver;
  276.     property OnEndDrag;
  277.     property OnEnter;
  278.     property OnExit;
  279.     property OnMouseDown;
  280.     property OnMouseMove;
  281.     property OnMouseUp;
  282.     property OnResize;
  283.     {$IFDEF SR_Delphi3_Up}
  284.     property OnStartDrag;
  285.     {$ENDIF}
  286.   end;
  287.  
  288.   TLEDDisplay = class(TGraphicControl)
  289.   private
  290.     FBevelStyle      : TPanelBevel;
  291.     FBorderStyle     : TBorderStyle;
  292.     FColorBackGround,
  293.     FColorLED        : TColor;
  294.     FDecSeperator    : TDecSeperator;
  295.     FDigit           : array [0..10] of TBitmap;
  296.     FDigitHeight,
  297.     FDigitWidth,
  298.     FFractionDigits  : integer;
  299.     FLEDContrast     : TContrast;
  300.     FLEDOffColor     : TColor;
  301.     FLineWidth,
  302.     FNumDigits       : integer;
  303.     FLeadingZeros    : boolean;
  304.     FSegCl           : array [0..10, 1..7] of TColor;
  305.     FSegmentStyle    : TSegmentStyle;
  306.     FValue           : extended;
  307.  
  308.     FOnChange        : TNotifyEvent;
  309.  
  310.     procedure SetBevelStyle (newValue: TPanelBevel);
  311.     procedure SetBorderStyle (newValue: TBorderStyle);
  312.     procedure SetColorBackGround (newValue: TColor);
  313.     procedure SetColorLED (newValue: TColor);
  314.     procedure SetDecSeperator (newValue: TDecSeperator);
  315.     procedure SetDigitHeight (newValue: integer);
  316.     procedure SetDigitWidth (newValue: integer);
  317.     procedure SetFractionDigits (newValue: integer);
  318.     procedure SetLeadingZeros (newValue: boolean);
  319.     procedure SetLEDContrast(newContrast: TContrast);
  320.     procedure SetLineWidth (newValue: integer);
  321.     procedure SetNumDigits (newValue: integer);
  322.     procedure SetSegmentStyle (newValue: TSegmentStyle);
  323.     procedure SetValue (newValue: extended);
  324.  
  325.     procedure GenerateBitMaps;
  326.     procedure AssignColors (seg: integer; s1,s2,s3,s4,s5,s6,s7: Boolean);
  327.  
  328.   protected
  329.     procedure paint; override;
  330.     procedure Change; dynamic;
  331.  
  332.  
  333.   public
  334.     constructor Create (AOwner: TComponent); override;
  335.     destructor Destroy; override;
  336.  
  337.   published
  338.     {$IFDEF SR_Delphi5_Up}
  339.     property Anchors;
  340.     {$ENDIF}
  341.     property BevelStyle: TPanelBevel read FBevelStyle write SetBevelStyle;
  342.     property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle;
  343.     property ColorBackGround: TColor read FColorBackGround write setColorBackGround default clOlive;
  344.     property ColorLED: TColor read FColorLED write setColorLED default cllime;
  345.     property DecSeperator: TDecSeperator read FDecSeperator write setDecSeperator;
  346.     property DigitHeight: integer read FDigitHeight write setDigitHeight default 30;
  347.     property DigitWidth: integer read FDigitWidth write setDigitWidth default 20;
  348.     property DigitLineWidth: integer read FLineWidth write setLineWidth default 3;
  349.     property FractionDigits: integer read FFractionDigits write setFractionDigits default 0;
  350.     property Height default 36;
  351.     property LeadingZeros: boolean read FLeadingZeros write setLeadingZeros default true;
  352.     property LEDContrast: TContrast read FLEDContrast write SetLEDContrast;
  353.     property NumDigits: integer read FNumDigits write setNumDigits default 6;
  354.     property SegmentStyle: TSegmentStyle read FSegmentStyle write setSegmentStyle;
  355.     property Value: extended read FValue write setValue;
  356.     property Visible;
  357.     property Width default 168;
  358.  
  359.     property OnChange: TNotifyEvent read FOnChange write FOnChange;
  360.     property OnClick;
  361.     property OnDblClick;
  362.     property OnDragDrop;
  363.     property OnDragOver;
  364.     property OnEndDrag;
  365.     property OnMouseDown;
  366.     property OnMouseMove;
  367.     property OnMouseUp;
  368.   end;
  369.  
  370.   TLEDMeter = class(TGraphicControl)
  371.   private
  372.     FBevelStyle     : TPanelBevel;
  373.     FColorLED1,
  374.     FColorLED2,
  375.     FColorLED3,
  376.     FColorOff1,
  377.     FColorOff2,
  378.     FColorOff3,
  379.     FColorSeperator : TColor;
  380.     FDirection      : TMeterDirection;
  381.     FLEDContrast    : TContrast;
  382.     FMax, FMin,
  383.     FNumDigits,
  384.     FPosition        : integer;
  385.     FSingleLED      : boolean;
  386.     FStartColor2,
  387.     FStartColor3    : integer;
  388.  
  389.     FOnChange       : TNotifyEvent;
  390.  
  391.     procedure SetBevelStyle(newVal : TPanelBevel);
  392.     procedure SetColorLED1(newVal : tColor);
  393.     procedure SetColorLED2(newVal : tColor);
  394.     procedure SetColorLED3(newVal : tColor);
  395.     procedure SetColorSeperator(newVal : tColor);
  396.     procedure SetDirection(newVal : TMeterdirection);
  397.     procedure SetLEDContrast(newContrast: TContrast);
  398.     procedure SetMax(newVal : integer);
  399.     procedure SetMin(newVal : integer);
  400.     procedure SetNumDigits(newVal : integer);
  401.     procedure SetPosition(newVal : integer);
  402.     procedure SetSingleLED(newVal : boolean);
  403.     procedure SetStartColor2(newVal : integer);
  404.     procedure SetStartColor3(newVal : integer);
  405.  
  406.   protected
  407.     procedure Paint;override;
  408.     procedure Change; dynamic;
  409.  
  410.   public
  411.     constructor Create(AOwner : TComponent);override;
  412.     destructor Destroy ; override;
  413.  
  414.   published
  415.     {$IFDEF SR_Delphi5_Up}
  416.     property Anchors;
  417.     {$ENDIF}
  418.     property BevelStyle: TPanelBevel read FBevelStyle write SetBevelStyle;
  419.     property ColorLED1 : TColor read FColorLED1 write setColorLED1;
  420.     property ColorLED2 : TColor read FColorLED2 write setColorLED2;
  421.     property ColorLED3 : TColor read FColorLED3 write setColorLED3;
  422.     property ColorSeperator: TColor read FColorSeperator write setColorSeperator;
  423.     property Cursor;
  424.     property Direction: TMeterDirection read FDirection write setDirection;
  425.     property DragCursor;
  426.     property DragMode;
  427.     property LEDContrast: TContrast read FLEDContrast write SetLEDContrast;
  428.     property Max: integer read FMax write setMax;
  429.     property Min: integer read FMin write setMin;
  430.     property NumDigits: integer read FNumDigits write setNumDigits;
  431.     property Position: integer read FPosition write setPosition;
  432.     property SingleLED : boolean read FSingleLED write setSingleLED;
  433.     property StartColor2: integer read FStartColor2 write setStartColor2;
  434.     property StartColor3: integer read FStartColor3 write setStartColor3;
  435.     property Visible;
  436.  
  437.     property OnChange: TNotifyEvent read FOnChange write FOnChange;
  438.     property OnClick;
  439.     property OnDblClick;
  440.     property OnDragDrop;
  441.     property OnDragOver;
  442.     property OnEndDrag;
  443.     property OnMouseDown;
  444.     property OnMouseMove;
  445.     property OnMouseUp;
  446. end;
  447.  
  448. procedure Register;
  449.  
  450. implementation
  451.  
  452. {$IFDEF SR_Delphi2_Up}
  453. {$R *.D32}
  454. uses rrColors;
  455. {$ELSE}
  456. {$R *.D16}
  457. {$ENDIF}
  458.  
  459. const
  460.   DefaultWidth  = 45;
  461.   DefaultHeight = 45;
  462.   DefaultDepth  = 3;
  463.   FHLContrast   = 5;
  464.   FShContrast   = 4;
  465.  
  466. function IsAccellerator(VK: Word; const Str: string): Boolean;
  467. var
  468.   P : Integer;
  469. begin
  470.   P := Pos('&', Str);
  471.   Result := (P <> 0) and (P < Length(Str)) and
  472.     (Upcase(Str[P + 1])=Upcase(Char(VK)));
  473. end;
  474.  
  475. {$IFDEF SR_Delphi1}
  476. function ChangeBrightness(Color:TColor;Percentage:longint):TColor;
  477. var RGBColor       : longint;
  478.     Red,Green,Blue : byte;
  479.     NewR,NewG,NewB : longint;
  480.     Overflow       : longint;
  481. begin
  482.   RGBColor:=ColorToRGB(Color);
  483.   Overflow:=0;
  484.   { Rot }
  485.   Red:=GetRValue(RGBColor);
  486.   NewR:=Red+(Percentage*Red div 100);
  487.   if NewR>255 then begin
  488.     Overflow:=NewR-255;
  489.     NewG:=Overflow;
  490.     NewB:=Overflow;
  491.   end
  492.   else begin
  493.     NewG:=0;
  494.     NewB:=0;
  495.   end;
  496.   { Grⁿn }
  497.   Green:=GetGValue(RGBColor);
  498.   NewG:=NewG+Green+(Percentage*Green div 100);
  499.   if NewG>255 then begin
  500.     Overflow:=NewG-255;
  501.     NewR:=NewR+Overflow;
  502.     NewB:=Overflow;
  503.   end;
  504.   { Blau }
  505.   Blue:=GetBValue(RGBColor);
  506.   NewB:=NewB+Blue+(Percentage*Blue div 100);
  507.   if NewB>255 then begin
  508.     Overflow:=NewB-255;
  509.     if NewG<=255 then
  510.       NewR:=NewR+Overflow;
  511.   end;
  512.   if NewR>255 then
  513.     NewR:=255;
  514.   if NewG>255 then
  515.     NewG:=255;
  516.   if NewB>255 then
  517.     NewB:=255;
  518.   if NewR<0 then
  519.     NewR:=0;
  520.   if NewG<0 then
  521.     NewG:=0;
  522.   if NewB<0 then
  523.     NewB:=0;
  524.   Result:=NewR+(NewG shl 8)+(NewB shl 16);
  525. end;
  526. {$ENDIF}
  527.  
  528. procedure AssignBevelColors(FaceColor:TColor;var HighlightColor,ShadowColor:TColor;HLContrast,ShContrast:integer);
  529. begin
  530.   {$IFDEF SR_Delphi1}
  531.   HighlightColor:=ChangeBrightness(FaceColor,100 div 10*HLContrast);
  532.   ShadowColor:=ChangeBrightness(FaceColor,-100 div 10*ShContrast);
  533.   {$ELSE}
  534.   Get3DColors(FaceColor,HighlightColor,ShadowColor,(10-HLContrast)/10,(10-ShContrast)/10);
  535.   {$ENDIF}
  536. end;
  537.  
  538.  
  539. { Komponente TLEDButton }
  540. constructor TLEDButton.Create(AOwner: TComponent);
  541. var Dummy : TColor;
  542. begin
  543.   inherited Create(AOwner);
  544.  
  545.   { Vorgabewerte setzen }
  546.   FBeveled:=true;
  547.   FBorderStyle:=bsSingle;
  548.   FButtonDirection:=bdBottomUp;
  549.   FColor:=clGray;
  550.   AssignBevelColors(FColor,FColorHighlight,FColorShadow,FHLContrast,FShContrast);
  551.   FColorLED:=clBlue;
  552.   FLEDContrast:=6;
  553.   AssignBevelColors(FColorLED,Dummy,FColorLEDOff,FLEDContrast,FLEDContrast);
  554.   FDepth:=DefaultDepth;
  555.   FDown:=false;
  556.   FFont:=TFont.Create;
  557.   FGlyph:=TBitmap.Create;
  558.   FNumGlyphs:=1;
  559.   FShowLED:=true;
  560.   FStateOn:=false;
  561.   FSwitching:=true;
  562.   FTextPosition:=tpNone;
  563.   Height:=DefaultHeight;
  564.   Width:=DefaultWidth;
  565.  
  566.   FMouseDown:=False;
  567. end;
  568.  
  569. destructor  TLEDButton.Destroy;
  570. begin
  571.   FFont.Free;
  572.   FGlyph.Free;
  573.   inherited Destroy;
  574. end;
  575.  
  576. procedure TLEDButton.SetBeveled(NewValue: boolean);
  577. begin
  578.   if FBeveled<>NewValue then begin
  579.     FBeveled:=NewValue;
  580.     Invalidate;
  581.   end;
  582. end;
  583.  
  584. procedure TLEDButton.SetBorderStyle(NewBorderStyle: TBorderStyle);
  585. begin
  586.   if FBorderStyle<>NewBorderStyle then begin
  587.     FBorderStyle:=NewBorderStyle;
  588.     Invalidate;
  589.   end;
  590. end;
  591.  
  592. procedure TLEDButton.SetButtonDirection(NewDirection: TButtonDirection);
  593. begin
  594.   if FButtonDirection<>NewDirection then begin
  595.     FButtonDirection:=NewDirection;
  596.     Invalidate;
  597.   end;
  598. end;
  599.  
  600. procedure TLEDButton.SetColor(newColor: TColor);
  601. begin
  602.   if FColor<>newColor then begin
  603.     FColor:=newColor;
  604.     AssignBevelColors(FColor,FColorHighlight,FColorShadow,FHLContrast,FShContrast);
  605.     Invalidate;
  606.   end;
  607. end;
  608.  
  609. procedure TLEDButton.SetColorLED(newColor: TColor);
  610. var Dummy : TColor;
  611. begin
  612.   if FColorLED<>newColor then begin
  613.     FColorLED:=newColor;
  614.     AssignBevelColors(FColorLED,Dummy,FColorLEDOff,FLEDContrast,FLEDContrast);
  615.     Invalidate;
  616.   end;
  617. end;
  618.  
  619. procedure TLEDButton.SetDepth(newValue: integer);
  620. begin
  621.   if FDepth<>newValue then begin
  622.     FDepth:=newValue;
  623.     Invalidate;
  624.   end;
  625. end;
  626.  
  627. procedure TLEDButton.SetFont(newFont: TFont);
  628. begin
  629.   FFont.Assign(NewFont);
  630.   Invalidate;
  631. end;
  632.  
  633. procedure TLEDButton.SetGlyph(newGlyph: TBitmap);
  634. begin
  635.   if(Assigned(FGlyph)) then begin
  636.     FGlyph.Assign(newGlyph);
  637.  
  638.     if (csDesigning in ComponentState) then begin
  639.       { Glyph 1: Normal, 2: Disabled, 3: Down;
  640.         Mu▀ die Ausma▀e (Height * NumGlyphs) = Width  haben}
  641.       if (newGlyph.width mod newGlyph.height = 0) then
  642.         FNumGlyphs:= newGlyph.width div newGlyph.height
  643.       else
  644.         FNumGlyphs:= 1;
  645.     end;
  646.  
  647.     Invalidate;
  648.   end;
  649. end;
  650.  
  651. procedure TLEDButton.SetLEDContrast(newContrast: TContrast);
  652. var Dummy : TColor;
  653. begin
  654.   if (FLEDContrast<>newContrast) and (newContrast>=0) and (newContrast<10) then begin
  655.     FLEDContrast:=newContrast;
  656.     AssignBevelColors(FColorLED,Dummy,FColorLEDOff,FLEDContrast,FLEDContrast);
  657.     Invalidate;
  658.   end;
  659. end;
  660.  
  661. procedure TLEDButton.SetNumGlyphs(newNumGlyphs: TNumGlyphs);
  662. begin
  663.   if FNumGlyphs<>newNumGlyphs then begin
  664.     FNumGlyphs:=newNumGlyphs;
  665.     Invalidate;
  666.   end;
  667. end;
  668.  
  669. procedure TLEDButton.SetShowLED(newValue: boolean);
  670. begin
  671.   if FShowLED<>newValue then begin
  672.     FShowLED:=newValue;
  673.     Invalidate;
  674.   end;
  675. end;
  676.  
  677. procedure TLEDButton.SetStateOn(newValue: boolean);
  678. begin
  679.   if FStateOn<>newValue then begin
  680.     FStateOn:=newValue;
  681.     Invalidate;
  682.   end;
  683. end;
  684.  
  685. procedure TLEDButton.SetTextPosition(newValue: TTextPosition);
  686. begin
  687.   if FTextPosition<>newValue then begin
  688.     FTextPosition:=newValue;
  689.     Invalidate;
  690.   end;
  691. end;
  692.  
  693. procedure TLEDButton.DrawBorder(Dest:TRect);
  694. var i : integer;
  695. begin
  696.   Dest:=GetClientRect;
  697.   if FTextPosition=tpAbove then
  698.     Dest.Top:=Dest.Top+Canvas.TextWidth('W')+2;
  699.   if FTextPosition=tpBelow then
  700.     Dest.Bottom:=Dest.Bottom-Canvas.TextWidth('W')-2;
  701.   with Canvas do begin
  702.     if FBorderStyle=bsSingle then begin
  703.       Brush.Color:=clWindowFrame;
  704.       FrameRect(Dest);
  705.       InflateRect(Dest,-1,-1);
  706.     end;
  707.     Pen.Width:=1;
  708.     if FButtonDirection=bdBottomUp then begin
  709.       Pen.Color:=FColorHighlight;
  710.       { oben }
  711.       MoveTo(Dest.Right-1,Dest.Top);
  712.       LineTo(Dest.Left,Dest.Top);
  713.       { links }
  714.       if not FBeveled then begin
  715.         MoveTo(Dest.Left,Dest.Top);
  716.         LineTo(Dest.Left,Dest.Bottom-1);
  717.       end
  718.       else
  719.         for i:=0 to FDepth do begin
  720.           MoveTo(Dest.Left,Dest.Top);
  721.           if FDown then
  722.             LineTo(Dest.Left+(i div 2),Dest.Bottom-1)
  723.           else
  724.             LineTo(Dest.Left+i,Dest.Bottom-i-1);
  725.         end;
  726.       Pen.Color:=FColorShadow;
  727.       { rechts }
  728.       if not FBeveled then begin
  729.         MoveTo(Dest.Right-1,Dest.Top);
  730.         LineTo(Dest.Right-1,Dest.Bottom);
  731.       end
  732.       else
  733.         for i:=0 to FDepth do begin
  734.           MoveTo(Dest.Right-1,Dest.Top);
  735.           if FDown then
  736.             LineTo(Dest.Right-(i div 2)-1,Dest.Bottom-1)
  737.           else
  738.             LineTo(Dest.Right-i-1,Dest.Bottom-i-1);
  739.         end;
  740.       { unten }
  741.       if FDown then begin
  742.         MoveTo(Dest.Left,Dest.Bottom-1);
  743.         LineTo(Dest.Right-1,Dest.Bottom-1);
  744.       end
  745.       else
  746.         for i:=0 to FDepth do begin
  747.           if not FBeveled then begin
  748.             MoveTo(Dest.Left,Dest.Bottom-i-1);
  749.             LineTo(Dest.Right-1,Dest.Bottom-i-1);
  750.           end
  751.           else begin
  752.             MoveTo(Dest.Left+i,Dest.Bottom-i-1);
  753.             LineTo(Dest.Right-i-1,Dest.Bottom-i-1);
  754.           end;
  755.         end;
  756.     end;
  757.     if FButtonDirection=bdTopUp then begin
  758.       Pen.Color:=FColorHighlight;
  759.       { oben }
  760.       if FDown then begin
  761.         MoveTo(Dest.Left,Dest.Top);
  762.         LineTo(Dest.Right-1,Dest.Top);
  763.       end
  764.       else
  765.         for i:=0 to FDepth do begin
  766.           if not FBeveled then begin
  767.             MoveTo(Dest.Left,Dest.Top+i);
  768.             LineTo(Dest.Right-1,Dest.Top+i);
  769.           end
  770.           else begin
  771.             MoveTo(Dest.Left+i,Dest.Top+i);
  772.             LineTo(Dest.Right-i-1,Dest.Top+i);
  773.           end;
  774.         end;
  775.       { links }
  776.       if not FBeveled then begin
  777.         MoveTo(Dest.Left,Dest.Top);
  778.         LineTo(Dest.Left,Dest.Bottom-1);
  779.       end
  780.       else
  781.         for i:=0 to FDepth do begin
  782.           MoveTo(Dest.Left,Dest.Bottom-1);
  783.           if FDown then
  784.             LineTo(Dest.Left+(i div 2),Dest.Top)
  785.           else
  786.             LineTo(Dest.Left+i,Dest.Top+i);
  787.         end;
  788.       Pen.Color:=FColorShadow;
  789.       { rechts }
  790.       if not FBeveled then begin
  791.         MoveTo(Dest.Right-1,Dest.Top);
  792.         LineTo(Dest.Right-1,Dest.Bottom);
  793.       end
  794.       else
  795.         for i:=0 to FDepth do begin
  796.           MoveTo(Dest.Right-1,Dest.Bottom-1);
  797.           if FDown then
  798.             LineTo(Dest.Right-(i div 2)-1,Dest.Top)
  799.           else
  800.             LineTo(Dest.Right-i-1,Dest.Top+i);
  801.         end;
  802.       { unten }
  803.       MoveTo(Dest.Right-1,Dest.Bottom-1);
  804.       LineTo(Dest.Left,Dest.Bottom-1);
  805.     end;
  806.     if FButtonDirection=bdLeftUp then begin
  807.       Pen.Color:=FColorHighlight;
  808.       { oben }
  809.       if not FBeveled then begin
  810.         MoveTo(Dest.Left,Dest.Top);
  811.         LineTo(Dest.Right-1,Dest.Top);
  812.       end
  813.       else
  814.         for i:=0 to FDepth do begin
  815.           MoveTo(Dest.Right-1,Dest.Top);
  816.           if FDown then
  817.             LineTo(Dest.Left,Dest.Top+(i div 2))
  818.           else
  819.             LineTo(Dest.Left+i,Dest.Top+i);
  820.         end;
  821.       { links }
  822.       if FDown then begin
  823.         MoveTo(Dest.Left,Dest.Top);
  824.         LineTo(Dest.Left,Dest.Bottom-1);
  825.       end
  826.       else
  827.         for i:=0 to FDepth do begin
  828.           if not FBeveled then begin
  829.             MoveTo(Dest.Left+i,Dest.Top);
  830.             LineTo(Dest.Left+i,Dest.Bottom-1);
  831.           end
  832.           else begin
  833.             MoveTo(Dest.Left+i,Dest.Top+i);
  834.             LineTo(Dest.Left+i,Dest.Bottom-i-1);
  835.           end;
  836.         end;
  837.       Pen.Color:=FColorShadow;
  838.       { rechts }
  839.       MoveTo(Dest.Right-1,Dest.Top);
  840.       LineTo(Dest.Right-1,Dest.Bottom-1);
  841.       { unten }
  842.       if not FBeveled then begin
  843.         MoveTo(Dest.Right-1,Dest.Bottom-1);
  844.         LineTo(Dest.Left,Dest.Bottom-1);
  845.       end
  846.       else
  847.         for i:=0 to FDepth do begin
  848.           MoveTo(Dest.Right-1,Dest.Bottom-1);
  849.           if FDown then
  850.             LineTo(Dest.Left,Dest.Bottom-(i div 2)-1)
  851.           else
  852.             LineTo(Dest.Left+i,Dest.Bottom-i-1);
  853.         end;
  854.     end;
  855.     if FButtonDirection=bdRightUp then begin
  856.       Pen.Color:=FColorHighlight;
  857.       { oben }
  858.       if not FBeveled then begin
  859.         MoveTo(Dest.Left,Dest.Top);
  860.         LineTo(Dest.Right-1,Dest.Top);
  861.       end
  862.       else
  863.         for i:=0 to FDepth do begin
  864.           MoveTo(Dest.Left,Dest.Top);
  865.           if FDown then
  866.             LineTo(Dest.Right-1,Dest.Top+(i div 2))
  867.           else
  868.             LineTo(Dest.Right-1-i,Dest.Top+i);
  869.         end;
  870.       { links }
  871.       MoveTo(Dest.Left,Dest.Top);
  872.       LineTo(Dest.Left,Dest.Bottom-1);
  873.       Pen.Color:=FColorShadow;
  874.       { rechts }
  875.       if FDown then begin
  876.         MoveTo(Dest.Right-1,Dest.Top);
  877.         LineTo(Dest.Right-1,Dest.Bottom-1);
  878.       end
  879.       else
  880.         for i:=0 to FDepth do begin
  881.           if not FBeveled then begin
  882.             MoveTo(Dest.Right-1-i,Dest.Top);
  883.             LineTo(Dest.Right-1-i,Dest.Bottom-1);
  884.           end
  885.           else begin
  886.             MoveTo(Dest.Right-1-i,Dest.Top+i);
  887.             LineTo(Dest.Right-1-i,Dest.Bottom-i-1);
  888.           end;
  889.         end;
  890.       { unten }
  891.       if not FBeveled then begin
  892.         MoveTo(Dest.Left,Dest.Bottom-1);
  893.         LineTo(Dest.Right-1,Dest.Bottom-1);
  894.       end
  895.       else
  896.         for i:=0 to FDepth do begin
  897.           MoveTo(Dest.Left,Dest.Bottom-1);
  898.           if FDown then
  899.             LineTo(Dest.Right-1,Dest.Bottom-(i div 2)-1)
  900.           else
  901.             LineTo(Dest.Right-1-i,Dest.Bottom-i-1);
  902.         end;
  903.     end;
  904.   end;
  905. end;
  906.  
  907. procedure TLEDButton.DrawCaption(Dest:TRect);
  908. var OutText : array [0..79] of char;
  909. begin
  910.   with Canvas do begin
  911.     Brush.Style:=bsClear;
  912.     StrPCopy(OutText, Caption);
  913.     if not Enabled then
  914.       Font.Color:=clGrayText;
  915.     if FTextPosition=tpAbove then
  916.       DrawText(Handle, OutText, length(Caption), Dest, dt_center or dt_top or dt_singleline);
  917.     if FTextPosition=tpBelow then
  918.       DrawText(Handle, OutText, length(Caption), Dest, dt_center or dt_bottom or dt_singleline);
  919.     if FTextPosition=tpOnButton then
  920.       DrawText(Handle, OutText, length(Caption), Dest, dt_center or dt_vcenter or dt_singleline);
  921.   end;
  922. end;
  923.  
  924. procedure TLEDButton.DrawGlyph(Dest:TRect);
  925. var
  926.   Source    : TRect;
  927.   outWidth  : integer;
  928.   outHeight : integer;
  929. begin
  930.   with Canvas do begin
  931.     { Gr÷▀e des Destination-Rechtecks }
  932.     outWidth:=  FGlyph.Width div FNumGlyphs;
  933.     outHeight:= FGlyph.Height;
  934.     with Source do begin
  935.       Top:=0;
  936.       Bottom:=FGlyph.Height;
  937.       { Glyph 1: Normal, 2: Disabled, 3: Down;}
  938.       if Enabled then begin
  939.         if FStateOn and (FNumGlyphs>2) then
  940.           Left:=(outWidth*2)+1
  941.         else
  942.           Left:=0;
  943.       end
  944.       else
  945.         Left:=outWidth+1;
  946.       Right:= Left+outWidth;
  947.     end;
  948.     Dest.Left:=  ((Dest.Right +Dest.Left - outWidth)  shr 1);
  949.     Dest.Right:= Dest.Left+outWidth;
  950.     Dest.Top:=   ((Dest.Bottom + Dest.Top - outHeight) shr 1);
  951.     Dest.Bottom:=Dest.Top+outHeight;
  952.     Pen.Color := Color;
  953.     BrushCopy(Dest,FGlyph,Source,FGlyph.Canvas.Pixels[0,FGlyph.Height-1]);
  954.   end;
  955. end;
  956.  
  957. procedure TLEDButton.DrawLED(var Dest:TRect);
  958. begin
  959.   with Canvas do begin
  960.     if FStateOn then
  961.       Brush.Color:=FColorLED
  962.     else
  963.       Brush.Color:=FColorLEDOff;
  964.     if not Enabled then
  965.       Brush.Color:=FColor;
  966.     case ButtonDirection of
  967.       bdLeftUp : begin
  968.         if FDown then
  969.           OffsetRect(Dest,-FDepth div 2,0);
  970.         Rectangle(Dest.Left+FDepth+9,Dest.Top+FDepth+3,Dest.Left+FDepth+4,Dest.Bottom-FDepth-3);
  971.         Dest.Left:=Dest.Left+FDepth+9;
  972.       end;
  973.       bdRightUp : begin
  974.         if FDown then
  975.           OffsetRect(Dest,FDepth div 2,0);
  976.         Rectangle(Dest.Right-FDepth-9,Dest.Top+FDepth+3,Dest.Right-FDepth-4,Dest.Bottom-FDepth-3);
  977.         Dest.Right:=Dest.Right-FDepth-9;
  978.       end;
  979.       bdTopUp : begin
  980.         if FDown then
  981.           OffsetRect(Dest,0,-FDepth div 2);
  982.         Rectangle(Dest.Left+FDepth+3,Dest.Top+FDepth+4,Dest.Right-FDepth-3,Dest.Top+FDepth+9);
  983.         Dest.Top:=Dest.Top+FDepth+7;
  984.       end;
  985.       else begin
  986.         if FDown then
  987.           OffsetRect(Dest,0,FDepth div 2);
  988.         Rectangle(Dest.Left+FDepth+3,Dest.Bottom-FDepth-9,Dest.Right-FDepth-3,Dest.Bottom-FDepth-4);
  989.         Dest.Bottom:=Dest.Bottom-FDepth-7;
  990.       end;
  991.     end;
  992.   end;
  993. end;
  994.  
  995. procedure TLEDButton.Paint;
  996. var ARect : TRect;
  997. begin
  998.   Canvas.Font.Assign(Font);
  999.   with Canvas do begin
  1000.     ARect:=GetClientRect;
  1001.     if (Caption<>'') and (FTextPosition<>tpOnButton) and (FTextPosition<>tpNone) then
  1002.       DrawCaption(ARect);
  1003.     if FTextPosition=tpAbove then
  1004.       ARect.Top:=ARect.Top+TextWidth('W')+2;
  1005.     if FTextPosition=tpBelow then
  1006.       ARect.Bottom:=ARect.Bottom-TextWidth('W')-2;
  1007.     Brush.Style:=bsSolid;
  1008.     Brush.Color:=FColor;
  1009.     FillRect(ARect);
  1010.     DrawBorder(ARect);
  1011.     Pen.Color:=clBlack;
  1012.     if FShowLED then
  1013.       DrawLED(ARect);
  1014.     if (Caption<>'') and (FTextPosition=tpOnButton) then
  1015.       DrawCaption(ARect);
  1016.     Brush.Color:=Self.Color;
  1017.     if Assigned(FGlyph) and (FNumGlyphs > 0) and (FTextPosition<>tpOnButton) then
  1018.       DrawGlyph(ARect);
  1019.   end;
  1020. end;
  1021.  
  1022. procedure TLEDButton.CMDialogChar(var Message: TCMDialogChar);
  1023. begin
  1024.   with Message do begin
  1025.     if IsAccellerator(CharCode, Caption) then begin
  1026.       if Enabled then begin
  1027.         Click;
  1028.         if FSwitching then
  1029.           FStateOn:=not FStateOn;
  1030.         Invalidate;
  1031.       end;
  1032.       Result := 1;
  1033.     end
  1034.     else
  1035.       inherited;
  1036.   end;
  1037. end;
  1038.  
  1039. procedure TLEDButton.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1040. begin
  1041.   if Enabled then begin
  1042.     FDown:=true;
  1043.     Invalidate;
  1044.   end;
  1045.   FMouseDown:= True;
  1046. end;
  1047.  
  1048. procedure TLEDButton.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
  1049. begin
  1050.   if Enabled then begin
  1051.     FDown:=false;
  1052.     if FSwitching then
  1053.       FStateOn:=not FStateOn;
  1054.     Paint;
  1055.     if Assigned(FOnClick) then
  1056.        FOnClick(Self);
  1057.   end;
  1058.   FMouseDown:= False;
  1059. end;
  1060.  
  1061. procedure TLEDButton.CMTextChanged(var msg: TMessage);
  1062. begin
  1063.   Invalidate;
  1064. end;
  1065.  
  1066.  
  1067. { Komponente TButtonPanel }
  1068. constructor TButtonPanel.Create(AOwner: TComponent);
  1069. begin
  1070.   inherited Create(AOwner);
  1071.  
  1072.   { Vorgabewerte setzen }
  1073.   FBeveled:=true;
  1074.   FBorderStyle:=bsSingle;
  1075.   FPanelDirection:=bdBottomUp;
  1076.   FColor:=clGray;
  1077.   AssignBevelColors(FColor,FColorHighlight,FColorShadow,FHLContrast,FShContrast);
  1078.   FDepth:=DefaultDepth;
  1079.   FShowLED:=true;
  1080.   Height:=DefaultHeight;
  1081.   Width:=DefaultWidth;
  1082. end;
  1083.  
  1084. destructor  TButtonPanel.Destroy;
  1085. begin
  1086.   inherited Destroy;
  1087. end;
  1088.  
  1089. procedure TButtonPanel.SetBeveled(NewValue: boolean);
  1090. begin
  1091.   if FBeveled<>NewValue then begin
  1092.     FBeveled:=NewValue;
  1093.     Invalidate;
  1094.   end;
  1095. end;
  1096.  
  1097. procedure TButtonPanel.SetBorderStyle(NewBorderStyle: TBorderStyle);
  1098. begin
  1099.   if FBorderStyle<>NewBorderStyle then begin
  1100.     FBorderStyle:=NewBorderStyle;
  1101.     Invalidate;
  1102.   end;
  1103. end;
  1104.  
  1105. procedure TButtonPanel.SetPanelDirection(NewDirection: TButtonDirection);
  1106. begin
  1107.   if FPanelDirection<>NewDirection then begin
  1108.     FPanelDirection:=NewDirection;
  1109.     Invalidate;
  1110.   end;
  1111. end;
  1112.  
  1113. procedure TButtonPanel.SetColor(newColor: TColor);
  1114. begin
  1115.   if FColor<>newColor then begin
  1116.     FColor:=newColor;
  1117.     AssignBevelColors(FColor,FColorHighlight,FColorShadow,FHLContrast,FShContrast);
  1118.     Invalidate;
  1119.   end;
  1120. end;
  1121.  
  1122. procedure TButtonPanel.SetDepth(newValue: integer);
  1123. begin
  1124.   if FDepth<>newValue then begin
  1125.     FDepth:=newValue;
  1126.     Invalidate;
  1127.   end;
  1128. end;
  1129.  
  1130. procedure TButtonPanel.SetShowLED(newValue: boolean);
  1131. begin
  1132.   if FShowLED<>newValue then begin
  1133.     FShowLED:=newValue;
  1134.     Invalidate;
  1135.   end;
  1136. end;
  1137.  
  1138. procedure TButtonPanel.DrawBorder(Dest:TRect);
  1139. var i : integer;
  1140. begin
  1141.   Dest:=GetClientRect;
  1142.   with Canvas do begin
  1143.     if FBorderStyle=bsSingle then begin
  1144.       Brush.Color:=clWindowFrame;
  1145.       FrameRect(Dest);
  1146.       InflateRect(Dest,-1,-1);
  1147.     end;
  1148.     Pen.Width:=1;
  1149.     if FPanelDirection=bdBottomUp then begin
  1150.       Pen.Color:=FColorHighlight;
  1151.       { oben }
  1152.       MoveTo(Dest.Right-1,Dest.Top);
  1153.       LineTo(Dest.Left,Dest.Top);
  1154.       { links }
  1155.       if not FBeveled then begin
  1156.         MoveTo(Dest.Left,Dest.Top);
  1157.         LineTo(Dest.Left,Dest.Bottom-1);
  1158.       end
  1159.       else
  1160.         for i:=0 to FDepth do begin
  1161.           MoveTo(Dest.Left,Dest.Top);
  1162.           LineTo(Dest.Left+i,Dest.Bottom-i-1);
  1163.         end;
  1164.       Pen.Color:=FColorShadow;
  1165.       { rechts }
  1166.       if not FBeveled then begin
  1167.         MoveTo(Dest.Right-1,Dest.Top);
  1168.         LineTo(Dest.Right-1,Dest.Bottom);
  1169.       end
  1170.       else
  1171.         for i:=0 to FDepth do begin
  1172.           MoveTo(Dest.Right-1,Dest.Top);
  1173.           LineTo(Dest.Right-i-1,Dest.Bottom-i-1);
  1174.         end;
  1175.       { unten }
  1176.       for i:=0 to FDepth do begin
  1177.         if not FBeveled then begin
  1178.           MoveTo(Dest.Left,Dest.Bottom-i-1);
  1179.           LineTo(Dest.Right-1,Dest.Bottom-i-1);
  1180.         end
  1181.         else begin
  1182.           MoveTo(Dest.Left+i,Dest.Bottom-i-1);
  1183.           LineTo(Dest.Right-i-1,Dest.Bottom-i-1);
  1184.         end;
  1185.       end;
  1186.     end;
  1187.     if FPanelDirection=bdTopUp then begin
  1188.       Pen.Color:=FColorHighlight;
  1189.       { oben }
  1190.       for i:=0 to FDepth do begin
  1191.         if not FBeveled then begin
  1192.           MoveTo(Dest.Left,Dest.Top+i);
  1193.           LineTo(Dest.Right-1,Dest.Top+i);
  1194.         end
  1195.         else begin
  1196.           MoveTo(Dest.Left+i,Dest.Top+i);
  1197.           LineTo(Dest.Right-i-1,Dest.Top+i);
  1198.         end;
  1199.       end;
  1200.       { links }
  1201.       if not FBeveled then begin
  1202.         MoveTo(Dest.Left,Dest.Top);
  1203.         LineTo(Dest.Left,Dest.Bottom-1);
  1204.       end
  1205.       else
  1206.         for i:=0 to FDepth do begin
  1207.           MoveTo(Dest.Left,Dest.Bottom-1);
  1208.           LineTo(Dest.Left+i,Dest.Top+i);
  1209.         end;
  1210.       Pen.Color:=FColorShadow;
  1211.       { rechts }
  1212.       if not FBeveled then begin
  1213.         MoveTo(Dest.Right-1,Dest.Top);
  1214.         LineTo(Dest.Right-1,Dest.Bottom);
  1215.       end
  1216.       else
  1217.         for i:=0 to FDepth do begin
  1218.           MoveTo(Dest.Right-1,Dest.Bottom-1);
  1219.           LineTo(Dest.Right-i-1,Dest.Top+i);
  1220.         end;
  1221.       { unten }
  1222.       MoveTo(Dest.Right-1,Dest.Bottom-1);
  1223.       LineTo(Dest.Left,Dest.Bottom-1);
  1224.     end;
  1225.     if FPanelDirection=bdLeftUp then begin
  1226.       Pen.Color:=FColorHighlight;
  1227.       { oben }
  1228.       if not FBeveled then begin
  1229.         MoveTo(Dest.Left,Dest.Top);
  1230.         LineTo(Dest.Right-1,Dest.Top);
  1231.       end
  1232.       else
  1233.         for i:=0 to FDepth do begin
  1234.           MoveTo(Dest.Right-1,Dest.Top);
  1235.           LineTo(Dest.Left+i,Dest.Top+i);
  1236.         end;
  1237.       { links }
  1238.       for i:=0 to FDepth do begin
  1239.         if not FBeveled then begin
  1240.           MoveTo(Dest.Left+i,Dest.Top);
  1241.           LineTo(Dest.Left+i,Dest.Bottom-1);
  1242.         end
  1243.         else begin
  1244.           MoveTo(Dest.Left+i,Dest.Top+i);
  1245.           LineTo(Dest.Left+i,Dest.Bottom-i-1);
  1246.         end;
  1247.       end;
  1248.       Pen.Color:=FColorShadow;
  1249.       { rechts }
  1250.       MoveTo(Dest.Right-1,Dest.Top);
  1251.       LineTo(Dest.Right-1,Dest.Bottom-1);
  1252.       { unten }
  1253.       if not FBeveled then begin
  1254.         MoveTo(Dest.Right-1,Dest.Bottom-1);
  1255.         LineTo(Dest.Left,Dest.Bottom-1);
  1256.       end
  1257.       else
  1258.         for i:=0 to FDepth do begin
  1259.           MoveTo(Dest.Right-1,Dest.Bottom-1);
  1260.           LineTo(Dest.Left+i,Dest.Bottom-i-1);
  1261.         end;
  1262.     end;
  1263.     if FPanelDirection=bdRightUp then begin
  1264.       Pen.Color:=FColorHighlight;
  1265.       { oben }
  1266.       if not FBeveled then begin
  1267.         MoveTo(Dest.Left,Dest.Top);
  1268.         LineTo(Dest.Right-1,Dest.Top);
  1269.       end
  1270.       else
  1271.         for i:=0 to FDepth do begin
  1272.           MoveTo(Dest.Left,Dest.Top);
  1273.           LineTo(Dest.Right-1-i,Dest.Top+i);
  1274.         end;
  1275.       { links }
  1276.       MoveTo(Dest.Left,Dest.Top);
  1277.       LineTo(Dest.Left,Dest.Bottom-1);
  1278.       Pen.Color:=FColorShadow;
  1279.       { rechts }
  1280.       for i:=0 to FDepth do begin
  1281.         if not FBeveled then begin
  1282.           MoveTo(Dest.Right-1-i,Dest.Top);
  1283.           LineTo(Dest.Right-1-i,Dest.Bottom-1);
  1284.         end
  1285.         else begin
  1286.           MoveTo(Dest.Right-1-i,Dest.Top+i);
  1287.           LineTo(Dest.Right-1-i,Dest.Bottom-i-1);
  1288.         end;
  1289.       end;
  1290.       { unten }
  1291.       if not FBeveled then begin
  1292.         MoveTo(Dest.Left,Dest.Bottom-1);
  1293.         LineTo(Dest.Right-1,Dest.Bottom-1);
  1294.       end
  1295.       else
  1296.         for i:=0 to FDepth do begin
  1297.           MoveTo(Dest.Left,Dest.Bottom-1);
  1298.           LineTo(Dest.Right-1-i,Dest.Bottom-i-1);
  1299.         end;
  1300.     end;
  1301.   end;
  1302. end;
  1303.  
  1304. procedure TButtonPanel.DrawCaption(Dest:TRect);
  1305. var OutText : array [0..79] of char;
  1306. begin
  1307.   with Canvas do begin
  1308.     Brush.Style:=bsClear;
  1309.     StrPCopy(OutText, Caption);
  1310.     DrawText(Handle, OutText, length(Caption), Dest, dt_center or dt_vcenter or dt_singleline);
  1311.   end;
  1312. end;
  1313.  
  1314. procedure TButtonPanel.DrawLED(var Dest:TRect);
  1315. begin
  1316.   with Canvas do begin
  1317.     Brush.Color:=clWindowFrame;
  1318.     case PanelDirection of
  1319.       bdLeftUp : begin
  1320.         FrameRect(Rect(Dest.Left+FDepth+9,Dest.Top+FDepth+3,Dest.Left+FDepth+4,Dest.Bottom-FDepth-3));
  1321.         Dest.Left:=Dest.Left+FDepth+9;
  1322.       end;
  1323.       bdRightUp : begin
  1324.         FrameRect(Rect(Dest.Right-FDepth-9,Dest.Top+FDepth+3,Dest.Right-FDepth-4,Dest.Bottom-FDepth-3));
  1325.         Dest.Right:=Dest.Right-FDepth-9;
  1326.       end;
  1327.       bdTopUp : begin
  1328.         FrameRect(Rect(Dest.Left+FDepth+3,Dest.Top+FDepth+4,Dest.Right-FDepth-3,Dest.Top+FDepth+9));
  1329.         Dest.Top:=Dest.Top+FDepth+7;
  1330.       end;
  1331.       else begin
  1332.         FrameRect(Rect(Dest.Left+FDepth+3,Dest.Bottom-FDepth-9,Dest.Right-FDepth-3,Dest.Bottom-FDepth-4));
  1333.         Dest.Bottom:=Dest.Bottom-FDepth-7;
  1334.       end;
  1335.     end;
  1336.   end;
  1337. end;
  1338.  
  1339. procedure TButtonPanel.Paint;
  1340. var ARect : TRect;
  1341. begin
  1342.   Canvas.Font.Assign(Font);
  1343.   with Canvas do begin
  1344.     ARect:=GetClientRect;
  1345.     Brush.Style:=bsSolid;
  1346.     Brush.Color:=FColor;
  1347.     FillRect(ARect);
  1348.     DrawBorder(ARect);
  1349.     Pen.Color:=clBlack;
  1350.     if FShowLED then
  1351.       DrawLED(ARect);
  1352.     if Caption<>'' then
  1353.       DrawCaption(ARect);
  1354.   end;
  1355. end;
  1356.  
  1357.  
  1358. { Komponente TScrewPanel }
  1359. constructor TScrewPanel.Create(AOwner: TComponent);
  1360. begin
  1361.   inherited Create(AOwner);
  1362.  
  1363.   {Vorgabewerte setzen}
  1364.   FColor:=clBtnFace;
  1365.   AssignBevelColors(FColor,FColorHighlight,FColorShadow,FHLContrast,FShContrast);
  1366.   FMargin:=2;
  1367.   FScrewSize:=2;
  1368.   FShowScrews:=true;
  1369.   Height:=DefaultHeight;
  1370.   Width:=DefaultWidth;
  1371. end;
  1372.  
  1373. destructor TScrewPanel.Destroy;
  1374. begin
  1375.   inherited Destroy;
  1376. end;
  1377.  
  1378. procedure TScrewPanel.SetColor(newColor: TColor);
  1379. begin
  1380.   if FColor<>newColor then begin
  1381.     FColor:=newColor;
  1382.     AssignBevelColors(FColor,FColorHighlight,FColorShadow,FHLContrast,FShContrast);
  1383.     Invalidate;
  1384.   end;
  1385. end;
  1386.  
  1387. procedure TScrewPanel.SetMargin(newValue: integer);
  1388. begin
  1389.   if (NewValue<(Width-FScrewSize)) and (NewValue<(Height-FScrewSize)) and (FMargin<>newValue) then begin
  1390.     FMargin:=newValue;
  1391.     Invalidate;
  1392.   end;
  1393. end;
  1394.  
  1395. procedure TScrewPanel.SetScrewSize(newValue: TScrewSize);
  1396. begin
  1397.   if (NewValue<Width) and (NewValue<Height) and (FScrewSize<>newValue) then begin
  1398.     FScrewSize:=newValue;
  1399.     Invalidate;
  1400.   end;
  1401. end;
  1402.  
  1403. procedure TScrewPanel.SetShowScrews(newValue: boolean);
  1404. begin
  1405.   if FShowScrews<>newValue then begin
  1406.     FShowScrews:=newValue;
  1407.     Invalidate;
  1408.   end;
  1409. end;
  1410.  
  1411. procedure TScrewPanel.DrawScrew(X,Y:integer);
  1412. var Size : integer;
  1413. begin
  1414.   Size:=FScrewSize*4;
  1415.   with Canvas do begin
  1416.     Pen.Color:=FColorShadow;
  1417.     Brush.Color:=clSilver;
  1418.     Ellipse(X,Y,X+Size,Y+Size);
  1419.     Arc(X,Y,X+Size,Y+Size,
  1420.         X+((Size div 4)*3),Y+(Size div 4),
  1421.         X+(Size div 4),Y+((Size div 4)*3));
  1422.     Pen.Color:=clGray;
  1423.     MoveTo(X+(Size div 4)-1,Y+((Size div 4)*3)-1);
  1424.     LineTo(X+((Size div 4)*3),Y+(Size div 4)-2);
  1425.     Pen.Color:=FColorHighlight;
  1426.     Arc(X,Y,X+Size,Y+Size,
  1427.         X+(Size div 4),Y+((Size div 4)*3),
  1428.         X+((Size div 4)*3),Y+(Size div 4));
  1429.     Pen.Color:=clWhite;
  1430.     MoveTo(X+(Size div 4),Y+((Size div 4)*3));
  1431.     LineTo(X+((Size div 4)*3)+1,Y+(Size div 4)-1);
  1432.   end;
  1433. end;
  1434.  
  1435. procedure TScrewPanel.DrawBevel(ARect:TRect;Raised:boolean);
  1436. begin
  1437.   with Canvas do begin
  1438.     Pen.Width:=BevelWidth;
  1439.     if Raised then
  1440.       Pen.Color:=FColorHighlight
  1441.     else
  1442.       Pen.Color:=FColorShadow;
  1443.     MoveTo(ARect.Right-1,ARect.Top);
  1444.     LineTo(ARect.Left,ARect.Top);
  1445.     LineTo(ARect.Left,ARect.Bottom-1);
  1446.     if Raised then
  1447.       Pen.Color:=FColorShadow
  1448.     else
  1449.       Pen.Color:=FColorHighlight;
  1450.     MoveTo(ARect.Right-1,ARect.Top);
  1451.     LineTo(ARect.Right-1,ARect.Bottom-1);
  1452.     LineTo(ARect.Left,ARect.Bottom-1);
  1453.   end;
  1454. end;
  1455.  
  1456. procedure TScrewPanel.Paint;
  1457. var ARect   : TRect;
  1458.     Border  : integer;
  1459.     outText : array [0..79] of char;
  1460. begin
  1461.   with Canvas do begin
  1462.     Brush.Style:=bsSolid;
  1463.     Brush.Color:=Self.Color;
  1464.     ARect:=GetClientRect;
  1465.     FillRect(ARect);
  1466.     if BevelOuter<>bvNone then begin
  1467.       DrawBevel(ARect,BevelOuter=bvRaised);
  1468.       Border:=BevelWidth+BorderWidth;
  1469.     end
  1470.     else
  1471.       Border:=BorderWidth;
  1472.     InflateRect(ARect,-Border,-Border);
  1473.     if BevelInner<>bvNone then begin
  1474.       DrawBevel(ARect,BevelInner=bvRaised);
  1475.       InflateRect(ARect,-BevelWidth,-BevelWidth);
  1476.     end;
  1477.     if FShowScrews then begin
  1478.       DrawScrew(ARect.Left+FMargin,ARect.Top+FMargin);
  1479.       DrawScrew(ARect.Right-FMargin-(FScrewSize*4),ARect.Top+FMargin);
  1480.       DrawScrew(ARect.Left+FMargin,ARect.Bottom-FMargin-(FScrewSize*4));
  1481.       DrawScrew(ARect.Right-FMargin-(FScrewSize*4),ARect.Bottom-FMargin-(FScrewSize*4));
  1482.     end;
  1483.     Font:=Self.Font;
  1484.     Brush.Style:=bsClear;
  1485.     StrPCopy(outText,Caption);
  1486.     if Alignment=taCenter then
  1487.       DrawText(Handle,outText,length(Caption),Arect,DT_SINGLELINE or DT_VCENTER or DT_CENTER);
  1488.     if Alignment=taLeftJustify then
  1489.       DrawText(Handle,outText,length(Caption),Arect,DT_SINGLELINE or DT_VCENTER or DT_LEFT);
  1490.     if Alignment=taRightJustify then
  1491.       DrawText(Handle,outText,length(Caption),Arect,DT_SINGLELINE or DT_VCENTER or DT_RIGHT);
  1492.   end;
  1493. end;
  1494.  
  1495.  
  1496. { Komponente TLEDDisplay }
  1497. procedure TLEDDisplay.AssignColors(seg:integer; s1,s2,s3,s4,s5,s6,s7:Boolean);
  1498. begin
  1499.   if s1 then
  1500.     FSegCl[seg, 1] := FColorLED
  1501.   else
  1502.     FSegCl[seg, 1] := FLEDOffColor;
  1503.   if s2 then
  1504.     FSegCl[seg, 2] := FColorLED
  1505.   else
  1506.     FSegCl[seg, 2] := FLEDOffColor;
  1507.   if s3 then
  1508.     FSegCl[seg, 3] := FColorLED
  1509.   else
  1510.     FSegCl[seg, 3] := FLEDOffColor;
  1511.   if s4 then
  1512.     FSegCl[seg, 4] := FColorLED
  1513.   else
  1514.     FSegCl[seg, 4] := FLEDOffColor;
  1515.   if s5 then
  1516.     FSegCl[seg, 5] := FColorLED
  1517.   else
  1518.     FSegCl[seg, 5] := FLEDOffColor;
  1519.   if s6 then
  1520.     FSegCl[seg, 6] := FColorLED
  1521.   else
  1522.     FSegCl[seg, 6] := FLEDOffColor;
  1523.   if s7 then
  1524.     FSegCl[seg, 7] := FColorLED
  1525.   else
  1526.     FSegCl[seg, 7] := FLEDOffColor;
  1527. end;
  1528.  
  1529. procedure TLEDDisplay.GenerateBitMaps;
  1530. var
  1531.   TL, TR, TBL, TBR,
  1532.   ML, MTL, MTR, MR,
  1533.   MBL, MBR, BL, BTL,
  1534.   BTR, BR            : TPoint;
  1535.   c, wAlt, LineW     : integer;
  1536. begin
  1537.   LineW:=FLineWidth+2;
  1538.   wAlt := FDigitHeight;
  1539.   { Polygonpunkte zuweisen }
  1540.   TL.x := 0;
  1541.   TL.y := 0;
  1542.   TR.x := FDigitWidth-1;
  1543.   TR.y := 0;
  1544.   TBL.x := LineW - 1;
  1545.   TBL.y := LineW -1;
  1546.   TBR.x := FDigitWidth - LineW;
  1547.   TBR.y := TBL.y;
  1548.   ML.x := 0;
  1549.   ML.y := wAlt div 2;
  1550.   MTL.x := TBL.x;
  1551.   MTL.y := ML.y - (LineW div 2);
  1552.   MTR.x := TBR.x;
  1553.   MTR.y := MTL.y;
  1554.   MR.x := TR.x;
  1555.   MR.y := ML.y;
  1556.   MBL.x := TBL.x;
  1557.   MBL.y := ML.y + (LineW div 2);
  1558.   MBR.x := MTR.x; MBR.y := MBL.y;
  1559.   BL.x := 0;
  1560.   BL.y := wAlt - 1;
  1561.   BR.x := TR.x;
  1562.   BR.y := BL.y;
  1563.   BTL.x := TBL.x;
  1564.   BTL.y := wAlt - LineW;
  1565.   BTR.x := TBR.x;
  1566.   BTR.y := BTL.y;
  1567.  
  1568.   { Segmentfarben zuweisen }
  1569.   AssignColors (0, true, true, true, false, true, true, true);
  1570.   AssignColors (1, false, false, true, false, false, true, false);
  1571.   AssignColors (2, true, false, true, true, true, false, true);
  1572.   AssignColors (3, true, false, true, true, false, true, true);
  1573.   AssignColors (4, false, true, true, true, false, true, false);
  1574.   AssignColors (5, true, true, false, true, false, true, true);
  1575.   AssignColors (6, false, true, false, true, true, true, true);
  1576.   AssignColors (7, true, false, true, false, false, true, false);
  1577.   AssignColors (8, true, true, true, true, true, true, true);
  1578.   AssignColors (9, true, true, true, true, false, true, true);
  1579.   AssignColors (10, false, false, false, true, false, false, false);
  1580.  
  1581.   { Bitmap erstellen }
  1582.   for c := 0 to 10 do begin
  1583.     FDigit[c].free;
  1584.     FDigit[c] := TBitmap.create;
  1585.     FDigit[c].width := FDigitWidth;
  1586.     FDigit[c].height := wAlt;
  1587.     with FDigit[c].canvas do begin
  1588.       Pen.Color := FColorBackGround;
  1589.       Brush.Color := FColorBackGround;
  1590.       Brush.style := bsSolid;
  1591.       Pen.Width := 1;
  1592.       Rectangle (TL.x, TL.y, BR.x+1, BR.y+1);
  1593.       if FSegmentStyle=ssRectangular then
  1594.         Pen.Width:=FLineWidth;
  1595.       { Segment 1 }
  1596.       Brush.Color := FSegCl[c, 1];
  1597.       if FSegmentStyle=ssRectangular then begin
  1598.         Pen.Color := FSegCl[c, 1];
  1599.         MoveTo(FLineWidth, FLineWidth div 2);
  1600.         LineTo(FDigit[c].Width-FLineWidth-1, FLineWidth div 2);
  1601.       end
  1602.       else
  1603.         Polygon ([TL, TR, TBR, TBL]);
  1604.       { Segment 2 }
  1605.       Brush.Color := FSegCl[c, 2];
  1606.       if FSegmentStyle=ssRectangular then begin
  1607.         Pen.Color := FSegCl[c, 2];
  1608.         MoveTo(FLineWidth div 2, FLineWidth*3 div 2);
  1609.         LineTo(FLineWidth div 2, (FDigit[c].Height div 2)-FLineWidth);
  1610.       end
  1611.       else
  1612.         Polygon ([TL, TBL, MTL, ML]);
  1613.       { Segment 3 }
  1614.       Brush.Color := FSegCl[c, 3];
  1615.       if FSegmentStyle=ssRectangular then begin
  1616.         Pen.Color := FSegCl[c, 3];
  1617.         MoveTo(FDigit[c].Width-(FLineWidth div 2)-1, FLineWidth*3 div 2);
  1618.         LineTo(FDigit[c].Width-(FLineWidth div 2)-1, (FDigit[c].Height div 2)-FLineWidth);
  1619.       end
  1620.       else
  1621.         Polygon ([TR, MR, MTR, TBR]);
  1622.       { Segment 4 }
  1623.       Brush.Color := FSegCl[c, 4];
  1624.       if FSegmentStyle=ssRectangular then begin
  1625.         Pen.Color := FSegCl[c, 4];
  1626.         MoveTo(FLineWidth, FDigit[c].Height div 2);
  1627.         LineTo(FDigit[c].Width-FLineWidth, FDigit[c].Height div 2);
  1628.       end
  1629.       else
  1630.         Polygon ([ML, MTL, MTR, MR, MBR, MBL]);
  1631.       { Segment 5 }
  1632.       Brush.Color := FSegCl[c, 5];
  1633.       if FSegmentStyle=ssRectangular then begin
  1634.         Pen.Color := FSegCl[c, 5];
  1635.         MoveTo(FLineWidth div 2, (FDigit[c].Height div 2)+FLineWidth);
  1636.         LineTo(FLineWidth div 2, FDigit[c].Height-(FLineWidth*3 div 2));
  1637.       end
  1638.       else
  1639.         Polygon ([ML, MBL, BTL, BL]);
  1640.       { Segment 6 }
  1641.       Brush.Color := FSegCl[c, 6];
  1642.       if FSegmentStyle=ssRectangular then begin
  1643.         Pen.Color := FSegCl[c, 6];
  1644.         MoveTo(FDigit[c].Width-(FLineWidth div 2)-1, (FDigit[c].Height div 2)+FLineWidth);
  1645.         LineTo((FDigit[c].Width-FLineWidth div 2)-1, FDigit[c].Height-(FLineWidth*3 div 2));
  1646.       end
  1647.       else
  1648.         Polygon ([MR, BR, BTR, MBR]);
  1649.       { Segment 7 }
  1650.       Brush.Color := FSegCl[c, 7];
  1651.       if FSegmentStyle=ssRectangular then begin
  1652.         Pen.Color := FSegCl[c, 7];
  1653.         MoveTo(FLineWidth, FDigit[c].Height-(FLineWidth div 2)-1);
  1654.         LineTo(FDigit[c].Width-FLineWidth, FDigit[c].Height-(FLineWidth div 2)-1);
  1655.       end
  1656.       else
  1657.         Polygon ([BL, BTL, BTR, BR]);
  1658.     end;
  1659.   end;
  1660. end;
  1661.  
  1662. constructor TLEDDisplay.Create(AOwner: TComponent);
  1663. var Dummy : TColor;
  1664. begin
  1665.   inherited Create (AOwner);
  1666.  
  1667.   FBevelStyle:= bvLowered;
  1668.   FBorderStyle:= bsSingle;
  1669.   FColorBackGround:= clBlack;
  1670.   FColorLED:= clLime;
  1671.   FLEDContrast:=7;
  1672.   AssignBevelColors(FColorLED,Dummy,FLEDOffColor,FLEDContrast,FLEDContrast);
  1673.   FDecSeperator:= dsComma;
  1674.   FDigitHeight:= 30;
  1675.   FDigitWidth:= 20;
  1676.   FLineWidth:= 3;
  1677.   FLeadingZeros:= true;
  1678.   FNumDigits:= 6;
  1679.   FSegmentStyle:= ssBeveled;
  1680.   FValue:= 0;
  1681.   Height:= 36;
  1682.   Width:= 168;
  1683.  
  1684.   GenerateBitMaps;
  1685. end;
  1686.  
  1687. destructor TLEDDisplay.Destroy;
  1688. begin
  1689.   inherited destroy;
  1690. end;
  1691.  
  1692. procedure TLEDDisplay.Change;
  1693. begin
  1694.   if Assigned(FOnChange) then
  1695.     FOnChange(Self);
  1696. end;
  1697.  
  1698. procedure TLEDDisplay.Paint;
  1699. var
  1700.   Area        : TRect;
  1701.   outText     : string;
  1702.   anchoPosi,
  1703.   posiLeft,
  1704.   PosiTop, c,
  1705.   DigitIndex,
  1706.   SepPosition : integer;
  1707.   ANZeroDigit : Boolean;
  1708.  
  1709.   function GetDigitIndex(C:Char):integer;
  1710.   begin
  1711.     case C of
  1712.       '0'..'9' : Result:=StrToIntDeF(C, -1);
  1713.       '-'      : Result:=10;
  1714.       else       Result:=-1;
  1715.     end;
  1716.   end; {GetDigitIndex}
  1717.  
  1718. begin
  1719.   Area := getClientRect;
  1720.   try
  1721.     outText:=FloatToStrF(FValue, ffFixed, 18, FFractionDigits);
  1722.   except
  1723.     outText:='';
  1724.   end;
  1725.   SepPosition:=Pos(DecimalSeparator, outText);
  1726.   if SepPosition>0 then
  1727.     delete(outText, SepPosition, 1);
  1728.   while length(outText)<FNumDigits do begin
  1729.     outText:='0'+outText;
  1730.     if SepPosition>0 then
  1731.       inc(SepPosition);
  1732.   end;
  1733.   ANZeroDigit:=False; { bis jetzt noch keine Ziffer von 1..9 }
  1734.   with canvas do begin
  1735.     Brush.Color:=FColorBackGround;
  1736.     FillRect(Area);
  1737.     anchoPosi:=Self.width div FNumDigits;
  1738.     PosiTop:=(Self.height-DigitHeight) div 2;
  1739.     posiLeft:=(anchoPosi-FDigitwidth) div 2;
  1740.     Brush.Color:=FColorLED;
  1741.     Pen.Color:=ColorLED;
  1742.     { Bitmaps und DecSeperator zeichnen }
  1743.     for c:=1 to FNumDigits do begin
  1744.       { nachfolgende Nullen mⁿssen gezeichnet werden! }
  1745.       if FLeadingZeros or (strToInt(outText[c])<>0) or ANZeroDigit then begin
  1746.         DigitIndex:=GetDigitIndex(outText[c]);
  1747.         if (DigitIndex>=0) and (DigitIndex<=10) then
  1748.           Draw(posiLeft, posiTop, FDigit[DigitIndex]);
  1749.         ANZeroDigit:=True; { spΣtestens jetzt isse da... }
  1750.       end;
  1751.       inc(posiLeft, anchoPosi);
  1752.       if c=(SepPosition-1) then begin
  1753.         Pen.Width:=1;
  1754.         if FDecSeperator=dsPoint then
  1755.           Ellipse(posiLeft-6, posiTop+FDigitHeight-5, posiLeft-2, posiTop+FDigitHeight-1);
  1756.         if FDecSeperator=dsComma then begin
  1757.           Ellipse(posiLeft-6, posiTop+FDigitHeight-8, posiLeft-2, posiTop+FDigitHeight-4);
  1758.           MoveTo(posiLeft-3, posiTop+FDigitHeight-5);
  1759.           LineTo(posiLeft-6, posiTop+FDigitHeight-1);
  1760.           LineTo(posiLeft-2, posiTop+FDigitHeight-6);
  1761.         end;
  1762.         if FDecSeperator=dsDoublePoint then begin
  1763.           Ellipse(posiLeft-6, posiTop+(FDigitHeight div 3)-2, posiLeft-2, posiTop+(FDigitHeight div 3)+2);
  1764.           Ellipse(posiLeft-6, posiTop+(FDigitHeight*2 div 3)-2, posiLeft-2, posiTop+(FDigitHeight*2 div 3)+2);
  1765.         end;
  1766.         if FDecSeperator=dsMinus then begin
  1767.           Pen.Width:=FLineWidth;
  1768.           MoveTo(posiLeft-6, posiTop+((FDigitHeight) div 2));
  1769.           LineTo(posiLeft-FLineWidth, posiTop+((FDigitHeight) div 2));
  1770.         end;
  1771.       end;
  1772.     end;
  1773.     { Bevel zeichnen }
  1774.     if BevelStyle<>bvNone then begin
  1775.       if BevelStyle=bvRaised then
  1776.         Pen.Color:=clBtnHighlight
  1777.       else
  1778.         Pen.Color:=clBtnShadow;
  1779.       MoveTo(Area.Right-1, Area.Top);
  1780.       LineTo(Area.Left, Area.Top);
  1781.       LineTo(Area.Left, Area.Bottom-1);
  1782.       if BevelStyle=bvRaised then
  1783.         Pen.Color:=clBtnShadow
  1784.       else
  1785.         Pen.Color:=clBtnHighlight;
  1786.       MoveTo(Area.Left, Area.Bottom-1);
  1787.       LineTo(Area.Right-1, Area.Bottom-1);
  1788.       LineTo(Area.Right-1, Area.Top);
  1789.       InflateRect(Area, -1, -1);
  1790.     end;
  1791.     { Border zeichnen }
  1792.     if BorderStyle<>bsNone then begin
  1793.       Brush.Color:=clWindowFrame;
  1794.       FrameRect(Area);
  1795.     end;
  1796.   end;
  1797. end;
  1798.  
  1799. procedure TLEDDisplay.SetBevelStyle(newValue: TPanelBevel);
  1800. begin
  1801.   if FBevelStyle<>newValue then begin
  1802.     FBevelStyle:=newValue;
  1803.     Invalidate;
  1804.   end;
  1805. end;
  1806.  
  1807. procedure TLEDDisplay.SetBorderStyle(newValue: TBorderStyle);
  1808. begin
  1809.   if FBorderStyle<>newValue then begin
  1810.     FBorderStyle:=newValue;
  1811.     Invalidate;
  1812.   end;
  1813. end;
  1814.  
  1815. procedure TLEDDisplay.SetColorBackGround(newValue: TColor);
  1816. begin
  1817.   if FColorBackGround<>NewValue then begin
  1818.     FColorBackGround:=NewValue;
  1819.     GenerateBitMaps;
  1820.     Invalidate;
  1821.   end;
  1822. end;
  1823.  
  1824. procedure TLEDDisplay.SetColorLED(newValue: TColor);
  1825. var Dummy : TColor;
  1826. begin
  1827.   if FColorLED<>newValue then begin
  1828.     FColorLED:=newValue;
  1829.     AssignBevelColors(FColorLED,Dummy,FLEDOffColor,FLEDContrast,FLEDContrast);
  1830.     GenerateBitMaps;
  1831.     Invalidate;
  1832.   end;
  1833. end;
  1834.  
  1835. procedure TLEDDisplay.SetDecSeperator(newValue: TDecSeperator);
  1836. begin
  1837.   if FDecSeperator<>newValue then begin
  1838.     FDecSeperator:=newValue;
  1839.     Invalidate;
  1840.   end;
  1841. end;
  1842.  
  1843. procedure TLEDDisplay.SetDigitHeight(newValue: integer);
  1844. begin
  1845.   if FDigitHeight<>newValue then begin
  1846.     FDigitHeight:=newValue;
  1847.     GenerateBitMaps;
  1848.     Invalidate;
  1849.   end;
  1850. end;
  1851.  
  1852. procedure TLEDDisplay.SetDigitWidth(newValue: integer);
  1853. begin
  1854.   if FDigitWidth<>newValue then begin
  1855.     FDigitWidth:=newValue;
  1856.     GenerateBitMaps;
  1857.     Invalidate;
  1858.   end;
  1859. end;
  1860.  
  1861. procedure TLEDDisplay.SetFractionDigits(newValue: integer);
  1862. begin
  1863.   if FFractionDigits<>newValue then begin
  1864.     FFractionDigits:=newValue;
  1865.     if FFractionDigits>(FNumDigits-1) then
  1866.       FFractionDigits:=FNumDigits-1;
  1867.     Invalidate;
  1868.   end;
  1869. end;
  1870.  
  1871. procedure TLEDDisplay.SetLeadingZeros(newValue: boolean);
  1872. begin
  1873.   if FLeadingZeros<>newValue then begin
  1874.     FLeadingZeros:=newValue;
  1875.     Invalidate;
  1876.   end;
  1877. end;
  1878.  
  1879. procedure TLEDDisplay.SetLEDContrast(newContrast: TContrast);
  1880. var Dummy : TColor;
  1881. begin
  1882.   if (FLEDContrast<>newContrast) and (newContrast>=0) and (newContrast<10) then begin
  1883.     FLEDContrast:=newContrast;
  1884.     AssignBevelColors(FColorLED,Dummy,FLEDOffColor,FLEDContrast,FLEDContrast);
  1885.     GenerateBitMaps;
  1886.     Invalidate;
  1887.   end;
  1888. end;
  1889.  
  1890. procedure TLEDDisplay.SetLineWidth(newValue: integer);
  1891. begin
  1892.   if FLineWidth<>newValue then begin
  1893.     FLineWidth:=newValue;
  1894.     GenerateBitMaps;
  1895.     Invalidate;
  1896.   end;
  1897. end;
  1898.  
  1899. procedure TLEDDisplay.SetNumDigits(newValue: integer);
  1900. begin
  1901.   if FNumDigits<>newValue then begin
  1902.     FNumDigits:=newValue;
  1903.     Invalidate;
  1904.   end;
  1905. end;
  1906.  
  1907. procedure TLEDDisplay.SetSegmentStyle(newValue: TSegmentStyle);
  1908. begin
  1909.   if FSegmentStyle<>newValue then begin
  1910.     FSegmentStyle:=newValue;
  1911.     GenerateBitMaps;
  1912.     Invalidate;
  1913.   end;
  1914. end;
  1915.  
  1916. procedure TLEDDisplay.SetValue(newValue: extended);
  1917. begin
  1918.   if FValue<>NewValue then begin
  1919.     FValue:=NewValue;
  1920.     GenerateBitMaps;
  1921.     Invalidate;
  1922.     Change;
  1923.   end;
  1924. end;
  1925.  
  1926.  
  1927. { Komponente TLEDMeter }
  1928. constructor TLEDMeter.Create(AOwner: TComponent);
  1929. var Dummy : TColor;
  1930. begin
  1931.   inherited Create(AOwner);
  1932.   FBevelStyle:=bvlowered;
  1933.   FColorLED1:=clLime;
  1934.   FColorLED2:=clYellow;
  1935.   FColorLED3:=clRed;
  1936.   AssignBevelColors(FColorLED1,Dummy,FColorOff1,FHLContrast,FShContrast);
  1937.   AssignBevelColors(FColorLED2,Dummy,FColorOff2,FHLContrast,FShContrast);
  1938.   AssignBevelColors(FColorLED3,Dummy,FColorOff3,FHLContrast,FShContrast);
  1939.   FColorSeperator:=clBlack;
  1940.   FDirection:=mdRight;
  1941.   FMax:=100;
  1942.   FMin:=0;
  1943.   FLEDContrast:=6;
  1944.   FNumDigits:=20;
  1945.   FPosition:=0;
  1946.   FStartColor2:=75;
  1947.   FStartColor3:=90;
  1948.   Height:=16;
  1949.   Width:=143;
  1950. end;
  1951.  
  1952. destructor TLEDMeter.Destroy;
  1953. begin
  1954.   inherited Destroy;
  1955. end;
  1956.  
  1957. procedure TLEDMeter.SetBevelStyle(newVal: TPanelBevel);
  1958. begin
  1959.   if newVal<>FBevelStyle then begin
  1960.     FBevelStyle:=newVal;
  1961.     Paint;
  1962.   end;
  1963. end;
  1964.  
  1965. procedure TLEDMeter.SetColorLED1(newVal: TColor);
  1966. var Dummy : TColor;
  1967. begin
  1968.   if newVal<>FColorLED1 then begin
  1969.     FColorLED1:=newVal;
  1970.     AssignBevelColors(FColorLED1,Dummy,FColorOff1,FLEDContrast,FLEDContrast);
  1971.     Paint;
  1972.   end;
  1973. end;
  1974.  
  1975. procedure TLEDMeter.SetColorLED2(newVal: TColor);
  1976. var Dummy : TColor;
  1977. begin
  1978.   if newVal<>FColorLED2 then begin
  1979.     FColorLED2:=newVal;
  1980.     AssignBevelColors(FColorLED2,Dummy,FColorOff2,FLEDContrast,FLEDContrast);
  1981.     Paint;
  1982.   end;
  1983. end;
  1984.  
  1985. procedure TLEDMeter.SetColorLED3(newVal: TColor);
  1986. var Dummy : TColor;
  1987. begin
  1988.   if newVal<>FColorLED3 then begin
  1989.     FColorLED3:=newVal;
  1990.     AssignBevelColors(FColorLED3,Dummy,FColorOff3,FLEDContrast,FLEDContrast);
  1991.     Paint;
  1992.   end;
  1993. end;
  1994.  
  1995. procedure TLEDMeter.SetColorSeperator(newVal: TColor);
  1996. begin
  1997.   if newVal<>FColorSeperator then begin
  1998.     FColorSeperator:=newVal;
  1999.     Paint;
  2000.   end;
  2001. end;
  2002.  
  2003. procedure TLEDMeter.SetDirection(newVal: TMeterDirection);
  2004. begin
  2005.   if newVal<>FDirection then begin
  2006.     FDirection:=newVal;
  2007.     Paint;
  2008.   end;
  2009. end;
  2010.  
  2011. procedure TLEDMeter.SetLEDContrast(newContrast: TContrast);
  2012. var Dummy : TColor;
  2013. begin
  2014.   if (FLEDContrast<>newContrast) and (newContrast>=0) and (newContrast<10) then begin
  2015.     FLEDContrast:=newContrast;
  2016.     AssignBevelColors(FColorLED1,Dummy,FColorOff1,FLEDContrast,FLEDContrast);
  2017.     AssignBevelColors(FColorLED2,Dummy,FColorOff2,FLEDContrast,FLEDContrast);
  2018.     AssignBevelColors(FColorLED3,Dummy,FColorOff3,FLEDContrast,FLEDContrast);
  2019.     Invalidate;
  2020.   end;
  2021. end;
  2022.  
  2023. procedure TLEDMeter.SetMax(newVal: integer);
  2024. begin
  2025.   if newVal<>FMax then begin
  2026.     FMax:=newVal;
  2027.     if newVal<FStartColor2 then
  2028.       FStartColor2:=newVal;
  2029.     if newVal<FStartColor3 then
  2030.       FStartColor3:=newVal;
  2031.     Paint;
  2032.   end;
  2033. end;
  2034.  
  2035. procedure TLEDMeter.SetMin(newVal: integer);
  2036. begin
  2037.   if newVal<>FMin then begin
  2038.     FMin:=newVal;
  2039.     if newVal>FStartColor2 then
  2040.       FStartColor2:=newVal;
  2041.     if newVal>FStartColor3 then
  2042.       FStartColor3:=newVal;
  2043.     Paint;
  2044.   end;
  2045. end;
  2046.  
  2047. procedure TLEDMeter.SetNumDigits(newVal: integer);
  2048. begin
  2049.   if newVal<>FNumDigits then begin
  2050.     FNumDigits:=newVal;
  2051.     Paint;
  2052.   end;
  2053. end;
  2054.  
  2055. procedure TLEDMeter.SetPosition(newVal: integer);
  2056. begin
  2057.   if newVal<>FPosition then begin
  2058.     if newVal>FMax then
  2059.       newVal:=FMax;
  2060.     if newVal<FMin then
  2061.       newVal:=FMin;
  2062.     FPosition:=newVal;
  2063.     Paint;
  2064.     Change;
  2065.   end;
  2066. end;
  2067.  
  2068. procedure TLEDMeter.SetStartColor2(newVal: integer);
  2069. begin
  2070.   if newVal<>FStartColor2 then begin
  2071.     if newVal>Max then
  2072.       newVal:=Max;
  2073.     if newVal<Min then
  2074.       newVal:=Min;
  2075.     if newVal>FStartColor3 then
  2076.       newVal:=FStartColor3;
  2077.     FStartColor2:=newVal;
  2078.     Paint;
  2079.   end;
  2080. end;
  2081.  
  2082. procedure TLEDMeter.SetStartColor3(newVal: integer);
  2083. begin
  2084.   if newVal<>FStartColor3 then begin
  2085.     if newVal>Max then
  2086.       newVal:=Max;
  2087.     if newVal<Min then
  2088.       newVal:=Min;
  2089.     if newVal<FStartColor2 then
  2090.       newVal:=FStartColor2;
  2091.     FStartColor3:=newVal;
  2092.     Paint;
  2093.   end;
  2094. end;
  2095.  
  2096. procedure TLEDMeter.SetSingleLED(newVal: boolean);
  2097. begin
  2098.   if newVal<>FSingleLED then begin
  2099.     FSingleLED:=newVal;
  2100.     Paint;
  2101.   end;
  2102. end;
  2103.  
  2104. procedure TLEDMeter.Change;
  2105. begin
  2106.   if Assigned(FOnChange) then
  2107.     FOnChange(Self);
  2108. end;
  2109.  
  2110. procedure TLEDMeter.Paint;
  2111. var ARect       : TRect;
  2112.     NumPos,DPos,
  2113.     FirstYel,
  2114.     FirstRed,
  2115.     DigitLeft,
  2116.     DigitTop,i,
  2117.     DigitWidth,
  2118.     DigitHeight,
  2119.     BevelWidth  : integer;
  2120. begin
  2121.   with Canvas do begin
  2122.     NumPos:=FMax-FMin;
  2123.     if BevelStyle<>bvNone then
  2124.       BevelWidth:=1
  2125.     else
  2126.       BevelWidth:=0;
  2127.     if (FDirection=mdRight) or (FDirection=mdLeft) then begin
  2128.       DigitWidth:=(Width-(2*BevelWidth)) div FNumDigits;
  2129.       DigitHeight:=Height-(2*BevelWidth);
  2130.       DigitLeft:=BevelWidth;
  2131.       DigitTop:=BevelWidth;
  2132.     end
  2133.     else begin
  2134.       DigitWidth:=Width-(2*BevelWidth)-1;
  2135.       DigitHeight:=(Height-(2*BevelWidth)) div FNumDigits;
  2136.       DigitTop:=BevelWidth;
  2137.       DigitLeft:=BevelWidth;
  2138.     end;
  2139.     if (NumPos>0) and (FPosition>0) then
  2140.       DPos:=round(FNumDigits/(NumPos/FPosition))
  2141.     else
  2142.       DPos:=0;
  2143.     if (NumPos>0) and (FStartColor2>0) then
  2144.       FirstYel:=round(FNumDigits/(NumPos/FStartColor2))
  2145.     else
  2146.       FirstYel:=0;
  2147.     if (NumPos>0) and (FStartColor3>0) then
  2148.       FirstRed:=round(FNumDigits/(NumPos/FStartColor3))
  2149.     else
  2150.       FirstRed:=0;
  2151.  
  2152.     for i:=0 to FNumDigits-1 do begin
  2153.       if i>=DPos then begin
  2154.         if i<FirstYel then
  2155.           Brush.Color:=FColorOff1
  2156.         else
  2157.           if i<FirstRed then
  2158.             Brush.Color:=FColorOff2
  2159.           else
  2160.             Brush.Color:=FColorOff3;
  2161.       end
  2162.       else begin
  2163.         if FSingleLED then begin
  2164.           if (i=DPos-1) then begin
  2165.             if i<FirstYel then
  2166.               Brush.Color:=FColorLED1
  2167.             else
  2168.               if i<FirstRed then
  2169.                 Brush.Color:=FColorLED2
  2170.               else
  2171.                 Brush.Color:=FColorLED3;
  2172.           end
  2173.           else begin
  2174.             if i<FirstYel then
  2175.               Brush.Color:=FColorOff1
  2176.             else
  2177.               if i<FirstRed then
  2178.                 Brush.Color:=FColorOff2
  2179.               else
  2180.                 Brush.Color:=FColorOff3;
  2181.           end;
  2182.         end
  2183.         else begin
  2184.           if i<FirstYel then
  2185.             Brush.Color:=FColorLED1
  2186.           else
  2187.             if i<FirstRed then
  2188.               Brush.Color:=FColorLED2
  2189.             else
  2190.               Brush.Color:=FColorLED3;
  2191.         end;
  2192.       end;
  2193.  
  2194.       if FDirection=mdRight then
  2195.         DigitLeft:=BevelWidth+(i*DigitWidth);
  2196.       if FDirection=mdLeft then
  2197.         DigitLeft:=Width-BevelWidth-((i+1)*DigitWidth)-1;
  2198.       if FDirection=mdUp then
  2199.         DigitTop:=Height-BevelWidth-((i+1)*DigitHeight);
  2200.       if FDirection=mdDown then
  2201.         DigitTop:=BevelWidth+(i*DigitHeight);
  2202.       Pen.Color:=FColorSeperator;
  2203.       Rectangle(DigitLeft,DigitTop,DigitLeft+DigitWidth+1,DigitTop+DigitHeight);
  2204.     end;
  2205.     if BevelStyle<>bvNone then begin
  2206.       if BevelStyle=bvRaised then
  2207.         Pen.Color:=clBtnHighlight
  2208.       else
  2209.         Pen.Color:=clBtnShadow;
  2210.       ARect:=GetClientRect;
  2211.       MoveTo(ARect.Right-1,ARect.Top);
  2212.       LineTo(ARect.Left,ARect.Top);
  2213.       LineTo(ARect.Left,ARect.Bottom-1);
  2214.       if BevelStyle=bvRaised then
  2215.         Pen.Color:=clBtnShadow
  2216.       else
  2217.         Pen.Color:=clBtnHighlight;
  2218.       MoveTo(ARect.Left,ARect.Bottom-1);
  2219.       LineTo(ARect.Right-1,ARect.Bottom-1);
  2220.       LineTo(ARect.Right-1,ARect.Top);
  2221.     end;
  2222.   end;
  2223. end;
  2224.  
  2225.  
  2226. procedure Register;
  2227. begin
  2228.   RegisterComponents('Simon', [TLEDButton]);
  2229.   RegisterComponents('Simon', [TButtonPanel]);
  2230.   RegisterComponents('Simon', [TScrewPanel]);
  2231.   RegisterComponents('Simon', [TLEDDisplay]);
  2232.   RegisterComponents('Simon', [TLEDMeter]);
  2233. end;
  2234.  
  2235. end.
  2236.