⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 lcdscreen.pas.svn-base

📁 LCDScreen is a couple of Delphi component which simulate a dot-LCD multilines screen. It is fully c
💻 SVN-BASE
📖 第 1 页 / 共 5 页
字号:
unit LCDScreen;

////////////////////////////////////////////////////////////////////////////////
//
//  TLCDScreen / TLCDAnimator v2.5 (15/aug/01)
//  written by Jacques VOIRIN
//  E-Mail: jacques.voirin@iname.com
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//   TLCDScreen is an alphanumeric LCD- like display with multidirectionnal
//   scrolling and smart animation features.
//
//   TLCDScreen can be fully customized throught its On/Off Pixels Intensity,
//   DotMatrix, PixelSize, etc. properties.
//   The caption is strored in Lines: TStrings.
//   In order to animate a TLCDScreen link it to a TLCDAnimator,
//   using its LCDAnimator property.
//   AnimationEnabled and AnimationDelay control the execution of the Animation
//   Code store in a TLCDAnimator.
//
//   For best look, use 65536 colors (16 bits) or higher.
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//  TLCDScreen's props and methods list:
//  -----------------------------------
//
//   About: String               - Just for copyright;
//   AnimationDelay: Cardinal    - The smaller, the faster;
//   AnimationEnabled: Boolean   - Animation is set on or off;
//   AnimationRepeating: Boolean - If True, repeat the animation's code when done;
//   AnimationUnits: TAnimationUnit - auChar or auPixel;
//   BorderSpace: Byte       - The width in pixels beetween LCDdots and the border;
//   BorderStyle: TLCDBorder - bsRaised, bsLowered or bsNone;
//   CharSpacing: Byte       - The horz. width in pixels beetween LCD characters;
//   Color: TColor           - The main, background color of the component;
//   Cursor;
//   DotMatrix: TDotMatrix   - LCD's display look: mat5x7, mat7x9, mat9x12,
//   DotMatrixBorders: set of TDotMatrixBorder; (mbBottom, mbLeft, mbRight, mbTop)
//                           -  Put an empty line around one char;
//   Enabled;
//   Height;
//   Hint;
//   HorzScrollMode: TScrollMode - smIndependant or smDependant;
//                                 Only used with horizontal scroll directions.
//   Intensity: ShortInt     - The light power. [-127..127]
//                             'OnScreenOnPixColor := PixOnColor*Intensity'
//   LCDAnimator: TLCDAnimator - The animation code is store in it;
//   Left;
//   Lines: TStringList      - Where the text is strore. Can be edited at runtime
//                             using standard TStringList's functions;
//   LineSpacing: Byte       - The vert. width in pixels beetween LCD characters;
//   NoOfLines  : Byte       - The number of lines displayed;
//   NoOfChars  : Byte       - The number of characters displayed;
//   PixelHeight: Byte       - A read only prop in the general case.
//                             Only used when PixelSize is set to pixCustom;
//   PixelOff : TColor       - The color of switched on dots;
//   PixelOn  : TColor       - The color of switched off dots;
//   PixelShape: TPixelShape - The look of dots: psSquare, psShaped or psRound;
//   PixelSize: TPixelSize   - The size of one dot: pix1x1..pix16x16 or pixCustom;
//   PixelSpacing: Byte      - The vert.and horz.width in pixels beetween LCDdots;
//   PixelWidth: Byte        - A read only prop in the general case.
//                             Only used when PixelSize is set to pixCustom;
//   ShowHint;
//   Tag;
//   Top;
//   Visible;
//   Width;
//
//   OnClick;
//   OnDblClick;
//   OnDragDrop;
//   OnDragOver;
//   OnEndDrag;
//   OnMouseDown;
//   OnMouseMove;
//   OnMouseUp;
//
 //  procedure Reset(Value: TResetMode); TResetMode = (rmDisplay, rmCode, rmDisplayAndCode);
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//  TLCDAnimator's props and methods list:
//  --------------------------------------
//
//   About: String     - Just for copyright;
//   Code: TStrings    - The animation code; Can be edited throught the
//                       TLCDAnimatorEditor's Form;
//   CurrentLine: Byte - the number of the current code line ;
//
//   OnEndCode:      TEndCodeEvent;
//                   TEndCodeEvent = procedure (Sender: TLCDAnimator) of object;
//                   Event fire when code had proceed its last code line.
//
//   OnLineExecuted: TLineExecutedEvent;
//                   TLineExecutedEvent = procedure(Sender: TLCDAnimator; LineNumber: Word) of object;
//                   Event fire each time a line of the code had been proceeded.
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//  History:
//
//   v1.0: (30/jan/00)
//         First public release
//
//   v1.1: (20/feb/00)
//         - New scrolling commands: ScrollDirection removed.
//             Use now ScrollHorz, ScrollVert: ShortInt [-127..127]
//         - Intensity implementation (Byte: [0..255])
//         - BorderSpace, CharSpacing, LineSpacing, NoOfLines, NoOfChars,
//           PixelSpacing and PixelWidth are now Byte type.
//         - CharSpacing and LineSpacing are now expressed width in pixels.
//         - Other cosmetic code design.
//
//   v1.2: (02/apr/00)
//         - New code for Intensity (ShortInt [-128..127])
//           Allow now 'inverse intensity'
//
//   v2.0: (01/may/00)
//         - Introducing TLCDAnimator, the animation command for TLCDScreen
//           All 'Scroll' props and methods are now obsolet.
//           Use now AnimationDelay: Cardinal;
//                   AnimationEnabled: Boolean;
//                   AnimationRepeating: Boolean;
//                   and a TLCDAnimator to anime TLCDScreen;
//           Fisrt version of TLCDAnimatorCodeEditorForm.
//         - Remove all Dynamic Arrays: Less nice :(
//                                      but more compatible with old Delphi :))
//         - Rewrite drawing/scrolling routines.
//         - Removed internal FDisplayLines.
//
//   v2.1: (01/jun/00)
//         - An empty line doesn't raise error in TLCDAnimator.
//         - pixCustom bug fix.
//         - No more global protection error when a TLCDAnimator linked to a TLCDScreen
//           is detroyed.
//         - No more global protection error when TLCDScreen.LCDAnimator
//           is cleared.
//         - Other cosmetic code design.
//
//   v2.2:(01/jul/00)
//         - Matrix.pas ver 2.0 : - Hitachi, Hitachi2, dos5x7 removed;
//                                - use now mat5x7, mat7x9, mat9x12;
//         - Introducing DotMatrixBorders = set of (mbBottom, mbLeft, mbRight, mbTop);
//         - Introducing special effects: inverse and blinking effects;
//
//   v2.3:(20/jul/00)
//         - Fisrt version of TLCDScreenLineEditorForm.

