mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-22 13:19:28 +02:00
Object Inspector: Fix the alignment of Checkbox editor.
git-svn-id: trunk@46991 -
This commit is contained in:
parent
3cc613425f
commit
7d9296fe56
@ -1743,8 +1743,8 @@ end;
|
|||||||
function TOICustomPropertyGrid.GetNameRowHeight: Integer;
|
function TOICustomPropertyGrid.GetNameRowHeight: Integer;
|
||||||
begin
|
begin
|
||||||
Result := Abs(FNameFont.Height);
|
Result := Abs(FNameFont.Height);
|
||||||
if Result = 0
|
if Result = 0 then
|
||||||
then Result := 16;
|
Result := 16;
|
||||||
Inc(Result, 2); // margin
|
Inc(Result, 2); // margin
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -2581,6 +2581,7 @@ end;
|
|||||||
procedure TOICustomPropertyGrid.AlignEditComponents;
|
procedure TOICustomPropertyGrid.AlignEditComponents;
|
||||||
var
|
var
|
||||||
RRect,EditCompRect,EditBtnRect:TRect;
|
RRect,EditCompRect,EditBtnRect:TRect;
|
||||||
|
TopMargin: Integer;
|
||||||
|
|
||||||
function CompareRectangles(r1,r2:TRect):boolean;
|
function CompareRectangles(r1,r2:TRect):boolean;
|
||||||
begin
|
begin
|
||||||
@ -2594,7 +2595,6 @@ begin
|
|||||||
begin
|
begin
|
||||||
RRect := RowRect(ItemIndex);
|
RRect := RowRect(ItemIndex);
|
||||||
EditCompRect := RRect;
|
EditCompRect := RRect;
|
||||||
Dec(EditCompRect.Bottom);
|
|
||||||
|
|
||||||
if Layout = oilHorizontal then
|
if Layout = oilHorizontal then
|
||||||
EditCompRect.Left := RRect.Left + SplitterX
|
EditCompRect.Left := RRect.Left + SplitterX
|
||||||
@ -2609,7 +2609,7 @@ begin
|
|||||||
with EditBtnRect do begin
|
with EditBtnRect do begin
|
||||||
Top := EditCompRect.Top;
|
Top := EditCompRect.Top;
|
||||||
Left := EditCompRect.Right - 20;
|
Left := EditCompRect.Right - 20;
|
||||||
Bottom := EditCompRect.Bottom;
|
Bottom := EditCompRect.Bottom - 1;
|
||||||
Right := EditCompRect.Right;
|
Right := EditCompRect.Right;
|
||||||
EditCompRect.Right := Left;
|
EditCompRect.Right := Left;
|
||||||
end;
|
end;
|
||||||
@ -2622,9 +2622,16 @@ begin
|
|||||||
// resize the edit component
|
// resize the edit component
|
||||||
if (FCurrentEdit is TEdit) or (FCurrentEdit is TComboBox) then
|
if (FCurrentEdit is TEdit) or (FCurrentEdit is TComboBox) then
|
||||||
begin
|
begin
|
||||||
|
{$IFnDEF LCLGTK2}
|
||||||
Dec(EditCompRect.Left);
|
Dec(EditCompRect.Left);
|
||||||
|
{$ENDIF}
|
||||||
Dec(EditCompRect.Top);
|
Dec(EditCompRect.Top);
|
||||||
Inc(EditCompRect.Bottom);
|
end
|
||||||
|
else if FCurrentEdit is TCheckBox then
|
||||||
|
begin // Align CheckBox to the middle vertically
|
||||||
|
TopMargin := (EditCompRect.Bottom - EditCompRect.Top - ValueCheckBox.Height) div 2;
|
||||||
|
Inc(EditCompRect.Top, TopMargin);
|
||||||
|
Inc(EditCompRect.Left); // and move it a little right.
|
||||||
end;
|
end;
|
||||||
//debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect));
|
//debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect));
|
||||||
if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then
|
if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then
|
||||||
|
@ -3262,6 +3262,7 @@ var
|
|||||||
Details: TThemedElementDetails;
|
Details: TThemedElementDetails;
|
||||||
Check: TThemedButton;
|
Check: TThemedButton;
|
||||||
Sz: TSize;
|
Sz: TSize;
|
||||||
|
TopMargin, RightMargin: Integer;
|
||||||
begin
|
begin
|
||||||
BRect := ARect;
|
BRect := ARect;
|
||||||
fUseCheckbox := FPropertyHook.GetCheckboxForBoolean;
|
fUseCheckbox := FPropertyHook.GetCheckboxForBoolean;
|
||||||
@ -3274,13 +3275,20 @@ begin
|
|||||||
Check := tbCheckBoxUncheckedNormal;
|
Check := tbCheckBoxUncheckedNormal;
|
||||||
Details := ThemeServices.GetElementDetails(Check);
|
Details := ThemeServices.GetElementDetails(Check);
|
||||||
Sz := ThemeServices.GetDetailSize(Details);
|
Sz := ThemeServices.GetDetailSize(Details);
|
||||||
Inc(BRect.Top, 3);
|
TopMargin := (ARect.Bottom - ARect.Top - Sz.cy) div 2;
|
||||||
|
Inc(BRect.Top, TopMargin);
|
||||||
|
{$IFDEF LCLGTK2}
|
||||||
|
RightMargin := 3; // A hack. GTK2 checkbox itself has a left margin.
|
||||||
|
{$ELSE}
|
||||||
|
RightMargin := 1;
|
||||||
|
{$ENDIF}
|
||||||
|
Inc(BRect.Left, RightMargin);
|
||||||
BRect.Right := BRect.Left + Sz.cx;
|
BRect.Right := BRect.Left + Sz.cx;
|
||||||
BRect.Bottom := BRect.Top + Sz.cy;
|
BRect.Bottom := BRect.Top + Sz.cy;
|
||||||
ThemeServices.DrawElement(ACanvas.Handle, Details, BRect, nil);
|
ThemeServices.DrawElement(ACanvas.Handle, Details, BRect, nil);
|
||||||
// Write text after the box
|
// Write text after the box
|
||||||
BRect := ARect;
|
BRect := ARect;
|
||||||
Inc(BRect.Left, Sz.cx+2);
|
Inc(BRect.Left, Sz.cx+RightMargin+2);
|
||||||
end;
|
end;
|
||||||
inherited PropDrawValue(ACanvas, BRect, AState);
|
inherited PropDrawValue(ACanvas, BRect, AState);
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user