rtticontrols: fix fixedcols/fixedrows rttigrid properties, issue #29967

git-svn-id: trunk@52145 -
This commit is contained in:
jesus 2016-04-08 07:54:52 +00:00
parent 38d823ee5e
commit f976741718
2 changed files with 40 additions and 9 deletions

View File

@ -203,6 +203,8 @@ type
Shift: TShiftState); virtual; Shift: TShiftState); virtual;
procedure WriteCellText(aRect: TRect; const aText: string); procedure WriteCellText(aRect: TRect; const aText: string);
procedure UnlinkPropertyEditor(aEditor: TWinControl); procedure UnlinkPropertyEditor(aEditor: TWinControl);
procedure SetFixedCols(const AValue: Integer); override;
procedure SetFixedRows(const AValue: Integer); override;
public public
constructor Create(TheOwner: TComponent); override; constructor Create(TheOwner: TComponent); override;
destructor Destroy; override; destructor Destroy; override;
@ -485,10 +487,10 @@ end;
{$IFDEF DebugEditor} {$IFDEF DebugEditor}
procedure TTICustomGrid.DebugEditor(msg: String; aEditor: TWinControl); procedure TTICustomGrid.DebugEditor(msg: String; aEditor: TWinControl);
begin begin
Write(Msg,': Editor='); DbgOut(Msg,': Editor=');
if aEditor=nil then Write('nil') if aEditor=nil then DbgOut('nil')
else Write(AEditor.className); else DbgOut(AEditor.className);
WriteLn; DebugLn;
end; end;
{$ENDIF} {$ENDIF}
@ -531,6 +533,9 @@ var
ToID: Integer; ToID: Integer;
FromID: integer; FromID: integer;
begin begin
if FProperties=nil then
exit;
ClearProperties; ClearProperties;
// set column/row count for objects // set column/row count for objects
if ListDirection=tldObjectsAsRows then begin if ListDirection=tldObjectsAsRows then begin
@ -599,6 +604,7 @@ begin
FExtraBtnEditor.Parent := nil; FExtraBtnEditor.Parent := nil;
UnlinkPropertyEditor(FExtraBtnEditor); UnlinkPropertyEditor(FExtraBtnEditor);
FExtraBtnEditor.Visible := false; FExtraBtnEditor.Visible := false;
FExtraBtnEditor := nil;
UnlockEditor; UnlockEditor;
end; end;
end; end;
@ -676,6 +682,12 @@ var
CurProp: TTIGridProperty; CurProp: TTIGridProperty;
PropName: String; PropName: String;
begin begin
if FProperties=nil then begin
// still creating ancestor grid
Editor := nil;
FExtraBtnEditor := nil;
exit;
end;
NewEditor:=nil; NewEditor:=nil;
MapCell(Col,Row,ObjectIndex,PropertyIndex,CellType); MapCell(Col,Row,ObjectIndex,PropertyIndex,CellType);
if CellType=tgctValue then begin if CellType=tgctValue then begin
@ -816,6 +828,18 @@ begin
PropLink.SetObjectAndProperty(nil,''); PropLink.SetObjectAndProperty(nil,'');
end; end;
procedure TTICustomGrid.SetFixedCols(const AValue: Integer);
begin
inherited SetFixedCols(AValue);
RebuildGridLayout;
end;
procedure TTICustomGrid.SetFixedRows(const AValue: Integer);
begin
inherited SetFixedRows(AValue);
RebuildGridLayout;
end;
constructor TTICustomGrid.Create(TheOwner: TComponent); constructor TTICustomGrid.Create(TheOwner: TComponent);
begin begin
inherited Create(TheOwner); inherited Create(TheOwner);
@ -863,6 +887,7 @@ begin
end; end;
FProperties.Clear; FProperties.Clear;
Editor := nil; Editor := nil;
FExtraBtnEditor := nil;
end; end;
procedure TTICustomGrid.DefaultDrawCell(aCol, aRow: Integer; var aRect: TRect; procedure TTICustomGrid.DefaultDrawCell(aCol, aRow: Integer; var aRect: TRect;
@ -1109,10 +1134,16 @@ begin
end; end;
PropertyIndexValid:=(PropertyIndex>=0) and (PropertyIndex<PropertyCount); PropertyIndexValid:=(PropertyIndex>=0) and (PropertyIndex<PropertyCount);
ObjectIndexValid:=(ObjectIndex>=0) and (ObjectIndex<TIObjectCount); ObjectIndexValid:=(ObjectIndex>=0) and (ObjectIndex<TIObjectCount);
// tldObjectsAsRows:
// PropertyIndex is a Col index, needs to be checked against ObjectHeaderLines (fixedCols)
// ObjectIndex is a Row index, needs to be checked against PropHeaderLines (fixedRows)
// tldObjectsAsColumns:
// PropertyIndex is a Row index, needs to be checked against ObjectHeaderLines (fixedRows)
// ObjectIndex is a Col index, needs to be checked against PropHeaderLines (fixedCols)
PropertyIndexInHeader:=(PropertyIndex<0) PropertyIndexInHeader:=(PropertyIndex<0)
and (PropertyIndex>=-PropHeaderLines); and (PropertyIndex>=-ObjectHeaderLines);
ObjectIndexInHeader:=(ObjectIndex<0) ObjectIndexInHeader:=(ObjectIndex<0)
and (ObjectIndex>=-ObjectHeaderLines); and (ObjectIndex>=-PropHeaderLines);
//debugln('TTICustomGrid.MapCell A ',dbgs(aCol),',',dbgs(aRow),' ', //debugln('TTICustomGrid.MapCell A ',dbgs(aCol),',',dbgs(aRow),' ',
// dbgs(PropertyIndex),',',dbgs(ObjectIndex),' ', // dbgs(PropertyIndex),',',dbgs(ObjectIndex),' ',
// dbgs(PropertyIndexValid),',',dbgs(ObjectIndexValid), // dbgs(PropertyIndexValid),',',dbgs(ObjectIndexValid),
@ -1124,14 +1155,14 @@ begin
else if ObjectIndexInHeader then begin else if ObjectIndexInHeader then begin
if ObjectIndex=-1 then if ObjectIndex=-1 then
CellType:=tgctPropName CellType:=tgctPropName
else else if Objectindex=-2 then
CellType:=tgctPropNameAlt; CellType:=tgctPropNameAlt;
end; end;
end else if ObjectIndexValid then begin end else if ObjectIndexValid then begin
if PropertyIndexInHeader then begin if PropertyIndexInHeader then begin
if PropertyIndex=-1 then if PropertyIndex=-1 then
CellType:=tgctObjectName CellType:=tgctObjectName
else else if PropertyIndex=-2 then
CellType:=tgctObjectNameAlt; CellType:=tgctObjectNameAlt;
end; end;
end else begin end else begin

View File

@ -853,7 +853,6 @@ type
procedure SetDefRowHeight(AValue: Integer); procedure SetDefRowHeight(AValue: Integer);
procedure SetDefaultDrawing(const AValue: Boolean); procedure SetDefaultDrawing(const AValue: Boolean);
procedure SetEditor(AValue: TWinControl); procedure SetEditor(AValue: TWinControl);
procedure SetFixedRows(const AValue: Integer);
procedure SetFocusColor(const AValue: TColor); procedure SetFocusColor(const AValue: TColor);
procedure SetGridLineColor(const AValue: TColor); procedure SetGridLineColor(const AValue: TColor);
procedure SetGridLineStyle(const AValue: TPenStyle); procedure SetGridLineStyle(const AValue: TPenStyle);
@ -1076,6 +1075,7 @@ type
procedure SetBorderStyle(NewStyle: TBorderStyle); override; procedure SetBorderStyle(NewStyle: TBorderStyle); override;
procedure SetFixedcolor(const AValue: TColor); virtual; procedure SetFixedcolor(const AValue: TColor); virtual;
procedure SetFixedCols(const AValue: Integer); virtual; procedure SetFixedCols(const AValue: Integer); virtual;
procedure SetFixedRows(const AValue: Integer); virtual;
procedure SetRawColWidths(ACol: Integer; AValue: Integer); procedure SetRawColWidths(ACol: Integer; AValue: Integer);
procedure SetSelectedColor(const AValue: TColor); virtual; procedure SetSelectedColor(const AValue: TColor); virtual;
procedure ShowCellHintWindow(APoint: TPoint); procedure ShowCellHintWindow(APoint: TPoint);