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

📄 qiplottoolbar.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 3 页
字号:
            DisableAllTracking;
            if DataCursorCount > 0 then DataCursor[0].UserSelected := True;
          end
      else
        begin
          for x := 0 to DataCursorCount-1 do
            DataCursor[x].Visible := False;
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.SelectDownChange(Sender: TObject);
begin
  with TiPlotComponentAccess(Owner) do
    begin
      if SelectActive then
          begin
            DisableAllTracking;
            SelectModeActive := True;
          end
      else
        begin
          SelectModeActive := False;
        end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.DoButtonClickResume;         begin ResumeClick        (Self);end;
procedure TiPlotToolBar.DoButtonClickPause;          begin PauseClick         (Self);end;
procedure TiPlotToolBar.DoButtonClickScrollAxesMode; begin AxesModeScrollClick(Self);end;
procedure TiPlotToolBar.DoButtonClickZoomAxesMode;   begin AxesModeZoomClick  (Self);end;
procedure TiPlotToolBar.DoButtonClickZoomIn;         begin ZoomInClick        (Self);end;
procedure TiPlotToolBar.DoButtonClickZoomOut;        begin ZoomOutClick       (Self);end;
procedure TiPlotToolBar.DoButtonClickSelect;         begin SelectClick        (Self);end;
procedure TiPlotToolBar.DoButtonClickZoomBox;        begin ZoomBoxClick       (Self) end;
procedure TiPlotToolBar.DoButtonClickCursor;         begin CursorClick        (Self);end;
procedure TiPlotToolBar.DoButtonClickEdit;           begin EditClick          (Self);end;
procedure TiPlotToolBar.DoButtonClickCopy;           begin CopyClick          (Self);end;
procedure TiPlotToolBar.DoButtonClickSave;           begin SaveClick          (Self);end;
procedure TiPlotToolBar.DoButtonClickPrint;          begin PrintClick         (Self);end;
procedure TiPlotToolBar.DoButtonClickPreview;        begin PreviewClick       (Self);end;
//****************************************************************************************************************************************************
function TiPlotToolBar.CreateSpacer : TiPlotToolBarButton;
begin
  Result         := TiPlotToolBarButton.Create(Owner, nil, nil, nil, nil);
  Result.Style   := iptbbsSpacer;
  Result.Visible := True;
  FButtonList.AddObject('', Result);
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.ButtonInvalidate(Sender: TObject);
begin
  TriggerInvalidateNow(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.UpdateSpacers;
begin
  FResumePauseSpacer.Visible   := FResumeButton.Visible         or FPauseButton.Visible;
  FAxesModeSpacer.Visible      := FAxesModeScrollButton.Visible or FAxesModeZoomButton.Visible;
  FZoomInOutSpacer.Visible     := FZoomInButton.Visible         or FZoomOutButton.Visible;
  FZoomBoxCursorSpacer.Visible := FZoomBoxButton.Visible        or FCursorButton.Visible;
  FEditSpacer.Visible          := FEditButton.Visible;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.UpdateResumePauseButtons;
var
  x                   : Integer;
  AnyTrackingDisabled : Boolean;
  AllTrackingDisabled : Boolean;
begin
  AnyTrackingDisabled := False;
  AllTrackingDisabled := True;

  with TiPlotComponentAccess(Owner) do
    begin
      for x := 0 to XAxisCount - 1 do
        begin
          if not XAxis[x].TrackingEnabled then AnyTrackingDisabled := True;
          if     XAxis[x].TrackingEnabled then AllTrackingDisabled := False;
        end;

      for x := 0 to YAxisCount - 1 do
        begin
          if not YAxis[x].TrackingEnabled then AnyTrackingDisabled := True;
          if     YAxis[x].TrackingEnabled then AllTrackingDisabled := False;
        end;

      FResumeButton.Enabled := AnyTrackingDisabled;

      FPauseButton.Enabled  := not AllTrackingDisabled;
    end;
end;
//****************************************************************************************************************************************************
function TiPlotToolBar.GetCursorActive : Boolean;begin Result := FCursorButton.Down; end;
function TiPlotToolBar.GetZoomBoxActive: Boolean;begin Result := FZoomBoxButton.Down;end;
function TiPlotToolBar.GetSelectActive : Boolean;begin Result := FSelectButton.Down; end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.TurnOffCursor;
begin
  FCursorButton.Down := False;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.Draw(const Canvas: TCanvas; const BackGroundColor: TColor);
var
  ARect      : TRect;
  x          : Integer;
  iButton    : TiPlotToolBarButton;
  ALeft      : Integer;
  AWidth     : Integer;
  ButtonSize : Integer;
begin
  inherited Draw(Canvas, BackGroundColor);
  if not Visible then Exit;

  if FSmallButtons then ButtonSize := 22 else ButtonSize := 30;

  UpdateSpacers;
  UpdateResumePauseButtons;

  with Canvas do
    begin
      Brush.Style := bsSolid;
      Brush.Color := clBtnFace;
      Pen.Width   := 1;
      ARect       := DrawRect;
      ARect.Right := ARect.Right + 1;
      FillRect(ARect);
      if not FFlatBorder then iDrawEdge(Canvas, DrawRect, idesRaised);

    ALeft := Left + ButtonLeftOffset;
    for x := 0 to FButtonList.Count-1 do
      begin
        iButton        := FButtonList.Objects[x] as TiPlotToolBarButton;

        if not iButton.Visible then Continue;

        if iButton.Style = iptbbsButton then AWidth := ButtonSize else AWidth := SpacerWidth;

        iButton.Left   := ALeft;
        iButton.Right  := iButton.Left + AWidth;
        iButton.Top    := Top + ButtonTopOffset;
        iButton.Bottom := iButton.Top + ButtonSize;
        iButton.Draw(Canvas, BackGroundColor);

        ALeft := ALeft + AWidth;
      end;
    end;
end;
//****************************************************************************************************************************************************
function TiPlotToolBar.GetRequiredWidth(const Canvas : TCanvas) : Integer;
begin
  with Canvas do
    begin
      if FSmallButtons then Result := 28 else Result := 36;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.GroupClick(Sender: TObject);
var
  x      : Integer;
  Button : TiPlotToolBarButton;
begin
  for x := 0 to FButtonList.Count-1 do
    begin
      Button := FButtonList.Objects[x] as TiPlotToolBarButton;
      if (Button <> Sender) and (Button.GroupIndex = (Sender as TiPlotToolBarButton).GroupIndex) then
        Button.Down := False;
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.NotificationSetFocus(Sender: TObject);
begin
  if Sender = Self                                                      then Exit;
  if not (Sender as TiPlotObject).UserSelected                          then Exit;

  SetUserSelected(False);
end;
//****************************************************************************************************************************************************
{ TiPlotToolBarButton }
//****************************************************************************************************************************************************
procedure TiPlotToolBarButton.DoMouseHint(MouseData: TiPlotMouseData; var HintData: TiHintData);
begin
  HintData.Text := GetTranslation(Hint);
  HintData.Top  := Bottom + 3;
  HintData.Left := Left;

  TiPlotComponentAccess(Owner as TiPlotComponent).DoToolBarCustomizeHint(ToolBar, HintData.Text);
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBarButton.iMouseMove(var HintData: TiHintData; Shift: TShiftState; X, Y, ScreenX, ScreenY: Integer; DblClickActive: Boolean);
begin
  inherited;
  FMouseOver := True;
  if FFlat then TriggerChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBarButton.Draw(const Canvas: TCanvas; const BackGroundColor: TColor);
var
  ARect   : TRect;
  OffSetX : Integer;
  OffSetY : Integer;
  Bitmap  : TBitmap;
begin
  if FStyle = iptbbsSpacer then Exit;

  if (FImageIndex = -1) and (FImageName <> '') then
    begin
      Bitmap := TBitmap.Create;
      try
        Bitmap.LoadFromResourceName(HInstance, FImageName);
        FImageIndex := FImageList.AddMasked(Bitmap, clTeal);
      finally
        Bitmap.Free;
      end;
    end;

  with Canvas, DrawRect do
    begin
      ARect := DrawRect;

      OffSetX  := Left + Self.Width  div 2 - FImageList.Width  div 2;
      OffSetY  := Top  + Self.Height div 2 - FImageList.Height div 2;

      if not FFlat then
        begin
          if MouseDown or Down then
            begin
              Brush.Color :=  ColorToRGB(clWhite) and $FFFFFF - $101010;
              FillRect(ARect);
              iDrawEdge(Canvas, ARect, idesSunken);
              OffSetX := OffSetX + 1;
              OffSetY := OffSetY + 1;
            end
          else iDrawEdge(Canvas, ARect, idesRaised)
        end
      else
        begin
          if (MouseDown or Down) and not FMouseOver then
            begin
              Brush.Color :=  ColorToRGB(clWhite) and $FFFFFF - $101010;
              FillRect(ARect);
            end;

          if Enabled then
            begin
              if MouseDown or Down then
                begin
                  OffSetX := OffSetX + 1;
                  OffSetY := OffSetY + 1;
                  DrawLoweredEdge(Canvas);
                end
              else if FMouseOver then DrawRaisedEdge (Canvas);
            end;

        end;

      {$ifdef iVCL}FImageList.Draw(Canvas, OffSetX, OffSetY, FImageIndex, Enabled);         {$endif}
      {$ifdef iCLX}FImageList.Draw(Canvas, OffSetX, OffSetY, FImageIndex, itImage, Enabled);{$endif}
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBarButton.DrawLoweredEdge(const Canvas: TCanvas);
var
  ARect : TRect;
begin
  ARect := Rect(DrawRect.Left, DrawRect.Top, DrawRect.Right-1, DrawRect.Bottom-1);
  with Canvas, ARect do
    begin
      Pen.Color := clBtnShadow;
      Polyline([Point(Left, Bottom), Point(Left, Top), Point(Right, Top)]);

      Pen.Color := clBtnHighlight;
      Polyline([Point(Right, Top), Point(Right, Bottom), Point(Left, Bottom)]);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBarButton.DrawRaisedEdge(const Canvas: TCanvas);
var
  ARect : TRect;
begin
  ARect := Rect(DrawRect.Left, DrawRect.Top, DrawRect.Right-1, DrawRect.Bottom-1);
  with Canvas, ARect do
    begin
      Pen.Color := clBtnHighlight;
      Polyline([Point(Left, Bottom), Point(Left, Top), Point(Right, Top)]);

      Pen.Color := clBtnShadow;
      Polyline([Point(Right, Top), Point(Right, Bottom), Point(Left, Bottom)]);
    end;
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBarButton.DoMouseNotOver;
begin
  inherited;
  FMouseOver := False;
  TriggerChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiPlotToolBar.SetSmallButtons(const Value: Boolean);
begin
  if FSmallButtons <> Value then
    begin
      FSmallButtons := Value;
      if FSmallButtons then SetupSmallImages else SetupLargeImages;
      TriggerChange(Self);
    end;
end;
//****************************************************************************************************************************************************
end.

⌨️ 快捷键说明

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