MMPanel.pas
上传用户:hylc_2004
上传日期:2014-01-23
资源大小:46800k
文件大小:69k
- {========================================================================}
- {= (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: 13.11.98 - 16:43:33 $ =}
- {========================================================================}
- unit MMPanel;
- {$I COMPILER.INC}
- {$DEFINE FLOATCALC}
- interface
- uses
- {$IFDEF WIN32}
- Windows,
- {$ELSE}
- WinTypes,
- WinProcs,
- {$ENDIF}
- SysUtils,
- Messages,
- Classes,
- Graphics,
- Controls,
- Forms,
- Dialogs,
- ExtCtrls,
- Menus,
- MMObj,
- MMUtils,
- MMString,
- MMMath,
- MMMulDiv,
- MMMrkLst;
- type
- {-- TMMPanel ---------------------------------------------------------}
- TMMPanel = class(TMMCustomPanel)
- published
- property OnClick;
- property OnDblClick;
- property OnDragDrop;
- property OnDragOver;
- property OnEndDrag;
- property OnEnter;
- property OnExit;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnResize;
- {$IFDEF WIN32}
- property OnStartDrag;
- {$ENDIF}
- property Align;
- property Alignment;
- property Bevel;
- property DragCursor;
- property DragMode;
- property Enabled;
- property Caption;
- property Color;
- property Ctl3D;
- property Font;
- property ParentColor;
- property ParentCtl3D;
- property ParentFont;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property TabOrder;
- property TabStop;
- property Visible;
- end;
- {-- TMMBorder --------------------------------------------------------}
- TMMBorder = class(TMMGraphicControl)
- public
- constructor Create(AOwner: TComponent); override;
- published
- property OnClick;
- property OnDblClick;
- property OnDragDrop;
- property OnDragOver;
- property OnEndDrag;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property Align;
- property Bevel;
- property DragCursor;
- property DragMode;
- property Enabled;
- property Color;
- property ParentColor;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property Transparent;
- property Visible;
- property Width default 185;
- property Height default 41;
- end;
- type
- TMarkerShift = (mkNone, mkLocator, mkMarkerA, mkMarkerB, mkMarkerAB, mkMarkerBA,mkListMarker);
- TMarkerChangeEvent = procedure(Sender: TObject; var Value: Longint) of Object;
- TMarkersChangeEvent = procedure(Sender: TObject; Shift: TMarkerShift; var ValueA, ValueB: Longint) of Object;
- TRangeChangeEvent = procedure(Sender: TObject; Min, Max: Longint) of Object;
- {-- TMMCustomMarkerPanel --------------------------------------------}
- TMMCustomMarkerPanel = class(TMMCustomPanel)
- private
- FMarkerList : TMMMarkerList;
- FCurMarker : integer;
- FShowHints : Boolean;
- FCanUpdate : Boolean;
- FAutoScroll : Boolean;
- FMarkerShift : TMarkerShift; { which mouse action }
- FGridWidthX : Float;
- FGridWidthY : Float;
- FSnapToGrid : Boolean;
- FHelpLocator : Longint;
- FLastHelpLoc : integer;
- FLocator : Longint;
- FLastLoc : integer;
- FMarkerA : Longint;
- FLastMarkA : integer;
- FMarkerB : Longint;
- FLastMarkB : integer;
- FHelpLocColor : TColor;
- FLocColor : TColor;
- FMarkAColor : TColor;
- FMarkBColor : TColor;
- FGridColor : TColor;
- FDrawSolid : Boolean;
- FDrawGriff : Boolean;
- FUseHelpLocator: Boolean;
- FUseLocator : Boolean;
- FUseMarkers : Boolean;
- FCorralLocator : Boolean;
- FRangeMinX : Longint;
- FRangeMaxX : Longint;
- FRangeMinY : Longint;
- FRangeMaxY : Longint;
- FBaseY : Longint;
- FDispMinX : Longint;
- FDispMaxX : Longint;
- FDispMinY : Longint;
- FDispMaxY : Longint;
- FDefaultHint : string;
- FLocked : Boolean;
- FLButtonDown : Boolean;
- FRButtonDown : Boolean;
- FLocatorMap : TBitmap;
- FMarkerAMap : TBitmap;
- FMarkerBMap : TBitmap;
- FSnapRange : integer;
- FDrawGridX : Boolean;
- FDrawGridY : Boolean;
- FButton : TMouseButton;
- FDragging : Boolean;
- FOnTrackBegin : TNotifyEvent; { Mausaction started }
- FOnTrack : TNotifyEvent; { Mausaction }
- FOnTrackEnd : TNotifyEvent; { Mausaction stopped }
- FOnHelpLocatorChanged: TMarkerChangeEvent; { help Locator changed }
- FOnLocatorChanged: TMarkerChangeEvent; { Locator changed }
- FOnMarkerAChanged: TMarkerChangeEvent; { MarkerA changed }
- FOnMarkerBChanged: TMarkerChangeEvent; { MarkerB changed }
- FOnMarkersChanged: TMarkersChangeEvent; { both Markers changed }
- FOnRangeChanged : TRangeChangeEvent; { Range changed }
- procedure AdjustBitmaps;
- procedure SetHelpLocator(aValue: Longint);
- procedure SetLocator(aValue: Longint);
- procedure SetMarkerA(aValue: Longint);
- procedure SetMarkerB(aValue: Longint);
- procedure SetUseHelpLocator(aValue: Boolean);
- procedure SetUseLocator(aValue: Boolean);
- procedure SetUseMarkers(aValue: Boolean);
- procedure SetColors(index: integer; aValue: TColor);
- procedure SetDrawSolid(aValue: Boolean);
- procedure SetDrawGriff(aValue : Boolean);
- procedure SetRangeMinX(aValue: Longint);
- procedure SetRangeMaxX(aValue: Longint);
- procedure SetRangeMinY(aValue: Longint);
- procedure SetRangeMaxY(aValue: Longint);
- procedure SetBaseY(aValue: Longint);
- procedure SetDispMinX(aValue: Longint);
- procedure SetDispMaxX(aValue: Longint);
- procedure SetDispMinY(aValue: Longint);
- procedure SetDispMaxY(aValue: Longint);
- procedure SetDefaultHint(aValue: String);
- procedure SetMarkerList(aList: TMMMarkerList);
- function MouseAction(Button: TMouseButton; X: integer): TMarkerShift;
- procedure DrawHelpLocator(aCanvas: TCanvas; var LastLoc: integer);
- procedure DrawLocator(aCanvas: TCanvas; var LastLoc: integer);
- procedure DrawMarkerA(aCanvas: TCanvas; var LastLoc: integer);
- procedure DrawMarkerB(aCanvas: TCanvas; var LastLoc: integer);
- procedure DrawMarkerGriff(aCanvas: TCanvas; Loc,Mode: integer);
- procedure DrawAsSolid(aCanvas: TCanvas; MemDC: HDC; Mode,Loc: integer;
- var LastLoc: integer; Doted: Boolean; aColor: TColor);
- procedure DrawAsXOR(aCanvas: TCanvas; Mode,Loc: integer;
- var LastLoc: integer; Doted: Boolean; aColor: TColor);
- procedure WMLButtonDown(var Message: TWMLButtonDown); message WM_LBUTTONDOWN;
- procedure WMLButtonUp(var Message: TWMLButtonUp); message WM_LBUTTONUP;
- procedure WMRButtonDown(var Message: TWMRButtonDown); message WM_RBUTTONDOWN;
- procedure WMRButtonUp(var Message: TWMRButtonUp); message WM_RBUTTONUP;
- procedure WMCancelMode(var Message: TWMCancelMode); message WM_CANCELMODE;
- procedure CMShowHintChanged(var Message: TMessage); message CM_SHOWHINTCHANGED;
- procedure CMCursorChanged(var Message: TMessage); message CM_CURSORCHANGED;
- protected
- FOriginalCursor: TCursor;
- procedure Paint; override;
- procedure TrackBegin; dynamic;
- procedure Track; dynamic;
- procedure TrackEnd; dynamic;
- procedure HelpLocatorChanged(Value: Longint); dynamic;
- procedure LocatorChanged(Value: Longint); dynamic;
- procedure MarkerAChanged(Value: Longint); dynamic;
- procedure MarkerBChanged(Value: Longint); dynamic;
- procedure MarkersChanged(Shift: TMarkerShift; ValueA, ValueB: Longint); dynamic;
- procedure RangeChanged; dynamic;
- procedure CheckRange(var lMin, lMax: Longint; MinRange,MaxRange,MinDistance: Longint); virtual;
- function AdjustVisibleRange(Value: Longint): Boolean; virtual;
- procedure VLineDoted(aCanvas:TCanvas;x,y1,y2:integer;Clr:TColorRef); virtual;
- procedure HLineDoted(aCanvas:TCanvas;x1,x2,y:integer;Clr:TColorRef); virtual;
- procedure DrawGridsX(aCanvas: TCanvas; min,max: Longint);virtual;
- procedure DrawGridsY(aCanvas: TCanvas; min,max: Longint);virtual;
- procedure DrawListMarkers(aCanvas: TCanvas);
- procedure DrawAllMarkers(aCanvas: TCanvas);
- procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: integer); override;
- procedure MouseMove(Shift: TShiftState; X, Y: integer); override;
- procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
- X, Y: integer); override;
- procedure SetGridWidthX(aValue: Float); virtual;
- procedure SetDrawGridX(aValue: Boolean); virtual;
- procedure SetGridWidthY(aValue: Float); virtual;
- procedure SetDrawGridY(aValue: Boolean); virtual;
- function GetHintText(aPos: TPoint): string; virtual;
- function GetMouseCursor(aPos: TPoint): TCursor; virtual;
- public
- constructor Create(AOwner: TComponent); override;
- destructor Destroy; override;
- procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override;
- function X_ToPixelNoLimit(X_Value: longint): Longint; virtual;
- function X_ToPixel(X_Value: longint): integer; virtual;
- function PixelTo_X(X: integer): Longint; virtual;
- function Y_ToPixelNoLimit(Y_Value: Longint): Longint; virtual;
- function Y_ToPixel(Y_Value: Longint): integer; virtual;
- function PixelTo_Y(Y: integer): Longint; virtual;
- function FindListMarker(X: integer): integer;
- function IsAnyMarker(X: integer): Boolean;
- function IsLocator(X: integer): Boolean;
- function IsMarkerA(X: integer): Boolean;
- function IsMarkerB(X: integer): Boolean;
- function IsListMarker(X: integer): Boolean;
- function IsGridX(X: integer; var Value: Longint): Boolean; virtual;
- function IsGridY(Y: integer; var Value: Longint): Boolean; virtual;
- procedure SetMinMax(Min, Max: Longint); virtual;
- procedure SetMinMaxY(Min, Max: Longint); virtual;
- procedure SetRangeAll(MinX, MaxX, MinY, MaxY, YBase: Longint); virtual;
- procedure SetDispAll(MinX, MaxX, MinY, MaxY: Longint); virtual;
- property MouseCapture;
- property Locked: Boolean read FLocked write FLocked;
- protected
- property OnTrackBegin: TNotifyEvent read FOnTrackBegin write FOnTrackBegin;
- property OnTrack: TNotifyEvent read FOnTrack write FOnTrack;
- property OnTrackEnd: TNotifyEvent read FOnTrackEnd write FOnTrackEnd;
- property OnHelpLocatorChanged: TMarkerChangeEvent read FOnHelpLocatorChanged write FOnHelpLocatorChanged;
- property OnLocatorChanged: TMarkerChangeEvent read FOnLocatorChanged write FOnLocatorChanged;
- property OnMarkerAChanged: TMarkerChangeEvent read FOnMarkerAChanged write FOnMarkerAChanged;
- property OnMarkerBChanged: TMarkerChangeEvent read FOnMarkerBChanged write FOnMarkerBChanged;
- property OnMarkersChanged: TMarkersChangeEvent read FOnMarkersChanged write FOnMarkersChanged;
- property OnRangeChanged: TRangeChangeEvent read FOnRangeChanged write FOnRangeChanged;
- property AutoScroll: Boolean read FAutoScroll write FAutoScroll default True;
- property UseHelpLocator: Boolean read FUseHelpLocator write SetUseHelpLocator default True;
- property UseLocator: Boolean read FUseLocator write SetUseLocator default True;
- property UseMarkers: Boolean read FUseMarkers write SetUseMarkers default False;
- property CorralLocator: Boolean read FCorralLocator write FCorralLocator default True;
- property HelpLocator: Longint read FHelpLocator write SetHelpLocator default -1;
- property Locator: Longint read FLocator write SetLocator default -1;
- property MarkerA: Longint read FMarkerA write SetMarkerA default -1;
- property MarkerB: Longint read FMarkerB write SetMarkerB default -1;
- property HelpLocatorColor : TColor index 0 read FHelpLocColor write SetColors default clSilver;
- property LocatorColor : TColor index 1 read FLocColor write SetColors default clLime;
- property MarkerAColor : TColor index 2 read FMarkAColor write SetColors default clRed;
- property MarkerBColor : TColor index 3 read FMarkBColor write SetColors default clRed;
- property GridColor: TColor index 4 read FGridColor write SetColors default clGray;
- property DrawSolid: Boolean read FDrawSolid write SetDrawSolid default False;
- property DrawGriff: Boolean read FDrawGriff write SetDrawGriff default False;
- property DrawGridX: Boolean read FDrawGridX write SetDrawGridX default False;
- property DrawGridY: Boolean read FDrawGridY write SetDrawGridY default False;
- property GridWidthX: Float read FGridWidthX write SetGridWidthX;
- property GridWidthY: Float read FGridWidthY write SetGridWidthY;
- property SnapToGrid: Boolean read FSnapToGrid write FSnapToGrid default False;
- property SnapRange: integer read FSnapRange write FSnapRange default 3;
- property RangeMinX: Longint read FRangeMinX write SetRangeMinX default 0;
- property RangeMaxX: Longint read FRangeMaxX write SetRangeMaxX default 1000;
- property RangeMinY: Longint read FRangeMinY write SetRangeMinY default 0;
- property RangeMaxY: Longint read FRangeMaxY write SetRangeMaxY default 1000;
- property BaseY: Longint read FBaseY write SetBaseY default 500;
- property DispMinX: Longint read FDispMinX write SetDispMinX default 0;
- property DispMaxX: Longint read FDispMaxX write SetDispMaxX default 1000;
- property DispMinY: Longint read FDispMinY write SetDispMinY default 0;
- property DispMaxY: Longint read FDispMaxY write SetDispMaxY default 1000;
- property MarkerList: TMMMarkerList read FMarkerList write SetMarkerList;
- property DefaultHint: string read FDefaultHint write SetDefaultHint;
- end;
- {-- TMMMarkerPanel --------------------------------------------------}
- TMMMarkerPanel = class(TMMCustomMarkerPanel)
- public
- property MarkerList;
- published
- property OnClick;
- property OnDblClick;
- property OnDragDrop;
- property OnDragOver;
- property OnEndDrag;
- property OnEnter;
- property OnExit;
- property OnMouseDown;
- property OnMouseMove;
- property OnMouseUp;
- property OnResize;
- {$IFDEF WIN32}
- property OnStartDrag;
- {$ENDIF}
- property OnTrackBegin;
- property OnTrack;
- property OnTrackEnd;
- property OnHelpLocatorChanged;
- property OnLocatorChanged;
- property OnMarkerAChanged;
- property OnMarkerBChanged;
- property OnMarkersChanged;
- property OnRangeChanged;
- property Align;
- property Alignment;
- property Bevel;
- property DragCursor;
- property DragMode;
- property Enabled;
- property Color;
- property Ctl3D;
- property Font;
- property ParentFont;
- property ParentColor;
- property ParentCtl3D;
- property ParentShowHint;
- property PopupMenu;
- property ShowHint;
- property TabOrder;
- property TabStop;
- property Visible;
- property AutoScroll;
- property CorralLocator;
- property UseHelpLocator;
- property UseLocator;
- property UseMarkers;
- property HelpLocator;
- property Locator;
- property GridWidthX;
- property GridWidthY;
- property SnapToGrid;
- property SnapRange;
- property MarkerA;
- property MarkerB;
- property LocatorColor;
- property MarkerAColor;
- property MarkerBColor;
- property GridColor;
- property DrawSolid;
- property DrawGriff;
- property DrawGridX;
- property DrawGridY;
- property RangeMinX;
- property RangeMaxX;
- property RangeMinY;
- property RangeMaxY;
- property BaseY;
- property DispMinX;
- property DispMaxX;
- property DispMinY;
- property DispMaxY;
- property DefaultHint;
- end;
- implementation
- const
- GriffWidth = 10;
- ButtonDown : Boolean = False;
- {== TMMBorder ============================================================}
- constructor TMMBorder.Create(aOwner: TComponent);
- begin
- inherited Create(aOwner);
- Width := 185;
- Height := 41;
- ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
- if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
- end;
- {== TMMCustomMarkerPanel ================================================}
- constructor TMMCustomMarkerPanel.Create(AOwner: TComponent);
- begin
- inherited Create(AOwner);
- ControlStyle := ControlStyle - [csSetCaption,csAcceptsControls];
- FMarkerList := nil;
- FMarkerAMap := nil;
- FMarkerBMap := nil;
- FLocatorMap := nil;
- FShowHints := ShowHint;
- FOriginalCursor:= Cursor;
- FCanUpdate := True;
- FAutoScroll := True;
- FMarkerShift := mkNone;
- FUseHelpLocator:= True;
- FUseLocator := False;
- FUseMarkers := False;
- FCorralLocator := True;
- FRangeMinX := 0;
- FRangeMaxX := 1000;
- FRangeMinY := 0;
- FRangeMaxY := 1000;
- FBaseY := 500;
- FDispMinX := 0;
- FDispMaxX := 1000;
- FDispMinY := 0;
- FDispMaxY := 1000;
- FGridWidthX := 100;
- FGridWidthY := 100;
- FSnapToGrid := False;
- FSnapRange := 3;
- FHelpLocator := -1;
- FLastHelpLoc := -1;
- FHelpLocColor := clSilver;
- FLocator := -1;
- FLastLoc := -1;
- FLocColor := clLime;
- FMarkerA := -1;
- FLastMarkA := -1;
- FMarkAColor := clRed;
- FMarkerB := -1;
- FLastMarkB := -1;
- FMarkBColor := clRed;
- FGridColor := clGray;
- FDrawSolid := False;
- FDrawGriff := False;
- FDrawGridX := False;
- FDrawGridY := False;
- FDragging := False;
- UseLocator := True;
- FLocked := False;
- FDefaultHint := '';
- ErrorCode := ComponentRegistered(InitCode, Self, ClassName);
- if (ErrorCode <> 0) then RegisterFailed(InitCode, Self , ClassName);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- destructor TMMCustomMarkerPanel.Destroy;
- begin
- if assigned(FLocatorMap) then FLocatorMap.Free;
- if assigned(FMarkerAMap) then FMarkerAMap.Free;
- if assigned(FMarkerBMap) then FMarkerBMap.Free;
- FMarkerList := nil;
- inherited Destroy;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetMarkerList(aList: TMMMarkerList);
- begin
- FMarkerList := aList;
- Invalidate;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetRangeMinX(aValue: Longint);
- begin
- SetRangeAll(aValue, FRangeMaxX, FRangeMinY, FRangeMaxY, FBaseY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetRangeMaxX(aValue: Longint);
- begin
- SetRangeAll(FRangeMinX, aValue, FRangeMinY, FRangeMaxY, FBaseY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetRangeMinY(aValue: Longint);
- begin
- SetRangeAll(FRangeMinX, FRangeMaxX, aValue, FRangeMaxY, FBaseY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetRangeMaxY(aValue: Longint);
- begin
- SetRangeAll(FRangeMinX, FRangeMaxX, FRangeMinY, aValue, FBaseY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetBaseY(aValue: Longint);
- begin
- SetRangeAll(FRangeMinX, FRangeMaxX, FRangeMinY, FRangeMaxY, aValue);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetRangeAll(MinX, MaxX, MinY, MaxY, YBase: Longint);
- begin
- if (MinX > MaxX) then SwapLong(MinX, MaxX);
- if (MinY > MaxY) then SwapLong(MinY, MaxY);
- if (MinX <> FRangeMinX) or (MaxX <> FRangeMaxX) or
- (MinY <> FRangeMinY) or (MaxY <> FRangeMaxY) or
- (YBase <> FBaseY) then
- begin
- FRangeMinX := MinX;
- FRangeMaxX := Max(MaxX,MinX+1);
- FRangeMinY := MinY;
- FRangeMaxY := Max(MaxY,MinY+1);
- FBaseY := Limit(YBase, FRangeMinY, FRangeMaxY);
- SetDispAll(Limit(FDispMinX, FRangeMinX, FRangeMaxX),
- Max(Limit(FDispMaxX, FRangeMinX, FRangeMaxX),FDispMinX+1),
- Limit(FDispMinY, FRangeMinY, FRangeMaxY),
- Max(Limit(FDispMaxY, FRangeMinY, FRangeMaxY),FDispMinY+1));
- Invalidate;
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK1}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDispMinX(aValue: Longint);
- begin
- SetDispAll(aValue,FDispMaxX, FDispMinY, FDispMaxY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDispMaxX(aValue: Longint);
- begin
- SetDispAll(FDispMinX,aValue,FDispMinY,FDispMaxY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDispMinY(aValue: Longint);
- begin
- SetDispAll(FDispMinX,FDispMaxX, aValue, FDispMaxY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDispMaxY(aValue: Longint);
- begin
- SetDispAll(FDispMinX,FDispMaxX,FDispMinY,aValue);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetMinMax(Min, Max: Longint);
- begin
- SetDispAll(Min,Max,FDispMinY,FDispMaxY);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetMinMaxY(Min, Max: Longint);
- begin
- SetDispAll(FDispMinX,FDispMaxX,Min,Max);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDispAll(MinX, MaxX, MinY, MaxY: Longint);
- begin
- if (MinX > MaxX) then SwapLong(MinX, MaxX);
- if (MinY > MaxY) then SwapLong(MinY, MaxY);
- if (MinX <> FDispMinX) or (MaxX <> FDispMaxX) or
- (MinY <> FDispMinY) or (MaxY <> FDispMaxY) then
- begin
- CheckRange(MinX,MaxX,FRangeMinX,FRAngeMaxX,Width-2*BevelExtend);
- FDispMinX := MinX;
- FDispMaxX := MaxX;
- CheckRange(MinY,MaxY,FRangeMinY,FRangeMaxY,Height-2*BevelExtend);
- FDispMinY := MinY;
- FDispMaxY := MaxY;
- RangeChanged;
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK2}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.AdjustVisibleRange(Value: Longint): Boolean;
- var
- min, max: Longint;
- pixel: integer;
- aPos: TPoint;
- begin
- Result := False;
- { pa遲 den sichtbaren Bereich aller Elemente an (scrolling) }
- if (Value >= RangeMinX) then
- begin
- pixel := X_ToPixel(Value);
- if (pixel > Width-BevelExtend-5) and (DispMaxX < RangeMaxX) then
- begin
- max := limit(Value+(DispMaxX-DispMinX)div 2,RangeMinX,RangeMaxX);
- min := max-(DispMaxX-DispMinX);
- SetMinMax(min, max);
- Update;
- GetCursorPos(aPos);
- aPos.X := ClientToScreen(Point(X_ToPixel(Value),0)).X;
- SetCursorPos(aPos.X,aPos.Y);
- Result := True;
- end
- else if (pixel < BevelExtend+5) and (DispMinX > RangeMinX) then
- begin
- min := limit(Value-(DispMaxX-DispMinX)div 2,RangeMinX,RangeMaxX);
- max := min+(DispMaxX-DispMinX);
- SetMinMax(min, max);
- Update;
- GetCursorPos(aPos);
- aPos.X := ClientToScreen(Point(X_ToPixel(Value),0)).X;
- SetCursorPos(aPos.X,aPos.Y);
- Result := True
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.CheckRange(var lMin,lMax: Longint; MinRange,MaxRange,MinDistance: Longint);
- var
- Diff: Longint;
- begin
- if (lMax < lMin) then SwapLong(lMax,lMin);
- lMax := Max(lMax, lMin+MinDistance);
- if (lMax > MaxRange) then
- begin
- Diff := lMax-lMin;
- lMax := MaxRange;
- lMin := Max(lMax-Diff,MinRange);
- end
- else if (lMin < MinRange) then
- begin
- Diff := lMax-lMin;
- lMin := MinRange;
- lMax := Min(lMin+Diff,MaxRange);
- end;
- {$IFDEF WIN32}
- {$IFDEF TRIAL}
- {$DEFINE _HACK3}
- {$I MMHACK.INC}
- {$ENDIF}
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.X_ToPixelNoLimit(X_Value: Longint): Longint;
- begin
- {$IFDEF FLOATCALC}
- Result := BevelExtend+Round((X_Value-DispMinX)/(DispMaxX-DispMinX)*((Width-2*BevelExtend)-1));
- {$ELSE}
- Result := BevelExtend+MulDiv32(X_Value-DispMinX,(Width-2*BevelExtend)-1,DispMaxX-DispMinX);
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.X_ToPixel(X_Value: Longint): integer;
- begin
- Result := Limit(X_ToPixelNoLimit(X_Value),-16384,16384);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.PixelTo_X(X: integer): Longint;
- begin
- {$IFDEF FLOATCALC}
- Result := Round((X-BevelExtend)/((Width-2*BevelExtend)-1)*(DispMaxX-DispMinX))+DispMinX;
- {$ELSE}
- Result := MulDiv32(X-BevelExtend,DispMaxX-DispMinX,(Width-2*BevelExtend)-1)+DispMinX;
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.Y_ToPixelNoLimit(Y_Value: Longint): Longint;
- begin
- {$IFDEF FLOATCALC}
- Result := ((Height-BevelExtend)-1)-Round((Y_Value-DispMinY)/(DispMaxY-DispMinY)*((Height-2*BevelExtend)-1));
- {$ELSE}
- Result := ((Height-BevelExtend)-1)-MulDiv32(Y_Value-DispMinY,(Height-2*BevelExtend)-1,DispMaxY-DispMinY);
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.Y_ToPixel(Y_Value: Longint): integer;
- begin
- Result := Limit(Y_ToPixelNoLimit(Y_Value),-16384,16384);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.PixelTo_Y(Y: integer): Longint;
- begin
- {$IFDEF FLOATCALC}
- Result := Round((((Height-BevelExtend)-1)-Y)/((Height-2*BevelExtend)-1)*(DispMaxY-DispMinY))+DispMinY;
- {$ELSE}
- Result := MulDiv32(((Height-BevelExtend)-1)-Y,DispMaxY-DispMinY,(Height-2*BevelExtend)-1)+DispMinY;
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetColors(Index: integer; aValue: TColor);
- begin
- case Index of
- 0: if FHelpLocColor = aValue then exit else FHelpLocColor := aValue;
- 1: if FLocColor = aValue then exit else FLocColor := aValue;
- 2: if FMarkAColor = aValue then exit else FMarkAColor := aValue;
- 3: if FMarkBColor = aValue then exit else FMarkBColor := aValue;
- 4: if FGridColor = aValue then exit else FGridColor := aValue;
- end;
- Perform(CM_COLORCHANGED, 0, 0);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetGridWidthX(aValue: Float);
- begin
- if (aValue <> FGridWidthX) then
- begin
- if (aValue <= 0) then aValue := 1;
- FGridWidthX := aValue;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetGridWidthY(aValue: Float);
- begin
- if (aValue <> FGridWidthY) then
- begin
- if (aValue <= 0) then aValue := 1;
- FGridWidthY := aValue;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetHelpLocator(aValue: Longint);
- begin
- if (aValue <> FHelpLocator) then
- begin
- FHelpLocator := aValue;
- if (X_ToPixel(FHelpLocator) <> FLastHelpLoc) then
- begin
- DrawHelpLocator(Canvas, FLastHelpLoc);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetLocator(aValue: Longint);
- begin
- if (aValue <> FLocator) then
- begin
- if FUseMarkers and FCorralLocator then
- begin
- if (FMarkerA >= 0) then aValue := Max(aValue,FMarkerA);
- if (FMarkerB >= 0) then aValue := Min(aValue,FMarkerB);
- end;
- FLocator := aValue;
- if (X_ToPixel(FLocator) <> FLastLoc) then
- begin
- DrawLocator(Canvas, FLastLoc);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetMarkerA(aValue: Longint);
- begin
- if (aValue <> FMarkerA) then
- begin
- if FUseLocator and FCorralLocator and (FLocator > 0) then
- aValue := Min(aValue,FLocator-1)
- else if (FMarkerB > 0) then
- aValue := Min(aValue,FMarkerB-1);
- FMarkerA := aValue;
- if (X_ToPixel(FMarkerA) <> FLastMarkA) then
- begin
- DrawMarkerA(Canvas, FLastMarkA);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetMarkerB(aValue: Longint);
- begin
- if (aValue <> FMarkerB) then
- begin
- if FUseLocator and FCorralLocator and (FLocator >= 0) then
- aValue := Max(aValue,FLocator+1)
- else if (FMarkerA >= 0) then
- aValue := Max(aValue,FMarkerA+1);
- FMarkerB := aValue;
- if (X_ToPixel(FMarkerB) <> FLastMarkB) then
- begin
- DrawMarkerB(Canvas, FLastMarkB);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawListMarkers(aCanvas: TCanvas);
- var
- i,i2,von,bis: integer;
- Loc,OldLoc,Mode: integer;
- begin
- if (FMarkerList <> nil) and (FMarkerList.Count > 0) then
- with FMarkerList do
- begin
- von := LocateMarker(DispMinX-1)-2; { first marker to draw }
- bis := LocateMarker(DispMaxX); { last marker to draw }
- for i := von to bis do
- if inRange(i,0,Count-1) then
- begin
- if Markers[i]^.Visible then
- begin
- OldLoc := -1;
- Loc:= X_ToPixel(Markers[i]^.Offset);
- i2 := FindConnectedMarker(i);
- if (i2 >= 0) then
- begin
- if Markers[i]^.Offset < Markers[i2]^.Offset then
- Mode := 5
- else
- Mode := 6;
- end
- else Mode := 4;
- DrawAsSolid(aCanvas, 0, Mode, Loc, OldLoc, True, Markers[i]^.Color);
- end;
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawAllMarkers(aCanvas: TCanvas);
- begin
- DrawListMarkers(aCanvas);
- if FUseMarkers then
- begin
- FLastMarkA := -1;
- DrawMarkerA(aCanvas, FLastMarkA);
- FLastMarkB := -1;
- DrawMarkerB(aCanvas, FLastMarkB);
- end;
- if FUseLocator then
- begin
- FLastLoc := -1;
- DrawLocator(aCanvas, FLastLoc);
- end;
- if FUseHelpLocator then
- begin
- FLastHelpLoc := -1;
- DrawHelpLocator(aCanvas, FLastHelpLoc);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawHelpLocator(aCanvas: TCanvas; var LastLoc: integer);
- var
- Loc: integer;
- begin
- if FUseHelpLocator then
- begin
- if (FHelpLocator >= 0) then
- Loc := X_ToPixel(FHelpLocator)
- else
- Loc := FHelpLocator;
- DrawAsXOR(aCanvas, 3, Loc, LastLoc, True, FHelpLocColor);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawLocator(aCanvas: TCanvas; var LastLoc: integer);
- var
- Loc: integer;
- begin
- if FUseLocator then
- begin
- if (FLocator >= 0) then
- Loc := X_ToPixel(FLocator)
- else
- Loc := FLocator;
- if FDrawSolid then
- DrawAsSolid(aCanvas, FLocatorMap.Canvas.Handle, 0, Loc, LastLoc, False, FLocColor)
- else
- DrawAsXOR(aCanvas, 0, Loc, LastLoc, False, FLocColor);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawMarkerA(aCanvas: TCanvas; var LastLoc: integer);
- var
- Loc: integer;
- begin
- if FUseMarkers then
- begin
- if (FMarkerA >= 0) then
- Loc := Min(X_ToPixel(FMarkerA),X_ToPixel(FMarkerB)-1)
- else
- Loc := FMarkerA;
- if FDrawSolid then
- DrawAsSolid(aCanvas,FMarkerAMap.Canvas.Handle, 1, Loc, LastLoc, False, FMarkAColor)
- else
- DrawAsXOR(aCanvas, 1, Loc, LastLoc, False, FMarkAColor);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawMarkerB(aCanvas: TCanvas; var LastLoc: integer);
- var
- Loc: integer;
- begin
- if FUseMarkers then
- begin
- if (FMarkerB >= 0) then
- Loc := Max(X_ToPixel(FMarkerA)+1,X_ToPixel(FMarkerB))
- else
- Loc := FMarkerB;
- if FDrawSolid then
- DrawAsSolid(aCanvas,FMarkerBMap.Canvas.Handle, 2, Loc, LastLoc, False, FMarkBColor)
- else
- DrawAsXOR(aCanvas, 2, Loc, LastLoc, False, FMarkBColor);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawMarkerGriff(aCanvas: TCanvas; Loc,Mode: integer);
- procedure SaveRectangle(X1,Y1,X2,Y2: integer);
- var
- i: integer;
- begin
- if Y2 < Y1 then SwapInt(Y1,Y2);
- with aCanvas do
- for i := 0 to (Y2-Y1)-1 do
- begin
- MoveTo(X1,Y1+i);
- LineTo(X2,Y1+i);
- end;
- end;
- begin
- with aCanvas do
- begin
- case Mode of
- 0: begin
- { draw Locator }
- MoveTo(Loc,BevelExtend+9);
- LineTo(Loc,Height);
- { draw griff }
- MoveTo(Loc-4,BevelExtend+5);
- LineTo(Loc+5,BevelExtend+5);
- MoveTo(Loc-3,BevelExtend+6);
- LineTo(Loc+4,BevelExtend+6);
- MoveTo(Loc-2,BevelExtend+7);
- LineTo(Loc+3,BevelExtend+7);
- MoveTo(Loc-1,BevelExtend+8);
- LineTo(Loc+2,BevelExtend+8);
- end;
- 1: begin
- { draw Marker A }
- MoveTo(Loc,BevelExtend+1);
- LineTo(Loc,Height);
- { draw griff }
- MoveTo(Loc+1,BevelExtend+2);
- LineTo(Loc+2,BevelExtend+2);
- MoveTo(Loc+1,BevelExtend+3);
- LineTo(Loc+3,BevelExtend+3);
- MoveTo(Loc+1,BevelExtend+4);
- LineTo(Loc+4,BevelExtend+4);
- MoveTo(Loc+1,BevelExtend+5);
- LineTo(Loc+5,BevelExtend+5);
- MoveTo(Loc+1,BevelExtend+6);
- LineTo(Loc+4,BevelExtend+6);
- MoveTo(Loc+1,BevelExtend+7);
- LineTo(Loc+3,BevelExtend+7);
- MoveTo(Loc+1,BevelExtend+8);
- LineTo(Loc+2,BevelExtend+8);
- end;
- 2: begin
- { draw Marker B }
- MoveTo(Loc,BevelExtend+1);
- LineTo(Loc,Height);
- { draw griff }
- MoveTo(Loc-1,BevelExtend+2);
- LineTo(Loc-2,BevelExtend+2);
- MoveTo(Loc-1,BevelExtend+3);
- LineTo(Loc-3,BevelExtend+3);
- MoveTo(Loc-1,BevelExtend+4);
- LineTo(Loc-4,BevelExtend+4);
- MoveTo(Loc-1,BevelExtend+5);
- LineTo(Loc-5,BevelExtend+5);
- MoveTo(Loc-1,BevelExtend+6);
- LineTo(Loc-4,BevelExtend+6);
- MoveTo(Loc-1,BevelExtend+7);
- LineTo(Loc-3,BevelExtend+7);
- MoveTo(Loc-1,BevelExtend+8);
- LineTo(Loc-2,BevelExtend+8);
- end;
- 3,4,5,6: begin
- { draw List-Marker }
- MoveTo(Loc,BevelExtend+9);
- LineTo(Loc,Height);
- { draw griff }
- SaveRectangle(Loc-3,BevelExtend+2,Loc+4,BevelExtend+7);
- MoveTo(Loc-2,BevelExtend+7);
- LineTo(Loc+3,BevelExtend+7);
- MoveTo(Loc-1,BevelExtend+8);
- LineTo(Loc+2,BevelExtend+8);
- case Mode of
- 4: begin
- Pen.Color := clBlack;
- MoveTo(Loc-1,BevelExtend+3);
- LineTo(Loc+2,BevelExtend+3);
- MoveTo(Loc,BevelExtend+4);
- LineTo(Loc,BevelExtend+7);
- end;
- 5: begin
- Pen.Color := clBlack;
- MoveTo(Loc-1,BevelExtend+3);
- LineTo(Loc+2,BevelExtend+3);
- MoveTo(Loc-1,BevelExtend+4);
- LineTo(Loc-1,BevelExtend+6);
- end;
- 6: begin
- Pen.Color := clBlack;
- MoveTo(Loc-1,BevelExtend+3);
- LineTo(Loc+2,BevelExtend+3);
- MoveTo(Loc+1,BevelExtend+4);
- LineTo(Loc+1,BevelExtend+6);
- end;
- end;
- end;
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawAsSolid(aCanvas: TCanvas; MemDC: HDC;
- Mode, Loc: integer;
- var LastLoc: integer; Doted: Boolean;
- aColor: TColor);
- var
- DC: HDC;
- begin
- if not (csDesigning in ComponentState) and not Visible then exit;
- {$IFDEF DELPHI3}
- aCanvas.Lock;
- try
- {$ENDIF}
- aCanvas.Pen.Width := 1;
- aCanvas.Pen.Color := aColor;
- if FDrawGriff then
- begin
- aCanvas.Brush.Color := aColor;
- aCanvas.Brush.Style := bsSolid;
- IntersectClipRect(aCanvas.Handle,BevelExtend,1,Width-BevelExtend,Height);
- { clear old griff }
- if (LastLoc <> -1) and (MemDC <> 0) then
- begin
- { draw saved bitmap }
- BitBlt(aCanvas.Handle, LastLoc-5, 0, GriffWidth, Height,
- MemDC, 0,0, SrcCopy);
- end;
- if inRange(Loc,BevelExtend,Width-BevelExtend-1) then
- begin
- { save background in bitmap and draw new griff }
- if (MemDC <> 0) then
- BitBlt(MemDC, 0, 0, GriffWidth, Height,
- aCanvas.Handle, Loc-5,0, SrcCopy);
- DrawMarkerGriff(aCanvas,Loc,Mode);
- LastLoc := Loc;
- end
- else LastLoc := -1;
- end
- else
- begin
- if Doted then
- begin
- aCanvas.Pen.Style := psDot;
- SetBkMode(aCanvas.Handle,TRANSPARENT);
- end;
- { Reduce calls to GetHandle }
- DC := aCanvas.Handle;
- { clear old locator }
- if (LastLoc <> -1) and (MemDC <> 0) then
- begin
- { restore background }
- BitBlt(DC, LastLoc, 0, 1, Height,
- MemDC, 0, 0, SrcCopy);
- end;
- if inRange(Loc,BevelExtend,Width-BevelExtend-1) then
- begin
- { save background and draw new locator }
- if (MemDC <> 0) then
- BitBlt(MemDC, 0, 0, 1, Height,
- DC, Loc,0, srcCopy);
- if Doted then
- begin
- VLineDoted(aCanvas,Loc,0,Height, ColorToRGB(aColor));
- end
- else
- begin
- MoveToEx(DC,Loc,0,nil);
- LineTo(DC,Loc,Height);
- end;
- LastLoc := Loc;
- end
- else LastLoc := -1;
- aCanvas.Pen.Style := psSolid;
- SetBkMode(aCanvas.Handle,OPAQUE);
- end;
- {$IFDEF DELPHI3}
- finally
- aCanvas.Unlock;
- end;
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawAsXOR(aCanvas: TCanvas; Mode, Loc: integer;
- var LastLoc: integer; Doted: Boolean;
- aColor: TColor);
- begin
- if not (csDesigning in ComponentState) and not Visible then exit;
- {$IFDEF DELPHI3}
- aCanvas.Lock;
- try
- {$ENDIF}
- with aCanvas do
- begin
- Pen.Width := 1;
- Pen.Mode := pmXor;
- Pen.Color := aColor;
- if FDrawGriff then
- begin
- IntersectClipRect(Canvas.Handle,BevelExtend,0,Width-BevelExtend,Height);
- { clear old griff }
- Brush.Color := aColor;
- Brush.Style := bsSolid;
- if LastLoc <> -1 then
- begin
- { delete old marker }
- DrawMarkerGriff(aCanvas,LastLoc,Mode);
- end;
- if inRange(Loc,BevelExtend,Width-BevelExtend-1) then
- begin
- { draw new marker }
- DrawMarkerGriff(aCanvas,Loc,Mode);
- LastLoc := Loc;
- end
- else LastLoc := -1;
- end
- else
- begin
- if Doted then
- begin
- Pen.Style := psDot;
- SetBkMode(Handle,TRANSPARENT);
- end;
- { alten Locator l鰏chen }
- if (LastLoc <> -1) then
- begin
- MoveTo(LastLoc, 0);
- LineTo(LastLoc, Height);
- end;
- if inRange(Loc,BevelExtend,Width-BevelExtend-1) then
- begin
- { neuen Locator zeicnen }
- MoveTo(Loc,0);
- LineTo(Loc,Height);
- LastLoc := Loc;
- end
- else LastLoc := -1;
- end;
- Pen.Mode := pmCopy;
- Pen.Style := psSolid;
- SetBkMode(Handle,OPAQUE);
- end;
- {$IFDEF DELPHI3}
- finally
- aCanvas.Unlock;
- end;
- {$ENDIF}
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.AdjustBitmaps;
- begin
- if FDrawSolid then
- begin
- if FDrawGriff then
- begin
- if FUseLocator then
- begin
- if not assigned(FLocatorMap) then FLocatorMap := TBitmap.Create;
- FLocatorMap.Width := GriffWidth;
- FLocatorMap.Height := Height;
- FLastLoc := -1;
- end;
- if FUseMarkers then
- begin
- if not assigned(FMarkerAMap) then FMarkerAMap := TBitmap.Create;
- if not assigned(FMarkerBMap) then FMarkerBMap := TBitmap.Create;
- FMarkerAMap.Width := GriffWidth;
- FMarkerBMap.Width := GriffWidth;
- FMarkerAMap.Height := Height;
- FMarkerBMap.Height := Height;
- FLastMarkA := -1;
- FLastMarkB := -1;
- end;
- end
- else
- begin
- if FUseLocator then
- begin
- if not assigned(FLocatorMap) then FLocatorMap := TBitmap.Create;
- FLocatorMap.Width := 1;
- FLocatorMap.Height := Height;
- FLastLoc := -1;
- end;
- if FUseMarkers then
- begin
- if not assigned(FMarkerAMap) then FMarkerAMap := TBitmap.Create;
- if not assigned(FMarkerBMap) then FMarkerBMap := TBitmap.Create;
- FMarkerAMap.Width := 1;
- FMarkerBMap.Width := 1;
- FMarkerAMap.Height := Height;
- FMarkerBMap.Height := Height;
- FLastMarkA := -1;
- FLastMarkB := -1;
- end;
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetBounds(aLeft, aTop, aWidth, aHeight: integer);
- var
- H: Integer;
- begin
- H := Height;
- inherited SetBounds(aLeft, aTop, aWidth, aHeight);
- if (H <> Height) and (Height > 0) then
- begin
- AdjustBitmaps;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDrawGriff(aValue: Boolean);
- begin
- if (aValue <> FDrawGriff) then
- begin
- FDrawGriff := aValue;
- AdjustBitmaps;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetUseHelpLocator(aValue: Boolean);
- begin
- if (aValue <> FUseHelpLocator) then
- begin
- FUseHelpLocator := aValue;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetUseLocator(aValue: Boolean);
- begin
- if (aValue <> FUseLocator) then
- begin
- if assigned(FLocatorMap) then
- begin
- FLocatorMap.Free;
- FLocatorMap := nil;
- end;
- FUseLocator := aValue;
- AdjustBitmaps;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetUseMarkers(aValue: Boolean);
- begin
- if (aValue <> FUseMarkers) then
- begin
- if assigned(FMarkerAMap) then
- begin
- FMarkerAMap.Free;
- FMarkerAMap := nil;
- end;
- if assigned(FMarkerBMap) then
- begin
- FMarkerBMap.Free;
- FMarkerBMap := nil;
- end;
- FUseMarkers := aValue;
- AdjustBitmaps;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDrawSolid(aValue : boolean);
- begin
- if aValue <> FDrawSolid then
- begin
- if assigned(FLocatorMap) then
- begin
- FLocatorMap.Free;
- FLocatorMap := nil;
- end;
- if assigned(FMarkerAMap) then
- begin
- FMarkerAMap.Free;
- FMarkerAMap := nil;
- end;
- if assigned(FMarkerBMap) then
- begin
- FMarkerBMap.Free;
- FMarkerBMap := nil;
- end;
- FDrawSolid := aValue;
- AdjustBitmaps;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDrawGridX(aValue: Boolean);
- begin
- if (aValue <> FDrawGridX) then
- begin
- FDrawGridX := aValue;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDrawGridY(aValue: Boolean);
- begin
- if (aValue <> FDrawGridY) then
- begin
- FDrawGridY := aValue;
- Invalidate;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.TrackBegin;
- begin
- if assigned(FOnTrackBegin) then
- FOnTrackBegin(self);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.Track;
- begin
- if assigned(FOnTrack) then
- FOnTrack(self);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.TrackEnd;
- begin
- if assigned(FOnTrackEnd) then
- FOnTrackEnd(self);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.RangeChanged;
- begin
- if not (csLoading in ComponentState) and assigned(FOnRangeChanged) then
- FOnRangeChanged(Self, FDispMinX, FDispMaxX);
- Invalidate;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.HelpLocatorChanged(Value: Longint);
- begin
- if FAutoScroll and (FMarkerShift = mkListMarker) then
- AdjustVisibleRange(Value);
- if assigned(FOnHelpLocatorChanged) then
- FOnHelpLocatorChanged(Self, Value);
- SetHelpLocator(Value);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.LocatorChanged(Value: Longint);
- begin
- if FAutoScroll then
- AdjustVisibleRange(Value);
- if assigned(FOnLocatorChanged) then
- FOnLocatorChanged(Self, Value);
- SetLocator(Value);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.MarkerAChanged(Value: Longint);
- begin
- if FAutoScroll then
- AdjustVisibleRange(Value);
- if assigned(FOnMarkerAChanged) then
- FOnMarkerAChanged(Self, Value);
- SetMarkerA(Value);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.MarkerBChanged(Value: Longint);
- begin
- if FAutoScroll then
- AdjustVisibleRange(Value);
- if assigned(FOnMarkerBChanged) then
- FOnMarkerBChanged(Self, Value);
- SetMarkerB(Value);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.MarkersChanged(Shift: TMarkerShift; ValueA, ValueB: Longint);
- begin
- case Shift of
- mkMarkerAB:
- begin
- if FAutoScroll then
- AdjustVisibleRange(ValueA);
- if assigned(FOnMarkersChanged) then
- FOnMarkersChanged(Self, Shift, ValueA, ValueB);
- SetMarkerB(ValueB);
- SetMarkerA(ValueA);
- end;
- mkMarkerBA:
- begin
- if FAutoScroll then
- AdjustVisibleRange(ValueB);
- if assigned(FOnMarkersChanged) then
- FOnMarkersChanged(Self, Shift, ValueA, ValueB);
- SetMarkerA(ValueA);
- SetMarkerB(ValueB);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsAnyMarker(X: integer): Boolean;
- begin
- Result := IsLocator(X) or IsMarkerA(X) or IsMarkerB(X) or IsListMarker(X);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsLocator(X: integer): Boolean;
- var
- x1: Longint;
- begin
- x1 := X_ToPixel(FLocator);
- Result := FUseLocator and (FLocator >= 0) and
- (X >= x1-SNAPRANGE) and
- (X <= x1+SNAPRANGE) and
- (X >= 0) and (X <= Width);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsMarkerA(X: integer): Boolean;
- var
- x1: Longint;
- begin
- x1 := X_ToPixel(FMarkerA);
- Result := FUseMarkers and (FMarkerA >= 0) and
- (X >= x1-SNAPRANGE-1) and
- (X <= x1+SNAPRANGE) and
- (X >= 0) and (X <= Width);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsMarkerB(X: integer): Boolean;
- var
- x1: Longint;
- begin
- x1 := X_ToPixel(FMarkerB);
- Result := FUseMarkers and (FMarkerB >= 0) and
- (X >= x1-SNAPRANGE) and
- (X <= x1+SNAPRANGE+1) and
- (X >= 0) and (X <= Width);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.FindListMarker(X: integer): integer;
- var
- i: integer;
- begin
- Result := -1;
- if (FMarkerList <> nil) and (FMarkerList.Count > 0) then
- with FMarkerList do
- begin
- i := LocateMarker(PixelTo_X(X));
- if (i < Count) and
- (X >= X_ToPixel(Markers[i]^.Offset)-SNAPRANGE) and
- (X <= X_ToPixel(Markers[i]^.Offset)+SNAPRANGE) and
- Markers[i]^.Visible then
- begin
- Result := i;
- end
- else if (i > 0) and
- (X >= X_ToPixel(Markers[i-1]^.Offset)-SNAPRANGE) and
- (X <= X_ToPixel(Markers[i-1]^.Offset)+SNAPRANGE) and
- Markers[i-1]^.Visible then
- begin
- Result := i-1;
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsListMarker(X: integer): Boolean;
- var
- index: integer;
- begin
- index := FindListMarker(X);
- Result := (index >= 0) and not FMarkerList.Markers[index]^.Fixed;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsGridX(X: integer; var Value: Longint): Boolean;
- var
- g: Longint;
- begin
- Value := PixelTo_X(X);
- if FSnapToGrid and inMinMax(Value,DispMinX,DispMaxX) then
- begin
- g := Trunc(Trunc(Value/FGridWidthX)*FGridwidthX);
- { left }
- if (X - X_ToPixel(g) <= SNAPRANGE) then
- begin
- Result := True;
- Value := g;
- exit;
- end;
- { right }
- g := Trunc((Trunc(Value/FGridWidthX)+1)*FGridwidthX);
- if (X_ToPixel(g)-X <= SNAPRANGE) then
- begin
- Result := True;
- Value := g;
- exit;
- end;
- end;
- Result := False;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.IsGridY(Y: integer; var Value: Longint): Boolean;
- var
- g: Longint;
- begin
- Value := PixelTo_Y(Y);
- if FSnapToGrid and inMinMax(Value,DispMinY,DispMaxY) then
- begin
- g := Trunc(Trunc(Value/FGridWidthY)*FGridWidthY);
- { top }
- if (Y_ToPixel(g)-Y <= SNAPRANGE) then
- begin
- Result := True;
- Value := g;
- exit;
- end;
- { bottom }
- g := Trunc((Trunc(Value/FGridWidthY)+1)*FGridwidthY);
- if (Y-Y_ToPixel(g) <= SNAPRANGE) then
- begin
- Result := True;
- Value := g;
- exit;
- end;
- end;
- Result := False;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.WMLButtonDown(var Message: TWMLButtonDown);
- begin
- ButtonDown := True;
- FLButtonDown := True;
- if not FRButtonDown then inherited;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.WMLButtonUp(var Message: TWMLButtonUp);
- begin
- ButtonDown := False;
- FLButtonDown := False;
- if not FRButtonDown then inherited;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.WMRButtonDown(var Message: TWMRButtonDown);
- begin
- ButtonDown := True;
- FRButtonDown := True;
- if not FLButtonDown then inherited;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.WMRButtonUp(var Message: TWMRButtonUp);
- begin
- ButtonDown := False;
- FRButtonDown := False;
- if not FLButtonDown then inherited;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.WMCancelMode(var Message: TWMCancelMode);
- var
- P: TPoint;
- begin
- if FLButtonDown or FRButtonDown then
- begin
- GetCursorPos(P);
- P := ClientToScreen(P);
- if FLButtonDown then
- Perform(WM_LBUTTONUP, 0, Longint(PointToSmallPoint(P)));
- if FRButtonDown then
- Perform(WM_RBUTTONUP, 0, Longint(PointToSmallPoint(P)));
- end;
- inherited;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.MouseAction(Button: TMouseButton; X: integer): TMarkerShift;
- begin
- Result := mkNone;
- if FUseLocator and (Button = mbLeft) and IsLocator(X) then
- begin
- Result := mkLocator;
- exit; { Locator }
- end;
- if FUseMarkers then
- begin
- if IsMarkerA(X) then
- begin
- if (Button = mbLeft) then Result := mkMarkerA
- else Result := mkMarkerAB;
- exit;
- end;
- if IsMarkerB(X) then
- begin
- if (Button = mbLeft) then Result := mkMarkerB
- else Result := mkMarkerBA;
- exit;
- end;
- end;
- if (Button = mbLeft) and IsListMarker(X) then
- begin
- Result := mkListMarker;
- exit; { MarkerList }
- end;
- end;
- const
- inHandler: integer = 0; { verhinder Rekursion durch 2x WM_LBUTTONDOWN }
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.MouseDown(Button: TMouseButton; Shift: TShiftState;
- X, Y: integer);
- var
- P: TPoint;
- begin
- if not FDragging and not FLocked then
- begin
- FMarkerShift := MouseAction(Button, X);
- if (FMarkerShift <> mkNone) then
- begin
- if (Button=mbLeft)or((Button=mbRight)and(FMarkerShift<>mkLocator)) then
- begin
- if (FMarkerShift = mkListMarker) then
- FCurMarker := FindListMarker(X);
- MouseCapture := True;
- FButton := Button;
- FDragging := True;
- TrackBegin;
- exit;
- end;
- end
- else if (inHandler = 0) then
- begin
- inc(inHandler);
- FButton := Button;
- if (Button = mbLeft) and FUseLocator then
- begin
- { Locator neu setzen }
- if FUseMarkers and FCorralLocator then
- LocatorChanged(Limit(PixelTo_X(X),MarkerA,MarkerB))
- else
- LocatorChanged(Limit(PixelTo_X(X),DispMinX,DispMaxX));
- { !!! Trick 17 !!! }
- P := Point(X,Y);
- Perform(WM_LBUTTONUP, 0, Longint(PointToSmallPoint(P)));
- Perform(WM_MOUSEMOVE, 0, Longint(PointToSmallPoint(P)));
- Perform(WM_LBUTTONDOWN, 0, Longint(PointToSmallPoint(P)));
- end;
- dec(inHandler);
- end;
- end;
- inherited MouseDown(Button, Shift, X,Y);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.MouseMove(Shift: TShiftState; X,Y: integer);
- var
- NewPos,NewPos2: Longint;
- OnePixel: Longint;
- begin
- if FDragging and (FMarkerShift <> mkNone) then
- begin
- OnePixel := PixelTo_X(1)-PixelTo_X(0);
- isGridX(X,NewPos);
- case FMarkerShift of
- mkLocator:
- begin
- if UseMarkers and FCorralLocator then
- LocatorChanged(Limit(NewPos,MarkerA,MarkerB))
- else
- LocatorChanged(Limit(NewPos,DispMinX,DispMaxX));
- end;
- mkMarkerA:
- begin
- if UseLocator and FCorralLocator then
- NewPos := Limit(NewPos, DispMinX,Locator-OnePixel)
- else
- NewPos := Limit(NewPos, DispMinX,MarkerB-OnePixel);
- if (NewPos <> MarkerA) then
- begin
- MarkerAChanged(NewPos);
- end;
- end;
- mkMarkerB:
- begin
- if UseLocator and FCorralLocator then
- NewPos := Limit(NewPos, Locator+OnePixel,DispMaxX)
- else
- NewPos := Limit(NewPos, MarkerA+OnePixel,DispMaxX);
- if (NewPos <> MarkerB) then
- begin
- MarkerBChanged(NewPos);
- end;
- end;
- mkMarkerAB:
- begin
- if UseLocator and FCorralLocator then
- NewPos := Limit(NewPos,
- Max(DispMinX,(Locator+OnePixel)-(MarkerB-MarkerA)),
- Min(Locator-OnePixel,RangeMaxX-(MarkerB-MarkerA)))
- else
- NewPos := Limit(NewPos,DispMinX,RangeMaxX-(MarkerB-MarkerA));
- if (NewPos <> MarkerA) then
- begin
- if isGridX(X_ToPixel(NewPos+(MarkerB-MarkerA)),NewPos2) then
- begin
- if UseLocator and FCorralLocator then
- NewPos := Limit(NewPos + (NewPos2-(NewPos+(MarkerB-MarkerA))),
- Max(DispMinX,(Locator+OnePixel)-(MarkerB-MarkerA)),
- Min(Locator-OnePixel,RangeMaxX-(MarkerB-MarkerA)))
- else
- NewPos := Limit(NewPos + (NewPos2-(NewPos+(MarkerB-MarkerA))),
- DispMinX,RangeMaxX-(MarkerB-MarkerA));
- if (NewPos = MarkerA) then exit;
- end;
- MarkersChanged(FMarkerShift,NewPos,NewPos+(MarkerB-MarkerA));
- end;
- end;
- mkMarkerBA:
- begin
- if UseLocator and FCorralLocator then
- NewPos := Limit(NewPos,
- Max(RangeMinX+(MarkerB-MarkerA),Locator+OnePixel),
- Min(DispMaxX,Max(Locator-OnePixel,0)+(MarkerB-MarkerA)))
- else
- NewPos := Limit(NewPos,RangeMinX+(MarkerB-MarkerA),DispMaxX);
- if (NewPos <> MarkerB) then
- begin
- if isGridX(X_ToPixel(NewPos-(MarkerB-MarkerA)),NewPos2) then
- begin
- if UseLocator and FCorralLocator then
- NewPos := Limit(NewPos + (NewPos2-(NewPos-(MarkerB-MarkerA))),
- Max(RangeMinX+(MarkerB-MarkerA),Locator+OnePixel),
- Min(DispMaxX,Max(Locator-OnePixel,0)+(MarkerB-MarkerA)))
- else
- NewPos := Limit(NewPos + (NewPos2-(NewPos-(MarkerB-MarkerA))),
- RangeMinX+(MarkerB-MarkerA),DispMaxX);
- if (NewPos = MarkerB) then exit;
- end;
- MarkersChanged(FMarkerShift,NewPos-(MarkerB-MarkerA),NewPos);
- end;
- end;
- mkListMarker:
- begin
- HelpLocatorChanged(MinMax(NewPos,RangeMinX,RangeMaxX));
- end;
- end;
- Track;
- exit;
- end
- else
- begin
- FCanUpdate := False;
- Cursor := GetMouseCursor(Point(X,Y));
- if not Locked then
- begin
- Hint := GetHintText(Point(X,Y));
- if (Hint <> '')then
- begin
- ShowHint := FShowHints;
- end
- else
- begin
- {$IFDEF WIN32}
- Application.HideHint;
- {$ELSE}
- Application.CancelHint;
- {$ENDIF}
- ShowHint := False;
- end;
- end;
- FCanUpdate := True;
- end;
- inherited MouseMove(Shift,X,Y);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.MouseUp(Button: TMouseButton; Shift: TShiftState;
- X,Y: integer);
- var
- NewPos: Longint;
- begin
- if (Button = FButton) and FDragging then
- begin
- FDragging := False;
- if (FMarkerShift = mkListMarker) then
- begin
- if (HelpLocator >= 0) then
- NewPos := HelpLocator
- else
- NewPos := FMarkerList.Markers[FCurMarker]^.Offset;
- HelpLocatorChanged(-1);
- FMarkerList.SetOffset(FCurMarker,NewPos);
- end;
- FMarkerShift := mkNone;
- MouseCapture := False;
- TrackEnd;
- end
- else inherited MouseUp(Button,Shift,X,Y);
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.CMShowHintChanged(var Message: TMessage);
- begin
- inherited;
- if FCanUpdate then FShowHints := ShowHint;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.SetDefaultHint(aValue: String);
- begin
- if (aValue <> FDefaultHint) then
- begin
- FDefaultHint := aValue;
- Hint := aValue;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.GetHintText(aPos: TPoint): string;
- var
- i: integer;
- begin
- Result := DefaultHint;
- if IsLocator(aPos.X) then Result := 'Locator'
- else if IsMarkerA(aPos.X) then Result := 'Marker A'
- else if IsMarkerB(aPos.X) then Result := 'Marker B'
- else if (FMarkerList <> nil) then
- begin
- i := FindListMarker(aPos.X);
- if (i >= 0) then Result := MarkerList.Markers[i]^.Name;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.CMCursorChanged(var Message: TMessage);
- begin
- inherited;
- if FCanUpdate then FOriginalCursor := Cursor;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- function TMMCustomMarkerPanel.GetMouseCursor(aPos: TPoint): TCursor;
- begin
- Result := FOriginalCursor;
- if (not Locked and IsAnyMarker(aPos.X)) or
- (IsMarkerA(aPos.X) or IsMarkerB(aPos.X)) then
- begin
- if FDrawGriff then
- Result := crsHand1
- else
- Result := crsMark1
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.VLineDoted(aCanvas:TCanvas;x,y1,y2:integer;Clr:TColorRef);
- var
- DC: HDC;
- begin
- DC := aCanvas.Handle;
- if (y1 > y2) then SwapInt(y1,y2);
- while y1 < y2 do
- begin
- SetPixel(DC,x,y1,Clr);
- inc(y1,3);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.HLineDoted(aCanvas:TCanvas;x1,x2,y:integer;Clr:TColorRef);
- var
- DC: HDC;
- begin
- DC := aCanvas.Handle;
- if (x1 > x2) then SwapInt(x1,x2);
- while x1 < x2 do
- begin
- SetPixel(DC,x1,y,Clr);
- inc(x1,3);
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawGridsX(aCanvas: TCanvas; min,max: Longint);
- var
- i,x1,y1,y2,Steps: integer;
- Offset: Longint;
- Clr: TColorRef;
- begin
- if FDrawGridX then
- begin
- Steps := Trunc((DispMaxX-DispMinX)/GridWidthX);
- Offset := Round(DispMinX+GridWidthX-ModR(DispMinX,GridWidthX));
- if (Steps > Width div 2) then exit;
- Clr := ColorToRGB(FGridColor);
- y1 := Y_ToPixel(DispMinY);
- y2 := Y_ToPixel(DispMaxY);
- for i := 0 to Steps do
- begin
- x1 := X_ToPixel(Offset+Trunc(i*GridWidthX));
- if (x1 >= X_ToPixel(max)) then break;
- if (x1 >= X_ToPixel(min)) then
- VLineDoted(aCanvas,x1,y1,y2,Clr);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.DrawGridsY(aCanvas: TCanvas; min,max: Longint);
- var
- i,x1,x2,y1,Steps: integer;
- Offset: Longint;
- Clr: TColorRef;
- begin
- if FDrawGridY then
- begin
- Steps := Trunc((DispMaxY-DispMinY)/GridWidthY);
- Offset := Round(DispMinY+GridWidthY-ModR(DispMinY,GridWidthY));
- if (Steps > Height div 2) then exit;
- x1 := X_ToPixel(DispMinX);
- x2 := X_ToPixel(DispMaxX);
- Clr := ColorToRGB(FGridColor);
- for i := 0 To Steps do
- begin
- y1 := Height-1-Y_ToPixel(Offset+Trunc(i*GridWidthY));
- if (y1 >= Y_ToPixel(min)) then break;
- if (y1 >= Y_ToPixel(max)) then
- HLineDoted(aCanvas,x1,x2,y1,Clr);
- end;
- end;
- end;
- {-- TMMCustomMarkerPanel ------------------------------------------------}
- procedure TMMCustomMarkerPanel.Paint;
- begin
- inherited Paint;
- DrawGridsX(Canvas,DispMinX,DispMaxX);
- DrawGridsY(Canvas,DispMinY,DispMaxY);
- DrawAllMarkers(Canvas);
- end;
- end.