Object Inspector: Show parenthesis around True and False when using the Checkbox Boolean editor.

git-svn-id: trunk@46989 -
This commit is contained in:
juha 2014-11-25 19:48:33 +00:00
parent 28c049a4c7
commit 8e8d5a2fdf
2 changed files with 23 additions and 8 deletions

View File

@ -1329,6 +1329,7 @@ procedure TOICustomPropertyGrid.SetRowValue(CheckFocus: boolean);
var
PropKind: TTypeKind;
PropInfo: PPropInfo;
BoolVal: Boolean;
begin
Result:='';
PropInfo := Editor.GetPropInfo;
@ -1342,8 +1343,13 @@ procedure TOICustomPropertyGrid.SetRowValue(CheckFocus: boolean);
Result := GetEnumName(PropInfo^.PropType, Editor.GetOrdValueAt(Index));
tkFloat:
Result := FloatToStr(Editor.GetFloatValueAt(Index));
tkBool:
Result := BoolToStr(Boolean(Editor.GetOrdValueAt(Index)), 'True', 'False');
tkBool: begin
BoolVal := Boolean(Editor.GetOrdValueAt(Index));
if FCheckboxForBoolean then
Result := BoolToStr(BoolVal, '(True)', '(False)')
else
Result := BoolToStr(BoolVal, 'True', 'False');
end;
tkString, tkLString, tkAString, tkUString, tkWString:
Result := Editor.GetStrValueAt(Index);
tkSet:
@ -1575,7 +1581,7 @@ var
CurRow: TOIPropertyGridRow;
begin
if (pgsUpdatingEditControl in FStates) or not IsCurrentEditorAvailable then exit;
ValueCheckBox.Caption:=BoolToStr(ValueCheckBox.Checked, True); //'True','False';
ValueCheckBox.Caption:=BoolToStr(ValueCheckBox.Checked, '(True)', '(False)');
CurRow:=Rows[FItemIndex];
if paAutoUpdate in CurRow.Editor.GetAttributes then
SetRowValue(true);
@ -1687,7 +1693,7 @@ begin
FCurrentEdit:=ValueCheckBox;
ValueCheckBox.Enabled:=not NewRow.IsReadOnly;
ValueCheckBox.Caption:=NewValue;
ValueCheckBox.Checked:=(NewValue='True');
ValueCheckBox.Checked:=(NewValue='(True)');
end
else if paValueList in EditorAttributes then
begin
@ -3020,7 +3026,7 @@ begin
end
else if FCurrentEdit=ValueCheckBox then begin
ValueCheckBox.Caption:=NewValue;
ValueCheckBox.Checked:=NewValue='True';
ValueCheckBox.Checked:=NewValue='(True)';
end;
end;

View File

@ -447,6 +447,8 @@ type
Default property editor for all boolean properties }
TBoolPropertyEditor = class(TEnumPropertyEditor)
private
fUseCheckbox: Boolean;
public
function OrdValueToVisualValue(OrdValue: longint): string; override;
procedure GetValues(Proc: TGetStrProc); override;
@ -3225,6 +3227,8 @@ begin
Result := 'False'
else
Result := 'True';
if fUseCheckbox then
Result := '(' + Result + ')';
end;
procedure TBoolPropertyEditor.GetValues(Proc: TGetStrProc);
@ -3237,10 +3241,14 @@ procedure TBoolPropertyEditor.SetValue(const NewValue: ansistring);
var
I: Integer;
begin
if (CompareText(NewValue, 'False') = 0) or (CompareText(NewValue, 'F') = 0) then
if (CompareText(NewValue, 'False') = 0)
or (CompareText(NewValue, '(False)') = 0)
or (CompareText(NewValue, 'F') = 0) then
I := 0
else
if (CompareText(NewValue, 'True') = 0) or (CompareText(NewValue, 'T') = 0) then
if (CompareText(NewValue, 'True') = 0)
or (CompareText(NewValue, '(True)') = 0)
or (CompareText(NewValue, 'T') = 0) then
I := 1
else
I := StrToInt(NewValue);
@ -3256,7 +3264,8 @@ var
Sz: TSize;
begin
BRect := ARect;
if FPropertyHook.GetCheckboxForBoolean then
fUseCheckbox := FPropertyHook.GetCheckboxForBoolean;
if fUseCheckbox then
begin
// Draw the box using theme services.
if GetOrdValue <> 0 then