MMBmpLED.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:28k
- {========================================================================}
- {= (c) 1995-98 SwiftSoft Ronald Dittrich =}
- {========================================================================}
- {= All Rights Reserved =}
- {========================================================================}
- {= D 01099 Dresden = Fax.: +49(0)351-8037944 =}
- {= Loewenstr.7a = info@swiftsoft.de =}
- {========================================================================}
- {= Actual versions on http://www.swiftsoft.de/index.html =}
- {========================================================================}
- {= This code is for reference purposes only and may not be copied or =}
- {= distributed in any format electronic or otherwise except one copy =}
- {= for backup purposes. =}
- {= =}
- {= No Delphi Component Kit or Component individually or in a collection=}
- {= subclassed or otherwise from the code in this unit, or associated =}
- {= .pas, .dfm, .dcu, .asm or .obj files may be sold or distributed =}
- {= without express permission from SwiftSoft. =}
- {= =}
- {= For more licence informations please refer to the associated =}
- {= HelpFile. =}
- {========================================================================}
- {= $Date: 03.11.98 - 14:57:52 $ =}
- {========================================================================}
- unit MMBmpLED;
- {$I COMPILER.INC}
- interface
- uses
- Windows,
- SysUtils,
- Messages,
- Classes,
- Graphics,
- Controls,
- CommCtrl,
- ExtCtrls,
- Menus,
- Forms,
- MMObj,
- MMUtils,
- MMString,
- MMBmpLst,
- MMObsrv;
- type
- {-- TMMCustomBitmapLEDDigit -----------------------------------------------}
- TMMCustomBitmapLEDDigit = class(TMMCustomBitmapListControl);
- TMMPaintImage = procedure(Sender: TObject; Canvas: TCanvas; DstRect, SrcRect: TRect) of object;
- {-- TMMBitmapLEDDigit ------------------------------------------------------}
- TMMBitmapLEDDigit = class(TMMCustomBitmapLEDDigit)
- private
- FMinValue : integer;
- FMaxValue : integer;
- FValue : Longint;
- FDrawInactive : Boolean;
- FZeroBlank : Boolean;
- FEnabled : Boolean;
- FCascade : Boolean;
- FGlyphIndex : integer;
- FNumGlyphs : integer;
- FConnect : TMMCustomBitmapLEDDigit;
- FOnRollForward : TNotifyEvent;
- FOnRollBackward: TNotifyEvent;
- FOnPaint : TMMPaintImage;
- procedure SetNumGlyphs(aValue: integer);
- procedure SetGlyphIndex(aValue: integer);
- procedure SetEnabled(aValue: Boolean);
- function GetEnabled: Boolean;
- procedure SetMinValue(aValue: integer);
- procedure SetMaxValue(aValue: integer);
- procedure SetValue(aValue: Longint);
- procedure SetZeroBlank(aValue: Boolean);
- procedure SetCascade(aValue: Boolean);
- procedure SetConnect(aControl: TMMCustomBitmapLEDDigit);
- protected
- procedure Paint; override;
- procedure FastDraw; virtual;
- procedure Notification(AComponent: TComponent; Operation: TOperation); override;
- procedure RollForward; dynamic;
- procedure RollBackward; dynamic;
- procedure BitmapChanged; override;
- public
- constructor Create (AOwner: TComponent); override;
- procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
- procedure Increase;
- procedure Decrease;
- published
- { Events }
- property OnClick;
- property OnDblClick;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnDragDrop;
- property OnDragOver;
- property OnEndDrag;
- property OnStartDrag;
- property OnRollForward: TNotifyEvent read FOnRollForward write FOnRollForward;
- property OnRollBackward: TNotifyEvent read FOnRollBackward write FOnRollBackward;
- property OnPaint: TMMPaintImage read FOnPaint write FOnPaint;
- property Color default clBlack;
- property ParentColor;
- property ParentShowHint;
- property DragCursor;
- property ShowHint;
- property Visible;
- property Width default 11;
- property Height default 21;
- property PopupMenu;
- property BitmapList;
- property BitmapIndex;
- property BitmapBackIndex;
- property NumGlyphs: integer read FNumGlyphs write SetNumGlyphs;
- property GlyphIndex: integer read FGlyphIndex write SetGlyphIndex default 0;
- property Enabled: Boolean read GetEnabled write SetEnabled default True;
- property MinValue: integer read FMinValue write SetMinValue default 0;
- property MaxValue: integer read FMaxValue write SetMaxValue default 9;
- property Value: Longint read FValue write SetValue default 0;
- property ZeroBlank: Boolean read FZeroBlank write SetZeroBlank default False;
- property CascadeValues: Boolean read FCascade write SetCascade default False;
- property Connect: TMMCustomBitmapLEDDigit read FConnect write SetConnect;
- end;
- TMMScrollDirection = (sdLeft,sdRight);
- {-- TMMBitmapLabel --------------------------------------------------------}
- TMMBitmapLabel = class(TMMCustomBitmapListControl)
- private
- FRC_CharWidth : integer; { the width of one digit }
- FRC_CharHeight: integer; { the height of one digit }
- FAutoSize : Boolean;
- FCharSpace : integer;
- FNumChars : integer;
- FAutoScroll : Boolean;
- FTimer : TTimer;
- FSpeed : integer;
- FScrollDir : TMMScrollDirection;
- FStartStep : integer;
- FCurStep : integer;
- FOnChange,
- FOnBegin,
- FOnStep,
- FOnEnd : TNotifyEvent;
- procedure AdjustControlSize(var W, H: integer);
- procedure AdjustBounds;
- procedure DrawLabel;
- procedure SetAutoSize(aValue: Boolean);
- procedure SetCharSpace(aValue: integer);
- procedure SetNumChars(aValue: integer);
- procedure SetCurStep(aValue: integer);
- procedure SetStartStep(aValue: integer);
- procedure SetSpeed(aValue: integer);
- procedure SetAutoScroll(aValue: Boolean);
- procedure SetScrollDir(aValue: TMMScrollDirection);
- procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
- protected
- procedure BitmapChanged; override;
- procedure Paint; override;
- procedure Loaded; override;
- procedure TimerTick(Sender: TObject);
- procedure Changed; override;
- function GetCharMapping(ch: Char): integer; virtual;
- public
- constructor Create (AOwner: TComponent); override;
- destructor Destroy; override;
- procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
- procedure Start;
- procedure Stop;
- published
- { Events }
- property OnClick;
- property OnDblClick;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnChange: TNotifyEvent read FOnChange write FOnChange;
- property OnBegin: TNotifyEvent read FOnBegin write FOnBegin;
- property OnStep: TNotifyEvent read FOnStep write FOnStep;
- property OnEnd: TNotifyEvent read FOnEnd write FOnEnd;
- property Align;
- property Caption;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property Visible;
- property Width default 11;
- property Height default 13;
- property AutoSize: Boolean read FAutoSize write SetAutoSize default True;
- property Enabled;
- property BitmapList;
- property BitmapIndex;
- property NumChars: integer read FNumChars write SetNumChars default 12;
- property CharSpace: integer read FCharSpace write SetCharSpace default 0;
- property ScrollSpeed: integer read FSpeed write SetSpeed default 100;
- property StartStep: integer read FStartStep write SetStartStep default 0;
- property CurrentStep: integer read FCurStep write SetCurStep default 0;
- property AutoScroll: Boolean read FAutoScroll write SetAutoScroll default False;
- property ScrollDirection: TMMScrollDirection read FScrollDir write SetScrollDir default sdLeft;
- end;
- implementation
- const
- RC_NumDigits = 11; { number of digits in the digit bitmap }
- RC_CHARSPERROW = 31; { number of chars in the label bitmap }
- RC_CHARROWS = 3; { number of rows in the label bitmap }
- {== TMMBitmapLEDDigit ==========================================================}
- constructor TMMBitmapLEDDigit.Create (AOwner: TComponent);
- begin
- inherited Create (AOwner);
- Width := 11;
- Height := 21;
- FCascade := False;
- FConnect := Nil;
- FEnabled := True; { !!!!!!!! ev. wieder zu inherited 鋘dern }
- FMinValue := 0;
- FMaxValue := 9;
- FDrawInactive := True;
- FZeroBlank := False;
- FNumGlyphs := 1;
- FGlyphIndex := 0;
- ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
- if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.Notification(AComponent: TComponent; Operation: TOperation);
- begin
- inherited Notification(AComponent, Operation);
- if (Operation = opRemove) then
- begin
- if (AComponent = FConnect) then
- FConnect := nil;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.BitmapChanged;
- begin
- if BitmapValid then
- SetBounds(Left, Top, Bitmap.Width, Bitmap.Height);
- inherited BitmapChanged
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetGlyphIndex(aValue: integer);
- begin
- if (aValue <> FGlyphIndex) then
- begin
- FGlyphIndex := MinMax(aValue,0,FNumGlyphs-1);
- Invalidate;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetNumGlyphs(aValue: integer);
- begin
- if (FNumGlyphs <> aValue) then
- begin
- FNumGlyphs := Max(aValue,1);
- if BitmapValid then
- SetBounds(Left, Top, Bitmap.Width, Bitmap.Height);
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.RollForward;
- begin
- if (csLoading in ComponentState) or
- (csReading in ComponentState) then exit;
- if assigned(FOnRollForward) then FOnRollForward(self);
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.RollBackward;
- begin
- if (csLoading in ComponentState) or
- (csReading in ComponentState) then exit;
- if assigned(FOnRollBackward) then FOnRollBackward(self);
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
- Var
- DigitWidth: integer;
- begin
- if BitmapValid then
- begin
- DigitWidth := Bitmap.Width div RC_NumDigits;
- inherited SetBounds(aLeft, aTop, DigitWidth, Bitmap.Height div FNumGlyphs);
- end
- else inherited SetBounds(aLeft, aTop, aWidth, aHeight);
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetZeroBlank(aValue: Boolean);
- begin
- if (FZeroBlank <> aValue) then
- begin
- FZeroBlank := aValue;
- Invalidate;
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK2}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetCascade(aValue: Boolean);
- begin
- if (aValue <> FCascade) then FCascade := aValue;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetMinValue(aValue: integer);
- begin
- if (aValue <> FMinValue) AND (aValue >= 0) AND (aValue < 10) then
- begin
- FMinValue := aValue;
- if (FValue < FMinValue) then FValue := FMinValue;
- Invalidate;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetMaxValue(aValue: integer);
- begin
- if (aValue <> FMaxValue) AND (aValue >= 0) AND (aValue < 10) then
- begin
- FMaxValue := aValue;
- if (FValue > FMaxValue) then FValue := FMaxValue;
- Invalidate;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetValue(aValue: Longint);
- begin
- if FCascade AND assigned(FConnect) then
- TMMBitmapLEDDigit(FConnect).Value := aValue div 10;
- aValue := aValue mod 10;
- if (aValue <> FValue) AND (aValue >= FMinValue) AND (aValue <= FMaxValue) then
- begin
- FValue := aValue;
- if (csDesigning in ComponentState) then
- Refresh
- else
- FastDraw;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.Increase;
- begin
- if (FValue = FMaxValue) then
- begin
- FValue := FMinValue;
- if assigned(FConnect) then TMMBitmapLEDDigit(FConnect).Increase;
- RollForward;
- end
- else inc(FValue);
- Invalidate;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.Decrease;
- begin
- if (FValue = FMinValue) then
- begin
- FValue := FMaxValue;
- if assigned(FConnect) then TMMBitmapLEDDigit(FConnect).Decrease;
- RollBackward;
- end
- else dec(FValue);
- Invalidate;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetEnabled(aValue: Boolean);
- begin
- {inherited Enabled := aValue;}
- if (aValue <> FEnabled) then
- begin
- FEnabled := aValue; { !!!!!!!! ev. wieder zu inherited 鋘dern }
- Invalidate;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- function TMMBitmapLEDDigit.GetEnabled: Boolean;
- begin
- {Result := inherited Enabled;}
- Result := FEnabled; { !!!!!!!! ev. wieder zu inherited 鋘dern }
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.SetConnect(aControl: TMMCustomBitmapLEDDigit);
- var
- C: TMMCustomBitmapLEDDigit;
- begin
- if FConnect <> aControl then
- begin
- C := aControl;
- while (C <> nil) and (C <> Self) do
- begin
- if C is TMMBitmapLEDDigit then
- C := TMMBitmapLEDDigit(C).Connect
- else break;
- end;
- if C <> Self then
- FConnect := aControl;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.FastDraw;
- var
- DC: HDC;
- Control: TWinControl;
- begin
- Control := Parent;
- if Visible and (Control <> nil) and Control.HandleAllocated then
- begin
- DC := GetDC(Control.Handle);
- try
- {$IFDEF DELPHI3}
- Canvas.Lock;
- {$ENDIF}
- if RectVisible(DC, Rect(Left, Top, Left + Width, Top + Height)) then
- begin
- MoveWindowOrg(DC, Left, Top);
- IntersectClipRect(DC, 0, 0, Width, Height);
- Canvas.Handle := DC;
- Paint;
- end;
- finally
- ReleaseDC(Control.Handle, DC);
- Canvas.Handle := 0;
- {$IFDEF DELPHI3}
- Canvas.Unlock;
- {$ENDIF}
- end;
- end;
- end;
- {-- TMMBitmapLEDDigit ----------------------------------------------------------}
- procedure TMMBitmapLEDDigit.Paint;
- Var
- MemDC: HDC;
- oldBitmap: HBitmap;
- BitmapOfs: integer;
- Blank: Boolean;
- X,Y: integer;
- begin
- if BitmapValid then
- begin
- {$IFDEF DELPHI3}
- Bitmap.Canvas.Lock;
- {$ENDIF}
- try
- if FZeroBlank and (FValue = 0) then Blank := True
- else Blank := False;
- BitmapOfs := Width * ((Ord(FValue)+1) * Ord(Enabled)) * Ord(NOT Blank);
- X := BitmapOfs;
- Y := FGlyphIndex*Height;
- if assigned(FOnPaint) then
- begin
- FOnPaint(Self,Canvas,ClientRect,Rect(X,Y,X+Width,Y+Height));
- end
- else
- begin
- MemDC := CreateCompatibleDC(0);
- oldBitmap := SelectObject(MemDC, Bitmap.Handle);
- BitBlt(Canvas.Handle,
- 0, 0, Width, Height,
- MemDC,
- X, Y,
- SRCCOPY);
- SelectObject(MemDC, oldBitmap);
- DeleteDC(MemDC);
- end;
- finally
- {$IFDEF DELPHI3}
- Bitmap.Canvas.UnLock;
- {$ENDIF}
- end;
- end
- else if csDesigning in ComponentState then
- begin
- Canvas.Brush.Style := bsClear;
- Canvas.Pen.Color := clBlack;
- Canvas.Pen.Style := psDot;
- Canvas.Rectangle(0,0,Width,Height);
- end;
- end;
- {== TMMBitmapLabel ============================================================}
- constructor TMMBitmapLabel.Create (AOwner: TComponent);
- begin
- inherited Create(AOwner);
- FRC_CharWidth := 1;
- FRC_CharHeight := 1;
- FAutoScroll := False;
- FSpeed := 100;
- FStartStep := 0;
- FCurStep := 0;
- FScrollDir := sdLeft;
- FTimer := nil;
- Width := 11;
- Height := 13;
- FAutoSize := True;
- NumChars := 11;
- FCharSpace := 0;
- Color := clBlack;
- ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
- if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- destructor TMMBitmapLabel.Destroy;
- begin
- if (FTimer <> nil) then FTimer.Free;
- inherited Destroy;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.BitmapChanged;
- begin
- if BitmapValid then
- begin
- FRC_CharWidth := Bitmap.Width div RC_CHARSPERROW;
- FRC_CharHeight:= Bitmap.Height div RC_CHARROWS;
- AdjustBounds;
- end;
- inherited BitmapChanged
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.TimerTick(Sender: TObject);
- begin
- if not FTimer.Enabled then exit;
- if FScrollDir = sdLeft then
- inc(FCurStep)
- else
- dec(FCurStep);
- if Visible then DrawLabel;
- if ((FScrollDir = sdLeft) and (FCurStep >= Length(Caption))) or
- ((FScrollDir = sdRight) and (FCurStep <= 0)) then
- begin
- if FAutoScroll then FCurStep := FStartStep
- else FTimer.Enabled := False;
- if Assigned(FOnEnd) then FOnEnd(Self);
- end
- else if Assigned(FOnStep) then FOnStep(Self);
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetAutoScroll;
- begin
- if (aValue <> FAutoScroll) then
- begin
- FAutoScroll := aValue;
- if FAutoScroll then Start
- else Stop;
- FCurStep := FStartStep;
- Invalidate;
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK1}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetScrollDir(aValue: TMMScrollDirection);
- begin
- if (aValue <> FScrollDir) then
- begin
- FScrollDir := aValue;
- if csDesigning in ComponentState then
- if FScrollDir = sdLeft then
- if StartStep = NumChars then StartStep := 0 else
- else
- if StartStep = 0 then StartStep := NumChars;
- end;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.Start;
- begin
- if (FTimer = nil) then
- begin
- FTimer := TTimer.Create(Self);
- with FTimer do
- begin
- Enabled := False;
- OnTimer := TimerTick;
- Interval := FSpeed;
- end;
- end
- else if FTimer.Enabled then exit;
- if (FScrollDir = sdLeft) then
- begin
- if (FCurStep > Length(Caption)) then
- FCurStep := FStartStep;
- end
- else
- begin
- if (FCurStep <= 0) then
- FCurStep := FStartStep;
- end;
- if Assigned(FOnBegin) then FOnBegin(Self);
- FTimer.Enabled := True;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.Stop;
- begin
- if (FTimer <> nil) then FTimer.Enabled := False;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetCurStep(aValue: integer);
- begin
- if (FCurStep <> aValue) AND (aValue >= 0) AND (aValue <= Length(Caption)) then
- begin
- FCurStep := aValue;
- DrawLabel;
- end;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetStartStep(aValue: integer);
- begin
- if (FStartStep <> aValue) AND (aValue >= 0) AND (aValue <= Length(Caption)) then
- begin
- FStartStep := aValue;
- FCurStep := aValue;
- DrawLabel;
- end;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
- Var
- W, H: integer;
- begin
- W := aWidth;
- H := aHeight;
- AdjustControlSize(W,H);
- inherited SetBounds(aLeft, aTop, W, H);
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.AdjustControlSize(Var W, H: integer);
- begin
- if (csLoading in ComponentState) or (csReading in ComponentState) then exit;
- if BitmapValid then
- begin
- if FAutoSize then FNumChars := Length(Caption)
- else FNumChars := (W - (FCharSpace)) div (FRC_CharWidth + FCharSpace);
- if (Align <> alTop) and (Align <> alBottom) then
- W := FNumChars * (FRC_CharWidth + FCharSpace)-(FCharSpace);
- H := Bitmap.Height div RC_CHARROWS;
- end;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.AdjustBounds;
- Var
- W, H: integer;
- begin
- W := Width;
- H := Height;
- AdjustControlSize(W, H);
- if (W <> Width) or (H <> Height) then
- inherited SetBounds(Left, Top, W, H)
- else Invalidate;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.Changed;
- begin
- AdjustBounds;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetAutoSize(aValue: Boolean);
- begin
- if (FAutoSize <> aValue) then
- begin
- FAutoSize := aValue;
- AdjustBounds;
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK2}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetNumChars(aValue: integer);
- begin
- if (FNumChars <> aValue) then
- begin
- FNumChars := aValue;
- AdjustBounds;
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK3}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetCharSpace(aValue: integer);
- begin
- if (FCharSpace <> aValue) and (aValue >= 0) then
- begin
- FCharSpace := aValue;
- AdjustBounds;
- end;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.SetSpeed(aValue: integer);
- begin
- if (FSpeed <> aValue) then
- begin
- FSpeed := aValue;
- if (FTimer <> nil) then FTimer.Interval := FSpeed;
- end;
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- procedure TMMBitmapLabel.CMTextChanged(var Message: TMessage);
- begin
- if AutoSize then
- AdjustBounds
- else
- DrawLabel;
- if assigned(FOnChange) then FOnChange(Self);
- end;
- {-- TMMBitmapLabel ------------------------------------------------------------}
- function TMMBitmapLabel.GetCharMapping(ch: Char): integer;
- begin
- Result := RC_CHARSPERROW*RC_CHARROWS-1;
- if (Ord(ch) >= Ord('A')) and (Ord(ch) <= Ord('Z')) then
- begin
- Result := Ord(ch)-Ord('A');
- end
- else
- if (Ord(ch) >= Ord('0')) and (Ord(ch) <= Ord('9')) then
- begin
- Result := RC_CHARSPERROW + (Ord(ch)-Ord('0'));
- end
- else case ch of
- '"': Result := 26; // "
- '@': Result := 27; // @
- '.': Result := RC_CHARSPERROW+11; // .
- ':': Result := RC_CHARSPERROW+12; // :
- '(': Result := RC_CHARSPERROW+13; // (
- ')': Result := RC_CHARSPERROW+14; // )
- '-': Result := RC_CHARSPERROW+15; // -
- '''': Result := RC_CHARSPERROW+16; // '
- '!': Result := RC_CHARSPERROW+17; // !
- '_': Result := RC_CHARSPERROW+18; // _
- '+': Result := RC_CHARSPERROW+19; // +
- '': Result := RC_CHARSPERROW+20; //
- '/': Result := RC_CHARSPERROW+21; // /
- '[': Result := RC_CHARSPERROW+22; // [
- ']': Result := RC_CHARSPERROW+23; // ]
- '^': Result := RC_CHARSPERROW+24; // ^
- '&': Result := RC_CHARSPERROW+25; // &
- '%': Result := RC_CHARSPERROW+26; // %
- ',': Result := RC_CHARSPERROW+27; // ,
- '=': Result := RC_CHARSPERROW+28; // =
- '$': Result := RC_CHARSPERROW+29; // $
- '#': Result := RC_CHARSPERROW+30; // #
- '