fixed readonly of properties

git-svn-id: trunk@4268 -
This commit is contained in:
mattias 2003-06-13 11:58:46 +00:00
parent 83c3371683
commit 56b99b1664
6 changed files with 122 additions and 64 deletions

View File

@ -131,6 +131,7 @@ type
LastPaintedValue:string;
function GetBottom:integer;
function IsReadOnly: boolean;
function IsDisabled: boolean;
public
property Editor:TPropertyEditor read FEditor;
property Top:integer read FTop write FTop;
@ -930,7 +931,7 @@ begin
end;
end;
if FCurrentButton<>nil then
FCurrentButton.Enabled:=not NewRow.IsReadOnly;
FCurrentButton.Enabled:=not NewRow.IsDisabled;
end;
Exclude(FStates,pgsChangingItemIndex);
end;
@ -1886,14 +1887,18 @@ begin
end;
function TOIPropertyGridRow.IsReadOnly: boolean;
begin
Result:=Editor.IsReadOnly or IsDisabled;
end;
function TOIPropertyGridRow.IsDisabled: boolean;
var
ParentRow: TOIPropertyGridRow;
begin
Result:=Editor.IsReadOnly;
if Result then exit;
Result:=false;
ParentRow:=Parent;
while (ParentRow<>nil) do begin
if paReadOnlySubProperties in ParentRow.Editor.GetAttributes then begin
if paDisableSubProperties in ParentRow.Editor.GetAttributes then begin
Result:=true;
exit;
end;

View File

@ -126,7 +126,9 @@ type
paAutoUpdate: Causes the SetValue method to be called on each
change made to the editor instead of after the change
has been approved (e.g. the Caption property).
paReadOnly: Value is not allowed to change.
paReadOnly: Value is not allowed to change. But if paDialog is set
a Dialog can change the value. This disbales only the
edit and combobox in the object inspector.
paRevertable: Allows the property to be reverted to the original
value. Things that shouldn't be reverted are nested
properties (e.g. Fonts) and elements of a composite
@ -135,14 +137,15 @@ type
need to be rendered and as such the name should be
rendered the full width of the inspector.
paVolatileSubProperties: Any change of property value causes any shown
subproperties to be recollected.
paReadOnlySubProperties: All subproperties are readonly.
paReference: Property contains a reference to something else. When
used in conjunction with paSubProperties the referenced
object should be displayed as sub properties to this
property.
paNotNestable: Indicates that the property is not safe to show when
showing the properties of an expanded reference.
subproperties to be recollected.
paDisableSubProperties: All subproperties are readonly
(not even via Dialog).
paReference: property contains a reference to something else. When
used in conjunction with paSubProperties the referenced
object should be displayed as sub properties to this
property.
paNotNestable: Indicates that the property is not safe to show when
showing the properties of an expanded reference.
GetComponent
Returns the Index'th component being edited by this property editor. This
@ -249,7 +252,7 @@ type
paRevertable,
paFullWidthName,
paVolatileSubProperties,
paReadOnlySubProperties,
paDisableSubProperties,
paReference,
paNotNestable
);

View File

