mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-08 15:41:12 +02:00
LCL: Fix grid ellipsis editor layout. Issue #34307
This commit is contained in:
parent
655bd2ba0d
commit
f8f1652fd4
@ -325,6 +325,8 @@ type
|
|||||||
procedure VisibleChanging; override;
|
procedure VisibleChanging; override;
|
||||||
function SendChar(AChar: TUTF8Char): Integer;
|
function SendChar(AChar: TUTF8Char): Integer;
|
||||||
procedure WndProc(var TheMessage : TLMessage); override;
|
procedure WndProc(var TheMessage : TLMessage); override;
|
||||||
|
procedure CustomAlignPosition(AControl: TControl; var ANewLeft, ANewTop, ANewWidth,
|
||||||
|
ANewHeight: Integer; var AlignRect: TRect; AlignInfo: TAlignInfo); override;
|
||||||
public
|
public
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
procedure AddEditor(aEditor: TWinControl; aAlign: TAlign; ActiveCtrl:boolean);
|
procedure AddEditor(aEditor: TWinControl; aAlign: TAlign; ActiveCtrl:boolean);
|
||||||
@ -5561,7 +5563,7 @@ end;
|
|||||||
function TCustomGrid.GetEditorBorderStyle: TBorderStyle;
|
function TCustomGrid.GetEditorBorderStyle: TBorderStyle;
|
||||||
begin
|
begin
|
||||||
result := bsSingle;
|
result := bsSingle;
|
||||||
if FEditor = FStringEditor then
|
if (FEditor = FStringEditor) or (FEditor = FButtonStringEditor) then
|
||||||
Result := FStringEditor.BorderStyle
|
Result := FStringEditor.BorderStyle
|
||||||
else if FEditor = FPickListEditor then
|
else if FEditor = FPickListEditor then
|
||||||
Result := FPickListEditor.BorderStyle;
|
Result := FPickListEditor.BorderStyle;
|
||||||
@ -8573,8 +8575,18 @@ end;
|
|||||||
procedure TCustomGrid.EditorPos;
|
procedure TCustomGrid.EditorPos;
|
||||||
var
|
var
|
||||||
msg: TGridMessage;
|
msg: TGridMessage;
|
||||||
CellR: TRect;
|
CellR, editorBounds: TRect;
|
||||||
PosValid: Boolean;
|
PosValid: Boolean;
|
||||||
|
|
||||||
|
procedure CalcEditorBounds(aEditor: TWinControl; var refRect: TRect);
|
||||||
|
begin
|
||||||
|
if (aEditor = FStringEditor) and (EditorBorderStyle = bsNone) then
|
||||||
|
refRect := TWSCustomGridClass(WidgetSetClass).
|
||||||
|
GetEditorBoundsFromCellRect(Canvas, refRect, GetColumnLayout(FCol, False))
|
||||||
|
else
|
||||||
|
AdjustInnerCellRect(refRect);
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
{$ifdef dbgGrid} DebugLn('Grid.EditorPos INIT');{$endif}
|
{$ifdef dbgGrid} DebugLn('Grid.EditorPos INIT');{$endif}
|
||||||
if HandleAllocated and (FEditor<>nil) then begin
|
if HandleAllocated and (FEditor<>nil) then begin
|
||||||
@ -8605,13 +8617,16 @@ begin
|
|||||||
Canvas.Font.Assign(Font);
|
Canvas.Font.Assign(Font);
|
||||||
|
|
||||||
if FEditorOptions and EO_AUTOSIZE = EO_AUTOSIZE then begin
|
if FEditorOptions and EO_AUTOSIZE = EO_AUTOSIZE then begin
|
||||||
if (FEditor = FStringEditor) and (EditorBorderStyle = bsNone) then
|
CalcEditorBounds(FEditor, CellR);
|
||||||
CellR := TWSCustomGridClass(WidgetSetClass).
|
|
||||||
GetEditorBoundsFromCellRect(Canvas, CellR, GetColumnLayout(FCol, False))
|
|
||||||
else
|
|
||||||
AdjustInnerCellRect(CellR);
|
|
||||||
FEditor.BoundsRect := CellR;
|
FEditor.BoundsRect := CellR;
|
||||||
end else begin
|
end else begin
|
||||||
|
if FEditor=FButtonStringEditor then begin
|
||||||
|
// here we ensure that FStringEditor which is the ActiveControl in
|
||||||
|
// FButtonStringEditor get its bounds right
|
||||||
|
editorBounds := CellR;
|
||||||
|
CalcEditorBounds(FStringEditor, editorBounds);
|
||||||
|
FStringEditor.BoundsRect := editorBounds;
|
||||||
|
end;
|
||||||
Msg.LclMsg.msg:=GM_SETBOUNDS;
|
Msg.LclMsg.msg:=GM_SETBOUNDS;
|
||||||
Msg.CellRect:=CellR;
|
Msg.CellRect:=CellR;
|
||||||
Msg.Grid:=Self;
|
Msg.Grid:=Self;
|
||||||
@ -9852,7 +9867,7 @@ begin
|
|||||||
FButtonStringEditor := TCompositeCellEditor.Create(nil);
|
FButtonStringEditor := TCompositeCellEditor.Create(nil);
|
||||||
FButtonStringEditor.Name:='ButtonTextEditor';
|
FButtonStringEditor.Name:='ButtonTextEditor';
|
||||||
FButtonStringEditor.Visible:=False;
|
FButtonStringEditor.Visible:=False;
|
||||||
FButtonStringEditor.AddEditor(FStringEditor, alClient, true);
|
FButtonStringEditor.AddEditor(FStringEditor, alCustom, true);
|
||||||
FButtonStringEditor.AddEditor(FButtonEditor, alRight, false);
|
FButtonStringEditor.AddEditor(FButtonEditor, alRight, false);
|
||||||
|
|
||||||
FFastEditing := True;
|
FFastEditing := True;
|
||||||
@ -13667,6 +13682,16 @@ begin
|
|||||||
inherited WndProc(TheMessage);
|
inherited WndProc(TheMessage);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCompositeCellEditor.CustomAlignPosition(AControl: TControl;
|
||||||
|
var ANewLeft, ANewTop, ANewWidth, ANewHeight: Integer; var AlignRect: TRect;
|
||||||
|
AlignInfo: TAlignInfo);
|
||||||
|
begin
|
||||||
|
// Currently there is only one custom aligned control, so no provision is for
|
||||||
|
// calling CustomAlignInsertBefore() or share the space with other editors.
|
||||||
|
aNewLeft := 0;
|
||||||
|
aNewWidth := AlignRect.Width;
|
||||||
|
aNewTop := alignRect.Height div 2 - aNewHeight div 2;
|
||||||
|
end;
|
||||||
|
|
||||||
function TCompositeCellEditor.DoUTF8KeyPress(var UTF8Key: TUTF8Char): boolean;
|
function TCompositeCellEditor.DoUTF8KeyPress(var UTF8Key: TUTF8Char): boolean;
|
||||||
begin
|
begin
|
||||||
|
Loading…
Reference in New Issue
Block a user