mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 19:09:19 +02:00
MG: fixed streaming visible=false
git-svn-id: trunk@1412 -
This commit is contained in:
parent
6df3b96306
commit
92d57158d6
@ -127,6 +127,7 @@ type
|
|||||||
paFullWidthName:Tells the object inspector that the value does not
|
paFullWidthName:Tells the object inspector that the value does not
|
||||||
need to be rendered and as such the name should be
|
need to be rendered and as such the name should be
|
||||||
rendered the full width of the inspector.
|
rendered the full width of the inspector.
|
||||||
|
|
||||||
GetComponent
|
GetComponent
|
||||||
Returns the Index'th component being edited by this property editor. This
|
Returns the Index'th component being edited by this property editor. This
|
||||||
is used to retrieve the components. A property editor can only refer to
|
is used to retrieve the components. A property editor can only refer to
|
||||||
@ -256,10 +257,11 @@ type
|
|||||||
|
|
||||||
TPropertyEditor=class
|
TPropertyEditor=class
|
||||||
private
|
private
|
||||||
FPropertyHook:TPropertyEditorHook;
|
|
||||||
FComponents:TComponentSelectionList;
|
FComponents:TComponentSelectionList;
|
||||||
FPropList:PInstPropList;
|
FOnSubPropertiesChanged: TNotifyEvent;
|
||||||
|
FPropertyHook:TPropertyEditorHook;
|
||||||
FPropCount:Integer;
|
FPropCount:Integer;
|
||||||
|
FPropList:PInstPropList;
|
||||||
function GetPrivateDirectory:ansistring;
|
function GetPrivateDirectory:ansistring;
|
||||||
protected
|
protected
|
||||||
function GetPropInfo:PPropInfo;
|
function GetPropInfo:PPropInfo;
|
||||||
@ -318,10 +320,14 @@ type
|
|||||||
AState:TPropEditDrawState); dynamic;
|
AState:TPropEditDrawState); dynamic;
|
||||||
procedure PropDrawValue(ACanvas:TCanvas; const ARect:TRect;
|
procedure PropDrawValue(ACanvas:TCanvas; const ARect:TRect;
|
||||||
AState:TPropEditDrawState); dynamic;
|
AState:TPropEditDrawState); dynamic;
|
||||||
|
procedure UpdateSubProperties; virtual;
|
||||||
|
function SubPropertiesNeedsUpdate: boolean; virtual;
|
||||||
property PropertyHook:TPropertyEditorHook read FPropertyHook;
|
property PropertyHook:TPropertyEditorHook read FPropertyHook;
|
||||||
property PrivateDirectory:ansistring read GetPrivateDirectory;
|
property PrivateDirectory:ansistring read GetPrivateDirectory;
|
||||||
property PropCount:Integer read FPropCount;
|
property PropCount:Integer read FPropCount;
|
||||||
property FirstValue:ansistring read GetValue write SetValue;
|
property FirstValue:ansistring read GetValue write SetValue;
|
||||||
|
property OnSubPropertiesChanged: TNotifyEvent
|
||||||
|
read FOnSubPropertiesChanged write FOnSubPropertiesChanged;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TPropertyEditorClass=class of TPropertyEditor;
|
TPropertyEditorClass=class of TPropertyEditor;
|
||||||
@ -453,17 +459,30 @@ type
|
|||||||
function GetValue: AnsiString; override;
|
function GetValue: AnsiString; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCustomListPropertyEditor
|
{ TListPropertyEditor
|
||||||
}
|
UNDER CONSTRUCTION by Mattias}
|
||||||
TCustomListPropertyEditor = class(TPropertyEditor)
|
TListPropertyEditor = class(TPropertyEditor)
|
||||||
|
private
|
||||||
|
FSaveElementLock: integer;
|
||||||
|
FSubPropertiesChanged: boolean;
|
||||||
protected
|
protected
|
||||||
function GetListName: AnsiString; virtual;
|
OldList: TObject;
|
||||||
|
OldElements: TList;
|
||||||
function GetElementCount: integer; virtual;
|
function GetElementCount: integer; virtual;
|
||||||
function GetElement(Index: integer): TPropertyEditor; virtual;
|
function GetElement(Index: integer): TObject; virtual;
|
||||||
|
function GetElementPropertyEditor(Index: integer): TPropertyEditor; virtual;
|
||||||
|
procedure BeginSaveElement;
|
||||||
|
procedure EndSaveElement;
|
||||||
|
property SaveElementLock: integer read FSaveElementLock;
|
||||||
public
|
public
|
||||||
|
constructor Create(Hook:TPropertyEditorHook;
|
||||||
|
ComponentList: TComponentSelectionList; APropCount:Integer); override;
|
||||||
|
destructor Destroy; override;
|
||||||
function GetAttributes: TPropertyAttributes; override;
|
function GetAttributes: TPropertyAttributes; override;
|
||||||
procedure GetProperties(Proc: TGetPropEditProc); override;
|
procedure GetProperties(Proc: TGetPropEditProc); override;
|
||||||
function GetValue: AnsiString; override;
|
function GetValue: AnsiString; override;
|
||||||
|
procedure SaveElements; virtual;
|
||||||
|
function SubPropertiesNeedsUpdate: boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TClassPropertyEditor
|
{ TClassPropertyEditor
|
||||||
@ -725,6 +744,11 @@ procedure GetComponentProperties(PropertyEditorHook:TPropertyEditorHook;
|
|||||||
function GetEditorClass(PropInfo:PPropInfo;
|
function GetEditorClass(PropInfo:PPropInfo;
|
||||||
Obj:TPersistent): TPropertyEditorClass;
|
Obj:TPersistent): TPropertyEditorClass;
|
||||||
|
|
||||||
|
//==============================================================================
|
||||||
|
|
||||||
|
procedure RegisterListPropertyEditor(AnEditor: TListPropertyEditor);
|
||||||
|
procedure UnregisterListPropertyEditor(AnEditor: TListPropertyEditor);
|
||||||
|
procedure UpdateListPropertyEditors(AnObject: TObject);
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
{
|
{
|
||||||
@ -959,6 +983,37 @@ implementation
|
|||||||
|
|
||||||
uses Dialogs, ColumnDlg;
|
uses Dialogs, ColumnDlg;
|
||||||
|
|
||||||
|
const
|
||||||
|
ListPropertyEditors: TList = nil;
|
||||||
|
|
||||||
|
procedure RegisterListPropertyEditor(AnEditor: TListPropertyEditor);
|
||||||
|
begin
|
||||||
|
if ListPropertyEditors=nil then
|
||||||
|
ListPropertyEditors:=TList.Create;
|
||||||
|
ListPropertyEditors.Add(AnEditor);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure UnregisterListPropertyEditor(AnEditor: TListPropertyEditor);
|
||||||
|
begin
|
||||||
|
if ListPropertyEditors=nil then exit;
|
||||||
|
ListPropertyEditors.Remove(AnEditor);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure UpdateListPropertyEditors(AnObject: TObject);
|
||||||
|
var
|
||||||
|
i: integer;
|
||||||
|
Editor: TListPropertyEditor;
|
||||||
|
begin
|
||||||
|
if ListPropertyEditors=nil then exit;
|
||||||
|
for i:=0 to ListPropertyEditors.Count-1 do begin
|
||||||
|
Editor:=TListPropertyEditor(ListPropertyEditors[i]);
|
||||||
|
if (Editor.GetComponent(0)=AnObject)
|
||||||
|
and (Editor.OnSubPropertiesChanged<>nil) then
|
||||||
|
Editor.UpdateSubProperties;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
const
|
const
|
||||||
{ TypeKinds see typinfo.pp
|
{ TypeKinds see typinfo.pp
|
||||||
@ -1689,6 +1744,17 @@ begin
|
|||||||
ACanvas.TextRect(ARect, 3,0,GetVisualValue, Style);
|
ACanvas.TextRect(ARect, 3,0,GetVisualValue, Style);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TPropertyEditor.UpdateSubProperties;
|
||||||
|
begin
|
||||||
|
if (OnSubPropertiesChanged<>nil) and SubPropertiesNeedsUpdate then
|
||||||
|
OnSubPropertiesChanged(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TPropertyEditor.SubPropertiesNeedsUpdate: boolean;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TOrdinalPropertyEditor }
|
{ TOrdinalPropertyEditor }
|
||||||
|
|
||||||
function TOrdinalPropertyEditor.AllEqual: Boolean;
|
function TOrdinalPropertyEditor.AllEqual: Boolean;
|
||||||
@ -2075,38 +2141,127 @@ begin
|
|||||||
Result := Result + ']';
|
Result := Result + ']';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TCustomListPropertyEditor }
|
{ TListPropertyEditor }
|
||||||
|
|
||||||
function TCustomListPropertyEditor.GetListName: AnsiString;
|
function TListPropertyEditor.GetElementCount: integer;
|
||||||
begin
|
var
|
||||||
Result:='';
|
TheList: TList;
|
||||||
end;
|
|
||||||
|
|
||||||
function TCustomListPropertyEditor.GetElementCount: integer;
|
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
|
TheList:=TList(GetComponent(0));
|
||||||
|
if (TheList<>nil) and (TheList is TList) then
|
||||||
|
Result:=TheList.Count
|
||||||
|
else
|
||||||
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomListPropertyEditor.GetElement(Index: integer): TPropertyEditor;
|
function TListPropertyEditor.GetElement(Index: integer): TObject;
|
||||||
|
var
|
||||||
|
TheList: TList;
|
||||||
|
ElementCount: integer;
|
||||||
|
TheObject: TObject;
|
||||||
|
begin
|
||||||
|
Result:=nil;
|
||||||
|
if (Index<0) then
|
||||||
|
raise Exception('TListPropertyEditor.GetElement Index='+IntToStr(Index));
|
||||||
|
ElementCount:=GetElementCount;
|
||||||
|
if Index>=ElementCount then
|
||||||
|
raise Exception('TListPropertyEditor.GetElement Index='+IntToStr(Index)
|
||||||
|
+' Count='+IntToStr(ElementCount));
|
||||||
|
TheList:=TList(GetComponent(0));
|
||||||
|
if (TheList<>nil) and (TheList is TList) then
|
||||||
|
TheObject:=TObject(TheList[Index])
|
||||||
|
else
|
||||||
|
TheObject:=nil;
|
||||||
|
if TheObject<>nil then begin
|
||||||
|
// create a corresponding TPropertyEditor
|
||||||
|
|
||||||
|
end else begin
|
||||||
|
// create a TNilPropertyEditor
|
||||||
|
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TListPropertyEditor.GetElementPropertyEditor(Index: integer
|
||||||
|
): TPropertyEditor;
|
||||||
begin
|
begin
|
||||||
Result:=nil;
|
Result:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomListPropertyEditor.GetAttributes: TPropertyAttributes;
|
procedure TListPropertyEditor.SaveElements;
|
||||||
|
var
|
||||||
|
i, ElementCount: integer;
|
||||||
|
begin
|
||||||
|
if SaveElementLock>0 then exit;
|
||||||
|
BeginSaveElement;
|
||||||
|
OldList:=GetComponent(0);
|
||||||
|
ElementCount:=GetElementCount;
|
||||||
|
OldElements.Count:=ElementCount;
|
||||||
|
for i:=0 to ElementCount-1 do
|
||||||
|
OldElements[i]:=GetElement(i);
|
||||||
|
FSubPropertiesChanged:=true;
|
||||||
|
EndSaveElement;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TListPropertyEditor.SubPropertiesNeedsUpdate: boolean;
|
||||||
|
var i: integer;
|
||||||
|
begin
|
||||||
|
Result:=true;
|
||||||
|
if FSubPropertiesChanged then exit;
|
||||||
|
FSubPropertiesChanged:=true;
|
||||||
|
if OldList<>GetComponent(0) then exit;
|
||||||
|
if GetElementCount<>OldElements.Count then exit;
|
||||||
|
for i:=0 to OldElements.Count-1 do
|
||||||
|
if TObject(OldElements[i])<>GetElement(i) then exit;
|
||||||
|
Result:=false;
|
||||||
|
FSubPropertiesChanged:=false;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TListPropertyEditor.BeginSaveElement;
|
||||||
|
begin
|
||||||
|
inc(FSaveElementLock);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TListPropertyEditor.EndSaveElement;
|
||||||
|
begin
|
||||||
|
dec(FSaveElementLock);
|
||||||
|
if FSaveElementLock<0 then
|
||||||
|
writeln('TListPropertyEditor.EndSaveElement ERROR: FSaveElementLock=',FSaveElementLock);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TListPropertyEditor.Create(Hook: TPropertyEditorHook;
|
||||||
|
ComponentList: TComponentSelectionList; APropCount: Integer);
|
||||||
|
begin
|
||||||
|
inherited Create(Hook, ComponentList, APropCount);
|
||||||
|
OldElements:=TList.Create;
|
||||||
|
if (ComponentList<>nil) and (ComponentList.Count=1) then
|
||||||
|
RegisterListPropertyEditor(Self);
|
||||||
|
SaveElements;
|
||||||
|
end;
|
||||||
|
|
||||||
|
destructor TListPropertyEditor.Destroy;
|
||||||
|
begin
|
||||||
|
UnregisterListPropertyEditor(Self);
|
||||||
|
FreeAndNil(OldElements);
|
||||||
|
inherited Destroy;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TListPropertyEditor.GetAttributes: TPropertyAttributes;
|
||||||
begin
|
begin
|
||||||
Result:= [paSubProperties, paReadOnly];
|
Result:= [paSubProperties, paReadOnly];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TCustomListPropertyEditor.GetProperties(Proc: TGetPropEditProc);
|
procedure TListPropertyEditor.GetProperties(Proc: TGetPropEditProc);
|
||||||
var
|
var
|
||||||
i, ElementCount: integer;
|
i, ElementCount: integer;
|
||||||
begin
|
begin
|
||||||
|
SaveElements;
|
||||||
ElementCount:=GetElementCount;
|
ElementCount:=GetElementCount;
|
||||||
for i:=0 to ElementCount-1 do
|
for i:=0 to ElementCount-1 do
|
||||||
Proc(GetElement(i));
|
Proc(GetElementPropertyEditor(i));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TCustomListPropertyEditor.GetValue: AnsiString;
|
function TListPropertyEditor.GetValue: AnsiString;
|
||||||
var
|
var
|
||||||
ElementCount: integer;
|
ElementCount: integer;
|
||||||
begin
|
begin
|
||||||
@ -3511,6 +3666,8 @@ begin
|
|||||||
end;
|
end;
|
||||||
PropertyClassList.Free;
|
PropertyClassList.Free;
|
||||||
PropertyClassList:=nil;
|
PropertyClassList:=nil;
|
||||||
|
|
||||||
|
FreeAndNil(ListPropertyEditors);
|
||||||
|
|
||||||
// XXX workaround for missing typeinfo function
|
// XXX workaround for missing typeinfo function
|
||||||
DummyClassForPropTypes.Free;
|
DummyClassForPropTypes.Free;
|
||||||
|
Loading…
Reference in New Issue
Block a user