Skip to content

Enhancement: Paint a splitter frame in TSpTBXCustomSplitter. #10

@pyscripter

Description

@pyscripter

The SpTBXSplitter looks better with frame painted. In my fork I use a function:

procedure PaintSplitterFrame(Canvas : TCanvas; IsVertical: Boolean; var R: TRect);
var
  FrameBrush: HBRUSH;
begin
  if IsVertical then
    InflateRect(R, -1, 2)
  else
    InflateRect(R, 2, -1);
  OffsetRect(R, 1, 1);
  FrameBrush := CreateSolidBrush(ColorToRGB(CurrentSkin.GetThemedSystemColor(clBtnHighlight)));
  FrameRect(Canvas.Handle, R, FrameBrush);
  DeleteObject(FrameBrush);
  OffsetRect(R, -2, -2);
  FrameBrush := CreateSolidBrush(ColorToRGB(CurrentSkin.GetThemedSystemColor(clBtnShadow)));
  FrameRect(Canvas.Handle, R, FrameBrush);
  DeleteObject(FrameBrush);
end;

and in TSpTBXCustomSplitter.Paint added one line:

procedure TSpTBXCustomSplitter.Paint;
var
  ClientR, R, DragHandleR: TRect;
  C1, C2: TColor;
  PaintDefault: Boolean;
begin
  ClientR := ClientRect;
  PaintDefault := True;
  DoDrawBackground(Canvas, ClientR, pstPrePaint, PaintDefault);
  if PaintDefault then begin
    // Paint background
    if SkinManager.GetSkinType = sknSkin then
      CurrentSkin.PaintBackground(Canvas, ClientR, skncSplitter, sknsNormal, True, False, IsVertical)
    else begin
      if Color = clNone then
        Canvas.Brush.Color := CurrentSkin.GetThemedSystemColor(clBtnFace)
      else
        Canvas.Brush.Color := Color;
      SpFillRect(Canvas, ClientR, Canvas.Brush.Color);
      PaintSplitterFrame(Canvas, IsVertical, ClientR);  //<-- added
    end;

Alternatively, there could be an option for framing the splitter.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions