reduced overhead on updating OI combobox

git-svn-id: trunk@6841 -
This commit is contained in:
mattias 2005-02-25 17:44:30 +00:00
parent ea81fad7e7
commit 383be2bf12

View File

@ -171,6 +171,7 @@ type
FIndent: integer; FIndent: integer;
FItemIndex: integer; FItemIndex: integer;
FNameFont, FDefaultValueFont, FValueFont: TFont; FNameFont, FDefaultValueFont, FValueFont: TFont;
FNewComboBoxItems: TStringList;
FOnModified: TNotifyEvent; FOnModified: TNotifyEvent;
FPreferredSplitterX: integer; // best splitter position FPreferredSplitterX: integer; // best splitter position
FPropertyEditorHook: TPropertyEditorHook; FPropertyEditorHook: TPropertyEditorHook;
@ -673,6 +674,7 @@ begin
FreeAndNil(FExpandedProperties); FreeAndNil(FExpandedProperties);
FreeAndNil(FHintTimer); FreeAndNil(FHintTimer);
FreeAndNil(FHintWindow); FreeAndNil(FHintWindow);
FreeAndNil(FNewComboBoxItems);
inherited Destroy; inherited Destroy;
end; end;
@ -900,8 +902,9 @@ begin
if OldValue<>NewValue then begin if OldValue<>NewValue then begin
if FCurrentEdit=ValueEdit then if FCurrentEdit=ValueEdit then
ValueEdit.Text:=NewValue ValueEdit.Text:=NewValue
else else begin
ValueComboBox.Text:=NewValue; FillComboboxItems;
end;
end; end;
end; end;
end; end;
@ -1092,12 +1095,11 @@ begin
end; end;
end; end;
procedure TOICustomPropertyGrid.AddStringToComboBox(const s:string); procedure TOICustomPropertyGrid.AddStringToComboBox(const s: string);
var NewIndex:integer;
begin begin
NewIndex:=ValueComboBox.Items.Add(s); if FNewComboBoxItems=nil then
if ValueComboBox.Text=s then FNewComboBoxItems:=TStringList.Create;
ValueComboBox.ItemIndex:=NewIndex; FNewComboBoxItems.Add(s);
end; end;
procedure TOICustomPropertyGrid.ExpandRow(Index:integer); procedure TOICustomPropertyGrid.ExpandRow(Index:integer);
@ -1198,17 +1200,29 @@ procedure TOICustomPropertyGrid.FillComboboxItems;
var var
NewRow: TOIPropertyGridRow; NewRow: TOIPropertyGridRow;
NewValue: String; NewValue: String;
NewItemIndex: LongInt;
begin begin
NewRow:=Rows[FItemIndex]; NewRow:=Rows[FItemIndex];
NewValue:=NewRow.Editor.GetVisualValue; NewValue:=NewRow.Editor.GetVisualValue;
ValueComboBox.MaxLength:=NewRow.Editor.GetEditLimit; ValueComboBox.MaxLength:=NewRow.Editor.GetEditLimit;
ValueComboBox.Items.BeginUpdate; ValueComboBox.Items.BeginUpdate;
ValueComboBox.Items.Text:='';
ValueComboBox.Items.Clear;
ValueComboBox.Sorted:=paSortList in NewRow.Editor.GetAttributes; ValueComboBox.Sorted:=paSortList in NewRow.Editor.GetAttributes;
ValueComboBox.Enabled:=not NewRow.IsReadOnly; ValueComboBox.Enabled:=not NewRow.IsReadOnly;
NewRow.Editor.GetValues(@AddStringToComboBox); NewRow.Editor.GetValues(@AddStringToComboBox);
if FNewComboBoxItems<>nil then begin
FNewComboBoxItems.Sorted:=paSortList in NewRow.Editor.GetAttributes;
if not ValueComboBox.Items.Equals(FNewComboBoxItems) then begin
ValueComboBox.Items.Assign(FNewComboBoxItems);
end;
FreeAndNil(FNewComboBoxItems);
end else begin
ValueComboBox.Items.Text:='';
ValueComboBox.Items.Clear;
end;
ValueComboBox.Text:=NewValue; ValueComboBox.Text:=NewValue;
NewItemIndex:=ValueComboBox.Items.IndexOf(NewValue);
if NewItemIndex>=0 then
ValueComboBox.ItemIndex:=NewItemIndex;
ValueComboBox.Items.EndUpdate; ValueComboBox.Items.EndUpdate;
end; end;