Jump to content


Photo

Repaint bug in NextGrid v5.8

FixedCols; Repaint; NextGrid;

  • Please log in to reply
10 replies to this topic

#1 PhilW

PhilW
  • Members
  • 75 posts

Posted 29 March 2013 - 03:30 PM

Hi, Boki,

Hope you are well. There was a bug introduced from Grid v5.7.5 which effected the grid repaint when they are Fixed Columns set in the grid.

This bug was not present in the previous version, v5.7.5.

In the screenshot, please note that the desktop wallpaper is visible though the body of column 3. This grid has FixedCols = 2 property. The bug affects the column *next* to the last fixed column.

I guess that it is a "out-by-one" error; arising from the 0-based column index against the 1-based fixed column count.

Kind regards
PhilW.

Posted Image

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 29 March 2013 - 05:24 PM

Hm. I will check it.

I think that I didn't change anything there, but I will check it. I hope that I didn't edit v5 by accident when I am develop v6 side-by-side. I will fix this.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 30 March 2013 - 12:12 AM

Hi Phil,

For some reason all work fine for me. Maybe you have set custom drawing by accident for this column?
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#4 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 04 April 2013 - 11:37 AM

Hi Boki

I get the same problem in V5.8 (D2007 and DXE2) but I only get it at design time.


It's easy to recreate:
  • Make a new project
  • Add a NextGrid to the form
  • Add two text columns to the grid
  • Change the width of the first column to 100
  • Set FixedColumns to 1.

Click on the grid in design time so that the grid repaints - you will see the problem.

It only happens if FixedColumns > 0 and the last fixed column's width is greater than the width of the first column following the last fixed column.

For example:

if (FixedColumns = 1) and (Columns[0].Width = 80) and (Columns[1].Width = 80) --> No problem
if (FixedColumns = 0) and (Columns[0].Width = 100) and (Columns[1].Width = 80) --> No problem
if (FixedColumns = 1) and (Columns[0].Width = 100) and (Columns[1].Width = 80) --> Columns[1] is not repainted

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 05 April 2013 - 02:03 AM

Hi Deon,

Still nothing.

Can you please check my new version 5.8.5 to see if is still there? Thanks!
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 05 April 2013 - 09:06 AM

Hi Boki

