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

📄 aqdockinguivs2005.pas

📁 AutomatedDocking Library 控件源代码修改 适合Delphi 2009 和C++ Builder 20009 使用。 修正汉字不能正确显示问题
💻 PAS
📖 第 1 页 / 共 2 页
字号:

  DoDrawTabItemContent(ACanvas, FillRect, AText, TabStates[AState],
    HOrientations[AOrientation], ADrawImage, ADrawText, HiddenTabFont,
    ActiveHiddenTabFont, AImages, AImageIndex, False);
end;

procedure TaqVS2005UIDockingStyle.DoDrawSplitter(ACanvas: TCanvas;
  ARect: TRect; AOrientation: TaqSplitterOrientation);
begin
  ACanvas.Brush.Style := bsSolid;
  ACanvas.Brush.Color := SplitterColor;
  ACanvas.FillRect(ARect);
end;

procedure TaqVS2005UIDockingStyle.DoDrawTabButton(ACanvas: TCanvas;
  ARect: TRect; AState: TaqTabButtonState;
  AKind: TaqTabButtonKind);
const
  EdgeStyles                                                : array[TaqTabButtonState] of TaqEdgeStyle = (
    // tbsNormal, tbsHot, tbsPressed, tbsDisabled
    esNone, esFlat, esFlat, esNone);
begin
  if AKind = tbkClose then
  begin
    OffsetRect(ARect, 1, 0);
    ARect.Top := FLastTabTextRect.Top;
    ARect.Bottom := FLastTabTextRect.Bottom;
  end
  else
  begin
    with ACanvas do
    begin
      Brush.Style := bsSolid;
      Brush.Color := TabPaneColor.StartColor;
      FillRect(ARect);
    end;

    DrawEdge(ACanvas, ARect, EdgeStyles[AState], esNone, ebRect);
    InflateRect(ARect, -1, -1);
  end;
  DoDrawTabButtonWidget(ACanvas, ARect, AState, AKind);
end;

const
  ChamphedTabOffset                                         = 2;

procedure TaqVS2005UIDockingStyle.DoDrawTabItem(ACanvas: TCanvas;
  ARect: TRect; const ACaption: string; AState: TaqTabItemState;
  APosition: TaqTabItemPosition; AOrientation: TaqOrientation;
  AButtonAreaWidthBefore: Integer; AButtonAreaWidthAfter: Integer;
  ADrawImage: Boolean; AImages: TCustomImageList; AImageIndex: Integer);
const
  Round                                                     = 2;
var
  FillRect: TRect;
  SwapColors: Boolean;
  TbColor: TGradient;
  ActiveTab: Boolean;
  Points: array of TPoint;
  Offset: Integer;
  TabRect: TRect;
  TabGradient: TGradient;
