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

📄 iplotobjects.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 4 页
字号:

    property ForceStacking      : Boolean read FForceStacking write SetForceStacking;

    property ZOrderString       : String  read GetZOrderString;
    property StartPercentString : String  read GetStartPercentString;
  public
    constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
    destructor  Destroy;                                                                           override;

    property DrawRect           : TRect   read GetDrawRect;
    property LayoutRect         : TRect   read GetLayoutRect;

    property IsHorz             : Boolean read GetIsHorz;
    property IsVert             : Boolean read GetIsVert;
    property LayoutWidth        : Integer read GetLayoutWidth;
    property LayoutHeight       : Integer read GetLayoutHeight;
    property Width              : Integer read GetWidth;
    property Height             : Integer read GetHeight;
  published
    property Horizontal         : Boolean read FHorizontal     write SetHorizontal;
    property ZOrder             : Integer read FZOrder         write SetZOrder;

    property StartPercent       : Double  read FStartPercent   write SetStartPercent;
    property StopPercent        : Double  read FStopPercent    write SetStopPercent;

  end;

  TiPlotButton = class(TiPlotObject)
  private
    FTop               : Integer;
    FBottom            : Integer;
    FRight             : Integer;
    FLeft              : Integer;
    FDown              : Boolean;
    FOnClick           : TNotifyEvent;
    FOnGroupClick      : TNotifyEvent;
    FOnInvalidate      : TNotifyEvent;
    FOnDownChange      : TNotifyEvent;
    FTimer             : TTimer;
    FFirstTimerMessage : Boolean;
    FTimerEnabled      : Boolean;
    FGroupIndex        : Integer;
    procedure SetDown     (const Value: Boolean);
  protected
    procedure SetEnabled(const Value: Boolean); override;

    procedure SetDrawRect(const Value: TRect);
    function  GetDrawRect: TRect;
    function  GetHeight  : Integer;
    function  GetWidth   : Integer;
    procedure Invalidate;
    procedure TimerEvent(Sender: TObject);
    procedure DestroyTimer;
  public
    constructor Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent); override;
    destructor  Destroy;                                                                           override;

    procedure DoMouseLeft(MouseData: TiPlotMouseData); override;
    procedure DoMouseMove(MouseData: TiPlotMouseData); override;
    procedure DoMouseUp  (MouseData: TiPlotMouseData); override;

    property DrawRect     : TRect        read GetDrawRect   write SetDrawRect;
    property Left         : Integer      read FLeft         write FLeft;
    property Top          : Integer      read FTop          write FTop;
    property Right        : Integer      read FRight        write FRight;
    property Bottom       : Integer      read FBottom       write FBottom;
    property Down         : Boolean      read FDown         write SetDown;
    property Width        : Integer      read GetWidth;
    property Height       : Integer      read GetHeight;
    property TimerEnabled : Boolean      read FTimerEnabled write FTimerEnabled;
    property GroupIndex   : Integer      read FGroupIndex   write FGroupIndex;

    property OnInvalidate : TNotifyEvent read FOnInvalidate write FOnInvalidate;
    property OnClick      : TNotifyEvent read FOnClick      write FOnClick;
    property OnGroupClick : TNotifyEvent read FOnGroupClick write FOnGroupClick;
    property OnDownChange : TNotifyEvent read FOnDownChange write FOnDownChange;
  end;

implementation

uses
{$ifdef iVCL} iPlotComponent;{$endif}
{$ifdef iCLX}QiPlotComponent;{$endif}

type
  TiPlotComponentAccess = class(TiPlotComponent)end;
//****************************************************************************************************************************************************
{TiPlotObject}
//****************************************************************************************************************************************************
constructor TiPlotObject.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
  FOwner     := AOwner;
  FOnChange  := AOnChange;
  FOnInsert  := AOnInsert;
  FOnRemove  := AOnRemove;
  FOnRename  := AOnRename;

  FVisible      := True;
  FEnabled      := True;
  FLayer        := 100;
  FPopupEnabled := True;