@ -503,7 +503,7 @@ type
end;
{ TUpDown }
TUDAlignButton = (udLeft, udRight);
TUDAlignButton = (udLeft, udRight, udTop, udBottom);
TUDOrientation = (udHorizontal, udVertical);
TUDBtnType = (btNext, btPrev);
TUDClickEvent = procedure (Sender: TObject; Button: TUDBtnType) of object;
@ -516,7 +516,6 @@ type
BTimer : TTimer;
BTimerProc : Procedure of Object;
BTimerBounds : TRect;
InheritedChangeBounds,
FArrowKeys: Boolean;
FAssociate: TWinControl;
FMin: SmallInt;
@ -541,10 +540,13 @@ type
procedure SetThousands(Value: Boolean);
procedure SetWrap(Value: Boolean);
Procedure BTimerExec(Sender : TObject);
procedure UpdateUpDownPositionText;
procedure UpdateOrientation;
procedure UpdateAlignButtonPos;
protected
OldKeyDown : TKeyEvent;
Procedure AssociateKeyDown(Sender: TObject; var Key: Word; ShiftState : TShiftState);
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer); Override;
//procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer); Override;
function CanChange: Boolean; dynamic;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Click(Button: TUDBtnType); dynamic; overload;
@ -1758,6 +1760,9 @@ end.
{ =============================================================================
$Log$
Revision 1.75 2003/06/13 11:58:46 mattias
fixed readonly of properties
Revision 1.74 2003/06/10 00:46:16 mattias
fixed aligning controls

View File

@ -58,7 +58,7 @@ begin
//TCustomMemo also inherits from here but it's create changes fcompstyle to csMemo
FCompStyle := csEdit;
FMaxLength:= -1;
Height:=23;
SetInitialBounds(0,0,80,23);
end;
{------------------------------------------------------------------------------
@ -309,6 +309,9 @@ end;
{ =============================================================================
$Log$
Revision 1.17 2003/06/13 11:58:46 mattias
fixed readonly of properties
Revision 1.16 2002/12/27 17:12:37 mattias
added more Delphi win32 compatibility functions

View File

@ -34,7 +34,7 @@ begin
FLines := TMemoStrings.Create(Self);
FVertScrollbar := TMemoScrollBar.Create(Self, sbVertical);
FHorzScrollbar := TMemoScrollBar.Create(Self, sbHorizontal);
SetBounds(0,0,185,90);
SetInitialBounds(0,0,185,90);
end;
{------------------------------------------------------------------------------
@ -159,6 +159,9 @@ end;
{ =============================================================================
$Log$
Revision 1.16 2003/06/13 11:58:46 mattias
fixed readonly of properties
Revision 1.15 2003/04/15 08:54:27 mattias
fixed TMemo.WordWrap

View File

@ -19,6 +19,8 @@ Problems -
- Associate Key down and Tabbing(VK_Up, VK_Down)
}
Type
{ TUpDownButton }
TUpDownButton = Class(TSpeedButton)
Private
FUpDown : TCustomUpDown;
@ -94,7 +96,7 @@ begin
end;
end;
FUpDown.Click(FButtonType);
Click(FButtonType);
end;
end;
@ -110,7 +112,6 @@ begin
ControlStyle := ControlStyle + [csNoFocus];
OnMouseDown := @ButtonMouseDown;
OnMouseUp := @ButtonMouseUp;
Show;
end;
Procedure TUpDownButton.Paint;
@ -189,17 +190,17 @@ begin
end;
end;
{ TCustomUpDown }
constructor TCustomUpDown.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCompStyle := csPanel;
ControlStyle := ControlStyle - [csDoubleClicks] +
[csClickEvents, csOpaque, csReplicatable, csNoFocus];
[csClickEvents, csOpaque, csReplicatable, csNoFocus];
MinBtn := TUpDownButton.CreateWithParams(Self, btPrev);
MaxBtn := TUpDownButton.CreateWithParams(Self, btNext);
InheritedChangeBounds := True;
SetBounds(0,0,17,31);
InheritedChangeBounds := False;
SetInitialBounds(0,0,17,31);
BTimerProc := nil;
BTimerBounds := Rect(0,0,0,0);
FArrowKeys := True;
@ -213,7 +214,6 @@ end;
destructor TCustomUpDown.Destroy;
begin
FAssociate := nil;
InheritedChangeBounds := True;
inherited destroy;
end;
@ -224,7 +224,61 @@ begin
BTimerProc;
end;
procedure TCustomUpDown.ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer);
procedure TCustomUpDown.UpdateUpDownPositionText;
var
str : String;
begin
if (not (csDesigning in ComponentState)) and (FAssociate <> nil) then begin
If Thousands then
Str := FloatToStrF(FPosition, ffNumber, 0, 0)
else
str := IntToStr(FPosition);
FAssociate.SetText(Str);
end;
end;
procedure TCustomUpDown.UpdateOrientation;
begin
If FOrientation = udHorizontal then begin
MinBtn.SetBounds(0,0,ClientWidth div 2,ClientHeight);
MaxBtn.SetBounds(ClientWidth div 2,0,ClientWidth div 2,ClientHeight);
end
else begin
MaxBtn.SetBounds(0,0,ClientWidth,ClientHeight div 2);
MinBtn.SetBounds(0,ClientHeight div 2,ClientWidth,ClientHeight div 2);
end;
end;
procedure TCustomUpDown.UpdateAlignButtonPos;
var
NewWidth: Integer;
NewLeft: Integer;
NewHeight: Integer;
NewTop: Integer;
begin
If Assigned(Associate) then begin
if FAlignButton in [udLeft,udRight] then begin
NewWidth := Width;
NewHeight := Associate.Height;
If FAlignButton = udLeft then
NewLeft := Associate.Left - NewWidth
else
NewLeft := Associate.Left + Associate.Width;
NewTop := Associate.Top;
end else begin
NewWidth := Associate.Width;
NewHeight := Height;
NewLeft := Associate.Left;
If FAlignButton = udTop then
NewTop := Associate.Top - NewHeight
else
NewTop := Associate.Top + Associate.Height;
end;
SetBounds(NewLeft,NewTop,NewWidth,NewHeight);
end;
end;
{procedure TCustomUpDown.ChangeBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
ARect : TRect;
begin
@ -240,7 +294,7 @@ begin
InheritedChangeBounds := False;
Inherited ChangeBounds(ALeft, ATop, AWidth, AHeight);
end;
end;
end;}
Function TCustomUpDown.CanChange: Boolean;
begin
@ -270,7 +324,8 @@ var
end;
begin
if Value <> nil then
// check that no other updown component is associated to the new Associate
if Value <> FAssociate then
for I := 0 to Parent.ControlCount - 1 do
if (Parent.Controls[I] is TCustomUpDown) and
(Parent.Controls[I] <> Self)
@ -279,6 +334,7 @@ begin
raise Exception.CreateFmt(rsIsAlreadyAssociatedWith,
[Value.Name, Parent.Controls[I].Name]);
// disconnect old Associate
if FAssociate <> nil then
begin
FAssociate.OnKeyDown := OldKeyDown;
@ -286,24 +342,26 @@ begin
FAssociate := nil;
end;
if (Value <> nil) and (Value.Parent = Self.Parent) and
not (Value is TCustomUpDown) and
not (Value is TCustomTreeView) and not (Value is TCustomListView)
// connect new Associate
if (Value <> nil) and (Value.Parent = Self.Parent)
and not (Value is TCustomUpDown) and not (Value is TCustomTreeView)
and not (Value is TCustomListView)
then
begin
FAssociate := Value;
SetOrientation(FOrientation);
SetPosition(FPosition);
OldKeyDown := Value.OnKeyDown;
Value.OnKeyDown := @AssociateKeyDown;
Value.SetText(IntToStr(FPosition));
UpdateUpDownPositionText;
UpdateOrientation;
if not (csDesigning in ComponentState) then
OldKeyDown := FAssociate.OnKeyDown;
FAssociate.OnKeyDown := @AssociateKeyDown;
end;
end;
Procedure TCustomUpDown.AssociateKeyDown(Sender: TObject; var Key: Word; ShiftState : TShiftState);
Procedure TCustomUpDown.AssociateKeyDown(Sender: TObject; var Key: Word;
ShiftState : TShiftState);
begin
If Assigned(OldKeyDown) then
OldKeyDown(Sender,Key, ShiftState);
OldKeyDown(Sender,Key,ShiftState);
If ArrowKeys then
If ShiftState = [] then
Case Key of
@ -388,43 +446,24 @@ begin
end;
procedure TCustomUpDown.SetPosition(Value: SmallInt);
var
str : String;
begin
if FPosition = Value then exit;
FPosition := Value;
If Thousands then
Str := FloatToStrF(FPosition, ffNumber, 0, 0)
else
str := IntToStr(FPosition);
if (not (csDesigning in ComponentState)) and (FAssociate <> nil) then
FAssociate.SetText(Str);
UpdateUpDownPositionText;
end;
procedure TCustomUpDown.SetOrientation(Value: TUDOrientation);
begin
if FOrientation = Value then exit;
FOrientation := Value;
If Value = udHorizontal then begin
MinBtn.SetBounds(0,0,Width div 2,Height);
MaxBtn.SetBounds(Width div 2,0,Width div 2, ClientHeight);
end
else begin
MaxBtn.SetBounds(0,0,Width,Height div 2);
MinBtn.SetBounds(0,Height div 2,Width, ClientHeight div 2);
end;
SetAlignButton(FAlignButton);
UpdateOrientation;
end;
procedure TCustomUpDown.SetAlignButton(Value: TUDAlignButton);
begin
if FAlignButton = Value then exit;
FAlignButton := Value;
If assigned(Associate) then begin
If Value = udLeft then
Left := Associate.Left - Width
else
Left := Associate.Left + Associate.Width;
Height := Associate.Height;
Top := Associate.Top;
end;
UpdateAlignButtonPos;
end;
procedure TCustomUpDown.SetArrowKeys(Value: Boolean);