Object inspector: Solve the redraw problem with Boolean CheckBox editor using AutoSize instead of SetBounds. Issue #22347.

git-svn-id: trunk@46880 -
This commit is contained in:
juha 2014-11-18 16:28:11 +00:00
parent 79d5a6bf8e
commit 0be2affe39

View File

@ -956,9 +956,8 @@ begin
begin begin
Name:='ValueCheckBox'; Name:='ValueCheckBox';
Visible:=false; Visible:=false;
AutoSize:=false;
Enabled:=false; Enabled:=false;
SetBounds(0,-30,Width,Height); // hidden AutoSize:=true; // SetBounds does not work for CheckBox, AutoSize does.
Parent:=Self; Parent:=Self;
OnMouseDown := @ValueControlMouseDown; OnMouseDown := @ValueControlMouseDown;
OnMouseMove := @ValueControlMouseMove; OnMouseMove := @ValueControlMouseMove;
@ -1661,7 +1660,7 @@ begin
FCurrentButton:=nil; FCurrentButton:=nil;
end; end;
FCurrentEditorLookupRoot:=nil; FCurrentEditorLookupRoot:=nil;
if (NewIndex>=0) and (NewIndex<FRows.Count) then if (NewIndex >= 0) and (NewIndex < FRows.Count) then
begin begin
NewRow:=Rows[NewIndex]; NewRow:=Rows[NewIndex];
ScrollToItem(NewIndex); ScrollToItem(NewIndex);
@ -2572,38 +2571,32 @@ var
function CompareRectangles(r1,r2:TRect):boolean; function CompareRectangles(r1,r2:TRect):boolean;
begin begin
Result:=(r1.Left=r2.Left) and (r1.Top=r2.Top) and (r1.Right=r2.Right) Result := (r1.Left=r2.Left) and (r1.Top=r2.Top)
and (r1.Bottom=r2.Bottom); and (r1.Right=r2.Right) and (r1.Bottom=r2.Bottom);
end;
function CompareTopLeft(r1,r2:TRect):boolean;
begin
Result := (r1.Left=r2.Left) and (r1.Top=r2.Top);
end; end;
// AlignEditComponents // AlignEditComponents
begin begin
if ItemIndex>=0 if ItemIndex>=0 then
then begin begin
RRect := RowRect(ItemIndex); RRect := RowRect(ItemIndex);
EditCompRect := RRect; EditCompRect := RRect;
Dec(EditCompRect.Bottom); Dec(EditCompRect.Bottom);
if Layout = oilHorizontal if Layout = oilHorizontal then
then begin EditCompRect.Left := RRect.Left + SplitterX
EditCompRect.Left := RRect.Left + SplitterX;
{$IFDEF UseOICheckBox}
{$IFDEF WINDOWS}
// Make the edit control short, it reveals redraw problems in many places
// on Windows. Normally the long control hides the problems.
// Note! This has nothing to do with CheckBox editors directly.
// CheckBox only revealed the problem originally because its caption
// does not cover all the drawing area.
EditCompRect.Right:=EditCompRect.Left+50; // This line can be removed
{$ENDIF}
{$ENDIF}
end
else begin else begin
EditCompRect.Top := RRect.Top + GetNameRowHeight; EditCompRect.Top := RRect.Top + GetNameRowHeight;
EditCompRect.Left := RRect.Left + GetTreeIconX(ItemIndex) + Indent; EditCompRect.Left := RRect.Left + GetTreeIconX(ItemIndex) + Indent;
end; end;
if FCurrentButton<>nil then begin if FCurrentButton<>nil then
begin
// edit dialog button // edit dialog button
with EditBtnRect do begin with EditBtnRect do begin
Top := EditCompRect.Top; Top := EditCompRect.Top;
@ -2616,14 +2609,22 @@ begin
FCurrentButton.BoundsRect:=EditBtnRect; FCurrentButton.BoundsRect:=EditBtnRect;
//DebugLn(['TOICustomPropertyGrid.AlignEditComponents FCurrentButton.BoundsRect=',dbgs(FCurrentButton.BoundsRect),' EditBtnRect=',dbgs(EditBtnRect)]); //DebugLn(['TOICustomPropertyGrid.AlignEditComponents FCurrentButton.BoundsRect=',dbgs(FCurrentButton.BoundsRect),' EditBtnRect=',dbgs(EditBtnRect)]);
end; end;
if FCurrentEdit<>nil then begin if FCurrentEdit<>nil then
begin
// resize the edit component // resize the edit component
Dec(EditCompRect.Left); Dec(EditCompRect.Left);
Dec(EditCompRect.Top); Dec(EditCompRect.Top);
Inc(EditCompRect.Bottom); Inc(EditCompRect.Bottom);
//debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect)); //debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect));
if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then begin if not CompareTopLeft(FCurrentEdit.BoundsRect,EditCompRect) then
FCurrentEdit.BoundsRect:=EditCompRect; begin
if FCurrentEdit is TCheckBox then
begin
TCheckBox(FCurrentEdit).Top := EditCompRect.Top;
TCheckBox(FCurrentEdit).Left := EditCompRect.Left;
end
else
FCurrentEdit.BoundsRect:=EditCompRect;
if FCurrentEdit is TComboBox then if FCurrentEdit is TComboBox then
TComboBox(FCurrentEdit).ItemHeight:=EditCompRect.Bottom-EditCompRect.Top-6; TComboBox(FCurrentEdit).ItemHeight:=EditCompRect.Bottom-EditCompRect.Top-6;
FCurrentEdit.Invalidate; FCurrentEdit.Invalidate;