//   v2.5:(15/aug/01)
//         - D6 version and new code design with TLCDScreenReg.pas
//         - Code cleaning and rewriting animation routines;
//         - Add AnimationUnits: TAnimationUnit = (auChar, auPixel);
//         - Add two new special effects: underline and strike;
//         - Remove psShaped from Pixelshape (not really usefull);
//         - Remove InfoPanelOn/Off (too buggy);
//         - Remove BorderColor and simplify BorderStyle;
//         - Updated Demo.exe and Help file;
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//  Know bugs:
//
//   - none :)
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//  The Strory and the Status of TLCDScreen
//  ---------------------------------------
//
//  TLCDScreen is based on an original code from Peter Czidlina's TLCDLabel v1.5a
//                               (petercz@swipnet.se)
//                               (http://hem2.passagen.se/ebcpecz/)
//
// The mother code for dots and characters drawing and Matrix.pas are Peter
// Czidlina's stuff.
// At the beginning, my idea was only to improve TLCDLabel.
// First, I try to implemente a true-multiline dimension. When done I add
// scrolling capacities to the component. I also recode drawing routines
// to improve speed.
// Days after days, improvments after improvments and e-mails after e-mails,
// it appears that I write a totally new component.
// Then, with the express agreement of Peter, I rename it and publish my work
// under my name.
//
// As Peter Czidlina's component was FREEWARE, it was easy for me to analyse his
// code and try to improve it.
//
// This is why TLCDScreen is also FREEWARE.
// However, use in commercial or shareware applications requires
// MY EXPRESS WRITTEN PERMISSION.
//
////////////////////////////////////////////////////////////////////////////////
//
// There is no direct compatibility between TLCDScreen and TLCDLabel because
// some properties had been renames, added or removed from the original code.
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
// Installation note:
// ------------------
//    TLCDScreen use 'DsgnIntf.pas' for the About prop and the TLCDAnimator's
//    ComponentEditor and PropertyEditor.
//    'DsgnIntf.pas' can be find in '$(DELPHI)\Source\Toolsapi'
//    Then you must add it:
//                [Project/Options]
//                [Select Directories/Conditionnals]
//                Add [$(DELPHI)\Source\Toolsapi] in [SearchPath]
//
//
////////////////////////////////////////////////////////////////////////////////

////////////////////////////////////////////////////////////////////////////////
//
//  Please notice bugs or problems, suggestions and improvements at
//
//  jacques.voirin@iname.com
//
////////////////////////////////////////////////////////////////////////////////


interface

{$R LCDScreen.res}

uses
  Windows, Classes, Graphics, Controls, Dialogs, ExtCtrls, Math, SysUtils,
  Forms, Matrix;


function NbOfThings(tempcode: string; Thing: Char): Integer;


const MaxSizeCodeInstructionArray = 255; //Removing dynamic Arrays...


type
  TLCDAnimator = class;

  TCodeInstruction = record
                       Word: string[25];
                       Param: Integer;
                       end;

  CodeInstructionArrayBuilder = array[1..MaxSizeCodeInstructionArray] of TCodeInstruction; //Removing dynamic Arrays...

  TEndCodeEvent = procedure(Sender: TLCDAnimator) of object;

  TResetMode = (rmDisplay, rmCode, rmDisplayAndCode);

  TLineExecutedEvent = procedure(Sender: TLCDAnimator; LineNumber: Word) of object;

  //TDotMatrix = (mat5x7, mat7x9, mat9x12 {, CustomFont});

  TDotMatrixBorder = (mbBottom, mbLeft, mbRight, mbTop);

  TDotMatrixBorders = set of TDotMatrixBorder;

  TPixelSize = (pixCustom, pix1x1, pix2x2, pix3x3, pix4x4, pix5x5, pix6x6,
                pix7x7, pix8x8, pix9x9, pix10x10, pix11x11, pix12x12, pix13x13,
                pix14x14, pix15x15, pix16x16);

  TPixelShape = (psSquare, psRound);

  TLCDBorder = (bsLowered, bsNone, bsRaised);

  TSpecialEffect = (spBlinking, spInverse, spUnderline, spStrike);

  TSpecialEffects = set of TSpecialEffect;

  TAnimationUnit = (auChar, auPixel);

  TOneChar = record
                TheChar:WideChar;
                SpEff: Byte;
                end;

////////////////////////////////////////////////////////////////////////////////
//
// TLCDAnimator
//
////////////////////////////////////////////////////////////////////////////////

  TLCDAnimator = class(TComponent)
  private
    FCode: TStrings;
    FCodeErrorFound: Boolean;
    FCurrentLine: SmallInt;
    FOnEndCode: TEndCodeEvent;
    FOnLineExecuted: TLineExecutedEvent;
    function  GetAbout: string;
    procedure SetAbout(Value: string);
    procedure SetCurrentLine(Value: SmallInt);

  protected
    procedure SetCode(Value: TStrings);

  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy; override;

  published
    property About: string read GetAbout write SetAbout stored False;
    property Code: TStrings read FCode write SetCode;
    property CodeErrorFound: Boolean read FCodeErrorFound write FCodeErrorFound;
    property CurrentLine: SmallInt read FCurrentLine write SetCurrentLine;
    property OnEndCode: TEndCodeEvent read FOnEndCode write FOnEndCode;
    property OnLineExecuted: TLineExecutedEvent read FOnLineExecuted write FOnLineExecuted;
  end;


////////////////////////////////////////////////////////////////////////////////
//
// TLCDScreen
//
////////////////////////////////////////////////////////////////////////////////

  TLCDScreen = class(TGraphicControl)
  private

    P: ^CodeInstructionArrayBuilder;      //Removing dynamic Arrays...
    Display: array [0..255,0..255] of TOneChar; { Internal image of the screen        }
    PixHRef, PixVRef: ShortInt;           { Internal offset in Pixel unit             }
    CharHRef, CharVRef: SmallInt;         { Internal offset in Char unit              }
    CharWidth, CharHeight: Word;          { Temp. storage of character sizes          }
    psx, psy: Byte;                       { Internal pixel dimension variables        }
    FontWidth, FontHeight: Byte;          { Font size                                 }
    FTimer: TTimer;                       { Internal Timer                            }
    //FVirginMatrixBitmap: TBitmap;         { Internal bitmap of a virgin matrix        }
    //FBlackMatrixBitmap: TBitmap;          { Internal bitmap of a allOnPixels matrix   }
    //FDisplayCharBitmap: TBitmap;

    FVirginMatrixDC: HDC;
    FVirginMatrixBitmap: TBitmap;
    FOVirginMatrixBitmap: HBITMAP;

    FBlackMatrixDC: HDC;
    FBlackMatrixBitmap: TBitmap;
    FOBlackMatrixBitmap: HBITMAP;

    FCharDC: HDC;
    FCharBitmap, FOCharBitmap: HBITMAP;
    
    FTrueOnColor : TColor;                { Internal color for OnPixels               }
    FTrueOffColor: TColor;                { Internal color for OffPixels              }
    FBlinkingStatus: Boolean;             { Internal Blinking On/Off flag             }

    FAnimationDelay: Cardinal;            { In milliseconds; the smaller, the faster  }
    FAnimationEnabled: Boolean;           { Enable or disable the animation           }
    FAnimationRepeating: Boolean;         { What to do when all code lines had been processed }
    FAnimationUnits: TAnimationUnit;      { Animation pixel per pix or char per char  }
    FBorderSpace: Byte;                   { Distance from the LCD border              }
    FBorderStyle: TLCDBorder;             { Border around the the component           }
    FCharSpacing: Byte;                   { Space between the characters on the LCD   }
    FColor: TColor;                       { LCD color                                 }
    //FDotMatrix: TDotMatrix;               { Type of character matrix on the LCD       }
    FDotMatrixBorders: TDotMatrixBorders; { PixelOff borders around a character       }
    FHeight: Integer;                     { Label height in pixels                    }
    FIntensity: ShortInt;                 { [-128..127] percentage of ligth           }
    FLCDAnimator: TLCDAnimator;           { The TLCDAnimator associated with          }
    FLines: TStringList;                  { The component's multilines text           }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -