Project JEDI - Issue Tracker
Mantis Bugtracker

Viewing Issue Simple Details Jump to Notes ] View Advanced ] Issue History ] Print ]
ID Category Severity Reproducibility Date Submitted Last Update
0005813 [JEDI VCL] 00 JVCL Components minor always 2012-02-28 11:13 2012-09-10 14:15
Reporter fschenckel View Status public  
Assigned To obones
Priority normal Resolution fixed  
Status resolved   Product Version Daily / GIT
Summary 0005813: jvDocking - JvDockVSNetStyle Drawing transparent icon
Description I 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 Information in 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;


Tags No tags attached.
Attached Files ? file icon JvDockVSNetStyle.pas [^] (117,612 bytes) 2012-02-28 11:13

- Relationships

-  Notes
(0019612)
obones (administrator)
2012-02-28 13:49

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.
(0019613)
fschenckel (reporter)
2012-02-28 14:11

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 !
(0019614)
obones (administrator)
2012-02-28 16:49

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


Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker