Object Inspector: Fix the alignment of Checkbox editor.

git-svn-id: trunk@46991 -
This commit is contained in:
juha 2014-11-26 00:35:13 +00:00
parent 3cc613425f
commit 7d9296fe56
2 changed files with 22 additions and 7 deletions

View File

@ -1743,8 +1743,8 @@ end;
function TOICustomPropertyGrid.GetNameRowHeight: Integer;
begin
Result := Abs(FNameFont.Height);
if Result = 0
then Result := 16;
if Result = 0 then
Result := 16;
Inc(Result, 2); // margin
end;
@ -2581,6 +2581,7 @@ end;
procedure TOICustomPropertyGrid.AlignEditComponents;
var
RRect,EditCompRect,EditBtnRect:TRect;
TopMargin: Integer;
function CompareRectangles(r1,r2:TRect):boolean;
begin
@ -2594,7 +2595,6 @@ begin
begin
RRect := RowRect(ItemIndex);
EditCompRect := RRect;
Dec(EditCompRect.Bottom);
if Layout = oilHorizontal then
EditCompRect.Left := RRect.Left + SplitterX
@ -2609,7 +2609,7 @@ begin
with EditBtnRect do begin
Top := EditCompRect.Top;
Left := EditCompRect.Right - 20;
Bottom := EditCompRect.Bottom;
Bottom := EditCompRect.Bottom - 1;
Right := EditCompRect.Right;
EditCompRect.Right := Left;
end;
@ -2622,9 +2622,16 @@ begin
// resize the edit component
if (FCurrentEdit is TEdit) or (FCurrentEdit is TComboBox) then
begin
{$IFnDEF LCLGTK2}
Dec(EditCompRect.Left);
{$ENDIF}
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;
//debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect));
if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then

View File

@ -3262,6 +3262,7 @@ var
Details: TThemedElementDetails;
Check: TThemedButton;
Sz: TSize;
TopMargin, RightMargin: Integer;
begin
BRect := ARect;
fUseCheckbox := FPropertyHook.GetCheckboxForBoolean;
@ -3274,13 +3275,20 @@ begin
Check := tbCheckBoxUncheckedNormal;
Details := ThemeServices.GetElementDetails(Check);
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.Bottom := BRect.Top + Sz.cy;
ThemeServices.DrawElement(ACanvas.Handle, Details, BRect, nil);
// Write text after the box
BRect := ARect;
Inc(BRect.Left, Sz.cx+2);
Inc(BRect.Left, Sz.cx+RightMargin+2);
end;
inherited PropDrawValue(ACanvas, BRect, AState);
end;