begin
  ActiveTab := AState in [tisSelected, tisFocused];
  if AOrientation = orTop then
  begin
    TabRect := Rect(ARect.Left, ARect.Top + 2, ARect.Right, ARect.Bottom - ChamphedTabOffset);
    Offset := (TabRect.Bottom - TabRect.Top) * 3 div 4;
    ACanvas.Pen.Color := clBtnShadow;

    if ActiveTab then
      TabGradient := FActiveTriangleTabColor
    else
      TabGradient := FTriangleTabColor;

    TabGradient.Fill(ACanvas, TabRect, TabRect);
    TabRect.Top := TabRect.Top - 1;

    SetLength(Points, 5);
    Points[0] := Point(TabRect.Left, TabRect.Top);
    Points[1] := Point(TabRect.Left, (TabRect.Bottom + TabRect.Top) div 2);
    Points[2] := Point(TabRect.Left + Offset div 2, TabRect.Top + Round);
    Points[3] := Point(TabRect.Left + Offset div 2 + Round * 2, TabRect.Top);
    Points[4] := Point(TabRect.Right - Round, TabRect.Top);
    ACanvas.Brush.Color := TabPaneColor.StartColor;
    ACanvas.Pen.Color := TabPaneColor.StartColor;
    ACanvas.Polygon(Points);

    if ActiveTab or (APosition = tipFirst) then
    begin
      SetLength(Points, 3);
      Points[0] := Point(TabRect.Left - Offset div 2 + 1, TabRect.Bottom - 1);
      Points[1] := Point(TabRect.Left, (TabRect.Bottom + TabRect.Top + Round) div 2 + 1);
      Points[2] := Point(TabRect.Left, TabRect.Bottom - 1);
      ACanvas.Brush.Color := GetGradientColor(TabGradient);
      ACanvas.Pen.Color := GetGradientColor(TabGradient);
      ACanvas.Polygon(Points);
    end;

    if ActiveTab or (APosition = tipFirst) then
    begin
      SetLength(Points, 6);
      Points[0] := Point(TabRect.Left - Offset div 2, TabRect.Bottom);
      Points[1] := Point(TabRect.Left + Offset div 2, TabRect.Top + Round);
      Points[2] := Point(TabRect.Left + Offset div 2 + Round * 2, TabRect.Top);
      Points[3] := Point(TabRect.Right - Round, TabRect.Top);
      Points[4] := Point(TabRect.Right, TabRect.Top + Round);
      Points[5] := Point(TabRect.Right, TabRect.Bottom);
    end
    else
    begin
      SetLength(Points, 7);
      Points[0] := Point(TabRect.Left - 1, TabRect.Bottom);
      Points[1] := Point(TabRect.Left - 1, TabRect.Bottom - Offset div 2);
      Points[2] := Point(TabRect.Left + Offset div 2, TabRect.Top + Round);
      Points[3] := Point(TabRect.Left + Offset div 2 + Round * 2, TabRect.Top);
      Points[4] := Point(TabRect.Right - Round, TabRect.Top);
      Points[5] := Point(TabRect.Right, TabRect.Top + Round);
      Points[6] := Point(TabRect.Right, TabRect.Bottom);
    end;
    ACanvas.Pen.Color := clBtnShadow;
    if ActiveTab then
      ACanvas.Brush.Color := clBtnHighlight;

    ACanvas.Polyline(Points);

    if ActiveTab then
    begin
      ACanvas.Pen.Color := clBtnHighlight;
      ACanvas.MoveTo(TabRect.Left - Offset div 2 + 1, TabRect.Bottom);
      ACanvas.LineTo(TabRect.Right, TabRect.Bottom);
    end;
    InflateRect(TabRect, -1, -1);
    DoDrawTabItemContent(ACanvas, TabRect, ACaption, AState,
      AOrientation, False, True, FTriangleTabFont, FActiveTriangleTabFont, nil, -1, False);
  end
  else
  begin
    if ActiveTab then
      TbColor := ActiveTabColor
    else
      TbColor := TabColor;
    ACanvas.Pen.Style := psSolid;
    ACanvas.Pen.Color := clBtnShadow;
    if ActiveTab then
    begin
      FillRect := Rect(ARect.Left - 2, ARect.Top, ARect.Right, ARect.Bottom);
      if APosition = tipFirst then
        FillRect.Left := FillRect.Left - TabIndent + 1;
      case AOrientation of
        orTop:
          begin
            Inc(FillRect.Top, 2);
            ACanvas.RoundRect(FillRect.Left, FillRect.Top, FillRect.Right, FillRect.Bottom, 2, 2);
            Inc(FillRect.Top);
          end;
        orBottom:
          begin
            Dec(FillRect.Bottom, 2);

            ACanvas.RoundRect(FillRect.Left, FillRect.Top, FillRect.Right, FillRect.Bottom, 2, 2);
            Dec(FillRect.Bottom);
          end;
      end;
      Inc(FillRect.Left);
      Dec(FillRect.Right);
    end
    else
    begin
      FillRect := Rect(ARect.Left, ARect.Top + 4, ARect.Right, ARect.Bottom - 4);
      if APosition = tipFirst then
        FillRect.Left := FillRect.Left - TabIndent + 1;
      ACanvas.MoveTo(FillRect.Right - 1, FillRect.Top);
      ACanvas.LineTo(FillRect.Right - 1, FillRect.Bottom);
      Dec(FillRect.Right);
    end;
    if AOrientation = orTop then
      SwapColors := False
    else
      SwapColors := TbColor.FillType = gtVertical;
    TbColor.Fill(ACanvas, FillRect, FillRect, SwapColors);

    Inc(FillRect.Left, AButtonAreaWidthBefore + 1);
    Dec(FillRect.Right, AButtonAreaWidthAfter);
    DoDrawTabItemContent(ACanvas, FillRect, ACaption, AState,
      AOrientation, ADrawImage, True, TabFont, ActiveTabFont, AImages, AImageIndex, True);
  end;
end;

procedure TaqVS2005UIDockingStyle.DoDrawTabPane(ACanvas: TCanvas;
  ARect: TRect; AOrientation: TaqTabOrientation);
begin
  TabPaneColor.Fill(ACanvas, ARect, ARect);
  ACanvas.Pen.Style := psSolid;

  ACanvas.Brush.Color := clBtnHighlight;
  ACanvas.Pen.Color := clBtnShadow;
  case AOrientation of
    dtoTop:
      begin
        ACanvas.FillRect(Rect(ARect.Left, ARect.Bottom, ARect.Right, ARect.Bottom - ChamphedTabOffset));
        ACanvas.MoveTo(ARect.Left, ARect.Bottom - ChamphedTabOffset);
        ACanvas.LineTo(ARect.Right, ARect.Bottom - ChamphedTabOffset);
        ACanvas.MoveTo(ARect.Left, ARect.Bottom - ChamphedTabOffset);
        ACanvas.LineTo(ARect.Left, ARect.Bottom);
        ACanvas.MoveTo(ARect.Right - 1, ARect.Bottom - ChamphedTabOffset);
        ACanvas.LineTo(ARect.Right - 1, ARect.Bottom);
      end;
    dtoBottom:
      begin
        ACanvas.FillRect(Rect(ARect.Left, ARect.Top, ARect.Right, ARect.Top + 1));
        ACanvas.MoveTo(ARect.Left, ARect.Top + 1);
        ACanvas.LineTo(ARect.Right, ARect.Top + 1);
      end;
  end;
