mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-15 23:29:50 +02:00
TStringGrid/TDrawGrid Columns fixes, bugs #1359,#1367
git-svn-id: trunk@7988 -
This commit is contained in:
parent
7b07d9012d
commit
0235d8ac82
@ -1577,17 +1577,6 @@ procedure TCustomDbGrid.DefaultDrawCell(aCol, aRow: Integer; aRect: TRect;
|
||||
else
|
||||
result := dsInactive;
|
||||
end;
|
||||
procedure FixRectangle;
|
||||
begin
|
||||
case Canvas.TextStyle.Alignment of
|
||||
Classes.taLeftJustify: Inc(aRect.Left, 3);
|
||||
Classes.taRightJustify: Dec(aRect.Right, 3);
|
||||
end;
|
||||
case Canvas.TextStyle.Layout of
|
||||
tlTop: Inc(aRect.Top, 3);
|
||||
tlBottom: Dec(aRect.Bottom, 3);
|
||||
end;
|
||||
end;
|
||||
var
|
||||
S: string;
|
||||
F: TField;
|
||||
@ -1599,10 +1588,8 @@ begin
|
||||
dbgOut('>');
|
||||
{$endif}
|
||||
end else
|
||||
if (aRow=0)and(ACol>=FixedCols) then begin
|
||||
FixRectangle;
|
||||
Canvas.TextRect(ARect,ARect.Left,ARect.Top,GetColumnTitle(aCol));
|
||||
end;
|
||||
if (aRow=0)and(ACol>=FixedCols) then
|
||||
DrawCellText(aCol,aRow,aRect,aState,GetColumnTitle(aCol));
|
||||
end else begin
|
||||
F := GetFieldFromGridColumn(aCol);
|
||||
case ColumnEditorStyle(aCol, F) of
|
||||
@ -1616,8 +1603,7 @@ begin
|
||||
S := '(blob)';
|
||||
end else
|
||||
S := '';
|
||||
FixRectangle;
|
||||
Canvas.TextRect(Arect,ARect.Left,ARect.Top, S);
|
||||
DrawCellText(aCol,aRow,aRect,aState,S);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -2504,31 +2490,16 @@ procedure TCustomDbGrid.DefaultDrawColumnCell(const Rect: TRect;
|
||||
else
|
||||
result := dsInactive;
|
||||
end;
|
||||
function FixRectangle: TRect;
|
||||
begin
|
||||
result := Rect;
|
||||
case Canvas.TextStyle.Alignment of
|
||||
Classes.taLeftJustify: Inc(Result.Left, 3);
|
||||
Classes.taRightJustify: Dec(Result.Right, 3);
|
||||
end;
|
||||
case Canvas.TextStyle.Layout of
|
||||
tlTop: Inc(Result.Top, 3);
|
||||
tlBottom: Dec(Result.Bottom, 3);
|
||||
end;
|
||||
end;
|
||||
var
|
||||
S: string;
|
||||
F: TField;
|
||||
R: TRect;
|
||||
begin
|
||||
if gdFixed in State then begin
|
||||
if (DataCol=0)and FDrawingActiveRecord then
|
||||
DrawArrow(Canvas, Rect, GetDataSetState)
|
||||
else
|
||||
if (DataCol>=FixedCols) then begin
|
||||
R := FixRectangle();
|
||||
Canvas.TextRect(R,R.Left,R.Top,GetColumnTitle(DataCol));
|
||||
end;
|
||||
if (DataCol>=FixedCols) then
|
||||
DrawCellText(0{dummy}, DataCol{dummy}, Rect, State,GetColumnTitle(DataCol));
|
||||
end else begin
|
||||
F := GetFieldFromGridColumn(DataCol);
|
||||
case ColumnEditorStyle(DataCol, F) of
|
||||
@ -2542,8 +2513,7 @@ begin
|
||||
S := '(blob)';
|
||||
end else
|
||||
S := '';
|
||||
FixRectangle();
|
||||
Canvas.TextRect(rect,Rect.Left,Rect.Top, S);
|
||||
DrawCellText(0, DataCol, Rect, State, S);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
@ -69,6 +69,7 @@ const
|
||||
|
||||
const
|
||||
DEFCOLWIDTH = 64;
|
||||
DEFROWHEIGHT= 20;
|
||||
|
||||
type
|
||||
EGridException = class(Exception);
|
||||
@ -675,7 +676,8 @@ type
|
||||
procedure DrawBorder;
|
||||
procedure DrawByRows; virtual;
|
||||
procedure DrawCell(aCol,aRow:Integer; aRect:TRect; aState:TGridDrawState); virtual;
|
||||
procedure DrawCellGrid(aCol,aRow: Integer; aRect: TRect; astate: TGridDrawState); virtual;
|
||||
procedure DrawCellGrid(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState); virtual;
|
||||
procedure DrawCellText(aCol,aRow: Integer; aRect: TRect; aState: TGridDrawState; aText: String); virtual;
|
||||
procedure DrawColRowMoving;
|
||||
procedure DrawEdges;
|
||||
//procedure DrawFixedCells; virtual;
|
||||
@ -785,7 +787,7 @@ type
|
||||
property Columns: TGridColumns read GetColumns write SetColumns stored IsColumnsStored;
|
||||
property ColWidths[aCol: Integer]: Integer read GetColWidths write SetColWidths;
|
||||
property DefaultColWidth: Integer read FDefColWidth write SetDefColWidth default DEFCOLWIDTH;
|
||||
property DefaultRowHeight: Integer read FDefRowHeight write SetDefRowHeight default 20;
|
||||
property DefaultRowHeight: Integer read FDefRowHeight write SetDefRowHeight default DEFROWHEIGHT;
|
||||
property DefaultDrawing: Boolean read FDefaultDrawing write SetDefaultDrawing default True;
|
||||
property DefaultTextStyle: TTextStyle read FDefaultTextStyle write FDefaultTextStyle;
|
||||
property DragDx: Integer read FDragDx write FDragDx;
|
||||
@ -2845,6 +2847,20 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.DrawCellText(aCol, aRow: Integer; aRect: TRect;
|
||||
aState: TGridDrawState; aText: String);
|
||||
begin
|
||||
case Canvas.TextStyle.Alignment of
|
||||
Classes.taLeftJustify: Inc(aRect.Left, 3);
|
||||
Classes.taRightJustify: Dec(aRect.Right, 3);
|
||||
end;
|
||||
case Canvas.TextStyle.Layout of
|
||||
tlTop: Inc(aRect.Top, 3);
|
||||
tlBottom: Dec(aRect.Bottom, 3);
|
||||
end;
|
||||
Canvas.TextRect(aRect,ARect.Left,ARect.Top, aText);
|
||||
end;
|
||||
|
||||
procedure TCustomGrid.OnTitleFontChanged(Sender: TObject);
|
||||
begin
|
||||
if FColumns.Enabled then
|
||||
@ -3765,13 +3781,16 @@ begin
|
||||
if csDestroying in ComponentState then
|
||||
exit;
|
||||
|
||||
if AColumn=nil then
|
||||
if AColumn=nil then begin
|
||||
if Columns.Enabled then begin
|
||||
InternalSetColCount( FixedCols + Columns.VisibleCount )
|
||||
if FixedCols + Columns.VisibleCount <> ColCount then
|
||||
InternalSetColCount( FixedCols + Columns.VisibleCount )
|
||||
else
|
||||
VisualChange;
|
||||
end else
|
||||
if not (csloading in ComponentState) then
|
||||
ColCount := FixedCols + 1
|
||||
else begin
|
||||
ColCount := FixedCols + 1
|
||||
end else begin
|
||||
aCol := Columns.IndexOf(AColumn);
|
||||
if ACol>=0 then begin
|
||||
if aColumn.WidthChanged then
|
||||
@ -4108,7 +4127,6 @@ begin
|
||||
end;
|
||||
gsColSizing:
|
||||
begin
|
||||
{.$ifdef UseXOR}
|
||||
if FUseXORFeatures then begin
|
||||
if FPrevLine then
|
||||
DrawXorVertLine(FPrevValue);
|
||||
@ -4116,12 +4134,10 @@ begin
|
||||
FPrevValue := -1;
|
||||
ResizeColumn(FSplitter.x, x-FSplitter.y);
|
||||
end;
|
||||
{.$endif}
|
||||
HeaderSized( True, FSplitter.X);
|
||||
end;
|
||||
gsRowSizing:
|
||||
begin
|
||||
{.$ifdef UseXOR}
|
||||
if FUseXORFeatures then begin
|
||||
if FPrevLine then
|
||||
DrawXorHorzLine(FPrevValue);
|
||||
@ -4129,7 +4145,6 @@ begin
|
||||
FPrevValue := -1;
|
||||
ResizeRow(FSplitter.y, y-FSplitter.x);
|
||||
end;
|
||||
{.$endif}
|
||||
HeaderSized( False, FSplitter.Y);
|
||||
end;
|
||||
end;
|
||||
@ -5588,7 +5603,7 @@ begin
|
||||
RowCount:=Cfg.GetValue('grid/design/rowcount', 5);
|
||||
FixedCols:=Cfg.GetValue('grid/design/fixedcols', 1);
|
||||
FixedRows:=Cfg.GetValue('grid/design/fixedrows', 1);
|
||||
DefaultRowheight:=Cfg.GetValue('grid/design/defaultrowheight', 20);
|
||||
DefaultRowheight:=Cfg.GetValue('grid/design/defaultrowheight', DEFROWHEIGHT);
|
||||
DefaultColWidth:=Cfg.getValue('grid/design/defaultcolwidth', DEFCOLWIDTH);
|
||||
|
||||
Path:='grid/design/columns/';
|
||||
@ -5696,8 +5711,8 @@ begin
|
||||
FScrollbars:=ssAutoBoth;
|
||||
fGridState:=gsNormal;
|
||||
fDefColWidth:=DEFCOLWIDTH;
|
||||
fDefRowHeight:=20;//18;
|
||||
fGridLineColor:=clSilver;//clGray;
|
||||
fDefRowHeight:=DEFROWHEIGHT;
|
||||
fGridLineColor:=clSilver;
|
||||
FGridLineStyle:=psSolid;
|
||||
fFocusColor:=clRed;
|
||||
FFixedColor:=clBtnFace;
|
||||
@ -6188,14 +6203,24 @@ end;
|
||||
|
||||
procedure TCustomDrawGrid.DrawCell(aCol,aRow: Integer; aRect: TRect;
|
||||
aState:TGridDrawState);
|
||||
var
|
||||
OldDefaultDrawing: boolean;
|
||||
begin
|
||||
if Assigned(OnDrawCell) and not(CsDesigning in ComponentState) then begin
|
||||
PrepareCanvas(aCol, aRow, aState);
|
||||
if DefaultDrawing then
|
||||
Canvas.FillRect(aRect);
|
||||
OnDrawCell(Self,aCol,aRow,aRect,aState)
|
||||
end else
|
||||
end else begin
|
||||
OldDefaultDrawing:=FDefaultDrawing;
|
||||
FDefaultDrawing:=True;
|
||||
try
|
||||
PrepareCanvas(aCol, aRow, aState);
|
||||
finally
|
||||
FDefaultDrawing:=OldDefaultDrawing;
|
||||
end;
|
||||
DefaultDrawCell(aCol,aRow,aRect,aState);
|
||||
end;
|
||||
inherited DrawCellGrid(aCol,aRow,aRect,aState);
|
||||
end;
|
||||
|
||||
@ -6368,18 +6393,18 @@ end;
|
||||
procedure TCustomDrawGrid.DefaultDrawCell(aCol, aRow: Integer; var aRect: TRect;
|
||||
aState: TGridDrawState);
|
||||
var
|
||||
OldDefaultDrawing: boolean;
|
||||
C: TGridColumn;
|
||||
begin
|
||||
OldDefaultDrawing:=FDefaultDrawing;
|
||||
FDefaultDrawing:=True;
|
||||
try
|
||||
PrepareCanvas(aCol, aRow, aState);
|
||||
finally
|
||||
FDefaultDrawing:=OldDefaultDrawing;
|
||||
end;
|
||||
if goColSpanning in Options then CalcCellExtent(acol, arow, aRect);
|
||||
Canvas.FillRect(aRect);
|
||||
|
||||
if Columns.Enabled and (gdFixed in aState) and (aRow=0) then begin
|
||||
// draw the column title if there is any
|
||||
C := ColumnFromGridColumn(aCol);
|
||||
if C<>nil then
|
||||
DrawCellText(aCol,aRow,aRect,aState,C.Title.Caption);
|
||||
end;
|
||||
|
||||
if (goFixedRowNumbering in Options) and (FixedCols >= 1) and (aCol = 0) then
|
||||
Canvas.TextRect(aRect,ARect.Left+3,ARect.Top+3, IntTostr(aRow));
|
||||
end;
|
||||
@ -6658,17 +6683,8 @@ procedure TCustomStringGrid.DrawCell(aCol, aRow: Integer; aRect: TRect;
|
||||
aState: TGridDrawState);
|
||||
begin
|
||||
inherited DrawCell(aCol, aRow, aRect, aState);
|
||||
if DefaultDrawing then begin
|
||||
case Canvas.TextStyle.Alignment of
|
||||
Classes.taLeftJustify: Inc(aRect.Left, 3);
|
||||
Classes.taRightJustify: Dec(aRect.Right, 3);
|
||||
end;
|
||||
case Canvas.TextStyle.Layout of
|
||||
tlTop: Inc(aRect.Top, 3);
|
||||
tlBottom: Dec(aRect.Bottom, 3);
|
||||
end;
|
||||
Canvas.TextRect(aRect,ARect.Left,ARect.Top, Cells[aCol,aRow]);
|
||||
end;
|
||||
if DefaultDrawing then
|
||||
DrawCellText(aCol, aRow, aRect, aState, Cells[aCol,aRow]);
|
||||
end;
|
||||
|
||||
function TCustomStringGrid.GetEditText(aCol, aRow: Integer): string;
|
||||
|
Loading…
Reference in New Issue
Block a user