I installed V5.8.5 but I still get the same problem (I tried to add a screenshot here, but I can't figure out how to upload an image - lol). It's still only doing it in design time however - at runtime it seems to be fine (on my machine at least).

I will try to compare the code from a working version of NextGrid with the latest version if I get time later today, and see if I can find anything.

#7 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 05 April 2013 - 12:33 PM

Hi Boki

The problem is in the TNxCustomGridControl.PaintReportRows procedure, in the second section (around line 4906) where (FLastRow < ARowCount) is False.

The problem is in this code:

Clipped := (I >= FFixedCols) and (DrawPos.X + Width < GetFixedWidth);

DrawPos.X := Left - Indent;

You are seting the value of Clipped while DrawPos.X still has the value of the Left of the previous column. You only update DrawPos.X to the value of the current column after Clipped has already been set. This causes Clipped to be True even though the column is not really clipped, and the column is then not painted.

To fix it, change the two lines around like this:

DrawPos.X := Left - Indent;

Clipped := (I >= FFixedCols) and (DrawPos.X + Width < GetFixedWidth);

or change the line that sets the value of Clipped so that it looks the same as it does in the first section of that procedure:

Clipped := (I >= FFixedCols) and (Left - Indent + Width < GetFixedWidth);

DrawPos.X := Left - Indent;


#8 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 05 April 2013 - 09:18 PM

Hi Deon,

I will try it. Really don't know why for me all works, but I will apply your code. I hope that other users may confirm your fix.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#9 PhilW

PhilW
  • Members
  • 75 posts

Posted 07 April 2013 - 05:42 PM

To fix it, change the two lines around like this:

DrawPos.X := Left - Indent;

Clipped := (I >= FFixedCols) and (DrawPos.X + Width < GetFixedWidth);


Yes, this works in run time. Thank you Deonvn. I can still see the problem in design time, but the important thing is that the run time is fixed.

Kind regards
PhilW.

#10 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 09 April 2013 - 08:41 PM

Hi guys,

Please tell me does this complete fix works?


procedure TNxCustomGridControl.PaintReportRows;
var
  I, Limit, Indent, ARowCount, RowHeight: Integer;
  Done, Clipped: Boolean;
  CellRect: TRect;
  DrawPos: TPoint;
begin
  { Start Pos }
  DrawPos := GetBodyRect.TopLeft;

  Limit := GetBodyRect.Top;
  Done := False;
  FLastRow := FFirstRow;
  ARowCount := RowCount;

  while not Done do
  begin

    if FLastRow < ARowCount then
    begin
      if GetRowVisible(FLastRow) then
      begin
        { Note: Prevent multiple calls
                of OnMeasureRowHeight }
        RowHeight := GetRowHeight(FLastRow);

        for i := 0 to Pred(Columns.Count) do
        begin
          with Columns.PositionItem[i] do
          begin
            if I >= FFixedCols then Indent := HorzScrollBar.Position else Indent := 0;

            DrawPos.X := Left - Indent;

            Clipped := (I >= FFixedCols) and (DrawPos.X + Width < GetFixedWidth);

            DrawPos.X := Left - Indent;

            if Visible
              and not Clipped
              and (DrawPos.X <= ClientWidth)
              and (DrawPos.X + Width >= 0) then
            begin

              CellRect := Bounds(DrawPos.X, DrawPos.Y, Width, RowHeight);

              if IntegralHeight
                and (limit + RowHeight + GridSpace[lpBottom] > GetBodyRect.Bottom)
              then DrawEmptyCell(Index, FLastRow, CellRect)
              else DrawCell(Index, FLastRow, CellRect);
            end;
          end;
        end;

        if goIndicator in Options then
        begin
          DrawRowIndicator(FLastRow, (FLastRow = SelectedRow) and (not InputSelected), (not InputSelected) and ((Selected[FLastRow]) or (FLastRow = SelectedRow)));
        end;

        Inc(Limit, RowHeight + GridSpace[lpBottom]);
        Inc(DrawPos.Y, RowHeight + GridSpace[lpBottom]);
      end;

      Inc(FLastRow);

    end
    else
    begin
      RowHeight := GetRowHeight(FLastRow);

      for i := 0 to Pred(Columns.Count) do
        with Columns.PositionItem[i] do
        begin
          if i >= FFixedCols
            then Indent := HorzScrollBar.Position
            else Indent := 0;

          DrawPos.X := Left - Indent;

          Clipped := (I >= FFixedCols) and (DrawPos.X + Width < GetFixedWidth);

          if Visible
            and not Clipped
            and (DrawPos.X <= ClientWidth)
            and (DrawPos.X + Width >= 0) then
          begin
            CellRect := Bounds(DrawPos.X, DrawPos.Y, Width, RowHeight);

            DrawEmptyCell(Index, FLastRow, CellRect);
          end;
        end;

      if goIndicator in Options
        then DrawRowIndicator(FLastRow, False, False);

      Inc(FLastRow);
      Inc(DrawPos.Y, RowHeight + GridSpace[lpBottom]);
      Inc(Limit, RowSize + GridSpace[lpBottom]);
    end;

    { Escape loop }
    if Limit > GetBodyRect.Bottom
      then Done := True;

  end;

  if goSelectFullRow in Options
    then DrawFocusCell;
end;

I will include it in next fix.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#11 deonvn

deonvn

    Senior Member

  • Honorable Members
  • PipPip
  • 313 posts

Posted 11 April 2013 - 10:29 AM

Hi Boki

Yes - that works fine.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users