end;
//****************************************************************************************************************************************************
constructor TiPlotManagerObject.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
  if not Assigned(AOwner)     then raise Exception.Create('Owner must be assigned');
  if not Assigned(AOnChange)  then raise Exception.Create('OnChange event handler can not be null');
  if not Assigned(AOnInsert)  then raise Exception.Create('OnInsert event handler can not be null');
  if not Assigned(AOnRemove)  then raise Exception.Create('OnRemove event handler can not be null');
  if not Assigned(AOnRename)  then raise Exception.Create('AOnRename event handler can not be null');

  inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.Loaded;
begin
  if Assigned(FOnInsert) then FOnInsert(Self);
end;
//****************************************************************************************************************************************************
destructor TiPlotObject.Destroy;
begin
  if Assigned(FOnRemove) then FOnRemove(Self);
  TriggerLayoutChange(Self);
  inherited;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.NotificationRemove  (Sender: TObject);begin end;
procedure TiPlotObject.NotificationRename  (Sender: TObject);begin end;
procedure TiPlotObject.NotificationSetFocus(Sender: TObject);begin end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetVisible     (const Value:Boolean);begin SetBooleanProperty(Value,FVisible,      TriggerChange);end;
procedure TiPlotObject.SetPopupEnabled(const Value:Boolean);begin SetBooleanProperty(Value,FPopupEnabled, TriggerChange);end;
procedure TiPlotObject.SetLayer       (const Value:Integer);begin SetIntegerProperty(Value,FLayer,        TriggerChange);end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetEnabled(const Value:Boolean);
begin
  if FEnabled <> Value then
    begin
      FEnabled := Value;
      if not FEnabled then
        begin
          FMouseDown   := False;
          UserSelected := False;
        end;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetXYAxesReversed(const Value: Boolean);
begin
  FXYAxesReversed := Value;
end;
//****************************************************************************************************************************************************
function TiPlotObject.GetLayerString: String;
begin
  Result := IntToStr(FLayer);
  while Length(Result) < 6 do
    Result := '0' + Result;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetUserSelected(const Value:Boolean);
begin
  if FUserSelected <> Value then
    begin
      FUserSelected := Value;
      TriggerInvalidateNow(Self);
      if FUserSelected then
        begin
          TriggerSetFocus(Self);
          DoSetFocus; //Must be after TriggerSetFocus
        end
      else
        begin
          DoLostFocus;
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetName(const Value:String);
begin
  if FName <> Value then
    begin
      FNameOld := FName;
      FName    := Value;
      TriggerRename(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetUserCanEdit(const Value: Boolean);
begin
  FUserCanEdit := Value;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetShiftState(const Value: TShiftState);
begin
  FShiftState := Value;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.TriggerChange(Sender: TObject);
begin
  if Assigned(FOnChange) then FOnChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.TriggerRename(Sender: TObject);
begin
  if Assigned(FOnRename) then FOnRename(Self);
  TriggerChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.TriggerLayoutChange(Sender: TObject);
begin
  if Assigned(FOnLayoutChange) then FOnLayoutChange(Self);
  TriggerChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.TriggerInvalidateNow(Sender: TObject);
begin
  if Assigned(FOnInvalidateNow) then FOnInvalidateNow(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.TriggerSetFocus(Sender: TObject);
begin
  if Assigned(FOnSetFocus) then FOnSetFocus(Self);
end;
//****************************************************************************************************************************************************
function TiPlotObject.HitTest(X, Y: Integer): Boolean;
var
  MouseData: TiPlotMouseData;
begin
  MouseData.X              := X;
  MouseData.Y              := Y;
  MouseData.ScreenX        := 0;
  MouseData.ScreenY        := 0;
  MouseData.XAxisPixels    := 0;
  MouseData.YAxisPixels    := 0;
  MouseData.Shift          := [];
  MouseData.Button         := mbLeft;
  MouseData.DblClickActive := False;

  Result := iMouseHitTest(MouseData);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetBooleanProperty(Value: Boolean; var FVariable: Boolean; EventHandler : TNotifyEvent);
begin
  if FVariable <> Value then
    begin
      FVariable := Value;
      if Assigned(EventHandler) then EventHandler(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.SetColorProperty(Value: TColor; var FVariable: TColor; EventHandler : TNotifyEvent);
begin
  if FVariable <> Value then
    begin
      FVariable := Value;
      if Assigned(EventHandler) then EventHandler(Self);
    end;
end;

⌨️ 快捷键说明

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