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

📄 ithermometer.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 3 页
字号:
                             Pen.Color := clBtnShadow;   Arc(Left, Top, Right, Bottom, Left, Bottom, (Right + Left) div 2, Top);

                             with BulbRefRect do
                               begin
                                 Pen.Color   := clWhite;
                                 Arc(Left, Top, Right, Bottom, (Right + Left) div 2, Top, Left, (Top + Bottom) div 2);
                                 BulbRefRect := Rect(Left - 1, Top - 1, Right + 1, Bottom + 1);
                                 Arc(Left, Top, Right, Bottom, (Right + Left) div 2, Top, Left, (Top + Bottom) div 2);
                               end;
                           end;


                         with IndicatorRect do
                           begin
                             Pen.Color   := FIndicatorBackGroundColor;
                             Brush.Color := FIndicatorBackGroundColor;
                             Ellipse(Right -2*FIndicatorWidth, Top, Right, Bottom);  //Indicator BackGround Rounded Top
                             Rectangle(Left, Top, Right - FIndicatorWidth, Bottom);  //Indicator BackGround Rectangle

                             PositionLength := Round((Right - Left)*ValuePercent(Position));
                             IndicatorRect  := Rect(Left , Top, Left + PositionLength, Bottom);
                             Pen.Color   := FIndicatorColor;
                             Brush.Color := FIndicatorColor;
                             Ellipse(Right -2*FIndicatorWidth, Top, Right, Bottom); //Indicator BackGround Rounded Top
                             Rectangle(Left, Top, Right - FIndicatorWidth, Bottom); //Indicator BackGround Rectangle
                           end;
                       end;
      end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiThermometer.DrawIndicatorBox(Canvas: TCanvas);
var
  BarRect        : TRect;
  PixelsStart    : Integer;
  PixelsPosition : Integer;
begin
  BarRect := FBarRect;
  with Canvas, BarRect do
    begin
      Brush.Color := FIndicatorColor;
      Pen.Color   := FIndicatorColor;
      Pen.Style   := psSolid;
      Brush.Style := bsSolid;

      case FIndicatorFillReferenceStyle of
        ipfrsMin   : PixelsStart := GetPositionPixels(PositionMin);
        ipfrsMax   : PixelsStart := GetPositionPixels(PositionMax);
        else         PixelsStart := GetPositionPixels(FIndicatorFillReferenceValue);
      end;

      PixelsPosition := GetPositionPixels(Position);

      case FOrientation of
        ioVertical   : begin
                         if (FIndicatorStyle = itisBarRaised) or (FIndicatorStyle = itisBarSunken) then
                           begin
                             InflateRect(BarRect, +2, +2);
                             case FIndicatorStyle of
                               itisBarRaised : iDrawEdge(Canvas, BarRect, idesRaised);
                               itisBarSunken : iDrawEdge(Canvas, BarRect, idesSunken);
                             end;
                             InflateRect(BarRect, -2, -2);
                           end;

                         Pen.Color   := FIndicatorBackGroundColor;
                         Brush.Color := FIndicatorBackGroundColor;

                         Rectangle(Left, Top, Right, Bottom);

                         Pen.Color      := FIndicatorColor;
                         Brush.Color    := FIndicatorColor;

                         Rectangle(Left, PixelsPosition, Right, PixelsStart);
                       end;
        ioHorizontal : begin
                         if (FIndicatorStyle = itisBarRaised) or (FIndicatorStyle = itisBarSunken) then
                           begin
                             InflateRect(BarRect, +2, +2);
                             case FIndicatorStyle of
                               itisBarRaised : iDrawEdge(Canvas, BarRect, idesRaised);
                               itisBarSunken : iDrawEdge(Canvas, BarRect, idesSunken);
                             end;
                             InflateRect(BarRect, -2, -2);
                           end;

                         Pen.Color   := FIndicatorBackGroundColor;
                         Brush.Color := FIndicatorBackGroundColor;

                         Rectangle(Left, Top, Right, Bottom);

                         Pen.Color   := FIndicatorColor;
                         Brush.Color := FIndicatorColor;

                         Rectangle(PixelsStart, Top, PixelsPosition, Bottom);
                       end;
      end;
    end;
end;
//****************************************************************************************************************************************************
procedure TiThermometer.DrawTicks(Canvas: TCanvas);
begin
  ScaleObject.PositionMax          := PositionMax;
  ScaleObject.PositionMin          := PositionMin;
  ScaleObject.Orientation          := FOrientation;
  ScaleObject.OrientationTickMarks := FOrientationTickMarks;

  if FIndicatorStyle <> itisBulb then
    ScaleObject.ReverseScale := FReverseScale
  else ScaleObject.ReverseScale := False;

  case FOrientation of
    ioVertical   : begin
                     ScaleObject.Start := FBarRect.Bottom;
                     ScaleObject.Stop  := FBarRect.Top;
                     ScaleObject.Edge  := FCenterPoint.X;
                   end;
    ioHorizontal : begin
                     ScaleObject.Start := FBarRect.Left;
                     ScaleObject.Stop  := FBarRect.Right;
                     ScaleObject.Edge  := FCenterPoint.Y;
                   end;
  end;

  ScaleObject.Draw(Canvas);
end;
//****************************************************************************************************************************************************
procedure TiThermometer.DrawLimits(Canvas: TCanvas);
var
  x         : Integer;
  DummyRect : TRect;
begin
  for x := 0 to LimitCount -1 do
    begin
      if LimitShowUpperPointer[x] then DrawPointer(Canvas, LimitUpperValue[x], LimitPointerMargin[x], LimitPointerSize[x], LimitDrawScaleSide[x], LimitUpperPointerColor[x], DummyRect);
      if LimitShowLowerPointer[x] then DrawPointer(Canvas, LimitLowerValue[x], LimitPointerMargin[x], LimitPointerSize[x], LimitDrawScaleSide[x], LimitLowerPointerColor[x], DummyRect);
    end;
end;
//****************************************************************************************************************************************************
procedure TiThermometer.DrawPointer(Canvas: TCanvas; Position: Double; Margin, Size: Integer; DrawScaleSide: Boolean; AColor: TColor; var PositionRect: TRect);
var
  PositionPixels             : Integer;
  ActualOrientationTickMarks : TiOrientationSide;
begin
  ActualOrientationTickMarks := FOrientationTickMarks;
  if DrawScaleSide then if ActualOrientationTickMarks = iosBottomRight then ActualOrientationTickMarks := iosTopLeft else ActualOrientationTickMarks := iosBottomRight;
  with Canvas, FBarRect do
    begin
      Brush.Color := AColor;
      Pen.Color   := AColor;
      PositionPixels := GetPositionPixels(Position);
      case FOrientation of
        ioVertical   : begin
                         case ActualOrientationTickMarks of
                           iosBottomRight : begin
                                              Polygon([Point(Left - Margin - Size, PositionPixels - Size div 2),
                                                       Point(Left - Margin,        PositionPixels             ),
                                                       Point(Left - Margin - Size, PositionPixels + Size div 2)]);

                                              PositionRect := Rect(Left-Margin - Size,PositionPixels-Size div 2,
                                                                   Left-Margin       ,PositionPixels+Size div 2);
                                            end;
                           iosTopLeft     : begin
                                              Polygon([Point(Right + Margin + Size, PositionPixels - Size div 2),
                                                       Point(Right + Margin + Size, PositionPixels + Size div 2),
                                                       Point(Right + Margin,        PositionPixels             )]);

                                              PositionRect := Rect(Right+Margin,     PositionPixels-Size div 2,
                                                                   Right+Margin+Size,PositionPixels+Size div 2);
                                            end;
                         end;
                       end;
        ioHorizontal : begin
                         case ActualOrientationTickMarks of
                           iosBottomRight : begin
                                              Polygon([Point(PositionPixels - Size div 2, Top    - Margin - Size),
                                                       Point(PositionPixels + Size div 2, Top    - Margin - Size),
                                                       Point(PositionPixels             , Top    - Margin       )]);

                                              PositionRect := Rect(PositionPixels-Size div 2, Top-Margin - Size,
                                                                   PositionPixels+Size div 2, Top-Margin);
                                            end;
                           iosTopLeft     : begin
                                              Polygon([Point(PositionPixels - Size div 2, Bottom + Margin + Size),
                                                       Point(PositionPixels + Size div 2, Bottom + Margin + Size),
                                                       Point(PositionPixels             , Bottom + Margin       )]);

                                              PositionRect := Rect(PositionPixels-Size div 2, Bottom+Margin,
                                                                   PositionPixels+Size div 2, Bottom+Margin+Size);
                                            end;
                         end;
                       end;
      end;
  end;
end;
//****************************************************************************************************************************************************
procedure TiThermometer.iMouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  if MinMaxUserCanMove and (Button = mbLeft) then
    begin
      FMouseDownX := X;
      FMouseDownY := Y;
      if      ShowMinPointer and PtInRect(FCurrentMinRect, Point(X,Y)) then
        begin
          FMovingMin       := True;
          FOldCurrentValue := CurrentMin;
        end
      else if ShowMaxPointer and PtInRect(FCurrentMaxRect, Point(X,Y)) then
        begin
          FMovingMax       := True;
          FOldCurrentValue := CurrentMax;
        end;
      InvalidateChange;
    end;
end;
//****************************************************************************************************************************************************
procedure TiThermometer.iMouseMove(Shift: TShiftState; X, Y: Integer);
begin
  if FMovingMax then
    begin
      case Forientation of
        ioHorizontal : CurrentMax := FOldCurrentValue - (FMouseDownX - X)/GetTravelRange*(PositionMax - PositionMin);
        ioVertical   : CurrentMax := FOldCurrentValue + (FMouseDownY - Y)/GetTravelRange*(PositionMax - PositionMin);
      end;
      if CurrentMin > CurrentMax then CurrentMin := CurrentMax;
    end
  else if FMovingMin then
    begin
      case Forientation of
        ioHorizontal : CurrentMin := FOldCurrentValue - (FMouseDownX - X)/GetTravelRange*(PositionMax - PositionMin);
        ioVertical   : CurrentMin := FOldCurrentValue + (FMouseDownY - Y)/GetTravelRange*(PositionMax - PositionMin);
      end;
      if CurrentMax < CurrentMin then CurrentMax := CurrentMin;
    end;
end;
//****************************************************************************************************************************************************
procedure TiThermometer.iMouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  FMovingMax := False;
  FMovingMin := False;
end;
//****************************************************************************************************************************************************
end.

⌨️ 快捷键说明

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