Recent

Author Topic: StringGrid bug: Far right column text exceeds cell space (carbon) [Fixed]  (Read 6217 times)

Hansaplast

  • Hero Member
  • *****
  • Posts: 711
  • Tweaking4All.com
    • Tweaking4All
I'm running into a bug (I think) under Carbon.

I have a TStringGrid with 3 column, the entire grid is a little wider than the column to keep space for a vertical scrollbar if needed.
If the length of the text of a cell on the far right exceeds the size of a cell it will continue writing outside of the cell.

Am I missing a setting/property? Or is this a bug?

I'm using Lazarus 0.9.31, FPC 2.4.2, XCode 3.2.5, MacOS X 10.6.6 (Intel).
« Last Edit: February 06, 2011, 07:32:43 am by Hansaplast »

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: StringGrid bug: Far right column text exceeds cell space (carbon)
« Reply #1 on: February 05, 2011, 06:26:53 am »
That does look like a TStringGrid bug. Maybe file a bug report in Mantis and include your screenshot and ideally a small example that reproduces the problem. There are some known issues with TStringGrid on Carbon, but whether this is related or new I don't know.

The Orpheus TOvcTable does work sort of on Carbon, but not perfectly since some of the Win API calls the code makes are not implemented except on Windows (of course). It does work well on Windows, though. You might try the example. I had hoped at one time to get TOvcTable working on Carbon too - I've used it with Delphi for many years and it's really a powerful grid control. TStringGrid on Delphi was never really intended to be a full-features grid, so a lot of 3rd party grids stepped in to fill the void.

Thanks.

-Phil

Hansaplast

  • Hero Member
  • *****
  • Posts: 711
  • Tweaking4All.com
    • Tweaking4All
Re: StringGrid bug: Far right column text exceeds cell space (carbon)
« Reply #2 on: February 06, 2011, 07:08:44 am »
Thanks (again) Phil :)

As you might have noticed; I've been pretty active with Lazarus these past few days, and am enjoying it more and more :)
I'm glad I can contribute (using Carbon) in the shape of reporting bugs, just wish I could do something about fixing the bugs, maybe  one of these days. It's a little over my head right now ...

I've created a few applications over the years using Delphi, and I'm kind-a sticking to the rule to use 3rd party components as less as possible. I've ran in too many issues when it comes to version on Delphi - seems with Lazarus even more sensitive. (I've successfully recompiled my app on Windows, but I can't even get Lazarus [daily build] to run under Ubuntu - see my post elsewhere)

I'll try to create a small app that reproduces this bug if I can't find it in bug tracker and post a bug :)

Hansaplast

  • Hero Member
  • *****
  • Posts: 711
  • Tweaking4All.com
    • Tweaking4All
Re: StringGrid bug: Far right column text exceeds cell space (carbon)
« Reply #3 on: February 06, 2011, 07:16:33 am »
I think I found what is causing this;

I'm using the onDrawItem event to draw alternating colors and alternating selection colors.
(I know, the grid already support alternating row colors, but I wanted alternating row colors for selections as well)
It just dawned to me (while creating the example) that this might cause (using canvas.TextOut) the text to exceed the cell size.
No idea yet how to prevent it yet ...

Hansaplast

  • Hero Member
  • *****
  • Posts: 711
  • Tweaking4All.com
    • Tweaking4All
Re: StringGrid bug: Far right column text exceeds cell space (carbon)
« Reply #4 on: February 06, 2011, 07:32:20 am »
Figured it out ... :)
In case it helps someone;

Code: [Select]

procedure Form1.StringGrid1DrawCell(Sender: TObject; aCol, aRow: Integer; aRect: TRect; aState: TGridDrawState);
var tmpString:string;
begin
...

  tmpString:='something very very very long that does not fit in a cell';

...

  while StringGrid1.Canvas.TextWidth(tmpString)>(aRect.Right-aRect.Left-4) do
    tmpString:=Copy(tmpString,0,Length(tmpString)-1);

  StringGrid1.Canvas.TextOut(aRect.Left+2,aRect.Top+2,tmpString); 
end;
 
 

The "-4" was needed as in some cases the TextWidth appears a few pixels of?

 

TinyPortal © 2005-2018