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

📄 iplotobjects.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 4 页
字号:
//****************************************************************************************************************************************************
procedure TiPlotLayoutObject.SetStartPercent(const Value : Double);
var
  TempValue : Double;
begin
  TempValue := Value;
  if TempValue <   0 then TempValue :=   0;
  if TempValue > 100 then TempValue := 100;

  if (FStopPercent - TempValue) < 5 then
    begin
      FStopPercent :=  TempValue + 5;
      if FStopPercent > 100 then
        begin
          TempValue     := 95;
          FStopPercent  := 100;
        end;
    end;

  SetDoubleProperty(TempValue,FStartPercent,TriggerChange)
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutObject.SetStopPercent(const Value : Double);
var
  TempValue : Double;
begin
  TempValue := Value;
  if TempValue <   0 then TempValue :=   0;
  if TempValue > 100 then TempValue := 100;

  if (TempValue - FStartPercent) < 5 then
    begin
      FStartPercent :=  TempValue - 5;
      if FStartPercent < 0 then
        begin
          FStartPercent := 0;
          TempValue     := 5;
        end;
    end;

  SetDoubleProperty(TempValue,FStopPercent,TriggerChange)
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutObject.SetStartStopPercent(const Start : Double; const Stop : Double);
begin
  FStartPercent := Start;
  FStopPercent  := Stop;
  TriggerChange(Self);
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetDrawRect: TRect;
begin
  Result := Rect(FLeft, FTop, FRight, FBottom);
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutObject.SetDrawRect(const Value: TRect);
begin
  Left   := Value.Left;
  Top    := Value.Top;
  Right  := Value.Right;
  Bottom := Value.Bottom;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetIsHorz: Boolean;
begin
  Result := FHorizontal;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetIsVert: Boolean;
begin
  Result := not FHorizontal;
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutObject.Loaded;
begin
  inherited Loaded;
  if Assigned(FOnLayoutChange) then FOnLayoutChange(Self);
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetRequiredWidth(const Canvas : TCanvas): Integer;
begin
  Result := 0;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetRequiredLengthGaurd(const Canvas : TCanvas): Integer;
begin
  Result := 0;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetHeight: Integer;
begin
  Result := Bottom - Top;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetWidth: Integer;
begin
  Result := Right - Left;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetLayoutRect: TRect;
begin
  Result := Rect(FLayoutLeft, FLayoutTop, FLayoutRight, FLayoutBottom);
end;
//****************************************************************************************************************************************************
procedure TiPlotLayoutObject.SetLayoutRect(const Value: TRect);
begin
  FLayoutLeft   := Value.Left;
  FLayoutTop    := Value.Top;
  FLayoutRight  := Value.Right;
  FLayoutBottom := Value.Bottom;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetLayoutHeight: Integer;
begin
  Result := FLayoutBottom - FLayoutTop;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.GetLayoutWidth: Integer;
begin
  Result := FLayoutRight - FLayoutLeft;
end;
//****************************************************************************************************************************************************
function TiPlotLayoutObject.iMouseHitTest(MouseData: TiPlotMouseData): Boolean;
begin
  Result := PtInRect(DrawRect, Point(MouseData.X, MouseData.Y));
end;
//****************************************************************************************************************************************************
{TiPlotButton}
//****************************************************************************************************************************************************
constructor TiPlotButton.Create(AOwner: TObject; AOnChange, AOnInsert, AOnRemove, AOnRename: TNotifyEvent);
begin
  inherited Create(AOwner, AOnChange, AOnInsert, AOnRemove, AOnRename);
  FEnabled := True;
end;
//****************************************************************************************************************************************************
destructor TiPlotButton.Destroy;
begin
  DestroyTimer;
  inherited;
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.SetDrawRect(const Value: TRect);
begin
  Left   := Value.Left;
  Top    := Value.Top;
  Right  := Value.Right;
  Bottom := Value.Bottom;
end;
//****************************************************************************************************************************************************
function TiPlotButton.GetDrawRect: TRect;
begin
  Result := Rect(Left, Top, Right, Bottom)
end;
//****************************************************************************************************************************************************
function TiPlotButton.GetHeight: Integer;
begin
  Result := FBottom - FTop;
end;
//****************************************************************************************************************************************************
function TiPlotButton.GetWidth: Integer;
begin
  Result := FRight - FLeft;
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.DoMouseLeft(MouseData: TiPlotMouseData);
begin
  if FTimerEnabled then
    begin
      if not Assigned(FTimer) then FTimer := TTimer.Create(nil);
      FTimer.Interval    := 500;
      FTimer.Enabled     := True;
      FTimer.OnTimer     := TimerEvent;
      FFirstTimerMessage := True;
    end;
  Invalidate;
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.DoMouseMove(MouseData: TiPlotMouseData);
begin
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.DoMouseUp(MouseData: TiPlotMouseData);
begin
  if MouseDown then
    begin
      FMouseDown := False;
      DestroyTimer;
      Invalidate;

      if PtInRect(DrawRect, Point(MouseData.X, MouseData.Y)) then
        begin
          if FGroupIndex > 0 then
            begin
              if Assigned(FOnGroupClick) then FOnGroupClick(Self);
            end
          else if FGroupIndex < 0 then
            begin
              if Assigned(FOnGroupClick) then FOnGroupClick(Self);
            end;
          if Assigned(FOnClick) then FOnClick(Self);
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.DoSetFocus;
begin
  TiPlotComponentAccess(Owner).DoObjectGotFocus(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotObject.DoLostFocus;
begin
  TiPlotComponentAccess(Owner).DoObjectLostFocus(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.Invalidate;
begin
  if Assigned(FOnInvalidate) then FOnInvalidate(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.TimerEvent(Sender : TObject);
begin
  if FFirstTimerMessage then
    begin
      FTimer.Interval := 50;
      FFirstTimerMessage := False;
    end;
  if Assigned(FOnClick) then FOnClick(Self);
  Invalidate;
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.SetDown(const Value: Boolean);
begin
  if FDown <> Value then
    begin
      FDown := Value;
      Invalidate;
      if Assigned(FOnDownChange) then FOnDownChange(Self);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.DestroyTimer;
begin
  if Assigned(FTimer) then
    begin
      FTimer.Free;
      FTimer := nil;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotButton.SetEnabled(const Value: Boolean);
begin
  inherited SetEnabled(Value);
  if not Enabled then DestroyTimer;
end;
//****************************************************************************************************************************************************
end.

⌨️ 快捷键说明

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