View Issue Details

IDProjectCategoryView StatusLast Update
0005813JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReporterfschenckelAssigned Toobones 
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.46 
Summary0005813: jvDocking - JvDockVSNetStyle Drawing transparent icon
DescriptionI couldn't get the icons transparently drawn on tabs.

I made a modification to draw them transparently.
You will find the modifications in the Additional information memo.

The modified unit is jvDockVSNetStyle.
Attached, you will find my jvDockVSNetStyle unit.
Additional Informationin private section of TjvDockVSChannel :

  TJvDockVSChannel = class(TCustomControl)
  private
    ...
    FtmpIcon : TIcon;



  destructor TJvDockVSChannel.Destroy;
  begin
    ...
    if Assigned(FtmpIcon) then
      FtmpIcon.Free;
    inherited Destroy;
  end;

procedure TJvDockVSChannel.Paint;
var
  I: Integer;

  procedure DrawSingleBlock(Block: TJvDockVSBlock);
  var
    DrawRect: TRect;
    I: Integer;
    OldGraphicsMode: Integer;
    VisiblePaneCount: Integer;

    procedure AdjustImagePos;
    begin
      if Align = alLeft then
      begin
        Inc(DrawRect.Left, 3);
        Inc(DrawRect.Top, 4);
      end
      else
      if Align = alTop then
      begin
        Inc(DrawRect.Left, 4);
        Inc(DrawRect.Top, 2);
      end
      else
      if Align = alRight then
      begin
        Inc(DrawRect.Left, 4);
        Inc(DrawRect.Top, 4);
      end
      else
      if Align = alBottom then
      begin
        Inc(DrawRect.Left, 4);
        Inc(DrawRect.Top, 3);
      end;
    end;

  begin
    VisiblePaneCount := 0;

    for I := 0 to Block.VSPaneCount - 1 do
    begin
      if not Block.VSPane[I].FVisible then
        Continue;

      GetBlockRect(Block, I, DrawRect);
      Canvas.Brush.Color := TabColor;
      Canvas.FillRect(DrawRect);
      Canvas.Brush.Color := clGray;
      Canvas.FrameRect(DrawRect);

      AdjustImagePos;

      if TJvDockVSNETTabServerOption(FStyleLink.DockStyle.TabServerOption).ShowTabImages then begin
        if not assigned(FtmpIcon) then
          FtmpIcon := TIcon.Create;

        Block.FImageList.GetIcon(i, FtmpIcon);
        FtmpIcon.Transparent := True;
        Canvas.Draw(DrawRect.Left, DrawRect.Top, FtmpIcon);
      end;

      if Block.ActivePane = Block.VSPane[I] then
      begin
        if Align in [alTop, alBottom] then
          Inc(DrawRect.Left, Block.InactiveBlockWidth)
        else
        if Align in [alLeft, alRight] then
        begin
          Inc(DrawRect.Top, Block.InactiveBlockWidth);
          if Align = alLeft then
            DrawRect.Left := 15
          else
            DrawRect.Left := 20;
          DrawRect.Right := DrawRect.Left + (DrawRect.Bottom - DrawRect.Top);
        end;
        Canvas.Brush.Color := TabColor;
        Canvas.Pen.Color := clBlack;

        Dec(DrawRect.Right, 3);

        OldGraphicsMode := SetGraphicsMode(Canvas.Handle, GM_ADVANCED);
        Canvas.Brush.Style := bsClear;
        DrawText(Canvas.Handle, PChar(Block.VSPane[I].FDockForm.Caption), -1, DrawRect, DT_END_ELLIPSIS or DT_NOCLIP);
        SetGraphicsMode(Canvas.Handle, OldGraphicsMode);
      end;
      Inc(VisiblePaneCount);
    end;
    if VisiblePaneCount > 0 then
      Inc(FCurrentPos, FBlockInterval);
  end;

begin
  inherited Paint;

  FCurrentPos := FBlockStartOffset;
  for I := 0 to BlockCount - 1 do
    DrawSingleBlock(Block[I]);
end;


TagsNo tags attached.

Activities

2012-02-28 11:13

 

JvDockVSNetStyle.pas (117,612 bytes)

obones

2012-02-28 13:49

administrator   ~0019612

Wouldn't have it been easier to simply call Draw in the following manner:

Block.FImageList.Draw(Canvas, DrawRect.Left, DrawRect.Top, I, dsTransparent, itImage);

I tried it with D2007, it works just fine.

fschenckel

2012-02-28 14:11

reporter   ~0019613

Yes, much more efficient !
I've tested it on XE it works also.
The only drawback is icons with alpha channels won't be drawn transparently (Black instead of transparent).
Don't know why we have this different behavior !

But I don't think it's a big issue !

obones

2012-02-28 16:49

administrator   ~0019614

This is now in SVN

Issue History

Date Modified Username Field Change
2012-02-28 11:13 fschenckel New Issue
2012-02-28 11:13 fschenckel File Added: JvDockVSNetStyle.pas
2012-02-28 13:49 obones Note Added: 0019612
2012-02-28 13:49 obones Status new => feedback
2012-02-28 14:11 fschenckel Note Added: 0019613
2012-02-28 16:49 obones Note Added: 0019614
2012-02-28 16:49 obones Status feedback => resolved
2012-02-28 16:49 obones Fixed in Version => Daily / SVN
2012-02-28 16:49 obones Resolution open => fixed
2012-02-28 16:49 obones Assigned To => obones
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46