From :
	AMC Software
	PAscal Courte-Heuse
	101667.455@compuserve.com

Subject :
	Electronic like component library


	Including : 

		Led based vu meter with realistic release time decay,
		single seven display panel,
		Linkable seven display panel,
		Multiple display panel multi-format capabilities,
		High performance status bar with self-updating routine,
		Multiple characters LED display panel, with resizing, much coloring and width option,
		Linear potentiometer.

	
Registrering : 
	
	with compuserve :
		
		GO SWREG 	file name : ctrlLib.zip
				Reg number : 13699
				fee : 20US$

	When you register, you receive full source code and resource files and you can, removed this crazy start panel ;-)
	include all components in your applications with or without modification (please sent it to me.. thank's) without
	paied anything more.


Notes :	All subscribers receive new release of the Library, free updating for registered users
	Any comments and suggests are very very welcome.
	Have enjoy with these components.



For best use, find following the actual source of INTERFACE of the CTRLIB Unit



(*****************************************************************************)
(* LIBRARY of electronic components                                          *)
(* all component are copyrighted by Pascal Courte-Heuse                     *)
(* for AMC company                                                          *)
(* please send any comment and suggestion to 101667.455@compuserve.com       *)
(* register CIS : go SWREG reg Num 13699
(*****************************************************************************)

unit CtrlLib;

interface

uses
  SysUtils,
  WinTypes,
  WinProcs,
  Messages,
  Classes,
  Graphics,
  Controls,
  Forms,
  Dialogs,
  Menus,
  ExtCtrls,
  Gauges;

type
(*****************************************************************************)
  { internal use only definitions -------------------------------------}
(*****************************************************************************)
  TAutoSize = (None,Block,Digit,Client);
  tDirection = (TopToBottom,BottomToTop,RightToLeft,LeftToRight);
  tScale     = (Analog,Log);
  tAspect    = (Rectangle,Trapeze);
  tPercent   = byte {set of 0..100};
  TColorBtn = ( cbWhite,cbBlack,cbBlue,cbYellow,cbRed,cbGreen);
  TGaugeKind = (gkText, gkHorizontalBar, gkVerticalBar, gkPie, gkNeedle);
  TSelColor = (cpAqua,cpBlue,cpFuchsia,cpLime,cpRed,cpWhite,cpYellow);

(*****************************************************************************)
{
   alphanumeric multiple characters display
   an AMC realization
   design & programming Pascal Courte-Heuse
   (c) 1996 AMC
   CIS : 101667.455
   eMail : 101667.455@compuserve.com
   sources available in compuserve go SWREG

   The mean : use a bitmap to draw characters faster than other method
              result : 	less than 50 lines of code for this component
}		       	display a 60 charracters message in less than 3 milliseconds
			without flicking.
			( with a pentium 133, 16Mo RAM an Millenium Card and win 3.11)	
(*****************************************************************************)
  TPanelDisplay = class(TGraphicControl)
  private
    { Private-dclarations }
    fNumChar : Byte;
    fColor   : tSelColor;
    fResName : array[0..20] of char;
    fString  : String;
    fAlignment : tAlignment;
  protected
    { Protected-dclarations }
    procedure setNumChar(a : byte);
    procedure SetColor(a : tSelColor);
    procedure SetString(a : string);
    procedure setAlignment(a : tAlignment);
  public
    { Public-dclarations }
    constructor create(aOwner : tComponent);override;
    procedure paint;override;
  published
    { Published-dclarations }
    property numChar : byte read fnumChar write SetNumChar default 1;
    property Color : tSelColor read fColor write SetColor Default cpAqua;
    property TheString : string read fString write setString;
    property Alignment : tAlignment read fAlignment write setAlignment;
    property Cursor;
    property onClick;
    property onDblClick;
  end;

  {---------------------------------------------------------------------
  same as TGauge in sample Delphi product - fix a bug in solveForX function
  ----------------------------------------------------------------------}
  TGauge = class(TGraphicControl)
  private
    FMinValue: Longint;
    FMaxValue: Longint;
    FCurValue: Longint;
    FKind: TGaugeKind;
    FShowText: Boolean;
    FBorderStyle: TBorderStyle;
    FForeColor: TColor;
    FBackColor: TColor;
    procedure PaintBackground(AnImage: TBitmap);
    procedure PaintAsText(AnImage: TBitmap; PaintRect: TRect);
    procedure PaintAsNothing(AnImage: TBitmap; PaintRect: TRect);
    procedure PaintAsBar(AnImage: TBitmap; PaintRect: TRect);
    procedure PaintAsPie(AnImage: TBitmap; PaintRect: TRect);
    procedure PaintAsNeedle(AnImage: TBitmap; PaintRect: TRect);
    procedure SetGaugeKind(Value: TGaugeKind);
    procedure SetShowText(Value: Boolean);
    procedure SetBorderStyle(Value: TBorderStyle);
    procedure SetForeColor(Value: TColor);
    procedure SetBackColor(Value: TColor);
    procedure SetMinValue(Value: Longint);
    procedure SetMaxValue(Value: Longint);
    procedure SetProgress(Value: Longint);
    function GetPercentDone: Longint;
  protected
    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure AddProgress(Value: Longint);
    property PercentDone: Longint read GetPercentDone;
  published
    property Align;
    property Color;
    property Enabled;
    property Kind: TGaugeKind read FKind write SetGaugeKind default gkHorizontalBar;
    property ShowText: Boolean read FShowText write SetShowText default True;
    property Font;
    property BorderStyle: TBorderStyle read FBorderStyle write SetBorderStyle default bsSingle;
    property ForeColor: TColor read FForeColor write SetForeColor default clBlack;
    property BackColor: TColor read FBackColor write SetBackColor default clWhite;
    property MinValue: Longint read FMinValue write SetMinValue default 0;
    property MaxValue: Longint read FMaxValue write SetMaxValue default 100;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property Progress: Longint read FCurValue write SetProgress;
    property ShowHint;
    property Visible;
  end;

  {---------------------------------------------------------------------
     a full functionnal Status panel with auto sizing, lot of options,
     keyState, resources viewer, date and time and self update
  ----------------------------------------------------------------------}
  TStatus = class(TCustomPanel)
  private
    FDate         : Boolean;
    FKeys         : Boolean;
    FTime         : Boolean;
    FResources    : Boolean;
    DateTimePanel : TPanel;
    ResPanel      : TPanel;
    ResGauge      : TGauge;
    CapPanel      : TPanel;
    NumPanel      : TPanel;
    InsPanel      : TPanel;
    HelpPanel     : TPanel;
    UpdateWidth   : Boolean;
    FTimer        : TTimer;
    fTimerOn      : boolean;
    procedure SetDate(A: Boolean);
    procedure SetKeys(A: Boolean);
    procedure SetTime(A: Boolean);
    procedure SetResources(A: Boolean);
    procedure SetCaption(A: String);
    Function  GetCaption: String;
    Procedure SetTimerOn(a : boolean);
    procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure SetupPanelFields(ThePanel: TPanel);
    procedure SetupPanel(ThePanel: TPanel; WidthMask: String);
    procedure UpdateStatusBar(Sender: TObject);
  published
    property ShowDate: Boolean read FDate write SetDate default True;
    property ShowKeys: Boolean read FKeys write SetKeys default True;
    property ShowTime: Boolean read FTime write SetTime default True;
    property ShowResources: Boolean read FResources write SetResources default True;
    property BevelInner;
    property BevelOuter;
    property BevelWidth;
    property BorderStyle;
    property BorderWidth;
    property Caption: string read GetCaption write SetCaption;
    property TimerOn : boolean read fTimeron write SetTimerOn;
    property Color;
    property Ctl3D;
    property DragCursor;
    property DragMode;
    property Enabled;
    property Font;
    property ParentColor;
    property ParentCtl3d;
    property ParentFont;
    property ParentShowHint;
    property PopUpMenu;
    property ShowHint;
    property Visible;
  end;


{ ************************************************************** }
{ *  This component draws a 7 segment display character        * }
{ *      Written and developed by Mr Keith A. Moore,           * }
{ *                               Process Automation Dept.     * }
{ *                               UCB Films plc.               * }
{ *  Please feel free to derive any new components,            * }
{ *  see the 'SEG7.WRI' file for details of where to           * }
{ *  send any feedback.                                        * }
{ ************************************************************** }
{ 26/10/96, add an new displayable value : '-'                   }
{           add a border around component (BorderColor)          }
{           PC-H 101677.455@compuserve.com                       }
{ ************************************************************** }
{ 30/10/96, linkable 7seg, allowing multi characters             }
{           PC-H 101677.455@compuserve.com                       }
{ ************************************************************** }
  TSevenSegmentDisplay = class(TGraphicControl)
  private
    fBlockValue  : longint;                  { for multiple 7seg             }
    fNext7Seg    : TGraphicControl;          { next 7seg in block            }
    Segments     : Byte;                     { Byte containing binary code   }
                                             { for the segments (see below)  }
    fBorderWidth : Byte;                     { Border width, must be 0 or 1  }
                                             { for this release              }
    FBorderColor : Tcolor;                   { Border Color                  }
    fDrawSegOff  : Boolean;                  { for fast update               }

                 { precision }
                 {     bit0     }
                 {   --------   }
                 {  |        |  }
                 {b1|   b3   |b2}
                 {   --------   }
                 {  |        |  }
                 {b4|   b6   |b5}
                 {   --------   }

    FValue       : Char;                     {*Actual value to be displayed  *}
    FSegOnColor,                             {*Color of segments when on     *}
    FSegOffColor : TColor;                   {*Color of segments when off    *}
    FOnChange    : TNotifyEvent;             {*OnChange event variable       *}

    procedure SetValue(Value : Char);        {*Property setting routines     *}
    procedure SetSegOnColor(Value : TColor);
    procedure SetSegOffColor(Value : TColor);
    procedure SetBorderColor(Value : TColor);
    procedure SetBorderWidth(Value : Byte);
    procedure Change; virtual;               {*OnChange Event implementation *}
    procedure SetBlockValue(Value : LongInt);       { property setting proc   }
    procedure SetNext7Seg(Value : tGraphicControl); { property setting proc   }
  protected
    { ********* Painting Routines ******************************************* }
    { ** Copies Entire SourceC canvas to DestR on DestC canvas ************** }
    procedure ImageCopy(DestC : TCanvas; DestR : TRect; SourceC : TCanvas);
    procedure Paint; override;
    { ** Fills a bitmap object with color 'COL' ** }
    procedure PaintBackGround(var AnImage : TBitmap; Col : TColor);
    { ** Draws all the segments of the display ** }
    procedure PaintSegments(var AnImage : TBitmap); virtual;
    { ** Paints a horizontal segment at co-ordinates X,Y (called by PaintSegments) ** }
    procedure PaintHorizSegment(var AnImage : TBitmap; X, Y : Integer; Col : TColor); virtual;
    { ** Paints a vertical segment at co-ordinates X,Y (called by PaintSegments) ** }
    procedure PaintVertSegment(var AnImage : TBitmap; X, Y : Integer; Col : TColor); virtual;
  public
    constructor Create(AOwner : TComponent); override;
    Procedure   Inc;
    Procedure   Dec;
  published
    { link to other 7seg display }
    property Next7Seg : tGraphicControl read fNext7Seg Write SetNext7Seg;
    property Color default clSilver;                      { Background color }
    property Cursor;                                      { Cursor Shape     }
    property DragCursor;
    property DragMode;
    property Enabled;
    property Hint;
    property ParentColor;
    property ParentShowHint;
    property PopupMenu;
    { * Color of segments when they are lit * }
    property SegOnColor : TColor read FSegOnColor write SetSegOnColor default clYellow;
    { * Color of segments when they are not lit * }
    property SegOffColor : TColor read FSegOffColor write SetSegOffColor default clGray;
    property BorderColor : tColor read FBorderColor  write SetBorderColor default clWhite;
    property BorderWidth : byte   read FBorderWidth  write SetBorderWidth default 1;
    property ShowHint;
    { * Current Value of the seven segment display * }
    property Value : Char read FValue write SetValue default '0';
    property Visible;
    { Current value for multiple 7seg display }
    property BlockValue : longInt read fBlockValue write setBlockValue default 0;
        { ** Standard Events ** }
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    { * Occurs when the user changes the value property and presses return to confirm * }
    property OnChange : TNotifyEvent read FOnChange write FOnChange;
    property DrawSegOff : boolean read fDrawSegOff write fDrawSegOff;
  end;


(****************************************************************************)
(* TPanel7Segment : multiple seven segment panel display                    *)
(* written and developed by :  Pascal Courte-Heuse                          *)
(*                             company : AMC                               *)
(*                             101667.455@compuserve.com                    *)
(* build from an idea of Keith A. Moore ( 100101.1630@compuserve.com )      *)
(****************************************************************************)
(****************************************************************************)
(* Properties                                                               *)
(*    AutoSize : select a mode to sizing component should be :              *)
(*               None : user component and digit size select                *)
(*               Block : set digit sizes using DigitNumber and blockSize    *)
(*               Digit : set blockSize using DigitNumber and size of digit  *)
(*               Client : set component size to Owner size and set digit    *)
(*                        size using new blockSize                          *)
(*    Color : current color for background when component is active         *)
(*    ColorShutDown : background color when component is "off"              *)
(*    Cursor : no comment                                                   *)
(*    DigitHeight : height for a single digit should be modify by AutoSize  *)
(*    DigitNumber : how many digits in panel                                *)
(*    DigitWidth : width of a single digit should be modify by AutoSize     *)
(*    Height : full size of panel, should be modify by AutoSize             *)
(*    Hint : no comment                                                     *)
(*    LeadingZero : if true, no significant zero are "lite off"             *)
(*    Left : inHerited property                                             *)
(*    Name : inHerited property                                             *)
(*    ParentColor :inHerited property                                       *)
(*    SegmentColorOff : color for segment when segment is OFF               *)
(*    SegmentColorOn  : color for segment when segment is ON                *)
(*    SegmentShutDown : color for segment when panel is "off"               *)
(*    ShutDown : switch to ON/OFF enterely of panel                         *)
(*    Tag : inHerited property                                              *)
(*    Top : inHerited property                                              *)
(*    Value : Value to be displayed, must be a LongInt, sorry for Hexa value*)
(*    Width :inHerited property                                             *)
(****************************************************************************)
  TPanel7Segment = class(TGraphicControl)
  private
    { Private-dclarations }     {  P   R   W   D        Desc                                       }
    fValue : LongInt;            {  x   x   x   x        current value                              }
    fDigitNumber : Byte;         {  x   x   x   x        digits number                              }
    fShutDown : Boolean;         {  x   x   x   x        true for "power off"                       }
    fColorShutDown : tColor;     {  x   x   x   x        background color for shut down display     }
    fAutoSize    : tAutoSize;    {  x   x   x   x        proportionnal design                       }
    fDigitWidth  : Byte;         {  x   x   x   x        X size for single digit                    }
    fDigitHeight : Byte;         {  x   x   x   x        Y size  "     "     "                      }
    fSegmentColorOn : tColor;    {  x   x   x   x        color for segment light on                 }
    fSegmentColorOff : tColor;   {  x   x   x   x        color for segment light off                }
    fSegmentShutDown : tColor;   {  x   x   x   x        color for shut down display                }
    fLeadingZero : boolean;
    fOnChange : tNotifyEvent;
    procedure setValue(aValue : LongInt);
    procedure setDigitNumber(aValue : byte);
    procedure setAutoSize(aValue : tAutoSize);
    procedure setShutDown(aValue : Boolean);
    procedure setColorShutDown(aValue : tColor);
    procedure setDigitWidth(aValue : byte);
    procedure setDigitHeight(aValue : byte);
    procedure setSegmentColorOn(aValue : tColor);
    procedure setSegmentColorOff(aValue : tColor);
    procedure setSegmentShutDown(aValue : tColor);
    procedure setLeadingZero(aValue : Boolean);
    procedure Change; virtual;               {*OnChange Event implementation *}
    procedure PaintADigit(aCanvas : tCanvas;aDigit : Byte;aValue : LongInt);
  protected
    { Protected-dclarations }
    poly4 : Array[1..4] of tPoint;  { tPoint Array for ordinary segments }
    poly6 : Array[1..6] of tPoint;  {   "      "    "  special  segments }
    procedure Paint;override;
  public
    { Public-dclarations }
    constructor Create(AOwner : TComponent); override;
  published
    { Published-dclarations }
    Property Value : LongInt Read fValue write SetValue Default 0;
    Property DigitNumber : byte read fDigitNumber write setDigitNumber Default 1;
    Property AutoSize : tAutoSize read fAutoSize write setAutoSize default None;
    Property ShutDown : boolean read fShutDown write setShutDown default False;
    Property ColorShutDown : tColor read fColorShutDown write SetColorShutDown default clBlack;
    Property DigitWidth : byte read fDigitWidth write setDigitWidth default 28;
    Property DigitHeight : byte read fDigitHeight write setDigitHeight default 38;
    Property SegmentColorOn : tColor read fSegmentColorOn write SetSegmentColorOn default clYellow;
    Property SegmentColorOff : tColor read fSegmentColorOff write SetSegmentColorOff default clgray;
    Property SegmentShutDown : tColor read fSegmentShutDown write SetSegmentShutDown default clMaroon;
    Property LeadingZero : boolean read fLeadingZero Write setLeadingZero;
    { inherited }
    property Width {write setWidth} default 30;
    property Height {write setHeight} default 40;
    property Color default clBlack;
    property ParentColor default false;
    {event }
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnChange : TNotifyEvent read FOnChange write FOnChange;
  end;


(****************************************************************************)
(* TvuMeter : multiple seven segment panel display                          *)
(* written and developed by :  Pascal Courte-Heuse                          *)
(*                             company : AMC                               *)
(*                             101667.455@compuserve.com                    *)
(****************************************************************************)
  tVuMeter = class(TGraphicControl)
  private
    { Private-dclarations }
    fDirection : tDirection;
    fLedNumber : word;
    fLedWidth  : word;
    fLedHeight : Word;
    fLedGreenOn : Tcolor;
    fLedGreenOff : Tcolor;
    fLedYellowOn : Tcolor;
    fLedYellowOff : Tcolor;
    fLedRedOn : Tcolor;
    fLEdRedOff : Tcolor;
    fValue  : Word;
    fDisplayedValue  : Word;
    fLastOn : word;
    fTimer : tTimer;
    property Width;
    property Height;
    property LedNumber : word read fLedNumber write fLedNumber;
    procedure Invalidate;override;
    property LedWidth  : word read fLedWidth  write fLedWidth;
    property LedHeight : word read fLedHeight write fLedHeight;
  protected
    { Protected-dclarations }
    procedure SetDirection(aValue : tDirection);
    procedure SetValue(aValue : word);
    Procedure AdjustLedSize;
    procedure Paint; override;
    procedure UpDateDisplay(sender : tObject);
    procedure setLedGreenOn(aValue: tColor);
    procedure setLedGreenOff(aValue: tColor);
    procedure setLedYellowOn(aValue: tColor);
    procedure setLedYellowOff(aValue: tColor);
    procedure setLedRedOn(aValue: tColor);
    procedure setLedRedOff(aValue: tColor);
  public
    { Public-dclarations }
    fMinValue : word;
    fMaxValue : word;
    constructor Create(aowner : tComponent);override;
    destructor  Destroy;override;
    Procedure   Alea;
  published
    { Published-dclarations }
    property Direction : tDirection read fDirection write setDirection;
    property Color;
    property Value     : word read fValue write SetValue;
    property LedGreenOn : Tcolor read fLedGreenOn write setLedGreenOn;
    property LedGreenOff : Tcolor read fLedGreenOff write setLedGreenOff;
    property LedYellowOn : Tcolor read fLedYellowOn write setLedYellowOn;
    property LedYellowOff : Tcolor read fLedYellowOff write setLedYellowOff;
    property LedRedOn : Tcolor read fLedRedOn write setLedRedOn;
    property LedRedOff : Tcolor read fLedRedOff write setLedRedOff;
    { publishing inherited property }
    property onMouseUp;
    property onMouseDown;
    property onMouseMove;
    property onClick;
    property onDblClick;
    property onDragDrop;
    property onDragOver;
    property onEndDrag;
  end;

(****************************************************************************)
(* TLinearPotentiometer : single linear potentiometer range from 0 to 100   *)
(* written and developed by :  Pascal Courte-Heuse                          *)
(*                             company : AMC                               *)
(*                             101667.455@compuserve.com                    *)
(****************************************************************************)
  TLinearPotentiometer = class(TCustomPanel)
  private
    { Private-dclarations }
    fDrawBitmap : tBitMap; { reserved field for fast drawing          }
    fResName    : Array[0..10] of Char; { reserved for resource name  }
    fSRect      : tRect; { reserved for resource sizing               }
    fBtnRect    : tRect; { actual pos of button                       }
    fDRect      : tRect; { Rect for background drawing                }
    fCurseur    : tBitmap; { button bitmap                            }
    fValue      : Integer; { current value                            }
    fValueChange : Boolean; { if true then fast Paint function        }
    fMaxValue : integer;    { max allowed value                       }
    fbtnColor : tColorBtn;  { btn aspect                              }
    fXFactor,               { use by mouse cursor management          }
    fYFactor  : real;       { to find where is the button...          }
    fLastX,                 { location of old XY mouse pointer        }
    fLastY    : integer;    {                                         }
    fMinStep  : real;       { min Y step when dragging                }
    procedure SetValue(a : integer);
    procedure setBtnColor(a : tColorBtn);
    procedure SizeChanging(Sender : tObject); { event manager         }
    procedure MouseMove( Sender: TObject;
                         Shift: TShiftState;
                         X,Y: Integer);
    procedure MouseDown( Sender: TObject;
                         Shift: TShiftState;
                         X,Y: Integer);
    Function  PointInBtn(X,Y : Integer) : Boolean;
  protected
    { Protected-dclarations }
      procedure Paint; override;
  public
    { Public-dclarations }
    constructor create(a : tComponent);override;
    destructor  Destroy;override;
  published
    { Published-dclarations }
    property Value : integer read fValue write SetValue;
    property btnColor : tColorBtn read fBtnColor write SetBtnColor;
    property BevelInner;
    property BevelOuter;
    Property BorderStyle;
    property width;
    property Height;
    property Left;
    property Top;
    property Color;
    property Visible;
    property Align;
    property onClick;
    property onDblClick;
    property onMouseDown;
    property onMouseMove;
    property onMouseUp;
    property onResize;
  end;

procedure Register;

implementation

 