mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 14:59:08 +02:00
Object Inspector: Show parenthesis around True and False when using the Checkbox Boolean editor.
git-svn-id: trunk@46989 -
This commit is contained in:
parent
28c049a4c7
commit
8e8d5a2fdf
@ -1329,6 +1329,7 @@ procedure TOICustomPropertyGrid.SetRowValue(CheckFocus: boolean);
|
|||||||
var
|
var
|
||||||
PropKind: TTypeKind;
|
PropKind: TTypeKind;
|
||||||
PropInfo: PPropInfo;
|
PropInfo: PPropInfo;
|
||||||
|
BoolVal: Boolean;
|
||||||
begin
|
begin
|
||||||
Result:='';
|
Result:='';
|
||||||
PropInfo := Editor.GetPropInfo;
|
PropInfo := Editor.GetPropInfo;
|
||||||
@ -1342,8 +1343,13 @@ procedure TOICustomPropertyGrid.SetRowValue(CheckFocus: boolean);
|
|||||||
Result := GetEnumName(PropInfo^.PropType, Editor.GetOrdValueAt(Index));
|
Result := GetEnumName(PropInfo^.PropType, Editor.GetOrdValueAt(Index));
|
||||||
tkFloat:
|
tkFloat:
|
||||||
Result := FloatToStr(Editor.GetFloatValueAt(Index));
|
Result := FloatToStr(Editor.GetFloatValueAt(Index));
|
||||||
tkBool:
|
tkBool: begin
|
||||||
Result := BoolToStr(Boolean(Editor.GetOrdValueAt(Index)), 'True', 'False');
|
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:
|
tkString, tkLString, tkAString, tkUString, tkWString:
|
||||||
Result := Editor.GetStrValueAt(Index);
|
Result := Editor.GetStrValueAt(Index);
|
||||||
tkSet:
|
tkSet:
|
||||||
@ -1575,7 +1581,7 @@ var
|
|||||||
CurRow: TOIPropertyGridRow;
|
CurRow: TOIPropertyGridRow;
|
||||||
begin
|
begin
|
||||||
if (pgsUpdatingEditControl in FStates) or not IsCurrentEditorAvailable then exit;
|
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];
|
CurRow:=Rows[FItemIndex];
|
||||||
if paAutoUpdate in CurRow.Editor.GetAttributes then
|
if paAutoUpdate in CurRow.Editor.GetAttributes then
|
||||||
SetRowValue(true);
|
SetRowValue(true);
|
||||||
@ -1687,7 +1693,7 @@ begin
|
|||||||
FCurrentEdit:=ValueCheckBox;
|
FCurrentEdit:=ValueCheckBox;
|
||||||
ValueCheckBox.Enabled:=not NewRow.IsReadOnly;
|
ValueCheckBox.Enabled:=not NewRow.IsReadOnly;
|
||||||
ValueCheckBox.Caption:=NewValue;
|
ValueCheckBox.Caption:=NewValue;
|
||||||
ValueCheckBox.Checked:=(NewValue='True');
|
ValueCheckBox.Checked:=(NewValue='(True)');
|
||||||
end
|
end
|
||||||
else if paValueList in EditorAttributes then
|
else if paValueList in EditorAttributes then
|
||||||
begin
|
begin
|
||||||
@ -3020,7 +3026,7 @@ begin
|
|||||||
end
|
end
|
||||||
else if FCurrentEdit=ValueCheckBox then begin
|
else if FCurrentEdit=ValueCheckBox then begin
|
||||||
ValueCheckBox.Caption:=NewValue;
|
ValueCheckBox.Caption:=NewValue;
|
||||||
ValueCheckBox.Checked:=NewValue='True';
|
ValueCheckBox.Checked:=NewValue='(True)';
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -447,6 +447,8 @@ type
|
|||||||
Default property editor for all boolean properties }
|
Default property editor for all boolean properties }
|
||||||
|
|
||||||
TBoolPropertyEditor = class(TEnumPropertyEditor)
|
TBoolPropertyEditor = class(TEnumPropertyEditor)
|
||||||
|
private
|
||||||
|
fUseCheckbox: Boolean;
|
||||||
public
|
public
|
||||||
function OrdValueToVisualValue(OrdValue: longint): string; override;
|
function OrdValueToVisualValue(OrdValue: longint): string; override;
|
||||||
procedure GetValues(Proc: TGetStrProc); override;
|
procedure GetValues(Proc: TGetStrProc); override;
|
||||||
@ -3225,6 +3227,8 @@ begin
|
|||||||
Result := 'False'
|
Result := 'False'
|
||||||
else
|
else
|
||||||
Result := 'True';
|
Result := 'True';
|
||||||
|
if fUseCheckbox then
|
||||||
|
Result := '(' + Result + ')';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TBoolPropertyEditor.GetValues(Proc: TGetStrProc);
|
procedure TBoolPropertyEditor.GetValues(Proc: TGetStrProc);
|
||||||
@ -3237,10 +3241,14 @@ procedure TBoolPropertyEditor.SetValue(const NewValue: ansistring);
|
|||||||
var
|
var
|
||||||
I: Integer;
|
I: Integer;
|
||||||
begin
|
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
|
I := 0
|
||||||
else
|
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
|
I := 1
|
||||||
else
|
else
|
||||||
I := StrToInt(NewValue);
|
I := StrToInt(NewValue);
|
||||||
@ -3256,7 +3264,8 @@ var
|
|||||||
Sz: TSize;
|
Sz: TSize;
|
||||||
begin
|
begin
|
||||||
BRect := ARect;
|
BRect := ARect;
|
||||||
if FPropertyHook.GetCheckboxForBoolean then
|
fUseCheckbox := FPropertyHook.GetCheckboxForBoolean;
|
||||||
|
if fUseCheckbox then
|
||||||
begin
|
begin
|
||||||
// Draw the box using theme services.
|
// Draw the box using theme services.
|
||||||
if GetOrdValue <> 0 then
|
if GetOrdValue <> 0 then
|
||||||
|
Loading…
Reference in New Issue
Block a user