View Issue Details

IDProjectCategoryView StatusLast Update
0006308JEDI VCL00 JVCL Componentspublic2015-09-21 17:47
ReporterbfrostAssigned ToAHUser 
PrioritynormalSeveritymajorReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.49 
Summary0006308: TJvOutlookBar draws buttons behind bottom page button.
DescriptionWhen the page button count is greater than the page area, the buttons are drawn on past the bottom page button and are visible 'behind' the page button.

The problem is in DrawButtons where truncation of further buttons should be performed before attempting drawing. The problem is visible with 32 pixel and 48 pixel images, I have not tried 16-pixel buttons.

My fix is attached. There are two places where '//BJF ***' indicates the changes.



TagsNo tags attached.

Activities

2014-07-25 11:38

 

DrawButtons.txt (4,832 bytes)
procedure TJvCustomOutlookBar.DrawButtons(Index: Integer);
var
  I: Integer;
  R, R2, R3: TRect;
  C: TColor;
  SavedDC: Integer;
  SavedColor: TColor;
  {$IFDEF JVCLThemesEnabled}
  ThemedColor: Cardinal;
  Details: TThemedElementDetails;
  {$ENDIF JVCLThemesEnabled}
begin
  if csDestroying in ComponentState then
    Exit;
  if (Index < 0) or (Index >= Pages.Count) or (Pages[Index].Buttons = nil) or
    (Pages[Index].Buttons.Count <= 0) then
    Exit;
  R2 := GetPageRect(Index);
  R := GetButtonRect(Index, Pages[Index].TopButtonIndex);
  C := Canvas.Pen.Color;
  Canvas.Font := Pages[Index].Font;

  {$IFDEF JVCLThemesEnabled}
  if Themed then
  begin
    Details := StyleServices.GetElementDetails(ttbButtonNormal);
    with Details do
      GetThemeColor(StyleServices.Theme[Element], Part, State, TMT_TEXTCOLOR, ThemedColor);
  end;
  {$ENDIF JVCLThemesEnabled}
  try
    Canvas.Brush.Style := bsClear;
    for I := Pages[Index].TopButtonIndex to Pages[Index].Buttons.Count - 1 do
    begin


      // BJF ***
      If GetButtonRect(Index, I ).Bottom >= R2.Bottom then

        Break;




      Canvas.Font := Pages[Index].Font;
//      Canvas.Rectangle(R);  // DEBUG
      {$IFDEF JVCLThemesEnabled}
      if Themed then
        Canvas.Font.Color := ThemedColor;
      {$ENDIF JVCLThemesEnabled}
      if Pages[Index].Buttons[I].Down then
      begin
        Canvas.Font := Pages[Index].DownFont;
        DrawButtonFrame(Index, I, I);
      end;
      if DoDrawButton(R, I, Pages[Index].Buttons[I].Down, I = FLastButtonIndex) then
        case Pages[Index].ButtonSize of
          olbsLarge:
            begin
              SavedColor := Canvas.Font.Color;
              try
                SavedDC := SaveDC(Canvas.Handle);
                try
                  if LargeImages <> nil then
                    LargeImages.Draw(Canvas, R.Left + ((R.Right - R.Left) - LargeImages.Width) div 2, R.Top + 4,
                      Pages[Index].Buttons[I].ImageIndex,

                      Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled);
                finally
                  RestoreDC(Canvas.Handle, SavedDC);
                end;
                R3 := GetButtonTextRect(ActivePageIndex, I);
                SetBkMode(Canvas.Handle, TRANSPARENT);
                if not Pages[Index].Enabled or not Pages[Index].Buttons[I].Enabled then
                begin
                  if ColorToRGB(Pages[Index].Color) = ColorToRGB(clGrayText) then
                    Canvas.Font.Color := PageBtnProps.Face//clBtnFace
                  else
                    Canvas.Font.Color := clGrayText;
                end;
                if FWordWrap then
                  DrawText(Canvas.Handle, PChar(Pages[Index].Buttons[I].Caption), -1, R3,
                           DT_WORDBREAK or DT_CENTER or DT_VCENTER)
                else
                  DrawText(Canvas.Handle, PChar(Pages[Index].Buttons[I].Caption), -1, R3,
                           DT_EXPANDTABS or DT_SINGLELINE or DT_CENTER or DT_VCENTER);
              finally
                Canvas.Font.Color := SavedColor;
              end;
            end;
          olbsSmall:
            begin
              SavedColor := Canvas.Font.Color;
              try
                SavedDC := SaveDC(Canvas.Handle);
                try
                  if SmallImages <> nil then
                    SmallImages.Draw(Canvas, R.Left + 2, R.Top + 2,
                      Pages[Index].Buttons[I].ImageIndex,
                      Pages[Index].Enabled and Pages[Index].Buttons[I].Enabled);
                finally
                  RestoreDC(Canvas.Handle, SavedDC);
                end;
                R3 := GetButtonTextRect(ActivePageIndex, I);
                SetBkMode(Canvas.Handle, TRANSPARENT);
                if not Pages[Index].Enabled or not Pages[Index].Buttons[I].Enabled then
                begin
                  if ColorToRGB(Pages[Index].Color) = ColorToRGB(clGrayText) then
                    Canvas.Font.Color := PageBtnProps.Face//clBtnFace
                  else
                    Canvas.Font.Color := clGrayText;
                end;
                InflateRect(R3, -4, 0);
                DrawText(Canvas.Handle, PChar(Pages[Index].Buttons[I].Caption), -1, R3,
                  DT_EXPANDTABS or DT_SINGLELINE or DT_LEFT or DT_VCENTER or DT_NOCLIP or DT_EDITCONTROL);
              finally
                Canvas.Font.Color := SavedColor;
              end;
            end;
        end;
      OffsetRect(R, 0, GetButtonHeight(Index, I));

      // BJF ***
      //      if R.Top >= R2.Bottom then
      //        Break;


    end;
  finally
    Canvas.Font := Self.Font;
    Canvas.Pen.Color := C;
  end;
end;
DrawButtons.txt (4,832 bytes)

obones

2014-09-03 11:41

administrator   ~0021037

Please provide the zipped sources of a sample application showing this

2014-09-03 14:43

 

demo.zip (11,996 bytes)

bfrost

2014-09-03 14:46

reporter   ~0021045

File DEMO.ZIP shows the problem. Compile under XE5 or XE6 (but any IDE should show this) and run. Click on the first bar page (folder) to see the visible icons. Now drag the bottom of the form upwards to gradually hide the icons and you will see that they continue to be visible 'through' the buttons of the other bar pages.

Issue History

Date Modified Username Field Change
2014-07-25 11:38 bfrost New Issue
2014-07-25 11:38 bfrost File Added: DrawButtons.txt
2014-09-03 11:41 obones Note Added: 0021037
2014-09-03 11:41 obones Status new => feedback
2014-09-03 14:43 bfrost File Added: demo.zip
2014-09-03 14:46 bfrost Note Added: 0021045
2014-10-01 10:50 AHUser Status feedback => resolved
2014-10-01 10:50 AHUser Fixed in Version => Daily / GIT
2014-10-01 10:50 AHUser Resolution open => fixed
2014-10-01 10:50 AHUser Assigned To => AHUser
2015-09-21 17:47 obones Fixed in Version Daily / GIT => 3.49