end;

function TaqVS2005UIDockingStyle.DoGetTabHeight(AState: TaqTabItemState;
  AOrientation: TaqTabOrientation; ADrawImage: Boolean;
  AImages: TCustomImageList; AImageIndex: Integer): Integer;
begin
  if AOrientation = dtoTop then
    Result := inherited DoGetTabHeight(AState,
      AOrientation, False, nil, -1)
  else
    Result := inherited DoGetTabHeight(AState,
      AOrientation, ADrawImage, AImages, AImageIndex);
end;

function TaqVS2005UIDockingStyle.DoGetTabWidth(const AText: string;
  AState: TaqTabItemState; APosition: TaqTabItemPosition;
  AOrientation: TaqTabOrientation; AButtonAreaWidth: Integer;
  ADrawImage: Boolean; AImages: TCustomImageList;
  AImageIndex: Integer): Integer;
var
  Fnt                                                       : TFont;
  str                                                       : string;
begin
  if AOrientation = dtoTop then
  begin
    str := StripHotkey(AText);

    if AState in [tisSelected, tisFocused] then
      Fnt := FActiveTriangleTabFont
    else
      Fnt := FTriangleTabFont;

    Result := TextMetrics(Fnt, str).X + (GetTabHeight(AState, AOrientation, False, nil, -1) * 3 div 4);

    Inc(Result, 2 * (FMetrics[dumTextSpacingX] + FMetrics[dumTabItemBorderX]));
    if AButtonAreaWidth > 0 then
      Inc(Result, AButtonAreaWidth + FMetrics[dumTextSpacingX]);
  end
  else
    Result := inherited DoGetTabWidth(AText, AState, APosition,
      AOrientation, AButtonAreaWidth,
      ADrawImage, AImages, AImageIndex);
end;

function TaqVS2005UIDockingStyle.GetCaptionButtonSelColor: TColorRef;
begin
  Result := ColorToRGB(clInactiveCaption);
end;

procedure TaqVS2005UIDockingStyle.AssignTo(Dest: TPersistent);
begin
  if Dest is TaqVS2005UIDockingStyle then
    with TaqVS2005UIDockingStyle(Dest) do
    begin
      BeginUpdate;
      try
        inherited;
        ActiveTriangleTabFont.Assign(Self.ActiveTriangleTabFont);
        TriangleTabFont.Assign(Self.TriangleTabFont);
        ActiveTriangleTabColor.Assign(Self.ActiveTriangleTabColor);
        TriangleTabColor.Assign(Self.TriangleTabColor);
      finally
        EndUpdate;
      end;
    end
  else
    inherited;
end;

function TaqVS2005UIDockingStyle.GetCaptionButtonsPosition: TaqCaptionButtonPostions;
begin
  Result := [bcpAfter];
end;

procedure TaqVS2005UIDockingStyle.SetActiveTriangleTabFont(const Value: TFont);
begin
  FActiveTriangleTabFont.Assign(Value);
end;

procedure TaqVS2005UIDockingStyle.SetActiveTriangleTabColor(const Value: TGradient);
begin
  if Value <> nil then
    FActiveTriangleTabColor.Assign(Value)
  else
    FActiveTriangleTabColor.Clear;
end;

procedure TaqVS2005UIDockingStyle.SetTriangleTabFont(const Value: TFont);
begin
  FTriangleTabFont.Assign(Value);
end;

procedure TaqVS2005UIDockingStyle.SetTriangleTabColor(
  const Value: TGradient);
begin
  if Value <> nil then
    FTriangleTabColor.Assign(Value)
  else
    FTriangleTabColor.Clear;
end;

function TaqVS2005UIDockingStyle.GetGradientColor(const Gradient: TGradient): TColor;
begin
  case Gradient.FillType of
    gtSolid: Result := Gradient.StartColor;
    gtHorizontal: Result := Gradient.StartColor;
    gtVertical: Result := Gradient.EndColor;
    gtHorzSplit: Result := Gradient.StartColor;
    gtVertSplit: Result := Gradient.StartColor;
  else
    Result := Gradient.EndColor;
  end;
end;

procedure TaqVS2005UIDockingStyle.GradientChange(Sender: TObject);
begin
  Change;
end;

procedure TaqVS2005UIDockingStyle.FontChange(Sender: TObject);
begin
  Change;
end;

end.

⌨️ 快捷键说明

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