View Issue Details

IDProjectCategoryView StatusLast Update
0006069JEDI VCL00 JVCL Componentspublic2015-09-14 13:20
ReporterstevegrAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
Product VersionDaily / GIT 
Target VersionFixed in Version3.48 
Summary0006069: TJvDBGrid.CalcSizingState -> Mantis 5818 issue NOT resolved.
DescriptionEarlier fix of Mantis 5818 issue produced a new bug when trying to resize partially displayed rightmost column. Latest fix (JVCL3-2013-01-20) reproduced the first bug. I upload the final fix for TJvDBGrid.CalcSizingState.

Regards,

Steve
Argonet Development Group
www.argonet.gr

TagsNo tags attached.

Activities

2013-01-20 14:33

 

ADG.txt (1,615 bytes)
procedure TJvDBGrid.CalcSizingState(X, Y: Integer; var State: TGridState;
  var Index: Longint; var SizingPos, SizingOfs: Integer;
  var FixedInfo: TGridDrawInfo);
var
	Coord: TGridCoord;
	DrawInfo: TGridDrawInfo; { My code }
begin
	inherited CalcSizingState(X, Y, State, Index, SizingPos, SizingOfs, FixedInfo);

	// do nothing if not authorized to size columns
	if not (dgColumnResize in Options) and not (csDesigning in ComponentState) then
		Exit;

	FCanResizeColumn := State = gsColSizing; //  If true, mouse double clicking can resize column.

(*
	// Mantis 5818: the inherited code sometimes gives an invalid index for the column
	if Index > LeftCol + VisibleColCount then
		Index := LeftCol + VisibleColCount;
*)

	{ Mantis 5818: fixed }
	{ My code }
	CalcDrawInfo(DrawInfo);
	if (DrawInfo.Horz.FullVisBoundary = DrawInfo.Horz.FixedBoundary) then begin
		Index := Index - 1;
	end;

	FResizeColumnIndex := Index - 1; // Store the column index to resize.

	if (State = gsNormal) and (Y <= RowHeights[0]) then
	begin
		Coord := MouseCoord(X, Y);
		CalcDrawInfo(FixedInfo);
		if CellRect(Coord.X, 0).Right - 5 < X then
		begin
			State := gsColSizing;
			Index := Coord.X;
			SizingPos := X;
			SizingOfs := X - CellRect(Coord.X, 0).Right;
		end;
		if CellRect(Coord.X, 0).Left + 5 > X then
		begin
			State := gsColSizing;
			Index := Coord.X - 1;
			SizingPos := X;
			SizingOfs := X - CellRect(Coord.X, 0).Left;
		end;
		if Index <= Byte(dgIndicator in Options) - 1 then
			State := gsNormal;
	end;
	FSizingIndex := Index;
	FSizingOfs := SizingOfs;
end;
ADG.txt (1,615 bytes)

stevegr

2013-02-15 19:59

reporter   ~0020429

Upload fix for Mantis 6061 issue. (Filename ADG2.txt)

(The fix is contributed by Argonet Development Group that implemented the column resizing feature. Any future remarks whould be much appreciated to improve this feature further).

Related issues: 6061, 6082.

2013-02-15 19:59

 

ADG2.txt (1,626 bytes)
procedure TJvDBGrid.CalcSizingState(X, Y: Integer; var State: TGridState;
  var Index: Longint; var SizingPos, SizingOfs: Integer;
  var FixedInfo: TGridDrawInfo);
var
	Coord: TGridCoord;
	DrawInfo: TGridDrawInfo;
begin
	inherited CalcSizingState(X, Y, State, Index, SizingPos, SizingOfs, FixedInfo);

	// do nothing if not authorized to size columns
	if not (dgColumnResize in Options) and not (csDesigning in ComponentState) then
		Exit;

	FCanResizeColumn := State = gsColSizing; //  If true, mouse double clicking can resize column.

	{ Mantis 5818: Index-out-of-range error when there is only one visible column partially displayed }
	CalcDrawInfo(DrawInfo);
	if (DrawInfo.Horz.FullVisBoundary = DrawInfo.Horz.FixedBoundary) then begin
		Index := Index - 1; // Index from inherited code has the value of 2.
	end;

	{ Store the column index to resize }
	if dgIndicator in Options then
		FResizeColumnIndex := Index - 1
	else
		FResizeColumnIndex := Index; // Mantis 6061

	if (State = gsNormal) and (Y <= RowHeights[0]) then
	begin
		Coord := MouseCoord(X, Y);
		CalcDrawInfo(FixedInfo);
		if CellRect(Coord.X, 0).Right - 5 < X then
		begin
			State := gsColSizing;
			Index := Coord.X;
			SizingPos := X;
			SizingOfs := X - CellRect(Coord.X, 0).Right;
		end;
		if CellRect(Coord.X, 0).Left + 5 > X then
		begin
			State := gsColSizing;
			Index := Coord.X - 1;
			SizingPos := X;
			SizingOfs := X - CellRect(Coord.X, 0).Left;
		end;
		if Index <= Byte(dgIndicator in Options) - 1 then
			State := gsNormal;
	end;
	FSizingIndex := Index;
	FSizingOfs := SizingOfs;
end;
ADG2.txt (1,626 bytes)

frank_jepsen

2013-02-19 08:14

reporter   ~0020438

Hi,

in my review in 6082 it handled all cases.
This should be used for JVCL.

Regards
Frank

stevegr

2013-02-19 12:59

reporter   ~0020440

That's excellent,

A new set of improvements regarding TJvDBGrid will be uploaded soon.

By the way, do you use LibreOffice or PostgreSQL?

frank_jepsen

2013-02-19 13:05

reporter   ~0020441

No I am working with BetterADODataset on MS-SQL in a JvDBUltimGrid with Ex-/Import to MS-Excel.

What Improvements?

AHUser

2013-05-25 14:26

developer   ~0020502

Fixed in svn revision 13517.

Issue History

Date Modified Username Field Change
2013-01-20 14:32 stevegr New Issue
2013-01-20 14:33 stevegr File Added: ADG.txt
2013-02-15 19:59 stevegr Note Added: 0020429
2013-02-15 19:59 stevegr File Added: ADG2.txt
2013-02-19 08:14 frank_jepsen Note Added: 0020438
2013-02-19 12:59 stevegr Note Added: 0020440
2013-02-19 13:05 frank_jepsen Note Added: 0020441
2013-05-25 14:26 AHUser Note Added: 0020502
2013-05-25 14:26 AHUser Status new => resolved
2013-05-25 14:26 AHUser Fixed in Version => Daily / SVN
2013-05-25 14:26 AHUser Resolution open => fixed
2013-05-25 14:26 AHUser Assigned To => AHUser
2015-09-14 13:20 obones Fixed in Version Daily / GIT => 3.48