IDE: Minor optimization and formatting in OI

git-svn-id: trunk@37831 -
This commit is contained in:
juha 2012-07-01 07:56:25 +00:00
parent e0d69ad952
commit 9f3c8533e3

View File

@ -441,7 +441,7 @@ type
function PropertyPath(Index: integer):string; function PropertyPath(Index: integer):string;
function PropertyPath(Row: TOIPropertyGridRow):string; function PropertyPath(Row: TOIPropertyGridRow):string;
function TopMax: integer; function TopMax: integer;
procedure BuildPropertyList(OnlyIfNeeded: boolean = false); procedure BuildPropertyList(OnlyIfNeeded: boolean = False);
procedure Clear; procedure Clear;
procedure Paint; override; procedure Paint; override;
procedure PropEditLookupRootChange; procedure PropEditLookupRootChange;
@ -1322,8 +1322,7 @@ begin
end; end;
{$ENDIF} {$ENDIF}
if (OldChangeStep<>FChangeStep) then begin if (OldChangeStep<>FChangeStep) then begin
// the selection has changed // the selection has changed => CurRow does not exist any more
// => CurRow does not exist any more
exit; exit;
end; end;
@ -1383,8 +1382,7 @@ begin
{$ENDIF} {$ENDIF}
if (OldChangeStep<>FChangeStep) then begin if (OldChangeStep<>FChangeStep) then begin
// the selection has changed // the selection has changed => CurRow does not exist any more
// => CurRow does not exist any more
RefreshPropertyValues; RefreshPropertyValues;
exit; exit;
end; end;
@ -1576,24 +1574,17 @@ begin
{$ENDIF} {$ENDIF}
if paValueList in EditorAttributes then begin if paValueList in EditorAttributes then begin
FCurrentEdit:=ValueComboBox; FCurrentEdit:=ValueComboBox;
if paPickList in EditorAttributes then begin
// text field should be readonly
if paCustomDrawn in EditorAttributes then
ValueComboBox.Style:=csOwnerDrawVariable
else
ValueComboBox.Style:=csDropDownList;
end else begin
if paCustomDrawn in EditorAttributes then if paCustomDrawn in EditorAttributes then
ValueComboBox.Style:=csOwnerDrawVariable ValueComboBox.Style:=csOwnerDrawVariable
else if paPickList in EditorAttributes then
ValueComboBox.Style:=csDropDownList // text field should be readonly
else else
ValueComboBox.Style:=csDropDown; ValueComboBox.Style:=csDropDown;
end;
ValueComboBox.MaxLength:=NewRow.Editor.GetEditLimit; ValueComboBox.MaxLength:=NewRow.Editor.GetEditLimit;
ValueComboBox.Sorted:=paSortList in NewRow.Editor.GetAttributes; ValueComboBox.Sorted:=paSortList in NewRow.Editor.GetAttributes;
ValueComboBox.Enabled:=not NewRow.IsReadOnly; ValueComboBox.Enabled:=not NewRow.IsReadOnly;
// Do not fill the items here, because it can be very slow. // Do not fill the items here, because it can be very slow.
// Just fill in some values and update the values, before the combobox // Just fill in some values and update the values, before the combobox popups
// popups
ValueComboBox.Items.Text:=NewValue; ValueComboBox.Items.Text:=NewValue;
Exclude(FStates,pgsGetComboItemsCalled); Exclude(FStates,pgsGetComboItemsCalled);
SetIdleEvent(true); SetIdleEvent(true);
@ -1685,9 +1676,8 @@ begin
UpdateScrollBar; UpdateScrollBar;
// reselect // reselect
CurRow:=GetRowByPath(OldSelectedRowPath); CurRow:=GetRowByPath(OldSelectedRowPath);
if CurRow<>nil then begin if CurRow<>nil then
ItemIndex:=CurRow.Index; ItemIndex:=CurRow.Index;
end;
// paint // paint
Invalidate; Invalidate;
end; end;
@ -2469,7 +2459,8 @@ begin
end; end;
procedure TOICustomPropertyGrid.AlignEditComponents; procedure TOICustomPropertyGrid.AlignEditComponents;
var RRect,EditCompRect,EditBtnRect:TRect; var
RRect,EditCompRect,EditBtnRect:TRect;
function CompareRectangles(r1,r2:TRect):boolean; function CompareRectangles(r1,r2:TRect):boolean;
begin begin
@ -2483,7 +2474,7 @@ begin
then begin then begin
RRect := RowRect(ItemIndex); RRect := RowRect(ItemIndex);
EditCompRect := RRect; EditCompRect := RRect;
EditCompRect.Bottom := EditCompRect.Bottom - 1; Dec(EditCompRect.Bottom);
if Layout = oilHorizontal if Layout = oilHorizontal
then begin then begin
@ -2503,9 +2494,8 @@ begin
Right := EditCompRect.Right; Right := EditCompRect.Right;
EditCompRect.Right := Left; EditCompRect.Right := Left;
end; end;
if not CompareRectangles(FCurrentButton.BoundsRect,EditBtnRect) then begin if not CompareRectangles(FCurrentButton.BoundsRect,EditBtnRect) then
FCurrentButton.BoundsRect:=EditBtnRect; FCurrentButton.BoundsRect:=EditBtnRect;
end;
//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
@ -2517,8 +2507,7 @@ begin
if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then begin if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then begin
FCurrentEdit.BoundsRect:=EditCompRect; FCurrentEdit.BoundsRect:=EditCompRect;
if FCurrentEdit is TComboBox then if FCurrentEdit is TComboBox then
TComboBox(FCurrentEdit).ItemHeight:= TComboBox(FCurrentEdit).ItemHeight:=EditCompRect.Bottom-EditCompRect.Top-6;
EditCompRect.Bottom-EditCompRect.Top-6;
FCurrentEdit.Invalidate; FCurrentEdit.Invalidate;
end; end;
end; end;
@ -2552,11 +2541,6 @@ var
ThemeServices.DrawElement(Canvas.Handle, Details, Rect(X, Y, X + Size.cx, Y + Size.cy), nil); ThemeServices.DrawElement(Canvas.Handle, Details, Rect(X, Y, X + Size.cx, Y + Size.cy), nil);
end; end;
procedure DrawActiveRow(X, Y: Integer);
begin
Canvas.Draw(X, Y, FActiveRowBmp);
end;
// PaintRow // PaintRow
begin begin
CurRow := Rows[ARow]; CurRow := Rows[ARow];
@ -2631,9 +2615,8 @@ begin
// draw icon // draw icon
if CanExpandRow(CurRow) then if CanExpandRow(CurRow) then
DrawTreeIcon(IconX, IconY, CurRow.Expanded) DrawTreeIcon(IconX, IconY, CurRow.Expanded)
else else if (ARow = FItemIndex) then
if (ARow = FItemIndex) then Canvas.Draw(IconX, IconY, FActiveRowBmp);
DrawActiveRow(IconX, IconY);
// draw name // draw name
OldFont:=Font; OldFont:=Font;
@ -2749,7 +2732,7 @@ begin
end; end;
end; end;
end end
else begin else begin // Layout <> oilHorizontal
Pen.Style := psSolid; Pen.Style := psSolid;
Pen.Color := cl3DLight; Pen.Color := cl3DLight;
MoveTo(ValueRect.Left, ValueRect.Bottom - 1); MoveTo(ValueRect.Left, ValueRect.Bottom - 1);